aboutsummaryrefslogtreecommitdiff
path: root/game/src
diff options
context:
space:
mode:
Diffstat (limited to 'game/src')
-rw-r--r--game/src/GameSession/GameSession.tscn1
-rw-r--r--game/src/GameSession/MapControlPanel.gd26
-rw-r--r--game/src/GameSession/MapControlPanel.tscn7
-rw-r--r--game/src/GameSession/MapView.gd20
-rw-r--r--game/src/GameSession/TerrainMap.gdshader2
5 files changed, 44 insertions, 12 deletions
diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn
index 390040e..a645528 100644
--- a/game/src/GameSession/GameSession.tscn
+++ b/game/src/GameSession/GameSession.tscn
@@ -42,3 +42,4 @@ offset_right = 0.0
[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="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"]
diff --git a/game/src/GameSession/MapControlPanel.gd b/game/src/GameSession/MapControlPanel.gd
index ad56536..cfd102c 100644
--- a/game/src/GameSession/MapControlPanel.gd
+++ b/game/src/GameSession/MapControlPanel.gd
@@ -1,8 +1,32 @@
extends PanelContainer
signal game_session_menu_button_pressed
+signal mapmode_changed
+
+@export var _mapmodes_grid : GridContainer
+var _mapmode_button_group : ButtonGroup
+
+func _add_mapmode_button(identifier : String) -> void:
+ var button := Button.new()
+ button.text = identifier
+ button.tooltip_text = identifier
+ button.toggle_mode = true
+ button.button_group = _mapmode_button_group
+ _mapmodes_grid.add_child(button)
+ if _mapmode_button_group.get_pressed_button() == null:
+ button.button_pressed = true
+
+func _ready():
+ _mapmode_button_group = ButtonGroup.new()
+ _mapmode_button_group.pressed.connect(_mapmode_pressed)
+ for index in MapSingleton.get_mapmode_count():
+ _add_mapmode_button(MapSingleton.get_mapmode_identifier(index))
# REQUIREMENTS:
# * UIFUN-10
-func _on_game_session_menu_button_pressed():
+func _on_game_session_menu_button_pressed() -> void:
game_session_menu_button_pressed.emit()
+
+func _mapmode_pressed(button : BaseButton) -> void:
+ MapSingleton.set_mapmode(button.tooltip_text)
+ mapmode_changed.emit()
diff --git a/game/src/GameSession/MapControlPanel.tscn b/game/src/GameSession/MapControlPanel.tscn
index 2a0c971..e0ba0b2 100644
--- a/game/src/GameSession/MapControlPanel.tscn
+++ b/game/src/GameSession/MapControlPanel.tscn
@@ -8,9 +8,10 @@ action = &"ui_cancel"
[sub_resource type="Shortcut" id="Shortcut_fc1tk"]
events = [SubResource("InputEventAction_5nck3")]
-[node name="PanelContainer" type="PanelContainer"]
+[node name="PanelContainer" type="PanelContainer" node_paths=PackedStringArray("_mapmodes_grid")]
editor_description = "SS-103"
script = ExtResource("1_ign64")
+_mapmodes_grid = NodePath("HBoxContainer/VBoxContainer/MapmodesGrid")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
@@ -18,9 +19,9 @@ layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
layout_mode = 2
-[node name="MapmodesPlaceholder" type="Label" parent="HBoxContainer/VBoxContainer"]
+[node name="MapmodesGrid" type="GridContainer" parent="HBoxContainer/VBoxContainer"]
layout_mode = 2
-text = "MAPMODES"
+columns = 11
[node name="MinimapPlaceholder" type="Label" parent="HBoxContainer/VBoxContainer"]
layout_mode = 2
diff --git a/game/src/GameSession/MapView.gd b/game/src/GameSession/MapView.gd
index 4291191..b13f09d 100644
--- a/game/src/GameSession/MapView.gd
+++ b/game/src/GameSession/MapView.gd
@@ -19,7 +19,7 @@ const _shader_param_selected_pos : StringName = &"selected_pos"
@export var _camera : Camera3D
@export var _cardinal_move_speed : float = 1.0
-@export var _edge_move_threshold: float = 0.15
+@export var _edge_move_threshold: float = 0.02
@export var _edge_move_speed: float = 2.5
var _drag_anchor : Vector2
var _drag_active : bool = false
@@ -38,6 +38,8 @@ 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
var _map_mesh_dims : Vector2
@@ -60,7 +62,7 @@ func _ready():
return
# Shader Material
- var map_material = _map_mesh_instance.get_active_material(0)
+ var map_material := _map_mesh_instance.get_active_material(0)
if map_material == null:
push_error("Map mesh is missing material!")
return
@@ -78,12 +80,12 @@ func _ready():
_map_shader_material.set_shader_parameter(_shader_param_province_index, province_index_texture)
# Province colour texture
- var province_colour_image = MapSingleton.get_province_colour_image()
- if province_colour_image == null:
+ _map_province_colour_image = MapSingleton.get_province_colour_image()
+ if _map_province_colour_image == null:
push_error("Failed to get province colour image!")
return
- var province_colour_texture := ImageTexture.create_from_image(province_colour_image)
- _map_shader_material.set_shader_parameter(_shader_param_province_colour, province_colour_texture)
+ _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)")
@@ -103,6 +105,10 @@ func _ready():
map_mesh_aabb.position.z - map_mesh_aabb.end.z
))
+func _update_colour_texture() -> void:
+ MapSingleton.update_colour_image()
+ _map_province_colour_texture.update(_map_province_colour_image)
+
func _unhandled_input(event : InputEvent):
if event.is_action_pressed(_action_click):
# Check if the mouse is outside of bounds
@@ -151,7 +157,7 @@ func _movement_process(delta : float) -> void:
func _edge_scrolling_vector() -> Vector2:
var viewport_dims := Vector2(Resolution.get_current_resolution())
var mouse_vector := _mouse_pos_viewport / viewport_dims - Vector2(0.5, 0.5);
- if pow(mouse_vector.x, 4) + pow(mouse_vector.y, 4) < pow(0.5 - _edge_move_threshold, 4):
+ if abs(mouse_vector.x) < 0.5 - _edge_move_threshold and abs(mouse_vector.y) < 0.5 - _edge_move_threshold:
mouse_vector *= 0
return mouse_vector * _edge_move_speed
diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader
index a6774fd..f3d0c7d 100644
--- a/game/src/GameSession/TerrainMap.gdshader
+++ b/game/src/GameSession/TerrainMap.gdshader
@@ -37,7 +37,7 @@ void fragment() {
uint selected_index = read_uint16(province_index_tex, selected_pos);
// Boost prov_colour's contribution if it matches hover_colour or selected_colour
- float mix_val = float(prov_index == hover_index) * 0.3 + float(prov_index == selected_index) * 0.5;
+ 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);