aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-04-13 20:37:31 +0200
committer Hop311 <hop3114@gmail.com>2023-04-13 20:37:31 +0200
commit66e63d41a109d85b10396e8a2dd934a829cc57fe (patch)
treedfa1b40b6f4f555b9f25e5ddc3abfa46f7728a4b
parent7523c42190c9211ea65db3b00b9476487c61052a (diff)
Small fixes
-rw-r--r--extension/src/MapSingleton.cpp8
-rw-r--r--game/src/GameSession/MapView.gd2
-rw-r--r--game/src/GameSession/Minimap.gd6
3 files changed, 6 insertions, 10 deletions
diff --git a/extension/src/MapSingleton.cpp b/extension/src/MapSingleton.cpp
index 7ad404c..73cf522 100644
--- a/extension/src/MapSingleton.cpp
+++ b/extension/src/MapSingleton.cpp
@@ -243,8 +243,8 @@ Province* MapSingleton::get_province_from_uv_coords(godot::Vector2 const& coords
if (province_index_image.is_valid()) {
const PackedByteArray index_data_array = province_index_image->get_data();
Province::index_t const* index_data = reinterpret_cast<Province::index_t const*>(index_data_array.ptr());
- const int32_t x_mod_w = UtilityFunctions::posmod(coords.x, 1.0f) * get_width();
- const int32_t y_mod_h = UtilityFunctions::posmod(coords.y, 1.0f) * get_height();
+ const int32_t x_mod_w = UtilityFunctions::fposmod(coords.x, 1.0f) * get_width();
+ const int32_t y_mod_h = UtilityFunctions::fposmod(coords.y, 1.0f) * get_height();
return map.get_province_by_index(index_data[x_mod_w + y_mod_h * get_width()]);
}
return nullptr;
@@ -254,8 +254,8 @@ Province const* MapSingleton::get_province_from_uv_coords(godot::Vector2 const&
if (province_index_image.is_valid()) {
const PackedByteArray index_data_array = province_index_image->get_data();
Province::index_t const* index_data = reinterpret_cast<Province::index_t const*>(index_data_array.ptr());
- const int32_t x_mod_w = UtilityFunctions::posmod(coords.x, 1.0f) * get_width();
- const int32_t y_mod_h = UtilityFunctions::posmod(coords.y, 1.0f) * get_height();
+ const int32_t x_mod_w = UtilityFunctions::fposmod(coords.x, 1.0f) * get_width();
+ const int32_t y_mod_h = UtilityFunctions::fposmod(coords.y, 1.0f) * get_height();
return map.get_province_by_index(index_data[x_mod_w + y_mod_h * get_width()]);
}
return nullptr;
diff --git a/game/src/GameSession/MapView.gd b/game/src/GameSession/MapView.gd
index 05e77fa..857365b 100644
--- a/game/src/GameSession/MapView.gd
+++ b/game/src/GameSession/MapView.gd
@@ -241,7 +241,7 @@ func _update_minimap_viewport() -> void:
func _update_mouse_map_position() -> void:
_mouse_pos_map = _viewport_to_map_coords(_mouse_pos_viewport)
var hover_index := MapSingleton.get_province_index_from_uv_coords(_mouse_pos_map)
- if not _mouse_over_viewport:
+ if _mouse_over_viewport:
_map_shader_material.set_shader_parameter(_shader_param_hover_index, hover_index)
func _on_mouse_entered_viewport():
diff --git a/game/src/GameSession/Minimap.gd b/game/src/GameSession/Minimap.gd
index d904b3d..25c7cac 100644
--- a/game/src/GameSession/Minimap.gd
+++ b/game/src/GameSession/Minimap.gd
@@ -17,11 +17,7 @@ func _draw() -> void:
# * SS-81
# * UIFUN-127
func _unhandled_input(event : InputEvent):
- if event is InputEventMouseMotion and Input.is_action_pressed(_action_click):
- var pos_clicked := get_local_mouse_position() / size - Vector2(0.5, 0.5)
- if abs(pos_clicked.x) < 0.5 and abs(pos_clicked.y) < 0.5:
- minimap_clicked.emit(pos_clicked)
- if event != InputEventMouseMotion and Input.is_action_pressed(_action_click):
+ if event is InputEventMouse and Input.is_action_pressed(_action_click):
var pos_clicked := get_local_mouse_position() / size - Vector2(0.5, 0.5)
if abs(pos_clicked.x) < 0.5 and abs(pos_clicked.y) < 0.5:
minimap_clicked.emit(pos_clicked)