diff options
Diffstat (limited to 'game/src')
-rw-r--r-- | game/src/Autoload/Events.gd | 31 | ||||
-rw-r--r-- | game/src/GameSession/GameSession.tscn | 3 | ||||
-rw-r--r-- | game/src/GameSession/MapControlPanel.gd | 9 | ||||
-rw-r--r-- | game/src/GameSession/MapControlPanel.tscn | 1 | ||||
-rw-r--r-- | game/src/GameSession/MapView.gd | 11 | ||||
-rw-r--r-- | game/src/GameSession/Minimap.gd | 1 | ||||
-rw-r--r-- | game/src/GameSession/ProvinceOverviewPanel.gd | 43 | ||||
-rw-r--r-- | game/src/GameSession/ProvinceOverviewPanel.tscn | 21 |
8 files changed, 62 insertions, 58 deletions
diff --git a/game/src/Autoload/Events.gd b/game/src/Autoload/Events.gd index 47c3b88..db63330 100644 --- a/game/src/Autoload/Events.gd +++ b/game/src/Autoload/Events.gd @@ -5,23 +5,22 @@ var Options = preload("Events/Options.gd").new() var Localisation = preload("Events/Localisation.gd").new() var ShaderManager = preload("Events/ShaderManager.gd").new() -const _province_identifier_file : String = "res://common/map/provinces.json" -const _water_province_file : String = "res://common/map/water.json" -const _region_file : String = "res://common/map/regions.json" -const _terrain_file : String = "res://common/map/terrain.json" -const _province_image_file : String = "res://common/map/provinces.png" -const _terrain_image_file : String = "res://common/map/terrain.png" +var _define_filepaths_dict : Dictionary = { + GameSingleton.get_province_identifier_file_key(): "res://common/map/provinces.json", + GameSingleton.get_water_province_file_key(): "res://common/map/water.json", + GameSingleton.get_region_file_key(): "res://common/map/regions.json", + GameSingleton.get_terrain_variant_file_key(): "res://common/map/terrain.json", + GameSingleton.get_province_image_file_key(): "res://common/map/provinces.png", + GameSingleton.get_terrain_image_file_key(): "res://common/map/terrain.png", + GameSingleton.get_goods_file_key(): "res://common/goods.json", + GameSingleton.get_good_icons_dir_key(): "res://art/economy/goods" +} # REQUIREMENTS # * FS-333, FS-334, FS-335, FS-341 func _ready(): - if GameSingleton.load_province_identifier_file(_province_identifier_file) != OK: - push_error("Failed to load province identifiers") - if GameSingleton.load_water_province_file(_water_province_file) != OK: - push_error("Failed to load water provinces") - if GameSingleton.load_region_file(_region_file) != OK: - push_error("Failed to load regions") - if GameSingleton.load_terrain_file(_terrain_file) != OK: - push_error("Failed to load terrain variants") - if GameSingleton.load_map_images(_province_image_file, _terrain_image_file) != OK: - push_error("Failed to load map images") + var start := Time.get_ticks_usec() + if GameSingleton.load_defines(_define_filepaths_dict) != OK: + push_error("Failed to load game defines!") + var end := Time.get_ticks_usec() + print("Loading took ", float(end - start) / 1000000, " seconds") diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn index cad6a96..411a829 100644 --- a/game/src/GameSession/GameSession.tscn +++ b/game/src/GameSession/GameSession.tscn @@ -66,8 +66,6 @@ offset_right = 0.0 grow_horizontal = 0 [connection signal="map_view_camera_changed" from="MapView" to="MapControlPanel" method="_on_map_view_camera_changed"] -[connection signal="province_selected" from="MapView" to="MapControlPanel" method="_on_province_selected"] -[connection signal="province_selected" from="MapView" to="ProvinceOverviewPanel" method="_on_province_selected"] [connection signal="options_button_pressed" from="GameSessionMenu" to="OptionsMenu" method="show"] [connection signal="game_session_menu_button_pressed" from="MapControlPanel" to="." method="_on_game_session_menu_button_pressed"] [connection signal="minimap_clicked" from="MapControlPanel" to="MapView" method="_on_minimap_clicked"] @@ -77,6 +75,5 @@ grow_horizontal = 0 [connection signal="zoom_out_button_pressed" from="MapControlPanel" to="MapView" method="zoom_out"] [connection signal="mouse_entered" from="ProvinceOverviewPanel" to="MapView" method="_on_mouse_exited_viewport"] [connection signal="mouse_exited" from="ProvinceOverviewPanel" to="MapView" method="_on_mouse_entered_viewport"] -[connection signal="province_deselected" from="ProvinceOverviewPanel" to="MapView" method="_deselect_province"] [connection signal="back_button_pressed" from="OptionsMenu" to="MapView" method="enable_processing"] [connection signal="back_button_pressed" from="OptionsMenu" to="OptionsMenu" method="hide"] diff --git a/game/src/GameSession/MapControlPanel.gd b/game/src/GameSession/MapControlPanel.gd index e9249b3..0cef057 100644 --- a/game/src/GameSession/MapControlPanel.gd +++ b/game/src/GameSession/MapControlPanel.gd @@ -3,7 +3,6 @@ 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 province_selcted(index : int) signal zoom_in_button_pressed signal zoom_out_button_pressed @@ -12,7 +11,7 @@ signal zoom_out_button_pressed var _mapmode_button_group : ButtonGroup # REQUIREMENTS: -# * UI-550, UI-554 +# * UI-550, UI-552, UI-554, UI-561 func _add_mapmode_button(identifier : String) -> void: var button := Button.new() button.text = identifier @@ -37,10 +36,9 @@ func _on_game_session_menu_button_pressed() -> void: # REQUIREMENTS: # * SS-76 -# * UIFUN-129, UIFUN-133 +# * UIFUN-129, UIFUN-131, UIFUN-133 func _mapmode_pressed(button : BaseButton) -> void: GameSingleton.set_mapmode(button.tooltip_text) - GameSingleton.update_colour_image() 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) @@ -48,9 +46,6 @@ func _on_map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_ri func _on_minimap_clicked(pos_clicked : Vector2) -> void: minimap_clicked.emit(pos_clicked) -func _on_province_selected(index : int) -> void: - province_selcted.emit(index) - # REQUIREMENTS: # * UIFUN-269 func _on_zoom_in_button_pressed() -> void: diff --git a/game/src/GameSession/MapControlPanel.tscn b/game/src/GameSession/MapControlPanel.tscn index 82b9c86..0da2d5a 100644 --- a/game/src/GameSession/MapControlPanel.tscn +++ b/game/src/GameSession/MapControlPanel.tscn @@ -101,7 +101,6 @@ 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="province_selcted" from="." to="MapPanelMargin/MapPanelList/MapDisplayList/Minimap/ViewportQuad" method="_on_province_selected"] [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"] diff --git a/game/src/GameSession/MapView.gd b/game/src/GameSession/MapView.gd index c3b5cbb..22a7e6b 100644 --- a/game/src/GameSession/MapView.gd +++ b/game/src/GameSession/MapView.gd @@ -1,6 +1,5 @@ extends Node3D -signal province_selected(index : int) signal map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) const _action_north : StringName = &"map_north" @@ -83,6 +82,8 @@ func _ready(): map_mesh_aabb.position.z - map_mesh_aabb.end.z )) + GameSingleton.province_selected.connect(_on_province_selected) + func _notification(what : int): match what: NOTIFICATION_WM_MOUSE_ENTER: # Mouse inside window @@ -112,12 +113,8 @@ func zoom_in() -> void: func zoom_out() -> void: _zoom_target += _zoom_target_step -func _select_province(index : int) -> void: +func _on_province_selected(index : int) -> void: _map_shader_material.set_shader_parameter(Events.ShaderManager.param_selected_index, index) - province_selected.emit(index) - -func _deselect_province() -> void: - _select_province(0) # REQUIREMENTS # * SS-31 @@ -125,7 +122,7 @@ func _unhandled_input(event : InputEvent): if _mouse_over_viewport and event.is_action_pressed(_action_click): # Check if the mouse is outside of bounds if _map_mesh.is_valid_uv_coord(_mouse_pos_map): - _select_province(GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map)) + GameSingleton.set_selected_province(GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map)) else: print("Clicked outside the map!") elif event.is_action_pressed(_action_drag): diff --git a/game/src/GameSession/Minimap.gd b/game/src/GameSession/Minimap.gd index f5d972a..1f9b75e 100644 --- a/game/src/GameSession/Minimap.gd +++ b/game/src/GameSession/Minimap.gd @@ -16,6 +16,7 @@ func _ready(): 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: diff --git a/game/src/GameSession/ProvinceOverviewPanel.gd b/game/src/GameSession/ProvinceOverviewPanel.gd index 80f02c5..4172860 100644 --- a/game/src/GameSession/ProvinceOverviewPanel.gd +++ b/game/src/GameSession/ProvinceOverviewPanel.gd @@ -1,10 +1,10 @@ extends PanelContainer -signal province_deselected - @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" @@ -17,6 +17,7 @@ var _selected_index : int: var _province_info : Dictionary func _ready(): + GameSingleton.province_selected.connect(_on_province_selected) GameSingleton.state_updated.connect(update_info) update_info() @@ -31,28 +32,23 @@ func _expand_building(building_identifier : String) -> void: # * 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 _building_key : StringName = &"building" - const _level_key : StringName = &"level" - const _expansion_state_key : StringName = &"expansion_state" - const _start_key : StringName = &"start" - const _end_key : StringName = &"end" - const _expansion_progress_key : StringName = &"expansion_progress" - const _expand_province_building : String = "EXPAND_PROVINCE_BUILDING" var level_label := Label.new() - level_label.text = str(building.get(_level_key, 0)) + 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(_building_key, _building_key + _missing_suffix) + 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(_expansion_state_key, CANNOT_EXPAND) + 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(_expansion_progress_key, 0) + 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) @@ -66,25 +62,26 @@ func _add_building(building : Dictionary) -> void: _buildings_container.add_child(expand_button) func update_info() -> void: - const _province_key : StringName = &"province" - const _region_key : StringName = &"region" - const _life_rating_key : StringName = &"life_rating" - const _buildings_key : StringName = &"buildings" - 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(_province_key, _province_key + _missing_suffix) - _region_name_label.text = _province_info.get(_region_key, _region_key + _missing_suffix) + _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(_life_rating_key, 0) + _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(_buildings_key, []) + var buildings : Array = _province_info.get(GameSingleton.get_province_info_buildings_key(), []) for building in buildings: _add_building(building) @@ -96,4 +93,4 @@ func _on_province_selected(index : int) -> void: _selected_index = index func _on_close_button_pressed() -> void: - province_deselected.emit() + GameSingleton.set_selected_province(0) diff --git a/game/src/GameSession/ProvinceOverviewPanel.tscn b/game/src/GameSession/ProvinceOverviewPanel.tscn index 8c83baa..722299b 100644 --- a/game/src/GameSession/ProvinceOverviewPanel.tscn +++ b/game/src/GameSession/ProvinceOverviewPanel.tscn @@ -2,7 +2,7 @@ [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", "_buildings_container")] +[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 @@ -15,6 +15,8 @@ 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="."] @@ -60,6 +62,23 @@ size_flags_vertical = 3 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 |