aboutsummaryrefslogtreecommitdiff
path: root/game/src
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-04-18 19:55:10 +0200
committer GitHub <noreply@github.com>2023-04-18 19:55:10 +0200
commitea077c8a7c78477bd247c7fbd21de13bcf2285e9 (patch)
tree0cc2be6ef3ab1f2af5c2806f60abe988ca6aa7b5 /game/src
parent258a088018d36e987b3ffe4a9b418a6c21ad9217 (diff)
parent1fdd198f943a41468b03b2cdc62c24147f707239 (diff)
Merge pull request #88 from OpenVic2Project/map-drawing
Further Map Stuff
Diffstat (limited to 'game/src')
-rw-r--r--game/src/Autoload/Events.gd5
-rw-r--r--game/src/GameSession/GameSession.gd9
-rw-r--r--game/src/GameSession/GameSession.tscn32
-rw-r--r--game/src/GameSession/GameSessionMenu.gd21
-rw-r--r--game/src/GameSession/GameSessionMenu.tscn59
-rw-r--r--game/src/GameSession/MapControlPanel.gd13
-rw-r--r--game/src/GameSession/MapControlPanel.tscn68
-rw-r--r--game/src/GameSession/MapView.gd30
-rw-r--r--game/src/GameSession/MapView.tscn6
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel.gd27
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel.tscn13
-rw-r--r--game/src/GameSession/TerrainMap.gdshader50
12 files changed, 252 insertions, 81 deletions
diff --git a/game/src/Autoload/Events.gd b/game/src/Autoload/Events.gd
index f4aac70..dbd3f9f 100644
--- a/game/src/Autoload/Events.gd
+++ b/game/src/Autoload/Events.gd
@@ -4,14 +4,17 @@ var Options = preload("Events/Options.gd").new()
var Localisation = preload("Events/Localisation.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"
# REQUIREMENTS
-# * FS-333, FS-335, FS-341
+# * FS-333, FS-334, FS-335, FS-341
func _ready():
if MapSingleton.load_province_identifier_file(_province_identifier_file) != OK:
push_error("Failed to load province identifiers")
+ if MapSingleton.load_water_province_file(_water_province_file) != OK:
+ push_error("Failed to load water provinces")
if MapSingleton.load_region_file(_region_file) != OK:
push_error("Failed to load regions")
if MapSingleton.load_province_shape_file(_province_shape_file) != OK:
diff --git a/game/src/GameSession/GameSession.gd b/game/src/GameSession/GameSession.gd
index 38eaba1..fe83a8a 100644
--- a/game/src/GameSession/GameSession.gd
+++ b/game/src/GameSession/GameSession.gd
@@ -1,16 +1,11 @@
-extends Node
+extends Control
@export var _game_session_menu : Control
func _ready():
- print("GameSession ready")
+ Events.Options.load_settings_from_file()
# REQUIREMENTS:
# * SS-42
func _on_game_session_menu_button_pressed():
_game_session_menu.visible = !_game_session_menu.visible
-
-# REQUIREMENTS:
-# * SS-64
-func _on_game_session_menu_close_button_pressed():
- _game_session_menu.hide()
diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn
index e270f8a..d23cb6c 100644
--- a/game/src/GameSession/GameSession.tscn
+++ b/game/src/GameSession/GameSession.tscn
@@ -1,13 +1,21 @@
-[gd_scene load_steps=6 format=3 uid="uid://bgnupcshe1m7r"]
+[gd_scene load_steps=7 format=3 uid="uid://bgnupcshe1m7r"]
[ext_resource type="Script" path="res://src/GameSession/GameSession.gd" id="1_eklvp"]
[ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/GameSession/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://cnbfxjy1m6wja" path="res://src/OptionMenu/OptionsMenu.tscn" id="6_p5mnx"]
-[node name="GameSession" type="Node" node_paths=PackedStringArray("_game_session_menu")]
+[node name="GameSession" type="Control" node_paths=PackedStringArray("_game_session_menu")]
editor_description = "SS-102, UI-546"
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+mouse_filter = 2
script = ExtResource("1_eklvp")
_game_session_menu = NodePath("GameSessionMenu")
@@ -15,6 +23,7 @@ _game_session_menu = NodePath("GameSessionMenu")
[node name="GameSessionMenu" parent="." instance=ExtResource("3_bvmqh")]
visible = false
+layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
@@ -24,28 +33,31 @@ grow_horizontal = 2
grow_vertical = 2
[node name="MapControlPanel" parent="." instance=ExtResource("3_afh6d")]
+layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
-offset_left = -350.0
-offset_top = -210.0
grow_horizontal = 0
grow_vertical = 0
[node name="ProvinceOverviewPanel" parent="." instance=ExtResource("5_osjnn")]
-anchors_preset = -1
-anchor_top = 0.583333
-anchor_right = 0.15625
-offset_top = 0.0
-offset_right = 0.0
+layout_mode = 1
+
+[node name="OptionsMenu" parent="." instance=ExtResource("6_p5mnx")]
+visible = false
+layout_mode = 1
[connection signal="map_view_camera_changed" from="MapView" to="MapControlPanel" method="_on_map_view_camera_changed"]
[connection signal="province_selected" from="MapView" to="ProvinceOverviewPanel" method="_on_province_selected"]
-[connection signal="close_button_pressed" from="GameSessionMenu" to="." method="_on_game_session_menu_close_button_pressed"]
+[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="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/GameSessionMenu.gd b/game/src/GameSession/GameSessionMenu.gd
index 3722b52..8a76c0f 100644
--- a/game/src/GameSession/GameSessionMenu.gd
+++ b/game/src/GameSession/GameSessionMenu.gd
@@ -1,19 +1,24 @@
extends PanelContainer
-signal close_button_pressed
-
@export var _main_menu_scene : PackedScene
-func _ready():
- print("GameSessionMenu ready")
+signal options_button_pressed
# REQUIREMENTS:
# * SS-47
# * UIFUN-69
-func _on_to_main_menu_pressed():
+func _on_main_menu_confirmed() -> void:
get_tree().change_scene_to_packed(_main_menu_scene)
# REQUIREMENTS:
-# * UIFUN-69
-func _on_close_button_pressed():
- close_button_pressed.emit()
+# * SS-48
+# * UIFUN-70
+func _on_quit_confirmed() -> void:
+ get_tree().quit()
+
+# REQUIREMENTS:
+# * SS-7, SS-46
+# * UIFUN-11
+func _on_options_button_pressed() -> void:
+ hide()
+ options_button_pressed.emit()
diff --git a/game/src/GameSession/GameSessionMenu.tscn b/game/src/GameSession/GameSessionMenu.tscn
index 45fff4b..a753184 100644
--- a/game/src/GameSession/GameSessionMenu.tscn
+++ b/game/src/GameSession/GameSessionMenu.tscn
@@ -8,21 +8,64 @@ editor_description = "UI-68"
script = ExtResource("1_usq6o")
_main_menu_scene = ExtResource("2_xi6a4")
-[node name="VBoxContainer" type="VBoxContainer" parent="."]
+[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
+theme_override_constants/margin_left = 10
+theme_override_constants/margin_top = 10
+theme_override_constants/margin_right = 10
+theme_override_constants/margin_bottom = 10
-[node name="MainMenuButton" type="Button" parent="VBoxContainer"]
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
+layout_mode = 2
+
+[node name="SaveButton" type="Button" parent="MarginContainer/VBoxContainer"]
+editor_description = "UI-69"
+layout_mode = 2
+text = "GAMESESSIONMENU_SAVE"
+
+[node name="LoadButton" type="Button" parent="MarginContainer/VBoxContainer"]
+editor_description = "UI-70"
+layout_mode = 2
+text = "GAMESESSIONMENU_LOAD"
+
+[node name="OptionsButton" type="Button" parent="MarginContainer/VBoxContainer"]
+editor_description = "UI-10"
+layout_mode = 2
+text = "GAMESESSIONMENU_OPTIONS"
+
+[node name="MainMenuButton" type="Button" parent="MarginContainer/VBoxContainer"]
editor_description = "UI-71"
layout_mode = 2
-text = "GAMESESSIONMENU_RESIGN"
+text = "GAMESESSIONMENU_MAINMENU"
+
+[node name="QuitButton" type="Button" parent="MarginContainer/VBoxContainer"]
+editor_description = "UI-72"
+layout_mode = 2
+text = "GAMESESSIONMENU_QUIT"
-[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
+[node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
-[node name="CloseButton" type="Button" parent="VBoxContainer"]
-editor_description = "UI-80"
+[node name="CloseButton" type="Button" parent="MarginContainer/VBoxContainer"]
+editor_description = "SS-64, UI-80, UIFUN-79"
layout_mode = 2
text = "GAMESESSIONMENU_CLOSE"
-[connection signal="pressed" from="VBoxContainer/MainMenuButton" to="." method="_on_to_main_menu_pressed"]
-[connection signal="pressed" from="VBoxContainer/CloseButton" to="." method="_on_close_button_pressed"]
+[node name="MainMenuDialog" type="ConfirmationDialog" parent="."]
+title = "GAMESESSIONMENU_MAINMENU_DIALOG_TITLE"
+ok_button_text = "DIALOG_OK"
+dialog_text = "GAMESESSIONMENU_MAINMENU_DIALOG_TEXT"
+cancel_button_text = "DIALOG_CANCEL"
+
+[node name="QuitDialog" type="ConfirmationDialog" parent="."]
+title = "GAMESESSIONMENU_QUIT_DIALOG_TITLE"
+ok_button_text = "DIALOG_OK"
+dialog_text = "GAMESESSIONMENU_QUIT_DIALOG_TEXT"
+cancel_button_text = "DIALOG_CANCEL"
+
+[connection signal="pressed" from="MarginContainer/VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"]
+[connection signal="pressed" from="MarginContainer/VBoxContainer/MainMenuButton" to="MainMenuDialog" method="popup_centered"]
+[connection signal="pressed" from="MarginContainer/VBoxContainer/QuitButton" to="QuitDialog" method="popup_centered"]
+[connection signal="pressed" from="MarginContainer/VBoxContainer/CloseButton" to="." method="hide"]
+[connection signal="confirmed" from="MainMenuDialog" to="." method="_on_main_menu_confirmed"]
+[connection signal="confirmed" from="QuitDialog" to="." method="_on_quit_confirmed"]
diff --git a/game/src/GameSession/MapControlPanel.gd b/game/src/GameSession/MapControlPanel.gd
index 693890f..d5810c5 100644
--- a/game/src/GameSession/MapControlPanel.gd
+++ b/game/src/GameSession/MapControlPanel.gd
@@ -4,6 +4,8 @@ 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 zoom_in_button_pressed
+signal zoom_out_button_pressed
@export var _mapmodes_grid : GridContainer
@@ -17,6 +19,7 @@ func _add_mapmode_button(identifier : String) -> void:
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
@@ -44,3 +47,13 @@ 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)
+
+# 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
index 70d7eab..27205e3 100644
--- a/game/src/GameSession/MapControlPanel.tscn
+++ b/game/src/GameSession/MapControlPanel.tscn
@@ -15,49 +15,89 @@ events = [SubResource("InputEventAction_5nck3")]
editor_description = "SS-103"
mouse_filter = 1
script = ExtResource("1_ign64")
-_mapmodes_grid = NodePath("HBoxContainer/VBoxContainer/MapmodesGrid")
+_mapmodes_grid = NodePath("MarginContainer/HBoxContainer/VBoxContainer/MapmodesGrid")
-[node name="HBoxContainer" type="HBoxContainer" parent="."]
+[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
-alignment = 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="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
layout_mode = 2
+theme_override_constants/separation = 6
+alignment = 1
-[node name="MapmodesGrid" type="GridContainer" parent="HBoxContainer/VBoxContainer"]
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"]
+layout_mode = 2
+alignment = 1
+
+[node name="MapmodesGrid" type="GridContainer" parent="MarginContainer/HBoxContainer/VBoxContainer"]
editor_description = "UI-750"
layout_mode = 2
columns = 11
-[node name="Minimap" type="PanelContainer" parent="HBoxContainer/VBoxContainer"]
+[node name="Minimap" type="PanelContainer" parent="MarginContainer/HBoxContainer/VBoxContainer"]
editor_description = "UI-549"
layout_mode = 2
mouse_filter = 1
-[node name="TextureRect" type="TextureRect" parent="HBoxContainer/VBoxContainer/Minimap"]
+[node name="TextureRect" type="TextureRect" parent="MarginContainer/HBoxContainer/VBoxContainer/Minimap"]
editor_description = "UI-751, FS-338"
layout_mode = 2
texture = ExtResource("2_r613r")
-[node name="ViewportQuad" type="Control" parent="HBoxContainer/VBoxContainer/Minimap"]
+[node name="ViewportQuad" type="Control" parent="MarginContainer/HBoxContainer/VBoxContainer/Minimap"]
layout_mode = 2
mouse_filter = 2
script = ExtResource("3_s4dml")
-[node name="Frame" type="NinePatchRect" parent="HBoxContainer/VBoxContainer/Minimap"]
+[node name="Frame" type="NinePatchRect" parent="MarginContainer/HBoxContainer/VBoxContainer/Minimap"]
layout_mode = 2
texture = ExtResource("4_f1exl")
-[node name="AuxiliaryPanel" type="VBoxContainer" parent="HBoxContainer"]
+[node name="AuxiliaryPanel" type="VBoxContainer" parent="MarginContainer/HBoxContainer"]
editor_description = "UI-761"
layout_mode = 2
-[node name="GameSessionMenuButton" type="Button" parent="HBoxContainer/AuxiliaryPanel"]
+[node name="GameSessionMenuButton" type="Button" parent="MarginContainer/HBoxContainer/AuxiliaryPanel"]
editor_description = "UI-9"
layout_mode = 2
+mouse_filter = 1
shortcut = SubResource("Shortcut_fc1tk")
text = "ESC"
-[connection signal="map_view_camera_changed" from="." to="HBoxContainer/VBoxContainer/Minimap/ViewportQuad" method="_on_map_view_camera_changed"]
-[connection signal="minimap_clicked" from="HBoxContainer/VBoxContainer/Minimap/ViewportQuad" to="." method="_on_minimap_clicked"]
-[connection signal="pressed" from="HBoxContainer/AuxiliaryPanel/GameSessionMenuButton" to="." method="_on_game_session_menu_button_pressed"]
+[node name="LedgerButton" type="Button" parent="MarginContainer/HBoxContainer/AuxiliaryPanel"]
+editor_description = "UI-860"
+layout_mode = 2
+mouse_filter = 1
+text = "L"
+
+[node name="FindButton" type="Button" parent="MarginContainer/HBoxContainer/AuxiliaryPanel"]
+editor_description = "UI-861"
+layout_mode = 2
+mouse_filter = 1
+text = "F"
+
+[node name="ZoomButtonsContainer" type="HBoxContainer" parent="MarginContainer/HBoxContainer/AuxiliaryPanel"]
+layout_mode = 2
+alignment = 1
+
+[node name="ZoomInButton" type="Button" parent="MarginContainer/HBoxContainer/AuxiliaryPanel/ZoomButtonsContainer"]
+editor_description = "UI-862"
+layout_mode = 2
+mouse_filter = 1
+text = "+"
+
+[node name="ZoomOutButton" type="Button" parent="MarginContainer/HBoxContainer/AuxiliaryPanel/ZoomButtonsContainer"]
+editor_description = "UI-863"
+layout_mode = 2
+mouse_filter = 1
+text = "-"
+
+[connection signal="map_view_camera_changed" from="." to="MarginContainer/HBoxContainer/VBoxContainer/Minimap/ViewportQuad" method="_on_map_view_camera_changed"]
+[connection signal="minimap_clicked" from="MarginContainer/HBoxContainer/VBoxContainer/Minimap/ViewportQuad" to="." method="_on_minimap_clicked"]
+[connection signal="pressed" from="MarginContainer/HBoxContainer/AuxiliaryPanel/GameSessionMenuButton" to="." method="_on_game_session_menu_button_pressed"]
+[connection signal="pressed" from="MarginContainer/HBoxContainer/AuxiliaryPanel/ZoomButtonsContainer/ZoomInButton" to="." method="_on_zoom_in_button_pressed"]
+[connection signal="pressed" from="MarginContainer/HBoxContainer/AuxiliaryPanel/ZoomButtonsContainer/ZoomOutButton" to="." method="_on_zoom_out_button_pressed"]
diff --git a/game/src/GameSession/MapView.gd b/game/src/GameSession/MapView.gd
index 54d8df8..ae49e82 100644
--- a/game/src/GameSession/MapView.gd
+++ b/game/src/GameSession/MapView.gd
@@ -16,6 +16,7 @@ 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
@@ -25,9 +26,9 @@ const _shader_param_selected_index : StringName = &"selected_index"
var _drag_anchor : Vector2
var _drag_active : bool = false
-var _mouse_over_viewport : bool = false
+var _mouse_over_viewport : bool = true
-@export var _zoom_target_min : float = 0.2
+@export var _zoom_target_min : float = 0.05
@export var _zoom_target_max : float = 5.0
@export var _zoom_target_step : float = 0.1
@export var _zoom_epsilon : float = _zoom_target_step * 0.1
@@ -100,6 +101,7 @@ func _ready():
# Set map mesh size and get bounds
_map_image_size = Vector2(Vector2i(MapSingleton.get_width(), MapSingleton.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)
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),
@@ -137,10 +139,16 @@ func _viewport_to_map_coords(pos_viewport : Vector2) -> Vector2:
push_error("Invalid intersection: ", intersection)
return Vector2(0.5, 0.5)
+func zoom_in() -> void:
+ _zoom_target -= _zoom_target_step
+
+func zoom_out() -> void:
+ _zoom_target += _zoom_target_step
+
# REQUIREMENTS
# * SS-31
func _unhandled_input(event : InputEvent):
- if event.is_action_pressed(_action_click):
+ 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 := MapSingleton.get_province_index_from_uv_coords(_mouse_pos_map)
@@ -159,9 +167,9 @@ func _unhandled_input(event : InputEvent):
push_warning("Drag being deactivated while already not active!")
_drag_active = false
elif event.is_action_pressed(_action_zoomin, true):
- _zoom_target -= _zoom_target_step
+ zoom_in()
elif event.is_action_pressed(_action_zoomout, true):
- _zoom_target += _zoom_target_step
+ zoom_out()
func _physics_process(delta : float):
_mouse_pos_viewport = get_viewport().get_mouse_position()
@@ -228,7 +236,7 @@ func _zoom_process(delta : float) -> void:
_camera.position.y = height
func _update_orientation() -> void:
- var dir := Vector3(0, -1, -exp(-_camera.position.y * 2.0 + 0.5))
+ var dir := Vector3(0, -1, -exp(-_camera.position.y - 1))
_camera.look_at(_camera.position + dir)
func _update_minimap_viewport() -> void:
@@ -254,4 +262,12 @@ func _on_minimap_clicked(pos_clicked : Vector2):
pos_clicked *= _map_mesh_dims
_camera.position.x = pos_clicked.x
_camera.position.z = pos_clicked.y
- _clamp_over_map() \ No newline at end of file
+ _clamp_over_map()
+
+func enable_processing() -> void:
+ set_process_unhandled_input(true)
+ set_physics_process(true)
+
+func disable_processing() -> void:
+ set_process_unhandled_input(false)
+ set_physics_process(false)
diff --git a/game/src/GameSession/MapView.tscn b/game/src/GameSession/MapView.tscn
index 93fc162..c8934c5 100644
--- a/game/src/GameSession/MapView.tscn
+++ b/game/src/GameSession/MapView.tscn
@@ -2,14 +2,15 @@
[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://cmw0pvjthnn8c" path="res://art/terrain/terrain.png" id="3_l8pnf"]
+[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/hover_index = null
shader_parameter/selected_index = null
-shader_parameter/terrain_tex = ExtResource("3_l8pnf")
+shader_parameter/terrain_tile_factor = null
+shader_parameter/farmlands_tex = ExtResource("3_47mq1")
[sub_resource type="MapMesh" id="MapMesh_3gtsd"]
@@ -21,6 +22,7 @@ _map_mesh_instance = NodePath("MapMeshInstance")
[node name="MapCamera" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0.25, 1.5, -2.75)
+near = 0.01
[node name="MapMeshInstance" type="MeshInstance3D" parent="."]
editor_description = "FS-343"
diff --git a/game/src/GameSession/ProvinceOverviewPanel.gd b/game/src/GameSession/ProvinceOverviewPanel.gd
index 434f6b1..4615df9 100644
--- a/game/src/GameSession/ProvinceOverviewPanel.gd
+++ b/game/src/GameSession/ProvinceOverviewPanel.gd
@@ -1,22 +1,33 @@
extends Panel
@export var _province_name_label : Label
+@export var _region_name_label : Label
-@export var province_identifier: String = "":
- get: return province_identifier
+var _province_identifier: String = "":
+ get: return _province_identifier
set(v):
- province_identifier = v
+ _province_identifier = v
update_info()
+const _name_suffix : String = "_NAME"
+
func _ready():
update_info()
func update_info() -> void:
- _province_name_label.text = province_identifier + "_NAME"
- visible = not province_identifier.is_empty()
+ if _province_identifier:
+ _province_name_label.text = _province_identifier + _name_suffix
+ var region_identifier := MapSingleton.get_region_identifier_from_province_identifier(_province_identifier)
+ if region_identifier:
+ _region_name_label.text = region_identifier + _name_suffix
+ else:
+ _region_name_label.text = "NO REGION"
+ show()
+ else:
+ hide()
func _on_province_selected(identifier : String) -> void:
- province_identifier = identifier
+ _province_identifier = identifier
-func _on_button_pressed() -> void:
- province_identifier = ""
+func _on_close_button_pressed() -> void:
+ _province_identifier = ""
diff --git a/game/src/GameSession/ProvinceOverviewPanel.tscn b/game/src/GameSession/ProvinceOverviewPanel.tscn
index 2df95fb..7d21edc 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="Panel" node_paths=PackedStringArray("_province_name_label")]
+[node name="ProvinceOverviewPanel" type="Panel" node_paths=PackedStringArray("_province_name_label", "_region_name_label")]
editor_description = "UI-56"
anchors_preset = 2
anchor_top = 1.0
@@ -12,6 +12,7 @@ offset_right = 200.0
grow_vertical = 0
script = ExtResource("1_3n8k5")
_province_name_label = NodePath("VBoxContainer/ProvinceName")
+_region_name_label = NodePath("VBoxContainer/RegionName")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
@@ -29,7 +30,13 @@ layout_mode = 2
text = "PROVINCE_NAME"
vertical_alignment = 1
-[node name="Button" type="Button" parent="."]
+[node name="RegionName" type="Label" parent="VBoxContainer"]
+editor_description = "UI-58"
+layout_mode = 2
+text = "REGION_NAME"
+vertical_alignment = 1
+
+[node name="CloseButton" type="Button" parent="."]
custom_minimum_size = Vector2(30, 30)
layout_mode = 1
anchors_preset = -1
@@ -39,4 +46,4 @@ anchor_bottom = 0.103333
grow_horizontal = 0
text = "X"
-[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
+[connection signal="pressed" from="CloseButton" to="." method="_on_close_button_pressed"]
diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader
index 7aca0f9..9ce1a24 100644
--- a/game/src/GameSession/TerrainMap.gdshader
+++ b/game/src/GameSession/TerrainMap.gdshader
@@ -2,16 +2,18 @@ shader_type spatial;
render_mode unshaded;
-// Cosmetic terrain texture
-uniform sampler2D terrain_tex: source_color, repeat_enable, filter_linear;
+// Cosmetic farmlands terrain texture
+uniform sampler2D farmlands_tex: source_color, repeat_enable, filter_linear;
// Province index texture
-uniform sampler2D province_index_tex : repeat_enable, filter_nearest;
+uniform sampler2D 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
uniform uint hover_index;
// Index of the currently selected province
uniform uint selected_index;
+// 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);
@@ -29,17 +31,39 @@ uint read_uint16(sampler2D tex, vec2 uv) {
return uvec2_to_uint(read_uvec2(tex, uv));
}
-void fragment() {
- uvec2 prov_idx_split = read_uvec2(province_index_tex, UV);
- uint prov_index = uvec2_to_uint(prov_idx_split);
+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));
+ 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;
+}
- // Boost prov_colour's contribution if it matches hover_colour or selected_colour
- float mix_val = 0.3 + float(prov_index == hover_index) * 0.3 + float(prov_index == selected_index) * 0.3;
- // Don't mix if the province index is 0
- mix_val *= float(prov_index != 0u);
+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 half_pixel_size = 0.49 / map_size;
- vec3 terrain_colour = texture(terrain_tex, UV).rgb;
- vec3 province_colour = texelFetch(province_colour_tex, ivec2(prov_idx_split), 0).rgb;
+ vec2 terrain_uv = uv;
+ terrain_uv.x *= map_size.x / map_size.y;
+ terrain_uv *= terrain_tile_factor;
- ALBEDO = mix(terrain_colour, province_colour, mix_val);
+ return mix(
+ mix(get_terrain_colour(uv, vec2(-1, -1), half_pixel_size, terrain_uv),
+ get_terrain_colour(uv, vec2(+1, -1), half_pixel_size, terrain_uv), pixel_offset.x),
+ mix(get_terrain_colour(uv, vec2(-1, +1), half_pixel_size, terrain_uv),
+ get_terrain_colour(uv, vec2(+1, +1), half_pixel_size, terrain_uv), pixel_offset.x),
+ pixel_offset.y);
+}
+
+void fragment() {
+ vec3 terrain_colour = mix_terrain_colour(UV);
+ ALBEDO = terrain_colour;
}