aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/GameSession/NationManagementScreen/PoliticsMenu.gd
blob: 7237bf5f60d1fbf06b2e11197d01060856dce3b2 (plain) (blame)
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
extends GUINode

var _active : bool = false

const _screen : NationManagement.Screen = NationManagement.Screen.POLITICS

func _ready() -> void:
   GameSingleton.gamestate_updated.connect(_update_info)

   Events.NationManagementScreens.update_active_nation_management_screen.connect(_on_update_active_nation_management_screen)

   add_gui_element("country_politics", "country_politics")

   var close_button : Button = get_button_from_nodepath(^"./country_politics/close_button")
   if close_button:
      close_button.pressed.connect(Events.NationManagementScreens.close_nation_management_screen.bind(_screen))

   _update_info()

func _notification(what : int) -> void:
   match what:
      NOTIFICATION_TRANSLATION_CHANGED:
         _update_info()

func _on_update_active_nation_management_screen(active_screen : NationManagement.Screen) -> void:
   _active = active_screen == _screen
   _update_info()

func _update_info() -> void:
   if _active:
      # TODO - update UI state
      show()
   else:
      hide()