Updated escoria-demo-game
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
# `block_say`
|
||||
#
|
||||
# `say` commands called subsequent to using the `block_say` command will reuse the
|
||||
# dialog box type of the previous `say` command if both dialog box types between the two `say`
|
||||
# commands match.
|
||||
#
|
||||
# Different dialog box types can be used across multiple `say` commands, with the latest one
|
||||
# used being preserved for reuse by the next `say` command should the dialog box type specified by
|
||||
# both `say` commands match.
|
||||
#
|
||||
# This reuse will continue until a call to `end_block_say` is made.
|
||||
#
|
||||
# Using `block_say` more than once prior to calling `end_block_say` is idempotent and has the
|
||||
# following behaviour:
|
||||
#
|
||||
# - If no `say` command has yet been encountered since the first use of `block_say`,
|
||||
# the result of using this command will be as described above.
|
||||
# - If a `say` command has been encountered since the previous use of `block_say`,
|
||||
# the dialog box used with that `say` command will continue to be reused for subsequent
|
||||
# `say` commands should the dialog box type requested match. Note that the dialog box used with
|
||||
# the next `say` command may be different than the one currently being reused.
|
||||
#
|
||||
# Example:
|
||||
# `block say`
|
||||
# `say player "Picture's looking good."`
|
||||
# `say player "And so am I."`
|
||||
# `end_block_say`
|
||||
#
|
||||
# This example will reuse the same dialog box type since they are the same between both `say` calls.
|
||||
#
|
||||
# @ESC
|
||||
extends ESCBaseCommand
|
||||
class_name BlockSayCommand
|
||||
|
||||
|
||||
# Constructor
|
||||
func _init() -> void:
|
||||
pass
|
||||
|
||||
|
||||
# Return the descriptor of the arguments of this command
|
||||
func configure() -> ESCCommandArgumentDescriptor:
|
||||
return ESCCommandArgumentDescriptor.new(0)
|
||||
|
||||
|
||||
# Validate whether the given arguments match the command descriptor
|
||||
func validate(arguments: Array):
|
||||
return true
|
||||
|
||||
|
||||
# Run the command
|
||||
func run(command_params: Array) -> int:
|
||||
escoria.dialog_player.enable_preserve_dialog_box()
|
||||
return ESCExecution.RC_OK
|
||||
|
||||
|
||||
# Function called when the command is interrupted.
|
||||
func interrupt():
|
||||
escoria.logger.debug(
|
||||
self,
|
||||
"[%s] interrupt() function not implemented." % get_command_name()
|
||||
)
|
||||
@@ -0,0 +1,47 @@
|
||||
# `end_block_say`
|
||||
#
|
||||
# `say` commands used subsequent to using the `end_block_say` command will no longer
|
||||
# reuse the dialog box type used by the previous `say` command(s) encountered.
|
||||
#
|
||||
# Using `end_block_say` more than once is safe and idempotent.
|
||||
#
|
||||
# Example:
|
||||
# `block say`
|
||||
# `say player "Picture's looking good."`
|
||||
# `say player "And so am I."`
|
||||
# `end_block_say`
|
||||
#
|
||||
# This example will reuse the same dialog box type since they are the same between both `say` calls.
|
||||
#
|
||||
# @ESC
|
||||
extends ESCBaseCommand
|
||||
class_name EndBlockSayCommand
|
||||
|
||||
|
||||
# Constructor
|
||||
func _init() -> void:
|
||||
pass
|
||||
|
||||
|
||||
# Return the descriptor of the arguments of this command
|
||||
func configure() -> ESCCommandArgumentDescriptor:
|
||||
return ESCCommandArgumentDescriptor.new(0)
|
||||
|
||||
|
||||
# Validate whether the given arguments match the command descriptor
|
||||
func validate(arguments: Array):
|
||||
return true
|
||||
|
||||
|
||||
# Run the command
|
||||
func run(command_params: Array) -> int:
|
||||
escoria.dialog_player.disable_preserve_dialog_box()
|
||||
return ESCExecution.RC_OK
|
||||
|
||||
|
||||
# Function called when the command is interrupted.
|
||||
func interrupt():
|
||||
escoria.logger.debug(
|
||||
self,
|
||||
"[%s] interrupt() function not implemented." % get_command_name()
|
||||
)
|
||||
@@ -1,18 +1,11 @@
|
||||
# `hide_menu menu_type [enable_automatic_transition]`
|
||||
# `hide_menu menu_type`
|
||||
#
|
||||
# Hides either the main menu or the pause menu. The enable_automatic_transition
|
||||
# parameter can be used to specify if Escoria manages the graphical transition
|
||||
# for you or not.
|
||||
# Setting `enable_automatic_transition` to false allows you to manage the
|
||||
# transition effect for your room as it transitions in and out. Place a
|
||||
# `transition` command in the room's `setup` event to manage the look of the
|
||||
# transition in, and in the room's `exit_scene` event to manage the look of the
|
||||
# transition out.
|
||||
# Hides either the main menu or the pause menu. Transitions from the menu using
|
||||
# the default transition type (set in the Escoria project settings).
|
||||
#
|
||||
# **Parameters**
|
||||
#
|
||||
# - *menu_type*: Which menu to hide. Can be either `main` or `pause` (default: `main`)
|
||||
# - *enable_automatic_transition*: Whether to automatically transition from the menu (default: `false`)
|
||||
#
|
||||
# @ESC
|
||||
extends ESCBaseCommand
|
||||
@@ -23,8 +16,8 @@ class_name HideMenuCommand
|
||||
func configure() -> ESCCommandArgumentDescriptor:
|
||||
return ESCCommandArgumentDescriptor.new(
|
||||
0,
|
||||
[TYPE_STRING, TYPE_BOOL],
|
||||
["main", false]
|
||||
[TYPE_STRING],
|
||||
["main"]
|
||||
)
|
||||
|
||||
|
||||
@@ -45,26 +38,26 @@ func validate(arguments: Array):
|
||||
# Run the command
|
||||
func run(command_params: Array) -> int:
|
||||
var transition_id: int
|
||||
if command_params[1]:
|
||||
# Transition out from menu
|
||||
transition_id = escoria.main.scene_transition.transition(
|
||||
"",
|
||||
ESCTransitionPlayer.TRANSITION_MODE.OUT
|
||||
)
|
||||
|
||||
if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT:
|
||||
while yield(
|
||||
escoria.main.scene_transition,
|
||||
"transition_done"
|
||||
) != transition_id:
|
||||
pass
|
||||
# Transition out from menu
|
||||
transition_id = escoria.main.scene_transition.transition(
|
||||
"",
|
||||
ESCTransitionPlayer.TRANSITION_MODE.OUT
|
||||
)
|
||||
|
||||
if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT:
|
||||
while yield(
|
||||
escoria.main.scene_transition,
|
||||
"transition_done"
|
||||
) != transition_id:
|
||||
pass
|
||||
|
||||
if command_params[0] == "main":
|
||||
escoria.game_scene.hide_main_menu()
|
||||
elif command_params[0] == "pause":
|
||||
escoria.game_scene.unpause_game()
|
||||
|
||||
if command_params[1] and escoria.main.current_scene != null:
|
||||
if escoria.main.current_scene != null:
|
||||
transition_id = escoria.main.scene_transition.transition()
|
||||
|
||||
if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT:
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
# `show_menu menu_type [enable_automatic_transition]`
|
||||
# `show_menu menu_type`
|
||||
#
|
||||
# Shows either the main menu or the pause menu. The enable_automatic_transition
|
||||
# parameter can be used to specify if Escoria manages the graphical transition to
|
||||
# the menu or not.
|
||||
# Setting `enable_automatic_transition` to false allows you to manage the
|
||||
# transition effect for your menu as it transitions in and out. Place a
|
||||
# `transition` command in the menu's `setup` event to manage the look of the
|
||||
# transition in, and in the menu's `exit_scene` event to manage the look of the
|
||||
# transition out.
|
||||
# Shows either the main menu or the pause menu. Transitions to the menu using
|
||||
# the default transition type (set in the Escoria project settings).
|
||||
#
|
||||
# **Parameters**
|
||||
#
|
||||
# - *menu_type*: Which menu to show. Can be either `main` or `pause` (default: `main`)
|
||||
# - *enable_automatic_transition*: Whether to automatically transition to the menu (default: `false`)
|
||||
#
|
||||
# @ESC
|
||||
extends ESCBaseCommand
|
||||
@@ -23,8 +16,8 @@ class_name ShowMenuCommand
|
||||
func configure() -> ESCCommandArgumentDescriptor:
|
||||
return ESCCommandArgumentDescriptor.new(
|
||||
0,
|
||||
[TYPE_STRING, TYPE_BOOL],
|
||||
["main", false]
|
||||
[TYPE_STRING],
|
||||
["main"]
|
||||
)
|
||||
|
||||
|
||||
@@ -47,39 +40,33 @@ func run(command_params: Array) -> int:
|
||||
if not escoria.game_scene.is_inside_tree():
|
||||
escoria.add_child(escoria.game_scene)
|
||||
|
||||
if command_params[1]:
|
||||
# Transition out from current scene
|
||||
var transition_id = escoria.main.scene_transition.transition(
|
||||
"",
|
||||
ESCTransitionPlayer.TRANSITION_MODE.OUT
|
||||
)
|
||||
# Transition out from current scene
|
||||
var transition_id = escoria.main.scene_transition.transition(
|
||||
"",
|
||||
ESCTransitionPlayer.TRANSITION_MODE.OUT
|
||||
)
|
||||
|
||||
if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT:
|
||||
while yield(
|
||||
escoria.main.scene_transition,
|
||||
"transition_done"
|
||||
) != transition_id:
|
||||
pass
|
||||
if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT:
|
||||
while yield(
|
||||
escoria.main.scene_transition,
|
||||
"transition_done"
|
||||
) != transition_id:
|
||||
pass
|
||||
|
||||
if command_params[0] == "main":
|
||||
escoria.game_scene.show_main_menu()
|
||||
elif command_params[0] == "pause":
|
||||
escoria.game_scene.pause_game()
|
||||
if command_params[0] == "main":
|
||||
escoria.game_scene.show_main_menu()
|
||||
elif command_params[0] == "pause":
|
||||
escoria.game_scene.pause_game()
|
||||
|
||||
# Transition in to menu
|
||||
transition_id = escoria.main.scene_transition.transition()
|
||||
# Transition in to menu
|
||||
transition_id = escoria.main.scene_transition.transition()
|
||||
|
||||
if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT:
|
||||
while yield(
|
||||
escoria.main.scene_transition,
|
||||
"transition_done"
|
||||
) != transition_id:
|
||||
pass
|
||||
else:
|
||||
if command_params[0] == "main":
|
||||
escoria.game_scene.show_main_menu()
|
||||
elif command_params[0] == "pause":
|
||||
escoria.game_scene.pause_game()
|
||||
if transition_id != ESCTransitionPlayer.TRANSITION_ID_INSTANT:
|
||||
while yield(
|
||||
escoria.main.scene_transition,
|
||||
"transition_done"
|
||||
) != transition_id:
|
||||
pass
|
||||
|
||||
return ESCExecution.RC_OK
|
||||
|
||||
|
||||
@@ -117,5 +117,6 @@ func interrupt():
|
||||
tween.stop_all()
|
||||
|
||||
|
||||
func _on_tween_completed(tween: Tween):
|
||||
tween.queue_free()
|
||||
func _on_tween_completed(tween: Tween, _key: NodePath):
|
||||
if tween:
|
||||
tween.queue_free()
|
||||
|
||||
@@ -75,11 +75,6 @@ var action_state = ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM \
|
||||
#
|
||||
# - action: type of the action to run
|
||||
# - params: Parameters for the action
|
||||
# - BACKGROUND_CLICK: [moving_obj, target, walk_fast]
|
||||
# - ITEM_LEFT_CLICK: [item, input_event]
|
||||
# - ITEM_RIGHT_CLICK: [item, input_event]
|
||||
# - TRIGGER_IN: [trigger_id, object_id, trigger_in_verb]
|
||||
# - TRIGGER_OUT: [trigger_id, object_id, trigger_out_verb]
|
||||
# - can_interrupt: if true, this command will interrupt any ongoing event
|
||||
# before it is finished
|
||||
func do(action: int, params: Array = [], can_interrupt: bool = false) -> void:
|
||||
|
||||
@@ -121,6 +121,12 @@ func register_object(object: ESCObject, room: ESCRoom = null, force: bool = fals
|
||||
if room == null or room.global_id.empty():
|
||||
# We duplicate the key so as to not hold a reference when current_room_key
|
||||
# changes.
|
||||
if current_room_key.room_global_id.empty():
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"The current room has no Global ID.\n" +
|
||||
"Please set the ESCRoom's Global ID property."
|
||||
)
|
||||
room_key.room_global_id = current_room_key.room_global_id
|
||||
room_key.room_instance_id = current_room_key.room_instance_id
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ func change_scene(room_path: String, enable_automatic_transitions: bool) -> void
|
||||
if escoria.dialog_player:
|
||||
escoria.dialog_player.interrupt()
|
||||
|
||||
escoria.inputs_manager.hover_stack_clear()
|
||||
escoria.inputs_manager.hover_stack.clear()
|
||||
|
||||
# Check if game scene was loaded
|
||||
if not escoria.game_scene:
|
||||
|
||||
@@ -39,7 +39,7 @@ func run() -> int:
|
||||
if _is_interrupted:
|
||||
final_rc = ESCExecution.RC_INTERRUPTED
|
||||
statement.interrupt()
|
||||
emit_signal("interrupted", self, final_rc)
|
||||
emit_signal("interrupted", self, statement, final_rc)
|
||||
return final_rc
|
||||
|
||||
if statement.is_valid():
|
||||
|
||||
@@ -74,6 +74,10 @@ func _enter_tree():
|
||||
func _ready():
|
||||
mouse_filter = MOUSE_FILTER_IGNORE
|
||||
|
||||
# If background has no texture, set its rect size to viewport size
|
||||
if texture == null and rect_size == Vector2.ZERO:
|
||||
rect_size = escoria.game_size
|
||||
|
||||
if !Engine.is_editor_hint():
|
||||
escoria.inputs_manager.register_background(self)
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ var tooltip_node: Object
|
||||
# function of game.gd script.
|
||||
var room_ready_for_inputs: bool = false
|
||||
|
||||
# Displayer node for hover stack debugging
|
||||
var hover_stack_displayer
|
||||
|
||||
|
||||
# Function called when ESCGame enters the scene tree.
|
||||
func _enter_tree():
|
||||
@@ -59,13 +62,21 @@ func _enter_tree():
|
||||
self,
|
||||
"_on_action_finished"
|
||||
)
|
||||
|
||||
escoria.main.connect(
|
||||
"room_ready",
|
||||
self,
|
||||
"_on_room_ready"
|
||||
)
|
||||
|
||||
# Debug display for hover stack
|
||||
if ProjectSettings.get_setting(ESCProjectSettingsManager.ENABLE_HOVER_STACK_VIEWER) and \
|
||||
get_node_or_null("hover_stack_layer") == null:
|
||||
hover_stack_displayer = preload(
|
||||
"res://addons/escoria-core/ui_library/tools/hover_stack/hover_stack.tscn"
|
||||
).instance()
|
||||
add_child(hover_stack_displayer)
|
||||
escoria.inputs_manager.hover_stack.connect("hover_stack_changed", hover_stack_displayer, "update")
|
||||
|
||||
|
||||
# Function called when ESCGame exits the scene tree.
|
||||
func _exit_tree():
|
||||
|
||||
@@ -300,7 +300,7 @@ func _ready():
|
||||
# the top level of overlapping stack.
|
||||
func _on_mouse_exited():
|
||||
if escoria.inputs_manager.hover_stack.has(self):
|
||||
escoria.inputs_manager.hover_stack_erase_item(self)
|
||||
escoria.inputs_manager.hover_stack.erase_item(self)
|
||||
escoria.inputs_manager.unset_hovered_node(self)
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ class HoverStackSorter:
|
||||
func _on_input_event(_viewport: Object, event: InputEvent, _shape_idx: int):
|
||||
if event is InputEventMouseMotion:
|
||||
var physics2d_dss: Physics2DDirectSpaceState = get_world_2d().direct_space_state
|
||||
var colliding: Array = physics2d_dss.intersect_point(get_global_mouse_position(), 32, [], 0x7FFFFFFF, true, true)
|
||||
var colliding: Array = physics2d_dss.intersect_point(get_global_mouse_position(), 32, [], 0x7FFFFFFF, true, true)
|
||||
var colliding_nodes = []
|
||||
for c in colliding:
|
||||
if c.collider.get("global_id") \
|
||||
@@ -331,8 +331,8 @@ func _on_input_event(_viewport: Object, event: InputEvent, _shape_idx: int):
|
||||
if colliding_nodes.empty():
|
||||
return
|
||||
colliding_nodes.sort_custom(HoverStackSorter, "sort_ascending_z_index")
|
||||
escoria.inputs_manager.hover_stack_clear()
|
||||
escoria.inputs_manager.hover_stack_add_items(colliding_nodes)
|
||||
escoria.inputs_manager.hover_stack.clear()
|
||||
escoria.inputs_manager.hover_stack.add_items(colliding_nodes)
|
||||
escoria.inputs_manager.set_hovered_node(colliding_nodes.back())
|
||||
|
||||
|
||||
@@ -587,7 +587,7 @@ func teleport_to(target: Vector2) -> void:
|
||||
escoria.logger.warn(
|
||||
self,
|
||||
"Node %s cannot \"teleport_to\". Its \"is_movable\" parameter is false." %self
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# Use the movable node to make the item walk to the given position
|
||||
@@ -603,7 +603,7 @@ func walk_to(pos: Vector2, p_walk_context: ESCWalkContext = null) -> void:
|
||||
escoria.logger.warn(
|
||||
self,
|
||||
"Node %s cannot use \"walk_to\". Its \"is_movable\" parameter is false." %self
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# Stop the movable node immediately and remain where it is at this moment,
|
||||
@@ -667,7 +667,7 @@ func set_angle(deg: int, wait: float = 0.0):
|
||||
escoria.logger.warn(
|
||||
self,
|
||||
"Node %s cannot use \"set_angle\". Its \"is_movable\" parameter is false." % self
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# Turn to face another object
|
||||
@@ -718,13 +718,13 @@ func check_talk_possible():
|
||||
)
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
|
||||
|
||||
# Play the talking animation
|
||||
func start_talking():
|
||||
if not check_talk_possible():
|
||||
return
|
||||
|
||||
|
||||
var animation_player = get_animation_player()
|
||||
|
||||
if animation_player.is_playing():
|
||||
@@ -744,7 +744,7 @@ func start_talking():
|
||||
func stop_talking():
|
||||
if not check_talk_possible():
|
||||
return
|
||||
|
||||
|
||||
var animation_player = get_animation_player()
|
||||
|
||||
if animation_player.is_playing():
|
||||
|
||||
@@ -3,15 +3,23 @@
|
||||
# automatically use an `ESCLocation` that is a child of the destination node.
|
||||
# Commands like `turn_to`--which are not movement-based--will ignore child
|
||||
# `ESCLocation`s and refer to the parent node.
|
||||
tool
|
||||
extends Position2D
|
||||
class_name ESCLocation, "res://addons/escoria-core/design/esc_location.svg"
|
||||
|
||||
|
||||
signal is_start_location_set
|
||||
|
||||
|
||||
const MULTIPLE_START_LOCATIONS_WARNING = \
|
||||
"Only 1 ESCLocation should have is_start_location set to true in an ESCRoom"
|
||||
|
||||
|
||||
# The global ID of this item
|
||||
export(String) var global_id
|
||||
|
||||
# If true, this ESCLocation is considered as a player start location
|
||||
export(bool) var is_start_location = false
|
||||
export(bool) var is_start_location = false setget set_is_start_location
|
||||
|
||||
# If true, player orients towards 'interaction_direction' as
|
||||
# player character arrives.
|
||||
@@ -22,6 +30,9 @@ export(bool) var player_orients_on_arrival = true
|
||||
export(int) var interaction_direction
|
||||
|
||||
|
||||
var _multiple_start_locations_exist: bool = false setget set_multiple_locations_exist
|
||||
|
||||
|
||||
# Used by "is" keyword to check whether a node's class_name
|
||||
# is the same as p_classname.
|
||||
#
|
||||
@@ -34,10 +45,36 @@ func is_class(p_classname: String) -> bool:
|
||||
|
||||
# Ready function
|
||||
func _ready():
|
||||
if not self.global_id.empty():
|
||||
escoria.object_manager.register_object(
|
||||
ESCObject.new(
|
||||
self.global_id,
|
||||
self
|
||||
if not Engine.is_editor_hint():
|
||||
if not self.global_id.empty():
|
||||
escoria.object_manager.register_object(
|
||||
ESCObject.new(
|
||||
self.global_id,
|
||||
self
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
if Engine.is_editor_hint():
|
||||
if is_start_location:
|
||||
emit_signal("is_start_location_set", self)
|
||||
|
||||
|
||||
func _get_configuration_warning():
|
||||
if _multiple_start_locations_exist:
|
||||
return MULTIPLE_START_LOCATIONS_WARNING
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
func set_multiple_locations_exist(value: bool) -> void:
|
||||
_multiple_start_locations_exist = value
|
||||
update_configuration_warning()
|
||||
|
||||
|
||||
func set_is_start_location(value: bool) -> void:
|
||||
is_start_location = value
|
||||
|
||||
if Engine.is_editor_hint() and is_instance_valid(get_owner()):
|
||||
emit_signal("is_start_location_set")
|
||||
|
||||
@@ -1,47 +1,24 @@
|
||||
# A cache for resources
|
||||
extends Reference
|
||||
extends Node
|
||||
class_name ESCResourceCache
|
||||
|
||||
var thread: Thread
|
||||
var mutex: Mutex
|
||||
var sem: Semaphore
|
||||
|
||||
var queue: Array = []
|
||||
var pending: Dictionary = {}
|
||||
|
||||
signal resource_loading_progress(path, progress)
|
||||
signal resource_loading_done(path)
|
||||
signal resource_queue_progress(queue_size)
|
||||
|
||||
|
||||
#warning-ignore:unused_argument
|
||||
func _lock(caller):
|
||||
mutex.lock()
|
||||
|
||||
#warning-ignore:unused_argument
|
||||
func _unlock(caller):
|
||||
mutex.unlock()
|
||||
|
||||
#warning-ignore:unused_argument
|
||||
func _post(caller):
|
||||
sem.post()
|
||||
|
||||
#warning-ignore:unused_argument
|
||||
func _wait(caller):
|
||||
sem.wait()
|
||||
var queue: Array = []
|
||||
var pending: Dictionary = {}
|
||||
|
||||
|
||||
func queue_resource(path: String, p_in_front: bool = false, p_permanent: bool = false):
|
||||
_lock("queue_resource")
|
||||
if path in pending:
|
||||
_unlock("queue_resource")
|
||||
return
|
||||
|
||||
elif ResourceLoader.has(path):
|
||||
var res = ResourceLoader.load(path)
|
||||
pending[path] = ESCResourceDescriptor.new(res, p_permanent)
|
||||
_unlock("queue_resource")
|
||||
return
|
||||
else:
|
||||
var res = ResourceLoader.load_interactive(path)
|
||||
res.set_meta("path", path)
|
||||
@@ -50,21 +27,16 @@ func queue_resource(path: String, p_in_front: bool = false, p_permanent: bool =
|
||||
else:
|
||||
queue.push_back(res)
|
||||
pending[path] = ESCResourceDescriptor.new(res, p_permanent)
|
||||
_post("queue_resource")
|
||||
_unlock("queue_resource")
|
||||
return
|
||||
|
||||
|
||||
func cancel_resource(path):
|
||||
_lock("cancel_resource")
|
||||
if path in pending:
|
||||
if pending[path].res is ResourceInteractiveLoader:
|
||||
queue.erase(pending[path].res)
|
||||
pending.erase(path)
|
||||
_unlock("cancel_resource")
|
||||
|
||||
|
||||
func clear():
|
||||
_lock("clear")
|
||||
|
||||
for p in pending.keys():
|
||||
if pending[p].permanent:
|
||||
continue
|
||||
@@ -72,11 +44,8 @@ func clear():
|
||||
#queue = []
|
||||
#pending = {}
|
||||
|
||||
_unlock("clear")
|
||||
|
||||
|
||||
func get_progress(path):
|
||||
_lock("get_progress")
|
||||
var ret = -1
|
||||
if path in pending:
|
||||
if pending[path].res is ResourceInteractiveLoader:
|
||||
@@ -85,36 +54,32 @@ func get_progress(path):
|
||||
ret = 1.0
|
||||
emit_signal("resource_loading_done", path)
|
||||
emit_signal("resource_loading_progress", path, ret)
|
||||
_unlock("get_progress")
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
func is_ready(path):
|
||||
var ret
|
||||
_lock("is_ready")
|
||||
|
||||
if path in pending:
|
||||
ret = !(pending[path].res is ResourceInteractiveLoader)
|
||||
else:
|
||||
ret = false
|
||||
|
||||
_unlock("is_ready")
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
func _wait_for_resource(res, path):
|
||||
_unlock("wait_for_resource")
|
||||
while true:
|
||||
#VisualServer.call("sync") # workaround because sync is a keyword
|
||||
VisualServer.force_sync()
|
||||
OS.delay_usec(16000) # wait 1 frame
|
||||
_lock("wait_for_resource")
|
||||
|
||||
if queue.size() == 0 || queue[0] != res:
|
||||
return pending[path].res
|
||||
_unlock("wait_for_resource")
|
||||
|
||||
|
||||
func get_resource(path):
|
||||
_lock("get_resource")
|
||||
if path in pending:
|
||||
if pending[path].res is ResourceInteractiveLoader:
|
||||
var res = pending[path].res
|
||||
@@ -127,17 +92,16 @@ func get_resource(path):
|
||||
|
||||
if !pending[path].permanent:
|
||||
pending.erase(path)
|
||||
_unlock("return")
|
||||
|
||||
return res
|
||||
|
||||
else:
|
||||
var res = pending[path].res
|
||||
if !pending[path].permanent:
|
||||
pending.erase(path)
|
||||
_unlock("return")
|
||||
|
||||
return res
|
||||
else:
|
||||
_unlock("return")
|
||||
# We can't use ESCProjectSettingsManager here since this method
|
||||
# can be called from escoria._init()
|
||||
if not ProjectSettings.get_setting("escoria/platform/skip_cache"):
|
||||
@@ -146,17 +110,32 @@ func get_resource(path):
|
||||
return res
|
||||
return ResourceLoader.load(path)
|
||||
|
||||
func thread_process():
|
||||
_wait("thread_process")
|
||||
|
||||
_lock("process")
|
||||
func print_progress(p_path, p_progress):
|
||||
printt(p_path, "loading", round(p_progress * 100), "%")
|
||||
|
||||
|
||||
func res_loaded(p_path):
|
||||
printt("loaded resource", p_path)
|
||||
|
||||
|
||||
func print_queue_progress(p_queue_size):
|
||||
printt("queue size:", p_queue_size)
|
||||
|
||||
|
||||
func start():
|
||||
pass
|
||||
## Uncomment these for debug, or wait for someone to implement log levels
|
||||
# connect("resource_loading_progress", self, "print_progress")
|
||||
# connect("resource_loading_done", self, "res_loaded")
|
||||
# connect("resource_queue_progress", self, "print_queue_progress")
|
||||
|
||||
|
||||
func _process(_delta) -> void:
|
||||
while queue.size() > 0:
|
||||
var res = queue[0]
|
||||
|
||||
_unlock("process_poll")
|
||||
var ret = res.poll()
|
||||
_lock("process_check_queue")
|
||||
|
||||
var path = res.get_meta("path")
|
||||
if ret == ERR_FILE_EOF || ret != OK:
|
||||
@@ -166,33 +145,3 @@ func thread_process():
|
||||
|
||||
queue.erase(res) # something might have been put at the front of the queue while we polled, so use erase instead of remove
|
||||
emit_signal("resource_queue_progress", queue.size())
|
||||
|
||||
get_progress(path)
|
||||
|
||||
_unlock("process")
|
||||
|
||||
#warning-ignore:unused_argument
|
||||
func thread_func(u):
|
||||
while true:
|
||||
thread_process()
|
||||
|
||||
func print_progress(p_path, p_progress):
|
||||
printt(p_path, "loading", round(p_progress * 100), "%")
|
||||
|
||||
func res_loaded(p_path):
|
||||
printt("loaded resource", p_path)
|
||||
|
||||
func print_queue_progress(p_queue_size):
|
||||
printt("queue size:", p_queue_size)
|
||||
|
||||
func start():
|
||||
mutex = Mutex.new()
|
||||
sem = Semaphore.new()
|
||||
thread = Thread.new()
|
||||
thread.start(self, "thread_func", 0)
|
||||
|
||||
|
||||
## Uncomment these for debug, or wait for someone to implement log levels
|
||||
# connect("resource_loading_progress", self, "print_progress")
|
||||
# connect("resource_loading_done", self, "res_loaded")
|
||||
# connect("resource_queue_progress", self, "print_queue_progress")
|
||||
|
||||
@@ -12,6 +12,8 @@ enum EditorRoomDebugDisplay {
|
||||
CAMERA_LIMITS
|
||||
}
|
||||
|
||||
const ESC_BACKGROUND_NAME = "escbackground"
|
||||
|
||||
|
||||
# The global id of this room
|
||||
export(String) var global_id = ""
|
||||
@@ -66,8 +68,26 @@ func _ready():
|
||||
) != self.filename:
|
||||
is_run_directly = true
|
||||
|
||||
if not Engine.is_editor_hint():
|
||||
escoria.room_manager.init_room(self)
|
||||
if Engine.is_editor_hint():
|
||||
_connect_location_nodes()
|
||||
_validate_start_locations()
|
||||
return
|
||||
|
||||
# If room has no ESCBackground child, add one
|
||||
var found_escbackground: bool = false
|
||||
for child in get_children():
|
||||
if child is ESCBackground:
|
||||
found_escbackground = true
|
||||
move_child(child, 0)
|
||||
if not found_escbackground:
|
||||
var esc_bg = ESCBackground.new()
|
||||
esc_bg.name = ESC_BACKGROUND_NAME
|
||||
if not camera_limits.empty():
|
||||
esc_bg.set_size(camera_limits.front().size)
|
||||
add_child(esc_bg)
|
||||
move_child(esc_bg, 0)
|
||||
|
||||
escoria.room_manager.init_room(self)
|
||||
|
||||
|
||||
# Draw the camera limits visualization if enabled
|
||||
@@ -97,6 +117,56 @@ func _draw():
|
||||
camera_limits[i].position.y + 30), str(i), camera_limits_colors[i])
|
||||
|
||||
|
||||
# Listen for any signals from ESCLocation indicating that the is_start_location attribute
|
||||
# has been set/unset in order to update start location validation.
|
||||
func _connect_location_nodes() -> void:
|
||||
_connect_location_nodes_in_tree(self)
|
||||
|
||||
|
||||
func _connect_location_nodes_in_tree(node: Node):
|
||||
for n in node.get_children():
|
||||
if n is ESCLocation:
|
||||
if not n.is_connected("is_start_location_set", self, "_validate_start_locations"):
|
||||
n.connect("is_start_location_set", self, "_validate_start_locations")
|
||||
|
||||
if n.get_child_count() > 0:
|
||||
_connect_location_nodes_in_tree(n)
|
||||
|
||||
|
||||
# Validate that we only have one start location for this scene. If we don't, call it out in the
|
||||
# scene tree via configuration warnings.
|
||||
#
|
||||
# We may have to ignore a node if it's being removed/deleted from the scene tree.
|
||||
func _validate_start_locations(to_ignore: ESCLocation = null):
|
||||
var esc_locations: Array = _find_esc_locations(self)
|
||||
var num_start_locations: int = 0
|
||||
|
||||
for n in esc_locations:
|
||||
if n == to_ignore:
|
||||
continue
|
||||
|
||||
num_start_locations += 1 if n.is_start_location else 0
|
||||
|
||||
for n in esc_locations:
|
||||
if n == to_ignore:
|
||||
continue
|
||||
|
||||
n.set_multiple_locations_exist(n.is_start_location and num_start_locations > 1)
|
||||
|
||||
|
||||
func _find_esc_locations(node: Node) -> Array:
|
||||
var esc_locations: Array = []
|
||||
|
||||
for n in node.get_children():
|
||||
if n is ESCLocation:
|
||||
esc_locations.append(n)
|
||||
|
||||
if n.get_child_count() > 0:
|
||||
esc_locations.append_array(_find_esc_locations(n))
|
||||
|
||||
return esc_locations
|
||||
|
||||
|
||||
# Set the camera limits
|
||||
#
|
||||
# #### Parameters
|
||||
|
||||
@@ -4,12 +4,12 @@ class_name ESCResourceDescriptor
|
||||
|
||||
|
||||
# The resource being described
|
||||
var res: Resource
|
||||
var res
|
||||
|
||||
# Whether the resource is permanent
|
||||
var permanent: bool
|
||||
|
||||
|
||||
func _init(res_in: Resource, permanent_in: bool) -> void:
|
||||
func _init(res_in, permanent_in: bool) -> void:
|
||||
res = res_in
|
||||
permanent = permanent_in
|
||||
|
||||
@@ -30,7 +30,7 @@ const ESC_UI_PRIMARY_ACTION = "esc_ui_primary_action"
|
||||
var input_mode = INPUT_ALL
|
||||
|
||||
# A LIFO stack of hovered items
|
||||
var hover_stack: Array = []
|
||||
var hover_stack: HoverStack
|
||||
|
||||
# The global id of the topmost item from the hover_stack
|
||||
var hotspot_focused: String = ""
|
||||
@@ -55,6 +55,8 @@ var _hovered_element = null
|
||||
# Constructor
|
||||
func _init():
|
||||
escoria.event_manager.connect("event_finished", self, "_on_event_finished")
|
||||
hover_stack = HoverStack.new()
|
||||
hover_stack.connect("hover_stack_changed", self, "_on_hover_stack_changed")
|
||||
|
||||
|
||||
# Called when an event is finished, so that the current hotspot is reset
|
||||
@@ -175,22 +177,12 @@ func try_custom_input_handler(event: InputEvent, is_default_state: bool) -> bool
|
||||
return false
|
||||
|
||||
|
||||
|
||||
# Unsets the hovered node.
|
||||
#
|
||||
# **Parameters**
|
||||
#
|
||||
# - item: the item that was unfocused (mouse_exited)
|
||||
func unset_hovered_node(item: ESCItem):
|
||||
if _hovered_element == item:
|
||||
_hovered_element.mouse_exited()
|
||||
_hovered_element = null
|
||||
if hover_stack:
|
||||
set_hovered_node(hover_stack.pop_back())
|
||||
else:
|
||||
hotspot_focused = ""
|
||||
|
||||
|
||||
# Callback called by hover stack content change.
|
||||
func _on_hover_stack_changed():
|
||||
if hover_stack.empty():
|
||||
unset_hovered_node(_hovered_element)
|
||||
else:
|
||||
set_hovered_node(hover_stack.get_top_item())
|
||||
|
||||
|
||||
# Sets the hovered node and calls its mouse_entered() method if it was the top
|
||||
@@ -203,6 +195,12 @@ func unset_hovered_node(item: ESCItem):
|
||||
# **Returns**
|
||||
# True if item is the new top hovered object
|
||||
func set_hovered_node(item: ESCItem) -> bool:
|
||||
if _hovered_element != item \
|
||||
and escoria.action_manager.is_object_actionable(item.global_id) \
|
||||
or (item is ESCPlayer and not (item as ESCPlayer).selectable):
|
||||
_hovered_element = item
|
||||
_hovered_element.mouse_entered()
|
||||
return true
|
||||
# If tested item was already hovered
|
||||
# or is not actionable (not selectable for ESCPlayer) then do nothing
|
||||
if _hovered_element == item \
|
||||
@@ -211,7 +209,7 @@ func set_hovered_node(item: ESCItem) -> bool:
|
||||
return true
|
||||
# Else if the tested item is on top of hover stack (or null)
|
||||
# Set that item as hovered and call that item's mouse_entered()
|
||||
if not is_instance_valid(_hovered_element) or hover_stack.back() != item:
|
||||
if not is_instance_valid(_hovered_element) or hover_stack.get_top_item() != item:
|
||||
_hovered_element = item
|
||||
_hovered_element.mouse_entered()
|
||||
return true
|
||||
@@ -220,6 +218,20 @@ func set_hovered_node(item: ESCItem) -> bool:
|
||||
return false
|
||||
|
||||
|
||||
# Unsets the hovered node.
|
||||
#
|
||||
# **Parameters**
|
||||
#
|
||||
# - item: the item that was unfocused (mouse_exited)
|
||||
func unset_hovered_node(item: ESCItem):
|
||||
if item == null:
|
||||
return
|
||||
if _hovered_element == item:
|
||||
_hovered_element.mouse_exited()
|
||||
_hovered_element = null
|
||||
hotspot_focused = ""
|
||||
|
||||
|
||||
# The background was clicked with the LMB
|
||||
#
|
||||
# #### Parameters
|
||||
@@ -366,7 +378,7 @@ func _on_mouse_entered_item(item: ESCItem) -> void:
|
||||
hotspot_focused = ""
|
||||
escoria.main.current_scene.game.element_unfocused()
|
||||
else:
|
||||
hotspot_focused = hover_stack.back().global_id
|
||||
hotspot_focused = hover_stack.get_top_item().global_id
|
||||
escoria.main.current_scene.game.element_focused(hotspot_focused)
|
||||
return
|
||||
|
||||
@@ -394,7 +406,7 @@ func _on_mouse_entered_item(item: ESCItem) -> void:
|
||||
func _on_mouse_exited_item(item: ESCItem) -> void:
|
||||
var object: ESCObject = escoria.object_manager.get_object(item.global_id)
|
||||
if object and not object.interactive:
|
||||
hover_stack_erase_item(item)
|
||||
hover_stack.erase_item(item)
|
||||
escoria.main.current_scene.game.element_unfocused()
|
||||
return
|
||||
|
||||
@@ -413,7 +425,7 @@ func _on_mouse_exited_item(item: ESCItem) -> void:
|
||||
hotspot_focused = ""
|
||||
escoria.main.current_scene.game.element_unfocused()
|
||||
else:
|
||||
hotspot_focused = hover_stack.back().global_id
|
||||
hotspot_focused = hover_stack.get_top_item().global_id
|
||||
escoria.main.current_scene.game.element_focused(hotspot_focused)
|
||||
|
||||
|
||||
@@ -426,13 +438,13 @@ func _on_mouse_exited_item(item: ESCItem) -> void:
|
||||
func on_item_non_interactive(item: ESCItem) -> void:
|
||||
var object: ESCObject = escoria.object_manager.get_object(item.global_id)
|
||||
if object and not object.interactive:
|
||||
hover_stack_erase_item(item)
|
||||
hover_stack.erase_item(item)
|
||||
escoria.main.current_scene.game.element_unfocused()
|
||||
hover_stack.sort_custom(HoverStackSorter, "sort_ascending_z_index")
|
||||
|
||||
if hover_stack.empty():
|
||||
return
|
||||
else:
|
||||
var new_item = hover_stack.back()
|
||||
var new_item = hover_stack.get_top_item()
|
||||
escoria.action_manager.set_action_input_state(ESCActionManager.ACTION_INPUT_STATE.AWAITING_VERB_OR_ITEM)
|
||||
new_item.mouse_entered()
|
||||
|
||||
@@ -454,7 +466,7 @@ func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||
|
||||
# Get next object in hover stack and forward event to it
|
||||
if not hover_stack.empty():
|
||||
var next_item = hover_stack.pop_back()
|
||||
var next_item = hover_stack.pop_top_item()
|
||||
_on_mouse_left_clicked_item(next_item, event)
|
||||
else: # if no next object, consider this click as background click
|
||||
hotspot_focused = ""
|
||||
@@ -498,7 +510,7 @@ func _on_mouse_left_double_clicked_item(
|
||||
|
||||
# Get next object in hover stack and forward event to it
|
||||
if not hover_stack.empty():
|
||||
var next_item = hover_stack.pop_back()
|
||||
var next_item = hover_stack.pop_top_item()
|
||||
_on_mouse_left_double_clicked_item(next_item, event)
|
||||
else: # if no next object, consider this click as background click
|
||||
hotspot_focused = ""
|
||||
@@ -536,7 +548,7 @@ func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||
)
|
||||
|
||||
if not hover_stack.empty():
|
||||
var next_item = hover_stack.pop_back()
|
||||
var next_item = hover_stack.pop_top_item()
|
||||
_on_mouse_right_clicked_item(next_item, event)
|
||||
return
|
||||
|
||||
@@ -553,7 +565,7 @@ func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void:
|
||||
# we consider we clicked through it.
|
||||
var object: ESCObject = escoria.object_manager.get_object(item.global_id)
|
||||
if object.node is ESCPlayer and not (object.node as ESCPlayer).selectable:
|
||||
actual_item = hover_stack.back()
|
||||
actual_item = hover_stack.get_top_item()
|
||||
else:
|
||||
actual_item = item
|
||||
|
||||
@@ -594,51 +606,121 @@ func _on_pause_menu_requested():
|
||||
escoria.main.current_scene.game.pause_game()
|
||||
|
||||
|
||||
# Add the given item to the stack if not already in it.
|
||||
#
|
||||
# #### Parameters
|
||||
# - item: the item to add to the hover stack
|
||||
func hover_stack_add_item(item):
|
||||
if item is ESCPlayer and not (item as ESCPlayer).selectable:
|
||||
return
|
||||
if not hover_stack.has(item):
|
||||
hover_stack.push_back(item)
|
||||
# Hover Stack implementation.
|
||||
class HoverStack:
|
||||
|
||||
|
||||
# Emitted when the content of the hover stack has changed
|
||||
signal hover_stack_changed
|
||||
|
||||
# Emitted when the hover stack was emptied
|
||||
signal hover_stack_emptied
|
||||
|
||||
|
||||
# Array representing the hover stack
|
||||
var hover_stack: Array = []
|
||||
|
||||
|
||||
# Add the given item to the stack if not already in it.
|
||||
#
|
||||
# #### Parameters
|
||||
# - item: the item to add to the hover stack
|
||||
func add_item(item):
|
||||
if item is ESCPlayer and not (item as ESCPlayer).selectable:
|
||||
return
|
||||
if not hover_stack.has(item):
|
||||
hover_stack.push_back(item)
|
||||
_sort()
|
||||
emit_signal("hover_stack_changed")
|
||||
|
||||
|
||||
# Add the items contained in given list to the stack if not already in it.
|
||||
#
|
||||
# #### Parameters
|
||||
# - items: the items list (array) to add to the hover stack
|
||||
func add_items(items: Array):
|
||||
for item in items:
|
||||
if escoria.action_manager.is_object_actionable(item.global_id):
|
||||
add_item(item)
|
||||
|
||||
|
||||
# Clean the hover stack
|
||||
func clean():
|
||||
for e in hover_stack:
|
||||
if e == null or !is_instance_valid(e):
|
||||
hover_stack.erase(e)
|
||||
emit_signal("hover_stack_changed")
|
||||
|
||||
|
||||
# Pops the top element of the hover stack and returns it
|
||||
#
|
||||
# **Returns**
|
||||
# The top element of the hover stack
|
||||
func pop_top_item():
|
||||
var ret = hover_stack.pop_back()
|
||||
if is_instance_valid(ret):
|
||||
emit_signal("hover_stack_changed")
|
||||
return ret
|
||||
|
||||
|
||||
# Returns the top element of the hover stack a
|
||||
#
|
||||
# **Returns**
|
||||
# The top element of the hover stack
|
||||
func get_top_item():
|
||||
return hover_stack.back()
|
||||
|
||||
|
||||
# Remove the given item from the stack
|
||||
#
|
||||
# #### Parameters
|
||||
# - item: the item to remove from the hover stack
|
||||
func erase_item(item):
|
||||
hover_stack.erase(item)
|
||||
_sort()
|
||||
emit_signal("hover_stack_changed")
|
||||
|
||||
|
||||
# Clear the stack of hovered items
|
||||
func clear():
|
||||
hover_stack = []
|
||||
emit_signal("hover_stack_emptied")
|
||||
|
||||
|
||||
# Returns true if the hover stack is empty, else false
|
||||
#
|
||||
# **Returns**
|
||||
# True if hover stack is empty, else false
|
||||
func empty() -> bool:
|
||||
return hover_stack.empty()
|
||||
|
||||
|
||||
# Sort the hover stack by items' z-index
|
||||
func _sort():
|
||||
hover_stack.sort_custom(HoverStackSorter, "sort_ascending_z_index")
|
||||
|
||||
|
||||
# Add the items contained in given list to the stack if not already in it.
|
||||
#
|
||||
# #### Parameters
|
||||
# - items: the items list (array) to add to the hover stack
|
||||
func hover_stack_add_items(items: Array):
|
||||
for item in items:
|
||||
if escoria.action_manager.is_object_actionable(item.global_id):
|
||||
hover_stack_add_item(item)
|
||||
# Returns true if the hover stack contains the given item
|
||||
#
|
||||
# #### Parameters
|
||||
# - item: the item to search
|
||||
#
|
||||
# **Returns**
|
||||
# True if hover stack contains given item, else false
|
||||
func has(item) -> bool:
|
||||
return hover_stack.has(item)
|
||||
|
||||
|
||||
# Clean the hover stack
|
||||
func _clean_hover_stack():
|
||||
for e in hover_stack:
|
||||
if e == null or !is_instance_valid(e):
|
||||
hover_stack.erase(e)
|
||||
# Returns the hover stack array
|
||||
#
|
||||
# **Returns**
|
||||
# The hover stack array
|
||||
func get_all() -> Array:
|
||||
return hover_stack
|
||||
|
||||
|
||||
# Remove the given item from the stack
|
||||
#
|
||||
# #### Parameters
|
||||
# - item: the item to remove from the hover stack
|
||||
func hover_stack_erase_item(item):
|
||||
hover_stack.erase(item)
|
||||
hover_stack.sort_custom(HoverStackSorter, "sort_ascending_z_index")
|
||||
|
||||
|
||||
# Clear the stack of hovered items
|
||||
func hover_stack_clear():
|
||||
hover_stack = []
|
||||
|
||||
|
||||
class HoverStackSorter:
|
||||
static func sort_ascending_z_index(a, b):
|
||||
if a.z_index < b.z_index:
|
||||
return true
|
||||
return false
|
||||
# Z Sorter class for hover stack
|
||||
class HoverStackSorter:
|
||||
static func sort_ascending_z_index(a, b):
|
||||
if a.z_index < b.z_index:
|
||||
return true
|
||||
return false
|
||||
|
||||
@@ -37,12 +37,15 @@ const _DEBUG_ROOT = "debug"
|
||||
|
||||
const CRASH_MESSAGE = "%s/%s/crash_message" % [_ESCORIA_SETTINGS_ROOT, _DEBUG_ROOT]
|
||||
const DEVELOPMENT_LANG = "%s/%s/development_lang" % [_ESCORIA_SETTINGS_ROOT, _DEBUG_ROOT]
|
||||
# If enabled, displays the room selection box for quick room change
|
||||
const ENABLE_ROOM_SELECTOR = "%s/%s/enable_room_selector" % [_ESCORIA_SETTINGS_ROOT, _DEBUG_ROOT]
|
||||
const LOG_FILE_PATH = "%s/%s/log_file_path" % [_ESCORIA_SETTINGS_ROOT, _DEBUG_ROOT]
|
||||
const LOG_LEVEL = "%s/%s/log_level" % [_ESCORIA_SETTINGS_ROOT, _DEBUG_ROOT]
|
||||
const ROOM_SELECTOR_ROOM_DIR = "%s/%s/room_selector_room_dir" % [_ESCORIA_SETTINGS_ROOT, _DEBUG_ROOT]
|
||||
const TERMINATE_ON_ERRORS = "%s/%s/terminate_on_errors" % [_ESCORIA_SETTINGS_ROOT, _DEBUG_ROOT]
|
||||
const TERMINATE_ON_WARNINGS = "%s/%s/terminate_on_warnings" % [_ESCORIA_SETTINGS_ROOT, _DEBUG_ROOT]
|
||||
# If enabled, displays the hover stack on screen
|
||||
const ENABLE_HOVER_STACK_VIEWER = "%s/%s/enable_hover_stack_viewer" % [_ESCORIA_SETTINGS_ROOT, _DEBUG_ROOT]
|
||||
|
||||
# Sound-related Escoria project settings
|
||||
const _SOUND_ROOT = "sound"
|
||||
|
||||
@@ -25,7 +25,6 @@ func _init():
|
||||
escoria.object_manager = ESCObjectManager.new()
|
||||
escoria.command_registry = ESCCommandRegistry.new()
|
||||
escoria.resource_cache = ESCResourceCache.new()
|
||||
escoria.resource_cache.start()
|
||||
escoria.save_manager = ESCSaveManager.new()
|
||||
escoria.inputs_manager = ESCInputsManager.new()
|
||||
escoria.settings_manager = ESCSettingsManager.new()
|
||||
@@ -45,6 +44,8 @@ func _init():
|
||||
|
||||
# Load settings
|
||||
func _ready():
|
||||
add_child(escoria.resource_cache)
|
||||
|
||||
_handle_direct_scene_run()
|
||||
|
||||
escoria.settings_manager.load_settings()
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
[ext_resource path="res://addons/escoria-core/game/escoria.gd" type="Script" id=3]
|
||||
|
||||
[node name="escoria_scene" type="Node"]
|
||||
pause_mode = 2
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="main" parent="." instance=ExtResource( 2 )]
|
||||
|
||||
@@ -46,13 +46,35 @@ func say(dialog_player: Node, global_id: String, text: String, type: String):
|
||||
pass
|
||||
|
||||
|
||||
# Instructs the dialog manager to preserve the next dialog box used by a `say`
|
||||
# command until a call to `disable_preserve_dialog_box` is made.
|
||||
#
|
||||
# This method should be idempotent, i.e. if called after the first time and
|
||||
# prior to `disable_preserve_dialog_box` being called, the result should be the
|
||||
# same.
|
||||
func enable_preserve_dialog_box() -> void:
|
||||
pass
|
||||
|
||||
|
||||
# Instructs the dialog manager to no longer preserve the currently-preserved
|
||||
# dialog box or to not preserve the next dialog box used by a `say` command
|
||||
# (this is the default state).
|
||||
#
|
||||
# This method should be idempotent, i.e. if called after the first time and
|
||||
# prior to `enable_preserve_dialog_box` being called, the result should be the
|
||||
# same.
|
||||
func disable_preserve_dialog_box() -> void:
|
||||
pass
|
||||
|
||||
|
||||
# Present an option chooser to the player and sends the signal
|
||||
# `option_chosen` with the chosen dialog option
|
||||
#
|
||||
# #### Parameters
|
||||
# - dialog_player: Node of the dialog player in the UI
|
||||
# - dialog: Information about the dialog to display
|
||||
func choose(dialog_player: Node, dialog: ESCDialog):
|
||||
# - type: The dialog chooser type to use
|
||||
func choose(dialog_player: Node, dialog: ESCDialog, type: String):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Escoria dialog player
|
||||
extends StateMachine
|
||||
extends Node
|
||||
class_name ESCDialogPlayer
|
||||
|
||||
|
||||
@@ -14,8 +14,20 @@ signal option_chosen(option)
|
||||
signal say_finished
|
||||
|
||||
|
||||
# Reference to the currently playing dialog manager
|
||||
var _dialog_manager: ESCDialogManager = null
|
||||
# Used when specifying dialog types in various methods
|
||||
const DIALOG_TYPE_SAY = "say"
|
||||
|
||||
const DIALOG_TYPE_CHOOSE = "choose"
|
||||
|
||||
|
||||
# Reference to the currently playing "say" dialog manager
|
||||
var _say_dialog_manager: ESCDialogManager = null
|
||||
|
||||
# Reference to the currently playing "choose" dialog manager
|
||||
var _choose_dialog_manager: ESCDialogManager = null
|
||||
|
||||
# Whether to use the "dialog box preservation" feature
|
||||
var _block_say_enabled: bool = false
|
||||
|
||||
|
||||
# Register the dialog player and load the dialog resources
|
||||
@@ -25,38 +37,27 @@ func _ready():
|
||||
|
||||
escoria.dialog_player = self
|
||||
|
||||
_create_states()
|
||||
_add_states_to_machine()
|
||||
|
||||
states_map["say"].connect("dialog_manager_set", self, "_on_dialog_manager_set")
|
||||
|
||||
current_state_name = "idle"
|
||||
START_STATE = states_map[current_state_name]
|
||||
|
||||
initialize(START_STATE)
|
||||
# Instructs the dialog manager to preserve the next dialog box used by a `say`
|
||||
# command until a call to `disable_preserve_dialog_box` is made.
|
||||
#
|
||||
# This method should be idempotent, i.e. if called after the first time and
|
||||
# prior to `disable_preserve_dialog_box` being called, the result should be the
|
||||
# same.
|
||||
func enable_preserve_dialog_box() -> void:
|
||||
_block_say_enabled = true
|
||||
|
||||
|
||||
# Creates the states for this state machine.
|
||||
func _create_states() -> void:
|
||||
states_map = {
|
||||
"idle": DialogIdle.new(),
|
||||
"say": DialogSay.new(),
|
||||
"say_fast": DialogSayFast.new(),
|
||||
"say_finish": DialogSayFinish.new(),
|
||||
"visible": DialogVisible.new(),
|
||||
"finish": DialogFinish.new(),
|
||||
"interrupt": DialogInterrupt.new(),
|
||||
"choices": DialogChoices.new(),
|
||||
}
|
||||
|
||||
# This state needs a reference to this class.
|
||||
states_map["finish"].initialize(self)
|
||||
|
||||
|
||||
# Adds any created states into the state machine as children.
|
||||
func _add_states_to_machine() -> void:
|
||||
for key in states_map:
|
||||
add_child(states_map[key])
|
||||
# Instructs the dialog manager to no longer preserve the currently-preserved
|
||||
# dialog box or to not preserve the next dialog box used by a `say` command
|
||||
# (this is the default state).
|
||||
#
|
||||
# This method should be idempotent, i.e. if called after the first time and
|
||||
# prior to `enable_preserve_dialog_box` being called, the result should be the
|
||||
# same.
|
||||
func disable_preserve_dialog_box() -> void:
|
||||
_block_say_enabled = false
|
||||
_say_dialog_manager.disable_preserve_dialog_box()
|
||||
|
||||
|
||||
# Make a character say some text
|
||||
@@ -67,18 +68,19 @@ func _add_states_to_machine() -> void:
|
||||
# - type: UI to use for the dialog
|
||||
# - text: Text to say
|
||||
func say(character: String, type: String, text: String) -> void:
|
||||
states_map["say"].initialize(character, type, text)
|
||||
_change_state("say")
|
||||
if type == "":
|
||||
type = ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.DEFAULT_DIALOG_TYPE
|
||||
)
|
||||
|
||||
# We only need to remove the dialog manager from the scene tree if the dialog manager type
|
||||
# has changed since the last use of this method.
|
||||
_update_dialog_manager(DIALOG_TYPE_SAY, _say_dialog_manager, type)
|
||||
|
||||
# Called when a dialogue line is to be sped up.
|
||||
func speedup() -> void:
|
||||
_change_state("say_fast")
|
||||
if _block_say_enabled:
|
||||
_say_dialog_manager.enable_preserve_dialog_box()
|
||||
|
||||
|
||||
# Called when a dialogue line is to be finished immediately.
|
||||
func finish() -> void:
|
||||
_change_state("say_finish")
|
||||
_say_dialog_manager.say(self, character, text, type)
|
||||
|
||||
|
||||
# Display a list of choices
|
||||
@@ -86,22 +88,111 @@ func finish() -> void:
|
||||
# #### Parameters
|
||||
#
|
||||
# - dialog: The dialog to start
|
||||
# - type: The dialog chooser type to use (default: "simple")
|
||||
func start_dialog_choices(dialog: ESCDialog, type: String = "simple"):
|
||||
states_map["choices"].initialize(self, dialog, type)
|
||||
_change_state("choices")
|
||||
# We only need to remove the dialog manager from the scene tree if the dialog manager type
|
||||
# has changed since the last use of this method.
|
||||
_update_dialog_manager(DIALOG_TYPE_CHOOSE, _choose_dialog_manager, type)
|
||||
|
||||
_choose_dialog_manager.choose(self, dialog, type)
|
||||
|
||||
|
||||
# Interrupt the currently running dialog
|
||||
func interrupt() -> void:
|
||||
_change_state("interrupt")
|
||||
if is_instance_valid(_say_dialog_manager):
|
||||
_say_dialog_manager.interrupt()
|
||||
|
||||
|
||||
# Since the dialog manager is determined when a `say` command is performed and
|
||||
# other states need to know which one was picked, we notify the necessary states
|
||||
# via this method.
|
||||
func _on_dialog_manager_set(dialog_manager: ESCDialogManager) -> void:
|
||||
_dialog_manager = dialog_manager
|
||||
states_map["say_fast"].initialize(dialog_manager)
|
||||
states_map["say_finish"].initialize(dialog_manager)
|
||||
states_map["visible"].initialize(dialog_manager)
|
||||
states_map["interrupt"].initialize(dialog_manager)
|
||||
# Loads the first dialog manager that supports the specified "say" type; otherwise,
|
||||
# the engine throws an error and stops.
|
||||
#
|
||||
# #### Parameters
|
||||
# - type: The type the dialog manager should support, e.g. "floating"
|
||||
func _determine_say_dialog_manager(type: String) -> void:
|
||||
var dialog_manager: ESCDialogManager = null
|
||||
|
||||
for _manager_class in ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.DIALOG_MANAGERS
|
||||
):
|
||||
if ResourceLoader.exists(_manager_class):
|
||||
var _manager: ESCDialogManager = load(_manager_class).new()
|
||||
if _manager.has_type(type):
|
||||
dialog_manager = _manager
|
||||
else:
|
||||
dialog_manager = null
|
||||
|
||||
if not is_instance_valid(dialog_manager):
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"No dialog manager called '%s' configured." % type
|
||||
)
|
||||
|
||||
_say_dialog_manager = dialog_manager
|
||||
|
||||
|
||||
# Loads the first dialog manager that supports the specified "choose" type; otherwise,
|
||||
# the engine throws an error and stops.
|
||||
#
|
||||
# #### Parameters
|
||||
# - type: The type the dialog manager should support, e.g. "simple"
|
||||
func _determine_choose_dialog_manager(type: String) -> void:
|
||||
var dialog_manager: ESCDialogManager = null
|
||||
|
||||
for _manager_class in ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.DIALOG_MANAGERS
|
||||
):
|
||||
if ResourceLoader.exists(_manager_class):
|
||||
var _manager: ESCDialogManager = load(_manager_class).new()
|
||||
if _manager.has_chooser_type(type):
|
||||
dialog_manager = _manager
|
||||
else:
|
||||
dialog_manager = null
|
||||
|
||||
if not is_instance_valid(dialog_manager):
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"No dialog manager called '%s' configured." % type
|
||||
)
|
||||
|
||||
_choose_dialog_manager = dialog_manager
|
||||
|
||||
|
||||
# If necessary, updates the dialog manager for the specified dialog type.
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - dialog_type: The type of dialog that will be managed, e.g. "say" or "choose"
|
||||
# - current_dialog_manager: The dialog manager currently being used (if any) for the specified
|
||||
# dialog type
|
||||
# - dialog_manager_type: The dialog manager type specific to the dialog manager being requested
|
||||
func _update_dialog_manager(dialog_type: String, current_dialog_manager: ESCDialogManager, \
|
||||
dialog_manager_type: String) -> void:
|
||||
|
||||
if is_instance_valid(current_dialog_manager):
|
||||
if not current_dialog_manager.has_type(dialog_manager_type):
|
||||
if is_a_parent_of(current_dialog_manager):
|
||||
remove_child(current_dialog_manager)
|
||||
|
||||
add_child(_determine_dialog_manager(dialog_type, dialog_manager_type))
|
||||
else:
|
||||
add_child(_determine_dialog_manager(dialog_type, dialog_manager_type))
|
||||
|
||||
|
||||
# Sets the requested dialog manager type for the specified dialog function.
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - dialog_type: The type of dialog that will be managed, e.g. "say" or "choose"
|
||||
# - dialog_manager_type: The dialog manager type specific to the dialog manager being requested
|
||||
#
|
||||
# *Returns* the newly-resolved dialog manager
|
||||
func _determine_dialog_manager(dialog_type: String, dialog_manager_type: String) -> ESCDialogManager:
|
||||
if dialog_type == DIALOG_TYPE_SAY:
|
||||
_determine_say_dialog_manager(dialog_manager_type)
|
||||
return _say_dialog_manager
|
||||
elif dialog_type == DIALOG_TYPE_CHOOSE:
|
||||
_determine_choose_dialog_manager(dialog_manager_type)
|
||||
return _choose_dialog_manager
|
||||
|
||||
# This line will never be hit as a failure above will result in an Escoria error
|
||||
return null
|
||||
|
||||
@@ -302,6 +302,14 @@ func set_escoria_debug_settings():
|
||||
}
|
||||
)
|
||||
|
||||
register_setting(
|
||||
ESCProjectSettingsManager.ENABLE_HOVER_STACK_VIEWER,
|
||||
false,
|
||||
{
|
||||
"type": TYPE_BOOL
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# Prepare the settings in the Escoria sound settings
|
||||
func set_escoria_sound_settings():
|
||||
|
||||
@@ -81,6 +81,13 @@ func _on_inventory_item_gui_input(event: InputEvent):
|
||||
global_id,
|
||||
event
|
||||
)
|
||||
# Make sure fast right clicks in the inventory aren't ignored
|
||||
elif event.button_index == BUTTON_RIGHT:
|
||||
emit_signal(
|
||||
"mouse_right_inventory_item",
|
||||
global_id,
|
||||
event
|
||||
)
|
||||
else:
|
||||
if event.is_pressed():
|
||||
if event.button_index == BUTTON_LEFT:
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
slot_ui_scene = ExtResource( 2 )
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
@@ -29,7 +32,7 @@ __meta__ = {
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
|
||||
margin_right = 623.0
|
||||
margin_bottom = 276.0
|
||||
margin_bottom = 336.0
|
||||
size_flags_vertical = 3
|
||||
scroll_horizontal_enabled = false
|
||||
__meta__ = {
|
||||
@@ -38,7 +41,7 @@ __meta__ = {
|
||||
|
||||
[node name="slots" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
|
||||
margin_right = 623.0
|
||||
margin_bottom = 276.0
|
||||
margin_bottom = 336.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
@@ -46,9 +49,9 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="back" type="Button" parent="VBoxContainer"]
|
||||
margin_top = 280.0
|
||||
margin_top = 340.0
|
||||
margin_right = 623.0
|
||||
margin_bottom = 300.0
|
||||
margin_bottom = 360.0
|
||||
text = "OPTIONS_BACK"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
|
||||
@@ -14,7 +14,7 @@ func _on_load_game_pressed():
|
||||
$load_game.show()
|
||||
|
||||
|
||||
# Show the optiset_gui_visible trueons panel
|
||||
# Show the options panel
|
||||
func _on_options_pressed():
|
||||
$main.hide()
|
||||
$options.show()
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="load_game" parent="." instance=ExtResource( 5 )]
|
||||
visible = false
|
||||
@@ -41,18 +44,18 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="main/main"]
|
||||
margin_top = 92.0
|
||||
margin_top = 162.0
|
||||
margin_right = 616.0
|
||||
margin_bottom = 318.0
|
||||
margin_bottom = 398.0
|
||||
texture = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="buttons" type="VBoxContainer" parent="main/main"]
|
||||
margin_top = 418.0
|
||||
margin_top = 498.0
|
||||
margin_right = 616.0
|
||||
margin_bottom = 658.0
|
||||
margin_bottom = 738.0
|
||||
custom_constants/separation = 10
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
|
||||
@@ -25,9 +25,9 @@ __meta__ = {
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"]
|
||||
margin_left = 391.0
|
||||
margin_top = 265.0
|
||||
margin_top = 340.0
|
||||
margin_right = 888.0
|
||||
margin_bottom = 460.0
|
||||
margin_bottom = 535.0
|
||||
size_flags_horizontal = 6
|
||||
custom_constants/margin_right = 20
|
||||
custom_constants/margin_top = 20
|
||||
@@ -144,9 +144,9 @@ margin_right = 457.0
|
||||
margin_bottom = 155.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_top = 464.0
|
||||
margin_top = 539.0
|
||||
margin_right = 1280.0
|
||||
margin_bottom = 404.0
|
||||
margin_bottom = 500
|
||||
custom_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
extends CanvasLayer
|
||||
|
||||
onready var list = $VBoxContainer/hover_stack
|
||||
|
||||
func update() -> void:
|
||||
for e in list.get_children():
|
||||
list.remove_child(e)
|
||||
e.queue_free()
|
||||
if escoria.inputs_manager.hover_stack.empty():
|
||||
return
|
||||
for e in escoria.inputs_manager.hover_stack.get_all():
|
||||
var l = Label.new()
|
||||
l.text = e.global_id
|
||||
list.add_child(l)
|
||||
@@ -0,0 +1,27 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/ui_library/tools/hover_stack/hover_stack.gd" type="Script" id=1]
|
||||
|
||||
[node name="hover_stack_layer" type="CanvasLayer"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_top = 32.0
|
||||
margin_right = 99.0
|
||||
margin_bottom = 72.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="title" type="RichTextLabel" parent="VBoxContainer"]
|
||||
margin_right = 99.0
|
||||
margin_bottom = 18.0
|
||||
size_flags_vertical = 3
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "[u]Hover stack[/u]"
|
||||
text = "Hover stack"
|
||||
|
||||
[node name="hover_stack" type="VBoxContainer" parent="VBoxContainer"]
|
||||
margin_top = 22.0
|
||||
margin_right = 99.0
|
||||
margin_bottom = 40.0
|
||||
size_flags_vertical = 3
|
||||
@@ -1,14 +1,28 @@
|
||||
# A simple dialog manager for Escoria
|
||||
extends ESCDialogManager
|
||||
class_name ESCDialogSimple
|
||||
|
||||
|
||||
# State machine that governs how the dialog manager behaves
|
||||
var state_machine = preload("res://addons/escoria-dialog-simple/esc_dialog_simple_state_machine.gd").new()
|
||||
|
||||
# The currently running player
|
||||
var _type_player: Node = null
|
||||
var _preserved_type_player_type: String = ""
|
||||
|
||||
# Reference to the dialog player
|
||||
var _dialog_player: Node = null
|
||||
|
||||
# Basic state tracking
|
||||
var _is_saying: bool = false
|
||||
|
||||
# Whether to preserve the next dialog box used by `say`, or, if already
|
||||
# preserving a dialog box, whether to continue using that dialog box
|
||||
var _should_preserve_dialog_box: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
add_child(state_machine)
|
||||
|
||||
|
||||
# Check whether a specific type is supported by the
|
||||
# dialog plugin
|
||||
@@ -30,6 +44,31 @@ func has_chooser_type(type: String) -> bool:
|
||||
return true if type == "simple" else false
|
||||
|
||||
|
||||
# Instructs the dialog manager to preserve the next dialog box used by a `say`
|
||||
# command until a call to `disable_preserve_dialog_box` is made.
|
||||
#
|
||||
# This method should be idempotent, i.e. if called after the first time and
|
||||
# prior to `disable_preserve_dialog_box` being called, the result should be the
|
||||
# same.
|
||||
func enable_preserve_dialog_box() -> void:
|
||||
_should_preserve_dialog_box = true
|
||||
|
||||
|
||||
# Instructs the dialog manager to no longer preserve the currently-preserved
|
||||
# dialog box or to not preserve the next dialog box used by a `say` command
|
||||
# (this is the default state).
|
||||
#
|
||||
# This method should be idempotent, i.e. if called after the first time and
|
||||
# prior to `enable_preserve_dialog_box` being called, the result should be the
|
||||
# same.
|
||||
func disable_preserve_dialog_box() -> void:
|
||||
_should_preserve_dialog_box = false
|
||||
|
||||
if is_instance_valid(_dialog_player) and _dialog_player.get_children().has(_type_player):
|
||||
_dialog_player.remove_child(_type_player)
|
||||
_preserved_type_player_type = ""
|
||||
|
||||
|
||||
# Output a text said by the item specified by the global id. Emit
|
||||
# `say_finished` after finishing displaying the text.
|
||||
#
|
||||
@@ -42,6 +81,40 @@ func has_chooser_type(type: String) -> bool:
|
||||
func say(dialog_player: Node, global_id: String, text: String, type: String):
|
||||
_dialog_player = dialog_player
|
||||
|
||||
_initialize_say_states(global_id, text, type)
|
||||
|
||||
if _should_preserve_dialog_box:
|
||||
# If the dialog box type doesn't match what's currently being reused (if anything),
|
||||
# we want to remove the old one (if it exists) and then initialize and add the new dialog
|
||||
# box type to the dialog player
|
||||
if type != _preserved_type_player_type:
|
||||
if _dialog_player.get_children().has(_type_player):
|
||||
_dialog_player.remove_child(_type_player)
|
||||
|
||||
_init_type_player(type)
|
||||
|
||||
_preserved_type_player_type = type
|
||||
else:
|
||||
_init_type_player(type)
|
||||
|
||||
state_machine._change_state("say")
|
||||
|
||||
# yield(_type_player, "say_finished")
|
||||
# if _dialog_player.get_children().has(_type_player):
|
||||
# _dialog_player.remove_child(_type_player)
|
||||
# emit_signal("say_finished")
|
||||
|
||||
|
||||
func do_say(global_id: String, text: String) -> void:
|
||||
# Only add_child here in order to prevent _type_player from running its _process method
|
||||
# before we're ready, and only if it's necessary
|
||||
if not _dialog_player.get_children().has(_type_player):
|
||||
_dialog_player.add_child(_type_player)
|
||||
|
||||
_type_player.say(global_id, text)
|
||||
|
||||
|
||||
func _init_type_player(type: String) -> void:
|
||||
if type == "floating":
|
||||
_type_player = preload(\
|
||||
"res://addons/escoria-dialog-simple/types/floating.tscn"\
|
||||
@@ -51,21 +124,26 @@ func say(dialog_player: Node, global_id: String, text: String, type: String):
|
||||
"res://addons/escoria-dialog-simple/types/avatar.tscn"\
|
||||
).instance()
|
||||
|
||||
_type_player.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
|
||||
_type_player.connect("say_visible", self, "_on_say_visible", [], CONNECT_ONESHOT)
|
||||
_type_player.connect("say_finished", self, "_on_say_finished")
|
||||
_type_player.connect("say_visible", self, "_on_say_visible")
|
||||
|
||||
_dialog_player.add_child(_type_player)
|
||||
_type_player.say(global_id, text)
|
||||
# yield(_type_player, "say_finished")
|
||||
# if _dialog_player.get_children().has(_type_player):
|
||||
# _dialog_player.remove_child(_type_player)
|
||||
# emit_signal("say_finished")
|
||||
|
||||
func _initialize_say_states(global_id: String, text: String, type: String) -> void:
|
||||
state_machine.states_map["say"].initialize(self, global_id, text, type)
|
||||
state_machine.states_map["finish"].initialize(_dialog_player)
|
||||
state_machine.states_map["say_fast"].initialize(self)
|
||||
state_machine.states_map["say_finish"].initialize(self)
|
||||
state_machine.states_map["visible"].initialize(self)
|
||||
state_machine.states_map["interrupt"].initialize(self)
|
||||
|
||||
|
||||
func _on_say_finished():
|
||||
if _dialog_player.get_children().has(_type_player):
|
||||
if not _should_preserve_dialog_box and _dialog_player.get_children().has(_type_player):
|
||||
_dialog_player.remove_child(_type_player)
|
||||
emit_signal("say_finished")
|
||||
|
||||
_is_saying = false
|
||||
|
||||
emit_signal("say_finished")
|
||||
|
||||
|
||||
func _on_say_visible():
|
||||
@@ -78,13 +156,26 @@ func _on_say_visible():
|
||||
# #### Parameters
|
||||
# - dialog_player: Node of the dialog player in the UI
|
||||
# - dialog: Information about the dialog to display
|
||||
func choose(dialog_player: Node, dialog: ESCDialog):
|
||||
var chooser = preload(\
|
||||
"res://addons/escoria-dialog-simple/chooser/simple.tscn"\
|
||||
).instance()
|
||||
# - type: The dialog chooser type to use
|
||||
func choose(dialog_player: Node, dialog: ESCDialog, type: String):
|
||||
_dialog_player = dialog_player
|
||||
|
||||
state_machine.states_map["choices"].initialize(dialog_player, self, dialog, type)
|
||||
state_machine._change_state("choices")
|
||||
|
||||
|
||||
func do_choose(dialog_player: Node, dialog: ESCDialog, type: String = "simple"):
|
||||
var chooser
|
||||
|
||||
if type == "simple" or type == "":
|
||||
chooser = preload(\
|
||||
"res://addons/escoria-dialog-simple/chooser/simple.tscn"\
|
||||
).instance()
|
||||
|
||||
dialog_player.add_child(chooser)
|
||||
chooser.set_dialog(dialog)
|
||||
chooser.show_chooser()
|
||||
|
||||
var option = yield(chooser, "option_chosen")
|
||||
dialog_player.remove_child(chooser)
|
||||
emit_signal("option_chosen", option)
|
||||
@@ -92,13 +183,13 @@ func choose(dialog_player: Node, dialog: ESCDialog):
|
||||
|
||||
# Trigger running the dialogue faster
|
||||
func speedup():
|
||||
if _type_player != null:
|
||||
if is_instance_valid(_type_player):
|
||||
_type_player.speedup()
|
||||
|
||||
|
||||
# Trigger an instant finish of the current dialog
|
||||
func finish():
|
||||
if _type_player != null:
|
||||
if is_instance_valid(_type_player):
|
||||
_type_player.finish()
|
||||
|
||||
|
||||
@@ -110,11 +201,13 @@ func interrupt():
|
||||
as ESCSpeechPlayer
|
||||
).set_state("off")
|
||||
|
||||
_dialog_player.remove_child(_type_player)
|
||||
if not _should_preserve_dialog_box and _dialog_player.get_children().has(_type_player):
|
||||
_dialog_player.remove_child(_type_player)
|
||||
|
||||
emit_signal("say_finished")
|
||||
|
||||
|
||||
# To be called if voice audio has finished.
|
||||
func voice_audio_finished():
|
||||
if _type_player != null:
|
||||
if is_instance_valid(_type_player):
|
||||
_type_player.voice_audio_finished()
|
||||
|
||||
20
addons/escoria-dialog-simple/esc_dialog_simple_settings.gd
Normal file
20
addons/escoria-dialog-simple/esc_dialog_simple_settings.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
extends Resource
|
||||
class_name SimpleDialogSettings
|
||||
|
||||
const SETTINGS_ROOT = "escoria/dialog_simple"
|
||||
|
||||
const AVATARS_PATH = "%s/avatars_path" % SETTINGS_ROOT
|
||||
const TEXT_TIME_PER_LETTER_MS = "%s/text_time_per_letter_ms" % SETTINGS_ROOT
|
||||
const TEXT_TIME_PER_LETTER_MS_FAST = "%s/text_time_per_fast_letter_ms" % SETTINGS_ROOT
|
||||
const READING_SPEED_IN_WPM = "%s/reading_speed_in_wpm" % SETTINGS_ROOT
|
||||
const CLEAR_TEXT_BY_CLICK_ONLY = "%s/clear_text_by_click_only" % SETTINGS_ROOT
|
||||
const LEFT_CLICK_ACTION = "%s/left_click_action" % SETTINGS_ROOT
|
||||
|
||||
const STOP_TALKING_ANIMATION_ON = "%s/stop_talking_animation_on" % SETTINGS_ROOT
|
||||
|
||||
const LEFT_CLICK_ACTION_SPEED_UP = "Speed up"
|
||||
const LEFT_CLICK_ACTION_INSTANT_FINISH = "Instant finish"
|
||||
const LEFT_CLICK_ACTION_NOTHING = "None"
|
||||
|
||||
const STOP_TALKING_ANIMATION_ON_END_OF_TEXT = "End of text"
|
||||
const STOP_TALKING_ANIMATION_ON_END_OF_AUDIO = "End of audio"
|
||||
@@ -0,0 +1,31 @@
|
||||
extends "res://addons/escoria-dialog-simple/patterns/state_machine/state_machine.gd"
|
||||
|
||||
|
||||
func _init():
|
||||
_create_states()
|
||||
_add_states_to_machine()
|
||||
|
||||
current_state_name = "idle"
|
||||
START_STATE = states_map[current_state_name]
|
||||
|
||||
initialize(START_STATE)
|
||||
|
||||
|
||||
# Creates the states for this state machine.
|
||||
func _create_states() -> void:
|
||||
states_map = {
|
||||
"idle": preload("res://addons/escoria-dialog-simple/states/dialog_idle.gd").new(),
|
||||
"say": preload("res://addons/escoria-dialog-simple/states/dialog_say.gd").new(),
|
||||
"say_fast": preload("res://addons/escoria-dialog-simple/states/dialog_say_fast.gd").new(),
|
||||
"say_finish": preload("res://addons/escoria-dialog-simple/states/dialog_say_finish.gd").new(),
|
||||
"visible": preload("res://addons/escoria-dialog-simple/states/dialog_visible.gd").new(),
|
||||
"finish": preload("res://addons/escoria-dialog-simple/states/dialog_finish.gd").new(),
|
||||
"interrupt": preload("res://addons/escoria-dialog-simple/states/dialog_interrupt.gd").new(),
|
||||
"choices": preload("res://addons/escoria-dialog-simple/states/dialog_choices.gd").new(),
|
||||
}
|
||||
|
||||
|
||||
# Adds any created states into the state machine as children.
|
||||
func _add_states_to_machine() -> void:
|
||||
for key in states_map:
|
||||
add_child(states_map[key])
|
||||
31
addons/escoria-dialog-simple/patterns/state_machine/state.gd
Normal file
31
addons/escoria-dialog-simple/patterns/state_machine/state.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
Base interface for all states: it doesn't do anything in itself
|
||||
but forces us to pass the right arguments to the methods below
|
||||
and makes sure every State object had all of these methods.
|
||||
"""
|
||||
extends Node
|
||||
|
||||
|
||||
signal finished(next_state_name)
|
||||
|
||||
|
||||
# Initialize the state. E.g. change the animation
|
||||
func enter():
|
||||
return
|
||||
|
||||
|
||||
# Clean up the state. Reinitialize values like a timer
|
||||
func exit():
|
||||
return
|
||||
|
||||
|
||||
func handle_input(_event):
|
||||
return
|
||||
|
||||
|
||||
func update(_delta):
|
||||
return
|
||||
|
||||
|
||||
func _on_animation_finished(_anim_name):
|
||||
return
|
||||
@@ -0,0 +1,92 @@
|
||||
"""
|
||||
Base interface for a generic state machine
|
||||
It handles initializing, setting the machine active or not
|
||||
delegating _physics_process, _input calls to the State nodes,
|
||||
and changing the current/active state.
|
||||
"""
|
||||
extends Node
|
||||
|
||||
|
||||
signal state_changed(current_state)
|
||||
|
||||
|
||||
"""
|
||||
You must set a starting node from the inspector or on
|
||||
the node that inherits from this state machine interface
|
||||
If you don't the game will crash (on purpose, so you won't
|
||||
forget to initialize the state machine)
|
||||
"""
|
||||
export(NodePath) var START_STATE
|
||||
var states_map = {}
|
||||
|
||||
var states_stack = [] # can also be used as a pushdown automaton
|
||||
var current_state = null
|
||||
var current_state_name = ""
|
||||
var _active = false setget set_active
|
||||
|
||||
|
||||
func initialize(start_state):
|
||||
for child in get_children():
|
||||
child.connect("finished", self, "_change_state")
|
||||
|
||||
set_active(true)
|
||||
states_stack.push_front(start_state)
|
||||
current_state = states_stack[0]
|
||||
current_state.enter()
|
||||
|
||||
|
||||
func set_active(value):
|
||||
_active = value
|
||||
set_physics_process(value)
|
||||
set_process_input(value)
|
||||
if not _active:
|
||||
states_stack = []
|
||||
current_state = null
|
||||
|
||||
|
||||
func _input(event):
|
||||
current_state.handle_input(event)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
current_state.update(delta)
|
||||
|
||||
|
||||
func _on_animation_finished(anim_name):
|
||||
if not _active:
|
||||
return
|
||||
current_state._on_animation_finished(anim_name)
|
||||
|
||||
|
||||
func _change_state(state_name):
|
||||
if not _active:
|
||||
return
|
||||
|
||||
escoria.logger.trace(
|
||||
self,
|
||||
"Dialog State Machine: Changing state from '%s' to '%s'." % [current_state_name, state_name]
|
||||
)
|
||||
|
||||
current_state.exit()
|
||||
|
||||
if state_name == "previous":
|
||||
states_stack.pop_front()
|
||||
else:
|
||||
states_stack[0] = states_map[state_name]
|
||||
|
||||
current_state = states_stack[0]
|
||||
|
||||
emit_signal("state_changed", current_state)
|
||||
|
||||
#if state_name != "previous":
|
||||
current_state.enter()
|
||||
|
||||
current_state_name = state_name
|
||||
|
||||
|
||||
func get_current_state_name():
|
||||
for key in states_map.keys():
|
||||
if states_map[key] == current_state:
|
||||
return key
|
||||
|
||||
return null
|
||||
@@ -1,26 +1,8 @@
|
||||
# A simple dialog manager for Escoria
|
||||
tool
|
||||
extends EditorPlugin
|
||||
class_name SimpleDialogPlugin
|
||||
|
||||
|
||||
const MANAGER_CLASS="res://addons/escoria-dialog-simple/esc_dialog_simple.gd"
|
||||
const SETTINGS_ROOT="escoria/dialog_simple"
|
||||
|
||||
const AVATARS_PATH = "%s/avatars_path" % SETTINGS_ROOT
|
||||
const TEXT_TIME_PER_LETTER_MS = "%s/text_time_per_letter_ms" % SETTINGS_ROOT
|
||||
const TEXT_TIME_PER_LETTER_MS_FAST = "%s/text_time_per_fast_letter_ms" % SETTINGS_ROOT
|
||||
const READING_SPEED_IN_WPM = "%s/reading_speed_in_wpm" % SETTINGS_ROOT
|
||||
const CLEAR_TEXT_BY_CLICK_ONLY = "%s/clear_text_by_click_only" % SETTINGS_ROOT
|
||||
const LEFT_CLICK_ACTION = "%s/left_click_action" % SETTINGS_ROOT
|
||||
const STOP_TALKING_ANIMATION_ON = "%s/stop_talking_animation_on" % SETTINGS_ROOT
|
||||
|
||||
const LEFT_CLICK_ACTION_SPEED_UP = "Speed up"
|
||||
const LEFT_CLICK_ACTION_INSTANT_FINISH = "Instant finish"
|
||||
const LEFT_CLICK_ACTION_NOTHING = "None"
|
||||
|
||||
const STOP_TALKING_ANIMATION_ON_END_OF_TEXT = "End of text"
|
||||
const STOP_TALKING_ANIMATION_ON_END_OF_AUDIO = "End of audio"
|
||||
const MANAGER_CLASS = "res://addons/escoria-dialog-simple/esc_dialog_simple.gd"
|
||||
|
||||
const READING_SPEED_IN_WPM_DEFAULT_VALUE = 200
|
||||
const TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE = 100
|
||||
@@ -28,14 +10,14 @@ const TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE = 25
|
||||
|
||||
|
||||
var left_click_actions: PoolStringArray = [
|
||||
LEFT_CLICK_ACTION_SPEED_UP,
|
||||
LEFT_CLICK_ACTION_INSTANT_FINISH,
|
||||
LEFT_CLICK_ACTION_NOTHING
|
||||
SimpleDialogSettings.LEFT_CLICK_ACTION_SPEED_UP,
|
||||
SimpleDialogSettings.LEFT_CLICK_ACTION_INSTANT_FINISH,
|
||||
SimpleDialogSettings.LEFT_CLICK_ACTION_NOTHING
|
||||
]
|
||||
|
||||
var stop_talking_animation_on_options: PoolStringArray = [
|
||||
STOP_TALKING_ANIMATION_ON_END_OF_TEXT,
|
||||
STOP_TALKING_ANIMATION_ON_END_OF_AUDIO
|
||||
SimpleDialogSettings.STOP_TALKING_ANIMATION_ON_END_OF_TEXT,
|
||||
SimpleDialogSettings.STOP_TALKING_ANIMATION_ON_END_OF_AUDIO
|
||||
]
|
||||
|
||||
|
||||
@@ -52,31 +34,31 @@ func disable_plugin():
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.remove_setting(
|
||||
AVATARS_PATH
|
||||
SimpleDialogSettings.AVATARS_PATH
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.remove_setting(
|
||||
TEXT_TIME_PER_LETTER_MS
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.remove_setting(
|
||||
TEXT_TIME_PER_LETTER_MS_FAST
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.remove_setting(
|
||||
CLEAR_TEXT_BY_CLICK_ONLY
|
||||
SimpleDialogSettings.CLEAR_TEXT_BY_CLICK_ONLY
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.remove_setting(
|
||||
READING_SPEED_IN_WPM
|
||||
SimpleDialogSettings.READING_SPEED_IN_WPM
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.remove_setting(
|
||||
LEFT_CLICK_ACTION
|
||||
SimpleDialogSettings.LEFT_CLICK_ACTION
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.remove_setting(
|
||||
STOP_TALKING_ANIMATION_ON
|
||||
SimpleDialogSettings.STOP_TALKING_ANIMATION_ON
|
||||
)
|
||||
|
||||
EscoriaPlugin.deregister_dialog_manager(MANAGER_CLASS)
|
||||
@@ -96,7 +78,7 @@ func enable_plugin():
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.register_setting(
|
||||
AVATARS_PATH,
|
||||
SimpleDialogSettings.AVATARS_PATH,
|
||||
"res://game/dialog_avatars",
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
@@ -105,7 +87,7 @@ func enable_plugin():
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.register_setting(
|
||||
TEXT_TIME_PER_LETTER_MS,
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS,
|
||||
TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE,
|
||||
{
|
||||
"type": TYPE_REAL
|
||||
@@ -113,7 +95,7 @@ func enable_plugin():
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.register_setting(
|
||||
TEXT_TIME_PER_LETTER_MS_FAST,
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST,
|
||||
TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE,
|
||||
{
|
||||
"type": TYPE_REAL
|
||||
@@ -121,7 +103,7 @@ func enable_plugin():
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.register_setting(
|
||||
CLEAR_TEXT_BY_CLICK_ONLY,
|
||||
SimpleDialogSettings.CLEAR_TEXT_BY_CLICK_ONLY,
|
||||
false,
|
||||
{
|
||||
"type": TYPE_BOOL
|
||||
@@ -129,7 +111,7 @@ func enable_plugin():
|
||||
)
|
||||
|
||||
ESCProjectSettingsManager.register_setting(
|
||||
READING_SPEED_IN_WPM,
|
||||
SimpleDialogSettings.READING_SPEED_IN_WPM,
|
||||
READING_SPEED_IN_WPM_DEFAULT_VALUE,
|
||||
{
|
||||
"type": TYPE_INT
|
||||
@@ -139,8 +121,8 @@ func enable_plugin():
|
||||
var left_click_actions_string: String = left_click_actions.join(",")
|
||||
|
||||
ESCProjectSettingsManager.register_setting(
|
||||
LEFT_CLICK_ACTION,
|
||||
LEFT_CLICK_ACTION_SPEED_UP,
|
||||
SimpleDialogSettings.LEFT_CLICK_ACTION,
|
||||
SimpleDialogSettings.LEFT_CLICK_ACTION_SPEED_UP,
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_ENUM,
|
||||
@@ -151,8 +133,8 @@ func enable_plugin():
|
||||
var stop_talking_animation_on_options_string: String = stop_talking_animation_on_options.join(",")
|
||||
|
||||
ESCProjectSettingsManager.register_setting(
|
||||
STOP_TALKING_ANIMATION_ON,
|
||||
STOP_TALKING_ANIMATION_ON_END_OF_AUDIO,
|
||||
SimpleDialogSettings.STOP_TALKING_ANIMATION_ON,
|
||||
SimpleDialogSettings.STOP_TALKING_ANIMATION_ON_END_OF_AUDIO,
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_ENUM,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
extends State
|
||||
class_name DialogChoices
|
||||
extends "res://addons/escoria-dialog-simple/patterns/state_machine/state.gd"
|
||||
|
||||
|
||||
# The owning dialog player.
|
||||
@@ -14,8 +13,9 @@ var _dialog_chooser_ui: ESCDialogManager = null
|
||||
var _ready_to_choose: bool
|
||||
|
||||
|
||||
func initialize(dialog_player, dialog: ESCDialog, type: String) -> void:
|
||||
func initialize(dialog_player, dialog_chooser_ui: ESCDialogManager, dialog: ESCDialog, type: String) -> void:
|
||||
_dialog_player = dialog_player
|
||||
_dialog_chooser_ui = dialog_chooser_ui
|
||||
_dialog = dialog
|
||||
_type = type
|
||||
|
||||
@@ -29,27 +29,13 @@ func enter():
|
||||
"Received dialog options array was empty."
|
||||
)
|
||||
|
||||
for _manager_class in ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.DIALOG_MANAGERS
|
||||
):
|
||||
if ResourceLoader.exists(_manager_class):
|
||||
var _manager: ESCDialogManager = load(_manager_class).new()
|
||||
if _manager.has_chooser_type(_type):
|
||||
_dialog_chooser_ui = _manager
|
||||
|
||||
if _dialog_chooser_ui == null:
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"No dialog manager supports the chooser type %s." % _type
|
||||
)
|
||||
|
||||
_ready_to_choose = true
|
||||
|
||||
|
||||
func update(_delta):
|
||||
if _ready_to_choose:
|
||||
_ready_to_choose = false
|
||||
_dialog_chooser_ui.choose(self, _dialog)
|
||||
_dialog_chooser_ui.do_choose(_dialog_player, _dialog, _type)
|
||||
var option = yield(_dialog_chooser_ui, "option_chosen")
|
||||
|
||||
escoria.logger.trace(self, "Dialog State Machine: 'choices' -> 'idle'")
|
||||
@@ -1,5 +1,4 @@
|
||||
extends State
|
||||
class_name DialogFinish
|
||||
extends "res://addons/escoria-dialog-simple/patterns/state_machine/state.gd"
|
||||
|
||||
|
||||
# Owning dialog player
|
||||
@@ -1,5 +1,4 @@
|
||||
extends State
|
||||
class_name DialogIdle
|
||||
extends "res://addons/escoria-dialog-simple/patterns/state_machine/state.gd"
|
||||
|
||||
|
||||
func enter():
|
||||
@@ -1,5 +1,4 @@
|
||||
extends State
|
||||
class_name DialogInterrupt
|
||||
extends "res://addons/escoria-dialog-simple/patterns/state_machine/state.gd"
|
||||
|
||||
|
||||
# Reference to the currently playing dialog manager
|
||||
@@ -15,7 +14,7 @@ func enter():
|
||||
|
||||
if _dialog_manager != null:
|
||||
if not _dialog_manager.is_connected("say_finished", self, "_on_say_finished"):
|
||||
_dialog_manager.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
|
||||
_dialog_manager.connect("say_finished", self, "_on_say_finished")
|
||||
|
||||
_dialog_manager.interrupt()
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
extends State
|
||||
class_name DialogSay
|
||||
|
||||
|
||||
signal dialog_manager_set(dialog_manager)
|
||||
extends "res://addons/escoria-dialog-simple/patterns/state_machine/state.gd"
|
||||
|
||||
|
||||
# A regular expression that separates the translation key from the text
|
||||
@@ -34,12 +30,13 @@ func _init() -> void:
|
||||
_keytext_regex.compile(KEYTEXT_REGEX)
|
||||
|
||||
|
||||
func initialize(character: String, type: String, text: String) -> void:
|
||||
func initialize(dialog_manager: ESCDialogManager, character: String, text: String, type: String) -> void:
|
||||
_dialog_manager = dialog_manager
|
||||
_character = character
|
||||
_type = type
|
||||
_text = text
|
||||
_type = type
|
||||
_stop_talking_animation_on_option = \
|
||||
ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.STOP_TALKING_ANIMATION_ON)
|
||||
ESCProjectSettingsManager.get_setting(SimpleDialogSettings.STOP_TALKING_ANIMATION_ON)
|
||||
|
||||
|
||||
func handle_input(_event):
|
||||
@@ -48,20 +45,20 @@ func handle_input(_event):
|
||||
escoria.inputs_manager.INPUT_NONE and \
|
||||
_dialog_manager != null:
|
||||
|
||||
var left_click_action = ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.LEFT_CLICK_ACTION)
|
||||
var left_click_action = ESCProjectSettingsManager.get_setting(SimpleDialogSettings.LEFT_CLICK_ACTION)
|
||||
|
||||
_handle_left_click_action(left_click_action)
|
||||
|
||||
|
||||
func _handle_left_click_action(left_click_action: String) -> void:
|
||||
match left_click_action:
|
||||
SimpleDialogPlugin.LEFT_CLICK_ACTION_SPEED_UP:
|
||||
SimpleDialogSettings.LEFT_CLICK_ACTION_SPEED_UP:
|
||||
if _dialog_manager.is_connected("say_visible", self, "_on_say_visible"):
|
||||
_dialog_manager.disconnect("say_visible", self, "_on_say_visible")
|
||||
|
||||
escoria.logger.trace(self, "Dialog State Machine: 'say' -> 'say_fast'")
|
||||
emit_signal("finished", "say_fast")
|
||||
SimpleDialogPlugin.LEFT_CLICK_ACTION_INSTANT_FINISH:
|
||||
SimpleDialogSettings.LEFT_CLICK_ACTION_INSTANT_FINISH:
|
||||
if _dialog_manager.is_connected("say_visible", self, "_on_say_visible"):
|
||||
_dialog_manager.disconnect("say_visible", self, "_on_say_visible")
|
||||
|
||||
@@ -74,34 +71,8 @@ func _handle_left_click_action(left_click_action: String) -> void:
|
||||
func enter():
|
||||
escoria.logger.trace(self, "Dialog State Machine: Entered 'say'.")
|
||||
|
||||
if _type == "":
|
||||
_type = ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.DEFAULT_DIALOG_TYPE
|
||||
)
|
||||
|
||||
var dialog_manager: ESCDialogManager = null
|
||||
|
||||
for _manager_class in ESCProjectSettingsManager.get_setting(
|
||||
ESCProjectSettingsManager.DIALOG_MANAGERS
|
||||
):
|
||||
if ResourceLoader.exists(_manager_class):
|
||||
var _manager: ESCDialogManager = load(_manager_class).new()
|
||||
if _manager.has_type(_type):
|
||||
dialog_manager = _manager
|
||||
else:
|
||||
dialog_manager = null
|
||||
|
||||
if dialog_manager == null:
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"No dialog manager called '%s' configured." % _type
|
||||
)
|
||||
|
||||
_dialog_manager = dialog_manager
|
||||
emit_signal("dialog_manager_set", dialog_manager)
|
||||
|
||||
if not _dialog_manager.is_connected("say_visible", self, "_on_say_visible"):
|
||||
_dialog_manager.connect("say_visible", self, "_on_say_visible", [], CONNECT_ONESHOT)
|
||||
_dialog_manager.connect("say_visible", self, "_on_say_visible")
|
||||
|
||||
var matches = _keytext_regex.search(_text)
|
||||
|
||||
@@ -129,11 +100,16 @@ func enter():
|
||||
as ESCSpeechPlayer
|
||||
).set_state(_speech_resource)
|
||||
|
||||
if _stop_talking_animation_on_option == SimpleDialogPlugin.STOP_TALKING_ANIMATION_ON_END_OF_AUDIO:
|
||||
(
|
||||
if _stop_talking_animation_on_option == SimpleDialogSettings.STOP_TALKING_ANIMATION_ON_END_OF_AUDIO:
|
||||
if not (
|
||||
escoria.object_manager.get_object(escoria.object_manager.SPEECH).node\
|
||||
as ESCSpeechPlayer
|
||||
).stream.connect("finished", self, "_on_audio_finished", [], CONNECT_ONESHOT)
|
||||
).stream.is_connected("finished", self, "_on_audio_finished"):
|
||||
|
||||
(
|
||||
escoria.object_manager.get_object(escoria.object_manager.SPEECH).node\
|
||||
as ESCSpeechPlayer
|
||||
).stream.connect("finished", self, "_on_audio_finished")
|
||||
|
||||
var translated_text: String = tr(matches.get_string("key"))
|
||||
|
||||
@@ -155,7 +131,7 @@ func enter():
|
||||
|
||||
func update(_delta):
|
||||
if _ready_to_say:
|
||||
_dialog_manager.say(self, _character, _text, _type)
|
||||
_dialog_manager.do_say(_character, _text)
|
||||
_ready_to_say = false
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
extends State
|
||||
class_name DialogSayFast
|
||||
extends "res://addons/escoria-dialog-simple/patterns/state_machine/state.gd"
|
||||
|
||||
|
||||
# Reference to the currently playing dialog manager
|
||||
@@ -18,7 +17,7 @@ func enter():
|
||||
_dialog_manager != null:
|
||||
|
||||
if not _dialog_manager.is_connected("say_visible", self, "_on_say_visible"):
|
||||
_dialog_manager.connect("say_visible", self, "_on_say_visible", [], CONNECT_ONESHOT)
|
||||
_dialog_manager.connect("say_visible", self, "_on_say_visible")
|
||||
|
||||
_dialog_manager.speedup()
|
||||
else:
|
||||
@@ -1,5 +1,4 @@
|
||||
extends State
|
||||
class_name DialogSayFinish
|
||||
extends "res://addons/escoria-dialog-simple/patterns/state_machine/state.gd"
|
||||
|
||||
|
||||
# Reference to the currently playing dialog manager
|
||||
@@ -18,7 +17,7 @@ func enter():
|
||||
_dialog_manager != null:
|
||||
|
||||
if not _dialog_manager.is_connected("say_visible", self, "_on_say_visible"):
|
||||
_dialog_manager.connect("say_visible", self, "_on_say_visible", [], CONNECT_ONESHOT)
|
||||
_dialog_manager.connect("say_visible", self, "_on_say_visible")
|
||||
|
||||
_dialog_manager.finish()
|
||||
else:
|
||||
@@ -1,5 +1,4 @@
|
||||
extends State
|
||||
class_name DialogVisible
|
||||
extends "res://addons/escoria-dialog-simple/patterns/state_machine/state.gd"
|
||||
|
||||
|
||||
# Reference to the currently playing dialog manager
|
||||
@@ -14,7 +13,7 @@ func enter():
|
||||
escoria.logger.trace(self, "Dialog State Machine: Entered 'visible'.")
|
||||
|
||||
if not _dialog_manager.is_connected("say_finished", self, "_on_say_finished"):
|
||||
_dialog_manager.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
|
||||
_dialog_manager.connect("say_finished", self, "_on_say_finished")
|
||||
|
||||
|
||||
func handle_input(_event):
|
||||
@@ -47,7 +47,7 @@ onready var is_paused: bool = true
|
||||
# Build up the UI
|
||||
func _ready():
|
||||
_text_time_per_character = ProjectSettings.get_setting(
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS
|
||||
)
|
||||
|
||||
if _text_time_per_character < 0:
|
||||
@@ -55,15 +55,15 @@ func _ready():
|
||||
self,
|
||||
"%s setting must be a non-negative number. Will use default value of %s." %
|
||||
[
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS,
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS,
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
]
|
||||
)
|
||||
|
||||
_text_time_per_character = SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
_text_time_per_character = SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
|
||||
_fast_text_time_per_character = ProjectSettings.get_setting(
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST
|
||||
)
|
||||
|
||||
if _fast_text_time_per_character < 0:
|
||||
@@ -71,15 +71,15 @@ func _ready():
|
||||
self,
|
||||
"%s setting must be a non-negative number. Will use default value of %s." %
|
||||
[
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST,
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST,
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
]
|
||||
)
|
||||
|
||||
_fast_text_time_per_character = SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
_fast_text_time_per_character = SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
|
||||
_reading_speed_in_wpm = ProjectSettings.get_setting(
|
||||
SimpleDialogPlugin.READING_SPEED_IN_WPM
|
||||
SimpleDialogSettings.READING_SPEED_IN_WPM
|
||||
)
|
||||
|
||||
if _reading_speed_in_wpm <= 0:
|
||||
@@ -87,12 +87,12 @@ func _ready():
|
||||
self,
|
||||
"%s setting must be a positive number. Will use default value of %s." %
|
||||
[
|
||||
SimpleDialogPlugin.READING_SPEED_IN_WPM,
|
||||
SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
SimpleDialogSettings.READING_SPEED_IN_WPM,
|
||||
SimpleDialogSettings.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
]
|
||||
)
|
||||
|
||||
_reading_speed_in_wpm = SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
_reading_speed_in_wpm = SimpleDialogSettings.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
|
||||
_word_regex.compile("\\S+")
|
||||
|
||||
@@ -106,6 +106,8 @@ func _ready():
|
||||
escoria.connect("paused", self, "_on_paused")
|
||||
escoria.connect("resumed", self, "_on_resumed")
|
||||
|
||||
connect("tree_exited", self, "_on_tree_exited")
|
||||
|
||||
|
||||
# Switch the current character
|
||||
#
|
||||
@@ -191,8 +193,11 @@ func _on_dialog_line_typed(object, key):
|
||||
text_node.visible_characters = -1
|
||||
|
||||
var time_to_disappear: float = _calculate_time_to_disappear()
|
||||
|
||||
if not $Timer.is_connected("timeout", self, "_on_dialog_finished"):
|
||||
$Timer.connect("timeout", self, "_on_dialog_finished")
|
||||
|
||||
$Timer.start(time_to_disappear)
|
||||
$Timer.connect("timeout", self, "_on_dialog_finished")
|
||||
|
||||
emit_signal("say_visible")
|
||||
|
||||
@@ -207,10 +212,11 @@ func _get_number_of_words() -> int:
|
||||
|
||||
# Ending the dialog
|
||||
func _on_dialog_finished():
|
||||
$Timer.stop()
|
||||
|
||||
# Only trigger to clear the text if we aren't limiting the clearing trigger to a click.
|
||||
if not ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
|
||||
if not ESCProjectSettingsManager.get_setting(SimpleDialogSettings.CLEAR_TEXT_BY_CLICK_ONLY):
|
||||
emit_signal("say_finished")
|
||||
queue_free()
|
||||
|
||||
|
||||
# Handler managing pause notification from Escoria
|
||||
@@ -223,7 +229,14 @@ func _on_paused():
|
||||
# Handler managing resume notification from Escoria
|
||||
func _on_resumed():
|
||||
if not tween.is_active():
|
||||
# We can't rely on "show()" to make an invisible popup reappear, as per the docs for
|
||||
# CanvasItem. Instead, we need to use one of the popup_* methods.
|
||||
if is_inside_tree():
|
||||
popup_centered()
|
||||
|
||||
is_paused = false
|
||||
tween.resume_all()
|
||||
|
||||
|
||||
func _on_tree_exited():
|
||||
queue_free()
|
||||
|
||||
@@ -46,7 +46,7 @@ onready var is_paused: bool = true
|
||||
# Enable bbcode and catch the signal when a tween completed
|
||||
func _ready():
|
||||
_text_time_per_character = ProjectSettings.get_setting(
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS
|
||||
)
|
||||
|
||||
if _text_time_per_character < 0:
|
||||
@@ -54,15 +54,15 @@ func _ready():
|
||||
self,
|
||||
"%s setting must be a non-negative number. Will use default value of %s." %
|
||||
[
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS,
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS,
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
]
|
||||
)
|
||||
|
||||
_text_time_per_character = SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
_text_time_per_character = SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
|
||||
_fast_text_time_per_character = ProjectSettings.get_setting(
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST
|
||||
)
|
||||
|
||||
if _fast_text_time_per_character < 0:
|
||||
@@ -70,15 +70,15 @@ func _ready():
|
||||
self,
|
||||
"%s setting must be a non-negative number. Will use default value of %s." %
|
||||
[
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST,
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST,
|
||||
SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
]
|
||||
)
|
||||
|
||||
_fast_text_time_per_character = SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
_fast_text_time_per_character = SimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
|
||||
_reading_speed_in_wpm = ProjectSettings.get_setting(
|
||||
SimpleDialogPlugin.READING_SPEED_IN_WPM
|
||||
SimpleDialogSettings.READING_SPEED_IN_WPM
|
||||
)
|
||||
|
||||
if _reading_speed_in_wpm <= 0:
|
||||
@@ -86,12 +86,12 @@ func _ready():
|
||||
self,
|
||||
"%s setting must be a positive number. Will use default value of %s." %
|
||||
[
|
||||
SimpleDialogPlugin.READING_SPEED_IN_WPM,
|
||||
SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
SimpleDialogSettings.READING_SPEED_IN_WPM,
|
||||
SimpleDialogSettings.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
]
|
||||
)
|
||||
|
||||
_reading_speed_in_wpm = SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
_reading_speed_in_wpm = SimpleDialogSettings.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
|
||||
_word_regex.compile("\\S+")
|
||||
|
||||
@@ -114,14 +114,9 @@ func _process(delta):
|
||||
.get_global_transform_with_canvas().origin
|
||||
rect_position.x -= rect_size.x / 2
|
||||
|
||||
if rect_position.x < 0:
|
||||
rect_position.x = 0
|
||||
_account_for_margin_x()
|
||||
|
||||
var screen_margin = rect_position.x + rect_size.x - \
|
||||
ProjectSettings.get("display/window/size/width")
|
||||
|
||||
if screen_margin > 0:
|
||||
rect_position.x -= screen_margin
|
||||
_account_for_margin_y()
|
||||
|
||||
|
||||
# Make a character say something
|
||||
@@ -156,14 +151,9 @@ func say(character: String, line: String) :
|
||||
rect_position.x = 0
|
||||
rect_size.x = ProjectSettings.get_setting("display/window/size/width")
|
||||
|
||||
if rect_position.x < 0:
|
||||
rect_position.x = 0
|
||||
_account_for_margin_x()
|
||||
|
||||
var screen_margin = rect_position.x + rect_size.x - \
|
||||
ProjectSettings.get("display/window/size/width")
|
||||
|
||||
if screen_margin > 0:
|
||||
rect_position.x -= screen_margin
|
||||
_account_for_margin_y()
|
||||
|
||||
_current_character.start_talking()
|
||||
|
||||
@@ -227,7 +217,7 @@ func _get_number_of_words() -> int:
|
||||
# Ending the dialog
|
||||
func _on_dialog_finished():
|
||||
# Only trigger to clear the text if we aren't limiting the clearing trigger to a click.
|
||||
if not ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
|
||||
if not ESCProjectSettingsManager.get_setting(SimpleDialogSettings.CLEAR_TEXT_BY_CLICK_ONLY):
|
||||
emit_signal("say_finished")
|
||||
|
||||
|
||||
@@ -254,3 +244,25 @@ func _stop_character_talking():
|
||||
# Make the speaking item animation stop talking, if it is still alive
|
||||
if is_instance_valid(_current_character) and _current_character != null:
|
||||
_current_character.stop_talking()
|
||||
|
||||
|
||||
func _account_for_margin_x() -> void:
|
||||
if rect_position.x < 0:
|
||||
rect_position.x = 0
|
||||
|
||||
var screen_margin_x = rect_position.x + rect_size.x - \
|
||||
ProjectSettings.get("display/window/size/width")
|
||||
|
||||
if screen_margin_x > 0:
|
||||
rect_position.x -= screen_margin_x
|
||||
|
||||
|
||||
func _account_for_margin_y() -> void:
|
||||
if rect_position.y < 0:
|
||||
rect_position.y = 0
|
||||
|
||||
var screen_margin_y = rect_position.y + rect_size.y - \
|
||||
ProjectSettings.get("display/window/size/height")
|
||||
|
||||
if screen_margin_y > 0:
|
||||
rect_position.y -= screen_margin_y
|
||||
|
||||
@@ -53,7 +53,7 @@ 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 \
|
||||
if ProjectSettings.get_setting(ESCProjectSettingsManager.ENABLE_ROOM_SELECTOR) and \
|
||||
room_selector_parent.get_node_or_null("room_select") == null:
|
||||
room_select = preload(
|
||||
"res://addons/escoria-core/ui_library/tools/room_select" +\
|
||||
@@ -121,7 +121,6 @@ func element_focused(element_id: String) -> void:
|
||||
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_ITEM:
|
||||
tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
|
||||
@@ -244,6 +244,9 @@ func left_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
[item_global_id, event],
|
||||
true
|
||||
)
|
||||
|
||||
$mouse_layer/verbs_menu.clear_tool_texture()
|
||||
|
||||
func right_click_on_item(item_global_id: String, event: InputEvent) -> void:
|
||||
mousewheel_action(1)
|
||||
|
||||
@@ -398,7 +401,6 @@ func _on_action_finished():
|
||||
func _on_event_done(_return_code: int, _event_name: String):
|
||||
if _return_code == ESCExecution.RC_OK:
|
||||
escoria.action_manager.clear_current_action()
|
||||
$mouse_layer/verbs_menu.clear_tool_texture()
|
||||
$tooltip_layer/tooltip.set_target("")
|
||||
|
||||
|
||||
|
||||
@@ -35,16 +35,15 @@ __meta__ = {
|
||||
anchor_top = 0.9
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme = ExtResource( 9 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/ui"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
@@ -54,6 +53,7 @@ __meta__ = {
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/ui/HBoxContainer"]
|
||||
margin_right = 58.0
|
||||
margin_bottom = 90.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="MenuButton" type="Button" parent="CanvasLayer/ui/HBoxContainer/VBoxContainer"]
|
||||
margin_right = 58.0
|
||||
@@ -64,6 +64,7 @@ text = "Menu"
|
||||
margin_left = 62.0
|
||||
margin_right = 1186.0
|
||||
margin_bottom = 90.0
|
||||
mouse_filter = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="inventory_ui" parent="CanvasLayer/ui/HBoxContainer" instance=ExtResource( 1 )]
|
||||
|
||||
@@ -61,6 +61,7 @@ anchor_bottom = 1.0
|
||||
margin_left = -516.0
|
||||
margin_top = -160.0
|
||||
rect_min_size = Vector2( 0, 160 )
|
||||
mouse_filter = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
texture = ExtResource( 2 )
|
||||
@@ -72,27 +73,27 @@ __meta__ = {
|
||||
[node name="MarginContainer" type="MarginContainer" parent="FloatingInventory/panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
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
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="FloatingInventory/panel/MarginContainer"]
|
||||
margin_left = 20.0
|
||||
margin_top = 80.0
|
||||
margin_right = 496.0
|
||||
margin_bottom = 80.0
|
||||
mouse_filter = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 6
|
||||
scroll_vertical_enabled = false
|
||||
|
||||
[node name="container" type="HBoxContainer" parent="FloatingInventory/panel/MarginContainer/ScrollContainer"]
|
||||
margin_right = 476.0
|
||||
mouse_filter = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_constants/separation = 20
|
||||
|
||||
@@ -1264,7 +1264,7 @@ func export_player(scene_name) -> void:
|
||||
|
||||
new_character.global_id = get_node(NAME_NODE).get_node("global_id").text
|
||||
new_character.tooltip_name = get_node(NAME_NODE).get_node("node_name").text
|
||||
|
||||
|
||||
new_character.default_action = "look"
|
||||
|
||||
var animations_resource = ESCAnimationResource.new()
|
||||
|
||||
@@ -158,7 +158,7 @@ func _on_CreateButton_pressed() -> void:
|
||||
item.global_id = get_node(GLOBAL_ID_NODE).text
|
||||
item.is_interactive = get_node(INTERACTIVE_NODE).pressed
|
||||
item.tooltip_name = get_node(ITEM_NAME_NODE).text
|
||||
|
||||
|
||||
var selected_index = get_node(ACTION_NODE).selected
|
||||
item.default_action = get_node(ACTION_NODE).get_item_text(selected_index)
|
||||
|
||||
@@ -167,7 +167,7 @@ func _on_CreateButton_pressed() -> void:
|
||||
var new_pool_array: PoolStringArray = item.combine_when_selected_action_is_in
|
||||
new_pool_array.append("use")
|
||||
item.combine_when_selected_action_is_in = new_pool_array
|
||||
|
||||
|
||||
# Add Dialog Position to the background item
|
||||
var interact_position = ESCLocation.new()
|
||||
interact_position.name = "interact_position"
|
||||
|
||||
Reference in New Issue
Block a user