feat: Several fixes and optimizations (#467)
Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
@@ -24,7 +24,7 @@ const COMPARISON_DESCRIPTION = [
|
||||
"Checking if %s %s %s equals %s",
|
||||
"Checking if %s %s %s greater than %s",
|
||||
"Checking if %s %s %s less than %s",
|
||||
"Checking if %s is %s active%s"
|
||||
"Checking if %s %s %s active%s"
|
||||
]
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ func _init(comparison_string: String):
|
||||
# Run this comparison against the globals
|
||||
func run() -> bool:
|
||||
var global_name = self.flag
|
||||
|
||||
|
||||
escoria.logger.debug(
|
||||
COMPARISON_DESCRIPTION[self.comparison] % [
|
||||
"inventory item" if self.inventory else "global value",
|
||||
@@ -130,7 +130,7 @@ func run() -> bool:
|
||||
self.comparison_value:
|
||||
return_value = true
|
||||
elif self.comparison == COMPARISON_ACTIVITY and \
|
||||
escoria.object_manager.has_object(global_name) and \
|
||||
escoria.object_manager.has(global_name) and \
|
||||
escoria.object_manager.get_object(global_name).active:
|
||||
return_value = true
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ func stop():
|
||||
# - name: The animation name to play
|
||||
# - backwards: Play backwards
|
||||
func play(name: String, backwards: bool = false):
|
||||
if _is_animation_player:
|
||||
if _is_animation_player and _animation_player.current_animation != "":
|
||||
_animation_player.seek(0)
|
||||
else:
|
||||
elif not _is_animation_player:
|
||||
_animated_sprite.frame = 0
|
||||
_current_animation = name
|
||||
if backwards and _is_animation_player:
|
||||
|
||||
@@ -34,7 +34,7 @@ func perform_walk(
|
||||
if destination.node is ESCLocation:
|
||||
target_position = destination.node.global_position
|
||||
else:
|
||||
target_position = destination.node.interact_position
|
||||
target_position = destination.node.get_interact_position()
|
||||
|
||||
var walk_context = ESCWalkContext.new(
|
||||
destination,
|
||||
@@ -127,7 +127,7 @@ func perform_inputevent_on_object(
|
||||
var player_global_pos = escoria.main.current_scene.player.global_position
|
||||
var clicked_position = event.position
|
||||
|
||||
if not player_global_pos == destination_position:
|
||||
if not player_global_pos.is_equal_approx(destination_position):
|
||||
dont_interact = true
|
||||
|
||||
# If no interaction should happen after player has arrived, leave
|
||||
|
||||
@@ -256,34 +256,6 @@ func show_ui():
|
||||
pass
|
||||
|
||||
|
||||
# Function is called if Project setting escoria/ui/tooltip_follows_mouse = true
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - p_position: Position of the mouse
|
||||
func update_tooltip_following_mouse_position(p_position: Vector2):
|
||||
var corrected_position = p_position
|
||||
|
||||
# clamp TOP
|
||||
if tooltip_node.tooltip_distance_to_edge_top(p_position) <= mouse_tooltip_margin:
|
||||
corrected_position.y = mouse_tooltip_margin
|
||||
|
||||
# clamp BOTTOM
|
||||
if tooltip_node.tooltip_distance_to_edge_bottom(p_position + tooltip_node.rect_size) <= mouse_tooltip_margin:
|
||||
corrected_position.y = escoria.game_size.y - mouse_tooltip_margin - tooltip_node.rect_size.y
|
||||
|
||||
# clamp LEFT
|
||||
if tooltip_node.tooltip_distance_to_edge_left(p_position - tooltip_node.rect_size/2) <= mouse_tooltip_margin:
|
||||
corrected_position.x = mouse_tooltip_margin
|
||||
|
||||
# clamp RIGHT
|
||||
if tooltip_node.tooltip_distance_to_edge_right(p_position + tooltip_node.rect_size/2) <= mouse_tooltip_margin:
|
||||
corrected_position.x = escoria.game_size.x - mouse_tooltip_margin - tooltip_node.rect_size.x
|
||||
|
||||
tooltip_node.anchor_right = 0.2
|
||||
tooltip_node.rect_position = corrected_position + tooltip_node.offset_from_cursor
|
||||
|
||||
|
||||
# Set the Editor debug mode
|
||||
func _set_editor_debug_mode(p_editor_debug_mode: int) -> void:
|
||||
editor_debug_mode = p_editor_debug_mode
|
||||
|
||||
@@ -299,10 +299,13 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
if mouse_in_shape:
|
||||
if event.doubleclick and event.button_index == BUTTON_LEFT:
|
||||
emit_signal("mouse_double_left_clicked_item", self, event)
|
||||
get_tree().set_input_as_handled()
|
||||
elif event.button_index == BUTTON_LEFT:
|
||||
emit_signal("mouse_left_clicked_item", self, event)
|
||||
get_tree().set_input_as_handled()
|
||||
elif event.button_index == BUTTON_RIGHT:
|
||||
emit_signal("mouse_right_clicked_item", self, event)
|
||||
get_tree().set_input_as_handled()
|
||||
|
||||
|
||||
# Return the animation player node
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# The escoria main script
|
||||
tool
|
||||
extends Node
|
||||
|
||||
# Signal sent when pause menu has to be displayed
|
||||
@@ -310,12 +311,6 @@ func _input(event):
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
emit_signal("request_pause_menu")
|
||||
|
||||
if ProjectSettings.get_setting("escoria/ui/tooltip_follows_mouse"):
|
||||
if escoria.main.current_scene and escoria.main.current_scene.game:
|
||||
if event is InputEventMouseMotion:
|
||||
escoria.main.current_scene.game. \
|
||||
update_tooltip_following_mouse_position(event.position)
|
||||
|
||||
|
||||
# Pauses or unpause the game
|
||||
#
|
||||
@@ -349,6 +344,110 @@ func run_event_from_script(script: ESCScript, event_name: String):
|
||||
[]
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
# Register a new project setting if it hasn't been defined already
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - name: Name of the project setting
|
||||
# - default: Default value
|
||||
# - info: Property info for the setting
|
||||
func register_setting(name: String, default, info: Dictionary):
|
||||
if not ProjectSettings.has_setting(name):
|
||||
ProjectSettings.set_setting(
|
||||
name,
|
||||
default
|
||||
)
|
||||
info.name = name
|
||||
ProjectSettings.add_property_info(info)
|
||||
|
||||
|
||||
# Register a user interface. This should be called in a deferred way
|
||||
# from the addon's _enter_tree.
|
||||
#
|
||||
# #### Parameters
|
||||
# - game_scene: Path to the game scene extending ESCGame
|
||||
func register_ui(game_scene: String):
|
||||
if not ProjectSettings.get_setting("escoria/ui/game_scene") in [
|
||||
"",
|
||||
game_scene
|
||||
]:
|
||||
logger.report_errors(
|
||||
"escoria.gd:register_ui()",
|
||||
[
|
||||
"Can't register user interface because %s is registered" % \
|
||||
ProjectSettings.get_setting("escoria/ui/game_scene")
|
||||
]
|
||||
)
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/game_scene",
|
||||
game_scene
|
||||
)
|
||||
|
||||
|
||||
# Deregister a user interface
|
||||
#
|
||||
# #### Parameters
|
||||
# - game_scene: Path to the game scene extending ESCGame
|
||||
func deregister_ui(game_scene: String):
|
||||
if ProjectSettings.get_setting("escoria/ui/game_scene") != game_scene:
|
||||
logger.report_errors(
|
||||
"escoria.gd:deregister_ui()",
|
||||
[
|
||||
(
|
||||
"Can't deregister user interface %s because it " +
|
||||
"is not registered."
|
||||
) % ProjectSettings.get_setting("escoria/ui/game_scene")
|
||||
]
|
||||
)
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/game_scene",
|
||||
""
|
||||
)
|
||||
|
||||
|
||||
# Register a dialog manager addon. This should be called in a deferred way
|
||||
# from the addon's _enter_tree.
|
||||
#
|
||||
# #### Parameters
|
||||
# - manager_class: Path to the manager class script
|
||||
func register_dialog_manager(manager_class: String):
|
||||
var dialog_managers: Array = ProjectSettings.get_setting(
|
||||
"escoria/ui/dialog_managers"
|
||||
)
|
||||
if manager_class in dialog_managers:
|
||||
return
|
||||
dialog_managers.push_back(manager_class)
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/dialog_managers",
|
||||
dialog_managers
|
||||
)
|
||||
|
||||
|
||||
# Deregister a dialog manager addon
|
||||
#
|
||||
# #### Parameters
|
||||
# - manager_class: Path to the manager class script
|
||||
func deregister_dialog_manager(manager_class: String):
|
||||
var dialog_managers: Array = ProjectSettings.get_setting(
|
||||
"escoria/ui/dialog_managers"
|
||||
)
|
||||
if not manager_class in dialog_managers:
|
||||
logger.report_warnings(
|
||||
"escoria.gd:deregister_dialog_manager()",
|
||||
[
|
||||
"Dialog manager %s is not registered" % manager_class
|
||||
]
|
||||
)
|
||||
return
|
||||
|
||||
dialog_managers.erase(manager_class)
|
||||
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/dialog_managers",
|
||||
dialog_managers
|
||||
)
|
||||
|
||||
|
||||
# Function called to quit the game.
|
||||
|
||||
@@ -2,21 +2,31 @@
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
# Autoloads to instantiate
|
||||
const autoloads = {
|
||||
"escoria": "res://addons/escoria-core/game/escoria.tscn",
|
||||
}
|
||||
|
||||
|
||||
# Setup Escoria
|
||||
func _enter_tree():
|
||||
for key in autoloads.keys():
|
||||
add_autoload_singleton(key, autoloads[key])
|
||||
|
||||
add_autoload_singleton(
|
||||
"escoria",
|
||||
"res://addons/escoria-core/game/escoria.tscn"
|
||||
)
|
||||
|
||||
# Add input actions in InputMap
|
||||
InputMap.add_action("switch_action_verb")
|
||||
InputMap.add_action("esc_show_debug_prompt")
|
||||
|
||||
# Define standard settings
|
||||
ProjectSettings.set_setting(
|
||||
"application/run/main_scene",
|
||||
"res://addons/escoria-core/game/main_scene.tscn"
|
||||
)
|
||||
|
||||
ProjectSettings.set_setting(
|
||||
"audio/default_bus_layout",
|
||||
"res://addons/escoria-core/default_bus_layout.tres"
|
||||
)
|
||||
|
||||
|
||||
func _ready():
|
||||
# Prepare settings
|
||||
set_escoria_main_settings()
|
||||
set_escoria_debug_settings()
|
||||
@@ -27,14 +37,7 @@ func _enter_tree():
|
||||
|
||||
# Prepare the settings in the Escoria UI category
|
||||
func set_escoria_ui_settings():
|
||||
ProjectSettings.set_setting(
|
||||
"audio/default_bus_layout",
|
||||
"res://addons/escoria-core/default_bus_layout.tres"
|
||||
)
|
||||
if !ProjectSettings.has_setting("escoria/ui/tooltip_follows_mouse"):
|
||||
ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", true)
|
||||
|
||||
_register_setting(
|
||||
escoria.register_setting(
|
||||
"escoria/ui/default_dialog_type",
|
||||
"",
|
||||
{
|
||||
@@ -42,62 +45,58 @@ func set_escoria_ui_settings():
|
||||
}
|
||||
)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/ui/game_scene"):
|
||||
ProjectSettings.set_setting("escoria/ui/game_scene", "")
|
||||
var game_scene_property_info = {
|
||||
escoria.register_setting(
|
||||
"escoria/ui/game_scene",
|
||||
"",
|
||||
{
|
||||
"name": "escoria/ui/game_scene",
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_FILE,
|
||||
"hint_string": "*.tscn, *.scn"
|
||||
}
|
||||
ProjectSettings.add_property_info(game_scene_property_info)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/ui/items_autoregister_path"):
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/items_autoregister_path",
|
||||
"res://game/items/escitems/"
|
||||
)
|
||||
var game_scene_property_info = {
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/ui/items_autoregister_path",
|
||||
"res://game/items/escitems/",
|
||||
{
|
||||
"name": "escoria/ui/items_autoregister_path",
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_DIR
|
||||
}
|
||||
ProjectSettings.add_property_info(game_scene_property_info)
|
||||
)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/ui/default_transition"):
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/default_transition",
|
||||
"curtain"
|
||||
)
|
||||
ProjectSettings.add_property_info({
|
||||
escoria.register_setting(
|
||||
"escoria/ui/default_transition",
|
||||
"curtain",
|
||||
{
|
||||
"name": "escoria/ui/default_transition",
|
||||
"type": TYPE_STRING
|
||||
})
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/ui/transition_paths"):
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/transition_paths",
|
||||
[
|
||||
"res://addons/escoria-core/game/scenes/transitions/shaders/"
|
||||
]
|
||||
)
|
||||
ProjectSettings.add_property_info({
|
||||
}
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/ui/transition_paths",
|
||||
[
|
||||
"res://addons/escoria-core/game/scenes/transitions/shaders/"
|
||||
],
|
||||
{
|
||||
"name": "escoria/ui/transition_paths",
|
||||
"type": TYPE_STRING_ARRAY,
|
||||
"hint": PROPERTY_HINT_DIR
|
||||
})
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/ui/inventory_item_size"):
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/inventory_item_size",
|
||||
Vector2(72, 72)
|
||||
)
|
||||
ProjectSettings.add_property_info({
|
||||
}
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/ui/inventory_item_size",
|
||||
Vector2(72, 72),
|
||||
{
|
||||
"name": "escoria/ui/inventory_item_size",
|
||||
"type": TYPE_VECTOR2
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
_register_setting(
|
||||
escoria.register_setting(
|
||||
"escoria/ui/dialog_managers",
|
||||
[],
|
||||
{
|
||||
@@ -107,196 +106,195 @@ func set_escoria_ui_settings():
|
||||
|
||||
# Prepare the settings in the Escoria main category
|
||||
func set_escoria_main_settings():
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/main/game_version"):
|
||||
ProjectSettings.set_setting("escoria/main/game_version", "")
|
||||
var game_version_property_info = {
|
||||
"name": "escoria/main/game_version",
|
||||
escoria.register_setting(
|
||||
"escoria/main/game_version",
|
||||
"",
|
||||
{
|
||||
"type": TYPE_STRING
|
||||
}
|
||||
ProjectSettings.add_property_info(game_version_property_info)
|
||||
)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/main/game_start_script"):
|
||||
ProjectSettings.set_setting("escoria/main/game_start_script", "")
|
||||
var game_start_script_property_info = {
|
||||
"name": "escoria/main/game_start_script",
|
||||
escoria.register_setting(
|
||||
"escoria/main/game_start_script",
|
||||
"",
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_FILE,
|
||||
"hint_string": "*.esc"
|
||||
}
|
||||
ProjectSettings.add_property_info(game_start_script_property_info)
|
||||
)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/main/force_quit"):
|
||||
ProjectSettings.set_setting("escoria/main/force_quit", true)
|
||||
var force_quit_property_info = {
|
||||
"name": "escoria/main/force_quit",
|
||||
escoria.register_setting(
|
||||
"escoria/main/force_quit",
|
||||
true,
|
||||
{
|
||||
"type": TYPE_BOOL
|
||||
}
|
||||
ProjectSettings.add_property_info(force_quit_property_info)
|
||||
)
|
||||
|
||||
ProjectSettings.set_setting("application/run/main_scene", "res://addons/escoria-core/game/main_scene.tscn")
|
||||
|
||||
if not ProjectSettings.has_setting("escoria/main/command_directories"):
|
||||
ProjectSettings.set_setting("escoria/main/command_directories", [
|
||||
escoria.register_setting(
|
||||
"escoria/main/command_directories",
|
||||
[
|
||||
"res://addons/escoria-core/game/core-scripts/esc/commands"
|
||||
])
|
||||
ProjectSettings.add_property_info({
|
||||
"name": "escoria/main/command_directories",
|
||||
],
|
||||
{
|
||||
"type": TYPE_ARRAY,
|
||||
})
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/main/text_lang"):
|
||||
ProjectSettings.set_setting("escoria/main/text_lang", TranslationServer.get_locale())
|
||||
var text_lang_property_info = {
|
||||
"name": "escoria/main/text_lang",
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_NONE
|
||||
}
|
||||
ProjectSettings.add_property_info(text_lang_property_info)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/main/voice_lang"):
|
||||
ProjectSettings.set_setting("escoria/main/voice_lang", TranslationServer.get_locale())
|
||||
var voice_lang_property_info = {
|
||||
"name": "escoria/main/voice_lang",
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_NONE
|
||||
}
|
||||
ProjectSettings.add_property_info(voice_lang_property_info)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/main/savegames_path"):
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/main/savegames_path",
|
||||
"user://saves/"
|
||||
)
|
||||
var savegames_path_property_info = {
|
||||
"name": "escoria/main/savegames_path",
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_DIR
|
||||
}
|
||||
ProjectSettings.add_property_info(savegames_path_property_info)
|
||||
)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/main/settings_path"):
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/main/settings_path",
|
||||
"user://"
|
||||
)
|
||||
var settings_path_property_info = {
|
||||
"name": "escoria/main/settings_path",
|
||||
escoria.register_setting(
|
||||
"escoria/main/text_lang",
|
||||
TranslationServer.get_locale(),
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_NONE
|
||||
}
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/main/voice_lang",
|
||||
TranslationServer.get_locale(),
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_NONE
|
||||
}
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/main/savegames_path",
|
||||
"user://saves/",
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_DIR
|
||||
}
|
||||
ProjectSettings.add_property_info(settings_path_property_info)
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/main/settings_path",
|
||||
"user://",
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_DIR
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# Prepare the settings in the Escoria debug category
|
||||
func set_escoria_debug_settings():
|
||||
if !ProjectSettings.has_setting("escoria/debug/terminate_on_warnings"):
|
||||
ProjectSettings.set_setting("escoria/debug/terminate_on_warnings", false)
|
||||
escoria.register_setting(
|
||||
"escoria/debug/terminate_on_warnings",
|
||||
false,
|
||||
{
|
||||
"type": TYPE_BOOL
|
||||
}
|
||||
)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/debug/terminate_on_errors"):
|
||||
ProjectSettings.set_setting("escoria/debug/terminate_on_errors", true)
|
||||
escoria.register_setting(
|
||||
"escoria/debug/terminate_on_errors",
|
||||
true,
|
||||
{
|
||||
"type": TYPE_BOOL
|
||||
}
|
||||
)
|
||||
|
||||
# Main language the game is developed in. Useful for translation management
|
||||
if !ProjectSettings.has_setting("escoria/debug/development_lang"):
|
||||
ProjectSettings.set_setting("escoria/debug/development_lang", "en")
|
||||
|
||||
# Assure log level preference
|
||||
if not ProjectSettings.has_setting("escoria/debug/log_level"):
|
||||
ProjectSettings.set_setting("escoria/debug/log_level", "ERROR")
|
||||
var property_info = {
|
||||
"name": "escoria/debug/log_level",
|
||||
escoria.register_setting(
|
||||
"escoria/debug/development_lang",
|
||||
"en",
|
||||
{
|
||||
"type": TYPE_STRING
|
||||
}
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/debug/log_level",
|
||||
"ERROR",
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_ENUM,
|
||||
"hint_string": "ERROR,WARNING,INFO,DEBUG"
|
||||
}
|
||||
ProjectSettings.add_property_info(property_info)
|
||||
)
|
||||
|
||||
# Define output log file path
|
||||
if not ProjectSettings.has_setting("escoria/debug/log_file_path"):
|
||||
ProjectSettings.set_setting("escoria/debug/log_file_path", "user://")
|
||||
var property_info = {
|
||||
"name": "escoria/debug/log_file_path",
|
||||
escoria.register_setting(
|
||||
"escoria/debug/log_file_path",
|
||||
"user://",
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_DIR
|
||||
}
|
||||
ProjectSettings.add_property_info(property_info)
|
||||
)
|
||||
|
||||
# Define crash message
|
||||
if not ProjectSettings.has_setting("escoria/debug/crash_message"):
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/debug/crash_message",
|
||||
"We're sorry, but the game crashed. Please send us the " +
|
||||
"following files:\n\n%s"
|
||||
)
|
||||
var property_info = {
|
||||
"name": "escoria/debug/crash_message",
|
||||
escoria.register_setting(
|
||||
"escoria/debug/crash_message",
|
||||
"We're sorry, but the game crashed. Please send us the " +
|
||||
"following files:\n\n%s",
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_MULTILINE_TEXT
|
||||
}
|
||||
ProjectSettings.add_property_info(property_info)
|
||||
)
|
||||
|
||||
# Room selector preference
|
||||
if not ProjectSettings.has_setting("escoria/debug/enable_room_selector"):
|
||||
ProjectSettings.set_setting("escoria/debug/enable_room_selector", false)
|
||||
var property_info = {
|
||||
"name": "escoria/debug/enable_room_selector",
|
||||
escoria.register_setting(
|
||||
"escoria/debug/enable_room_selector",
|
||||
false,
|
||||
{
|
||||
"type": TYPE_BOOL
|
||||
}
|
||||
ProjectSettings.add_property_info(property_info)
|
||||
|
||||
if not ProjectSettings.has_setting("escoria/debug/room_selector_room_dir"):
|
||||
ProjectSettings.set_setting("escoria/debug/room_selector_room_dir", "")
|
||||
var property_info = {
|
||||
"name": "escoria/debug/room_selector_room_dir",
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/debug/room_selector_room_dir",
|
||||
"",
|
||||
{
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_DIR
|
||||
}
|
||||
ProjectSettings.add_property_info(property_info)
|
||||
)
|
||||
|
||||
|
||||
# Prepare the settings in the Escoria sound settings
|
||||
func set_escoria_sound_settings():
|
||||
if !ProjectSettings.has_setting("escoria/sound/master_volume"):
|
||||
ProjectSettings.set_setting("escoria/sound/master_volume", 1)
|
||||
var master_data_property_info = {
|
||||
"name": "escoria/sound/master_volume",
|
||||
escoria.register_setting(
|
||||
"escoria/sound/master_volume",
|
||||
1,
|
||||
{
|
||||
"type": TYPE_INT,
|
||||
"hint": PROPERTY_HINT_RANGE,
|
||||
"hint_string": "0,1"
|
||||
}
|
||||
ProjectSettings.add_property_info(master_data_property_info)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/sound/music_volume"):
|
||||
ProjectSettings.set_setting("escoria/sound/music_volume", 1)
|
||||
var music_data_property_info = {
|
||||
"name": "escoria/sound/music_volume",
|
||||
"type": TYPE_INT,
|
||||
"hint": PROPERTY_HINT_RANGE,
|
||||
"hint_string": "0,1"
|
||||
}
|
||||
ProjectSettings.add_property_info(music_data_property_info)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/sound/sfx_volume"):
|
||||
ProjectSettings.set_setting("escoria/sound/sfx_volume", 1)
|
||||
var sound_data_property_info = {
|
||||
"name": "escoria/sound/sfx_volume",
|
||||
"type": TYPE_INT,
|
||||
"hint": PROPERTY_HINT_RANGE,
|
||||
"hint_string": "0,1"
|
||||
}
|
||||
ProjectSettings.add_property_info(sound_data_property_info)
|
||||
)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/sound/speech_volume"):
|
||||
ProjectSettings.set_setting("escoria/sound/speech_volume", 1)
|
||||
var speech_data_property_info = {
|
||||
"name": "escoria/sound/speech_volume",
|
||||
escoria.register_setting(
|
||||
"escoria/sound/music_volume",
|
||||
1,
|
||||
{
|
||||
"type": TYPE_INT,
|
||||
"hint": PROPERTY_HINT_RANGE,
|
||||
"hint_string": "0,1"
|
||||
}
|
||||
ProjectSettings.add_property_info(speech_data_property_info)
|
||||
)
|
||||
|
||||
_register_setting(
|
||||
escoria.register_setting(
|
||||
"escoria/sound/sfx_volume",
|
||||
1,
|
||||
{
|
||||
"type": TYPE_INT,
|
||||
"hint": PROPERTY_HINT_RANGE,
|
||||
"hint_string": "0,1"
|
||||
}
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/sound/speech_volume",
|
||||
1,
|
||||
{
|
||||
"type": TYPE_INT,
|
||||
"hint": PROPERTY_HINT_RANGE,
|
||||
"hint_string": "0,1"
|
||||
}
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/sound/speech_enabled",
|
||||
1,
|
||||
{
|
||||
@@ -304,7 +302,7 @@ func set_escoria_sound_settings():
|
||||
}
|
||||
)
|
||||
|
||||
_register_setting(
|
||||
escoria.register_setting(
|
||||
"escoria/sound/speech_folder",
|
||||
"res://speech",
|
||||
{
|
||||
@@ -313,7 +311,7 @@ func set_escoria_sound_settings():
|
||||
}
|
||||
)
|
||||
|
||||
_register_setting(
|
||||
escoria.register_setting(
|
||||
"escoria/sound/speech_extension",
|
||||
"ogg",
|
||||
{
|
||||
@@ -322,23 +320,6 @@ func set_escoria_sound_settings():
|
||||
)
|
||||
|
||||
|
||||
# Register a new project setting if it hasn't been defined already
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - name: Name of the project setting
|
||||
# - default: Default value
|
||||
# - info: Property info for the setting
|
||||
func _register_setting(name: String, default, info: Dictionary):
|
||||
if not ProjectSettings.has_setting(name):
|
||||
ProjectSettings.set_setting(
|
||||
name,
|
||||
default
|
||||
)
|
||||
info.name = name
|
||||
ProjectSettings.add_property_info(info)
|
||||
|
||||
|
||||
# Prepare the settings in the Escoria platform category and may need special
|
||||
# setting per build
|
||||
func set_escoria_platform_settings():
|
||||
@@ -346,18 +327,26 @@ func set_escoria_platform_settings():
|
||||
# scenes.
|
||||
# If set to true, all generic scenes (UI, inventory, etc) will be loaded
|
||||
# as any other scene.
|
||||
if !ProjectSettings.has_setting("escoria/platform/skip_cache"):
|
||||
ProjectSettings.set_setting("escoria/platform/skip_cache", false)
|
||||
if !ProjectSettings.has_setting("escoria/platform/skip_cache.mobile"):
|
||||
ProjectSettings.set_setting("escoria/platform/skip_cache.mobile", true)
|
||||
escoria.register_setting(
|
||||
"escoria/platform/skip_cache",
|
||||
false,
|
||||
{
|
||||
"type": TYPE_BOOL
|
||||
}
|
||||
)
|
||||
|
||||
escoria.register_setting(
|
||||
"escoria/platform/skip_cache.mobile",
|
||||
true,
|
||||
{
|
||||
"type": "TYPE_BOOL"
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# Uninstall plugin
|
||||
func _exit_tree():
|
||||
for key in autoloads.keys():
|
||||
if ProjectSettings.has_setting(key):
|
||||
remove_autoload_singleton(key)
|
||||
remove_autoload_singleton("escoria")
|
||||
|
||||
InputMap.erase_action("switch_action_verb")
|
||||
InputMap.erase_action("esc_show_debug_prompt")
|
||||
|
||||
|
||||
|
||||
@@ -3,31 +3,30 @@ tool
|
||||
extends EditorPlugin
|
||||
|
||||
|
||||
var _escoria
|
||||
|
||||
const MANAGER_CLASS="res://addons/escoria-dialog-simple/esc_dialog_simple.gd"
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_escoria = preload("res://addons/escoria-core/game/escoria.tscn")\
|
||||
.instance()
|
||||
|
||||
|
||||
# Register ourselves after setup
|
||||
func _enter_tree() -> void:
|
||||
func _ready() -> void:
|
||||
call_deferred("_register")
|
||||
|
||||
|
||||
# Unregister ourselves
|
||||
func _exit_tree() -> void:
|
||||
_unregister()
|
||||
_escoria.deregister_dialog_manager(MANAGER_CLASS)
|
||||
|
||||
|
||||
# Add ourselves to the list of dialog managers
|
||||
func _register():
|
||||
_unregister()
|
||||
var dialog_managers: Array = ProjectSettings.get_setting(
|
||||
"escoria/ui/dialog_managers"
|
||||
)
|
||||
dialog_managers.push_back(MANAGER_CLASS)
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/dialog_managers",
|
||||
dialog_managers
|
||||
)
|
||||
_register_setting(
|
||||
_escoria.register_dialog_manager(MANAGER_CLASS)
|
||||
_escoria.register_setting(
|
||||
"escoria/dialog_simple/avatars_path",
|
||||
"",
|
||||
{
|
||||
@@ -36,7 +35,7 @@ func _register():
|
||||
}
|
||||
)
|
||||
|
||||
_register_setting(
|
||||
_escoria.register_setting(
|
||||
"escoria/dialog_simple/text_speed_per_character",
|
||||
0.1,
|
||||
{
|
||||
@@ -44,7 +43,7 @@ func _register():
|
||||
}
|
||||
)
|
||||
|
||||
_register_setting(
|
||||
_escoria.register_setting(
|
||||
"escoria/dialog_simple/fast_text_speed_per_character",
|
||||
0.25,
|
||||
{
|
||||
@@ -52,41 +51,10 @@ func _register():
|
||||
}
|
||||
)
|
||||
|
||||
_register_setting(
|
||||
_escoria.register_setting(
|
||||
"escoria/dialog_simple/max_time_to_disappear",
|
||||
1.0,
|
||||
{
|
||||
"type": TYPE_REAL
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# Remove ourselves from the list of dialog managers
|
||||
func _unregister():
|
||||
var dialog_managers = ProjectSettings.get_setting(
|
||||
"escoria/ui/dialog_managers"
|
||||
)
|
||||
|
||||
dialog_managers.erase(MANAGER_CLASS)
|
||||
|
||||
ProjectSettings.set_setting(
|
||||
"escoria/ui/dialog_managers",
|
||||
dialog_managers
|
||||
)
|
||||
|
||||
|
||||
# Register a new project setting if it hasn't been defined already
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - name: Name of the project setting
|
||||
# - default: Default value
|
||||
# - info: Property info for the setting
|
||||
func _register_setting(name: String, default, info: Dictionary):
|
||||
if not ProjectSettings.has_setting(name):
|
||||
ProjectSettings.set_setting(
|
||||
name,
|
||||
default
|
||||
)
|
||||
info.name = name
|
||||
ProjectSettings.add_property_info(info)
|
||||
|
||||
@@ -45,7 +45,6 @@ onready var inventory_ui = $ui/Control/panel_down/VBoxContainer/HBoxContainer\
|
||||
/InventoryMargin/inventory_ui
|
||||
|
||||
func _enter_tree():
|
||||
ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", false)
|
||||
escoria.action_manager.connect(
|
||||
"action_finished",
|
||||
self,
|
||||
@@ -70,6 +69,7 @@ func _exit_tree():
|
||||
self,
|
||||
"_on_action_finished"
|
||||
)
|
||||
|
||||
|
||||
|
||||
## BACKGROUND ##
|
||||
|
||||
@@ -3,7 +3,16 @@ tool
|
||||
extends EditorPlugin
|
||||
|
||||
|
||||
# Setup Escoria
|
||||
func _enter_tree():
|
||||
ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", false)
|
||||
ProjectSettings.set_setting("escoria/ui/game_scene", "res://addons/escoria-ui-9verbs/game.tscn")
|
||||
# Register UI
|
||||
func _enter_tree() -> void:
|
||||
call_deferred("_register")
|
||||
|
||||
|
||||
# Deregister UI
|
||||
func _exit_tree() -> void:
|
||||
escoria.deregister_ui("res://addons/escoria-ui-9verbs/game.tscn")
|
||||
|
||||
|
||||
# Register UI with Escoria
|
||||
func _register():
|
||||
escoria.register_ui("res://addons/escoria-ui-9verbs/game.tscn")
|
||||
|
||||
@@ -36,7 +36,6 @@ Implement methods to react to inputs.
|
||||
"""
|
||||
|
||||
func _enter_tree():
|
||||
ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", true)
|
||||
escoria.action_manager.connect(
|
||||
"action_finished",
|
||||
self,
|
||||
@@ -60,6 +59,14 @@ func _exit_tree():
|
||||
self,
|
||||
"_on_action_finished"
|
||||
)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if escoria.main.current_scene and escoria.main.current_scene.game:
|
||||
if event is InputEventMouseMotion:
|
||||
escoria.main.current_scene.game. \
|
||||
update_tooltip_following_mouse_position(event.position)
|
||||
|
||||
|
||||
## BACKGROUND ##
|
||||
|
||||
@@ -202,6 +209,34 @@ func pause_game():
|
||||
escoria.main.current_scene.hide()
|
||||
|
||||
|
||||
# Update the tooltip
|
||||
#
|
||||
# #### Parameters
|
||||
#
|
||||
# - p_position: Position of the mouse
|
||||
func update_tooltip_following_mouse_position(p_position: Vector2):
|
||||
var corrected_position = p_position
|
||||
|
||||
# clamp TOP
|
||||
if tooltip_node.tooltip_distance_to_edge_top(p_position) <= mouse_tooltip_margin:
|
||||
corrected_position.y = mouse_tooltip_margin
|
||||
|
||||
# clamp BOTTOM
|
||||
if tooltip_node.tooltip_distance_to_edge_bottom(p_position + tooltip_node.rect_size) <= mouse_tooltip_margin:
|
||||
corrected_position.y = escoria.game_size.y - mouse_tooltip_margin - tooltip_node.rect_size.y
|
||||
|
||||
# clamp LEFT
|
||||
if tooltip_node.tooltip_distance_to_edge_left(p_position - tooltip_node.rect_size/2) <= mouse_tooltip_margin:
|
||||
corrected_position.x = mouse_tooltip_margin
|
||||
|
||||
# clamp RIGHT
|
||||
if tooltip_node.tooltip_distance_to_edge_right(p_position + tooltip_node.rect_size/2) <= mouse_tooltip_margin:
|
||||
corrected_position.x = escoria.game_size.x - mouse_tooltip_margin - tooltip_node.rect_size.x
|
||||
|
||||
tooltip_node.anchor_right = 0.2
|
||||
tooltip_node.rect_position = corrected_position + tooltip_node.offset_from_cursor
|
||||
|
||||
|
||||
func _on_action_finished():
|
||||
$mouse_layer/verbs_menu.clear_tool_texture()
|
||||
$mouse_layer/verbs_menu.iterate_actions_cursor(0)
|
||||
|
||||
@@ -3,7 +3,16 @@ tool
|
||||
extends EditorPlugin
|
||||
|
||||
|
||||
# Setup Escoria
|
||||
# Register UI
|
||||
func _enter_tree():
|
||||
ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", true)
|
||||
ProjectSettings.set_setting("escoria/ui/game_scene", "res://addons/escoria-ui-simplemouse/game.tscn")
|
||||
call_deferred("_register")
|
||||
|
||||
|
||||
# Deregister UI
|
||||
func _exit_tree() -> void:
|
||||
escoria.deregister_ui("res://addons/escoria-ui-simplemouse/game.tscn")
|
||||
|
||||
|
||||
# Register UI with Escoria
|
||||
func _register():
|
||||
escoria.register_ui("res://addons/escoria-ui-simplemouse/game.tscn")
|
||||
|
||||
@@ -731,6 +731,7 @@ debug/crash_message="We're sorry, but the game crashed. Please send us the follo
|
||||
|
||||
%s"
|
||||
ui/default_dialog_scene="res://addons/escoria-core/ui_library/dialogs/floating_dialog_player.tscn"
|
||||
esc/command_paths=[ "res://addons/escoria-core/game/core-scripts/esc/commands" ]
|
||||
|
||||
[input]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user