📄 menuwindow.java
字号:
m_title.m_iStyle |= Label.STYLE_SCROLLING;
m_title.setPosition( 0, m_iTextY );
m_title.setAlignment( Drawable.ALIGNH_CENTER );
m_title.setText(null);
m_title.setDimensions( m_iWidth-4, m_title.m_iHeight );
addToFront( m_title );
m_menuContainer = new Window( m_canvas );
m_menuContainer.m_iContainerType = CONTAINER_STACK;
addToFront(m_menuContainer);
m_canvas.m_bNeedPaint = true;
}
public Label createMenuLabel( int iType )
{
switch (iType)
{
case LABEL_TITLE:
return new Label( m_canvas.m_menuFont,0,0,0,0x31a000/*@COLOR_MENU_TITLE*/,0x383E5A/*@COLOR_MENU_OUTLINE*/,0 );
case LABEL_HIGHLIGHT:
return new Label( m_canvas.m_menuFont,0,0,0,0x9DACFD/*@COLOR_MENU_SELECTED*/,0x383E5A/*@COLOR_MENU_OUTLINE*/,Label.STYLE_OUTLINE );
default:
return new Label( m_canvas.m_menuFont,0,0,0,0x717AA7/*@COLOR_MENU_TEXT*/,0x383E5A/*@COLOR_MENU_OUTLINE*/,0 );
}
}
public void unloadResources()
{
m_canvas.unloadSoundResources();
unloadControls();
m_title = null;
m_aMenuItems = null;
m_menuContainer = null;
removeAll();
}
private void unloadControls()
{
m_aNames = null;
m_eventStack = null;
m_aScores = null;
m_aiHighScores = null;
m_asHighScoreNames = null;
//#ifndef _NO_ONLINE
//#ifndef _IS_SPRINT
// m_changeName = null;
// m_sName = null;
//#endif
//#endif
m_countryLabel = null;
m_difficulty = null;
m_difficultySelection = null;
m_eventLabel = null;
m_flagSprite = null;
m_itemStack = null;
m_keyPrompt = null;
//#ifdef _IS_SPRINT
// m_welcomePrompt = null;
//#endif
m_nameLabel = null;
m_noLabel = null;
m_resetPrompt = null;
//#ifdef _MULTI_LANG
// m_selectLang = null;
//#endif
m_resetRecords = null;
//#ifdef _SPRINT_MRC
// m_cancelLicense = null;
//#endif
m_scoreList = null;
//#ifndef _NO_SOUND
m_sound = null;
m_soundOnOff = null;
//#endif
m_statusLabel = null;
//#ifdef _IS_SPRINT
// m_statusLabel2 = null;
//#endif
m_textControl = null;
m_tips = null;
m_tipsOnOff = null;
m_yesLabel = null;
}
private final static int m_aiItems_Main[] =
{
STRING_PLAY,
STRING_SETTINGS,
STRING_HELP,
STRING_RECORDS,
STRING_ABOUT,
STRING_EXIT
};
private final static int m_aiItems_Resume[] =
{
STRING_RESUME_GAME,
STRING_ABORT_GAME
};
//#ifndef _NO_ONLINE
// private final static int m_aiItems_Online[] =
// {
// STRING_LOCAL_GAME,
// STRING_ONLINE_GAME
// };
// private final static int m_aiItems_Records[] =
// {
// STRING_LOCAL_TOP_TEN,
//#ifdef _IS_SPRINT
// STRING_GAME_LOBBY,
// STRING_RATE_GAME,
// STRING_LEADERBOARD
//#else
// STRING_ONLINE_TOP_TEN
//#endif
// };
//#endif
private final static int m_aiItems_EventMenuC[] =
{
STRING_PLAY,
STRING_INSTRUCTIONS,
STRING_SETTINGS,
STRING_QUIT_COMPETITION
};
private final static int m_aiItems_EventMenuC_MC[] =
{
STRING_PLAY,
STRING_SETTINGS,
STRING_QUIT_COMPETITION
};
private final static int m_aiItems_EventMenuP[] =
{
STRING_PLAY,
STRING_INSTRUCTIONS,
STRING_SETTINGS,
STRING_SELECT_NEW_EVENT
};
//#ifndef _NO_GHOST
// private final static int m_aiItems_EventMenuChallenge[] =
// {
// STRING_PLAY,
// STRING_INSTRUCTIONS,
// STRING_SETTINGS,
// STRING_SELECT_NEW_EVENT,
// STRING_SELECT_NEW_SCORE
// };
//#endif
private final static int m_aiItems_Play[] =
{
STRING_COMPETITION,
STRING_PRACTICE
//#ifndef _NO_GHOST
// ,
// STRING_CHALLENGE
//#endif
};
//#ifndef _IS_SPRINT
//#ifndef _NO_ONLINE
//#ifndef _NO_GHOST
// private final static int m_aiItems_Challenge[] =
// {
// STRING_LOCAL_TOP_TEN,
// STRING_ONLINE_TOP_TEN,
// STRING_ONLINE_SEARCH
// };
//#endif
//#endif
//#endif
public void changeMenu( int iMenuID ) throws IOException
{
// set up a new menu type
switch (iMenuID)
{
case MENU_EVENTMENU:
if (m_data.iEvent >= 3/*@EVENT_COMPETITION*/)
{
m_title.setTextNoResize( STRING_COMPETITION );
}
else
{
m_title.setTextNoResize( STRING_EVENT0+m_data.iEvent );
}
break;
case MENU_LOCALRECORDS:
if (m_data.iGameMode == 0/*@GAMEMODE_NONE*/
//#ifndef _NO_GHOST
// || m_data.bGhostScoreSearch
//#endif
)
//#ifdef _NO_ONLINE
m_title.setTextNoResize( STRING_RECORDS );
//#else
// m_title.setTextNoResize( STRING_LOCAL_TOP_TEN );
//#endif
else
m_title.setTextNoResize( STRING_NEW_LOCAL_RECORD );
break;
//#ifndef _NO_GHOST
// case MENU_ENTERNAME:
//#ifndef _NO_GHOST
//#ifndef _NO_ONLINE
//#ifndef _IS_SPRINT
// if ( m_data.iGameMode == 3/*@GAMEMODE_CHALLENGE*/ && m_data.bGhostOnlineNameSearch )
// m_title.setTextNoResize( STRING_ONLINE_SEARCH );
// else
//#endif
//#endif
//#endif
// m_title.setTextNoResize( STRING_ENTER_NAME );
// break;
//#endif
default:
m_title.setTextNoResize( s_aiMenuTitles[iMenuID] );
break;
}
if ( iMenuID == MENU_MAIN
//#ifndef _FULL_SPLASH
|| iMenuID == MENU_SPLASH
//#endif
//#ifdef _IS_SPRINT
// || iMenuID == MENU_GAMELOBBYPROMPT
//#endif
)
{
m_title.m_bVisible = false;
}
else
{
m_title.m_bVisible = true;
}
m_menuContainer.setPosition( 0, m_iTextY+m_title.m_iHeight+(-3)/*@FONT_PADDING*/ );
m_menuContainer.setDimensions( m_iWidth, m_iFillY + m_iFillHeight - m_iTextY - m_title.m_iHeight - (-3)/*@FONT_PADDING*/ );
// set up menu
//#ifndef _NO_ONLINE
//#ifndef _IS_SPRINT
// m_canvas.destroyOnlineService();
//#endif
// m_jciThread = null;
// m_iState = STATE_IDLE;
//#endif
if (m_headerLogo != null)
{
remove( m_headerLogo );
m_headerLogo = null;
}
unloadControls();
m_menuContainer.removeAll();
m_menuContainer.setPadding(0);
m_aMenuItems = null;
m_iMenuItemCount = 0;
m_iSelection = 0;
if (m_iMenuID == MENU_LOCALRECORDS)
{
for (int i=0; i<10/*@NUM_LOCAL_RECORDS*/; i++)
for (int j=0; j<=3/*@EVENT_COMPETITION*/; j++)
m_data.abRecordNew[j][i] = false;
}
m_iMenuID = iMenuID;
switch (iMenuID)
{
//#ifndef _FULL_SPLASH
case MENU_SPLASH:
initMenu_Splash();
break;
//#endif
case MENU_MAIN:
initMenu_Main();
break;
//#ifndef _NO_ONLINE
//#ifndef _IS_SPRINT
// case MENU_ONLINE:
// initMenu_General( m_aiItems_Online );
// m_canvas.setKeyLabels( STRING_OK, STRING_BACK );
// m_data.iNumPlayers = 1;
// break;
//#endif
//#endif
//#ifndef _IS_SPRINT
case MENU_SELECTPLAYERS:
//#ifndef _NO_ONLINE
// m_data.iNumPlayers = 1;
//#endif
initMenu_SelectPlayers();
break;
//#endif
//#ifndef _IS_SPRINT
case MENU_ENTERNAME:
initMenu_EnterName();
break;
//#endif
case MENU_SELECTCOUNTRY:
initMenu_SelectCountry();
break;
case MENU_SELECTEVENT:
initMenu_SelectEvent();
break;
//#ifdef _MULTI_LANG
// case MENU_SELECTLANGUAGE:
// initMenu_SelectLanguage();
// break;
//#endif
//#ifndef _NO_ONLINE
// case MENU_RECORDS:
// initMenu_General( m_aiItems_Records );
// m_canvas.setKeyLabels( STRING_OK, STRING_BACK );
// break;
//#endif
case MENU_INSTRUCTIONS:
case MENU_ABOUT:
initMenu_AboutInstructions();
break;
case MENU_RESUMEGAME:
m_canvas.setKeyLabels( STRING_OK, (-1)/*@NULL_STRING*/ );
initMenu_General( m_aiItems_Resume );
break;
case MENU_EVENTMENU:
//#ifndef _NO_GHOST
// if (m_data.iGameMode == 3/*@GAMEMODE_CHALLENGE*/)
// {
// m_canvas.setKeyLabels( STRING_OK, STRING_BACK );
// initMenu_General( m_aiItems_EventMenuChallenge );
// }
//
// else
//#endif
if (m_data.iGameMode == 1/*@GAMEMODE_PRACTICE*/)
{
m_canvas.setKeyLabels( STRING_OK, STRING_BACK );
initMenu_General( m_aiItems_EventMenuP );
}
else
{
m_canvas.setKeyLabels( STRING_OK, STRING_PLAY );
if (m_data.iEvent >= 3/*@EVENT_COMPETITION*/)
initMenu_General( m_aiItems_EventMenuC_MC );
else
initMenu_General( m_aiItems_EventMenuC );
}
break;
case MENU_STANDINGS:
initMenu_Standings();
break;
case MENU_EVENTRESULTS:
initMenu_EventResults();
break;
//#ifndef _NO_ONLINE
//#ifndef _IS_SPRINT
// case MENU_ONLINERECORDS:
//#endif
//#endif
case MENU_LOCALRECORDS:
if (m_data.iGameMode == 0/*@GAMEMODE_NONE*/)
m_canvas.setKeyLabels( (-1)/*@NULL_STRING*/, STRING_BACK );
initMenu_LocalOnlineRecords();
break;
case MENU_SETTINGS:
initMenu_Settings();
break;
//#ifdef _IS_SPRINT
// case MENU_GAMELOBBYPROMPT:
// initMenu_GameLobbyPrompt();
// break;
//#endif
case MENU_PLAY:
initMenu_General( m_aiItems_Play );
m_canvas.setKeyLabels( STRING_OK, STRING_BACK );
break;
//#ifndef _IS_SPRINT
//#ifndef _NO_ONLINE
//#ifndef _NO_GHOST
// case MENU_CHALLENGE:
// m_data.bInitialized = false;
// initMenu_General( m_aiItems_Challenge );
// m_canvas.setKeyLabels( STRING_OK, STRING_BACK );
// break;
//#endif
//#endif
//#endif
}
//#if defined(_USE_THREAD) || defined(_USE_KEY_QUEUE)
// m_canvas.clearKeyEvents();
//#endif
m_canvas.m_bNeedPaint = true;
}
private Sprite m_headerLogo;
private void initMenu_Main() throws IOException
{
// load a menu logo
m_canvas.setKeyLabels( STRING_OK, STRING_EXIT );
//#ifndef _NO_SOUND
//#if defined(_IS_NokiaS60) && !defined(_MMAPI)
// ////System.out.println("load sound");
// m_canvas.loadSound( 0/*@SOUND_THEME*/, false );
//#else
m_canvas.loadSound( 0/*@SOUND_THEME*/ );
//#endif
if (m_canvas.m_iCurrentSoundID != 0/*@SOUND_THEME*/ ||
m_canvas.m_iSoundState != TorinoCanvas.SOUNDSTATE_PLAYING)
{
////System.out.println("play sound");
m_canvas.playSound( 0/*@SOUND_THEME*/, (-1)/*@LOOP_INFINITE*/);
}
//#endif
//#ifdef _IS_NokiaS60
// short[] src = TorinoCanvas.loadPackedPalPixels( RESFILE_MENU, 8/*@RES_MENULOGO*/,
// RESFILE_MENU, 8/*@RES_MENULOGO*/+1 );
//#else
Image src = TorinoCanvas.loadPackedImage( RESFILE_COMMON, 0/*@RES_MENULOGO*/ );
//#endif
m_headerLogo = new Sprite(src);
m_headerLogo.setPosition( 0, m_iFillY+1);
m_headerLogo.setAlignment( Drawable.ALIGNH_CENTER );
addToFront(m_headerLogo);
m_menuContainer.setPosition( 0, m_iTextY+m_headerLogo.m_iHeight );
m_menuContainer.setDimensions( m_iWidth, m_iFillY + m_iFillHeight - m_iTextY - m_headerLogo.m_iHeight - (-3)/*@FONT_PADDING*/ );
initMenu_General(m_aiItems_Main);
m_data.iGameMode = 0/*@GAMEMODE_NONE*/;
m_data.bInitialized = false;
m_data.bCompetitionInitialized = false;
//#ifndef _NO_GHOST
// m_data.bGhostScoreSearch = false;
//#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -