diff options
author | hop311 <hop3114@gmail.com> | 2024-02-02 21:19:21 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-02-19 20:17:31 +0100 |
commit | 1455861632cd50f48f6e8ef8c50004087eff36f1 (patch) | |
tree | 5ce200d70f5f12d76dfd489ed06a6bb88204fd1c /game/src/Game/Autoload | |
parent | 576986af57db806af284bbc05a799e72f113f35c (diff) |
Basic Nation Management Screen frameworknation-management-screens
Diffstat (limited to 'game/src/Game/Autoload')
-rw-r--r-- | game/src/Game/Autoload/Events.gd | 6 | ||||
-rw-r--r-- | game/src/Game/Autoload/Events/NationManagementScreens.gd | 25 |
2 files changed, 29 insertions, 2 deletions
diff --git a/game/src/Game/Autoload/Events.gd b/game/src/Game/Autoload/Events.gd index 4f38f61..091a122 100644 --- a/game/src/Game/Autoload/Events.gd +++ b/game/src/Game/Autoload/Events.gd @@ -1,9 +1,11 @@ ## Events are exclusively for the purpose of handling global signals ## This is to reduce "signal bubbling" which is when a signal callback is used to "bubble" the signal callbacks up the scene tree. -## It does such by providing a global interface of signals that are connected to and emitted by that are garunteed to exist. +## It does such by providing a global interface of signals that are connected to and emitted by that are guaranteed to exist. extends Node -var Options: OptionsEventsObject +var Options : OptionsEventsObject +var NationManagementScreens : NationManagementScreensEventsObject func _init() -> void: Options = OptionsEventsObject.new() + NationManagementScreens = NationManagementScreensEventsObject.new() 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) |