/** * The menu sequence that allows the user to select options. * * <p> * * <ul> * <li>QuickStart (random character created for the player) * <li>Create new character * <li>Load a character * <li> * <li>Settings, including keybindings * <li>Quit * </ul> */ private void menuSelectionSequence() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); Input.poll(); mouseEvents = Input.getMouseEvents(); for (GLUIComponent b : menuSelectionButtons) { b.processMouseEvents(mouseEvents); b.update(0); b.renderGL(); } try { menuTheme .getFont() .glDrawText( "\\c#FFFFFFUniQuest", (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth("UniQuest")) / 2 + 2, 50); } catch (InvalidEscapeSequenceException e) { e.printStackTrace(); } Display.update(); if (Display.isCloseRequested()) { Game.GAME_STATE = Game.GAME_STATE_QUIT; menu = false; } }
private void keyConfigSequence() { while (loop) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); try { menuTheme .getFont() .glDrawText( "\\c#FFFFFFKey Bindings", (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth("Key Bindings")) / 2 + 2, 50); } catch (InvalidEscapeSequenceException e) { e.printStackTrace(); } Input.poll(); mouseEvents = Input.getMouseEvents(); keyEvents = Input.getKeyEvents(); try { drawKeyConfigText(margin, 75, 30); } catch (InvalidEscapeSequenceException e) { } for (GLUIComponent t : keyConfigTextField) { t.processKeyEvents(keyEvents); t.processMouseEvents(mouseEvents); t.update(0); t.renderGL(); } Display.update(); if (Display.isCloseRequested()) { Game.GAME_STATE = Game.GAME_STATE_QUIT; menu = false; loop = false; } else if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { loop = false; } } for (GLUIComponent t : keyConfigTextField) { if (t instanceof GLTextField) { ((GLTextField) t).setText(((GLTextField) t).getText().toUpperCase()); KeyBindings.valueOf(t.getContext().toString()) .setUserKey(Keyboard.getKeyIndex(((GLTextField) t).getText())); } } }
/** The menu sequence for changing the configuration settings */ private void configSequence() { loop = true; while (loop) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); try { menuTheme .getFont() .glDrawText( "\\c#FFFFFFSettings", (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth("Settings")) / 2 + 2, 50); } catch (InvalidEscapeSequenceException e) { e.printStackTrace(); } Input.poll(); mouseEvents = Input.getMouseEvents(); for (GLUIComponent b : configSequenceButtons) { b.processMouseEvents(mouseEvents); b.update(0); b.renderGL(); } Display.update(); if (Display.isCloseRequested()) { Game.GAME_STATE = Game.GAME_STATE_QUIT; menu = false; loop = false; } else if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { loop = false; } } }
/** The menu sequence for loading a previously saved character */ private void loadCharacterSequence() { String path; JFileChooser c = new JFileChooser(); c.setDialogTitle("Load a Saved Character"); int v = c.showOpenDialog(null); if (v == JFileChooser.APPROVE_OPTION) { path = c.getSelectedFile().getAbsolutePath(); } else { return; } try { Game.player = Player.loadPlayer(path); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } int y = 40; int diff = 60; loop = true; while (loop) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); Input.pollMouse(); mouseEvents = Input.getMouseEvents(); returnButton.processMouseEvents(mouseEvents); returnButton.update(0); returnButton.renderGL(); try { menuTheme.getFont().glDrawText("\\c#FFFFFF" + Game.player.getName(), margin, y + diff); menuTheme .getFont() .glDrawText("\\c#FFFFFFLevel: " + Game.player.getLevel(), margin, y + 2 * diff); menuTheme .getFont() .glDrawText( "\\c#FFFFFFHealth: " + Game.player.getHp() + " / " + Game.player.getMaxHP(), margin, y + 3 * diff); menuTheme .getFont() .glDrawText( "\\c#FFFFFFPower: " + Game.player.getPp() + " / " + Game.player.getMaxPP(), margin, y + 4 * diff); } catch (InvalidEscapeSequenceException e) { e.printStackTrace(); } Display.update(); if (Display.isCloseRequested()) { Game.GAME_STATE = Game.GAME_STATE_QUIT; menu = false; loop = false; } else if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { loop = false; } } }
@Override public void removeInputListeners(Input input) { input.removeListener(this); }
@Override public void addInputListeners(Input input) { input.replaceMappingResourcePath(getInputFilePath()); input.addListenerTo(this); }