aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/GameSession/Menubar/Menubar.gd
blob: b6b18b003e12ad10c6ad6af3c8713e7874ef2956 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
extends GUINode

signal game_session_menu_button_pressed
signal search_button_pressed
signal map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2)
signal zoom_in_button_pressed
signal zoom_out_button_pressed

@export var _mapmodes_grid : GridContainer

var _mapmode_button_group : ButtonGroup

# REQUIREMENTS:
# * UI-550, UI-552, UI-554, UI-561, UI-562, UI-563
func _add_mapmode_button(identifier : String) -> void:
   pass
   #var button := Button.new()
   #button.text = identifier
   #button.tooltip_text = identifier
   #button.toggle_mode = true
   #button.button_group = _mapmode_button_group
   #button.mouse_filter = MOUSE_FILTER_PASS
   #button.focus_mode = FOCUS_NONE
   #_mapmodes_grid.add_child(button)
   #if _mapmode_button_group.get_pressed_button() == null:
   #  button.button_pressed = true

func _ready() -> void:
   add_gui_element("menubar", "menubar")
   
   hide_nodes([
      ^"./menubar/messagelog_window", #todo
      ^"./menubar/OPENbutton", # not quite sure what this is
      ^"./menubar/menubar_plans_toggle", #todo
      ^"./menubar/menubar_plans_open", #todo
      ^"./menubar/menubar_mail_bg", #todo
      ^"./menubar/menubar_msg_diplo", #todo
      ^"./menubar/menubar_msg_settings", #todo
      ^"./menubar/menubar_msg_combat", #todo
      ^"./menubar/menubar_msg_diplo", #todo
      ^"./menubar/menubar_msg_unit", #todo
      ^"./menubar/menubar_msg_province", #todo
      ^"./menubar/menubar_msg_event", #todo
      ^"./menubar/menubar_msg_other", #todo
      ^"./menubar/chat_window", #todo
   ])

   var menubar: Panel = get_panel_from_nodepath(^"./menubar")
   if menubar:
      menubar.mouse_filter = Control.MOUSE_FILTER_IGNORE
   var minimap_bg: GUIIcon = get_gui_icon_from_nodepath(^"./menubar/minimap_bg")
   if minimap_bg:
      minimap_bg.mouse_filter = Control.MOUSE_FILTER_PASS
   var menubar_bg: GUIIcon = get_gui_icon_from_nodepath(^"./menubar/menubar_bg")
   if menubar_bg:
      menubar_bg.mouse_filter = Control.MOUSE_FILTER_PASS

   var menu_button: GUIButton = get_gui_icon_button_from_nodepath(^"./menubar/menu_button")
   if menu_button:
      menu_button.pressed.connect(_on_game_session_menu_button_pressed)

   var search_button: GUIButton = get_gui_icon_button_from_nodepath(^"./menubar/button_goto")
   if search_button:
      search_button.pressed.connect(_on_search_button_pressed)

   var zoom_in_button: GUIButton = get_gui_icon_button_from_nodepath(^"./menubar/map_zoom_in")
   if zoom_in_button:
      zoom_in_button.pressed.connect(_on_zoom_in_button_pressed)

   var zoom_out_button: GUIButton = get_gui_icon_button_from_nodepath(^"./menubar/map_zoom_out")
   if zoom_out_button:
      zoom_out_button.pressed.connect(_on_zoom_out_button_pressed)

   add_gui_element("menubar", "minimap_pic")
   var minimap_pic: GUIIcon = get_node(^"./minimap_pic")
   var minimap_rect: Control = get_node(^"./MinimapRect")
   minimap_rect.move_to_front()
   if minimap_pic:
      minimap_rect.custom_minimum_size = minimap_pic.size
      minimap_rect.position = minimap_pic.position + minimap_pic.size
      minimap_pic.queue_free()
      
   #_mapmode_button_group = ButtonGroup.new()
   #_mapmode_button_group.pressed.connect(_mapmode_pressed)
   #for index : int in GameSingleton.get_mapmode_count():
   #  _add_mapmode_button(GameSingleton.get_mapmode_identifier(index))

# REQUIREMENTS:
# * UIFUN-10
func _on_game_session_menu_button_pressed() -> void:
   game_session_menu_button_pressed.emit()

func _on_search_button_pressed() -> void:
   search_button_pressed.emit()

# REQUIREMENTS:
# * SS-76
# * UIFUN-129, UIFUN-131, UIFUN-133, UIFUN-140, UIFUN-141, UIFUN-142
func _mapmode_pressed(button : BaseButton) -> void:
   GameSingleton.set_mapmode(button.tooltip_text)

func _on_map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) -> void:
   map_view_camera_changed.emit(near_left, far_left, far_right, near_right)

# REQUIREMENTS:
# * UIFUN-269
func _on_zoom_in_button_pressed() -> void:
   zoom_in_button_pressed.emit()

# REQUIREMENTS:
# * UIFUN-270
func _on_zoom_out_button_pressed() -> void:
   zoom_out_button_pressed.emit()