diff options
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/menu/MenuEMS.java')
| -rw-r--r-- | src/com/fourisland/fourpuzzle/gamestate/menu/MenuEMS.java | 83 | 
1 files changed, 83 insertions, 0 deletions
| diff --git a/src/com/fourisland/fourpuzzle/gamestate/menu/MenuEMS.java b/src/com/fourisland/fourpuzzle/gamestate/menu/MenuEMS.java new file mode 100644 index 0000000..4fad509 --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/menu/MenuEMS.java | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | /* | ||
| 2 | * To change this template, choose Tools | Templates | ||
| 3 | * and open the template in the editor. | ||
| 4 | */ | ||
| 5 | |||
| 6 | package com.fourisland.fourpuzzle.gamestate.menu; | ||
| 7 | |||
| 8 | import com.fourisland.fourpuzzle.Display; | ||
| 9 | import com.fourisland.fourpuzzle.Game; | ||
| 10 | import com.fourisland.fourpuzzle.KeyInput; | ||
| 11 | import com.fourisland.fourpuzzle.KeyboardInput; | ||
| 12 | import com.fourisland.fourpuzzle.database.Database; | ||
| 13 | import com.fourisland.fourpuzzle.database.Transitions; | ||
| 14 | import com.fourisland.fourpuzzle.database.Vocabulary; | ||
| 15 | import com.fourisland.fourpuzzle.gamestate.TitleScreenGameState; | ||
| 16 | import com.fourisland.fourpuzzle.window.ChoiceWindow; | ||
| 17 | import com.fourisland.fourpuzzle.window.InputableChoiceWindow; | ||
| 18 | import java.awt.Color; | ||
| 19 | import java.awt.Graphics2D; | ||
| 20 | import java.awt.event.KeyEvent; | ||
| 21 | import java.util.Arrays; | ||
| 22 | |||
| 23 | /** | ||
| 24 | * | ||
| 25 | * @author hatkirby | ||
| 26 | */ | ||
| 27 | public class MenuEMS implements EscapeMenuState { | ||
| 28 | |||
| 29 | MenuGameState parent; | ||
| 30 | InputableChoiceWindow cw; | ||
| 31 | |||
| 32 | public void initalize(MenuGameState mgs) | ||
| 33 | { | ||
| 34 | parent = mgs; | ||
| 35 | cw = new InputableChoiceWindow(Arrays.asList(Database.getVocab(Vocabulary.EscapeMenuItems), Database.getVocab(Vocabulary.EscapeMenuEquipment), Database.getVocab(Vocabulary.EscapeMenuMagic), Database.getVocab(Vocabulary.EscapeMenuSave), Database.getVocab(Vocabulary.EscapeMenuQuit)), false, ChoiceWindow.ChoiceWindowLocation.AbsoluteTopLeft); | ||
| 36 | Display.registerRenderable(cw); | ||
| 37 | KeyboardInput.registerInputable(cw); | ||
| 38 | } | ||
| 39 | |||
| 40 | public void deinitalize() | ||
| 41 | { | ||
| 42 | Display.unregisterRenderable(cw); | ||
| 43 | KeyboardInput.unregisterInputable(cw); | ||
| 44 | } | ||
| 45 | |||
| 46 | public void tick() | ||
| 47 | { | ||
| 48 | if (cw.hasInput()) | ||
| 49 | { | ||
| 50 | String value = cw.getSelected(); | ||
| 51 | if (value.equals(Database.getVocab(Vocabulary.EscapeMenuQuit))) | ||
| 52 | { | ||
| 53 | try { | ||
| 54 | Display.transition(Database.getTransition(Transitions.Generic), new TitleScreenGameState(), true); | ||
| 55 | } catch (InterruptedException ex) { | ||
| 56 | Thread.currentThread().interrupt(); | ||
| 57 | } | ||
| 58 | } else if (value.equals(Database.getVocab(Vocabulary.EscapeMenuSave))) | ||
| 59 | { | ||
| 60 | parent.setEMS(new SaveEMS()); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | public void render(Graphics2D g) | ||
| 66 | { | ||
| 67 | g.setBackground(Color.BLACK); | ||
| 68 | g.clearRect(0, 0, Game.WIDTH, Game.HEIGHT); | ||
| 69 | } | ||
| 70 | |||
| 71 | public void processInput(KeyInput key) | ||
| 72 | { | ||
| 73 | if (key.getKey() == KeyEvent.VK_ESCAPE) | ||
| 74 | { | ||
| 75 | try { | ||
| 76 | Display.transition(Database.getTransition(Transitions.Generic), parent.mapView, true); | ||
| 77 | } catch (InterruptedException ex) { | ||
| 78 | Thread.currentThread().interrupt(); | ||
| 79 | } | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | } | ||
