aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/art/terrain/desert_rocky.pngbin0 -> 417538 bytes
-rw-r--r--game/art/terrain/desert_rocky.png.import34
-rw-r--r--game/art/terrain/desert_smooth.pngbin0 -> 202420 bytes
-rw-r--r--game/art/terrain/desert_smooth.png.import34
-rw-r--r--game/art/terrain/mountains.pngbin0 -> 374999 bytes
-rw-r--r--game/art/terrain/mountains.png.import (renamed from game/art/ui/minimap_frame.png.import)8
-rw-r--r--game/art/terrain/ocean.pngbin0 -> 92335 bytes
-rw-r--r--game/art/terrain/ocean.png.import (renamed from game/art/ui/minimap.png.import)8
-rw-r--r--game/art/ui/minimap.pngbin122017 -> 0 bytes
-rw-r--r--game/art/ui/minimap_frame.pngbin1043 -> 0 bytes
-rw-r--r--game/common/data/goods-jca.json2
-rw-r--r--game/common/data/goods.json2
-rw-r--r--game/common/map/terrain.json7
-rw-r--r--game/common/map/terrain.pngbin0 -> 650002 bytes
-rw-r--r--game/common/map/terrain.png.import3
-rw-r--r--game/project.godot3
-rw-r--r--game/src/Autoload/Events.gd12
-rw-r--r--game/src/Autoload/Events/GameDebug.gd (renamed from game/src/Autoload/GameDebug.gd)5
-rw-r--r--game/src/Autoload/Events/ShaderManager.gd48
-rw-r--r--game/src/Autoload/Resolution.gd2
-rw-r--r--game/src/GameSession/GameSession.tscn3
-rw-r--r--game/src/GameSession/MapControlPanel.gd7
-rw-r--r--game/src/GameSession/MapControlPanel.tscn32
-rw-r--r--game/src/GameSession/MapView.gd59
-rw-r--r--game/src/GameSession/MapView.tscn5
-rw-r--r--game/src/GameSession/Minimap.gd15
-rw-r--r--game/src/GameSession/Minimap.gdshader18
-rw-r--r--game/src/GameSession/ProvinceIndexSampler.gdshaderinc18
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel.gd4
-rw-r--r--game/src/GameSession/TerrainMap.gdshader41
30 files changed, 254 insertions, 116 deletions
diff --git a/game/art/terrain/desert_rocky.png b/game/art/terrain/desert_rocky.png
new file mode 100644
index 0000000..f7f9155
--- /dev/null
+++ b/game/art/terrain/desert_rocky.png
Binary files differ
diff --git a/game/art/terrain/desert_rocky.png.import b/game/art/terrain/desert_rocky.png.import
new file mode 100644
index 0000000..b8104eb
--- /dev/null
+++ b/game/art/terrain/desert_rocky.png.import
@@ -0,0 +1,34 @@
+[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
diff --git a/game/art/terrain/desert_smooth.png b/game/art/terrain/desert_smooth.png
new file mode 100644
index 0000000..4e977cd
--- /dev/null
+++ b/game/art/terrain/desert_smooth.png
Binary files differ
diff --git a/game/art/terrain/desert_smooth.png.import b/game/art/terrain/desert_smooth.png.import
new file mode 100644
index 0000000..bc0513d
--- /dev/null
+++ b/game/art/terrain/desert_smooth.png.import
@@ -0,0 +1,34 @@
+[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
diff --git a/game/art/terrain/mountains.png b/game/art/terrain/mountains.png
new file mode 100644
index 0000000..301ee23
--- /dev/null
+++ b/game/art/terrain/mountains.png
Binary files differ
diff --git a/game/art/ui/minimap_frame.png.import b/game/art/terrain/mountains.png.import
index 3d2aeee..47a00fd 100644
--- a/game/art/ui/minimap_frame.png.import
+++ b/game/art/terrain/mountains.png.import
@@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
-uid="uid://vr1hq2stk8ny"
-path="res://.godot/imported/minimap_frame.png-3668393435d2582fb1dc8a9598573e80.ctex"
+uid="uid://c20q2sqf38eq8"
+path="res://.godot/imported/mountains.png-f1ab7d9b0a0deb485923c40b1cfb258e.ctex"
metadata={
"vram_texture": false
}
[deps]
-source_file="res://art/ui/minimap_frame.png"
-dest_files=["res://.godot/imported/minimap_frame.png-3668393435d2582fb1dc8a9598573e80.ctex"]
+source_file="res://art/terrain/mountains.png"
+dest_files=["res://.godot/imported/mountains.png-f1ab7d9b0a0deb485923c40b1cfb258e.ctex"]
[params]
diff --git a/game/art/terrain/ocean.png b/game/art/terrain/ocean.png
new file mode 100644
index 0000000..3e52011
--- /dev/null
+++ b/game/art/terrain/ocean.png
Binary files differ
diff --git a/game/art/ui/minimap.png.import b/game/art/terrain/ocean.png.import
index 36f22e7..644f7e7 100644
--- a/game/art/ui/minimap.png.import
+++ b/game/art/terrain/ocean.png.import
@@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
-uid="uid://c0sm1jfu4kyv3"
-path="res://.godot/imported/minimap.png-05ee44469856e77fd05107fe9e259e25.ctex"
+uid="uid://dlvvim3j7dbnn"
+path="res://.godot/imported/ocean.png-3d7e213c3fca805d033e0d3bf567fc01.ctex"
metadata={
"vram_texture": false
}
[deps]
-source_file="res://art/ui/minimap.png"
-dest_files=["res://.godot/imported/minimap.png-05ee44469856e77fd05107fe9e259e25.ctex"]
+source_file="res://art/terrain/ocean.png"
+dest_files=["res://.godot/imported/ocean.png-3d7e213c3fca805d033e0d3bf567fc01.ctex"]
[params]
diff --git a/game/art/ui/minimap.png b/game/art/ui/minimap.png
deleted file mode 100644
index 9922b28..0000000
--- a/game/art/ui/minimap.png
+++ /dev/null
Binary files differ
diff --git a/game/art/ui/minimap_frame.png b/game/art/ui/minimap_frame.png
deleted file mode 100644
index 21aa2ce..0000000
--- a/game/art/ui/minimap_frame.png
+++ /dev/null
Binary files differ
diff --git a/game/common/data/goods-jca.json b/game/common/data/goods-jca.json
index 3a0390a..5017d7e 100644
--- a/game/common/data/goods-jca.json
+++ b/game/common/data/goods-jca.json
@@ -15,7 +15,7 @@
{"id": "precious_goods", "category": "Raw", "cost": 7.00, "colour": "247 241 61", "isAvailableAtStart": true, "isTradeable": false, "isMoney": true, "hasOverseasPenalty": false},
{"id": "rubber", "category": "Raw", "cost": 7.00, "colour": "123 110 86", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
{"id": "silk", "category": "Raw", "cost": 10.00, "colour": "125 158 43", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
- {"id": "sulpher", "category": "Raw", "cost": 6.00, "colour": "181 228 102", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
+ {"id": "sulphur", "category": "Raw", "cost": 6.00, "colour": "181 228 102", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
{"id": "timber", "category": "Raw", "cost": 0.90, "colour": "146 72 17", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
{"id": "tropical_wood", "category": "Raw", "cost": 5.40, "colour": "213 177 118", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
{"id": "wool", "category": "Raw", "cost": 0.70, "colour": "234 195 158", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
diff --git a/game/common/data/goods.json b/game/common/data/goods.json
index 4954fb0..9d8e0e3 100644
--- a/game/common/data/goods.json
+++ b/game/common/data/goods.json
@@ -14,7 +14,7 @@
{"id": "precious_metal", "category": "Raw", "cost": 8.00, "colour": "253 199 110", "isAvailableAtStart": true, "isTradeable": false, "isMoney": true, "hasOverseasPenalty": false},
{"id": "rubber", "category": "Raw", "cost": 7.00, "colour": "123 110 86", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
{"id": "silk", "category": "Raw", "cost": 10.00, "colour": "125 158 43", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
- {"id": "sulpher", "category": "Raw", "cost": 6.00, "colour": "181 228 102", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
+ {"id": "sulphur", "category": "Raw", "cost": 6.00, "colour": "181 228 102", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
{"id": "timber", "category": "Raw", "cost": 0.90, "colour": "146 72 17", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
{"id": "tropical_wood", "category": "Raw", "cost": 5.40, "colour": "213 177 118", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
{"id": "wool", "category": "Raw", "cost": 0.70, "colour": "234 195 158", "isAvailableAtStart": true, "isTradeable": true, "isMoney": false, "hasOverseasPenalty": false},
diff --git a/game/common/map/terrain.json b/game/common/map/terrain.json
new file mode 100644
index 0000000..60596c9
--- /dev/null
+++ b/game/common/map/terrain.json
@@ -0,0 +1,7 @@
+{
+ "ocean.png": "204080",
+ "farmlands.png": [88, 170, 37],
+ "mountains.png": "584B25",
+ "desert_rocky.png": "A06C38",
+ "desert_smooth.png": "BAA644"
+}
diff --git a/game/common/map/terrain.png b/game/common/map/terrain.png
new file mode 100644
index 0000000..6e7ca0a
--- /dev/null
+++ b/game/common/map/terrain.png
Binary files differ
diff --git a/game/common/map/terrain.png.import b/game/common/map/terrain.png.import
new file mode 100644
index 0000000..8dd0c09
--- /dev/null
+++ b/game/common/map/terrain.png.import
@@ -0,0 +1,3 @@
+[remap]
+
+importer="keep"
diff --git a/game/project.godot b/game/project.godot
index ff4081e..c10465d 100644
--- a/game/project.godot
+++ b/game/project.godot
@@ -22,10 +22,9 @@ config/project_settings_override.template="user://settings.cfg"
Events="*res://src/Autoload/Events.gd"
Resolution="*res://src/Autoload/Resolution.gd"
-MusicConductor="*res://src/MusicConductor/MusicConductor.tscn"
SoundManager="*res://src/Autoload/SoundManager.gd"
+MusicConductor="*res://src/MusicConductor/MusicConductor.tscn"
Keychain="*res://addons/keychain/Keychain.gd"
-GameDebug="*res://src/Autoload/GameDebug.gd"
[display]
diff --git a/game/src/Autoload/Events.gd b/game/src/Autoload/Events.gd
index 7540d3e..47c3b88 100644
--- a/game/src/Autoload/Events.gd
+++ b/game/src/Autoload/Events.gd
@@ -1,12 +1,16 @@
extends Node
+var GameDebug = preload("Events/GameDebug.gd").new()
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 _province_shape_file : String = "res://common/map/provinces.png"
+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"
# REQUIREMENTS
# * FS-333, FS-334, FS-335, FS-341
@@ -17,5 +21,7 @@ func _ready():
push_error("Failed to load water provinces")
if GameSingleton.load_region_file(_region_file) != OK:
push_error("Failed to load regions")
- if GameSingleton.load_province_shape_file(_province_shape_file) != OK:
- push_error("Failed to load province shapes")
+ 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")
diff --git a/game/src/Autoload/GameDebug.gd b/game/src/Autoload/Events/GameDebug.gd
index 6f10bf5..4e8931f 100644
--- a/game/src/Autoload/GameDebug.gd
+++ b/game/src/Autoload/Events/GameDebug.gd
@@ -1,8 +1,8 @@
-extends Node
+extends RefCounted
# REQUIREMENTS:
# * SS-56
-func _ready():
+func _init():
for engine_args in OS.get_cmdline_args():
match(engine_args):
"--game-debug":
@@ -15,6 +15,7 @@ func _ready():
func set_debug_mode(value : bool) -> void:
ProjectSettings.set_setting("openvic2/debug/enabled", value)
+ print("Set debug mode to: ", value)
func is_debug_mode() -> bool:
return ProjectSettings.get_setting("openvic2/debug/enabled", false)
diff --git a/game/src/Autoload/Events/ShaderManager.gd b/game/src/Autoload/Events/ShaderManager.gd
new file mode 100644
index 0000000..a503c52
--- /dev/null
+++ b/game/src/Autoload/Events/ShaderManager.gd
@@ -0,0 +1,48 @@
+extends RefCounted
+
+const param_province_shape_tex : StringName = &"province_shape_tex"
+const param_province_shape_subdivisions : StringName = &"province_shape_subdivisions"
+const param_province_colour_tex : StringName = &"province_colour_tex"
+const param_hover_index : StringName = &"hover_index"
+const param_selected_index : StringName = &"selected_index"
+const param_terrain_tex : StringName = &"terrain_tex"
+const param_terrain_tile_factor : StringName = &"terrain_tile_factor"
+
+func set_up_shader(material : Material, add_cosmetic_textures : bool) -> Error:
+ # Shader Material
+ if material == null:
+ push_error("material is null!")
+ return FAILED
+ if not material is ShaderMaterial:
+ push_error("Invalid map mesh material class: ", material.get_class())
+ return FAILED
+ var shader_material : ShaderMaterial = material
+
+ # Province shape texture
+ var province_shape_texture := GameSingleton.get_province_shape_texture()
+ if province_shape_texture == null:
+ push_error("Failed to get province shape texture!")
+ return FAILED
+ shader_material.set_shader_parameter(param_province_shape_tex, province_shape_texture)
+ var subdivisions := GameSingleton.get_province_shape_image_subdivisions()
+ if subdivisions.x < 1 or subdivisions.y < 1:
+ push_error("Invalid province shape image subdivision: ", subdivisions.x, "x", subdivisions.y)
+ return FAILED
+ shader_material.set_shader_parameter(param_province_shape_subdivisions, Vector2(subdivisions))
+
+ if add_cosmetic_textures:
+ # Province colour texture
+ var map_province_colour_texture := GameSingleton.get_province_colour_texture()
+ if map_province_colour_texture == null:
+ push_error("Failed to get province colour image!")
+ return FAILED
+ shader_material.set_shader_parameter(param_province_colour_tex, map_province_colour_texture)
+
+ # Terrain texture
+ var terrain_texture := GameSingleton.get_terrain_texture()
+ if terrain_texture == null:
+ push_error("Failed to get terrain texture!")
+ return FAILED
+ shader_material.set_shader_parameter(param_terrain_tex, terrain_texture)
+
+ return OK
diff --git a/game/src/Autoload/Resolution.gd b/game/src/Autoload/Resolution.gd
index e1e788b..35ecbb3 100644
--- a/game/src/Autoload/Resolution.gd
+++ b/game/src/Autoload/Resolution.gd
@@ -62,7 +62,7 @@ func get_resolution_display_name(resolution_value : Vector2i) -> StringName:
func get_resolution_value_from_string(resolution_string : String) -> Vector2i:
if not resolution_string.is_empty():
for resolution in _resolutions.values():
- if resolution_string == resolution.get(name) or resolution_string == resolution.display_name:
+ if resolution_string == resolution.name or resolution_string == resolution.display_name:
return resolution.value
var result := _regex.search(resolution_string)
if result: return Vector2i(result.get_string(1).to_int(), result.get_string(2).to_int())
diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn
index b993acf..70f0583 100644
--- a/game/src/GameSession/GameSession.tscn
+++ b/game/src/GameSession/GameSession.tscn
@@ -66,14 +66,15 @@ 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="mapmode_changed" from="MapControlPanel" to="MapView" method="_update_colour_texture"]
[connection signal="minimap_clicked" from="MapControlPanel" to="MapView" method="_on_minimap_clicked"]
[connection signal="mouse_entered" from="MapControlPanel" to="MapView" method="_on_mouse_exited_viewport"]
[connection signal="mouse_exited" from="MapControlPanel" to="MapView" method="_on_mouse_entered_viewport"]
[connection signal="zoom_in_button_pressed" from="MapControlPanel" to="MapView" method="zoom_in"]
[connection signal="zoom_out_button_pressed" from="MapControlPanel" to="MapView" method="zoom_out"]
+[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 73d7e06..e9249b3 100644
--- a/game/src/GameSession/MapControlPanel.gd
+++ b/game/src/GameSession/MapControlPanel.gd
@@ -1,9 +1,9 @@
extends PanelContainer
signal game_session_menu_button_pressed
-signal mapmode_changed
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
@@ -40,7 +40,7 @@ func _on_game_session_menu_button_pressed() -> void:
# * UIFUN-129, UIFUN-133
func _mapmode_pressed(button : BaseButton) -> void:
GameSingleton.set_mapmode(button.tooltip_text)
- mapmode_changed.emit()
+ 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,6 +48,9 @@ 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 18b1c3f..82b9c86 100644
--- a/game/src/GameSession/MapControlPanel.tscn
+++ b/game/src/GameSession/MapControlPanel.tscn
@@ -1,9 +1,13 @@
[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="Texture2D" uid="uid://c0sm1jfu4kyv3" path="res://art/ui/minimap.png" id="2_r613r"]
+[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="Texture2D" uid="uid://vr1hq2stk8ny" path="res://art/ui/minimap_frame.png" id="4_f1exl"]
+
+[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"
@@ -41,28 +45,21 @@ 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="TextureRect" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap"]
+[node name="MinimapTexture" type="ColorRect" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap"]
editor_description = "UI-751, FS-338"
+material = SubResource("ShaderMaterial_bhuqb")
layout_mode = 2
-texture = ExtResource("2_r613r")
+color = Color(0.921569, 0.835294, 0.701961, 1)
-[node name="ViewportQuad" type="Control" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap"]
+[node name="ViewportQuad" type="Control" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap" node_paths=PackedStringArray("_minimap_texture")]
layout_mode = 2
-mouse_filter = 2
+mouse_filter = 1
script = ExtResource("3_s4dml")
-
-[node name="Frame" type="NinePatchRect" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap"]
-layout_mode = 2
-texture = ExtResource("4_f1exl")
-draw_center = false
-patch_margin_left = 10
-patch_margin_top = 10
-patch_margin_right = 10
-patch_margin_bottom = 10
-axis_stretch_horizontal = 1
-axis_stretch_vertical = 1
+_minimap_texture = NodePath("../MinimapTexture")
[node name="AuxiliaryPanel" type="VBoxContainer" parent="MapPanelMargin/MapPanelList"]
editor_description = "UI-761"
@@ -104,6 +101,7 @@ 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 e74ea59..e2c8519 100644
--- a/game/src/GameSession/MapView.gd
+++ b/game/src/GameSession/MapView.gd
@@ -12,12 +12,6 @@ const _action_zoom_out : StringName = &"map_zoom_out"
const _action_drag : StringName = &"map_drag"
const _action_click : StringName = &"map_click"
-const _shader_param_province_index : StringName = &"province_index_tex"
-const _shader_param_province_colour : StringName = &"province_colour_tex"
-const _shader_param_hover_index : StringName = &"hover_index"
-const _shader_param_selected_index : StringName = &"selected_index"
-const _shader_param_terrain_tile_factor : StringName = &"terrain_tile_factor"
-
@export var _camera : Camera3D
@export var _cardinal_move_speed : float = 1.0
@@ -40,9 +34,6 @@ var _mouse_over_viewport : bool = true
@export var _map_mesh_instance : MeshInstance3D
var _map_mesh : MapMesh
var _map_shader_material : ShaderMaterial
-var _map_image_size : Vector2
-var _map_province_colour_image : Image
-var _map_province_colour_texture : ImageTexture
var _map_mesh_corner : Vector2
var _map_mesh_dims : Vector2
@@ -68,42 +59,20 @@ func _ready():
# Shader Material
var map_material := _map_mesh_instance.get_active_material(0)
- if map_material == null:
- push_error("Map mesh is missing material!")
- return
- if not map_material is ShaderMaterial:
- push_error("Invalid map mesh material class: ", map_material.get_class())
+ if Events.ShaderManager.set_up_shader(map_material, true) != OK:
+ push_error("Failed to set up map shader")
return
_map_shader_material = map_material
- # 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 := 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
- _map_province_colour_image = GameSingleton.get_province_colour_image()
- if _map_province_colour_image == null:
- push_error("Failed to get province colour image!")
- return
- _map_province_colour_texture = ImageTexture.create_from_image(_map_province_colour_image)
- _map_shader_material.set_shader_parameter(_shader_param_province_colour, _map_province_colour_texture)
-
if not _map_mesh_instance.mesh is MapMesh:
push_error("Invalid map mesh class: ", _map_mesh_instance.mesh.get_class(), "(expected MapMesh)")
return
_map_mesh = _map_mesh_instance.mesh
# Set map mesh size and get bounds
- _map_image_size = Vector2(Vector2i(GameSingleton.get_width(), GameSingleton.get_height()))
- _map_mesh.aspect_ratio = _map_image_size.x / _map_image_size.y
- _map_shader_material.set_shader_parameter(_shader_param_terrain_tile_factor, _map_image_size.y / 64.0)
+ _map_mesh.aspect_ratio = GameSingleton.get_aspect_ratio()
+ _map_shader_material.set_shader_parameter(Events.ShaderManager.param_terrain_tile_factor,
+ float(GameSingleton.get_height()) / 128.0)
var map_mesh_aabb := _map_mesh.get_core_aabb() * _map_mesh_instance.transform
_map_mesh_corner = Vector2(
min(map_mesh_aabb.position.x, map_mesh_aabb.end.x),
@@ -121,10 +90,6 @@ func _notification(what : int):
NOTIFICATION_WM_MOUSE_EXIT: # Mouse out of window
_on_mouse_exited_viewport()
-func _update_colour_texture() -> void:
- GameSingleton.update_colour_image()
- _map_province_colour_texture.update(_map_province_colour_image)
-
func _world_to_map_coords(pos : Vector3) -> Vector2:
return (Vector2(pos.x, pos.z) - _map_mesh_corner) / _map_mesh_dims
@@ -147,15 +112,20 @@ func zoom_in() -> void:
func zoom_out() -> void:
_zoom_target += _zoom_target_step
+func _select_province(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
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):
- var selected_index := GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map)
- _map_shader_material.set_shader_parameter(_shader_param_selected_index, selected_index)
- province_selected.emit(selected_index)
+ _select_province(GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map))
else:
print("Clicked outside the map!")
elif event.is_action_pressed(_action_drag):
@@ -251,13 +221,14 @@ func _update_mouse_map_position() -> void:
_mouse_pos_map = _viewport_to_map_coords(_mouse_pos_viewport)
var hover_index := GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map)
if _mouse_over_viewport:
- _map_shader_material.set_shader_parameter(_shader_param_hover_index, hover_index)
+ _map_shader_material.set_shader_parameter(Events.ShaderManager.param_hover_index, hover_index)
func _on_mouse_entered_viewport():
_mouse_over_viewport = true
func _on_mouse_exited_viewport():
_mouse_over_viewport = false
+ _map_shader_material.set_shader_parameter(Events.ShaderManager.param_hover_index, 0)
func _on_minimap_clicked(pos_clicked : Vector2):
pos_clicked *= _map_mesh_dims
diff --git a/game/src/GameSession/MapView.tscn b/game/src/GameSession/MapView.tscn
index c8934c5..fa6ffcd 100644
--- a/game/src/GameSession/MapView.tscn
+++ b/game/src/GameSession/MapView.tscn
@@ -1,16 +1,15 @@
-[gd_scene load_steps=6 format=3 uid="uid://dkehmdnuxih2r"]
+[gd_scene load_steps=5 format=3 uid="uid://dkehmdnuxih2r"]
[ext_resource type="Script" path="res://src/GameSession/MapView.gd" id="1_exccw"]
[ext_resource type="Shader" path="res://src/GameSession/TerrainMap.gdshader" id="1_upocn"]
-[ext_resource type="Texture2D" uid="uid://ckf222w5usrsu" path="res://art/terrain/farmlands.png" id="3_47mq1"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tayeg"]
render_priority = 0
shader = ExtResource("1_upocn")
+shader_parameter/province_shape_subdivisions = null
shader_parameter/hover_index = null
shader_parameter/selected_index = null
shader_parameter/terrain_tile_factor = null
-shader_parameter/farmlands_tex = ExtResource("3_47mq1")
[sub_resource type="MapMesh" id="MapMesh_3gtsd"]
diff --git a/game/src/GameSession/Minimap.gd b/game/src/GameSession/Minimap.gd
index 25c7cac..f5d972a 100644
--- a/game/src/GameSession/Minimap.gd
+++ b/game/src/GameSession/Minimap.gd
@@ -4,8 +4,23 @@ 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
+
+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
diff --git a/game/src/GameSession/Minimap.gdshader b/game/src/GameSession/Minimap.gdshader
new file mode 100644
index 0000000..8b68108
--- /dev/null
+++ b/game/src/GameSession/Minimap.gdshader
@@ -0,0 +1,18 @@
+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/ProvinceIndexSampler.gdshaderinc b/game/src/GameSession/ProvinceIndexSampler.gdshaderinc
new file mode 100644
index 0000000..65f73d8
--- /dev/null
+++ b/game/src/GameSession/ProvinceIndexSampler.gdshaderinc
@@ -0,0 +1,18 @@
+
+// Province shape texture
+uniform sampler2DArray province_shape_tex : repeat_enable, filter_nearest;
+// Province shape subdivisions
+uniform vec2 province_shape_subdivisions;
+
+uvec3 vec3_to_uvec3(vec3 v) {
+ return uvec3(v * 255.0);
+}
+uvec3 read_uvec3(vec2 uv) {
+ uv *= province_shape_subdivisions;
+ vec2 subdivision_coords = mod(floor(uv), province_shape_subdivisions);
+ float idx = subdivision_coords.x + subdivision_coords.y * province_shape_subdivisions.x;
+ return vec3_to_uvec3(texture(province_shape_tex, vec3(uv, idx)).rgb);
+}
+uint uvec2_to_uint(uvec2 v) {
+ return (v.y << 8u) | v.x;
+}
diff --git a/game/src/GameSession/ProvinceOverviewPanel.gd b/game/src/GameSession/ProvinceOverviewPanel.gd
index 17da9d0..5a914f7 100644
--- a/game/src/GameSession/ProvinceOverviewPanel.gd
+++ b/game/src/GameSession/ProvinceOverviewPanel.gd
@@ -1,5 +1,7 @@
extends PanelContainer
+signal province_deselected
+
@export var _province_name_label : Label
@export var _region_name_label : Label
@export var _life_rating_bar : ProgressBar
@@ -92,4 +94,4 @@ func _on_province_selected(index : int) -> void:
_selected_index = index
func _on_close_button_pressed() -> void:
- _selected_index = 0
+ province_deselected.emit()
diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader
index 305a34b..cab757b 100644
--- a/game/src/GameSession/TerrainMap.gdshader
+++ b/game/src/GameSession/TerrainMap.gdshader
@@ -2,49 +2,30 @@ shader_type spatial;
render_mode unshaded;
-// Cosmetic farmlands terrain texture
-uniform sampler2D farmlands_tex: source_color, repeat_enable, filter_linear;
-// Province index texture
-uniform sampler2DArray province_index_tex : source_color, repeat_enable, filter_nearest;
+#include "ProvinceIndexSampler.gdshaderinc"
+
// Province colour texture
uniform sampler2D province_colour_tex: source_color, repeat_enable, filter_nearest;
// Index of the mouse over the map mesh
uniform uint hover_index;
// Index of the currently selected province
uniform uint selected_index;
+// Cosmetic terrain textures
+uniform sampler2DArray terrain_tex: source_color, repeat_enable, filter_linear;
// The number of times the terrain textures should tile vertically
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;
-}
-
-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(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;
- float is_land = province_data.a;
- vec3 farmlands_colour = texture(farmlands_tex, terrain_uv).rgb;
- vec3 terrain_colour = mix(water_colour, farmlands_colour, is_land);
- float mix_val = 0.4 + float(index == hover_index) * 0.2 + float(index == selected_index) * 0.2;
- vec3 mixed_colour = mix(terrain_colour, province_colour, mix_val);
- return mixed_colour;
+ uvec3 province_data = read_uvec3(fma(corner, half_pixel_size, uv));
+ vec4 province_colour = texelFetch(province_colour_tex, ivec2(province_data.rg), 0);
+ vec3 terrain_colour = texture(terrain_tex, vec3(terrain_uv, float(province_data.b))).rgb;
+ uint index = uvec2_to_uint(province_data.rg);
+ float mix_val = province_colour.a + float(index == hover_index) * 0.2 + float(index == selected_index) * 0.2;
+ return mix(terrain_colour, province_colour.rgb, mix_val);
}
vec3 mix_terrain_colour(vec2 uv) {
- vec2 map_size = vec2(textureSize(province_index_tex, 0).xy);
+ vec2 map_size = vec2(textureSize(province_shape_tex, 0).xy) * province_shape_subdivisions;
vec2 pixel_offset = fract(fma(uv, map_size, vec2(0.5)));
vec2 half_pixel_size = 0.49 / map_size;