Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions game/src/Systems/Session/Map/MapView.gd
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,13 @@ func _ready() -> void:
_map_text.generate_map_names()

func _notification(what: int) -> void:
if what == NOTIFICATION_WM_MOUSE_EXIT:
_mouse_over_viewport = false
province_unhovered.emit()
match what:
NOTIFICATION_WM_MOUSE_ENTER:
_mouse_over_viewport = true
queue_province_hover_update()
NOTIFICATION_WM_MOUSE_EXIT:
_mouse_over_viewport = false
province_unhovered.emit()

func _world_to_map_coords(pos : Vector3) -> Vector2:
return (Vector2(pos.x, pos.z) - _map_mesh_corner) / _map_mesh_dims
Expand Down Expand Up @@ -213,7 +217,6 @@ func _input(event : InputEvent) -> void:
var _cardinal_movement_vector := Vector2.ZERO
func _unhandled_input(event : InputEvent) -> void:
if event is InputEventMouseMotion:
_mouse_over_viewport = true
queue_province_hover_update()

elif event.is_action(_action_north) or event.is_action(_action_south)\
Expand Down Expand Up @@ -278,10 +281,6 @@ func _process(delta : float) -> void:
if _cardinal_movement_vector != Vector2.ZERO and get_window().gui_get_focus_owner() != null:
_cardinal_movement_vector = Vector2.ZERO

if _is_viewport_inactive():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this case handled via the NOTIFICATION_WM_MOUSE_EXIT?
The old code implies it wasn't.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be now, in the old code we weren't catching the on exit stuff iirc, it was just doing a check each tick. Not sure why it was like that, this system should be more correct(?)

_mouse_over_viewport = false
province_unhovered.emit()

_viewport_dims = Vector2(Resolution.get_current_resolution())
# Process movement
_movement_process(delta)
Expand Down Expand Up @@ -387,9 +386,6 @@ func _on_minimap_clicked(pos_clicked : Vector2) -> void:
_clamp_over_map()
queue_province_hover_update()

func _is_viewport_inactive() -> bool:
return not get_window().has_focus() or get_window().is_input_handled()

func enable_processing() -> void:
set_process_unhandled_input(true)
set_process(true)
Expand Down
Loading