/** * 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 opening sequence for the very first screen of the menu. * * <p>This will be the first thing that the user sees, so make it fancy! */ @SuppressWarnings("unused") private void openingSequence() { boolean done = false; long start = System.currentTimeMillis(); String title = "UniQuest"; String text = "Welcome"; int x0 = -menuTheme.getFont().getStringWidth(title); int x1 = Main.SCREEN_WIDTH; int a0 = (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth(title)) / 2; int a1 = (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth(text)) / 2; while (!done) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); Display.sync(60); if (x0 < a0) x0 += a0 / 60; if (x1 > a1) x1 -= a1 / 60; GL11.glColor3f(1.0f, 1.0f, 1.0f); try { menuTheme.getFont().glDrawText("\\c#FFFFFF" + title, x0, 50); menuTheme.getFont().glDrawText("\\c#FFFFFF" + text, x1, 75); } catch (InvalidEscapeSequenceException e) { e.printStackTrace(); } Display.update(); if (System.currentTimeMillis() - start > 2500 || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { done = true; } else if (Display.isCloseRequested()) { done = true; Game.GAME_STATE = Game.GAME_STATE_QUIT; } } }
/** 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; } } }