-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPopupMenuControllerBuilder.java
44 lines (34 loc) · 1.42 KB
/
PopupMenuControllerBuilder.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
40
41
42
43
44
package controller.menu.builder;
import controller.GameController;
import controller.command.Command;
import controller.command.controller_state.SetControllerStateCommand;
import controller.menu.element.ButtonController;
import controller.menu.MenuController;
import controller.menu.PopupMenuController;
import model.Position;
import model.menu.Button;
import model.menu.Menu;
import java.util.List;
public abstract class PopupMenuControllerBuilder extends MenuControllerBuilder {
protected final GameController controller;
public PopupMenuControllerBuilder(GameController controller) {
this.controller = controller;
}
protected Command getClosePopupMenuCommand() {
return new SetControllerStateCommand(this.controller, this.controller.getGameControllerState());
}
@Override
protected MenuController getMenuController(Menu menu) {
return new PopupMenuController(menu, this.controller, this.controller.getGameControllerState());
}
@Override
protected List<ButtonController> getButtons() {
List<ButtonController> buttons = super.getButtons();
addCloseMenuButton(buttons);
return buttons;
}
private void addCloseMenuButton(List<ButtonController> buttons) {
Button closeMenuButton = new Button(new Position(this.getWidth() - 3, 0), "X");
buttons.add(new ButtonController(closeMenuButton, this.getClosePopupMenuCommand()));
}
}