Port: full rtmi-ui plugin
This commit is contained in:
@@ -17,7 +17,7 @@ func set_current_action(action: String):
|
||||
if action_state == ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM:
|
||||
set_action_input_state(ACTION_INPUT_STATE.AWAITING_ITEM)
|
||||
elif action_state == ACTION_INPUT_STATE.AWAITING_VERB:
|
||||
set_action_input_state(ACTION_INPUT_STATE.AWAITING_VERB_CONFIRM)
|
||||
set_action_input_state(ACTION_INPUT_STATE.AWAITING_VERB_CONFIRMATION)
|
||||
|
||||
emit_signal("action_changed")
|
||||
|
||||
@@ -39,14 +39,14 @@ func _get_event_to_queue(
|
||||
action: String,
|
||||
target: ESCObject,
|
||||
combine_with: ESCObject = null
|
||||
) -> ESCEvent:
|
||||
) -> ESCGrammarStmts.Event:
|
||||
|
||||
escoria.logger.info(
|
||||
self,
|
||||
"Checking if action '%s' on '%s' is valid..." % [action, target]
|
||||
)
|
||||
|
||||
var event_to_return: ESCEvent = null
|
||||
var event_to_return = null
|
||||
|
||||
# If we're using an action which item requires to combine
|
||||
if target.node is ESCItem \
|
||||
@@ -189,7 +189,7 @@ func perform_inputevent_on_object(
|
||||
elif action_state == ACTION_INPUT_STATE.AWAITING_ITEM and need_combine and not tool_just_set:
|
||||
set_action_input_state(ACTION_INPUT_STATE.AWAITING_TARGET_ITEM)
|
||||
|
||||
var event_to_queue: ESCEvent = null
|
||||
var event_to_queue: ESCGrammarStmts.Event = null
|
||||
|
||||
# Manage exits
|
||||
if obj.node.is_exit and current_action in ["", ACTION_WALK]:
|
||||
@@ -241,15 +241,12 @@ func perform_inputevent_on_object(
|
||||
if not obj.node is ESCPlayer and \
|
||||
not escoria.inventory_manager.inventory_has(obj.global_id) and \
|
||||
not event_flags & ESCEvent.FLAG_TK:
|
||||
var context = _walk_towards_object(
|
||||
var context = await _walk_towards_object(
|
||||
obj,
|
||||
event.position,
|
||||
event.doubleclick
|
||||
)
|
||||
|
||||
if context is GDScriptFunctionState:
|
||||
context = await context.completed
|
||||
|
||||
# In case of an interrupted walk, we don't want to proceed.
|
||||
if context == null:
|
||||
return
|
||||
|
||||
@@ -50,9 +50,8 @@ func removeFromInventoryIfCountLessThan(global_id: String, value:= 1) -> void:
|
||||
func get_item(global_id: String) -> ESCItem:
|
||||
var node = escoria.object_manager.get_object(global_id).node
|
||||
if not node is ESCItem:
|
||||
escoria.logger.error(
|
||||
"item_count_add: invalid object",
|
||||
["Object is not an ESCItem"]
|
||||
escoria.logger.error(self,
|
||||
"Object is not an ESCItem"
|
||||
)
|
||||
return null
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@tool
|
||||
@icon("res://addons/escoria-core/design/esc_item.svg")
|
||||
extends ESCItem
|
||||
class_name ESCItemWithTooltip, "res://addons/escoria-core/design/esc_item.svg"
|
||||
class_name ESCItemWithTooltip
|
||||
|
||||
# Action 3 tooltip texts if item is target. Dictionary with tool's global id as key.
|
||||
@export var action3_target_texts: Dictionary = {}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@tool
|
||||
@icon("res://addons/escoria-core/design/esc_player.svg")
|
||||
extends ESCItemWithTooltip
|
||||
class_name ESCPlayerWithTooltip, "res://addons/escoria-core/design/esc_player.svg"
|
||||
class_name ESCPlayerWithTooltip
|
||||
|
||||
# Whether the player can be selected like an item
|
||||
@export var selectable: bool = false
|
||||
@@ -8,7 +9,6 @@ class_name ESCPlayerWithTooltip, "res://addons/escoria-core/design/esc_player.sv
|
||||
|
||||
# A player is always movable
|
||||
func _init():
|
||||
super._init()
|
||||
is_movable = true
|
||||
_force_registration = true
|
||||
|
||||
|
||||
@@ -36,10 +36,8 @@ const ONE_LINE_HEIGHT = 16
|
||||
var current_action: String
|
||||
|
||||
# Target item/hotspot
|
||||
var current_target: String: set = set_target
|
||||
|
||||
var current_target_object: Object = null: set = set_target_object
|
||||
|
||||
var current_target: String
|
||||
var current_target_object: Object
|
||||
# Preposition: on, with...
|
||||
var current_prep: String = "with"
|
||||
|
||||
@@ -58,7 +56,7 @@ var debug_texturerect_node: TextureRect
|
||||
var _room_is_ready: bool = false
|
||||
|
||||
# Tooltips are hidden
|
||||
var hidden: bool = false
|
||||
var hiddenTooltip: bool = false
|
||||
|
||||
signal tooltip_size_updated
|
||||
|
||||
@@ -262,7 +260,7 @@ func tooltip_distance_to_edge_right(position: Vector2):
|
||||
|
||||
func show():
|
||||
escoria.logger.info(self, "show")
|
||||
hidden = false
|
||||
hiddenTooltip = false
|
||||
update_tooltip_text()
|
||||
|
||||
func hide():
|
||||
@@ -271,7 +269,7 @@ func hide():
|
||||
$tooltip2.visible = false;
|
||||
|
||||
func setHidden():
|
||||
hidden = true
|
||||
hiddenTooltip = true
|
||||
hide()
|
||||
|
||||
# Clear the tooltip targets texts
|
||||
|
||||
@@ -59,15 +59,15 @@ const DEADZONE = 0.2
|
||||
# Multiplier to apply to axis when it exceeds DEADZONE.
|
||||
const AXIS_WEIGHT = 50.0
|
||||
|
||||
# JOY_BUTTON_2 corresponds to the "X" button on an XBox controller
|
||||
# JOY_BUTTON_X corresponds to the "X" button on an XBox controller
|
||||
# or the Square button on a Playstation controller. These appear to
|
||||
# map to the "primary action," in practice, so we treat it like a left click.
|
||||
const PRIMARY_ACTION_BUTTON = JOY_BUTTON_2
|
||||
const PRIMARY_ACTION_BUTTON = JOY_BUTTON_X
|
||||
|
||||
# JOY_BUTTON_3 corresponds to the "Y" button on an XBox controller
|
||||
# JOY_BUTTON_Y corresponds to the "Y" button on an XBox controller
|
||||
# or the Triangle button on a Playstation controller. These appear to
|
||||
# map to the "secondary action," in practice, so we treat it like a right click.
|
||||
const CHANGE_VERB_BUTTON = JOY_BUTTON_3
|
||||
const CHANGE_VERB_BUTTON = JOY_BUTTON_Y
|
||||
|
||||
# Input action for use by InputMap
|
||||
const ESC_UI_CHANGE_VERB_ACTION = "esc_change_verb"
|
||||
@@ -124,7 +124,7 @@ func _enter_tree():
|
||||
room_selector.visible = false
|
||||
|
||||
|
||||
var input_handler = funcref(self, "_process_input")
|
||||
var input_handler = Callable(self, "_process_input")
|
||||
escoria.inputs_manager.register_custom_input_handler(input_handler)
|
||||
|
||||
_is_gamepad_connected = Input.is_joy_known(JOY_DEVICE)
|
||||
@@ -203,13 +203,13 @@ func _process(_delta) -> void:
|
||||
if !_is_gamepad_connected:
|
||||
return
|
||||
|
||||
var x = Input.get_joy_axis(JOY_DEVICE, JOY_AXIS_0)
|
||||
var y = Input.get_joy_axis(JOY_DEVICE, JOY_AXIS_1)
|
||||
var x = Input.get_joy_axis(JOY_DEVICE, JOY_AXIS_LEFT_X)
|
||||
var y = Input.get_joy_axis(JOY_DEVICE, JOY_AXIS_LEFT_Y)
|
||||
var delta_x = int(x * AXIS_WEIGHT) if abs(x) > DEADZONE else 0
|
||||
var delta_y = int(y * AXIS_WEIGHT) if abs(y) > DEADZONE else 0
|
||||
if delta_x or delta_y:
|
||||
var direction = Vector2(delta_x, delta_y)
|
||||
escoria.logger.trace("gamepad direction:", [direction])
|
||||
escoria.logger.trace(self, "gamepad direction: %s" % [direction])
|
||||
var viewport = get_viewport()
|
||||
viewport.warp_mouse(viewport.get_mouse_position() + direction)
|
||||
|
||||
@@ -220,14 +220,14 @@ func _process_input(event: InputEvent, is_default_state: bool) -> bool:
|
||||
# the "New Game" screen.
|
||||
return false
|
||||
elif _is_gamepad_connected and event is InputEventJoypadButton:
|
||||
escoria.logger.trace("InputEventJoypadButton:", [event.as_text()])
|
||||
escoria.logger.trace(self, "InputEventJoypadButton: %s" % [event.as_text()])
|
||||
if event.is_action_pressed(escoria.inputs_manager.ESC_UI_PRIMARY_ACTION):
|
||||
# Admittedly, this breaks abstraction barriers and is completely
|
||||
# inappropriate, but it's what works right now.
|
||||
escoria.inputs_manager._on_left_click_on_bg(get_global_mouse_position())
|
||||
return true
|
||||
elif event.is_action_pressed(ESC_UI_CHANGE_VERB_ACTION):
|
||||
escoria.logger.error("Someone invoked ESC_UI_CHANGE_VERB_ACTION:", [event.as_text()])
|
||||
escoria.logger.error(self, "Someone invoked ESC_UI_CHANGE_VERB_ACTION: %s" % [event.as_text()])
|
||||
return true
|
||||
return false
|
||||
|
||||
@@ -477,7 +477,7 @@ func correctPosition(tooltip: ESCRichTooltip, size: Vector2, mouse_position: Vec
|
||||
return mouse_position - offset
|
||||
|
||||
func _on_event_done(return_code: int, _event_name: String):
|
||||
escoria.logger.info(self, "EVENT DONE! code=" + String(return_code))
|
||||
escoria.logger.info(self, "EVENT DONE! code= %s" % [return_code])
|
||||
|
||||
# Reset mouse cursor (should be not needed, but avoids not resetting the cursor on bugs)
|
||||
Input.set_custom_mouse_cursor(null)
|
||||
|
||||
@@ -14,9 +14,9 @@ func _ready():
|
||||
if collision is CollisionPolygon2D:
|
||||
outline = ItemOutline.new()
|
||||
outline.polygon = collision.get("polygon")
|
||||
outline.color = Color(1,1,1,0.2)
|
||||
outline.color = Color(1, 1, 1, 0.2)
|
||||
outline.set_outline_width(2.0)
|
||||
outline.set_outline_color(Color(1,1,1,1))
|
||||
outline.set_outline_color(Color(1, 1, 1, 1))
|
||||
collision.add_child(outline)
|
||||
outline.hide()
|
||||
|
||||
|
||||
@@ -167,16 +167,8 @@ func register_object(object: ESCObject, room: ESCRoom = null, force: bool = fals
|
||||
# forcing the registration, since we don't know if this object will be
|
||||
# overwritten ("forced") in the future and, if it is, if it's set to
|
||||
# auto-unregister or not. In most cases, objects are set to auto unregister.
|
||||
if object.node.is_connected(
|
||||
"tree_exited",
|
||||
self,
|
||||
"unregister_object"
|
||||
):
|
||||
object.node.disconnect(
|
||||
"tree_exited",
|
||||
self,
|
||||
"unregister_object"
|
||||
)
|
||||
if object.node.tree_exited.is_connected(unregister_object):
|
||||
object.node.tree_exited.disconnect(unregister_object)
|
||||
|
||||
if force:
|
||||
# If this ID already exists and we're about to overwrite it, do the
|
||||
@@ -184,12 +176,7 @@ func register_object(object: ESCObject, room: ESCRoom = null, force: bool = fals
|
||||
unregister_object_by_global_id(object.global_id, room_key)
|
||||
|
||||
if auto_unregister:
|
||||
object.node.connect(
|
||||
"tree_exited",
|
||||
self,
|
||||
"unregister_object",
|
||||
[object, room_key]
|
||||
)
|
||||
object.node.tree_exited.connect(unregister_object.bind(object, room_key))
|
||||
|
||||
if "is_interactive" in object.node and object.node.is_interactive:
|
||||
object.interactive = true
|
||||
|
||||
Reference in New Issue
Block a user