-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPopupMenuController.java
39 lines (32 loc) · 1.13 KB
/
PopupMenuController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package controller.menu;
import controller.GameController;
import controller.GameControllerState;
import gui.GUI;
import model.menu.Menu;
import viewer.GameViewer;
import viewer.menu.PopupMenuViewer;
public class PopupMenuController extends MenuController {
private final GameControllerState backState;
public PopupMenuController(Menu menu, GameController gameController, GameControllerState backState) {
super(menu, gameController);
this.backState = backState;
}
@Override
public void reactKeyboard(GUI.KEYBOARD_ACTION action) {
if (action == GUI.KEYBOARD_ACTION.BACK) {
this.closePopup();
}
}
private void closePopup() {
this.gameController.setGameControllerState(this.backState);
}
@Override
public void reactTimePassed(long elapsedTimeSinceLastFrame) {
// By default, popups do not stop the time passing of the things in the background
this.backState.reactTimePassed(elapsedTimeSinceLastFrame);
}
@Override
public GameViewer getViewer() {
return new PopupMenuViewer(this.getMenu(), this.backState.getViewer());
}
}