aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/localisation/en_GB/menus.csv1
-rw-r--r--game/src/Autoload/Events.gd1
-rw-r--r--game/src/GameSession/GameSession.gd2
-rw-r--r--game/src/GameSession/GameSessionMenu.gd1
-rw-r--r--game/src/GameSession/GameSpeedPanel.gd1
-rw-r--r--game/src/GameSession/MapView.gd12
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel.gd10
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel.tscn7
-rw-r--r--game/src/GameSession/TerrainMap.gdshader23
9 files changed, 36 insertions, 22 deletions
diff --git a/game/localisation/en_GB/menus.csv b/game/localisation/en_GB/menus.csv
index 0009acd..3c3fff1 100644
--- a/game/localisation/en_GB/menus.csv
+++ b/game/localisation/en_GB/menus.csv
@@ -69,6 +69,7 @@ DIALOG_SAVE_AND_QUIT,Save and Quit
,, Province Overview Panel
province_MISSING,No Province
region_MISSING,No Region
+LIFE_RATING_TOOLTIP,Liferating: %d
building_MISSING,No Building
building_fort,Fort
building_naval_base,Naval Base
diff --git a/game/src/Autoload/Events.gd b/game/src/Autoload/Events.gd
index 0ee2eff..7540d3e 100644
--- a/game/src/Autoload/Events.gd
+++ b/game/src/Autoload/Events.gd
@@ -19,4 +19,3 @@ func _ready():
push_error("Failed to load regions")
if GameSingleton.load_province_shape_file(_province_shape_file) != OK:
push_error("Failed to load province shapes")
- GameSingleton.finished_loading_data()
diff --git a/game/src/GameSession/GameSession.gd b/game/src/GameSession/GameSession.gd
index 2761815..556b98e 100644
--- a/game/src/GameSession/GameSession.gd
+++ b/game/src/GameSession/GameSession.gd
@@ -4,6 +4,8 @@ extends Control
func _ready():
Events.Options.load_settings_from_file()
+ if GameSingleton.setup() != OK:
+ push_error("Failed to setup game")
func _process(delta : float):
GameSingleton.try_tick()
diff --git a/game/src/GameSession/GameSessionMenu.gd b/game/src/GameSession/GameSessionMenu.gd
index 70a1630..6f373d7 100644
--- a/game/src/GameSession/GameSessionMenu.gd
+++ b/game/src/GameSession/GameSessionMenu.gd
@@ -45,7 +45,6 @@ func show_save_dialog_button() -> void:
# * SS-47
# * UIFUN-69
func _on_main_menu_confirmed() -> void:
- # TODO - reset map when going back to main menu
get_tree().change_scene_to_packed(_main_menu_scene)
# REQUIREMENTS:
diff --git a/game/src/GameSession/GameSpeedPanel.gd b/game/src/GameSession/GameSpeedPanel.gd
index 8b7af29..80708b1 100644
--- a/game/src/GameSession/GameSpeedPanel.gd
+++ b/game/src/GameSession/GameSpeedPanel.gd
@@ -7,7 +7,6 @@ extends PanelContainer
@export var _decrease_speed_button : Button
@export var _increase_speed_button : Button
-# Called when the node enters the scene tree for the first time.
func _ready():
GameSingleton.state_updated.connect(_update_buttons)
_update_buttons()
diff --git a/game/src/GameSession/MapView.gd b/game/src/GameSession/MapView.gd
index 510d70a..e74ea59 100644
--- a/game/src/GameSession/MapView.gd
+++ b/game/src/GameSession/MapView.gd
@@ -41,7 +41,6 @@ var _mouse_over_viewport : bool = true
var _map_mesh : MapMesh
var _map_shader_material : ShaderMaterial
var _map_image_size : Vector2
-var _map_province_index_image : Image
var _map_province_colour_image : Image
var _map_province_colour_texture : ImageTexture
var _map_mesh_corner : Vector2
@@ -77,12 +76,15 @@ func _ready():
return
_map_shader_material = map_material
- # Province index texture
- _map_province_index_image = GameSingleton.get_province_index_image()
- if _map_province_index_image == null:
+ # Province index textures
+ var map_province_index_images := GameSingleton.get_province_index_images()
+ if map_province_index_images == null or map_province_index_images.is_empty():
push_error("Failed to get province index image!")
return
- var province_index_texture := ImageTexture.create_from_image(_map_province_index_image)
+ var province_index_texture := Texture2DArray.new()
+ if province_index_texture.create_from_images(map_province_index_images) != OK:
+ push_error("Failed to generate province index texture array!")
+ return
_map_shader_material.set_shader_parameter(_shader_param_province_index, province_index_texture)
# Province colour texture
diff --git a/game/src/GameSession/ProvinceOverviewPanel.gd b/game/src/GameSession/ProvinceOverviewPanel.gd
index cbab9d0..17da9d0 100644
--- a/game/src/GameSession/ProvinceOverviewPanel.gd
+++ b/game/src/GameSession/ProvinceOverviewPanel.gd
@@ -2,6 +2,7 @@ extends PanelContainer
@export var _province_name_label : Label
@export var _region_name_label : Label
+@export var _life_rating_bar : ProgressBar
@export var _buildings_container : Container
const _missing_suffix : String = "_MISSING"
@@ -23,6 +24,10 @@ 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 _building_key : StringName = &"building"
const _level_key : StringName = &"level"
@@ -62,11 +67,16 @@ func update_info() -> void:
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)
+ _life_rating_bar.value = _province_info.get(_life_rating_key, 0)
+ _life_rating_bar.tooltip_text = tr(_life_rating_tooltip) % _life_rating_bar.value
+
for child in _buildings_container.get_children():
_buildings_container.remove_child(child)
child.queue_free()
diff --git a/game/src/GameSession/ProvinceOverviewPanel.tscn b/game/src/GameSession/ProvinceOverviewPanel.tscn
index 7b28cc1..48e7c25 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", "_buildings_container")]
+[node name="ProvinceOverviewPanel" type="PanelContainer" node_paths=PackedStringArray("_province_name_label", "_region_name_label", "_life_rating_bar", "_buildings_container")]
editor_description = "UI-56"
anchors_preset = 2
anchor_top = 1.0
@@ -13,6 +13,7 @@ grow_vertical = 0
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")
_buildings_container = NodePath("PanelList/InteractList/BuildingsContainer")
[node name="PanelList" type="VBoxContainer" parent="."]
@@ -38,6 +39,10 @@ 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
+
[node name="CloseButton" type="Button" parent="PanelList/TopBarList"]
custom_minimum_size = Vector2(30, 30)
layout_mode = 2
diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader
index 9ce1a24..305a34b 100644
--- a/game/src/GameSession/TerrainMap.gdshader
+++ b/game/src/GameSession/TerrainMap.gdshader
@@ -5,7 +5,7 @@ render_mode unshaded;
// Cosmetic farmlands terrain texture
uniform sampler2D farmlands_tex: source_color, repeat_enable, filter_linear;
// Province index texture
-uniform sampler2D province_index_tex : source_color, repeat_enable, filter_nearest;
+uniform sampler2DArray province_index_tex : source_color, repeat_enable, filter_nearest;
// Province colour texture
uniform sampler2D province_colour_tex: source_color, repeat_enable, filter_nearest;
// Index of the mouse over the map mesh
@@ -18,23 +18,20 @@ uniform float terrain_tile_factor;
uvec2 vec2_to_uvec2(vec2 v) {
return uvec2(v * 255.0);
}
-
+uvec2 read_uvec2(vec2 uv) {
+ float width_divisions = float(textureSize(province_index_tex, 0).z);
+ uv.x *= width_divisions;
+ float idx = mod(floor(uv.x), width_divisions);
+ return vec2_to_uvec2(texture(province_index_tex, vec3(uv, idx)).rg);
+}
uint uvec2_to_uint(uvec2 v) {
return (v.y << 8u) | v.x;
}
-uvec2 read_uvec2(sampler2D tex, vec2 uv) {
- return vec2_to_uvec2(texture(tex, uv).rg);
-}
-
-uint read_uint16(sampler2D tex, vec2 uv) {
- return uvec2_to_uint(read_uvec2(tex, uv));
-}
-
const vec3 water_colour = vec3(0, 0, 1);
vec3 get_terrain_colour(vec2 uv, vec2 corner, vec2 half_pixel_size, vec2 terrain_uv) {
- uvec2 index_split = read_uvec2(province_index_tex, fma(corner, half_pixel_size, uv));
+ uvec2 index_split = read_uvec2(fma(corner, half_pixel_size, uv));
uint index = uvec2_to_uint(index_split);
vec4 province_data = texelFetch(province_colour_tex, ivec2(index_split), 0);
vec3 province_colour = province_data.rgb;
@@ -47,8 +44,8 @@ vec3 get_terrain_colour(vec2 uv, vec2 corner, vec2 half_pixel_size, vec2 terrain
}
vec3 mix_terrain_colour(vec2 uv) {
- vec2 map_size = vec2(textureSize(province_index_tex, 0));
- vec2 pixel_offset = mod(fma(uv, map_size, vec2(0.5)), 1.0);
+ vec2 map_size = vec2(textureSize(province_index_tex, 0).xy);
+ vec2 pixel_offset = fract(fma(uv, map_size, vec2(0.5)));
vec2 half_pixel_size = 0.49 / map_size;
vec2 terrain_uv = uv;