feat: introduce escoria-ui-keyboard-9verbs to verify register_custom_input_handler() API

This commit was started by copying `addons/escoria-ui-9verbs` as the
basis for `addons/escoria-ui-keyboard-9verbs`. It was then amended to
wire up keyboard shortcuts for each verb using the new
`register_custom_input_handler()` API.

Note that `addons/escoria-ui-keyboard-9verbs/input_map.gd` introduces
one action per verb and provides a `add_actions_to_input_map()`
function to add the actions to the `InputMap`. The `_process_input()`
function in `game.gd` is responsible for mapping each action to the
appropriate call to `verbs_menu.on_action_selected()`.
This commit is contained in:
Michael Bolin
2022-02-23 09:40:01 -08:00
committed by Julian Murgia
parent 14cf1327fe
commit 5a77bd6fdc
13 changed files with 897 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://addons/escoria-ui-keyboard-9verbs/fonts/caslonantique.ttf" type="DynamicFontData" id=1]
[resource]
size = 21
font_data = ExtResource( 1 )

Binary file not shown.

View File

@@ -0,0 +1,401 @@
extends ESCGame
const VERB_CLOSE = "close"
const VERB_GIVE = "give"
const VERB_LOOK = "look"
const VERB_OPEN = "open"
const VERB_PICKUP = "pickup"
const VERB_PULL = "pull"
const VERB_PUSH = "push"
const VERB_TALK = "talk"
const VERB_USE = "use"
"""
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()
- pause_game()
- unpause_game()
- show_main_menu()
- hide_main_menu()
- apply_custom_settings()
- _on_event_done(event_name: String)
"""
onready var verbs_menu = $ui/Control/panel_down/VBoxContainer/HBoxContainer\
/VerbsMargin/verbs_menu
onready var tooltip = $ui/Control/panel_down/VBoxContainer/MarginContainer\
/tooltip
onready var room_select = $ui/Control/panel_down/VBoxContainer/HBoxContainer\
/MainMargin/VBoxContainer/room_select
onready var inventory_ui = $ui/Control/panel_down/VBoxContainer/HBoxContainer\
/InventoryMargin/inventory_ui
const input_map = preload("res://addons/escoria-ui-keyboard-9verbs/input_map.gd")
func _enter_tree():
var room_selector_parent = $ui/Control/panel_down/VBoxContainer\
/HBoxContainer/MainMargin/VBoxContainer
if ProjectSettings.get_setting("escoria/debug/enable_room_selector") and \
room_selector_parent.get_node_or_null("room_select") == null:
room_selector_parent.add_child(
preload(
"res://addons/escoria-core/ui_library/tools/room_select" +\
"/room_select.tscn"
).instance()
)
var input_handler = funcref(self, "_process_input")
escoria.inputs_manager.register_custom_input_handler(input_handler)
input_map.add_actions_to_input_map()
func _exit_tree():
escoria.inputs_manager.register_custom_input_handler(null)
input_map.erase_actions_from_input_map()
func _process_input(event: InputEvent, is_default_state: bool) -> bool:
if not is_default_state:
return false
elif event.is_action_pressed(input_map.ACTION_SET_VERB_OPEN):
verbs_menu.on_action_selected(VERB_OPEN)
return true
elif event.is_action_pressed(input_map.ACTION_SET_VERB_PICKUP):
verbs_menu.on_action_selected(VERB_PICKUP)
return true
elif event.is_action_pressed(input_map.ACTION_SET_VERB_PUSH):
verbs_menu.on_action_selected(VERB_PUSH)
return true
elif event.is_action_pressed(input_map.ACTION_SET_VERB_CLOSE):
verbs_menu.on_action_selected(VERB_CLOSE)
return true
elif event.is_action_pressed(input_map.ACTION_SET_VERB_LOOK):
verbs_menu.on_action_selected(VERB_LOOK)
return true
elif event.is_action_pressed(input_map.ACTION_SET_VERB_PULL):
verbs_menu.on_action_selected(VERB_PULL)
return true
elif event.is_action_pressed(input_map.ACTION_SET_VERB_GIVE):
verbs_menu.on_action_selected(VERB_GIVE)
return true
elif event.is_action_pressed(input_map.ACTION_SET_VERB_USE):
verbs_menu.on_action_selected(VERB_USE)
return true
elif event.is_action_pressed(input_map.ACTION_SET_VERB_TALK):
verbs_menu.on_action_selected(VERB_TALK)
return true
else:
return false
## BACKGROUND ##
func left_click_on_bg(position: Vector2) -> void:
if escoria.main.current_scene.player:
escoria.action_manager.do(
escoria.action_manager.ACTION.BACKGROUND_CLICK,
[escoria.main.current_scene.player.global_id, position],
true
)
escoria.action_manager.clear_current_action()
escoria.action_manager.clear_current_tool()
tooltip.clear()
verbs_menu.unselect_actions()
func right_click_on_bg(position: Vector2) -> void:
if escoria.main.current_scene.player:
escoria.action_manager.do(
escoria.action_manager.ACTION.BACKGROUND_CLICK,
[escoria.main.current_scene.player.global_id, position],
true
)
escoria.action_manager.clear_current_action()
escoria.action_manager.clear_current_tool()
tooltip.clear()
verbs_menu.unselect_actions()
func left_double_click_on_bg(position: Vector2) -> void:
if escoria.main.current_scene.player:
escoria.action_manager.do(
escoria.action_manager.ACTION.BACKGROUND_CLICK,
[escoria.main.current_scene.player.global_id, position, true],
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
match escoria.action_manager.action_state:
# Don't change the tooltip if an action input is completed
# (ie verb+item(+target)) because the action is now being executed
# and the tooltip is already set because the item was focused
# (see element_focused() and inventory_item_focused())
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
return
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
tooltip.set_target(target_obj.tooltip_name)
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
tooltip.set_target2(target_obj.tooltip_name)
func element_unfocused() -> void:
match escoria.action_manager.action_state:
# Don't change the tooltip if an action input is completed
# (ie verb+item(+target)) because the action is now being executed
# and the tooltip is already set because the item was focused
# (see element_focused() and inventory_item_focused())
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
return
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
tooltip.set_target("")
verbs_menu.unselect_actions()
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
tooltip.set_target2("")
## ITEMS ##
func left_click_on_item(item_global_id: String, event: InputEvent) -> void:
escoria.action_manager.do(
escoria.action_manager.ACTION.ITEM_LEFT_CLICK,
[item_global_id, event],
true
)
var target_obj = escoria.object_manager.get_object(
item_global_id
).node
match escoria.action_manager.action_state:
# Don't change the tooltip if an action input is completed
# (ie verb+item(+target)) because the action is now being executed
# and the tooltip is already set because the item was focused
# (see element_focused() and inventory_item_focused())
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
return
# Just clicked on the item
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
tooltip.set_target(target_obj.tooltip_name)
# Clicked on item and now we're awaiting a target item
# This means we clicked the tool and we now need a target
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
tooltip.set_target(target_obj.tooltip_name, true)
func right_click_on_item(item_global_id: String, event: InputEvent) -> void:
escoria.action_manager.set_current_action(verbs_menu.selected_action)
escoria.action_manager.do(
escoria.action_manager.ACTION.ITEM_RIGHT_CLICK,
[item_global_id, event],
true
)
func left_double_click_on_item(item_global_id: String, event: InputEvent) -> void:
escoria.action_manager.do(
escoria.action_manager.ACTION.ITEM_LEFT_CLICK,
[item_global_id, event],
true
)
## INVENTORY ##
func left_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
escoria.action_manager.do(
escoria.action_manager.ACTION.ITEM_LEFT_CLICK,
[inventory_item_global_id, event]
)
var target_obj = escoria.object_manager.get_object(
inventory_item_global_id
).node
match escoria.action_manager.action_state:
# Don't change the tooltip if an action input is completed
# (ie verb+item(+target)) because the action is now being executed
# and the tooltip is already set because the item was focused
# (see element_focused() and inventory_item_focused())
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
return
# Just clicked on the inventory item: do nothing special
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
return
# Clicked on inventory item and now we're awaiting a target item
# This means we clicked the tool and we now need a target
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
tooltip.set_target(target_obj.tooltip_name, true)
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.action_manager.do(
escoria.action_manager.ACTION.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
match escoria.action_manager.action_state:
# Don't change the tooltip if an action input is completed
# (ie verb+item(+target)) because the action is now being executed
# and the tooltip is already set because the item was focused
# (see element_focused() and inventory_item_focused())
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
return
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
tooltip.set_target(target_obj.tooltip_name)
# Hovering an ESCItem highlights its default action
if escoria.action_manager.current_action != VERB_USE and target_obj is ESCItem:
verbs_menu.set_by_name(target_obj.default_action)
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
tooltip.set_target2(target_obj.tooltip_name)
func inventory_item_unfocused() -> void:
match escoria.action_manager.action_state:
ESCActionManager.ACTION_INPUT_STATE.COMPLETED:
# Don't change the tooltip if an action input is completed
# (ie verb+item(+target)) because the action is now being executed
return
ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM, \
ESCActionManager.ACTION_INPUT_STATE.AWAITING_ITEM:
tooltip.set_target("")
verbs_menu.unselect_actions()
ESCActionManager.ACTION_INPUT_STATE.AWAITING_TARGET_ITEM:
tooltip.set_target2("")
func open_inventory():
pass
func close_inventory():
pass
func mousewheel_action(_direction: int):
pass
func hide_ui():
$ui/Control.hide()
verbs_menu.hide()
if ProjectSettings.get("escoria/debug/enable_room_selector") == true:
room_select.hide()
inventory_ui.hide()
tooltip.hide()
func show_ui():
$ui/Control.show()
verbs_menu.show()
if ProjectSettings.get("escoria/debug/enable_room_selector") == true:
room_select.show()
inventory_ui.show()
tooltip.show()
func hide_main_menu():
if get_node(main_menu).visible:
get_node(main_menu).hide()
show_ui()
func show_main_menu():
if not get_node(main_menu).visible:
hide_ui()
get_node(main_menu).reset()
get_node(main_menu).show()
func unpause_game():
if get_node(pause_menu).visible:
get_node(pause_menu).hide()
escoria.object_manager.get_object("_camera").node.current = true
escoria.main.current_scene.game.show_ui()
escoria.main.current_scene.show()
escoria.set_game_paused(false)
func pause_game():
if not get_node(pause_menu).visible:
get_node(pause_menu).reset()
get_node(pause_menu).set_save_enabled(escoria.save_manager.save_enabled)
get_node(pause_menu).show()
escoria.object_manager.get_object("_camera").node.current = false
escoria.main.current_scene.game.hide_ui()
escoria.main.current_scene.hide()
escoria.set_game_paused(true)
func _on_MenuButton_pressed() -> void:
pause_game()
func _on_action_finished() -> void:
verbs_menu.unselect_actions()
tooltip.clear()
func _on_event_done(_return_code: int, _event_name: String):
escoria.action_manager.clear_current_action()
verbs_menu.unselect_actions()

View File

@@ -0,0 +1,165 @@
[gd_scene load_steps=11 format=2]
[ext_resource path="res://addons/escoria-ui-keyboard-9verbs/tooltip/action_target_tooltip.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/escoria-ui-keyboard-9verbs/inventory/inventory_ui.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/escoria-ui-keyboard-9verbs/verbs_menu.tscn" type="PackedScene" id=3]
[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/esc_dialog_player.gd" type="Script" id=4]
[ext_resource path="res://addons/escoria-ui-keyboard-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://addons/escoria-core/ui_library/menus/main_menu/main_menu.tscn" type="PackedScene" id=7]
[ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.tscn" type="PackedScene" id=9]
[ext_resource path="res://addons/escoria-ui-keyboard-9verbs/theme.tres" type="Theme" id=10]
[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 )
main_menu = NodePath("ui/main_menu")
pause_menu = NodePath("ui/pause_menu")
[node name="dialog_layer" type="CanvasLayer" parent="."]
[node name="ESCDialogsPlayer" type="Control" parent="dialog_layer"]
theme = ExtResource( 10 )
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ui" type="CanvasLayer" parent="."]
[node name="Control" type="Control" parent="ui"]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
theme = ExtResource( 10 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="panel_down" type="PanelContainer" parent="ui/Control"]
anchor_top = 0.7
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_vertical = 3
custom_styles/panel = SubResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="ui/Control/panel_down"]
margin_right = 1280.0
margin_bottom = 270.0
[node name="MarginContainer" type="MarginContainer" parent="ui/Control/panel_down/VBoxContainer"]
margin_right = 1280.0
margin_bottom = 32.0
custom_constants/margin_top = 10
[node name="tooltip" parent="ui/Control/panel_down/VBoxContainer/MarginContainer" instance=ExtResource( 1 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 10.0
margin_right = 1280.0
margin_bottom = 32.0
bbcode_text = "[center]Test[/center]"
text = "Test"
fit_content_height = true
color = Color( 1, 1, 1, 1 )
[node name="HSeparator" type="HSeparator" parent="ui/Control/panel_down/VBoxContainer"]
margin_top = 36.0
margin_right = 1280.0
margin_bottom = 46.0
custom_constants/separation = 10
[node name="HBoxContainer" type="HBoxContainer" parent="ui/Control/panel_down/VBoxContainer"]
margin_top = 50.0
margin_right = 1280.0
margin_bottom = 270.0
size_flags_vertical = 3
[node name="VerbsMargin" type="MarginContainer" parent="ui/Control/panel_down/VBoxContainer/HBoxContainer"]
margin_right = 424.0
margin_bottom = 220.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/margin_right = 20
custom_constants/margin_top = 20
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
[node name="verbs_menu" parent="ui/Control/panel_down/VBoxContainer/HBoxContainer/VerbsMargin" instance=ExtResource( 3 )]
margin_left = 20.0
margin_top = 20.0
margin_right = 404.0
margin_bottom = 200.0
[node name="MainMargin" type="MarginContainer" parent="ui/Control/panel_down/VBoxContainer/HBoxContainer"]
margin_left = 428.0
margin_right = 852.0
margin_bottom = 220.0
size_flags_horizontal = 3
custom_constants/margin_right = 20
custom_constants/margin_top = 20
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
[node name="VBoxContainer" type="VBoxContainer" parent="ui/Control/panel_down/VBoxContainer/HBoxContainer/MainMargin"]
margin_left = 20.0
margin_top = 20.0
margin_right = 404.0
margin_bottom = 200.0
[node name="MarginContainer" type="MarginContainer" parent="ui/Control/panel_down/VBoxContainer/HBoxContainer/MainMargin/VBoxContainer"]
margin_left = 142.0
margin_top = 70.0
margin_right = 242.0
margin_bottom = 110.0
rect_min_size = Vector2( 100, 40 )
size_flags_horizontal = 6
size_flags_vertical = 6
[node name="MenuButton" type="Button" parent="ui/Control/panel_down/VBoxContainer/HBoxContainer/MainMargin/VBoxContainer/MarginContainer"]
margin_right = 100.0
margin_bottom = 40.0
text = "Menu"
[node name="InventoryMargin" type="MarginContainer" parent="ui/Control/panel_down/VBoxContainer/HBoxContainer"]
margin_left = 856.0
margin_right = 1280.0
margin_bottom = 220.0
size_flags_horizontal = 3
custom_constants/margin_right = 20
custom_constants/margin_top = 20
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
[node name="inventory_ui" parent="ui/Control/panel_down/VBoxContainer/HBoxContainer/InventoryMargin" instance=ExtResource( 2 )]
margin_left = 20.0
margin_top = 20.0
margin_right = 404.0
margin_bottom = 200.0
size_flags_horizontal = 3
size_flags_vertical = 3
[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="main_menu" parent="ui" instance=ExtResource( 7 )]
visible = false
[node name="pause_menu" parent="ui" instance=ExtResource( 9 )]
visible = false
theme = ExtResource( 10 )
[node name="camera" parent="." instance=ExtResource( 6 )]
[connection signal="pressed" from="ui/Control/panel_down/VBoxContainer/HBoxContainer/MainMargin/VBoxContainer/MarginContainer/MenuButton" to="." method="_on_MenuButton_pressed"]

View File

@@ -0,0 +1,60 @@
const ACTION_SET_VERB_OPEN = "set_action_verb_open"
const ACTION_SET_VERB_PICKUP = "set_action_verb_pickup"
const ACTION_SET_VERB_PUSH = "set_action_verb_push"
const ACTION_SET_VERB_CLOSE = "set_action_verb_close"
const ACTION_SET_VERB_LOOK = "set_action_verb_look"
const ACTION_SET_VERB_PULL = "set_action_verb_pull"
const ACTION_SET_VERB_GIVE = "set_action_verb_give"
const ACTION_SET_VERB_USE = "set_action_verb_use"
const ACTION_SET_VERB_TALK = "set_action_verb_talk"
"""
The keyboard shortcuts are chosen to match the geometric layout in the
9verb UI (example below assumes QWERTY, but implementation should work
for non-QWERTY, as well):
```
open | pickup | push -> Q | W | E
close | look | pull -> A | S | D
give | use | talk -> Z | X | C
```
"""
# Implemented as an array of arrays rather than a dict because dict
# does not have an items() method to enumerate entries together:
# https://github.com/godotengine/godot-proposals/issues/1965
const action_to_scancode = [
[ACTION_SET_VERB_OPEN, KEY_Q],
[ACTION_SET_VERB_PICKUP, KEY_W],
[ACTION_SET_VERB_PUSH, KEY_E],
[ACTION_SET_VERB_CLOSE, KEY_A],
[ACTION_SET_VERB_LOOK, KEY_S],
[ACTION_SET_VERB_PULL, KEY_D],
[ACTION_SET_VERB_GIVE, KEY_Z],
[ACTION_SET_VERB_USE, KEY_X],
[ACTION_SET_VERB_TALK, KEY_C],
]
static func add_actions_to_input_map() -> void:
for entry in action_to_scancode:
var action = entry[0]
var scancode = entry[1]
var event = InputEventKey.new()
# Based on https://github.com/godotengine/godot/pull/18020,
# `physical_scancode` seems like a more appropriate property than
# `scancode` in order to support non-QWERTY keyboard layouts while
# preserving the geometric pattern of the shortcuts.
event.physical_scancode = scancode
InputMap.add_action(action)
InputMap.action_add_event(action, event)
static func erase_actions_from_input_map() -> void:
for entry in action_to_scancode:
var action = entry[0]
InputMap.action_erase_events(action)
InputMap.erase_action(action)

View File

@@ -0,0 +1,31 @@
[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-core/ui_library/inventory/esc_inventory_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
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="GridContainer" type="GridContainer" parent="ScrollContainer"]
margin_right = 586.0
margin_bottom = 161.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/vseparation = 16
custom_constants/hseparation = 16
columns = 4
script = ExtResource( 3 )

View File

@@ -0,0 +1,7 @@
[plugin]
name="Escoria 9 Verbs UI + keyboard"
description="Classical LucasArts style 9-verbs UI for the Escoria Framework with keyboard control"
author="StraToN & bolinfest"
version="1.0.0"
script="plugin.gd"

View File

@@ -0,0 +1,18 @@
# Plugin script to initialize Escoria simple mouse UI
tool
extends EditorPlugin
# Register UI
func _enter_tree() -> void:
call_deferred("_register")
# Deregister UI
func _exit_tree() -> void:
escoria.deregister_ui("res://addons/escoria-ui-keyboard-9verbs/game.tscn")
# Register UI with Escoria
func _register():
escoria.register_ui("res://addons/escoria-ui-keyboard-9verbs/game.tscn")

View File

@@ -0,0 +1,6 @@
[gd_resource type="Theme" load_steps=2 format=2]
[ext_resource path="res://addons/escoria-ui-keyboard-9verbs/fonts/caslonantique.tres" type="DynamicFont" id=1]
[resource]
default_font = ExtResource( 1 )

View File

@@ -0,0 +1,14 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-ui-keyboard-9verbs/tooltip/tooltip_action_target.gd" type="Script" id=1]
[node name="tooltip" type="RichTextLabel"]
anchor_right = 1.0
anchor_bottom = 1.0
bbcode_enabled = true
bbcode_text = "[center][/center]"
scroll_active = false
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

View 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()

View File

@@ -0,0 +1,32 @@
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):
if escoria.inputs_manager.input_mode != escoria.inputs_manager.INPUT_ALL:
unselect_actions()
return
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)

View File

@@ -0,0 +1,125 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-ui-keyboard-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
}