Package com.mg105.user_interface
Class BattleMenu
java.lang.Object
com.mg105.user_interface.BattleMenu
- All Implemented Interfaces:
BattleMenuInterface
,Toggleable
,EventListener
,javafx.event.EventHandler<javafx.event.ActionEvent>
public class BattleMenu
extends Object
implements javafx.event.EventHandler<javafx.event.ActionEvent>, BattleMenuInterface, Toggleable
This class uses JavaFX and is displayed during an active battle.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull javafx.scene.Scene
getScene()
Get the scene of this toggleable object.void
handle
(javafx.event.ActionEvent event) Handles button events.void
Sets the names of the player and opponent characters participating in the active battle.void
toggle
(boolean isVisible) Set the visibility of this component.void
updateCharacter
(String character) Updates the display corresponding to the given affected character.
-
Constructor Details
-
BattleMenu
Creates a new BattleMenu. Sets every UI element, except for labels which are set when the view is toggled on.- Parameters:
battlePres
- the BattlePresenter to refer to (following MVP pattern)
-
-
Method Details
-
setNames
Sets the names of the player and opponent characters participating in the active battle.- Specified by:
setNames
in interfaceBattleMenuInterface
- Parameters:
playerNames
- array of name Strings representing player characters.opponentNames
- array of name Strings representing opponents.
-
updateCharacter
Updates the display corresponding to the given affected character.- Specified by:
updateCharacter
in interfaceBattleMenuInterface
- Parameters:
character
- the character who needs to be updated on the screen.
-
getScene
@NotNull public @NotNull javafx.scene.Scene getScene()Get the scene of this toggleable object. It is this scene that will be displayed.- Specified by:
getScene
in interfaceToggleable
- Returns:
- the scene to be displayed.
-
toggle
public void toggle(boolean isVisible) Set the visibility of this component.- Specified by:
toggle
in interfaceToggleable
- Parameters:
isVisible
- true if the Toggleable is now visible, false otherwise. If false the Toggleable is expected to do nothing on ANY user inputs.
-
handle
public void handle(javafx.event.ActionEvent event) Handles button events. NextRound will start the next round, which is handled in BattlePresenter. The two move buttons represent a move to be selected, and will cause target buttons to appear next to valid target characters and the move buttons to disappear. The target buttons only become visible when the character they represent can be targeted with the selected move, and pressing them will apply the move onto the character and make the target buttons disappear.- Specified by:
handle
in interfacejavafx.event.EventHandler<javafx.event.ActionEvent>
- Parameters:
event
- the event which occurred.
-