aboutsummaryrefslogtreecommitdiff
path: root/game/src/GameSession
diff options
context:
space:
mode:
Diffstat (limited to 'game/src/GameSession')
-rw-r--r--game/src/GameSession/GameSession.tscn4
-rw-r--r--game/src/GameSession/MapControlPanel/MapControlPanel.gd (renamed from game/src/GameSession/MapControlPanel.gd)0
-rw-r--r--game/src/GameSession/MapControlPanel/MapControlPanel.tscn (renamed from game/src/GameSession/MapControlPanel.tscn)6
-rw-r--r--game/src/GameSession/MapControlPanel/Minimap.gd (renamed from game/src/GameSession/Minimap.gd)0
-rw-r--r--game/src/GameSession/MapControlPanel/Minimap.gdshader (renamed from game/src/GameSession/Minimap.gdshader)2
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel.gd96
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd121
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn (renamed from game/src/GameSession/ProvinceOverviewPanel.tscn)2
-rw-r--r--game/src/GameSession/TerrainMap.gdshader2
9 files changed, 129 insertions, 104 deletions
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/MapControlPanel.gd
index 0cef057..0cef057 100644
--- a/game/src/GameSession/MapControlPanel.gd
+++ b/game/src/GameSession/MapControlPanel/MapControlPanel.gd
diff --git a/game/src/GameSession/MapControlPanel.tscn b/game/src/GameSession/MapControlPanel/MapControlPanel.tscn
index 0da2d5a..91e2e7e 100644
--- a/game/src/GameSession/MapControlPanel.tscn
+++ b/game/src/GameSession/MapControlPanel/MapControlPanel.tscn
@@ -1,8 +1,8 @@
[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"]
+[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")
diff --git a/game/src/GameSession/Minimap.gd b/game/src/GameSession/MapControlPanel/Minimap.gd
index 1f9b75e..1f9b75e 100644
--- a/game/src/GameSession/Minimap.gd
+++ b/game/src/GameSession/MapControlPanel/Minimap.gd
diff --git a/game/src/GameSession/Minimap.gdshader b/game/src/GameSession/MapControlPanel/Minimap.gdshader
index 8b68108..608abe2 100644
--- a/game/src/GameSession/Minimap.gdshader
+++ b/game/src/GameSession/MapControlPanel/Minimap.gdshader
@@ -1,6 +1,6 @@
shader_type canvas_item;
-#include "ProvinceIndexSampler.gdshaderinc"
+#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc"
// Index of the currently selected province
uniform uint selected_index;
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/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.tscn b/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn
index 722299b..a233db0 100644
--- a/game/src/GameSession/ProvinceOverviewPanel.tscn
+++ b/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://byq323jbel48u"]
-[ext_resource type="Script" path="res://src/GameSession/ProvinceOverviewPanel.gd" id="1_3n8k5"]
+[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"
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;