From 9ed9ee209ef9accebb9ec0d81ec58b569d680b6a Mon Sep 17 00:00:00 2001 From: Hop311 Date: Wed, 10 May 2023 23:26:00 +0100 Subject: Fix building buttons and terrain texture imports --- extension/deps/openvic2-simulation | 2 +- extension/src/GameSingleton.cpp | 14 ++- game/art/terrain/desert_rocky.png.import | 33 +----- game/art/terrain/desert_smooth.png.import | 33 +----- game/art/terrain/farmlands.png.import | 33 +----- game/art/terrain/mountains.png.import | 33 +----- game/art/terrain/ocean.png.import | 33 +----- game/localisation/en_GB/menus.csv | 4 +- game/localisation/en_US/menus.csv | 2 +- game/localisation/fr_FR/menus.csv | 2 +- game/src/GameSession/GameSession.tscn | 4 +- game/src/GameSession/MapControlPanel.gd | 57 ---------- game/src/GameSession/MapControlPanel.tscn | 107 ------------------ .../GameSession/MapControlPanel/MapControlPanel.gd | 57 ++++++++++ .../MapControlPanel/MapControlPanel.tscn | 107 ++++++++++++++++++ game/src/GameSession/MapControlPanel/Minimap.gd | 105 ++++++++++++++++++ .../GameSession/MapControlPanel/Minimap.gdshader | 18 +++ game/src/GameSession/Minimap.gd | 105 ------------------ game/src/GameSession/Minimap.gdshader | 18 --- game/src/GameSession/ProvinceOverviewPanel.gd | 96 ---------------- game/src/GameSession/ProvinceOverviewPanel.tscn | 86 --------------- .../ProvinceOverviewPanel/ProvinceOverviewPanel.gd | 121 +++++++++++++++++++++ .../ProvinceOverviewPanel.tscn | 86 +++++++++++++++ game/src/GameSession/TerrainMap.gdshader | 2 +- game/src/MainMenu/ReleaseInfoBox.gd | 2 +- 25 files changed, 516 insertions(+), 644 deletions(-) delete mode 100644 game/src/GameSession/MapControlPanel.gd delete mode 100644 game/src/GameSession/MapControlPanel.tscn create mode 100644 game/src/GameSession/MapControlPanel/MapControlPanel.gd create mode 100644 game/src/GameSession/MapControlPanel/MapControlPanel.tscn create mode 100644 game/src/GameSession/MapControlPanel/Minimap.gd create mode 100644 game/src/GameSession/MapControlPanel/Minimap.gdshader delete mode 100644 game/src/GameSession/Minimap.gd delete mode 100644 game/src/GameSession/Minimap.gdshader delete mode 100644 game/src/GameSession/ProvinceOverviewPanel.gd delete mode 100644 game/src/GameSession/ProvinceOverviewPanel.tscn create mode 100644 game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd create mode 100644 game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn diff --git a/extension/deps/openvic2-simulation b/extension/deps/openvic2-simulation index 3550c45..339e027 160000 --- a/extension/deps/openvic2-simulation +++ b/extension/deps/openvic2-simulation @@ -1 +1 @@ -Subproject commit 3550c455526eb6f8935f488810e73fe01a1177a9 +Subproject commit 339e0278a2064f7eeb152fe8c5778840b609e9f3 diff --git a/extension/src/GameSingleton.cpp b/extension/src/GameSingleton.cpp index 44bf874..882bfcf 100644 --- a/extension/src/GameSingleton.cpp +++ b/extension/src/GameSingleton.cpp @@ -313,12 +313,15 @@ Error GameSingleton::_parse_terrain_entry(String const& identifier, Variant cons } Error GameSingleton::load_terrain_variant_file(String const& file_path) { - Error parse_err = _parse_json_dictionary_file("terrain variants", file_path, "", + const Error err = _parse_json_dictionary_file("terrain variants", file_path, "", [this](String const& identifier, Variant const& entry) -> Error { return _parse_terrain_entry(identifier, entry); }); terrain_variants.lock(); - if (terrain_variants.get_item_count() == 0) parse_err = FAILED; + if (err != OK || terrain_variants.get_item_count() == 0) { + UtilityFunctions::push_error("Failed to load terrain textures!"); + return FAILED; + } Array terrain_images; for (TerrainVariant const& var : terrain_variants.get_items()) { @@ -327,12 +330,11 @@ Error GameSingleton::load_terrain_variant_file(String const& file_path) { } terrain_texture.instantiate(); - const Error texturearray_err = terrain_texture->create_from_images(terrain_images); - if (texturearray_err != OK) { + if (terrain_texture->create_from_images(terrain_images) != OK) { UtilityFunctions::push_error("Failed to create terrain texture array!"); - return texturearray_err; + return FAILED; } - return parse_err; + return OK; } Error GameSingleton::load_map_images(String const& province_image_path, String const& terrain_image_path) { diff --git a/game/art/terrain/desert_rocky.png.import b/game/art/terrain/desert_rocky.png.import index b8104eb..8dd0c09 100644 --- a/game/art/terrain/desert_rocky.png.import +++ b/game/art/terrain/desert_rocky.png.import @@ -1,34 +1,3 @@ [remap] -importer="texture" -type="CompressedTexture2D" -uid="uid://do6rtj6cejxo7" -path="res://.godot/imported/desert_rocky.png-2c26845e144e1e8b9c55419654df6654.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://art/terrain/desert_rocky.png" -dest_files=["res://.godot/imported/desert_rocky.png-2c26845e144e1e8b9c55419654df6654.ctex"] - -[params] - -compress/mode=3 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=2 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=false -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=0 +importer="keep" diff --git a/game/art/terrain/desert_smooth.png.import b/game/art/terrain/desert_smooth.png.import index bc0513d..8dd0c09 100644 --- a/game/art/terrain/desert_smooth.png.import +++ b/game/art/terrain/desert_smooth.png.import @@ -1,34 +1,3 @@ [remap] -importer="texture" -type="CompressedTexture2D" -uid="uid://beo5i11jfu3al" -path="res://.godot/imported/desert_smooth.png-58a5349b112e9e97cf3426b380f022ef.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://art/terrain/desert_smooth.png" -dest_files=["res://.godot/imported/desert_smooth.png-58a5349b112e9e97cf3426b380f022ef.ctex"] - -[params] - -compress/mode=3 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=2 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=false -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=0 +importer="keep" diff --git a/game/art/terrain/farmlands.png.import b/game/art/terrain/farmlands.png.import index 4a06b1f..8dd0c09 100644 --- a/game/art/terrain/farmlands.png.import +++ b/game/art/terrain/farmlands.png.import @@ -1,34 +1,3 @@ [remap] -importer="texture" -type="CompressedTexture2D" -uid="uid://ckf222w5usrsu" -path="res://.godot/imported/farmlands.png-821213ab9dba19cea6f6c966b3a3760b.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://art/terrain/farmlands.png" -dest_files=["res://.godot/imported/farmlands.png-821213ab9dba19cea6f6c966b3a3760b.ctex"] - -[params] - -compress/mode=3 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=2 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=false -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=0 +importer="keep" diff --git a/game/art/terrain/mountains.png.import b/game/art/terrain/mountains.png.import index 47a00fd..8dd0c09 100644 --- a/game/art/terrain/mountains.png.import +++ b/game/art/terrain/mountains.png.import @@ -1,34 +1,3 @@ [remap] -importer="texture" -type="CompressedTexture2D" -uid="uid://c20q2sqf38eq8" -path="res://.godot/imported/mountains.png-f1ab7d9b0a0deb485923c40b1cfb258e.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://art/terrain/mountains.png" -dest_files=["res://.godot/imported/mountains.png-f1ab7d9b0a0deb485923c40b1cfb258e.ctex"] - -[params] - -compress/mode=3 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=2 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=false -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=0 +importer="keep" diff --git a/game/art/terrain/ocean.png.import b/game/art/terrain/ocean.png.import index 644f7e7..8dd0c09 100644 --- a/game/art/terrain/ocean.png.import +++ b/game/art/terrain/ocean.png.import @@ -1,34 +1,3 @@ [remap] -importer="texture" -type="CompressedTexture2D" -uid="uid://dlvvim3j7dbnn" -path="res://.godot/imported/ocean.png-3d7e213c3fca805d033e0d3bf567fc01.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://art/terrain/ocean.png" -dest_files=["res://.godot/imported/ocean.png-3d7e213c3fca805d033e0d3bf567fc01.ctex"] - -[params] - -compress/mode=3 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=2 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=false -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=0 +importer="keep" diff --git a/game/localisation/en_GB/menus.csv b/game/localisation/en_GB/menus.csv index 6351b59..999483f 100644 --- a/game/localisation/en_GB/menus.csv +++ b/game/localisation/en_GB/menus.csv @@ -7,7 +7,7 @@ MAINMENU_MULTIPLAYER,Multiplayer MAINMENU_OPTIONS,Options MAINMENU_CREDITS,Credits MAINMENU_EXIT,Exit -MAINMENU_CHECKSUM,Checksum %s +MAINMENU_CHECKSUM,Checksum {checksum} ,, Options OPTIONS_RESET,R @@ -70,7 +70,7 @@ DIALOG_SAVE_AND_QUIT,Save and Quit ,, Province Overview Panel province_MISSING,No Province region_MISSING,No Region -LIFE_RATING_TOOLTIP,Liferating: %d +LIFE_RATING_TOOLTIP,Liferating: {life_rating} rgo_MISSING,No RGO building_MISSING,No Building building_fort,Fort diff --git a/game/localisation/en_US/menus.csv b/game/localisation/en_US/menus.csv index 88cf12c..c69d36b 100644 --- a/game/localisation/en_US/menus.csv +++ b/game/localisation/en_US/menus.csv @@ -7,7 +7,7 @@ MAINMENU_MULTIPLAYER,Multiplayer MAINMENU_OPTIONS,Options MAINMENU_CREDITS,Credits MAINMENU_EXIT,Exit -MAINMENU_CHECKSUM,Checksum %s +MAINMENU_CHECKSUM,Checksum {checksum} ,, Options OPTIONS_RESET,R diff --git a/game/localisation/fr_FR/menus.csv b/game/localisation/fr_FR/menus.csv index 3794695..2e395f7 100644 --- a/game/localisation/fr_FR/menus.csv +++ b/game/localisation/fr_FR/menus.csv @@ -7,7 +7,7 @@ MAINMENU_MULTIPLAYER,Multijouer MAINMENU_OPTIONS,Options MAINMENU_CREDITS,Credits MAINMENU_EXIT,Quitter -MAINMENU_CHECKSUM,Somme de contrĂ´le %s +MAINMENU_CHECKSUM,Somme de contrĂ´le {checksum} ,, Options OPTIONS_RESET,R diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn index 411a829..ce3471f 100644 --- a/game/src/GameSession/GameSession.tscn +++ b/game/src/GameSession/GameSession.tscn @@ -2,10 +2,10 @@ [ext_resource type="Script" path="res://src/GameSession/GameSession.gd" id="1_eklvp"] [ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/MusicConductor/MusicPlayer.tscn" id="2_kt6aa"] -[ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/GameSession/MapControlPanel.tscn" id="3_afh6d"] +[ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/GameSession/MapControlPanel/MapControlPanel.tscn" id="3_afh6d"] [ext_resource type="PackedScene" uid="uid://dvdynl6eir40o" path="res://src/GameSession/GameSessionMenu.tscn" id="3_bvmqh"] [ext_resource type="PackedScene" uid="uid://dkehmdnuxih2r" path="res://src/GameSession/MapView.tscn" id="4_xkg5j"] -[ext_resource type="PackedScene" uid="uid://byq323jbel48u" path="res://src/GameSession/ProvinceOverviewPanel.tscn" id="5_osjnn"] +[ext_resource type="PackedScene" uid="uid://byq323jbel48u" path="res://src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn" id="5_osjnn"] [ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/OptionMenu/OptionsMenu.tscn" id="6_p5mnx"] [ext_resource type="PackedScene" uid="uid://dd8k3p7r3huwc" path="res://src/GameSession/GameSpeedPanel.tscn" id="7_myy4q"] diff --git a/game/src/GameSession/MapControlPanel.gd b/game/src/GameSession/MapControlPanel.gd deleted file mode 100644 index 0cef057..0000000 --- a/game/src/GameSession/MapControlPanel.gd +++ /dev/null @@ -1,57 +0,0 @@ -extends PanelContainer - -signal game_session_menu_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 -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 - _mapmodes_grid.add_child(button) - if _mapmode_button_group.get_pressed_button() == null: - button.button_pressed = true - -func _ready(): - _mapmode_button_group = ButtonGroup.new() - _mapmode_button_group.pressed.connect(_mapmode_pressed) - for index 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() - -# REQUIREMENTS: -# * SS-76 -# * UIFUN-129, UIFUN-131, UIFUN-133 -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/GameSession/MapControlPanel.tscn b/game/src/GameSession/MapControlPanel.tscn deleted file mode 100644 index 0da2d5a..0000000 --- a/game/src/GameSession/MapControlPanel.tscn +++ /dev/null @@ -1,107 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://g524p8lr574w"] - -[ext_resource type="Script" path="res://src/GameSession/MapControlPanel.gd" id="1_ign64"] -[ext_resource type="Shader" path="res://src/GameSession/Minimap.gdshader" id="2_rinsg"] -[ext_resource type="Script" path="res://src/GameSession/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" -mouse_filter = 1 -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 = 11 - -[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 -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 -mouse_filter = 1 -text = "L" - -[node name="FindButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] -editor_description = "UI-861" -layout_mode = 2 -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 -mouse_filter = 1 -text = "+" - -[node name="ZoomOutButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer"] -editor_description = "UI-863" -layout_mode = 2 -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/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/GameSession/MapControlPanel/MapControlPanel.gd b/game/src/GameSession/MapControlPanel/MapControlPanel.gd new file mode 100644 index 0000000..0cef057 --- /dev/null +++ b/game/src/GameSession/MapControlPanel/MapControlPanel.gd @@ -0,0 +1,57 @@ +extends PanelContainer + +signal game_session_menu_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 +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 + _mapmodes_grid.add_child(button) + if _mapmode_button_group.get_pressed_button() == null: + button.button_pressed = true + +func _ready(): + _mapmode_button_group = ButtonGroup.new() + _mapmode_button_group.pressed.connect(_mapmode_pressed) + for index 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() + +# REQUIREMENTS: +# * SS-76 +# * UIFUN-129, UIFUN-131, UIFUN-133 +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/GameSession/MapControlPanel/MapControlPanel.tscn b/game/src/GameSession/MapControlPanel/MapControlPanel.tscn new file mode 100644 index 0000000..91e2e7e --- /dev/null +++ b/game/src/GameSession/MapControlPanel/MapControlPanel.tscn @@ -0,0 +1,107 @@ +[gd_scene load_steps=7 format=3 uid="uid://g524p8lr574w"] + +[ext_resource type="Script" path="res://src/GameSession/MapControlPanel/MapControlPanel.gd" id="1_ign64"] +[ext_resource type="Shader" path="res://src/GameSession/MapControlPanel/Minimap.gdshader" id="2_rinsg"] +[ext_resource type="Script" path="res://src/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" +mouse_filter = 1 +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 = 11 + +[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 +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 +mouse_filter = 1 +text = "L" + +[node name="FindButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] +editor_description = "UI-861" +layout_mode = 2 +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 +mouse_filter = 1 +text = "+" + +[node name="ZoomOutButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer"] +editor_description = "UI-863" +layout_mode = 2 +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/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/GameSession/MapControlPanel/Minimap.gd b/game/src/GameSession/MapControlPanel/Minimap.gd new file mode 100644 index 0000000..1f9b75e --- /dev/null +++ b/game/src/GameSession/MapControlPanel/Minimap.gd @@ -0,0 +1,105 @@ +extends Control + +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(): + _minimap_texture.custom_minimum_size = Vector2(GameSingleton.get_aspect_ratio(), 1.0) * 150 + var minimap_material := _minimap_texture.get_material() + if Events.ShaderManager.set_up_shader(minimap_material, false) != OK: + push_error("Failed to set up minimap shader") + else: + _minimap_shader = minimap_material + GameSingleton.province_selected.connect(_on_province_selected) + +func _on_province_selected(index : int) -> void: + if _minimap_shader != null: + _minimap_shader.set_shader_parameter(Events.ShaderManager.param_selected_index, index) + +# REQUIREMENTS +# * SS-80 +# * UI-752 +func _draw() -> void: + if _viewport_points.size() > 1: + draw_multiline(_viewport_points, Color.WHITE, -1) + +# REQUIREMENTS +# * SS-81 +# * UIFUN-127 +func _unhandled_input(event : InputEvent): + if event is InputEventMouse and 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: + minimap_clicked.emit(pos_clicked) + +# Returns the point on the line going through p and q with the specific x coord +func _intersect_x(p : Vector2, q : Vector2, x : float) -> Vector2: + if p.x == q.x: + return Vector2(x, 0.5 * (p.y + q.y)) + var t := (x - q.x) / (p.x - q.x) + return q + t * (p - q) + +# Returns the point on the line going through p and q with the specific y coord +func _intersect_y(p : Vector2, q : Vector2, y : float) -> Vector2: + if p.y == q.y: + return Vector2(0.5 * (p.x + q.x), y) + var t := (y - q.y) / (p.y - q.y) + return q + t * (p - q) + +const _one_x := Vector2(1, 0) + +func _add_line_looped_over_x(left : Vector2, right : Vector2) -> void: + if left.x < 0: + if right.x < 0: + _viewport_points.push_back(left + _one_x) + _viewport_points.push_back(right + _one_x) + else: + var mid_point := _intersect_x(left, right, 0) + _viewport_points.push_back(mid_point) + _viewport_points.push_back(right) + mid_point.x = 1 + _viewport_points.push_back(left + _one_x) + _viewport_points.push_back(mid_point) + elif right.x > 1: + if left.x > 1: + _viewport_points.push_back(left - _one_x) + _viewport_points.push_back(right - _one_x) + else: + var mid_point := _intersect_x(left, right, 1) + _viewport_points.push_back(left) + _viewport_points.push_back(mid_point) + mid_point.x = 0 + _viewport_points.push_back(mid_point) + _viewport_points.push_back(right - _one_x) + else: + _viewport_points.push_back(left) + _viewport_points.push_back(right) + +# This can break if the viewport is rotated too far! +func _on_map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) -> void: + # Bound far y coords + if far_left.y < 0: + far_left = _intersect_y(near_left, far_left, 0) + if far_right.y < 0: + far_right = _intersect_y(near_right, far_right, 0) + # Bound near y coords + if near_left.y > 1: + near_left = _intersect_y(near_left, far_left, 1) + if near_right.y > 1: + near_right = _intersect_y(near_right, far_right, 1) + + _viewport_points.clear() + _add_line_looped_over_x(near_left, near_right) + _add_line_looped_over_x(far_left, far_right) + _add_line_looped_over_x(far_left, near_left) + _add_line_looped_over_x(near_right, far_right) + + for i in _viewport_points.size(): + _viewport_points[i] *= size + queue_redraw() diff --git a/game/src/GameSession/MapControlPanel/Minimap.gdshader b/game/src/GameSession/MapControlPanel/Minimap.gdshader new file mode 100644 index 0000000..608abe2 --- /dev/null +++ b/game/src/GameSession/MapControlPanel/Minimap.gdshader @@ -0,0 +1,18 @@ +shader_type canvas_item; + +#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc" + +// Index of the currently selected province +uniform uint selected_index; + +const vec3 land_colour = vec3(0.5); +const vec3 selected_colour = vec3(1.0, 1.0, 0.0); + +void fragment() { + uvec3 data = read_uvec3(UV); + uint index = uvec2_to_uint(data.rg); + float is_land = float(data.b != 0u); + float is_selected = float(index == selected_index); + COLOR.rgb = mix(COLOR.rgb, land_colour, is_land); + COLOR.rgb = mix(COLOR.rgb, selected_colour, is_selected); +} diff --git a/game/src/GameSession/Minimap.gd b/game/src/GameSession/Minimap.gd deleted file mode 100644 index 1f9b75e..0000000 --- a/game/src/GameSession/Minimap.gd +++ /dev/null @@ -1,105 +0,0 @@ -extends Control - -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(): - _minimap_texture.custom_minimum_size = Vector2(GameSingleton.get_aspect_ratio(), 1.0) * 150 - var minimap_material := _minimap_texture.get_material() - if Events.ShaderManager.set_up_shader(minimap_material, false) != OK: - push_error("Failed to set up minimap shader") - else: - _minimap_shader = minimap_material - GameSingleton.province_selected.connect(_on_province_selected) - -func _on_province_selected(index : int) -> void: - if _minimap_shader != null: - _minimap_shader.set_shader_parameter(Events.ShaderManager.param_selected_index, index) - -# REQUIREMENTS -# * SS-80 -# * UI-752 -func _draw() -> void: - if _viewport_points.size() > 1: - draw_multiline(_viewport_points, Color.WHITE, -1) - -# REQUIREMENTS -# * SS-81 -# * UIFUN-127 -func _unhandled_input(event : InputEvent): - if event is InputEventMouse and 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: - minimap_clicked.emit(pos_clicked) - -# Returns the point on the line going through p and q with the specific x coord -func _intersect_x(p : Vector2, q : Vector2, x : float) -> Vector2: - if p.x == q.x: - return Vector2(x, 0.5 * (p.y + q.y)) - var t := (x - q.x) / (p.x - q.x) - return q + t * (p - q) - -# Returns the point on the line going through p and q with the specific y coord -func _intersect_y(p : Vector2, q : Vector2, y : float) -> Vector2: - if p.y == q.y: - return Vector2(0.5 * (p.x + q.x), y) - var t := (y - q.y) / (p.y - q.y) - return q + t * (p - q) - -const _one_x := Vector2(1, 0) - -func _add_line_looped_over_x(left : Vector2, right : Vector2) -> void: - if left.x < 0: - if right.x < 0: - _viewport_points.push_back(left + _one_x) - _viewport_points.push_back(right + _one_x) - else: - var mid_point := _intersect_x(left, right, 0) - _viewport_points.push_back(mid_point) - _viewport_points.push_back(right) - mid_point.x = 1 - _viewport_points.push_back(left + _one_x) - _viewport_points.push_back(mid_point) - elif right.x > 1: - if left.x > 1: - _viewport_points.push_back(left - _one_x) - _viewport_points.push_back(right - _one_x) - else: - var mid_point := _intersect_x(left, right, 1) - _viewport_points.push_back(left) - _viewport_points.push_back(mid_point) - mid_point.x = 0 - _viewport_points.push_back(mid_point) - _viewport_points.push_back(right - _one_x) - else: - _viewport_points.push_back(left) - _viewport_points.push_back(right) - -# This can break if the viewport is rotated too far! -func _on_map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) -> void: - # Bound far y coords - if far_left.y < 0: - far_left = _intersect_y(near_left, far_left, 0) - if far_right.y < 0: - far_right = _intersect_y(near_right, far_right, 0) - # Bound near y coords - if near_left.y > 1: - near_left = _intersect_y(near_left, far_left, 1) - if near_right.y > 1: - near_right = _intersect_y(near_right, far_right, 1) - - _viewport_points.clear() - _add_line_looped_over_x(near_left, near_right) - _add_line_looped_over_x(far_left, far_right) - _add_line_looped_over_x(far_left, near_left) - _add_line_looped_over_x(near_right, far_right) - - for i in _viewport_points.size(): - _viewport_points[i] *= size - queue_redraw() diff --git a/game/src/GameSession/Minimap.gdshader b/game/src/GameSession/Minimap.gdshader deleted file mode 100644 index 8b68108..0000000 --- a/game/src/GameSession/Minimap.gdshader +++ /dev/null @@ -1,18 +0,0 @@ -shader_type canvas_item; - -#include "ProvinceIndexSampler.gdshaderinc" - -// Index of the currently selected province -uniform uint selected_index; - -const vec3 land_colour = vec3(0.5); -const vec3 selected_colour = vec3(1.0, 1.0, 0.0); - -void fragment() { - uvec3 data = read_uvec3(UV); - uint index = uvec2_to_uint(data.rg); - float is_land = float(data.b != 0u); - float is_selected = float(index == selected_index); - COLOR.rgb = mix(COLOR.rgb, land_colour, is_land); - COLOR.rgb = mix(COLOR.rgb, selected_colour, is_selected); -} diff --git a/game/src/GameSession/ProvinceOverviewPanel.gd b/game/src/GameSession/ProvinceOverviewPanel.gd deleted file mode 100644 index 4172860..0000000 --- a/game/src/GameSession/ProvinceOverviewPanel.gd +++ /dev/null @@ -1,96 +0,0 @@ -extends PanelContainer - -@export var _province_name_label : Label -@export var _region_name_label : Label -@export var _life_rating_bar : ProgressBar -@export var _rgo_icon_texture_rect : TextureRect -@export var _rgo_name_label : Label -@export var _buildings_container : Container - -const _missing_suffix : String = "_MISSING" - -var _selected_index : int: - get: return _selected_index - set(v): - _selected_index = v - update_info() -var _province_info : Dictionary - -func _ready(): - GameSingleton.province_selected.connect(_on_province_selected) - GameSingleton.state_updated.connect(update_info) - update_info() - -enum { CANNOT_EXPAND, CAN_EXPAND, PREPARING, EXPANDING } - -func _expand_building(building_identifier : String) -> void: - if GameSingleton.expand_building(_selected_index, building_identifier) != OK: - push_error("Failed to expand ", building_identifier, " in province #", _selected_index); - -# REQUIREMENTS: -# * UI-183, UI-185, UI-186, UI-765, UI-187, UI-188, UI-189 -# * UI-191, UI-193, UI-194, UI-766, UI-195, UI-196, UI-197 -# * UI-199, UI-201, UI-202, UI-767, UI-203, UI-204, UI-205 -func _add_building(building : Dictionary) -> void: - const _expand_province_building : String = "EXPAND_PROVINCE_BUILDING" - - var level_label := Label.new() - level_label.text = str(building.get(GameSingleton.get_building_info_level_key(), 0)) - _buildings_container.add_child(level_label) - - var building_label := Label.new() - building_label.text = building.get(GameSingleton.get_building_info_building_key(), - GameSingleton.get_building_info_building_key() + _missing_suffix) - _buildings_container.add_child(building_label) - - var expansion_state : int = building.get(GameSingleton.get_building_info_expansion_state_key(), - CANNOT_EXPAND) - if expansion_state == PREPARING or expansion_state == EXPANDING: - var progress_bar := ProgressBar.new() - progress_bar.max_value = 1 - progress_bar.value = building.get(GameSingleton.get_building_info_expansion_progress_key(), 0) - progress_bar.size_flags_horizontal = Control.SIZE_EXPAND_FILL - progress_bar.mouse_filter = Control.MOUSE_FILTER_PASS - _buildings_container.add_child(progress_bar) - else: - var expand_button := Button.new() - expand_button.text = _expand_province_building - expand_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL - expand_button.mouse_filter = Control.MOUSE_FILTER_PASS - expand_button.disabled = expansion_state != CAN_EXPAND - expand_button.pressed.connect(func(): _expand_building(building_label.text)) - _buildings_container.add_child(expand_button) - -func update_info() -> void: - const _life_rating_tooltip : String = "LIFE_RATING_TOOLTIP" - - _province_info = GameSingleton.get_province_info_from_index(_selected_index) - if _province_info: - _province_name_label.text = _province_info.get(GameSingleton.get_province_info_province_key(), - GameSingleton.get_province_info_province_key() + _missing_suffix) - _region_name_label.text = _province_info.get(GameSingleton.get_province_info_region_key(), - GameSingleton.get_province_info_region_key() + _missing_suffix) - - _life_rating_bar.value = _province_info.get(GameSingleton.get_province_info_life_rating_key(), 0) - _life_rating_bar.tooltip_text = tr(_life_rating_tooltip) % _life_rating_bar.value - - _rgo_name_label.text = _province_info.get(GameSingleton.get_province_info_rgo_key(), - GameSingleton.get_province_info_rgo_key() + _missing_suffix) - _rgo_icon_texture_rect.texture = GameSingleton.get_good_icon_texture(_rgo_name_label.text) - - for child in _buildings_container.get_children(): - _buildings_container.remove_child(child) - child.queue_free() - var buildings : Array = _province_info.get(GameSingleton.get_province_info_buildings_key(), []) - for building in buildings: - _add_building(building) - - show() - else: - hide() - -func _on_province_selected(index : int) -> void: - _selected_index = index - -func _on_close_button_pressed() -> void: - GameSingleton.set_selected_province(0) diff --git a/game/src/GameSession/ProvinceOverviewPanel.tscn b/game/src/GameSession/ProvinceOverviewPanel.tscn deleted file mode 100644 index 722299b..0000000 --- a/game/src/GameSession/ProvinceOverviewPanel.tscn +++ /dev/null @@ -1,86 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://byq323jbel48u"] - -[ext_resource type="Script" path="res://src/GameSession/ProvinceOverviewPanel.gd" id="1_3n8k5"] - -[node name="ProvinceOverviewPanel" type="PanelContainer" node_paths=PackedStringArray("_province_name_label", "_region_name_label", "_life_rating_bar", "_rgo_icon_texture_rect", "_rgo_name_label", "_buildings_container")] -editor_description = "UI-56" -anchors_preset = 2 -anchor_top = 1.0 -anchor_bottom = 1.0 -offset_top = -300.0 -offset_right = 200.0 -grow_vertical = 0 -mouse_filter = 1 -script = ExtResource("1_3n8k5") -_province_name_label = NodePath("PanelList/TopBarList/NameList/ProvinceName") -_region_name_label = NodePath("PanelList/TopBarList/NameList/RegionName") -_life_rating_bar = NodePath("PanelList/TopBarList/NameList/LifeRatingBar") -_rgo_icon_texture_rect = NodePath("PanelList/InteractList/RGOInfo/RGOIcon") -_rgo_name_label = NodePath("PanelList/InteractList/RGOInfo/RGOName") -_buildings_container = NodePath("PanelList/InteractList/BuildingsContainer") - -[node name="PanelList" type="VBoxContainer" parent="."] -layout_mode = 2 - -[node name="TopBarList" type="HBoxContainer" parent="PanelList"] -layout_mode = 2 - -[node name="NameList" type="VBoxContainer" parent="PanelList/TopBarList"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 0 - -[node name="ProvinceName" type="Label" parent="PanelList/TopBarList/NameList"] -editor_description = "UI-57" -layout_mode = 2 -text = "province_MISSING" -vertical_alignment = 1 - -[node name="RegionName" type="Label" parent="PanelList/TopBarList/NameList"] -editor_description = "UI-58" -layout_mode = 2 -text = "region_MISSING" -vertical_alignment = 1 - -[node name="LifeRatingBar" type="ProgressBar" parent="PanelList/TopBarList/NameList"] -editor_description = "UI-62" -layout_mode = 2 -mouse_filter = 1 - -[node name="CloseButton" type="Button" parent="PanelList/TopBarList"] -custom_minimum_size = Vector2(30, 30) -layout_mode = 2 -size_flags_vertical = 0 -mouse_filter = 1 -text = "X" - -[node name="InteractList" type="VBoxContainer" parent="PanelList"] -layout_mode = 2 -size_flags_vertical = 3 - -[node name="HSeparator" type="HSeparator" parent="PanelList/InteractList"] -layout_mode = 2 -mouse_filter = 1 - -[node name="RGOInfo" type="HBoxContainer" parent="PanelList/InteractList"] -editor_description = "UI-112" -layout_mode = 2 - -[node name="RGOIcon" type="TextureRect" parent="PanelList/InteractList/RGOInfo"] -editor_description = "UI-100" -layout_mode = 2 - -[node name="RGOName" type="Label" parent="PanelList/InteractList/RGOInfo"] -layout_mode = 2 -text = "rgo_MISSING" -vertical_alignment = 1 - -[node name="HSeparator2" type="HSeparator" parent="PanelList/InteractList"] -layout_mode = 2 -mouse_filter = 1 - -[node name="BuildingsContainer" type="GridContainer" parent="PanelList/InteractList"] -layout_mode = 2 -columns = 3 - -[connection signal="pressed" from="PanelList/TopBarList/CloseButton" to="." method="_on_close_button_pressed"] diff --git a/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd b/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd new file mode 100644 index 0000000..0d8d8b7 --- /dev/null +++ b/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd @@ -0,0 +1,121 @@ +extends PanelContainer + +@export var _province_name_label : Label +@export var _region_name_label : Label +@export var _life_rating_bar : ProgressBar +@export var _rgo_icon_texture_rect : TextureRect +@export var _rgo_name_label : Label +@export var _buildings_container : Container + +const _missing_suffix : String = "_MISSING" + +var _selected_index : int: + get: return _selected_index + set(v): + _selected_index = v + update_info() +var _province_info : Dictionary + +func _ready(): + GameSingleton.province_selected.connect(_on_province_selected) + GameSingleton.state_updated.connect(update_info) + update_info() + +enum { CANNOT_EXPAND, CAN_EXPAND, PREPARING, EXPANDING } + +func _expand_building(building_identifier : String) -> void: + if GameSingleton.expand_building(_selected_index, building_identifier) != OK: + push_error("Failed to expand ", building_identifier, " in province #", _selected_index); + +# Each building row contains: +# level - Level Label +# name - Name Label +# button - Expansion Button +# progress_bar - Expansion ProgressBar +var _building_rows : Array[Dictionary] + +# REQUIREMENTS: +# * UI-183, UI-185, UI-186, UI-765, UI-187, UI-188, UI-189 +# * UI-191, UI-193, UI-194, UI-766, UI-195, UI-196, UI-197 +# * UI-199, UI-201, UI-202, UI-767, UI-203, UI-204, UI-205 +func _add_building_row() -> void: + var row : Dictionary + + row.level = Label.new() + row.level.text = "X" + _buildings_container.add_child(row.level) + + row.name = Label.new() + row.name.text = GameSingleton.get_building_info_building_key() + _missing_suffix + _buildings_container.add_child(row.name) + + row.button = Button.new() + row.button.text = "EXPAND_PROVINCE_BUILDING" + row.button.size_flags_horizontal = Control.SIZE_EXPAND_FILL + row.button.mouse_filter = Control.MOUSE_FILTER_PASS + row.button.pressed.connect(func(): _expand_building(row.name.text)) + _buildings_container.add_child(row.button) + + row.progress_bar = ProgressBar.new() + row.progress_bar.max_value = 1 + row.progress_bar.size_flags_horizontal = Control.SIZE_EXPAND_FILL + row.progress_bar.mouse_filter = Control.MOUSE_FILTER_PASS + _buildings_container.add_child(row.progress_bar) + + _building_rows.append(row) + _set_building_row(_building_rows.size() - 1, {}) + +func _set_building_row(index : int, building : Dictionary) -> void: + if index < 0 or index > _building_rows.size(): + push_error("Invalid building row index: ", index, " (max ", _building_rows.size(), ")") + return + if index == _building_rows.size(): _add_building_row() + var row := _building_rows[index] + if building.is_empty(): + row.level.visible = false + row.name.visible = false + row.progress_bar.visible = false + row.button.visible = false + return + row.level.text = str(building.get(GameSingleton.get_building_info_level_key(), 0)) + row.level.visible = true + row.name.text = building.get(GameSingleton.get_building_info_building_key(), + GameSingleton.get_building_info_building_key() + _missing_suffix) + row.name.visible = true + + var expansion_state : int = building.get(GameSingleton.get_building_info_expansion_state_key(), + CANNOT_EXPAND) + var show_progress_bar := expansion_state == PREPARING or expansion_state == EXPANDING + row.progress_bar.value = building.get(GameSingleton.get_building_info_expansion_progress_key(), 0) + row.progress_bar.visible = show_progress_bar + row.button.disabled = expansion_state != CAN_EXPAND + row.button.visible = not show_progress_bar + +func update_info() -> void: + _province_info = GameSingleton.get_province_info_from_index(_selected_index) + if _province_info: + _province_name_label.text = _province_info.get(GameSingleton.get_province_info_province_key(), + GameSingleton.get_province_info_province_key() + _missing_suffix) + _region_name_label.text = _province_info.get(GameSingleton.get_province_info_region_key(), + GameSingleton.get_province_info_region_key() + _missing_suffix) + + _life_rating_bar.value = _province_info.get(GameSingleton.get_province_info_life_rating_key(), 0) + _life_rating_bar.tooltip_text = tr("LIFE_RATING_TOOLTIP").format({ "life_rating": _life_rating_bar.value }) + + _rgo_name_label.text = _province_info.get(GameSingleton.get_province_info_rgo_key(), + GameSingleton.get_province_info_rgo_key() + _missing_suffix) + _rgo_icon_texture_rect.texture = GameSingleton.get_good_icon_texture(_rgo_name_label.text) + + var buildings : Array = _province_info.get(GameSingleton.get_province_info_buildings_key(), []) + for i in max(buildings.size(), _building_rows.size()): + _set_building_row(i, buildings[i] if i < buildings.size() else {}) + + show() + else: + hide() + +func _on_province_selected(index : int) -> void: + _selected_index = index + +func _on_close_button_pressed() -> void: + GameSingleton.set_selected_province(0) diff --git a/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn b/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn new file mode 100644 index 0000000..a233db0 --- /dev/null +++ b/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn @@ -0,0 +1,86 @@ +[gd_scene load_steps=2 format=3 uid="uid://byq323jbel48u"] + +[ext_resource type="Script" path="res://src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd" id="1_3n8k5"] + +[node name="ProvinceOverviewPanel" type="PanelContainer" node_paths=PackedStringArray("_province_name_label", "_region_name_label", "_life_rating_bar", "_rgo_icon_texture_rect", "_rgo_name_label", "_buildings_container")] +editor_description = "UI-56" +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_top = -300.0 +offset_right = 200.0 +grow_vertical = 0 +mouse_filter = 1 +script = ExtResource("1_3n8k5") +_province_name_label = NodePath("PanelList/TopBarList/NameList/ProvinceName") +_region_name_label = NodePath("PanelList/TopBarList/NameList/RegionName") +_life_rating_bar = NodePath("PanelList/TopBarList/NameList/LifeRatingBar") +_rgo_icon_texture_rect = NodePath("PanelList/InteractList/RGOInfo/RGOIcon") +_rgo_name_label = NodePath("PanelList/InteractList/RGOInfo/RGOName") +_buildings_container = NodePath("PanelList/InteractList/BuildingsContainer") + +[node name="PanelList" type="VBoxContainer" parent="."] +layout_mode = 2 + +[node name="TopBarList" type="HBoxContainer" parent="PanelList"] +layout_mode = 2 + +[node name="NameList" type="VBoxContainer" parent="PanelList/TopBarList"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 0 + +[node name="ProvinceName" type="Label" parent="PanelList/TopBarList/NameList"] +editor_description = "UI-57" +layout_mode = 2 +text = "province_MISSING" +vertical_alignment = 1 + +[node name="RegionName" type="Label" parent="PanelList/TopBarList/NameList"] +editor_description = "UI-58" +layout_mode = 2 +text = "region_MISSING" +vertical_alignment = 1 + +[node name="LifeRatingBar" type="ProgressBar" parent="PanelList/TopBarList/NameList"] +editor_description = "UI-62" +layout_mode = 2 +mouse_filter = 1 + +[node name="CloseButton" type="Button" parent="PanelList/TopBarList"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_vertical = 0 +mouse_filter = 1 +text = "X" + +[node name="InteractList" type="VBoxContainer" parent="PanelList"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="HSeparator" type="HSeparator" parent="PanelList/InteractList"] +layout_mode = 2 +mouse_filter = 1 + +[node name="RGOInfo" type="HBoxContainer" parent="PanelList/InteractList"] +editor_description = "UI-112" +layout_mode = 2 + +[node name="RGOIcon" type="TextureRect" parent="PanelList/InteractList/RGOInfo"] +editor_description = "UI-100" +layout_mode = 2 + +[node name="RGOName" type="Label" parent="PanelList/InteractList/RGOInfo"] +layout_mode = 2 +text = "rgo_MISSING" +vertical_alignment = 1 + +[node name="HSeparator2" type="HSeparator" parent="PanelList/InteractList"] +layout_mode = 2 +mouse_filter = 1 + +[node name="BuildingsContainer" type="GridContainer" parent="PanelList/InteractList"] +layout_mode = 2 +columns = 3 + +[connection signal="pressed" from="PanelList/TopBarList/CloseButton" to="." method="_on_close_button_pressed"] diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader index 7d160f0..88e7019 100644 --- a/game/src/GameSession/TerrainMap.gdshader +++ b/game/src/GameSession/TerrainMap.gdshader @@ -2,7 +2,7 @@ shader_type spatial; render_mode unshaded; -#include "ProvinceIndexSampler.gdshaderinc" +#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc" // Province colour texture uniform sampler2D province_colour_tex: source_color, repeat_enable, filter_nearest; diff --git a/game/src/MainMenu/ReleaseInfoBox.gd b/game/src/MainMenu/ReleaseInfoBox.gd index ca03af3..e363162 100644 --- a/game/src/MainMenu/ReleaseInfoBox.gd +++ b/game/src/MainMenu/ReleaseInfoBox.gd @@ -28,7 +28,7 @@ func _notification(what : int): _update_checksum_label_text() func _update_checksum_label_text() -> void: - _checksum_label.tooltip_text = tr("MAINMENU_CHECKSUM") % _checksum + _checksum_label.tooltip_text = tr("MAINMENU_CHECKSUM").format({ "checksum": _checksum }) _checksum_label.text = "(%s)" % _checksum.substr(0, 4) func _on_version_label_pressed(): -- cgit v1.2.3-56-ga3b1