aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Autoload/Events
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-02-19 21:35:07 +0100
committer GitHub <noreply@github.com>2024-02-19 21:35:07 +0100
commit275cfbb62fe69828aeb9968110ad822447322a4e (patch)
tree15fe433ba9259623e2cb90a0ea7ae6a5c2f364b8 /game/src/Game/Autoload/Events
parente4de451ce753dd8786546b9e2c94c579c8dab52e (diff)
parent1455861632cd50f48f6e8ef8c50004087eff36f1 (diff)
Merge pull request #202 from OpenVicProject/nation-management-screens
Basic Nation Management Screen framework
Diffstat (limited to 'game/src/Game/Autoload/Events')
-rw-r--r--game/src/Game/Autoload/Events/NationManagementScreens.gd25
1 files changed, 25 insertions, 0 deletions
diff --git a/game/src/Game/Autoload/Events/NationManagementScreens.gd b/game/src/Game/Autoload/Events/NationManagementScreens.gd
new file mode 100644
index 0000000..4bdca6d
--- /dev/null
+++ b/game/src/Game/Autoload/Events/NationManagementScreens.gd
@@ -0,0 +1,25 @@
+class_name NationManagementScreensEventsObject
+extends RefCounted
+
+signal update_active_nation_management_screen(screen : NationManagement.Screen)
+
+var _current_screen : NationManagement.Screen = NationManagement.Screen.NONE
+
+# Set the current nation management screen. This emits an update signal to force
+# the argument screen to update, even if it was already the current screen.
+# Used by miscellaneous screen opening buttons (e.g. in province overview panel)
+# and by the close and toggle functions below.
+func open_nation_management_screen(screen : NationManagement.Screen) -> void:
+ _current_screen = screen
+ update_active_nation_management_screen.emit(_current_screen)
+
+# Close the screen if it is already open. Used for screens' close buttons.
+func close_nation_management_screen(screen : NationManagement.Screen) -> void:
+ if screen == _current_screen:
+ open_nation_management_screen(NationManagement.Screen.NONE)
+
+# Either switch to the screen or close it if it is already open. Used for topbar's buttons.
+func toggle_nation_management_screen(screen : NationManagement.Screen) -> void:
+ if screen == _current_screen:
+ screen = NationManagement.Screen.NONE
+ open_nation_management_screen(screen)