Implemented tooltip follows mouse (not perfect).
Fixed bug when using mousewheel action on inventory items. Added a debug mode for tooltip following mouse
This commit is contained in:
@@ -31,9 +31,6 @@ Implement methods to react to inputs.
|
||||
- _on_event_done(event_name: String)
|
||||
"""
|
||||
|
||||
func _ready():
|
||||
escoria.esc_runner.connect("event_done", self, "_on_event_done")
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("switch_action_verb"):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=9 format=2]
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://game/ui/ui_9verbs/tooltip/action_target_tooltip.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://game/ui/ui_9verbs/inventory/inventory_ui.tscn" type="PackedScene" id=2]
|
||||
@@ -7,6 +7,7 @@
|
||||
[ext_resource path="res://game/ui/ui_9verbs/game.gd" type="Script" id=5]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://game/ui/commons/room_select.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://game/ui/ui_9verbs/tooltip/tooltip_action_target.gd" type="Script" id=8]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.6, 0.6, 0.6, 0.5 )
|
||||
@@ -54,14 +55,15 @@ margin_bottom = 615.331
|
||||
layer = 2
|
||||
|
||||
[node name="tooltip" parent="ui/tooltip_layer" instance=ExtResource( 1 )]
|
||||
anchor_left = 0.208
|
||||
anchor_top = 0.722
|
||||
anchor_right = 0.734
|
||||
anchor_bottom = 0.77
|
||||
margin_left = 0.383453
|
||||
margin_top = 0.364075
|
||||
margin_right = 0.103394
|
||||
margin_bottom = -0.0359497
|
||||
anchor_left = 0.132
|
||||
anchor_top = 0.719
|
||||
anchor_right = 0.832
|
||||
anchor_bottom = 0.767
|
||||
margin_left = 0.0272522
|
||||
margin_top = 0.320557
|
||||
margin_right = -0.252686
|
||||
margin_bottom = -0.0794678
|
||||
script = ExtResource( 8 )
|
||||
|
||||
[node name="dialog_layer" type="CanvasLayer" parent="ui"]
|
||||
layer = 3
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
extends RichTextLabel
|
||||
|
||||
# Infinitive verb
|
||||
var current_action : String
|
||||
# Target item/hotspot
|
||||
var current_target : String
|
||||
# Preposition: on, with...
|
||||
var current_prep : String = "with"
|
||||
# Target 2 item/hotspot
|
||||
var current_target2 : String
|
||||
|
||||
var waiting_for_target2 = false
|
||||
|
||||
func _ready():
|
||||
escoria.esc_runner.connect("action_changed", self, "on_action_selected")
|
||||
|
||||
|
||||
func on_action_selected() -> void:
|
||||
current_action = escoria.esc_runner.current_action
|
||||
update_tooltip_text()
|
||||
|
||||
|
||||
func set_target(target : String, needs_second_target : bool = false) -> void:
|
||||
current_target = target
|
||||
if needs_second_target:
|
||||
waiting_for_target2 = true
|
||||
|
||||
update_tooltip_text()
|
||||
|
||||
|
||||
func set_target2(target2 : String) -> void:
|
||||
current_target2 = target2
|
||||
update_tooltip_text()
|
||||
|
||||
|
||||
func update_tooltip_text():
|
||||
bbcode_text = "[center]"
|
||||
|
||||
if !current_action.empty():
|
||||
bbcode_text += current_action
|
||||
bbcode_text += "\t"
|
||||
|
||||
bbcode_text += current_target
|
||||
|
||||
if waiting_for_target2 and current_target2.empty():
|
||||
bbcode_text += "\t"
|
||||
bbcode_text += current_prep
|
||||
|
||||
if !current_target2.empty():
|
||||
bbcode_text += "\t"
|
||||
bbcode_text += current_prep
|
||||
bbcode_text += "\t"
|
||||
bbcode_text += current_target2
|
||||
|
||||
bbcode_text += "[/center]"
|
||||
@@ -1,7 +1,6 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/assets/fonts/onesize/ONESIZE_.TTF" type="DynamicFontData" id=1]
|
||||
[ext_resource path="res://game/ui/ui_9verbs/tooltip/action_target_tooltip.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 30
|
||||
@@ -11,16 +10,44 @@ font_data = ExtResource( 1 )
|
||||
size = 30
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="GDScript" id=3]
|
||||
script/source = "extends ESCTooltip
|
||||
|
||||
|
||||
func update_tooltip_text():
|
||||
bbcode_text = \"[center]\"
|
||||
|
||||
if !current_action.empty():
|
||||
bbcode_text += current_action
|
||||
bbcode_text += \"\\t\"
|
||||
|
||||
bbcode_text += current_target
|
||||
|
||||
if waiting_for_target2 and current_target2.empty():
|
||||
bbcode_text += \"\\t\"
|
||||
bbcode_text += current_prep
|
||||
|
||||
if !current_target2.empty():
|
||||
bbcode_text += \"\\t\"
|
||||
bbcode_text += current_prep
|
||||
bbcode_text += \"\\t\"
|
||||
bbcode_text += current_target2
|
||||
|
||||
bbcode_text += \"[/center]\"
|
||||
"
|
||||
|
||||
[node name="tooltip" type="RichTextLabel"]
|
||||
anchor_right = 0.526
|
||||
anchor_right = 0.7
|
||||
anchor_bottom = 0.06
|
||||
margin_right = -0.280029
|
||||
margin_left = 1.49829
|
||||
margin_right = 1.21826
|
||||
margin_bottom = -10.0
|
||||
custom_fonts/mono_font = SubResource( 1 )
|
||||
custom_fonts/normal_font = SubResource( 2 )
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "[center][/center]"
|
||||
scroll_active = false
|
||||
script = ExtResource( 2 )
|
||||
script = SubResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
17
game/ui/ui_9verbs/tooltip/tooltip_action_target.gd
Normal file
17
game/ui/ui_9verbs/tooltip/tooltip_action_target.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
extends ESCTooltip
|
||||
|
||||
func update_tooltip_text():
|
||||
push_align(RichTextLabel.ALIGN_CENTER)
|
||||
|
||||
if !current_action.empty():
|
||||
add_text(current_action + "\t")
|
||||
|
||||
add_text(current_target)
|
||||
|
||||
if waiting_for_target2 and current_target2.empty():
|
||||
add_text("\t" + current_prep)
|
||||
|
||||
if !current_target2.empty():
|
||||
add_text("\t" + current_prep + "\t" + current_target2)
|
||||
|
||||
pop()
|
||||
@@ -11,17 +11,15 @@ Implement methods to react to inputs.
|
||||
- element_focused(element_id : String)
|
||||
- element_unfocused()
|
||||
|
||||
- left_click_on_hotspot(hotspot_global_id : String, event : InputEvent)
|
||||
- right_click_on_hotspot(hotspot_global_id : String, event : InputEvent)
|
||||
- left_double_click_on_hotspot(hotspot_global_id : String, event : InputEvent)
|
||||
|
||||
- left_click_on_item(item_global_id : String, event : InputEvent)
|
||||
- right_click_on_item(item_global_id : String, event : InputEvent)
|
||||
- left_double_click_on_item(item_global_id : String, event : InputEvent)
|
||||
|
||||
- inventory_item_focused(inventory_item_global_id : String) -> void
|
||||
- inventory_item_unfocused() -> void
|
||||
|
||||
- left_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent)
|
||||
- right_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent)
|
||||
- left_double_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent)
|
||||
- inventory_item_focused(inventory_item_global_id : String)
|
||||
- inventory_item_unfocused()
|
||||
- open_inventory()
|
||||
- close_inventory()
|
||||
|
||||
@@ -31,7 +29,6 @@ Implement methods to react to inputs.
|
||||
- show_ui()
|
||||
|
||||
- _on_event_done(event_name: String)
|
||||
- update_tooltip_position(p_position : Vector2)
|
||||
|
||||
"""
|
||||
|
||||
@@ -40,27 +37,32 @@ Implement methods to react to inputs.
|
||||
func left_click_on_bg(position : Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
$ui/verbs_layer/verbs_menu.set_by_name("walk")
|
||||
$ui/verbs_layer/verbs_menu.clear_tool_texture()
|
||||
|
||||
func right_click_on_bg(position : Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
$ui/verbs_layer/verbs_menu.set_by_name("walk")
|
||||
$ui/verbs_layer/verbs_menu.clear_tool_texture()
|
||||
|
||||
func left_double_click_on_bg(position : Vector2) -> void:
|
||||
escoria.do("walk", ["player", position, true])
|
||||
$ui/verbs_layer/verbs_menu.set_by_name("walk")
|
||||
$ui/verbs_layer/verbs_menu.clear_tool_texture()
|
||||
|
||||
## ITEM/HOTSPOT FOCUS ##
|
||||
|
||||
func element_focused(element_id : String) -> void:
|
||||
var target_obj = escoria.esc_runner.get_object(element_id)
|
||||
$ui/tooltip_layer/tooltip.text = target_obj.tooltip_name
|
||||
|
||||
$ui/tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
|
||||
$ui/tooltip_layer/tooltip.show()
|
||||
|
||||
if escoria.esc_runner.current_action != "use" && escoria.esc_runner.current_tool == null:
|
||||
if target_obj is ESCItem:
|
||||
$ui/verbs_layer/verbs_menu.set_by_name(target_obj.default_action)
|
||||
|
||||
func element_unfocused() -> void:
|
||||
$ui/tooltip_layer/tooltip.text = ""
|
||||
$ui/tooltip_layer/tooltip.set_target("")
|
||||
$ui/tooltip_layer/tooltip.hide()
|
||||
|
||||
|
||||
## ITEMS ##
|
||||
@@ -80,8 +82,8 @@ func left_click_on_inventory_item(inventory_item_global_id : String, event : Inp
|
||||
escoria.do("item_left_click", [inventory_item_global_id, event])
|
||||
if escoria.esc_runner.current_action == "use":
|
||||
var item = escoria.esc_runner.get_object(inventory_item_global_id)
|
||||
if item.texture:
|
||||
$ui/verbs_layer/verbs_menu.set_tool_texture(item.texture)
|
||||
if item.get_node("sprite").texture:
|
||||
$ui/verbs_layer/verbs_menu.set_tool_texture(item.get_node("sprite").texture)
|
||||
elif item.inventory_item_scene_file.instance().texture_normal:
|
||||
$ui/verbs_layer/verbs_menu.set_tool_texture(item.inventory_item_scene_file.instance().texture_normal)
|
||||
|
||||
@@ -117,8 +119,4 @@ func show_ui():
|
||||
|
||||
func _on_event_done(event_name: String):
|
||||
escoria.esc_runner.clear_current_action()
|
||||
|
||||
|
||||
func update_tooltip_position(p_position : Vector2):
|
||||
# + Vector2(-200,-50)
|
||||
$ui/tooltip_layer/tooltip.global_position = p_position
|
||||
$ui/verbs_layer/verbs_menu.clear_tool_texture()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/inventory/inventory_ui.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/dialog_player.tscn" type="PackedScene" id=2]
|
||||
@@ -6,9 +6,11 @@
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/verbs_mouseicons.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/game.gd" type="Script" id=5]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/tooltip/target_tooltip.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://game/ui/commons/room_select.tscn" type="PackedScene" id=7]
|
||||
|
||||
[node name="game" type="Node2D"]
|
||||
script = ExtResource( 5 )
|
||||
editor_debug_mode = 1
|
||||
|
||||
[node name="ui" type="CanvasLayer" parent="."]
|
||||
|
||||
@@ -35,10 +37,20 @@ layer = 2
|
||||
|
||||
[node name="tooltip" parent="ui/tooltip_layer" instance=ExtResource( 6 )]
|
||||
mouse_filter = 2
|
||||
bbcode_text = "[center][color=#000000][/color][/center]"
|
||||
color = Color( 0, 0, 0, 1 )
|
||||
offset_from_cursor = Vector2( 75, 10 )
|
||||
debug_mode = true
|
||||
|
||||
[node name="dialog_layer" type="CanvasLayer" parent="ui"]
|
||||
layer = 3
|
||||
|
||||
[node name="dialog_player" parent="ui/dialog_layer" instance=ExtResource( 2 )]
|
||||
|
||||
[node name="room_select" parent="ui" instance=ExtResource( 7 )]
|
||||
margin_left = 75.5099
|
||||
margin_top = 751.323
|
||||
margin_right = 138.51
|
||||
margin_bottom = 791.324
|
||||
|
||||
[node name="camera" parent="." instance=ExtResource( 3 )]
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
extends RichTextLabel
|
||||
|
||||
var current_target : String
|
||||
|
||||
func set_target(target : String) -> void:
|
||||
current_target = target
|
||||
update_tooltip_text()
|
||||
|
||||
func update_tooltip_text():
|
||||
bbcode_text = current_target
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/assets/fonts/onesize/ONESIZE_.TTF" type="DynamicFontData" id=1]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/tooltip/target_tooltip.gd" type="Script" id=2]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/tooltip/tooltip_target.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 30
|
||||
@@ -12,17 +12,17 @@ size = 30
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[node name="tooltip" type="RichTextLabel"]
|
||||
anchor_right = 0.7
|
||||
anchor_bottom = 0.06
|
||||
margin_left = 1.49829
|
||||
margin_right = 1.21826
|
||||
margin_bottom = -10.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 32.0
|
||||
rect_min_size = Vector2( 200, 32 )
|
||||
custom_fonts/mono_font = SubResource( 1 )
|
||||
custom_fonts/normal_font = SubResource( 2 )
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "[center][/center]"
|
||||
bbcode_text = "[center][color=#ffffff][/color][/center]"
|
||||
scroll_active = false
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
color = Color( 1, 1, 1, 1 )
|
||||
offset_from_cursor = Vector2( 100, 10 )
|
||||
|
||||
16
game/ui/ui_mouse_icons/tooltip/tooltip_target.gd
Normal file
16
game/ui/ui_mouse_icons/tooltip/tooltip_target.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
tool
|
||||
extends ESCTooltip
|
||||
|
||||
func update_tooltip_text():
|
||||
print("new color " + str(color))
|
||||
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()
|
||||
update_size()
|
||||
Reference in New Issue
Block a user