Esempio n. 1
0
 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);
   }
 }
Esempio n. 2
0
 private void clearMenuRes() {
   Resource.freeImage(Resource.PIC_ID_MAIN_BG);
   Resource.freeImage(Resource.PIC_ID_MAIN_MENU_BG);
   if (mainMenu != null) {
     hilightMainMenuIndex = (byte) mainMenu.getHilightIndex();
     mainMenu.setMenuBgImage(null);
     mainMenu = null;
   }
   Resource.freeImage(Resource.PIC_ID_COLLECT);
 }
Esempio n. 3
0
  private void showMenu(Graphics g) {
    Image bgImg = Resource.loadImage(Resource.PIC_ID_MAIN_BG);
    g.drawImage(bgImg, 0, 0, 0);
    if (mainMenu == null) {
      initMenuRes();
    }
    mainMenu.show(g);

    if (!Configurations.getInstance().isFavorWayNonsupport()) {
      Image collect = Resource.loadImage(Resource.PIC_ID_COLLECT);
      int sx = 12, sy = 405;
      if (collect != null) {
        g.drawImage(collect, sx, sy, 20);
      }
      if (groupIndex == 1) {
        DrawUtil.drawRect(g, sx, sy, collect.getWidth(), collect.getHeight(), 3, 0XFFFF00);
      }
    }
  }
Esempio n. 4
0
  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;
      }
    }
  }