private void initMenuRes() { if (mainMenu == null) { mainMenu = new VerticalListMenu(); mainMenu.setMenuBgImage(Resource.loadImage(Resource.PIC_ID_MAIN_MENU_BG), 197, 51); mainMenu.setItemsCoordinate(Resource.POS_MAIN_MENU); mainMenu.setHilightIndex(hilightMainMenuIndex); } }
private void handleMenu(KeyState key) { if (!Configurations.getInstance().isFavorWayNonsupport()) { if (key.containsAndRemove(KeyCode.LEFT)) { if (groupIndex == 0) { groupIndex = 1; hilightMainMenuIndex = (byte) mainMenu.getHilightIndex(); mainMenu.setHilightIndex(-1); } } if (key.containsAndRemove(KeyCode.RIGHT)) { if (groupIndex == 1) { groupIndex = 0; mainMenu.setHilightIndex(hilightMainMenuIndex); } } } if (groupIndex == 0) { if (key.containsAndRemove(KeyCode.UP)) { if (mainMenu != null) { mainMenu.prevItem(); } } if (key.containsAndRemove(KeyCode.DOWN)) { if (mainMenu != null) { mainMenu.nextItem(); } } } if (key.containsAndRemove(KeyCode.OK)) { if (groupIndex == 0) { if (mainMenu != null) { switch (mainMenu.getHilightIndex()) { case MAIN_MENU_START: if (!prepareStart()) { return; } clearMenuRes(); if (choiceCursor == null) { choiceCursor = Resource.buildRotateCursor(); } choiceIndex = 0; state = STATE_START; startState = STATE_START_CHOICE; break; case MAIN_MENU_LOAD: clearMenuRes(); StateRecord stateRecord = new StateRecord(); int result = stateRecord.popup(StateRecord.TYPE_LOAD); if (result == 0) { clearStartRes(); engine.gotoStateMap(); } break; case MAIN_MENU_RANK: state = STATE_FETCH_RANK; break; case MAIN_MENU_HELP: clearMenuRes(); StateHelp help = new StateHelp(); help.popup(); break; case MAIN_MENU_EXIT: PopupConfirm confirm = Resource.buildPopupConfirm(); confirm.setText("确定退出游戏吗?"); switch (confirm.popup()) { case 0: engine.setExit(); break; case 1: state = STATE_MENU; break; default: break; } break; default: break; } } } else { addfavorite(); } } if (key.containsAndRemove(KeyCode.NUM0 | KeyCode.BACK)) { key.clear(); PopupConfirm confirm = Resource.buildPopupConfirm(); confirm.setText("确定退出游戏吗?"); switch (confirm.popup()) { case 0: engine.setExit(); break; case 1: state = STATE_MENU; break; default: break; } } }