public static final boolean checkTutorial(GUIRoot gui_root, int tutorial_number) { switch (tutorial_number) { case TUTORIAL_TOWER: if (!Renderer.isRegistered()) { ResourceBundle db = ResourceBundle.getBundle(DemoForm.class.getName()); Form demo_form = new DemoForm( gui_root, Utils.getBundleString(db, "tower_unavailable_header"), new GUIImage(512, 256, 0f, 0f, 1f, 1f, "/textures/gui/demo_towers"), Utils.getBundleString(db, "tower_unavailable")); gui_root.addModalForm(demo_form); return false; } case TUTORIAL_CHIEFTAIN: if (!Renderer.isRegistered()) { ResourceBundle db = ResourceBundle.getBundle(DemoForm.class.getName()); Form demo_form = new DemoForm( gui_root, Utils.getBundleString(db, "chieftain_unavailable_header"), new GUIImage(512, 256, 0f, 0f, 1f, 1f, "/textures/gui/demo_chieftains"), Utils.getBundleString(db, "chieftain_unavailable")); gui_root.addModalForm(demo_form); return false; } default: } return true; }
private final void adjustPlayerSlot(int player_slot) { if (updating || game_network.getClient() == null) return; PlayerSlot player = game_network.getClient().getPlayers()[player_slot]; int index = slot_buttons[player_slot].getMenu().getChosenItemIndex(); if (index == COMPUTER_HARD_INDEX && !Renderer.isRegistered()) { slot_buttons[player_slot].getMenu().chooseItem(COMPUTER_NORMAL_INDEX); index = COMPUTER_NORMAL_INDEX; ResourceBundle db = ResourceBundle.getBundle(DemoForm.class.getName()); Form demo_form = new DemoForm( gui_root, Utils.getBundleString(db, "hard_ai_unavailable_header"), new GUIImage(512, 256, 0f, 0f, 1f, 1f, "/textures/gui/demo_hardai"), Utils.getBundleString(db, "hard_ai_unavailable")); gui_root.addModalForm(demo_form); } int race_index = race_buttons[player_slot].getMenu().getChosenItemIndex(); int team_index = team_buttons[player_slot].getMenu().getChosenItemIndex(); int difficulty_index = slot_buttons[player_slot].getMenu().getChosenItemIndex() - 1; boolean race_changed = player.getInfo() == null || race_index != player.getInfo().getRace(); boolean team_changed = player.getInfo() == null || team_index != player.getInfo().getTeam(); boolean ready_changed = ready != player.isReady(); boolean difficulty_changed = player.getInfo() == null || player.getAIDifficulty() != difficulty_index; PulldownButton slot_button = slot_buttons[player_slot]; switch (index) { case OPEN_INDEX: if ((player.getType() != PlayerSlot.OPEN && player.getType() != PlayerSlot.HUMAN) || race_changed || team_changed || ready_changed) { if (player_slot == local_player_slot) { int new_type = PlayerSlot.HUMAN; game_network .getClient() .getServerInterface() .setPlayerSlot( player_slot, new_type, race_index, team_index, ready, PlayerSlot.AI_NONE); } else { game_network.getClient().getServerInterface().resetSlotState(player_slot, true); } } break; case CLOSED_INDEX: if (player.getType() != PlayerSlot.CLOSED || race_changed || team_changed) { slot_button .getMenu() .getItem(OPEN_INDEX) .setLabelString(Utils.getBundleString(bundle, "open")); game_network.getClient().getServerInterface().resetSlotState(player_slot, false); } break; case COMPUTER_EASY_INDEX: case COMPUTER_NORMAL_INDEX: case COMPUTER_HARD_INDEX: assert !rated; boolean new_ai = player.getType() != PlayerSlot.AI; if (new_ai || race_changed || team_changed || difficulty_changed) { slot_button .getMenu() .getItem(OPEN_INDEX) .setLabelString(Utils.getBundleString(bundle, "open")); if (new_ai) { team_index = player_slot; race_index = new Random(LocalEventQueue.getQueue().getHighPrecisionManager().getTick()) .nextInt(RacesResources.getNumRaces()); } game_network .getClient() .getServerInterface() .setPlayerSlot( player_slot, PlayerSlot.AI, race_index, team_index, true, difficulty_index); } break; default: throw new RuntimeException("Invalid item index"); } }