📄 erixmidlet.java
字号:
return;
}
}
} else {
// For handling the list menu items when a saved game is not there.
//int nTempStatus = -1;
int nTempStatus = FAILURE;
nTempStatus = handleStartMenu(m_nSelectedIndex, 0);
/* Check if the 'Quit' menu item was selected, if yes, no
further handling of menu item is to be handled */
if (nTempStatus == FAILURE) {
return;
}
}
} else if ((objDisplay == m_objGameCanvas.m_objListStartMenu)
&& (objCommand == m_objGameCanvas.objBackCmd
|| objCommand == m_objGameCanvas.objBackDummyCmd)) {
m_bExitMidlet = true;
return;
}
/* If displayable is Help Screen and command is 'Back'*/
if ((objDisplay == m_objGameCanvas.m_objHelpForm)
&& (objCommand == m_objGameCanvas.objOkCmd)) {
m_objGameCanvas.update(GameCanvas.MENU_SCREEN);
}
/* If Canvas is drawing the High score list and command is 'Back'*/
if ((objDisplay == m_objGameCanvas)
&& (objCommand == m_objGameCanvas.objHighScoreBackCmd
|| objCommand == m_objGameCanvas.objHighScoreBackDummyCmd)) {
/* Set the mode of the Erix to High Score list mode */
// try{Thread.sleep(100);} catch (Exception e) {}
m_objGameCanvas.update(GameCanvas.MENU_SCREEN);
}
// if we are in the High Scores screen and the command is "Send"
else if ((objDisplay == m_objGameCanvas)
&& (objCommand == m_objGameCanvas.objSendCmd)) {
// Set the mode of the screen to the user authentication screen.
m_objGameCanvas.update(GameCanvas.USER_AUTHENTICATION_SCREEN);
m_objHTTPScoreTransmitter = new HTTPScoreTransmitter(this);
} else if ((objDisplay == m_objGameCanvas)
&& (objCommand == m_objGameCanvas.objResetCmd)) {
m_bAnimScreen = false;
m_bAttractMode = true;
m_objGameCanvas.update(GameCanvas.RESET_CONF_SCREEN);
}else if ((objDisplay == m_objGameCanvas)
&& (objCommand == m_objGameCanvas.objOkCmd)) {
m_bAnimScreen = false;
m_bAttractMode = true;
/* Set the mode of the Erix to High Score list mode */
m_objGameCanvas.update(GameCanvas.MENU_SCREEN);
}
/* If displayable is Settings menu and command is 'Ok'*/
if ((objDisplay == m_objGameCanvas.m_objListSettingsMenu)
&& (typeCommand == Command.SCREEN)) { // Patel
/* Get the index for the selected item form the list*/
m_nSelectedIndex = ((List)objDisplay).getSelectedIndex();
/* If the language item is selected */
if (m_nSelectedIndex == SETTINGS_LANGUAGE) {
m_objGameCanvas.update(GameCanvas.GAME_LANGUAGE_SELECTION_SCREEN);
} else if (m_nSelectedIndex == SETTINGS_AUDIO) {
/* If the audio item is selected */
m_objGameCanvas.update(GameCanvas.GAME_AUDIO_SELECTION_SCREEN);
}
} else if ((objDisplay == m_objGameCanvas.m_objListSettingsMenu)
&& (objCommand == m_objGameCanvas.objBackCmd
|| objCommand == m_objGameCanvas.objBackDummyCmd)) {
m_objGameCanvas.m_objListStartMenu.setSelectedIndex(m_nSelectedIndex,true);
/* If displayable is Settings menu and command is 'Back'
Set the mode of the Erix to main menu mode */
m_objGameCanvas.update(GameCanvas.MENU_SCREEN);
}
// If displayable is Langauge selection screen and command is
// "Ok" or "Select"
if ((objDisplay == m_objGameCanvas.m_objListLanguage)
&& (typeCommand == Command.SCREEN)) { // Patel
/* Get the index selected language from the language selection screen*/
m_nSelectedIndex = ((List)objDisplay).getSelectedIndex();
// If language chosen is different from the current one ...
if (m_nSelectedIndex != m_nGameLanguage) {
// ... set the language to the one chosen by the user.
m_nGameLanguage = m_nSelectedIndex;
// Re-create all the UI interface elements:
// Derefrence all the objects that were initialised while creating the canvas
m_objGameCanvas.cleanCanvas();
// Opens the File as Stream and reads all the language specific strings
createStream();
// Languages of all the text should be change to the user selected language
m_objGameCanvas.initialise();
} // end of if block that changes the UI elements.
if (m_bIsLanguageSet) { // If language setting is present ...
// ... it means that the language selection screen was
// invoked from the settings screen of the application. In
// this case, after the language selection is made, we have
// to set the view again to the settings screen.
// Set the view to the settings screen
m_objGameCanvas.update(GameCanvas.SETTINGS_SCREEN);
}
else { // If the language setting was not found ...
// ... it means that this
// screen was invoked directly after the end of the
// splash animation. In this case, after the language has
// been set, we have to set the view to the
// application's main menu.
// Set the flag to indicate that the language setting is
// now present.
m_bIsLanguageSet = true;
// try{Thread.sleep(100);} catch (Exception e) {}
m_objGameCanvas.update(GameCanvas.MENU_SCREEN);
}
}
// Else if the language selection screen is displayed
// and the user has issued the "Back" command:
else if ((objDisplay == m_objGameCanvas.m_objListLanguage)
&& (objCommand == m_objGameCanvas.objBackCmd
|| objCommand == m_objGameCanvas.objBackDummyCmd)) {
m_objGameCanvas.update(GameCanvas.SETTINGS_SCREEN);
}
// If the Audio preferences screen is being displayed and command is 'Ok'
if ((objDisplay == m_objGameCanvas.m_objListAudioMenu)
&& (typeCommand == Command.SCREEN)) { // Patel
m_nSelectedIndex = ((List)objDisplay).getSelectedIndex();
// Store the selected audio preference
m_nAudioSetting = m_nSelectedIndex;
// Set the mode of the Erix to main menu mode*/
m_objGameCanvas.update(GameCanvas.SETTINGS_SCREEN);
} else if((objDisplay == m_objGameCanvas.m_objListAudioMenu)
&& (objCommand == m_objGameCanvas.objBackCmd
|| objCommand == m_objGameCanvas.objBackDummyCmd)) {
// If displayable is Audio preferences selection screen
// and command is 'Back'
// Set the mode of the Erix to main menu mode
m_objGameCanvas.update(GameCanvas.SETTINGS_SCREEN);
}
/* If displayable is Game screen and command is 'Paused Game'*/
if (objDisplay == m_objGameCanvas
&& objCommand == m_objGameCanvas.objPauseGameCmd) {
// Commented out since the game should pause at any time during the game play
// if (m_objGameEngine.m_nEngineMode == GameEngine.NORMAL_MODE)
// {
/* Adding removing the commands from the Game canvas in play mode */
m_objGameCanvas.removeCommand(m_objGameCanvas.objPauseGameCmd);
// We need to remove the "Back" command before adding the
// "Resume" command, because otherwise, as soon as "Pause"
// is removed, its position is occupied by "Back".
m_objGameCanvas.removeCommand(m_objGameCanvas.objBackCmd);
m_objGameCanvas.removeCommand(m_objGameCanvas.objBackDummyCmd);
m_objGameCanvas.addCommand(m_objGameCanvas.objResumeGameCmd);
m_objGameCanvas.addCommand(m_objGameCanvas.objBackCmd);
m_objGameCanvas.addCommand(m_objGameCanvas.objBackDummyCmd);
/* Notify engine to pause the game */
m_objGameEngine.pauseGame();
// }
} else if(objDisplay == m_objGameCanvas
&& objCommand == m_objGameCanvas.objBackCmd
|| objCommand == m_objGameCanvas.objBackDummyCmd) {
/* Notify engine to do all the game end activity */
m_objGameEngine.endGame();
// Earlier, the game used to be saved whenever the user issued
// the "Back" command from within the game. However, now the
// game is being saved as soon as a level completes, and if
// the user backs out of a level without completing it, the
// progress made in that level is not to be saved. Therfore,
// we no longer perform saving of the game in response to the
// "Back" command.
//System.out.println("MIDlet: Game NOT being saved");
/* Removing the commands from the Game Screen */
m_objGameCanvas.removeCommand(m_objGameCanvas.objResumeGameCmd);
m_objGameCanvas.removeCommand(m_objGameCanvas.objPauseGameCmd);
/* To highlight the same menu item which was selected for traversing
forward */
m_objGameCanvas.m_objListStartMenu.setSelectedIndex(m_nSelectedIndex,true);
m_objGameCanvas.update(GameCanvas.MENU_SCREEN);
} else if (objDisplay == m_objGameCanvas
&& objCommand == m_objGameCanvas.objResumeGameCmd) {
// Commented out since the paused game can be resume at any time during the game play
// if (m_objGameEngine.m_nEngineMode == GameEngine.PAUSED_MODE)
// {
m_objGameCanvas.update(m_objGameCanvas.GAME_SCREEN);
m_objGameEngine.resumeGame();
// }
}
/* If displayable is Highscore name entry screen and command is 'Ok'*/
if (objDisplay == m_objGameCanvas.m_objHighScoreEntryForm
&& objCommand == m_objGameCanvas.objOkCmd) {
m_bAnimScreen = true;
m_bAttractMode = false;
m_bHighScoresPresent = true;
bytHTTPStatus = NOT_UPLOADED;
m_bSendMenu = true;
m_bClearMenu = true;
String strPlayerName = m_objGameCanvas.getHighScoreStringEntry();
// Check if formfeed is present in a signature.
if (strPlayerName.indexOf('\f', 0) != -1) {
//System.out.println("checkString: formfeed character in the signature.");
// Remove the formfeed character from the name.
int nStringLength = strPlayerName.length();
//m_objNewNameStringBuffer.setLength(nStringLength);
// Copy all characters of the string, except the formfeed character(s).
for (int i=0; i<nStringLength; i++) {
// If current character of String is not a formfeed,
char chNameChar = strPlayerName.charAt(i);
if (chNameChar != '\f') {
//System.out.println("char at index " + i + " IS NOT \\f.");
m_objNewNameStringBuffer.append(chNameChar);
}
}
// The StringBuffer contains all characters of the name,
// except the formfeeds.
// Re-create the name:
strPlayerName = null;
strPlayerName = m_objNewNameStringBuffer.toString();
strPlayerName.trim();
m_objNewNameStringBuffer.setLength(0); // erase contents.
} // end of code block that removes formfeed character(s) from the name.
//Currently, checkString() method is not used since the string is valid one.
//If required, we can make use of checkString() to validate the string
//int nTemp = checkString(strPlayerName);
//if (nTemp != -1) { // String is Valid
/* Get the player name entered in the High Score Entry screen */
int nStrlen = strPlayerName.length();
// If the player hasn't entered a name,
// set the name to be three blank spaces.
if(nStrlen == 0) {
for (int i=0; i<PLAYER_NAME_MAX_LENGTH; i++ ) {
strPlayerName = strPlayerName.concat(" ");
}
}
// For inserting high scores in high scores array
insertHighScore(strPlayerName);
// Keeping the player name and the high score, to be used if player selects to
// send the score to high score server
m_strHighScoreName = m_arrHighScoreNames[0].toString();
m_nHighScore = m_arrHighScores[0];
m_bytHighScoreLevel = m_arrLevelForHighScores[0];
/* Set the mode of the Erix to main menu mode*/
m_objGameCanvas.update(GameCanvas.HIGH_SCORE_LIST_SCREEN);
} // end of if the displayable is the highscores name entry form and command is "Done"
// If the displayable is the User Authentication Form and the command is "OK"
if (objDisplay == m_objGameCanvas.m_objUserAuthenticationForm) {
if (objCommand == m_objGameCanvas.objOkCmd) {
// Try to send authentication and highscores data
// to the highscores server.
// Remember the Highscores server userID and password entered by the user.
m_strHighscoresServerUserid = m_objGameCanvas.m_objUseridTextField.getString();
m_strHighscoresServerPassword = m_objGameCanvas.m_objPasswordTextField.getString();
m_bAnimScreen = false;
m_bAttractMode = true;
// Create a new progress form
m_objGameCanvas.m_objHighscoresUploadProgressForm
= new ProgressForm(m_objHTTPScoreTransmitter, this);
// Set the progress form to be the current displayable.
m_objDisplay.setCurrent(
m_objGameCanvas.m_objHighscoresUploadProgressForm);
} else if (objCommand == m_objGameCanvas.objHelpCmd) {
// Show the user the help text about authentication.
m_objGameCanvas.update(GameCanvas.AUTHENTICATION_HELP_SCREEN);
} else if (objCommand == m_objGameCanvas.objCancelCmd
|| objCommand == m_objGameCanvas.objCancelDummyCmd) {
bytHTTPStatus = NOT_UPLOADED;
// The user does not want to upload the highscores
// Take the user to the Highscores list screen.
m_objGameCanvas.update(GameCanvas.HIGH_SCORE_LIST_SCREEN);
}
} // end of if the current displayable is the User Authentication Form
// If the authentication help is being displayed ...
if (objDisplay == m_objGameCanvas.m_objAuthenticationHelpForm) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -