Moved UI scenes and resources to their own plugin.
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
|
||||
}
|
||||