Moved UI scenes and resources to their own plugin.
165
addons/escoria-ui-9verbs/game.gd
Normal file
@@ -0,0 +1,165 @@
|
||||
tool
|
||||
extends ESCGame
|
||||
|
||||
"""
|
||||
Implement methods to react to inputs.
|
||||
|
||||
- left_click_on_bg(position: Vector2)
|
||||
- right_click_on_bg(position: Vector2)
|
||||
- left_double_click_on_bg(position: Vector2)
|
||||
|
||||
- element_focused(element_id: String)
|
||||
- element_unfocused()
|
||||
|
||||
- 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)
|
||||
|
||||
- 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()
|
||||
|
||||
- mousewheel_action(direction: int)
|
||||
|
||||
- hide_ui()
|
||||
- show_ui()
|
||||
|
||||
- _on_event_done(event_name: String)
|
||||
"""
|
||||
|
||||
onready var verbs_menu = $ui/panel_down/verbs_layer/verbs_menu
|
||||
onready var tooltip = $ui/panel_down/tooltip_layer/tooltip
|
||||
|
||||
func _ready():
|
||||
ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", false)
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("switch_action_verb"):
|
||||
if event.button_index == BUTTON_WHEEL_UP:
|
||||
escoria.inputs_manager._on_mousewheel_action(-1)
|
||||
elif event.button_index == BUTTON_WHEEL_DOWN:
|
||||
escoria.inputs_manager._on_mousewheel_action(1)
|
||||
|
||||
|
||||
## BACKGROUND ##
|
||||
|
||||
func left_click_on_bg(position: Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
escoria.action_manager.clear_current_action()
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
func right_click_on_bg(position: Vector2) -> void:
|
||||
escoria.do("walk", ["player", position])
|
||||
escoria.action_manager.clear_current_action()
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
func left_double_click_on_bg(position: Vector2) -> void:
|
||||
escoria.do("walk", ["player", position, true])
|
||||
escoria.action_manager.clear_current_action()
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
|
||||
## ITEM FOCUS ##
|
||||
|
||||
func element_focused(element_id: String) -> void:
|
||||
var target_obj = escoria.object_manager.get_object(element_id).node
|
||||
tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
if escoria.action_manager.current_action != "use" \
|
||||
and escoria.action_manager.current_tool == null:
|
||||
if target_obj is ESCItem:
|
||||
verbs_menu.set_by_name(target_obj.default_action)
|
||||
|
||||
func element_unfocused() -> void:
|
||||
tooltip.clear()
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
## ITEMS ##
|
||||
|
||||
func left_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [item_global_id, event])
|
||||
|
||||
func right_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.action_manager.set_current_action(verbs_menu.selected_action)
|
||||
escoria.do("item_right_click", [item_global_id, event])
|
||||
|
||||
func left_double_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [item_global_id, event])
|
||||
|
||||
|
||||
## INVENTORY ##
|
||||
func left_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [inventory_item_global_id, event])
|
||||
|
||||
|
||||
func right_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.action_manager.set_current_action(verbs_menu.selected_action)
|
||||
escoria.do("item_right_click", [inventory_item_global_id, event])
|
||||
|
||||
func left_double_click_on_inventory_item(_inventory_item_global_id: String, _event: InputEvent) -> void:
|
||||
pass
|
||||
|
||||
func inventory_item_focused(inventory_item_global_id: String) -> void:
|
||||
var target_obj = escoria.object_manager.get_object(
|
||||
inventory_item_global_id
|
||||
).node
|
||||
tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
if escoria.action_manager.current_action != "use" \
|
||||
and escoria.action_manager.current_tool == null:
|
||||
if target_obj is ESCItem:
|
||||
verbs_menu.set_by_name(target_obj.default_action_inventory)
|
||||
|
||||
|
||||
func inventory_item_unfocused() -> void:
|
||||
tooltip.set_target("")
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
|
||||
func open_inventory():
|
||||
pass
|
||||
|
||||
|
||||
func close_inventory():
|
||||
pass
|
||||
|
||||
|
||||
func mousewheel_action(_direction: int):
|
||||
pass
|
||||
|
||||
|
||||
func hide_ui():
|
||||
$ui/panel_down.hide()
|
||||
verbs_menu.hide()
|
||||
$ui/panel_down/verbs_layer/room_select.hide()
|
||||
$ui/panel_down/inventory_layer/inventory_ui.hide()
|
||||
tooltip.hide()
|
||||
|
||||
|
||||
func show_ui():
|
||||
$ui/panel_down.show()
|
||||
verbs_menu.show()
|
||||
$ui/panel_down/verbs_layer/room_select.show()
|
||||
$ui/panel_down/inventory_layer/inventory_ui.show()
|
||||
tooltip.show()
|
||||
|
||||
func _on_event_done(_event_name: String):
|
||||
escoria.action_manager.clear_current_action()
|
||||
verbs_menu.unselect_actions()
|
||||
|
||||
|
||||
func pause_game():
|
||||
if $ui/pause_menu.visible:
|
||||
$ui/pause_menu.hide()
|
||||
escoria.main.current_scene.game.get_node("camera").current = true
|
||||
escoria.main.current_scene.game.show_ui()
|
||||
escoria.main.current_scene.show()
|
||||
else:
|
||||
$ui/pause_menu.show()
|
||||
escoria.main.current_scene.game.get_node("camera").current = false
|
||||
escoria.main.current_scene.game.hide_ui()
|
||||
escoria.main.current_scene.hide()
|
||||
94
addons/escoria-ui-9verbs/game.tscn
Normal file
@@ -0,0 +1,94 @@
|
||||
[gd_scene load_steps=11 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-ui-9verbs/tooltip/action_target_tooltip.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/escoria-ui-9verbs/inventory/inventory_ui.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/escoria-ui-9verbs/verbs_menu.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/dialog_player.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://addons/escoria-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://addons/escoria-ui-9verbs/tooltip/tooltip_action_target.gd" type="Script" id=8]
|
||||
[ext_resource path="res://game/ui/commons/pause_menu/pause_menu.tscn" type="PackedScene" id=9]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.6, 0.6, 0.6, 0.5 )
|
||||
|
||||
[node name="game" type="Node2D"]
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="ui" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="panel_down" type="PanelContainer" parent="ui"]
|
||||
anchor_top = 0.714
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -0.200012
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="verbs_layer" type="CanvasLayer" parent="ui/panel_down"]
|
||||
layer = 2
|
||||
|
||||
[node name="verbs_menu" parent="ui/panel_down/verbs_layer" instance=ExtResource( 3 )]
|
||||
anchor_top = 0.715
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 52.0
|
||||
margin_top = 38.5
|
||||
margin_right = -959.0
|
||||
margin_bottom = -63.0
|
||||
|
||||
[node name="room_select" parent="ui/panel_down/verbs_layer" instance=ExtResource( 7 )]
|
||||
margin_left = 503.504
|
||||
margin_top = 820.091
|
||||
margin_right = 686.504
|
||||
margin_bottom = 840.091
|
||||
|
||||
[node name="inventory_layer" type="CanvasLayer" parent="ui/panel_down"]
|
||||
layer = 2
|
||||
|
||||
[node name="inventory_ui" parent="ui/panel_down/inventory_layer" instance=ExtResource( 2 )]
|
||||
anchor_top = 0.722
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 752.0
|
||||
margin_top = 31.2
|
||||
margin_right = -63.0
|
||||
margin_bottom = -61.0
|
||||
|
||||
[node name="tooltip_layer" type="CanvasLayer" parent="ui/panel_down"]
|
||||
layer = 2
|
||||
|
||||
[node name="tooltip" parent="ui/panel_down/tooltip_layer" instance=ExtResource( 1 )]
|
||||
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
|
||||
rect_min_size = Vector2( 0, 32 )
|
||||
script = ExtResource( 8 )
|
||||
color = Color( 1, 1, 1, 1 )
|
||||
|
||||
[node name="dialog_layer" type="CanvasLayer" parent="ui"]
|
||||
layer = 3
|
||||
|
||||
[node name="dialog_player" parent="ui/dialog_layer" instance=ExtResource( 4 )]
|
||||
|
||||
[node name="hover_stack" type="Label" parent="ui"]
|
||||
margin_left = 1085.0
|
||||
margin_top = 2.81912
|
||||
margin_right = 1283.0
|
||||
margin_bottom = 107.819
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="pause_menu" parent="ui" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
|
||||
[node name="camera" parent="." instance=ExtResource( 6 )]
|
||||
27
addons/escoria-ui-9verbs/inventory/inventory_ui.tscn
Normal file
@@ -0,0 +1,27 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/inventory/inventory_ui.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/escoria-ui-9verbs/inventory/inventory_ui_container.gd" type="Script" id=3]
|
||||
|
||||
[node name="inventory_ui" type="PanelContainer"]
|
||||
margin_right = 600.0
|
||||
margin_bottom = 175.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
inventory_ui_container = NodePath("ScrollContainer/GridContainer")
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 593.0
|
||||
margin_bottom = 168.0
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="ScrollContainer"]
|
||||
margin_right = 586.0
|
||||
size_flags_horizontal = 3
|
||||
custom_constants/vseparation = 16
|
||||
custom_constants/hseparation = 16
|
||||
columns = 4
|
||||
script = ExtResource( 3 )
|
||||
39
addons/escoria-ui-9verbs/inventory/inventory_ui_container.gd
Normal file
@@ -0,0 +1,39 @@
|
||||
extends Control
|
||||
|
||||
"""
|
||||
This script is totally user-defined. It does exactly what the user wants the
|
||||
inventory to look like. It only requires 4 functions to be defined:
|
||||
- is_empty() -> bool
|
||||
- get_items() -> Array
|
||||
- add_item(inventory_item: ESCInventoryItem)
|
||||
- remove_item(inventory_item: ESCInventoryItem)
|
||||
The user is free to implement these methods the way s-he likes.
|
||||
"""
|
||||
|
||||
var current_nodes_in_container = {}
|
||||
|
||||
func is_empty() -> bool:
|
||||
return get_child_count() > 0
|
||||
|
||||
func get_items() -> Array:
|
||||
return current_nodes_in_container.keys()
|
||||
|
||||
func add_item(inventory_item: ESCInventoryItem):
|
||||
var center_container = CenterContainer.new()
|
||||
center_container.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
center_container.connect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
center_container.connect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||
# center_container.connect("gui_input", self, "_on_gui_input", [inventory_item])
|
||||
center_container.add_child(inventory_item)
|
||||
add_child(center_container)
|
||||
current_nodes_in_container[inventory_item] = center_container
|
||||
|
||||
func remove_item(inventory_item: ESCInventoryItem):
|
||||
var node_to_remove = current_nodes_in_container[inventory_item]
|
||||
current_nodes_in_container.erase(node_to_remove)
|
||||
node_to_remove.disconnect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
node_to_remove.disconnect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||
# node_to_remove.disconnect("pressed", self, "_on_gui_input")
|
||||
remove_child(node_to_remove)
|
||||
node_to_remove.queue_free()
|
||||
|
||||
7
addons/escoria-ui-9verbs/plugin.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Escoria 9 Verbs UI"
|
||||
description="Classical LucasArts style 9-verbs UI for the Escoria Framework"
|
||||
author="StraToN"
|
||||
version="1.0.0"
|
||||
script="plugin.gd"
|
||||
9
addons/escoria-ui-9verbs/plugin.gd
Normal file
@@ -0,0 +1,9 @@
|
||||
# Plugin script to initialize Escoria simple mouse UI
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
|
||||
# Setup Escoria
|
||||
func _enter_tree():
|
||||
ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", false)
|
||||
ProjectSettings.set_setting("escoria/ui/game_scene", "res://addons/escoria-ui-9verbs/game.tscn")
|
||||
53
addons/escoria-ui-9verbs/tooltip/action_target_tooltip.tscn
Normal file
@@ -0,0 +1,53 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/assets/fonts/onesize/ONESIZE_.TTF" type="DynamicFontData" id=1]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 30
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
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.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 = SubResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
31
addons/escoria-ui-9verbs/tooltip/tooltip_action_target.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
extends ESCTooltip
|
||||
|
||||
func update_tooltip_text():
|
||||
bbcode_text = "[center]"
|
||||
bbcode_text += "[color=#" + color.to_html(false) + "]"
|
||||
if !current_action.empty():
|
||||
bbcode_text += current_action + "\t"
|
||||
bbcode_text += current_target
|
||||
|
||||
if waiting_for_target2 and current_target2.empty():
|
||||
bbcode_text += "\t" + current_prep
|
||||
|
||||
if !current_target2.empty():
|
||||
bbcode_text += "\t" + current_prep + "\t" + current_target2
|
||||
|
||||
bbcode_text += "[/color]"
|
||||
bbcode_text += "[/center]"
|
||||
|
||||
# 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()
|
||||
31
addons/escoria-ui-9verbs/verbs_menu.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
"""
|
||||
This script is out of Escoria's scope. It controls the UI reaction to an
|
||||
UI event (eg right click) to change the cursor accordingly.
|
||||
"""
|
||||
|
||||
var selected_action
|
||||
|
||||
func _ready():
|
||||
for but in get_children():
|
||||
but.connect("pressed", self, "_on_action_selected", [but.name])
|
||||
but.toggle_mode = true
|
||||
|
||||
func _on_action_selected(action: String):
|
||||
escoria.action_manager.set_current_action(action)
|
||||
|
||||
for but in get_children():
|
||||
but.set_pressed(but.get_name() == action)
|
||||
|
||||
func unselect_actions():
|
||||
for but in get_children():
|
||||
but.set_pressed(false)
|
||||
|
||||
func set_by_name(action_name: String):
|
||||
selected_action = action_name
|
||||
for but in get_children():
|
||||
but.set_pressed(but.get_name() == action_name)
|
||||
|
||||
|
||||
125
addons/escoria-ui-9verbs/verbs_menu.tscn
Normal file
@@ -0,0 +1,125 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-ui-9verbs/verbs_menu.gd" type="Script" id=1]
|
||||
|
||||
[node name="actions" type="GridContainer"]
|
||||
margin_right = 493.0
|
||||
margin_bottom = 263.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
columns = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="open" type="Button" parent="."]
|
||||
margin_right = 161.0
|
||||
margin_bottom = 85.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
text = "Open"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="pickup" type="Button" parent="."]
|
||||
margin_left = 165.0
|
||||
margin_right = 326.0
|
||||
margin_bottom = 85.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
text = "Pick up"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="push" type="Button" parent="."]
|
||||
margin_left = 330.0
|
||||
margin_right = 491.0
|
||||
margin_bottom = 85.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
text = "Push"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="close" type="Button" parent="."]
|
||||
margin_top = 89.0
|
||||
margin_right = 161.0
|
||||
margin_bottom = 174.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
text = "Close"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="look" type="Button" parent="."]
|
||||
margin_left = 165.0
|
||||
margin_top = 89.0
|
||||
margin_right = 326.0
|
||||
margin_bottom = 174.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
text = "Look at"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="pull" type="Button" parent="."]
|
||||
margin_left = 330.0
|
||||
margin_top = 89.0
|
||||
margin_right = 491.0
|
||||
margin_bottom = 174.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
text = "Pull"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="give" type="Button" parent="."]
|
||||
margin_top = 178.0
|
||||
margin_right = 161.0
|
||||
margin_bottom = 263.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
text = "Give"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="use" type="Button" parent="."]
|
||||
margin_left = 165.0
|
||||
margin_top = 178.0
|
||||
margin_right = 326.0
|
||||
margin_bottom = 263.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
text = "Use"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="talk" type="Button" parent="."]
|
||||
margin_left = 330.0
|
||||
margin_top = 178.0
|
||||
margin_right = 491.0
|
||||
margin_bottom = 263.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
text = "Talk"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
BIN
addons/escoria-ui-simplemouse/cursors/cursor_examine.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_foot.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_glasses.png
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_gun.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_hand.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_heal.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_lock.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_pen.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_punch.png
Normal file
|
After Width: | Height: | Size: 53 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_shield.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_tool.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/cursor_wait.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 50 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/originals/cursor_foot.png
Normal file
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 51 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/originals/cursor_gun.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/originals/cursor_hand.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/originals/cursor_heal.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/originals/cursor_lock.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/originals/cursor_pen.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/originals/cursor_punch.png
Normal file
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 44 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/originals/cursor_tool.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
addons/escoria-ui-simplemouse/cursors/originals/cursor_wait.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
137
addons/escoria-ui-simplemouse/game.gd
Normal file
@@ -0,0 +1,137 @@
|
||||
tool
|
||||
extends ESCGame
|
||||
|
||||
"""
|
||||
Implement methods to react to inputs.
|
||||
|
||||
- left_click_on_bg(position: Vector2)
|
||||
- right_click_on_bg(position: Vector2)
|
||||
- left_double_click_on_bg(position: Vector2)
|
||||
|
||||
- element_focused(element_id: String)
|
||||
- element_unfocused()
|
||||
|
||||
- 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)
|
||||
|
||||
- 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()
|
||||
|
||||
- mousewheel_action(direction: int)
|
||||
|
||||
- hide_ui()
|
||||
- show_ui()
|
||||
|
||||
- _on_event_done(event_name: String)
|
||||
"""
|
||||
|
||||
func _ready():
|
||||
ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", true)
|
||||
|
||||
|
||||
## BACKGROUND ##
|
||||
|
||||
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.object_manager.get_object(element_id).node
|
||||
$ui/tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
if escoria.action_manager.current_action != "use" \
|
||||
and escoria.action_manager.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.set_target("")
|
||||
|
||||
|
||||
## ITEMS ##
|
||||
|
||||
func left_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [item_global_id, event])
|
||||
|
||||
func right_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_right_click", [item_global_id, event])
|
||||
|
||||
func left_double_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [item_global_id, event])
|
||||
|
||||
|
||||
## INVENTORY ##
|
||||
func left_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_left_click", [inventory_item_global_id, event])
|
||||
if escoria.action_manager.current_action == "use":
|
||||
var item = escoria.object_manager.get_object(
|
||||
inventory_item_global_id
|
||||
).node
|
||||
if item.get_node("sprite").texture:
|
||||
$ui/verbs_layer/verbs_menu.set_tool_texture(
|
||||
item.get_node("sprite").texture
|
||||
)
|
||||
elif item.inventory_item.texture_normal:
|
||||
$ui/verbs_layer/verbs_menu.set_tool_texture(
|
||||
item.inventory_item.texture_normal
|
||||
)
|
||||
|
||||
|
||||
func right_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
|
||||
escoria.do("item_right_click", [inventory_item_global_id, event])
|
||||
|
||||
|
||||
func left_double_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func inventory_item_focused(inventory_item_global_id: String) -> void:
|
||||
$ui/tooltip_layer/tooltip.set_target(
|
||||
escoria.object_manager.get_object(
|
||||
inventory_item_global_id
|
||||
).node.tooltip_name
|
||||
)
|
||||
|
||||
|
||||
func inventory_item_unfocused() -> void:
|
||||
$ui/tooltip_layer/tooltip.set_target("")
|
||||
|
||||
|
||||
func open_inventory():
|
||||
$ui/inventory_layer/inventory_ui/inventory_button.show_inventory()
|
||||
|
||||
|
||||
func close_inventory():
|
||||
$ui/inventory_layer/inventory_ui/inventory_button.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.action_manager.clear_current_action()
|
||||
$ui/verbs_layer/verbs_menu.clear_tool_texture()
|
||||
54
addons/escoria-ui-simplemouse/game.tscn
Normal file
@@ -0,0 +1,54 @@
|
||||
[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]
|
||||
[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]
|
||||
[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="."]
|
||||
|
||||
[node name="inventory_layer" type="CanvasLayer" parent="ui"]
|
||||
layer = 2
|
||||
|
||||
[node name="inventory_ui" parent="ui/inventory_layer" instance=ExtResource( 1 )]
|
||||
margin_left = 1173.73
|
||||
margin_top = 695.268
|
||||
margin_right = 394.205
|
||||
margin_bottom = 587.268
|
||||
|
||||
[node name="verbs_layer" type="CanvasLayer" parent="ui"]
|
||||
layer = 2
|
||||
|
||||
[node name="verbs_menu" parent="ui/verbs_layer" instance=ExtResource( 4 )]
|
||||
margin_left = 2234.6
|
||||
margin_top = -583.507
|
||||
margin_right = 2234.6
|
||||
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
|
||||
bbcode_text = "[center][color=#000000][/color][/center]"
|
||||
offset_from_cursor = Vector2( 75, 10 )
|
||||
|
||||
[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 )]
|
||||
BIN
addons/escoria-ui-simplemouse/images/frame.png
Executable file
|
After Width: | Height: | Size: 279 KiB |
BIN
addons/escoria-ui-simplemouse/images/inventory_bg.png
Executable file
|
After Width: | Height: | Size: 58 KiB |
BIN
addons/escoria-ui-simplemouse/images/inventory_icon.png
Executable file
|
After Width: | Height: | Size: 67 KiB |
@@ -0,0 +1,25 @@
|
||||
extends Control
|
||||
|
||||
var showed: bool = false
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
func _on_inventory_button_pressed():
|
||||
if !$AnimationPlayer.is_playing() and !showed:
|
||||
show_inventory()
|
||||
elif !$AnimationPlayer.is_playing() and showed:
|
||||
close_inventory()
|
||||
|
||||
|
||||
func show_inventory():
|
||||
$AnimationPlayer.play("show")
|
||||
yield($AnimationPlayer, "animation_finished")
|
||||
showed = true
|
||||
|
||||
|
||||
func close_inventory():
|
||||
$AnimationPlayer.play("hide")
|
||||
yield($AnimationPlayer, "animation_finished")
|
||||
showed = false
|
||||
168
addons/escoria-ui-simplemouse/inventory/inventory_ui.tscn
Normal file
@@ -0,0 +1,168 @@
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/inventory/inventory_ui.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/images/inventory_bg.png" type="Texture" id=2]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/inventory/inventory_ui_container.gd" type="Script" id=3]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/inventory/inventory_showhide.gd" type="Script" id=4]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/images/frame.png" type="Texture" id=5]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/images/inventory_icon.png" type="Texture" id=6]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "hide"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("../inventory_button:rect_position")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("../inventory_button/panel:rect_position")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0, 0.3 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( -1682.88, -52 ), Vector2( 268, -52 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "show"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("../inventory_button:rect_position")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("../inventory_button/panel:rect_position")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0, 0.3 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 268, -52 ), Vector2( -1682.88, -52 ) ]
|
||||
}
|
||||
|
||||
[node name="inventory_ui" type="Control"]
|
||||
anchor_right = 0.609
|
||||
anchor_bottom = 0.135
|
||||
margin_right = -779.52
|
||||
margin_bottom = -108.0
|
||||
rect_scale = Vector2( 0.4, 0.4 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
inventory_ui_container = NodePath("inventory_button/panel/MarginContainer/ScrollContainer/container")
|
||||
|
||||
[node name="inventory_button" type="TextureButton" parent="."]
|
||||
margin_right = 256.0
|
||||
margin_bottom = 322.0
|
||||
texture_normal = ExtResource( 6 )
|
||||
script = ExtResource( 4 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="frame" type="TextureRect" parent="inventory_button"]
|
||||
margin_right = 2643.0
|
||||
margin_bottom = 2630.0
|
||||
rect_scale = Vector2( 0.1, 0.1 )
|
||||
texture = ExtResource( 5 )
|
||||
stretch_mode = 1
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="panel" type="TextureRect" parent="inventory_button"]
|
||||
margin_left = 268.0
|
||||
margin_top = -52.0
|
||||
margin_right = 1957.0
|
||||
margin_bottom = 270.0
|
||||
grow_horizontal = 0
|
||||
rect_min_size = Vector2( 1689, 322 )
|
||||
texture = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="inventory_button/panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 57.0
|
||||
margin_top = 37.0
|
||||
margin_right = -68.0
|
||||
margin_bottom = -71.0
|
||||
custom_constants/margin_right = 20
|
||||
custom_constants/margin_top = 20
|
||||
custom_constants/margin_left = 20
|
||||
custom_constants/margin_bottom = 20
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="inventory_button/panel/MarginContainer"]
|
||||
margin_left = 20.0
|
||||
margin_top = 20.0
|
||||
margin_right = 1544.0
|
||||
margin_bottom = 194.0
|
||||
scroll_vertical_enabled = false
|
||||
|
||||
[node name="container" type="HBoxContainer" parent="inventory_button/panel/MarginContainer/ScrollContainer"]
|
||||
margin_right = 1524.0
|
||||
margin_bottom = 174.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_constants/separation = 20
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="inventory_button"]
|
||||
anims/hide = SubResource( 1 )
|
||||
anims/show = SubResource( 2 )
|
||||
|
||||
[connection signal="pressed" from="inventory_button" to="inventory_button" method="_on_inventory_button_pressed"]
|
||||
@@ -0,0 +1,37 @@
|
||||
extends Control
|
||||
|
||||
"""
|
||||
This script is totally user-defined. It does exactly what the user wants the
|
||||
inventory to look like. It only requires 4 functions to be defined:
|
||||
- is_empty() -> bool
|
||||
- get_items() -> Array
|
||||
- add_item(inventory_item: ESCInventoryItem)
|
||||
- remove_item(inventory_item: ESCInventoryItem)
|
||||
The user is free to implement these methods the way s-he likes.
|
||||
"""
|
||||
|
||||
var current_nodes_in_container = {}
|
||||
|
||||
func is_empty() -> bool:
|
||||
return get_child_count() > 0
|
||||
|
||||
func get_items() -> Array:
|
||||
return current_nodes_in_container.keys()
|
||||
|
||||
func add_item(inventory_item: ESCInventoryItem):
|
||||
var center_container = CenterContainer.new()
|
||||
center_container.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
center_container.connect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
center_container.connect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||
center_container.add_child(inventory_item)
|
||||
add_child(center_container)
|
||||
current_nodes_in_container[inventory_item] = center_container
|
||||
|
||||
func remove_item(inventory_item: ESCInventoryItem):
|
||||
var node_to_remove = current_nodes_in_container[inventory_item]
|
||||
current_nodes_in_container.erase(node_to_remove)
|
||||
node_to_remove.disconnect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||
node_to_remove.disconnect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||
remove_child(node_to_remove)
|
||||
node_to_remove.queue_free()
|
||||
|
||||
7
addons/escoria-ui-simplemouse/plugin.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Escoria Simple Mouse UI"
|
||||
description="Simple Mouse UI for the Escoria Framework"
|
||||
author="StraToN"
|
||||
version="1.0.0"
|
||||
script="plugin.gd"
|
||||
9
addons/escoria-ui-simplemouse/plugin.gd
Normal file
@@ -0,0 +1,9 @@
|
||||
# Plugin script to initialize Escoria simple mouse UI
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
|
||||
# Setup Escoria
|
||||
func _enter_tree():
|
||||
ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", true)
|
||||
ProjectSettings.set_setting("escoria/ui/game_scene", "res://addons/escoria-ui-simplemouse/game.tscn")
|
||||
28
addons/escoria-ui-simplemouse/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/tooltip_target.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"]
|
||||
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][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 )
|
||||
14
addons/escoria-ui-simplemouse/tooltip/tooltip_target.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
extends ESCTooltip
|
||||
|
||||
func update_tooltip_text():
|
||||
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()
|
||||
54
addons/escoria-ui-simplemouse/verbs_mouseicons.gd
Normal file
@@ -0,0 +1,54 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
|
||||
var current_cursor_id: int = 0
|
||||
onready var cursors: Array = $actions.get_children()
|
||||
|
||||
|
||||
"""
|
||||
This script is out of Escoria's scope. It controls the UI reaction to an
|
||||
UI event (eg right click) to change the cursor accordingly.
|
||||
"""
|
||||
enum UI_ACTIONS_DIRECTION {
|
||||
UP = 1,
|
||||
DOWN = -1
|
||||
}
|
||||
|
||||
func _ready():
|
||||
if !Engine.is_editor_hint():
|
||||
current_cursor_id = cursors.size()
|
||||
iterate_actions_cursor(UI_ACTIONS_DIRECTION.UP)
|
||||
|
||||
func _process(delta):
|
||||
$mouse_position.rect_global_position = get_global_mouse_position()
|
||||
|
||||
|
||||
func iterate_actions_cursor(direction: int):
|
||||
current_cursor_id += direction
|
||||
if current_cursor_id > cursors.size() - 1:
|
||||
current_cursor_id = 0
|
||||
elif current_cursor_id < 0:
|
||||
current_cursor_id = cursors.size() - 1
|
||||
|
||||
Input.set_custom_mouse_cursor(cursors[current_cursor_id].texture)
|
||||
escoria.action_manager.set_current_action(cursors[current_cursor_id].name)
|
||||
if $mouse_position/tool.texture != null:
|
||||
clear_tool_texture()
|
||||
|
||||
func set_by_name(name: String) -> void:
|
||||
for i in cursors.size():
|
||||
if cursors[i].name == name:
|
||||
current_cursor_id = i
|
||||
break
|
||||
|
||||
Input.set_custom_mouse_cursor(cursors[current_cursor_id].texture)
|
||||
escoria.action_manager.set_current_action(cursors[current_cursor_id].name)
|
||||
|
||||
func set_tool_texture(texture: Texture):
|
||||
set_process(true)
|
||||
$mouse_position/tool.texture = texture
|
||||
|
||||
func clear_tool_texture():
|
||||
$mouse_position/tool.texture = null
|
||||
set_process(false)
|
||||
70
addons/escoria-ui-simplemouse/verbs_mouseicons.tscn
Normal file
@@ -0,0 +1,70 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/verbs_mouseicons.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/cursors/cursor_examine.png" type="Texture" id=2]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/cursors/cursor_tool.png" type="Texture" id=3]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/cursors/cursor_pen.png" type="Texture" id=4]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/cursors/cursor_foot.png" type="Texture" id=5]
|
||||
[ext_resource path="res://game/ui/ui_mouse_icons/cursors/cursor_hand.png" type="Texture" id=6]
|
||||
|
||||
[node name="verbs_menu" type="Control"]
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="actions" type="GridContainer" parent="."]
|
||||
visible = false
|
||||
margin_right = 333.0
|
||||
margin_bottom = 175.0
|
||||
columns = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="walk" type="TextureRect" parent="actions"]
|
||||
margin_right = 64.0
|
||||
margin_bottom = 64.0
|
||||
texture = ExtResource( 5 )
|
||||
|
||||
[node name="look" type="TextureRect" parent="actions"]
|
||||
margin_left = 68.0
|
||||
margin_right = 132.0
|
||||
margin_bottom = 64.0
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="pickup" type="TextureRect" parent="actions"]
|
||||
margin_left = 136.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 64.0
|
||||
texture = ExtResource( 6 )
|
||||
|
||||
[node name="use" type="TextureRect" parent="actions"]
|
||||
margin_top = 68.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 132.0
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="talk" type="TextureRect" parent="actions"]
|
||||
margin_left = 68.0
|
||||
margin_top = 68.0
|
||||
margin_right = 132.0
|
||||
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"]
|
||||
margin_left = 46.4475
|
||||
margin_top = 45.6984
|
||||
margin_right = 86.4475
|
||||
margin_bottom = 85.6984
|
||||
mouse_filter = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||