MODIFIED addons/escoria-core/game/core-scripts/esc_game.gd
Created tooltip2_target
This commit is contained in:
@@ -38,9 +38,12 @@ export(EDITOR_GAME_DEBUG_DISPLAY) var editor_debug_mode = \
|
|||||||
# This should be a Control node and NOT a CanvasLayer (or any other type of) node.
|
# This should be a Control node and NOT a CanvasLayer (or any other type of) node.
|
||||||
export(NodePath) var ui_parent_control_node
|
export(NodePath) var ui_parent_control_node
|
||||||
|
|
||||||
# A reference to the node handling tooltips
|
# A reference to the node handling tooltip1
|
||||||
var tooltip_node: Object
|
var tooltip_node: Object
|
||||||
|
|
||||||
|
# A reference to the node handling tooltip2
|
||||||
|
var tooltip2_node: Object
|
||||||
|
|
||||||
# Boolean indicating whether the game scene is ready to accept inputs
|
# Boolean indicating whether the game scene is ready to accept inputs
|
||||||
# from the player. This enables using escoria.is_ready_for_inputs() in _input()
|
# from the player. This enables using escoria.is_ready_for_inputs() in _input()
|
||||||
# function of game.gd script.
|
# function of game.gd script.
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ var _current_mouse_pos = Vector2.ZERO
|
|||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
$tooltip_layer/tooltip.connect("tooltip_size_updated", self, "update_tooltip_following_mouse_position")
|
$tooltip_layer/tooltip.connect("tooltip_size_updated", self, "update_tooltip_following_mouse_position")
|
||||||
|
$tooltip_layer/tooltip.connect("tooltip2_size_updated", self, "update_tooltip2_following_mouse_position")
|
||||||
|
|
||||||
|
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
@@ -110,6 +111,7 @@ func _input(event: InputEvent) -> void:
|
|||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
_current_mouse_pos = get_global_mouse_position()
|
_current_mouse_pos = get_global_mouse_position()
|
||||||
update_tooltip_following_mouse_position()
|
update_tooltip_following_mouse_position()
|
||||||
|
update_tooltip2_following_mouse_position()
|
||||||
|
|
||||||
|
|
||||||
# https://github.com/godotengine/godot-demo-projects/blob/3.4-585455e/misc/joypads/joypads.gd
|
# https://github.com/godotengine/godot-demo-projects/blob/3.4-585455e/misc/joypads/joypads.gd
|
||||||
@@ -215,13 +217,9 @@ func left_double_click_on_bg(position: Vector2) -> void:
|
|||||||
## ITEM/HOTSPOT FOCUS ##
|
## ITEM/HOTSPOT FOCUS ##
|
||||||
|
|
||||||
func element_focused(element_id: String) -> void:
|
func element_focused(element_id: String) -> void:
|
||||||
escoria.logger.info(
|
|
||||||
self,
|
|
||||||
"monkey"
|
|
||||||
)
|
|
||||||
|
|
||||||
var target_obj = escoria.object_manager.get_object(element_id).node
|
var target_obj = escoria.object_manager.get_object(element_id).node
|
||||||
$tooltip_layer/tooltip.set_target(target_obj.tooltip_name + " " + target_obj.tooltip2_name)
|
$tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
|
||||||
|
$tooltip_layer/tooltip2.set_target(target_obj.tooltip2_name)
|
||||||
|
|
||||||
if escoria.action_manager.current_action != VERB_USE \
|
if escoria.action_manager.current_action != VERB_USE \
|
||||||
and escoria.action_manager.current_tool == null \
|
and escoria.action_manager.current_tool == null \
|
||||||
@@ -377,7 +375,7 @@ func get_custom_data() -> Dictionary:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Update the tooltip
|
# Update the tooltip1
|
||||||
func update_tooltip_following_mouse_position():
|
func update_tooltip_following_mouse_position():
|
||||||
var corrected_position = _current_mouse_pos \
|
var corrected_position = _current_mouse_pos \
|
||||||
- Vector2(
|
- Vector2(
|
||||||
@@ -403,6 +401,32 @@ func update_tooltip_following_mouse_position():
|
|||||||
|
|
||||||
tooltip_node.rect_position = corrected_position + tooltip_node.offset_from_cursor
|
tooltip_node.rect_position = corrected_position + tooltip_node.offset_from_cursor
|
||||||
|
|
||||||
|
# Update the tooltip2
|
||||||
|
func update_tooltip2_following_mouse_position():
|
||||||
|
var corrected_position = _current_mouse_pos \
|
||||||
|
- Vector2(
|
||||||
|
tooltip2_node.rect_size.x / 2,
|
||||||
|
tooltip2_node.rect_size.y / 2
|
||||||
|
)
|
||||||
|
|
||||||
|
# clamp TOP
|
||||||
|
if tooltip2_node.tooltip_distance_to_edge_top(_current_mouse_pos) <= mouse_tooltip_margin:
|
||||||
|
corrected_position.y = mouse_tooltip_margin
|
||||||
|
|
||||||
|
# clamp BOTTOM
|
||||||
|
if tooltip2_node.tooltip_distance_to_edge_bottom(_current_mouse_pos + tooltip2_node.rect_size) <= mouse_tooltip_margin:
|
||||||
|
corrected_position.y = escoria.game_size.y - mouse_tooltip_margin - tooltip2_node.rect_size.y
|
||||||
|
|
||||||
|
# clamp LEFT
|
||||||
|
if tooltip2_node.tooltip_distance_to_edge_left(_current_mouse_pos - tooltip2_node.rect_size/2) <= mouse_tooltip_margin:
|
||||||
|
corrected_position.x = mouse_tooltip_margin
|
||||||
|
|
||||||
|
# clamp RIGHT
|
||||||
|
if tooltip2_node.tooltip_distance_to_edge_right(_current_mouse_pos + tooltip2_node.rect_size/2) <= mouse_tooltip_margin:
|
||||||
|
corrected_position.x = escoria.game_size.x - mouse_tooltip_margin - tooltip2_node.rect_size.x
|
||||||
|
|
||||||
|
tooltip2_node.rect_position = corrected_position + tooltip2_node.offset_from_cursor
|
||||||
|
|
||||||
|
|
||||||
func _on_action_finished():
|
func _on_action_finished():
|
||||||
$mouse_layer/verbs_menu.clear_tool_texture()
|
$mouse_layer/verbs_menu.clear_tool_texture()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
[ext_resource path="res://addons/escoria-core/ui_library/menus/main_menu/main_menu.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://addons/escoria-core/ui_library/menus/main_menu/main_menu.tscn" type="PackedScene" id=7]
|
||||||
[ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.tscn" type="PackedScene" id=8]
|
[ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.tscn" type="PackedScene" id=8]
|
||||||
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/theme.tres" type="Theme" id=9]
|
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/theme.tres" type="Theme" id=9]
|
||||||
|
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/tooltip/target_tooltip2.tscn" type="PackedScene" id=10]
|
||||||
|
|
||||||
[node name="game" type="Node2D"]
|
[node name="game" type="Node2D"]
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
@@ -85,6 +86,12 @@ theme = ExtResource( 9 )
|
|||||||
bbcode_text = "[center][color=#000000][/color][/center]"
|
bbcode_text = "[center][color=#000000][/color][/center]"
|
||||||
fit_content_height = true
|
fit_content_height = true
|
||||||
|
|
||||||
|
[node name="tooltip2" parent="tooltip_layer" instance=ExtResource( 10 )]
|
||||||
|
mouse_filter = 2
|
||||||
|
theme = ExtResource( 9 )
|
||||||
|
bbcode_text = "[center][color=#000000][/color][/center]"
|
||||||
|
fit_content_height = true
|
||||||
|
|
||||||
[node name="mouse_layer" type="CanvasLayer" parent="."]
|
[node name="mouse_layer" type="CanvasLayer" parent="."]
|
||||||
layer = 2
|
layer = 2
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ bbcode_text = "[center][color=#ffffff][/color][/center]"
|
|||||||
scroll_active = false
|
scroll_active = false
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
color = Color( 1, 1, 1, 1 )
|
color = Color( 1, 1, 1, 1 )
|
||||||
offset_from_cursor = Vector2( 0, 0 )
|
offset_from_cursor = Vector2( 0, -50 )
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/tooltip/tooltip2_target.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="tooltip" type="RichTextLabel"]
|
||||||
|
bbcode_enabled = true
|
||||||
|
bbcode_text = "[center][color=#ffffff][/color][/center]"
|
||||||
|
scroll_active = false
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
color = Color( 1, 1, 1, 1 )
|
||||||
|
offset_from_cursor = Vector2( 0, 50 )
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
extends ESCTooltip
|
||||||
|
|
||||||
|
var id: int
|
||||||
|
|
||||||
|
func _init(tooltip_id = 0):
|
||||||
|
id = tooltip_id
|
||||||
|
|
||||||
|
signal tooltip2_size_updated
|
||||||
|
|
||||||
|
|
||||||
|
func update_tooltip_text():
|
||||||
|
# Need to update size of bbcode rect before updating the text itself otherwise on the
|
||||||
|
# first frame the text is wider than the default of 0 and ends up being really tall
|
||||||
|
# and setting the wrong vertical margin for the tooltip
|
||||||
|
update_size()
|
||||||
|
|
||||||
|
# We signal this here since the processing in this class happens AFTER input
|
||||||
|
# processing. We signal here to avoid "lagging" behind a frame since
|
||||||
|
# tooltips are presently dependent on the size of the bounding box around
|
||||||
|
# the rendered string.
|
||||||
|
emit_signal("tooltip2_size_updated")
|
||||||
|
|
||||||
|
bbcode_text = "[center]"
|
||||||
|
bbcode_text += "[color=#" + color.to_html(false) + "]"
|
||||||
|
bbcode_text += current_target
|
||||||
|
bbcode_text += "[/color]"
|
||||||
|
bbcode_text += "[/center]"
|
||||||
|
# push_align(RichTextLabel.ALIGN_CENTER)
|
||||||
|
# push_color(color)
|
||||||
|
# append_bbcode(current_target)
|
||||||
|
# pop()
|
||||||
|
# pop()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_room_ready():
|
||||||
|
escoria.logger.warn(
|
||||||
|
self,
|
||||||
|
"ON ROOM READY TOOLTIP2 id=" + String(id)
|
||||||
|
)
|
||||||
|
escoria.main.current_scene.game.tooltip2_node = self
|
||||||
|
_room_is_ready = true
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
extends ESCTooltip
|
extends ESCTooltip
|
||||||
|
|
||||||
|
var id: int
|
||||||
|
|
||||||
|
func _init(tooltip_id = 0):
|
||||||
|
id = tooltip_id
|
||||||
|
|
||||||
signal tooltip_size_updated
|
signal tooltip_size_updated
|
||||||
|
|
||||||
@@ -26,3 +30,12 @@ func update_tooltip_text():
|
|||||||
# append_bbcode(current_target)
|
# append_bbcode(current_target)
|
||||||
# pop()
|
# pop()
|
||||||
# pop()
|
# pop()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_room_ready():
|
||||||
|
escoria.logger.warn(
|
||||||
|
self,
|
||||||
|
"ON ROOM READY id=" + String(id)
|
||||||
|
)
|
||||||
|
escoria.main.current_scene.game.tooltip_node = self
|
||||||
|
_room_is_ready = true
|
||||||
|
|||||||
@@ -870,7 +870,7 @@ main/game_migration_path=""
|
|||||||
debug/terminate_on_warnings=false
|
debug/terminate_on_warnings=false
|
||||||
debug/terminate_on_errors=true
|
debug/terminate_on_errors=true
|
||||||
debug/development_lang="en"
|
debug/development_lang="en"
|
||||||
debug/log_level="TRACE"
|
debug/log_level="WARNING"
|
||||||
debug/log_file_path="user://"
|
debug/log_file_path="user://"
|
||||||
debug/crash_message="We're sorry, but the game crashed. Please send us the following files:
|
debug/crash_message="We're sorry, but the game crashed. Please send us the following files:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user