📄 games_cargador.c
字号:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static void APP_Cargador_select(void)
{
EDITOR_INFO_PARA_STRUCTURE_NAME_T *param ;
param = op_new(EDITOR_INFO_PARA_STRUCTURE_NAME_T);
op_memset(param,0x00,sizeof(EDITOR_INFO_PARA_STRUCTURE_NAME_T));
op_memset((void*)select_level_editor.digits, 0, DS_SCRN_POPUP_MAX_UC_LEN+2);
param->app_id = APP_GAMES;
param->mode = EDIT_IME_DIGITAL|EDIT_IME_SELECT_FORBID;
param->attribute = EDITOR_TYPE_FIGURE_RANGE_LTD;
param->editor_type = EDITOR_TYPE_FULLSCRN;
param->format = OP_NULL;
param->bOneline = OP_TRUE;
param->min_num = (OP_UINT16)1;
param->max_num = (OP_UINT16)80;
param->max_len = 2;
param->min_len = 1;
param->edit_buffer = level_buffer;
if (IS_NOT_NULL_STRING(level_buffer))
{
param->preset = level_buffer;
}
param->presetlen = 2;
param->title = cargador_enter_pmpt;
util_get_text_from_res_w_max_len(PMPT_TEXT_INPUT_LEVEL,cargador_enter_pmpt,28);
EM_Add_Event(OPUS_EVENT_GROUP_INTERNAL, OPUS_INTERNAL_EDITOR_START, (void*)param);
/*gamesApp_data.popupwin = ds_popup_numeditor_rm(
&select_level_editor,
popup_numeditor_handler
);*/
op_debug(DEBUG_LOW,"gamesApp_data.app.cur_state = %d\n",gamesApp_data.app.cur_state);
op_debug(DEBUG_LOW,"CAR:APP_Cargador_select\n");
}
/*==================================================================================================
FUNCTION: APP_Cargador_Init
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static void APP_Cargador_Init(void)
{
OP_UINT8 i,j;
if (ds_get_screen_mode() != SCREEN_GENERAL)
ds_set_screen_mode(SCREEN_GENERAL);
current_width=cargador_map[current_level].mWidth;
current_height=cargador_map[current_level].mHeight;
xoffset=(colNum-current_width)*RECTWIDTH/2;
yoffset=(rowNum-current_height)*RECTHEIGHT/2;
for (i=0;i<current_height;i++)
for (j=0;j<current_width;j++)
{
Current_Box[i][j]=(cargador_map[current_level].data[i*current_width+j]);
if(Current_Box[i][j]==1)
{
MY=i;
MX=j;
}
}
state=DOWN;
canRollBack=OP_FALSE;
ds_set_softkeys_rm( PMPT_SKEY_RESTART,PMPT_SKEY_EMPTY, PMPT_SKEY_BACK);
RePaint();
if (gamesApp_data.audio_on == OP_TRUE && gamePause == OP_FALSE)
{
SP_Audio_play_request(sound_list[0], gamesApp_data.volume, OP_FALSE);
}
TPO_SetCurrent_RPU(TPO_RUI_GAMES); /*Games pen process.*/
inGame=OP_TRUE;
op_debug(DEBUG_LOW,"CAR:APP_Cargador_Init\n");
}
/*==================================================================================================
FUNCTION: popup_numeditor_handler
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static OP_BOOLEAN popup_numeditor_handler
( DS_POPUP_STATE_ENUM_T state,
OP_INT32 event
)
{
OP_UINT8 posArray[3];
switch(state)
{
case PS_ENTER_S:
break;
case PS_STO_S:
ds_get_popup_edited_digits(gamesApp_data.popupwin);
posArray[0] = select_level_editor.digits[0];
posArray[1] = select_level_editor.digits[2];
posArray[2] = 0;
select_level = (OP_UINT8)op_atoi((char*)&posArray);
break;
case PS_MAIN_S:
break;
case PS_RETURN_S:
break;
case PS_EXIT_S:
break;
default:
break;
}
op_debug(DEBUG_LOW,"CAR:popup_numeditor_handler\n");
return OP_TRUE;
}
/*==================================================================================================
FUNCTION: cargador_pop_msg_processing
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static void cargador_pop_msg_processing(void)
{
close_old_popup();
switch(gamesApp_data.app.cur_state)
{
case APP_GAMES_CARGADOR_RESUME:
case APP_GAMES_CARGADOR_SELECT:
APP_Cargador_Init();
break;
case APP_GAMES_CARGADOR_STATE_POPUP:
Games_change_state((OP_UINT8) APP_GAMES_CARGADOR_SELECT);
break;
default:
break;
}
op_debug(DEBUG_LOW,"CAR:cargador_pop_msg_processing\n");
}
/*==================================================================================================
FUNCTION: onKeyPress
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static void onKeyPress(void *pMess)
{
KEYEVENT_STRUCT *pKey;
OP_UINT16 code;
OP_UINT8 OldMX, OldMY, OldState;
OP_UINT8 OldBox[rowNum][colNum];
OP_BOOLEAN hasMoved=OP_FALSE;
OP_BOOLEAN Success=OP_FALSE;
OP_UINT8 i,j;
pKey=(KEYEVENT_STRUCT *)pMess;
code=pKey->code;
guy_moved_count = 0;
SP_Audio_stop();
if ((gamesApp_data.popupwin != OP_NULL)
&& (gamesApp_data.popupwin->handle != PHANDLE_NONE) && (gamesApp_data.popupwin->type == POPUP_NUMEDITOR))
{
if (code != KEY_STAR && code != KEY_POUND) /* key_star and key_pound are not acceptable here */
{
if (ds_pass_event_to_popup(gamesApp_data.popupwin, OPUS_FOCUS_KEYPAD, pMess) == POPUP_CLOSE)
{
if(code==KEY_OK)
{
gamesApp_data.popupwin=OP_NULL;
/* turn to do data processing when KEY_OK pressed */
level_data_process();
}
else if (code==KEY_SOFT_RIGHT || code == KEY_CLEAR)
{
close_old_popup();
Games_change_state((OP_UINT8) APP_GAMES_STATE_MENU);
}
else if (code==KEY_END)
{
inGame=OP_FALSE;
}
}
}
return;
}
OldMX = MX;
OldMY = MY;
OldState = state;
for(i=0;i<current_height;i++)
for(j=0;j<current_width;j++)
OldBox[i][j] = Current_Box[i][j];
switch(code)
{
case KEY_SIDE_UP:
if (gamesApp_data.volume < VOLUME_LEVEL_SIZE-1)
{
gamesApp_data.volume++;
}
break;
case KEY_SIDE_DOWN:
if (gamesApp_data.volume > 0)
{
gamesApp_data.volume--;
}
break;
case KEY_8:
case KEY_DOWN:
if(inGame)
hasMoved=MoveTo(0,1);
break;
case KEY_2:
case KEY_UP:
if(inGame)
hasMoved=MoveTo(0,-1);
break;
case KEY_LEFT:
case KEY_4:
if(inGame)
hasMoved=MoveTo(-1,0);
break;
case KEY_RIGHT:
case KEY_6:
if(inGame)
hasMoved=MoveTo(1,0);
break;
case KEY_5:
case KEY_OK:
if(inGame)
Rollback();
break;
case KEY_SOFT_LEFT:
if(inGame)
APP_Cargador_Init();
break;
case KEY_SOFT_RIGHT:
case KEY_CLEAR:
if(gamesApp_data.popupwin)
{
OPUS_Stop_Timer(OPUS_TIMER_POPUP_MSG);
cargador_pop_msg_processing();
break;
}
inGame=OP_FALSE;
Games_change_state((OP_UINT8) APP_GAMES_STATE_MENU);
break;
case KEY_END:
inGame=OP_FALSE;
break;
default:
break;
}
if (hasMoved)
{
Old_MX = OldMX;
Old_MY = OldMY;
Old_State = OldState;
Success=OP_TRUE;
for(i=0;i<current_height;i++)
for(j=0;j<current_width;j++)
{
if(Current_Box[i][j]==2||Current_Box[i][j]==3)
Success=OP_FALSE;
Old_Box[i][j] = OldBox[i][j];
}
if (Success)
{
ShowLevelPassed();
}
}
op_debug(DEBUG_LOW,"CAR:onKeyPress\n");
}
/*==================================================================================================
FUNCTION: level_data_process
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static void level_data_process(void)
{
OP_UINT8 promptstr[MAX_STRING_LENGTH];
OP_UINT8 tmpstr[MAX_STRING_LENGTH];
char ss[4];
op_memset((void*)promptstr, 0, MAX_STRING_LENGTH);
op_memset((void*)tmpstr, 0, MAX_STRING_LENGTH);
if(select_level> MAX_LEVEL || select_level<1)
{
Games_change_state((OP_UINT8) APP_GAMES_CARGADOR_STATE_POPUP);
util_get_text_from_res_w_max_len(PMPT_TEXT_LEVEL_INVALID,promptstr,MAX_STRING_LENGTH);
op_sprintf(ss,"%d",MAX_LEVEL);
AtoU(tmpstr,(OP_UINT8 *)ss);
Ustrcat(promptstr,tmpstr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -