diff options
author | BrickPi <ajmach6@gmail.com> | 2024-11-14 04:05:46 +0100 |
---|---|---|
committer | BrickPi <ajmach6@gmail.com> | 2024-11-15 02:55:15 +0100 |
commit | 9960ccfd404f89fbc71a1d02796253503a483c23 (patch) | |
tree | 63fbfbfa6cce76b9a280772e4013428e8c52b546 /game/src/Game | |
parent | 7f7510cd3c3541b596d97eff8ade42e819d82c85 (diff) |
Use V2 Minimap GUI
Diffstat (limited to 'game/src/Game')
-rw-r--r-- | game/src/Game/GameSession/GameSession.tscn | 40 | ||||
-rw-r--r-- | game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd | 62 | ||||
-rw-r--r-- | game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn | 113 | ||||
-rw-r--r-- | game/src/Game/GameSession/Menubar/Menubar.gd | 120 | ||||
-rw-r--r-- | game/src/Game/GameSession/Menubar/Minimap.gd (renamed from game/src/Game/GameSession/MapControlPanel/Minimap.gd) | 7 | ||||
-rw-r--r-- | game/src/Game/GameSession/Menubar/Minimap.gdshader (renamed from game/src/Game/GameSession/MapControlPanel/Minimap.gdshader) | 0 |
6 files changed, 153 insertions, 189 deletions
diff --git a/game/src/Game/GameSession/GameSession.tscn b/game/src/Game/GameSession/GameSession.tscn index 5925f3d..81eb5e9 100644 --- a/game/src/Game/GameSession/GameSession.tscn +++ b/game/src/Game/GameSession/GameSession.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=21 format=3 uid="uid://bgnupcshe1m7r"] +[gd_scene load_steps=24 format=3 uid="uid://bgnupcshe1m7r"] [ext_resource type="Script" path="res://src/Game/GameSession/GameSession.gd" id="1_eklvp"] [ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/Game/MusicConductor/MusicPlayer.tscn" id="2_kt6aa"] -[ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/Game/GameSession/MapControlPanel/MapControlPanel.tscn" id="3_afh6d"] [ext_resource type="PackedScene" uid="uid://dvdynl6eir40o" path="res://src/Game/GameSession/GameSessionMenu.tscn" id="3_bvmqh"] [ext_resource type="Script" path="res://src/Game/GameSession/ModelManager.gd" id="3_qwk4j"] [ext_resource type="Script" path="res://src/Game/GameSession/Topbar.gd" id="4_2kbih"] @@ -19,7 +18,15 @@ [ext_resource type="Script" path="res://src/Game/GameSession/NationManagementScreen/TradeMenu.gd" id="10_mv1r6"] [ext_resource type="Script" path="res://src/Game/GameSession/NationManagementScreen/DiplomacyMenu.gd" id="11_fu7ys"] [ext_resource type="Script" path="res://src/Game/GameSession/NationManagementScreen/MilitaryMenu.gd" id="12_6h6nc"] +[ext_resource type="Script" path="res://src/Game/GameSession/Menubar/Minimap.gd" id="15_ckojr"] +[ext_resource type="Shader" path="res://src/Game/GameSession/Menubar/Minimap.gdshader" id="15_gtm7r"] [ext_resource type="Script" path="res://src/Game/GameSession/Tooltip.gd" id="20_3306e"] +[ext_resource type="Script" path="res://src/Game/GameSession/Menubar/Menubar.gd" id="20_s1i71"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_6eoxs"] +shader = ExtResource("15_gtm7r") +shader_parameter/province_shape_subdivisions = null +shader_parameter/selected_index = null [node name="GameSession" type="Control" node_paths=PackedStringArray("_model_manager", "_game_session_menu")] editor_description = "SS-102, UI-546" @@ -103,15 +110,27 @@ layout_mode = 1 anchors_preset = 15 script = ExtResource("12_6h6nc") -[node name="MapControlPanel" parent="UICanvasLayer/UI" instance=ExtResource("3_afh6d")] +[node name="Menubar" type="GUINode" parent="UICanvasLayer/UI"] layout_mode = 1 -anchors_preset = -1 +anchors_preset = 15 +mouse_force_pass_scroll_events = false +script = ExtResource("20_s1i71") + +[node name="MinimapRect" type="ColorRect" parent="UICanvasLayer/UI/Menubar"] +material = SubResource("ShaderMaterial_6eoxs") +layout_mode = 1 +anchors_preset = 3 anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 +offset_left = -1280.0 +offset_top = -720.0 +offset_right = -1280.0 +offset_bottom = -720.0 grow_horizontal = 0 grow_vertical = 0 +script = ExtResource("15_ckojr") [node name="SearchPanel" type="GUINode" parent="UICanvasLayer/UI" node_paths=PackedStringArray("_map_view")] layout_mode = 1 @@ -163,12 +182,13 @@ anchors_preset = 15 script = ExtResource("20_3306e") [connection signal="detailed_view_changed" from="MapView" to="ModelManager" method="set_visible"] -[connection signal="map_view_camera_changed" from="MapView" to="UICanvasLayer/UI/MapControlPanel" method="_on_map_view_camera_changed"] -[connection signal="game_session_menu_button_pressed" from="UICanvasLayer/UI/MapControlPanel" to="." method="_on_game_session_menu_button_pressed"] -[connection signal="minimap_clicked" from="UICanvasLayer/UI/MapControlPanel" to="MapView" method="_on_minimap_clicked"] -[connection signal="search_button_pressed" from="UICanvasLayer/UI/MapControlPanel" to="UICanvasLayer/UI/SearchPanel" method="toggle_visibility"] -[connection signal="zoom_in_button_pressed" from="UICanvasLayer/UI/MapControlPanel" to="MapView" method="zoom_in"] -[connection signal="zoom_out_button_pressed" from="UICanvasLayer/UI/MapControlPanel" to="MapView" method="zoom_out"] +[connection signal="map_view_camera_changed" from="MapView" to="UICanvasLayer/UI/Menubar" method="_on_map_view_camera_changed"] +[connection signal="game_session_menu_button_pressed" from="UICanvasLayer/UI/Menubar" to="." method="_on_game_session_menu_button_pressed"] +[connection signal="map_view_camera_changed" from="UICanvasLayer/UI/Menubar" to="UICanvasLayer/UI/Menubar/MinimapRect" method="_on_map_view_camera_changed"] +[connection signal="search_button_pressed" from="UICanvasLayer/UI/Menubar" to="UICanvasLayer/UI/SearchPanel" method="toggle_visibility"] +[connection signal="zoom_in_button_pressed" from="UICanvasLayer/UI/Menubar" to="MapView" method="zoom_in"] +[connection signal="zoom_out_button_pressed" from="UICanvasLayer/UI/Menubar" to="MapView" method="zoom_out"] +[connection signal="minimap_clicked" from="UICanvasLayer/UI/Menubar/MinimapRect" to="MapView" method="_on_minimap_clicked"] [connection signal="load_button_pressed" from="UICanvasLayer/UI/GameSessionMenu" to="UICanvasLayer/UI/SaveLoadMenu" method="show_for_load"] [connection signal="options_button_pressed" from="UICanvasLayer/UI/GameSessionMenu" to="UICanvasLayer/UI/OptionsMenu" method="show"] [connection signal="save_button_pressed" from="UICanvasLayer/UI/GameSessionMenu" to="UICanvasLayer/UI/SaveLoadMenu" method="show_for_save"] diff --git a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd deleted file mode 100644 index 61de6ae..0000000 --- a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd +++ /dev/null @@ -1,62 +0,0 @@ -extends PanelContainer - -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 minimap_clicked(pos_clicked : 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: - 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: - _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) - -func _on_minimap_clicked(pos_clicked : Vector2) -> void: - minimap_clicked.emit(pos_clicked) - -# 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() diff --git a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn deleted file mode 100644 index d49cf61..0000000 --- a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn +++ /dev/null @@ -1,113 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://g524p8lr574w"] - -[ext_resource type="Script" path="res://src/Game/GameSession/MapControlPanel/MapControlPanel.gd" id="1_ign64"] -[ext_resource type="Shader" path="res://src/Game/GameSession/MapControlPanel/Minimap.gdshader" id="2_rinsg"] -[ext_resource type="Script" path="res://src/Game/GameSession/MapControlPanel/Minimap.gd" id="3_s4dml"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_bhuqb"] -shader = ExtResource("2_rinsg") -shader_parameter/province_shape_subdivisions = null -shader_parameter/selected_index = null - -[sub_resource type="InputEventAction" id="InputEventAction_5nck3"] -action = &"ui_cancel" - -[sub_resource type="Shortcut" id="Shortcut_fc1tk"] -events = [SubResource("InputEventAction_5nck3")] - -[node name="MapControlPanel" type="PanelContainer" node_paths=PackedStringArray("_mapmodes_grid")] -editor_description = "SS-103, UI-548" -mouse_force_pass_scroll_events = false -script = ExtResource("1_ign64") -_mapmodes_grid = NodePath("MapPanelMargin/MapPanelList/MapDisplayList/MapmodesGrid") - -[node name="MapPanelMargin" type="MarginContainer" parent="."] -layout_mode = 2 -theme_override_constants/margin_left = 5 -theme_override_constants/margin_top = 5 -theme_override_constants/margin_right = 5 -theme_override_constants/margin_bottom = 5 - -[node name="MapPanelList" type="HBoxContainer" parent="MapPanelMargin"] -layout_mode = 2 -theme_override_constants/separation = 6 -alignment = 1 - -[node name="MapDisplayList" type="VBoxContainer" parent="MapPanelMargin/MapPanelList"] -layout_mode = 2 -alignment = 1 - -[node name="MapmodesGrid" type="GridContainer" parent="MapPanelMargin/MapPanelList/MapDisplayList"] -editor_description = "UI-750" -layout_mode = 2 -columns = 7 - -[node name="Minimap" type="PanelContainer" parent="MapPanelMargin/MapPanelList/MapDisplayList"] -editor_description = "UI-549" -layout_mode = 2 -size_flags_horizontal = 4 -size_flags_vertical = 4 -mouse_filter = 1 - -[node name="MinimapTexture" type="ColorRect" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap"] -editor_description = "UI-751, FS-338" -material = SubResource("ShaderMaterial_bhuqb") -layout_mode = 2 -color = Color(0.921569, 0.835294, 0.701961, 1) - -[node name="ViewportQuad" type="Control" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap" node_paths=PackedStringArray("_minimap_texture")] -layout_mode = 2 -mouse_filter = 1 -script = ExtResource("3_s4dml") -_minimap_texture = NodePath("../MinimapTexture") - -[node name="AuxiliaryPanel" type="VBoxContainer" parent="MapPanelMargin/MapPanelList"] -editor_description = "UI-761" -layout_mode = 2 - -[node name="GameSessionMenuButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] -editor_description = "UI-9" -layout_mode = 2 -focus_mode = 0 -mouse_filter = 1 -shortcut = SubResource("Shortcut_fc1tk") -text = "ESC" - -[node name="LedgerButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] -editor_description = "UI-860" -layout_mode = 2 -focus_mode = 0 -mouse_filter = 1 -text = "L" - -[node name="SearchButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] -editor_description = "UI-861" -layout_mode = 2 -focus_mode = 0 -mouse_filter = 1 -text = "F" - -[node name="ZoomButtonsContainer" type="HBoxContainer" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] -layout_mode = 2 -alignment = 1 - -[node name="ZoomInButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer"] -editor_description = "UI-862" -layout_mode = 2 -focus_mode = 0 -mouse_filter = 1 -text = "+" - -[node name="ZoomOutButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer"] -editor_description = "UI-863" -layout_mode = 2 -focus_mode = 0 -mouse_filter = 1 -text = "-" - -[connection signal="map_view_camera_changed" from="." to="MapPanelMargin/MapPanelList/MapDisplayList/Minimap/ViewportQuad" method="_on_map_view_camera_changed"] -[connection signal="minimap_clicked" from="MapPanelMargin/MapPanelList/MapDisplayList/Minimap/ViewportQuad" to="." method="_on_minimap_clicked"] -[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/GameSessionMenuButton" to="." method="_on_game_session_menu_button_pressed"] -[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/SearchButton" to="." method="_on_search_button_pressed"] -[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer/ZoomInButton" to="." method="_on_zoom_in_button_pressed"] -[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer/ZoomOutButton" to="." method="_on_zoom_out_button_pressed"] diff --git a/game/src/Game/GameSession/Menubar/Menubar.gd b/game/src/Game/GameSession/Menubar/Menubar.gd new file mode 100644 index 0000000..5e0bdc7 --- /dev/null +++ b/game/src/Game/GameSession/Menubar/Menubar.gd @@ -0,0 +1,120 @@ +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 + +var _mapmode_button_group : ButtonGroup + +# REQUIREMENTS: +# * UI-550, UI-552, UI-554, UI-561, UI-562, UI-563 +func _add_mapmode_button(index : int) -> void: + var button: GUIIconButton = get_gui_icon_button_from_nodepath("./menubar/mapmode_{i}".format({"i":index+1})) + if button: + button.tooltip_string = tr(GameSingleton.get_mapmode_identifier(index)) #tr("MAPMODE_{i}".format({"i":index+1})) <-- TODO: use for vanilla mapmodes when that gets changed on sim + button.toggle_mode = true + button.button_group = _mapmode_button_group + button.pressed.connect( + func() -> void: + _mapmode_pressed(index) + ) + 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: implement + ^"./menubar/OPENbutton", # not quite sure what this is + ^"./menubar/menubar_plans_toggle", # TODO: implement, v low priority + ^"./menubar/menubar_plans_open", # TODO: implement, v low priority + ^"./menubar/menubar_mail_bg", # TODO: implement + ^"./menubar/menubar_msg_diplo", # TODO: implement + ^"./menubar/menubar_msg_settings", # TODO: implement + ^"./menubar/menubar_msg_combat", # TODO: implement + ^"./menubar/menubar_msg_diplo", # TODO: implement + ^"./menubar/menubar_msg_unit", # TODO: implement + ^"./menubar/menubar_msg_province", # TODO: implement + ^"./menubar/menubar_msg_event", # TODO: implement + ^"./menubar/menubar_msg_other", # TODO: implement + ^"./menubar/chat_window", # TODO: Multiplayer + ]) + + 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 + + # TODO: add keyboard shortcuts (and shortcut tooltips) where vanilla does by default + use key bindings in settings + + var menu_button: GUIIconButton = get_gui_icon_button_from_nodepath(^"./menubar/menu_button") + if menu_button: + menu_button.tooltip_string = tr("M_MENU_BUTTON") + menu_button.pressed.connect(_on_game_session_menu_button_pressed) + + # TODO: implement ledger + var ledger_button: GUIIconButton = get_gui_icon_button_from_nodepath(^"./menubar/ledger_button") + if ledger_button: + ledger_button.tooltip_string = tr("M_LEDGER_BUTTON") + + var search_button: GUIIconButton = get_gui_icon_button_from_nodepath(^"./menubar/button_goto") + if search_button: + search_button.tooltip_string = tr("M_GOTO_BUTTON") + search_button.pressed.connect(_on_search_button_pressed) + + var zoom_in_button: GUIIconButton = 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: GUIIconButton = 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() + # TODO: make this more v2esque, project our box onto the v2 image. Low priority. + 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() + for index : int in GameSingleton.get_mapmode_count(): + _add_mapmode_button(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(index : int) -> void: + GameSingleton.set_mapmode(GameSingleton.get_mapmode_identifier(index)) + +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() diff --git a/game/src/Game/GameSession/MapControlPanel/Minimap.gd b/game/src/Game/GameSession/Menubar/Minimap.gd index 7cf1794..3b69147 100644 --- a/game/src/Game/GameSession/MapControlPanel/Minimap.gd +++ b/game/src/Game/GameSession/Menubar/Minimap.gd @@ -4,14 +4,13 @@ signal minimap_clicked(pos_clicked : Vector2) const _action_click : StringName = &"map_click" -@export var _minimap_texture : Control var _minimap_shader : ShaderMaterial var _viewport_points : PackedVector2Array func _ready() -> void: - _minimap_texture.custom_minimum_size = Vector2(GameSingleton.get_map_aspect_ratio(), 1.0) * 150 - var minimap_material := _minimap_texture.get_material() + custom_minimum_size = Vector2(GameSingleton.get_map_aspect_ratio(), 1.0) * 150 + var minimap_material := get_material() if GameLoader.ShaderManager.set_up_shader(minimap_material, false) != OK: push_error("Failed to set up minimap shader") else: @@ -32,7 +31,7 @@ func _draw() -> void: # REQUIREMENTS # * SS-81 # * UIFUN-127 -func _gui_input(event : InputEvent) -> void: +func _gui_input(_event : InputEvent) -> void: if Input.is_action_pressed(_action_click): var pos_clicked := get_local_mouse_position() / size - Vector2(0.5, 0.5) if abs(pos_clicked.x) < 0.5 and abs(pos_clicked.y) < 0.5: diff --git a/game/src/Game/GameSession/MapControlPanel/Minimap.gdshader b/game/src/Game/GameSession/Menubar/Minimap.gdshader index 271b809..271b809 100644 --- a/game/src/Game/GameSession/MapControlPanel/Minimap.gdshader +++ b/game/src/Game/GameSession/Menubar/Minimap.gdshader |