diff options
Diffstat (limited to 'game/src/Game/GameSession/Menubar/Menubar.gd')
-rw-r--r-- | game/src/Game/GameSession/Menubar/Menubar.gd | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/game/src/Game/GameSession/Menubar/Menubar.gd b/game/src/Game/GameSession/Menubar/Menubar.gd new file mode 100644 index 0000000..b6b18b0 --- /dev/null +++ b/game/src/Game/GameSession/Menubar/Menubar.gd @@ -0,0 +1,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() |