aboutsummaryrefslogtreecommitdiff
path: root/game/src/GameSession/MapView.gd
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-05-01 01:34:59 +0200
committer GitHub <noreply@github.com>2023-05-01 01:34:59 +0200
commitb1e985e0774598b3add22069be50f891e981fd79 (patch)
treee18e9cb252030e9b40ff91463ed117dd00a65789 /game/src/GameSession/MapView.gd
parent1f8545facd248bbf4ea0cd551fea5f7d9b0efdce (diff)
parent2fec521cc6bbe7b2cda0eef3b830acbfc8b68333 (diff)
Merge pull request #103 from OpenVic2Project/terrain
Cosmetic terrain + Hashmaps
Diffstat (limited to 'game/src/GameSession/MapView.gd')
-rw-r--r--game/src/GameSession/MapView.gd15
1 files changed, 11 insertions, 4 deletions
diff --git a/game/src/GameSession/MapView.gd b/game/src/GameSession/MapView.gd
index 340083f..e2c8519 100644
--- a/game/src/GameSession/MapView.gd
+++ b/game/src/GameSession/MapView.gd
@@ -71,7 +71,8 @@ func _ready():
# Set map mesh size and get bounds
_map_mesh.aspect_ratio = GameSingleton.get_aspect_ratio()
- _map_shader_material.set_shader_parameter(Events.ShaderManager.param_terrain_tile_factor, float(GameSingleton.get_height()) / 64.0)
+ _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),
@@ -111,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(Events.ShaderManager.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):
@@ -222,6 +228,7 @@ func _on_mouse_entered_viewport():
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