📄 games_highscore.c
字号:
#ifdef __cplusplus
extern "C" {
#endif
/*==================================================================================================
MODULE NAME : module-filename.c
GENERAL DESCRIPTION
General description of this grouping of functions.
TECHFAITH Telecom Confidential Proprietary
(c) Copyright 2002 by TECHFAITH Telecom Corp. All Rights Reserved.
====================================================================================================
Revision History
Modification Tracking
Date Author Number Description of changes
---------- -------------- --------- -----------------------------------------------------------------------------------
MM/DD/YYYY name of author crxxxxx Brief description of changes made
03/03/2002 Steven Lai PP00132 Change some popup timer from absolute number to default value
03/01/2003 Steven Lai PC00009 Restructure Games app
03/21/2003 Steven Lai P000002 Fix the bug in game highscore that cannot receive key event
if we close the flip when there is an popup dialog
04/25/2003 Steven Lai P000166 Change the default focused item of the highscore list, to
let there is no item be highlighted
03-06-3 Chenyu P00502 Fix game tetris
03-06-16 Chenyu P00610 Game highscore cannot exit correctly
03-06-24 Chenyu P00666 Fix bugs of games
- 1.in game cargador, missed call will stop animation.
- 2.in game help incoming missed call, softkey display wrong.
- 3.it can't exit highscroe by press "Back"
- 4.it can't back exit game by press "CLR"
07/02/2003 Steven Lai C000662 Add a sound-switch for Games App
replace all the App_change_state() with Games_change_state()
fixed some bugs
08/08/2003 Steven Lai P001115 Fixed some mistakes in judgement statements.
08/08/2003 zhangxiaodong P add the pen operator
10/23/2003 P001823 highsocre left softkey is invalid
04/16/2004 caoyanqing c003008 add the corresponding part of fruit_game app.
06/18/2004 lixingbo p006238 Modify some bugs for lotus about highscore.
Self-documenting Code
Describe/explain low-level design of this module and/or group of funtions and/or specific
funtion that are hard to understand by reading code and thus requires detail description.
Free format !
====================================================================================================
INCLUDE FILES
==================================================================================================*/
#include <stdlib.h>
#include "APP_include.h"
#include "MENU_main.h"
#include "MENU_display.h"
#include "MENU_item.h"
#include "uhapi.h"
#include "MENU_main.h"
#include "GAMES_main.h"
#include "product.h"
#include "TP_Operator.h"
/*==================================================================================================
LOCAL FUNCTION PROTOTYPES
==================================================================================================*/
void Games_Highscore_entry(void);
void Games_Highscore_exit(void);
void Games_Highscore_Handler
(
OPUS_EVENT_ENUM_TYPE event,
void *pMess,
OP_BOOLEAN *handle
);
static void Games_Highscore_Init(void);
static void Games_Highscore_List_create(RM_RESOURCE_ID_T title_id, RM_RESOURCE_ID_T *item_id);
static OP_BOOLEAN highscore_popup_confirm_handler
(
DS_POPUP_STATE_ENUM_T state,
OP_INT32 event
);
static OP_BOOLEAN highscore_set_default(void);
/*==================================================================================================
LOCAL CONSTANTS
==================================================================================================*/
#define MAX_HIGH_SCORE_RECORDS 5
/*==================================================================================================
LOCAL TYPEDEFS - Structure, Union, Enumerations...etc
==================================================================================================*/
/*
* description of this structure, if needed. - Remember self documenting code
*/
/*==================================================================================================
LOCAL MACROS
==================================================================================================*/
/*
* description of this macro, if needed. - Remember self documenting code
*/
/*==================================================================================================
LOCAL VARIABLES
==================================================================================================*/
#ifdef GAMES_GOPHER
RM_RESOURCE_ID_T gopher_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_GOPHER_SCORE1,
FEATURE_GAME_GOPHER_SCORE2,
FEATURE_GAME_GOPHER_SCORE3,
FEATURE_GAME_GOPHER_SCORE4,
FEATURE_GAME_GOPHER_SCORE5,
};
#endif
#ifdef GAMES_FALLBALL
RM_RESOURCE_ID_T fallball_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_GOPHER_SCORE1,
FEATURE_GAME_GOPHER_SCORE2,
FEATURE_GAME_GOPHER_SCORE3,
FEATURE_GAME_GOPHER_SCORE4,
FEATURE_GAME_GOPHER_SCORE5,
};
#endif
#ifdef GAMES_HUARONG
RM_RESOURCE_ID_T huarong_map1_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_HUARONG_MAP1_SCORE1,
FEATURE_GAME_HUARONG_MAP1_SCORE2,
FEATURE_GAME_HUARONG_MAP1_SCORE3,
FEATURE_GAME_HUARONG_MAP1_SCORE4,
FEATURE_GAME_HUARONG_MAP1_SCORE5,
};
RM_RESOURCE_ID_T huarong_map2_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_HUARONG_MAP2_SCORE1,
FEATURE_GAME_HUARONG_MAP2_SCORE2,
FEATURE_GAME_HUARONG_MAP2_SCORE3,
FEATURE_GAME_HUARONG_MAP2_SCORE4,
FEATURE_GAME_HUARONG_MAP2_SCORE5,
};
RM_RESOURCE_ID_T huarong_map3_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_HUARONG_MAP3_SCORE1,
FEATURE_GAME_HUARONG_MAP3_SCORE2,
FEATURE_GAME_HUARONG_MAP3_SCORE3,
FEATURE_GAME_HUARONG_MAP3_SCORE4,
FEATURE_GAME_HUARONG_MAP3_SCORE5,
};
RM_RESOURCE_ID_T huarong_map4_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_HUARONG_MAP4_SCORE1,
FEATURE_GAME_HUARONG_MAP4_SCORE2,
FEATURE_GAME_HUARONG_MAP4_SCORE3,
FEATURE_GAME_HUARONG_MAP4_SCORE4,
FEATURE_GAME_HUARONG_MAP4_SCORE5,
};
#endif
#ifdef GAMES_LIGHTUP
RM_RESOURCE_ID_T lightup_3_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_LIGHTUP_3_SCORE1,
FEATURE_GAME_LIGHTUP_3_SCORE2,
FEATURE_GAME_LIGHTUP_3_SCORE3,
FEATURE_GAME_LIGHTUP_3_SCORE4,
FEATURE_GAME_LIGHTUP_3_SCORE5,
};
RM_RESOURCE_ID_T lightup_4_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_LIGHTUP_4_SCORE1,
FEATURE_GAME_LIGHTUP_4_SCORE2,
FEATURE_GAME_LIGHTUP_4_SCORE3,
FEATURE_GAME_LIGHTUP_4_SCORE4,
FEATURE_GAME_LIGHTUP_4_SCORE5,
};
RM_RESOURCE_ID_T lightup_5_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_LIGHTUP_5_SCORE1,
FEATURE_GAME_LIGHTUP_5_SCORE2,
FEATURE_GAME_LIGHTUP_5_SCORE3,
FEATURE_GAME_LIGHTUP_5_SCORE4,
FEATURE_GAME_LIGHTUP_5_SCORE5,
};
#endif
#ifdef GAMES_TETRIS
RM_RESOURCE_ID_T tetris_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_STARWAR_SCORE1,
FEATURE_GAME_STARWAR_SCORE2,
FEATURE_GAME_STARWAR_SCORE3,
FEATURE_GAME_STARWAR_SCORE4,
FEATURE_GAME_STARWAR_SCORE5,
};
#endif
#ifdef GAMES_STARWAR
RM_RESOURCE_ID_T starwar_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_STARWAR_SCORE1,
FEATURE_GAME_STARWAR_SCORE2,
FEATURE_GAME_STARWAR_SCORE3,
FEATURE_GAME_STARWAR_SCORE4,
FEATURE_GAME_STARWAR_SCORE5,
};
#endif
#ifdef GAMES_FRUIT
RM_RESOURCE_ID_T fruit_items[MAX_HIGH_SCORE_RECORDS]=
{
FEATURE_GAME_FRUIT_SCORE1,
FEATURE_GAME_FRUIT_SCORE2,
FEATURE_GAME_FRUIT_SCORE3,
FEATURE_GAME_FRUIT_SCORE4,
FEATURE_GAME_FRUIT_SCORE5,
};
#endif
static OP_UINT8 text_str[DS_SCRN_MAX_UC_LEN*DS_SCRN_CHIGH+2];
static OP_BOOLEAN is_dialog_alive = OP_FALSE;
static OP_BOOLEAN is_yes;
static OP_BOOLEAN is_list_empty;
/*==================================================================================================
GLOBAL VARIABLES
==================================================================================================*/
extern APP_GAMES_STRUCTURE_NAME_T gamesApp_data;
extern APP_SUBSTATE_STRUCTURE_NAME_T games_substate;
/*==================================================================================================
LOCAL FUNCTIONS
==================================================================================================*/
/*==================================================================================================
FUNCTION: Games_Game_help_entry
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
void Games_Highscore_entry(void)
{
Games_Highscore_Init();
LIST_build_ds_lines(&display_list_buffer, BUILD_ALL);
ds_refresh();
}
/*==================================================================================================
FUNCTION: Games_Highscore_exit
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
void Games_Highscore_exit(void)
{
}
/*==================================================================================================
FUNCTION: Games_Highscore_Handler
DESCRIPTION:
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
void Games_Highscore_Handler
(
OPUS_EVENT_ENUM_TYPE event,
void *pMess,
OP_BOOLEAN *handle
)
{
KEYEVENT_STRUCT *key;
*handle = OP_TRUE;
key = (KEYEVENT_STRUCT *)pMess;
switch (event)
{
case OPUS_FOCUS_CUST_PAINT:
if ( (pMess != OP_NULL) && (*((OP_BOOLEAN *)pMess) == OP_TRUE))
{
Games_Highscore_entry();
if (is_dialog_alive==OP_TRUE)
{
gamesApp_data.popupwin = ds_popup_dialog_rm(PMPT_COM_NULL_STRING,
PMPT_TEXT_CLEAR,
highscore_popup_confirm_handler);
}
}
ds_refresh();
break;
case OPUS_FOCUS_CUST_APP_PAUSE:
if (ds_pass_event_to_popup(gamesApp_data.popupwin, event, pMess)
== POPUP_CLOSE )
{
gamesApp_data.popupwin = OP_NULL;
}
break;
case OPUS_FOCUS_KEYPAD:
if(key->state != UHKEY_PRESS)
break;
if(is_dialog_alive)
{
if(ds_pass_event_to_popup(gamesApp_data.popupwin, OPUS_FOCUS_KEYPAD, pMess) == POPUP_CLOSE)
{
if (is_yes == OP_TRUE)
{
if (highscore_set_default()==OP_SUCCESS)
{
gamesApp_data.popupwin = ds_popup_message_rm( PMPT_COM_NULL_STRING,
PMPT_MSG_CLEARED,
DS_POPUP_DEFAULT_MSG_TIME);
}
else
{
gamesApp_data.popupwin = ds_popup_message_rm( PMPT_COM_NULL_STRING,
PMPT_MSG_CLEAR_FAILED,
DS_POPUP_DEFAULT_MSG_TIME);
}
is_yes = OP_FALSE;
}
else
{
gamesApp_data.popupwin =OP_NULL;
}
is_dialog_alive = OP_FALSE;
Games_Highscore_entry();
}
break;
}
if(gamesApp_data.popupwin !=OP_NULL)
{
close_old_popup() ;
Games_Highscore_entry();
break;
}
switch (key->code)
{
case KEY_SOFT_RIGHT:
case KEY_CLEAR:
Games_change_state((OP_UINT8) APP_GAMES_STATE_MENU);
break;
case KEY_SOFT_LEFT:
if (!is_list_empty)
{
gamesApp_data.popupwin = ds_popup_dialog_rm(PMPT_COM_NULL_STRING,
PMPT_TEXT_CLEAR,
highscore_popup_confirm_handler);
is_dialog_alive = OP_TRUE;
}
break;
default:
break;
}
break;
case OPUS_TIMER_POPUP_MSG:
if (gamesApp_data.popupwin != OP_NULL)
{
close_old_popup();
}
Games_Highscore_entry();
break;
/*
*
* attention: need test on the phone
*/
case OPUS_FOCUS_OPERATION:
{
TPO_OPERATION_PARAM_STRUCTURE_T *pOp;
pOp = (TPO_OPERATION_PARAM_STRUCTURE_T *)pMess;
if(is_dialog_alive)
{
if(ds_pass_event_to_popup(gamesApp_data.popupwin, OPUS_FOCUS_OPERATION, pMess) == POPUP_CLOSE)
{
if (is_yes == OP_TRUE)
{
if (highscore_set_default()==OP_SUCCESS)
{
gamesApp_data.popupwin = ds_popup_message_rm( PMPT_COM_NULL_STRING,
PMPT_MSG_CLEARED,
DS_POPUP_DEFAULT_MSG_TIME);
}
else
{
gamesApp_data.popupwin = ds_popup_message_rm( PMPT_COM_NULL_STRING,
PMPT_MSG_CLEAR_FAILED,
DS_POPUP_DEFAULT_MSG_TIME);
}
is_yes = OP_FALSE;
}
else
{
gamesApp_data.popupwin =OP_NULL;
}
is_dialog_alive = OP_FALSE;
Games_Highscore_entry();
}
break;
}
if(gamesApp_data.popupwin !=OP_NULL)
{
close_old_popup() ;
Games_Highscore_entry();
break;
}
if(OPERATION_ID_SK_CONFIRM == pOp->op )
{
switch (pOp->id)
{
case COMMAND_SOFTKEY_RIGHT:
Games_change_state((OP_UINT8) APP_GAMES_STATE_MENU);
break;
case COMMAND_SOFTKEY_LEFT:
if (!is_list_empty)
{
gamesApp_data.popupwin = ds_popup_dialog_rm(PMPT_COM_NULL_STRING,
PMPT_TEXT_CLEAR,
highscore_popup_confirm_handler);
is_dialog_alive = OP_TRUE;
}
break;
default:
break;
}
}
}
break;
default:
*handle = OP_FALSE;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -