Simplemouse fixes (#669)

* fix: Simplemouse bounding box size fix
* fix: Bug when exiting game with simplemouse with disconnecting non-connected gamepad
* fix: issue-339. Simplemouse gives an error in the debug when you move on/off ESCItems
* fix: tracks mouse position to allow for mouse tracking as well as on-demand tooltip updates on immediate target change, i.e. rendering doesn't lag a frame behind.
* chore: decouple further by using a signal
* fix: Correct action getting randomly lost with simplemouse
* fix: deleted objects aren't always equated to null.
* fix: clear the tooltip when an action is finished.
* fix: clears tooltip only on successful event completion; debug code cleanup.
* Broken room 5
* fix: Item collisions correctly determined when game resolution = screen resolution
* Update addons/escoria-core/game/core-scripts/esc_item.gd
Co-authored-by: Duncan Brown <duncan@prometheussoftware.ca>
* Update addons/escoria-ui-simplemouse/game.gd
Co-authored-by: Duncan Brown <duncan@prometheussoftware.ca>
* fix: Reverted default UI to 9 verbs
Co-authored-by: Balloonpopper <balloonpopper@git.com>
Co-authored-by: Duncan Brown <duncan@prometheussoftware.ca>
This commit is contained in:
balloonpopper
2023-01-12 22:38:06 +11:00
committed by GitHub
parent 68220ced91
commit 53c900b36e
10 changed files with 71 additions and 70 deletions

View File

@@ -321,7 +321,7 @@ class HoverStackSorter:
func _on_input_event(_viewport: Object, event: InputEvent, _shape_idx: int):
if event is InputEventMouseMotion:
var physics2d_dss: Physics2DDirectSpaceState = get_world_2d().direct_space_state
var colliding: Array = physics2d_dss.intersect_point(event.global_position, 32, [], 0x7FFFFFFF, true, true)
var colliding: Array = physics2d_dss.intersect_point(get_global_mouse_position(), 32, [], 0x7FFFFFFF, true, true)
var colliding_nodes = []
for c in colliding:
if c.collider.get("global_id") \

View File

@@ -45,6 +45,9 @@ var waiting_for_target2 = false
# Node containing the debug white background
var debug_texturerect_node: TextureRect
# Indicates whether the current room is loaded and ready
var _room_is_ready: bool = false
# Connect relevant functions
func _ready():
@@ -58,7 +61,8 @@ func _ready():
# - p_color: the color to set the label
func set_color(p_color: Color):
color = p_color
update_tooltip_text()
if _room_is_ready:
update_tooltip_text()
# Enable/disable debug mode of the label. If enabled, the label is displayed
@@ -96,7 +100,8 @@ func set_debug_mode(p_debug_mode: bool):
func set_target(target: String, needs_second_target: bool = false) -> void:
current_target = target
waiting_for_target2 = needs_second_target
update_tooltip_text()
if _room_is_ready:
update_tooltip_text()
# Set the second target of the label
@@ -105,7 +110,8 @@ func set_target(target: String, needs_second_target: bool = false) -> void:
# - target2: String the second target to add to the label
func set_target2(target2: String) -> void:
current_target2 = target2
update_tooltip_text()
if _room_is_ready:
update_tooltip_text()
# Update the tooltip text.
@@ -121,39 +127,7 @@ func update_size():
if not get_tree():
# We're not in the tree anymore. Return
return
var rtl_width = rect_size.x
var rtl_height = rect_size.y
var content_height = get_content_height()
var nb_visible_characters = visible_characters
var nb_visible_lines = get_visible_line_count()
# if text is too long and is wrapped
var nblines = nb_visible_lines
if nblines >= 1:
var text_height = get_content_height()
if text_height > MAX_HEIGHT:
text_height = MAX_HEIGHT
if text_height <= MIN_HEIGHT:
text_height = MIN_HEIGHT
var parent_width = rect_size.x
# first, try to increase width until it goes above max_width
while parent_width < MAX_WIDTH && float(text_height) / float(ONE_LINE_HEIGHT) > 1.0:
rect_size.x += 1
parent_width = rect_size.x
rect_size.y = text_height
if rect_size.x >= MAX_WIDTH:
rect_size.x = MAX_WIDTH
## END RECT_SIZE ##
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
anchor_left = 0.0
rect_size = get_font("normal_font").get_string_size(current_target)
# Calculate the offset of the label depending on its position.
@@ -227,9 +201,12 @@ func clear():
# Called when the room is loaded to setup the label.
func _on_room_ready():
escoria.main.current_scene.game.tooltip_node = self
_room_is_ready = true
# Called when an action is selected in Escoria
func _on_action_selected() -> void:
current_action = escoria.action_manager.current_action
update_tooltip_text()
if _room_is_ready:
update_tooltip_text()

View File

@@ -185,7 +185,7 @@ func unset_hovered_node(item: ESCItem):
if _hovered_element == item:
_hovered_element.mouse_exited()
_hovered_element = null
if not hover_stack.empty() and hover_stack.back():
if hover_stack:
set_hovered_node(hover_stack.pop_back())
else:
hotspot_focused = ""
@@ -211,7 +211,7 @@ func set_hovered_node(item: ESCItem) -> bool:
return true
# Else if the tested item is on top of hover stack (or null)
# Set that item as hovered and call that item's mouse_entered()
if _hovered_element == null or hover_stack.back() != item:
if not is_instance_valid(_hovered_element) or hover_stack.back() != item:
_hovered_element = item
_hovered_element.mouse_entered()
return true