Created ESCGame class to force game.tscn scene to have empty functions by inheritance.
Also continued some tests about tooltip following mouse. Fixed project settings wrongly set.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
extends Node
|
||||
tool
|
||||
extends ESCGame
|
||||
|
||||
"""
|
||||
Implement methods to react to inputs.
|
||||
@@ -17,43 +18,49 @@ Implement methods to react to inputs.
|
||||
- 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
|
||||
|
||||
- open_inventory()
|
||||
- close_inventory()
|
||||
|
||||
- mousewheel_action(direction : int)
|
||||
|
||||
- hide_ui()
|
||||
- show_ui()
|
||||
|
||||
- _on_event_done(event_name: String)
|
||||
- update_tooltip_position(p_position : Vector2)
|
||||
|
||||
"""
|
||||
|
||||
signal element_focused(element_global_id)
|
||||
|
||||
|
||||
#func _input(event):
|
||||
# if event.is_action_pressed("switch_action_verb"):
|
||||
# if event.button_index == BUTTON_WHEEL_UP:
|
||||
# $ui/verbs_layer/verbs_menu.iterate_actions_cursor(-1)
|
||||
# elif event.button_index == BUTTON_WHEEL_DOWN:
|
||||
# $ui/verbs_layer/verbs_menu.iterate_actions_cursor(1)
|
||||
|
||||
## BACKGROUND ##
|
||||
|
||||
func left_click_on_bg(position : Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
$ui/verbs_layer/verbs_menu.set_by_name("walk")
|
||||
|
||||
func right_click_on_bg(position : Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
$ui/verbs_layer/verbs_menu.set_by_name("walk")
|
||||
|
||||
func left_double_click_on_bg(position : Vector2) -> void:
|
||||
escoria.do("walk", ["player", position, true])
|
||||
|
||||
$ui/verbs_layer/verbs_menu.set_by_name("walk")
|
||||
|
||||
## ITEM/HOTSPOT FOCUS ##
|
||||
|
||||
func element_focused(element_id : String) -> void:
|
||||
#emit_signal("element_focused", element_id)
|
||||
var target_obj = escoria.esc_runner.get_object(element_id)
|
||||
$ui/tooltip_layer/tooltip.text = target_obj.tooltip_name
|
||||
|
||||
if escoria.esc_runner.current_action != "use" && escoria.esc_runner.current_tool == null:
|
||||
if target_obj is ESCItem or target_obj is ESCHotspot:
|
||||
if target_obj is ESCItem:
|
||||
$ui/verbs_layer/verbs_menu.set_by_name(target_obj.default_action)
|
||||
|
||||
func element_unfocused() -> void:
|
||||
#emit_signal("element_focused", "")
|
||||
#$ui/verbs_layer/verbs_menu.set_by_name("walk")
|
||||
pass
|
||||
$ui/tooltip_layer/tooltip.text = ""
|
||||
|
||||
|
||||
## ITEMS ##
|
||||
@@ -86,10 +93,10 @@ func left_double_click_on_inventory_item(inventory_item_global_id : String, even
|
||||
pass
|
||||
|
||||
func inventory_item_focused(inventory_item_global_id : String) -> void:
|
||||
emit_signal("element_focused", inventory_item_global_id)
|
||||
$ui/tooltip_layer/tooltip.set_target(escoria.esc_runner.get_object(inventory_item_global_id).tooltip_name)
|
||||
|
||||
func inventory_item_unfocused() -> void:
|
||||
emit_signal("element_focused", "")
|
||||
$ui/tooltip_layer/tooltip.set_target("")
|
||||
|
||||
|
||||
func open_inventory():
|
||||
@@ -101,3 +108,17 @@ func close_inventory():
|
||||
|
||||
func mousewheel_action(direction : int):
|
||||
$ui/verbs_layer/verbs_menu.iterate_actions_cursor(direction)
|
||||
|
||||
func hide_ui():
|
||||
$ui/inventory_layer/inventory_ui.hide()
|
||||
|
||||
func show_ui():
|
||||
$ui/inventory_layer/inventory_ui.show()
|
||||
|
||||
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
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=7 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]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=3]
|
||||
[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]
|
||||
|
||||
[node name="game" type="Node"]
|
||||
[node name="game" type="Node2D"]
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="ui" type="CanvasLayer" parent="."]
|
||||
@@ -32,6 +33,9 @@ margin_bottom = -583.507
|
||||
[node name="tooltip_layer" type="CanvasLayer" parent="ui"]
|
||||
layer = 2
|
||||
|
||||
[node name="tooltip" parent="ui/tooltip_layer" instance=ExtResource( 6 )]
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="dialog_layer" type="CanvasLayer" parent="ui"]
|
||||
layer = 3
|
||||
|
||||
|
||||
10
game/ui/ui_mouse_icons/tooltip/target_tooltip.gd
Normal file
10
game/ui/ui_mouse_icons/tooltip/target_tooltip.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
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
|
||||
28
game/ui/ui_mouse_icons/tooltip/target_tooltip.tscn
Normal file
28
game/ui/ui_mouse_icons/tooltip/target_tooltip.tscn
Normal file
@@ -0,0 +1,28 @@
|
||||
[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]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 30
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
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
|
||||
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 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
@@ -53,6 +53,10 @@ margin_bottom = 132.0
|
||||
texture = ExtResource( 4 )
|
||||
|
||||
[node name="mouse_position" type="Control" parent="."]
|
||||
margin_left = 323.435
|
||||
margin_top = 57.9191
|
||||
margin_right = 323.435
|
||||
margin_bottom = 57.9191
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="tool" type="TextureRect" parent="mouse_position"]
|
||||
|
||||
Reference in New Issue
Block a user