Implement save and loading games (#8)

This commit is contained in:
Julian Murgia
2021-07-02 23:08:43 +02:00
committed by GitHub
parent 58d880101d
commit bd4c33cf77
66 changed files with 1268 additions and 736 deletions

View File

@@ -157,16 +157,9 @@ func _process(delta: float) -> void:
# #
# #### Parameters # #### Parameters
# #
# - target: Vector2, Position2d or ESCItem # - target: Position2d or ESCItem to teleport to
func teleport(target, angle : Object = null) -> void: func teleport(target: Node, angle: Object = null) -> void:
if typeof(target) == TYPE_VECTOR2 : if target is Position2D:
escoria.logger.info(
"Object %s teleported at position %s with angle" %
[parent.global_id, str(target)],
[angle]
)
parent.position = target
elif target is Position2D:
escoria.logger.info( escoria.logger.info(
"Object %s teleported at position %s with angle" % "Object %s teleported at position %s with angle" %
[parent.global_id, str(target.position)], [parent.global_id, str(target.position)],
@@ -185,7 +178,27 @@ func teleport(target, angle : Object = null) -> void:
+ str(parent.position) + " with angle ", str(angle)) + str(parent.position) + " with angle ", str(angle))
else: else:
escoria.logger.report_errors("escitem.gd:teleport()", escoria.logger.report_errors("escitem.gd:teleport()",
["Target to teleport to is null or unusable (" + target + ")"]) ["Target to teleport to is null or unusable (" + str(target) + ")"])
# Teleports this item to the target position.
# TODO angle is only used for logging and has no further use, so it probably
# can be removed
#
# #### Parameters
#
# - target: Vector2 target position to teleport to
func teleport_to(target: Vector2, angle: Object = null) -> void:
if typeof(target) == TYPE_VECTOR2 :
escoria.logger.info(
"Object %s teleported at position %s with angle" %
[parent.global_id, str(target)],
[angle]
)
parent.position = target
else:
escoria.logger.report_errors("escitem.gd:teleport_to()",
["Target to teleport to is null or unusable (" + str(target) + ")"])
# Walk to a given position # Walk to a given position
@@ -436,3 +449,8 @@ func set_angle(deg : int, immediate = true) -> void:
parent.animation_sprite.play(parent.animations.idles[last_dir][0]) parent.animation_sprite.play(parent.animations.idles[last_dir][0])
pose_scale = parent.animations.idles[last_dir][1] pose_scale = parent.animations.idles[last_dir][1]
update_terrain() update_terrain()
# Returns the angle that corresponds to the current direction of the object.
func _get_angle() -> int:
return parent.animations.dir_angles[last_dir][0]

View File

@@ -17,7 +17,7 @@ func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new( return ESCCommandArgumentDescriptor.new(
2, 2,
[TYPE_STRING, TYPE_INT], [TYPE_STRING, TYPE_INT],
[null, true] [null, null]
) )
@@ -40,6 +40,6 @@ func run(command_params: Array) -> int:
# angle against X axis not Y, we need to check direction using (angle-90°). # angle against X axis not Y, we need to check direction using (angle-90°).
# Since the ESC command already gives the right angle, we add 90. # Since the ESC command already gives the right angle, we add 90.
escoria.object_manager.get_object(command_params[0]).node\ escoria.object_manager.get_object(command_params[0]).node\
.set_angle(int(command_params[1] + 90)) .set_angle(wrapi(int(command_params[1]) + 90, 0, 360))
return ESCExecution.RC_OK return ESCExecution.RC_OK

View File

@@ -0,0 +1,37 @@
# `teleport_pos object1 x y
#
# Sets the position of object1 to the position (x,y).
# FIXME re-add the angle parameter here
#
# @ESC
extends ESCBaseCommand
class_name TeleportPosCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_STRING, TYPE_INT, TYPE_INT],
[null, null, null]
)
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.objects.has(arguments[0]):
escoria.logger.report_errors(
"teleport_pos: invalid first object",
[
"Object with global id %s not found" % arguments[0]
]
)
return false
return .validate(arguments)
# Run the command
func run(command_params: Array) -> int:
(escoria.object_manager.get_object(command_params[0]).node as ESCPlayer)\
.teleport_to(Vector2(int(command_params[1]), int(command_params[2])))
return ESCExecution.RC_OK

View File

@@ -93,3 +93,15 @@ func set_global_wildcard(pattern: String, value) -> void:
for global_key in _globals.keys: for global_key in _globals.keys:
if global_key.match(pattern): if global_key.match(pattern):
self.set_global(global_key, value) self.set_global(global_key, value)
# Save the state of globals in the savegame.
#
# #### Parameters
# - p_savegame: ESCSaveGame resource that holds all data of the save
func save_game(p_savegame: ESCSaveGame) -> void:
p_savegame.globals = {}
for g in _globals:
if g in RESERVED_GLOBALS:
continue
p_savegame.globals[g] = _globals[g]

View File

@@ -4,7 +4,8 @@ class_name ESCObjectManager
const RESERVED_OBJECTS = [ const RESERVED_OBJECTS = [
"bg_music" "bg_music",
"bg_sound"
] ]
@@ -23,7 +24,7 @@ func _process(_delta):
# #
# #### Parameters # #### Parameters
# #
# - object: Obejct to register # - object: Object to register
# - force: Register the object, even if it has already been registered # - force: Register the object, even if it has already been registered
func register_object(object: ESCObject, force: bool = false) -> void: func register_object(object: ESCObject, force: bool = false) -> void:
if objects.has(object.global_id) and not force: if objects.has(object.global_id) and not force:
@@ -70,6 +71,11 @@ func has(global_id: String) -> bool:
# Get the object from the object registry # Get the object from the object registry
#
# #### Parameters
#
# - global_id: The global id of the object to retrieve
# **Returns** The retrieved object, or null if not found
func get_object(global_id: String) -> ESCObject: func get_object(global_id: String) -> ESCObject:
if objects.has(global_id): if objects.has(global_id):
return objects[global_id] return objects[global_id]
@@ -93,3 +99,17 @@ func unregister_object(object: ESCObject) -> void:
and not object.global_id in RESERVED_OBJECTS: and not object.global_id in RESERVED_OBJECTS:
objects.erase(object.global_id) objects.erase(object.global_id)
# Insert data to save into savegame.
#
# #### Parameters
#
# - p_savegame: The savegame resource
func save_game(p_savegame: ESCSaveGame) -> void:
p_savegame.objects = {}
for obj_global_id in objects:
if !objects[obj_global_id] is ESCObject:
continue
p_savegame.objects[obj_global_id] = \
objects[obj_global_id].get_save_data()

View File

@@ -70,3 +70,21 @@ func set_state(p_state: String, immediate: bool = false):
func _set_active(value: bool): func _set_active(value: bool):
active = value active = value
self.node.visible = value self.node.visible = value
# Return the data of the object to be inserted in a savegame file.
#
# **Returns**
# A dictionary containing the data to be saved for this object.
func get_save_data() -> Dictionary:
var save_data: Dictionary = {}
save_data["active"] = self.active
save_data["interactive"] = self.interactive
save_data["state"] = self.state
if self.node.get("is_movable") and self.node.is_movable:
save_data["global_transform"] = self.node.global_transform
save_data["last_deg"] = wrapi(self.node._movable._get_angle() + 1, 0, 360)
save_data["last_dir"] = self.node._movable.last_dir
return save_data

View File

@@ -276,11 +276,20 @@ func element_exited(body):
# #
# #### Parameters # #### Parameters
# #
# - target: Target item to teleport to # - target: Target node to teleport to
func teleport(target: Node) -> void: func teleport(target: Node) -> void:
_movable.teleport(target) _movable.teleport(target)
# Use the movable node to teleport this item to the target position
#
# #### Parameters
#
# - target: Vector2 position to teleport to
func teleport_to(target: Vector2) -> void:
_movable.teleport_to(target)
# Use the movable node to make the item walk to the given position # Use the movable node to make the item walk to the given position
# #
# #### Parameters # #### Parameters
@@ -359,3 +368,4 @@ func _get_inventory_item() -> ESCInventoryItem:
inventory_item.global_id = self.global_id inventory_item.global_id = self.global_id
return inventory_item return inventory_item

View File

@@ -74,6 +74,7 @@ func _ready():
navigation_enabled_found = true navigation_enabled_found = true
current_active_navigation_instance = n current_active_navigation_instance = n
if !Engine.is_editor_hint(): if !Engine.is_editor_hint():
escoria.room_terrain = self escoria.room_terrain = self
_update_texture() _update_texture()

View File

@@ -0,0 +1,207 @@
# Saves and loads savegame and settings files
class_name ESCSaveManager
# Variable containing the saves folder obtained from Project Settings
var save_folder: String
# Template for savegames filenames
const SAVE_NAME_TEMPLATE: String = "save_%03d.tres"
# Variable containing the settings folder obtained from Project Settings
var settings_folder: String
# Template for settings filename
const SETTINGS_TEMPLATE: String = "settings.tres"
# Constructor of ESCSaveManager object.
func _init():
save_folder = ProjectSettings.get_setting("escoria/main/savegames_path")
settings_folder = ProjectSettings.get_setting("escoria/main/settings_path")
# Return a list of savegames metadata (id, date, name and game version)
func get_saves_list() -> Dictionary:
var regex = RegEx.new()
regex.compile("save_([0-9]{3})\\.tres")
var saves = {}
var dirsave = Directory.new()
if dirsave.open(save_folder) == OK:
dirsave.list_dir_begin(true, true)
var nextfile = dirsave.get_next()
while nextfile != "":
var save_path = save_folder.plus_file(nextfile)
var file: File = File.new()
var save_game_res: Resource = load(save_path)
var save_game_data = {
"date": save_game_res["date"],
"name": save_game_res["name"],
"game_version": save_game_res["game_version"],
}
var id: int
var matches = regex.search(nextfile)
if matches.strings.size() > 1:
id = int(matches.strings[1])
saves[id] = save_game_data
nextfile = dirsave.get_next()
return saves
# Returns true whether the savegame identified by id does exist
#
# ## Parameters
# - id: integer suffix of the savegame file
func save_game_exists(id: int) -> bool:
var save_file_path: String = save_folder.plus_file(SAVE_NAME_TEMPLATE % id)
var file: File = File.new()
return file.file_exists(save_file_path)
# Save the current state of the game in a file suffixed with the id value.
# This id can help with slots development for the game developer.
#
# ## Parameters
# - id: integer suffix of the savegame file
# - p_savename: name of the savegame
func save_game(id: int, p_savename: String):
var save_game := ESCSaveGame.new()
save_game.escoria_version = escoria.ESCORIA_VERSION
save_game.game_version = ProjectSettings.get_setting(
"escoria/main/game_version"
)
save_game.name = p_savename
var datetime = OS.get_datetime()
var datetime_string = "%02d/%02d/%02d %02d:%02d" % [
datetime["day"],
datetime["month"],
datetime["year"],
datetime["hour"],
datetime["minute"],
]
save_game.date = datetime_string
escoria.globals_manager.save_game(save_game)
escoria.object_manager.save_game(save_game)
escoria.main.save_game(save_game)
var directory: Directory = Directory.new()
if not directory.dir_exists(save_folder):
directory.make_dir_recursive(save_folder)
var save_path = save_folder.plus_file(SAVE_NAME_TEMPLATE % id)
var error: int = ResourceSaver.save(save_path, save_game)
if error != OK:
escoria.logger.report_errors(
"esc_save_data_resources.gd",
["There was an issue writing the save %s to %s" % [id, save_path]])
# Load a savegame file from its id.
#
# ## Parameters
# - id: integer suffix of the savegame file
func load_game(id: int):
var save_file_path: String = save_folder.plus_file(SAVE_NAME_TEMPLATE % id)
var file: File = File.new()
if not file.file_exists(save_file_path):
escoria.logger.report_errors(
"esc_save_data_resources.gd",
["Save file %s doesn't exist" % save_file_path])
return
var save_game: Resource = ResourceLoader.load(save_file_path)
var load_event = ESCEvent.new(":load")
var load_statements = []
## GLOBALS
for k in save_game.globals.keys():
load_statements.append(
ESCCommand.new("set_global %s \"%s\"\n" \
% [k, save_game.globals[k]])
)
## ROOM
load_statements.append(
ESCCommand.new("change_scene %s true" \
% save_game.main["current_scene_filename"])
)
## OBJECTS
for object_global_id in save_game.objects.keys():
if save_game.objects[object_global_id].has("active"):
load_statements.append(ESCCommand.new("set_active %s %s" \
% [object_global_id,
save_game.objects[object_global_id]["active"]])
)
if save_game.objects[object_global_id].has("interactive"):
load_statements.append(ESCCommand.new("set_interactive %s %s" \
% [object_global_id,
save_game.objects[object_global_id]["interactive"]])
)
if save_game.objects[object_global_id].has("state"):
load_statements.append(ESCCommand.new("set_state %s %s true" \
% [object_global_id,
save_game.objects[object_global_id]["state"]])
)
if save_game.objects[object_global_id].has("global_transform"):
load_statements.append(ESCCommand.new("teleport_pos %s %s %s" \
% [object_global_id,
save_game.objects[object_global_id] \
["global_transform"].origin.x,
save_game.objects[object_global_id] \
["global_transform"].origin.y])
)
load_statements.append(ESCCommand.new("set_angle %s %s" \
% [object_global_id,
save_game.objects[object_global_id]["last_deg"]])
)
load_event.statements = load_statements
escoria.event_manager.queue_event(load_event)
# Save the game settings in the settings file.
func save_settings():
var settings_res := ESCSaveSettings.new()
settings_res.escoria_version = escoria.ESCORIA_VERSION
settings_res.text_lang = escoria.settings.text_lang
settings_res.voice_lang = escoria.settings.voice_lang
settings_res.speech_enabled = escoria.settings.speech_enabled
settings_res.master_volume = escoria.settings.master_volume
settings_res.music_volume = escoria.settings.music_volume
settings_res.sfx_volume = escoria.settings.sfx_volume
settings_res.voice_volume = escoria.settings.voice_volume
settings_res.fullscreen = escoria.settings.fullscreen
settings_res.skip_dialog = escoria.settings.skip_dialog
settings_res.rate_shown = escoria.settings.rate_shown
var directory: Directory = Directory.new()
if not directory.dir_exists(settings_folder):
directory.make_dir_recursive(settings_folder)
var save_path = settings_folder.plus_file(SETTINGS_TEMPLATE)
var error: int = ResourceSaver.save(save_path, settings_res)
if error != OK:
escoria.logger.report_errors(
"esc_save_data_resources.gd:save_settings()",
["There was an issue writing settings %s" % save_path])
# Load the game settings from the settings file
func load_settings():
var save_settings_path: String = settings_folder.plus_file(SETTINGS_TEMPLATE)
var file: File = File.new()
if not file.file_exists(save_settings_path):
escoria.logger.report_warnings(
"esc_save_data_resources.gd:load_settings()",
["Settings file %s doesn't exist" % save_settings_path,
"Setting default settings."])
save_settings()
return
var settings_resource: Resource = load(save_settings_path)
escoria._on_settings_loaded(settings_resource)

View File

@@ -0,0 +1,29 @@
# Resource used for holding savegames data.
extends Resource
class_name ESCSaveGame
# Access key for the main data last_scene_global_id
const MAIN_LAST_SCENE_GLOBAL_ID_KEY = "last_scene_global_id"
# Access key for the main data current_scene_filename
const MAIN_CURRENT_SCENE_FILENAME_KEY = "current_scene_filename"
# Escoria version which the savegame was created with.
export var escoria_version: String
# Game version which the savegame was created with.
export var game_version: String = ""
# Name of the savegame. Can be custom value, provided by the player.
export var name: String = ""
# Date of creation of the savegame.
export var date: String = ""
# Main data to be saved
export var main: Dictionary = {}
# Escoria Global variables exported from ESCGlobalsManager
export var globals: Dictionary = {}
# Escoria objects exported from ESCObjectsManager
export var objects: Dictionary = {}

View File

@@ -0,0 +1,40 @@
# Resource holding game settings.
extends Resource
class_name ESCSaveSettings
# Version of ESCORIA Framework
export var escoria_version: String
# Language of displayed text
export var text_lang: String = ProjectSettings.get_setting("escoria/main/text_lang")
# Language of voice speech
export var voice_lang: String = ProjectSettings.get_setting("escoria/main/voice_lang")
# Whether speech is enabled
export var speech_enabled: bool = ProjectSettings.get_setting(
"escoria/sound/speech_enabled")
# Master volume (mix of music, voice and sfx)
export var master_volume: float = ProjectSettings.get_setting(
"escoria/sound/master_volume")
# Volume of music only
export var music_volume: float = ProjectSettings.get_setting(
"escoria/sound/music_volume")
# Volume of SFX only
export var sfx_volume: float = ProjectSettings.get_setting("escoria/sound/sfx_volume")
# Voice volume only
export var voice_volume: float = ProjectSettings.get_setting(
"escoria/sound/speech_volume")
# True if game has to be fullscreen
export var fullscreen: bool = false
# True if skipping dialogs is allowed
export var skip_dialog: bool = true
# FIXME: to be defined (achievements?)
export var rate_shown: bool = false

View File

@@ -1,218 +0,0 @@
const DATA_STRING = 0
const DATA_STRING_ARRAY = 1
const DATA_VARIANT = 2
var base = "user://esc_saves"
var slots = {}
var max_slots = 3
var settings
func save_settings(p_data, p_callback):
var f = File.new()
f.open("user://settings.json", File.WRITE)
f.store_string(to_json(p_data))
f.close()
if typeof(p_callback) != typeof(null):
p_callback[0].call_deferred(p_callback[1], OK)
return OK
func check_settings():
var f = File.new()
var error = f.open("user://settings.json", File.READ)
if !f.is_open() and error != OK:
match error:
ERR_FILE_NOT_FOUND:
f.close()
save_settings(escoria.settings_default, null)
func load_settings(p_callback):
var f = File.new()
var error = f.open("user://settings.json", File.READ)
if !f.is_open() and error != OK:
escoria.logger.report_warnings("save_data.gd:load_settings()",
["Failed opening settings file user://settings.json.",
"File.open() returned " + error])
if typeof(p_callback) != typeof(null):
p_callback[0].call_deferred(p_callback[1], null)
return FAILED
settings = f.get_as_text()
f.close()
if typeof(p_callback) != typeof(null):
p_callback[0].call_deferred(p_callback[1], settings)
return settings
func _get_fname(p_slot):
var date = OS.get_date()
var time = OS.get_time()
var day = str(date.day)
if date.day < 10:
day = "0"+day
var hour = str(time.hour)
if time.hour < 10:
hour = "0"+hour
var minute = str(time.minute)
if time.minute < 10:
minute = "0"+minute
var second = str(time.second)
if time.second < 10:
second = "0"+second
var fname = str(p_slot) + "-"
fname = fname + day + "-" + str(date.month) + "-" + str(date.year) + " " + hour+"."+minute+"."+second+".esc"
return fname
func save_game(p_data, p_slot, p_callback):
if p_slot < 0 || p_slot >= max_slots:
return FAILED
var fname = _get_fname(p_slot)
var ret = _do_save(base + "/" + fname, p_data)
if ret != OK:
if typeof(p_callback) != typeof(null):
p_callback[0].call_deferred(p_callback[1], FAILED)
return FAILED
if p_slot in slots:
var old_fname = slots[p_slot].fname
var d = Directory.new()
d.open(base)
d.remove(old_fname)
if typeof(p_callback) != typeof(null):
p_callback[0].call_deferred(p_callback[1], OK)
return OK
func _do_save(fname, p_data):
var f = File.new()
var ret = f.open(fname, File.WRITE)
if ret or not f.is_open():
print("Unable to open file for save ", fname)
return FAILED
if typeof(p_data) == typeof([]):
for s in p_data:
f.store_string(s)
else:
f.store_string(p_data)
f.close()
printt("Saved game to " + fname)
return OK
func load_slot(p_slot, p_callback):
if p_callback == null:
return FAILED
if !(p_slot in slots):
return FAILED
var data = _do_load(slots[p_slot].fname)
if !data:
return FAILED
p_callback[0].call_deferred(p_callback[1], data)
return OK
func load_autosave(p_callback):
if p_callback == null:
return FAILED
var data = _do_load("user://quick_save.esc")
if data == null:
return FAILED
p_callback[0].call_deferred(p_callback[1], data)
return OK
func _do_load(fname):
var f = File.new()
if !f.file_exists(fname):
return null
f.open(fname, File.READ)
var data = f.get_as_text()
f.close()
return data
func autosave(p_data, p_callback):
var err = _do_save("user://quick_save.esc", p_data)
if typeof(p_callback) != typeof(null):
p_callback[0].call_deferred(p_callback[1], err)
return err
func get_slots_available(p_callback):
if p_callback == null:
return FAILED
var d = Directory.new()
d.open("user://")
if !d.dir_exists(base):
d.make_dir(base)
d.open(base)
d.list_dir_begin()
var f = d.get_next()
while f != "":
if f.find(".esc") < 0 || f.find("-") < 0:
f = d.get_next()
continue
var sep = f.find("-")
var n = int(f.substr(0, sep))
if n >= max_slots:
f = d.get_next()
continue
var t = f.replace(".esc", "")
t = t.substr(2, t.length()-2)
var l = t.split(" ")
var h = l[1]
var date = l[0]
slots[n] = { "n": n, "fname": base + "/" + f, "date": date, "hour": h }
f = d.get_next()
d.list_dir_end()
p_callback[0].call_deferred(p_callback[1], slots)
return OK
func autosave_available():
var f = File.new()
return f.file_exists("user://quick_save.esc")
func start():
pass

View File

@@ -1,6 +1,8 @@
# The escorie main script # The escoria main script
extends Node extends Node
# Escoria version number
const ESCORIA_VERSION = "0.1.0"
# Current game state # Current game state
# * DEFAULT: Common game function # * DEFAULT: Common game function
@@ -56,31 +58,7 @@ var dialog_player
var inventory var inventory
# These are settings that the player can affect and save/load later # These are settings that the player can affect and save/load later
var settings : Dictionary var settings: ESCSaveSettings
# These are default settings
var settings_default : Dictionary = {
# Text language
"text_lang": ProjectSettings.get_setting("escoria/main/text_lang"),
# Voice language
"voice_lang": ProjectSettings.get_setting("escoria/main/voice_lang"),
# Speech enabled
"speech_enabled": ProjectSettings.get_setting("escoria/sound/speech_enabled"),
# Master volume (max is 1.0)
"master_volume": ProjectSettings.get_setting("escoria/sound/master_volume"),
# Music volume (max is 1.0)
"music_volume": ProjectSettings.get_setting("escoria/sound/music_volume"),
# Sound effects volume (max is 1.0)
"sfx_volume": ProjectSettings.get_setting("escoria/sound/sfx_volume"),
# Voice volume (for speech only, max is 1.0)
"voice_volume": ProjectSettings.get_setting("escoria/sound/speech_volume"),
# Set fullscreen
"fullscreen": false,
# Allow dialog skipping
"skip_dialog": true,
# XXX: What is this? `achievements.gd` looks like iOS-only
"rate_shown": false,
}
# The current state of the game # The current state of the game
@@ -95,8 +73,8 @@ onready var main = $main
# The escoria inputs manager # The escoria inputs manager
onready var inputs_manager = $inputs_manager onready var inputs_manager = $inputs_manager
# Savegame management # Savegames and settings manager
onready var save_data = load("res://addons/escoria-core/game/core-scripts/save_data/save_data.gd").new() var save_manager: ESCSaveManager
# Initialize various objects # Initialize various objects
@@ -113,14 +91,13 @@ func _init():
self.esc_compiler = ESCCompiler.new() self.esc_compiler = ESCCompiler.new()
self.resource_cache = ESCResourceCache.new() self.resource_cache = ESCResourceCache.new()
self.resource_cache.start() self.resource_cache.start()
self.save_manager = ESCSaveManager.new()
# Load settings # Load settings
func _ready(): func _ready():
save_data.start() settings = ESCSaveSettings.new()
save_data.check_settings() settings = save_manager.load_settings()
var settings = save_data.load_settings(null)
escoria.settings = parse_json(settings)
escoria._on_settings_loaded(escoria.settings) escoria._on_settings_loaded(escoria.settings)
@@ -386,16 +363,12 @@ func _ev_left_click_on_item(obj, event, default_action = false):
# #### Parameters # #### Parameters
# #
# * p_settings: Loaded settings # * p_settings: Loaded settings
func _on_settings_loaded(p_settings : Dictionary) -> void: func _on_settings_loaded(p_settings: ESCSaveSettings) -> void:
escoria.logger.info("******* settings loaded", p_settings) escoria.logger.info("******* settings loaded")
if p_settings != null: if p_settings != null:
settings = p_settings settings = p_settings
else: else:
settings = {} settings = ESCSaveSettings.new()
for k in settings_default:
if !(k in settings):
settings[k] = settings_default[k]
# TODO Apply globally # TODO Apply globally
# AudioServer.set_fx_global_volume_scale(settings.sfx_volume) # AudioServer.set_fx_global_volume_scale(settings.sfx_volume)
@@ -414,4 +387,3 @@ func _on_settings_loaded(p_settings : Dictionary) -> void:
TranslationServer.set_locale(settings.text_lang) TranslationServer.set_locale(settings.text_lang)
# music_volume_changed() # music_volume_changed()

View File

@@ -116,6 +116,13 @@ func set_camera_limits(camera_limit_id : int = 0) -> void:
current_scene.game.get_node("camera").set_offset(screen_ofs * 2) current_scene.game.get_node("camera").set_offset(screen_ofs * 2)
func save_game(p_savegame_res: Resource) -> void:
p_savegame_res.main = {
ESCSaveGame.MAIN_LAST_SCENE_GLOBAL_ID_KEY: last_scene_global_id,
ESCSaveGame.MAIN_CURRENT_SCENE_FILENAME_KEY: current_scene.filename
}
# Sanity check that the game.tscn scene's root node script MUST # Sanity check that the game.tscn scene's root node script MUST
# implement the following methods. If they do not exist, stop immediately. # implement the following methods. If they do not exist, stop immediately.
# Implement them, even if empty # Implement them, even if empty

View File

@@ -9,7 +9,6 @@ func _ready():
"escoria/ui/main_menu_scene" "escoria/ui/main_menu_scene"
) )
var main_menu_scene = load(main_menu_path).instance() var main_menu_scene = load(main_menu_path).instance()
# get_tree().get_root().call_deferred("add_child", main_menu_scene)
escoria.call_deferred("add_child", main_menu_scene) escoria.call_deferred("add_child", main_menu_scene)
escoria.main_menu_instance = main_menu_scene escoria.main_menu_instance = main_menu_scene

View File

@@ -2,7 +2,6 @@
tool tool
extends EditorPlugin extends EditorPlugin
# Autoloads to instantiate # Autoloads to instantiate
const autoloads = { const autoloads = {
"escoria": "res://addons/escoria-core/game/escoria.tscn", "escoria": "res://addons/escoria-core/game/escoria.tscn",
@@ -18,7 +17,6 @@ func _enter_tree():
set_escoria_main_settings() set_escoria_main_settings()
set_escoria_debug_settings() set_escoria_debug_settings()
set_escoria_ui_settings() set_escoria_ui_settings()
set_escoria_internal_settings()
set_escoria_sound_settings() set_escoria_sound_settings()
set_escoria_platform_settings() set_escoria_platform_settings()
@@ -92,6 +90,15 @@ func set_escoria_ui_settings():
# Prepare the settings in the Escoria main category # Prepare the settings in the Escoria main category
func set_escoria_main_settings(): 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",
"type": TYPE_STRING
}
ProjectSettings.add_property_info(game_version_property_info)
if !ProjectSettings.has_setting("escoria/main/game_start_script"): if !ProjectSettings.has_setting("escoria/main/game_start_script"):
ProjectSettings.set_setting("escoria/main/game_start_script", "") ProjectSettings.set_setting("escoria/main/game_start_script", "")
var game_start_script_property_info = { var game_start_script_property_info = {
@@ -121,7 +128,6 @@ func set_escoria_main_settings():
"type": TYPE_ARRAY, "type": TYPE_ARRAY,
}) })
if !ProjectSettings.has_setting("escoria/main/text_lang"): if !ProjectSettings.has_setting("escoria/main/text_lang"):
ProjectSettings.set_setting("escoria/main/text_lang", TranslationServer.get_locale()) ProjectSettings.set_setting("escoria/main/text_lang", TranslationServer.get_locale())
var text_lang_property_info = { var text_lang_property_info = {
@@ -140,6 +146,30 @@ func set_escoria_main_settings():
} }
ProjectSettings.add_property_info(voice_lang_property_info) 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",
"type": TYPE_STRING,
"hint": PROPERTY_HINT_DIR
}
ProjectSettings.add_property_info(settings_path_property_info)
# Prepare the settings in the Escoria debug category # Prepare the settings in the Escoria debug category
func set_escoria_debug_settings(): func set_escoria_debug_settings():
@@ -165,19 +195,6 @@ func set_escoria_debug_settings():
ProjectSettings.add_property_info(property_info) ProjectSettings.add_property_info(property_info)
# Prepare the settings in the Escoria internal category
func set_escoria_internal_settings():
if !ProjectSettings.has_setting("escoria/internals/save_data"):
ProjectSettings.set_setting("escoria/internals/save_data", "")
var save_data_property_info = {
"name": "escoria/internals/save_data",
"type": TYPE_STRING,
"hint": PROPERTY_HINT_FILE,
"hint_string": "*.tscn, *.scn"
}
ProjectSettings.add_property_info(save_data_property_info)
# Prepare the settings in the Escoria sound settings # Prepare the settings in the Escoria sound settings
func set_escoria_sound_settings(): func set_escoria_sound_settings():
if !ProjectSettings.has_setting("escoria/sound/master_volume"): if !ProjectSettings.has_setting("escoria/sound/master_volume"):
@@ -220,6 +237,14 @@ func set_escoria_sound_settings():
} }
ProjectSettings.add_property_info(speech_data_property_info) ProjectSettings.add_property_info(speech_data_property_info)
if !ProjectSettings.has_setting("escoria/sound/speech_enabled"):
ProjectSettings.set_setting("escoria/sound/speech_enabled", 1)
var speech_enabled_property_info = {
"name": "escoria/sound/speech_enabled",
"type": TYPE_BOOL
}
ProjectSettings.add_property_info(speech_enabled_property_info)
# Prepare the settings in the Escoria platform category and may need special # Prepare the settings in the Escoria platform category and may need special
# setting per build # setting per build

View File

@@ -162,8 +162,8 @@ func calculate_areas(nb_directions : int = 8):
$VBoxContainer/VBoxContainer/angles/angle_array.text = str(result_angles) $VBoxContainer/VBoxContainer/angles/angle_array.text = str(result_angles)
construct_scene_nodes(angles) construct_scene_nodes(angles)
func construct_scene_nodes(angles):
func construct_scene_nodes(angles):
var areas_nodes = [] var areas_nodes = []
for i in angles.size(): for i in angles.size():
var polygon_node = Polygon2D.new() var polygon_node = Polygon2D.new()

View File

@@ -9,191 +9,191 @@
[ext_resource path="res://game/characters/mark/png/mark_talk_right.png" type="Texture" id=7] [ext_resource path="res://game/characters/mark/png/mark_talk_right.png" type="Texture" id=7]
[sub_resource type="AtlasTexture" id=1] [sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 4 ) atlas = ExtResource( 2 )
region = Rect2( 48, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 5 )
region = Rect2( 0, 0, 24, 70 ) region = Rect2( 0, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=3] [sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 5 ) atlas = ExtResource( 2 )
region = Rect2( 24, 0, 24, 70 ) region = Rect2( 24, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=4] [sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 5 ) atlas = ExtResource( 2 )
region = Rect2( 48, 0, 24, 70 ) region = Rect2( 48, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=5] [sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 4 ) atlas = ExtResource( 4 )
region = Rect2( 96, 0, 24, 70 ) region = Rect2( 96, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 5 )
region = Rect2( 0, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=6] [sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 4 ) atlas = ExtResource( 5 )
region = Rect2( 72, 0, 24, 70 ) region = Rect2( 24, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=7] [sub_resource type="AtlasTexture" id=7]
atlas = ExtResource( 4 ) atlas = ExtResource( 5 )
region = Rect2( 216, 0, 24, 70 ) region = Rect2( 48, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=8] [sub_resource type="AtlasTexture" id=8]
atlas = ExtResource( 4 ) atlas = ExtResource( 4 )
region = Rect2( 240, 0, 24, 70 ) region = Rect2( 24, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=9] [sub_resource type="AtlasTexture" id=9]
atlas = ExtResource( 4 ) atlas = ExtResource( 4 )
region = Rect2( 264, 0, 24, 70 ) region = Rect2( 0, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=10] [sub_resource type="AtlasTexture" id=10]
atlas = ExtResource( 4 ) atlas = ExtResource( 7 )
region = Rect2( 288, 0, 24, 70 ) region = Rect2( 0, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=11] [sub_resource type="AtlasTexture" id=11]
atlas = ExtResource( 4 ) atlas = ExtResource( 7 )
region = Rect2( 312, 0, 24, 70 ) region = Rect2( 24, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=12] [sub_resource type="AtlasTexture" id=12]
atlas = ExtResource( 7 ) atlas = ExtResource( 7 )
region = Rect2( 0, 0, 24, 70 ) region = Rect2( 48, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=13] [sub_resource type="AtlasTexture" id=13]
atlas = ExtResource( 7 ) atlas = ExtResource( 7 )
region = Rect2( 24, 0, 24, 70 ) region = Rect2( 72, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=14] [sub_resource type="AtlasTexture" id=14]
atlas = ExtResource( 7 ) atlas = ExtResource( 7 )
region = Rect2( 48, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=15]
atlas = ExtResource( 7 )
region = Rect2( 72, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=16]
atlas = ExtResource( 7 )
region = Rect2( 96, 0, 24, 70 ) region = Rect2( 96, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=17] [sub_resource type="AtlasTexture" id=15]
atlas = ExtResource( 4 )
region = Rect2( 0, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=18]
atlas = ExtResource( 4 )
region = Rect2( 120, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=19]
atlas = ExtResource( 4 ) atlas = ExtResource( 4 )
region = Rect2( 144, 0, 24, 70 ) region = Rect2( 144, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=20] [sub_resource type="AtlasTexture" id=16]
atlas = ExtResource( 4 ) atlas = ExtResource( 4 )
region = Rect2( 168, 0, 24, 70 ) region = Rect2( 168, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=21] [sub_resource type="AtlasTexture" id=17]
atlas = ExtResource( 4 ) atlas = ExtResource( 4 )
region = Rect2( 192, 0, 24, 70 ) region = Rect2( 192, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=22] [sub_resource type="AtlasTexture" id=18]
atlas = ExtResource( 2 ) atlas = ExtResource( 4 )
region = Rect2( 0, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=23]
atlas = ExtResource( 2 )
region = Rect2( 24, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=24]
atlas = ExtResource( 2 )
region = Rect2( 48, 0, 24, 70 ) region = Rect2( 48, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=19]
atlas = ExtResource( 4 )
region = Rect2( 120, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=20]
atlas = ExtResource( 4 )
region = Rect2( 216, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=21]
atlas = ExtResource( 4 )
region = Rect2( 240, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=22]
atlas = ExtResource( 4 )
region = Rect2( 264, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=23]
atlas = ExtResource( 4 )
region = Rect2( 288, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=24]
atlas = ExtResource( 4 )
region = Rect2( 312, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=25] [sub_resource type="AtlasTexture" id=25]
atlas = ExtResource( 6 ) atlas = ExtResource( 4 )
region = Rect2( 0, 0, 24, 70 ) region = Rect2( 72, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=26] [sub_resource type="AtlasTexture" id=26]
atlas = ExtResource( 6 )
region = Rect2( 24, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=27]
atlas = ExtResource( 4 )
region = Rect2( 24, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=28]
atlas = ExtResource( 4 ) atlas = ExtResource( 4 )
region = Rect2( 336, 0, 24, 70 ) region = Rect2( 336, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=29] [sub_resource type="AtlasTexture" id=27]
atlas = ExtResource( 4 ) atlas = ExtResource( 4 )
region = Rect2( 360, 0, 24, 70 ) region = Rect2( 360, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=30] [sub_resource type="AtlasTexture" id=28]
atlas = ExtResource( 4 ) atlas = ExtResource( 4 )
region = Rect2( 384, 0, 24, 70 ) region = Rect2( 384, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=29]
atlas = ExtResource( 6 )
region = Rect2( 0, 0, 24, 70 )
[sub_resource type="AtlasTexture" id=30]
atlas = ExtResource( 6 )
region = Rect2( 24, 0, 24, 70 )
[sub_resource type="SpriteFrames" id=31] [sub_resource type="SpriteFrames" id=31]
animations = [ { animations = [ {
"frames": [ SubResource( 1 ) ], "frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 2 ), SubResource( 3 ) ],
"loop": true,
"name": "idle_right",
"speed": 5.0
}, {
"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ],
"loop": true,
"name": "speak_down_right",
"speed": 6.0
}, {
"frames": [ SubResource( 5 ) ],
"loop": true,
"name": "idle_left",
"speed": 5.0
}, {
"frames": [ SubResource( 6 ) ],
"loop": true,
"name": "idle_up",
"speed": 5.0
}, {
"frames": [ SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ) ],
"loop": true,
"name": "walk_right",
"speed": 6.0
}, {
"frames": [ SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ],
"loop": true,
"name": "speak_right",
"speed": 5.0
}, {
"frames": [ SubResource( 17 ) ],
"loop": true,
"name": "idle_down",
"speed": 5.0
}, {
"frames": [ SubResource( 18 ) ],
"loop": true,
"name": "idle_down_left",
"speed": 5.0
}, {
"frames": [ SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 20 ) ],
"loop": true,
"name": "walk_down",
"speed": 6.0
}, {
"frames": [ SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 23 ), SubResource( 24 ) ],
"loop": true, "loop": true,
"name": "speak_down", "name": "speak_down",
"speed": 6.0 "speed": 6.0
}, { }, {
"frames": [ SubResource( 25 ), SubResource( 26 ), SubResource( 25 ), SubResource( 26 ), SubResource( 26 ) ], "frames": [ SubResource( 4 ) ],
"loop": true, "loop": true,
"name": "speak_up", "name": "idle_left",
"speed": 3.0 "speed": 5.0
}, { }, {
"frames": [ SubResource( 27 ) ], "frames": [ SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ],
"loop": true,
"name": "speak_down_right",
"speed": 6.0
}, {
"frames": [ SubResource( 8 ) ],
"loop": true, "loop": true,
"name": "idle_down_right", "name": "idle_down_right",
"speed": 5.0 "speed": 5.0
}, { }, {
"frames": [ SubResource( 28 ), SubResource( 29 ), SubResource( 30 ), SubResource( 29 ) ], "frames": [ SubResource( 9 ) ],
"loop": true,
"name": "idle_down",
"speed": 5.0
}, {
"frames": [ SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ) ],
"loop": true,
"name": "speak_right",
"speed": 5.0
}, {
"frames": [ SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 16 ) ],
"loop": true,
"name": "walk_down",
"speed": 6.0
}, {
"frames": [ SubResource( 18 ) ],
"loop": true,
"name": "idle_right",
"speed": 5.0
}, {
"frames": [ SubResource( 19 ) ],
"loop": true,
"name": "idle_down_left",
"speed": 5.0
}, {
"frames": [ SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ) ],
"loop": true,
"name": "walk_right",
"speed": 6.0
}, {
"frames": [ SubResource( 25 ) ],
"loop": true,
"name": "idle_up",
"speed": 5.0
}, {
"frames": [ SubResource( 26 ), SubResource( 27 ), SubResource( 28 ), SubResource( 27 ) ],
"loop": true, "loop": true,
"name": "walk_up", "name": "walk_up",
"speed": 6.0 "speed": 6.0
}, {
"frames": [ SubResource( 29 ), SubResource( 30 ), SubResource( 29 ), SubResource( 30 ), SubResource( 30 ) ],
"loop": true,
"name": "speak_up",
"speed": 3.0
} ] } ]
[sub_resource type="CapsuleShape2D" id=32] [sub_resource type="CapsuleShape2D" id=32]
@@ -202,6 +202,7 @@ height = 0.0
[node name="mark" type="Area2D"] [node name="mark" type="Area2D"]
script = ExtResource( 1 ) script = ExtResource( 1 )
global_id = "player" global_id = "player"
is_movable = true
dialog_color = Color( 1, 1, 1, 1 ) dialog_color = Color( 1, 1, 1, 1 )
animations = ExtResource( 3 ) animations = ExtResource( 3 )

View File

@@ -39,6 +39,7 @@ say player "Hey!"
enable_terrain bridge_open enable_terrain bridge_open
set_global r2_bridge_closed false set_global r2_bridge_closed false
#set_interactive r2_right_platform true #set_interactive r2_right_platform true
set_interactive r2_bridge false
stop stop
> [!r2_bridge_closed] > [!r2_bridge_closed]
set_state r2_bridge bridge_close set_state r2_bridge bridge_close

View File

@@ -16,18 +16,9 @@ player_scene = ExtResource( 4 )
camera_limits = [ Rect2( 0, 0, 1289, 555 ) ] camera_limits = [ Rect2( 0, 0, 1289, 555 ) ]
[node name="walkable_area" parent="." instance=ExtResource( 1 )] [node name="walkable_area" parent="." instance=ExtResource( 1 )]
scales = null
bitmaps_scale = Vector2( 1, 1 )
lightmap = null
player_speed_multiplier = 1.0
player_doubleclick_speed_multiplier = 1.5
lightmap_modulate = Color( 1, 1, 1, 1 )
debug_mode = 1 debug_mode = 1
scale_min = 0.3
scale_max = 1.0
[node name="background" parent="." instance=ExtResource( 2 )] [node name="background" parent="." instance=ExtResource( 2 )]
esc_script = ""
[node name="room_label" type="Label" parent="background"] [node name="room_label" type="Label" parent="background"]
margin_right = 40.0 margin_right = 40.0
@@ -44,26 +35,10 @@ __meta__ = {
script = ExtResource( 7 ) script = ExtResource( 7 )
global_id = "r2_right_platform" global_id = "r2_right_platform"
esc_script = "res://game/rooms/room2/esc/right_platform.esc" esc_script = "res://game/rooms/room2/esc/right_platform.esc"
is_exit = false
is_trigger = false
trigger_in_verb = "trigger_in"
trigger_out_verb = "trigger_out"
is_interactive = true
player_orients_on_arrival = true
interaction_direction = 3 interaction_direction = 3
tooltip_name = "Right platform" tooltip_name = "Right platform"
default_action = "look" default_action = "look"
combine_if_action_used_among = PoolStringArray( )
combine_is_one_way = false
use_from_inventory_only = false
inventory_item_scene_file = null
dialog_color = Color( 1, 1, 1, 1 ) dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": Vector2( 430.893, 451.052 )
}
animations = null
speed = 300
v_speed_damp = 1.0
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_platform"] [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_platform"]
polygon = PoolVector2Array( 870.974, 538.342, 827.536, 353.995, 1181.4, 357.174, 1287.34, 413.325, 1289.46, 545.758 ) polygon = PoolVector2Array( 870.974, 538.342, 827.536, 353.995, 1181.4, 357.174, 1287.34, 413.325, 1289.46, 545.758 )
@@ -76,25 +51,9 @@ script = ExtResource( 7 )
global_id = "r2_r_exit" global_id = "r2_r_exit"
esc_script = "res://game/rooms/room2/esc/right_exit.esc" esc_script = "res://game/rooms/room2/esc/right_exit.esc"
is_exit = true is_exit = true
is_trigger = false
trigger_in_verb = "trigger_in"
trigger_out_verb = "trigger_out"
is_interactive = true
player_orients_on_arrival = true
interaction_direction = 0
tooltip_name = "Right exit" tooltip_name = "Right exit"
default_action = "walk" default_action = "walk"
combine_if_action_used_among = PoolStringArray( )
combine_is_one_way = false
use_from_inventory_only = false
inventory_item_scene_file = null
dialog_color = Color( 1, 1, 1, 1 ) dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": Vector2( 1225.47, 353.99 )
}
animations = null
speed = 300
v_speed_damp = 1.0
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door"] [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door"]
polygon = PoolVector2Array( 1177.94, 348.61, 1175.95, 45.3759, 1276.06, 92.0953, 1277.95, 399.407 ) polygon = PoolVector2Array( 1177.94, 348.61, 1175.95, 45.3759, 1276.06, 92.0953, 1277.95, 399.407 )
@@ -107,25 +66,9 @@ script = ExtResource( 7 )
global_id = "r2_l_exit" global_id = "r2_l_exit"
esc_script = "res://game/rooms/room2/esc/left_exit.esc" esc_script = "res://game/rooms/room2/esc/left_exit.esc"
is_exit = true is_exit = true
is_trigger = false
trigger_in_verb = "trigger_in"
trigger_out_verb = "trigger_out"
is_interactive = true
player_orients_on_arrival = true
interaction_direction = 0
tooltip_name = "Left exit" tooltip_name = "Left exit"
default_action = "walk" default_action = "walk"
combine_if_action_used_among = PoolStringArray( )
combine_is_one_way = false
use_from_inventory_only = false
inventory_item_scene_file = null
dialog_color = Color( 1, 1, 1, 1 ) dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": Vector2( 52.1462, 384.691 )
}
animations = null
speed = 300
v_speed_damp = 1.0
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/l_door"] [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/l_door"]
polygon = PoolVector2Array( -1.37926, 443.158, 7.96461, 122.796, 84.0504, 77.4118, 88.055, 377.751 ) polygon = PoolVector2Array( -1.37926, 443.158, 7.96461, 122.796, 84.0504, 77.4118, 88.055, 377.751 )
@@ -137,24 +80,7 @@ position = Vector2( 52.1462, 384.691 )
position = Vector2( 958.107, 176.401 ) position = Vector2( 958.107, 176.401 )
global_id = "r2_button_right" global_id = "r2_button_right"
esc_script = "res://game/rooms/room2/esc/button.esc" esc_script = "res://game/rooms/room2/esc/button.esc"
is_exit = false
is_trigger = false
trigger_in_verb = "trigger_in"
trigger_out_verb = "trigger_out"
is_interactive = true
player_orients_on_arrival = true
interaction_direction = 0
combine_if_action_used_among = PoolStringArray( )
combine_is_one_way = false
use_from_inventory_only = false
inventory_item_scene_file = null
dialog_color = Color( 0, 1, 0.109804, 1 ) dialog_color = Color( 0, 1, 0.109804, 1 )
interact_positions = {
"default": Vector2( 987.537, 371.812 )
}
animations = null
speed = 300
v_speed_damp = 1.0
[node name="Position2D" type="Position2D" parent="Hotspots/button_right"] [node name="Position2D" type="Position2D" parent="Hotspots/button_right"]
position = Vector2( 29.4302, 195.411 ) position = Vector2( 29.4302, 195.411 )
@@ -166,24 +92,7 @@ __meta__ = {
position = Vector2( 288.82, 171.439 ) position = Vector2( 288.82, 171.439 )
global_id = "r2_button" global_id = "r2_button"
esc_script = "res://game/rooms/room2/esc/button.esc" esc_script = "res://game/rooms/room2/esc/button.esc"
is_exit = false
is_trigger = false
trigger_in_verb = "trigger_in"
trigger_out_verb = "trigger_out"
is_interactive = true
player_orients_on_arrival = true
interaction_direction = 0
combine_if_action_used_among = PoolStringArray( )
combine_is_one_way = false
use_from_inventory_only = false
inventory_item_scene_file = null
dialog_color = Color( 0, 1, 0.109804, 1 ) dialog_color = Color( 0, 1, 0.109804, 1 )
interact_positions = {
"default": Vector2( 313.488, 368.437 )
}
animations = null
speed = 300
v_speed_damp = 1.0
[node name="Position2D" type="Position2D" parent="Hotspots/button_left"] [node name="Position2D" type="Position2D" parent="Hotspots/button_left"]
position = Vector2( 24.6681, 196.998 ) position = Vector2( 24.6681, 196.998 )

View File

@@ -15,6 +15,7 @@ say player "I must USE this."
enable_terrain bridge_closed enable_terrain bridge_closed
set_global r3_bridge_closed true set_global r3_bridge_closed true
set_interactive r3_right_platform false set_interactive r3_right_platform false
set_interactive r3_bridge false
stop stop
> [!button_broken, r3_bridge_closed] > [!button_broken, r3_bridge_closed]

View File

@@ -28,7 +28,7 @@
stop stop
:ready :ready
set_global bridge_closed false set_global r3_bridge_closed false
set_state r3_button button_broken set_state r3_button button_broken
set_global button_broken true set_global button_broken true

View File

@@ -8,3 +8,6 @@ OPTIONS_LANGUAGE,Language,Langue
GENERAL_VOLUME,General,Général GENERAL_VOLUME,General,Général
MUSIC_VOLUME,Music,Musique MUSIC_VOLUME,Music,Musique
SOUND_VOLUME,Sound effects,Effets sonores SOUND_VOLUME,Sound effects,Effets sonores
CANCEL,Cancel,Annuler
OK,OK,OK
ENTER_SAVE_NAME,Enter the save name:,Entrez un nom de sauvegarde
1 keys en fr
8 GENERAL_VOLUME General Général
9 MUSIC_VOLUME Music Musique
10 SOUND_VOLUME Sound effects Effets sonores
11 CANCEL Cancel Annuler
12 OK OK OK
13 ENTER_SAVE_NAME Enter the save name: Entrez un nom de sauvegarde

View File

@@ -0,0 +1,26 @@
extends Control
signal back_button_pressed
export(PackedScene) var slot_ui_scene
func _ready():
refresh_savegames()
func _on_slot_pressed(slot_id: int) -> void:
escoria.save_manager.load_game(slot_id)
func _on_back_pressed():
emit_signal("back_button_pressed")
func refresh_savegames():
for slot in $ScrollContainer/slots.get_children():
$ScrollContainer/slots.remove_child(slot)
var saves_list = escoria.save_manager.get_saves_list()
for i in saves_list.size():
var save_data = saves_list[i+1]
var new_slot = slot_ui_scene.instance()
$ScrollContainer/slots.add_child(new_slot)
new_slot.set_slot_name_date(save_data["name"], save_data["date"])
new_slot.connect("pressed", self, "_on_slot_pressed", [i+1])

View File

@@ -0,0 +1,50 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=1]
[ext_resource path="res://game/ui/commons/load_save_slot/load_save_slot.tscn" type="PackedScene" id=2]
[ext_resource path="res://game/ui/commons/load/load_game.gd" type="Script" id=3]
[node name="load_game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
slot_ui_scene = ExtResource( 2 )
[node name="back" type="Button" parent="."]
margin_left = 130.0
margin_top = 329.0
margin_right = 304.0
margin_bottom = 383.0
custom_fonts/font = ExtResource( 1 )
text = "OPTIONS_BACK"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ScrollContainer" type="ScrollContainer" parent="."]
anchor_left = 0.291
anchor_top = 0.369
anchor_right = 0.709
anchor_bottom = 0.941
margin_left = -0.480011
margin_top = -1.10001
margin_right = 0.479919
margin_bottom = -0.900024
scroll_horizontal_enabled = false
__meta__ = {
"_edit_use_anchors_": false
}
[node name="slots" type="VBoxContainer" parent="ScrollContainer"]
margin_right = 536.0
margin_bottom = 515.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="back" to="." method="_on_back_pressed"]

View File

@@ -0,0 +1,7 @@
extends Button
func set_slot_name_date(p_name: String, p_date: String):
$VBoxContainer/slot_name.text = p_name
$VBoxContainer/date.text = p_date

View File

@@ -0,0 +1,38 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=1]
[ext_resource path="res://game/ui/commons/load_save_slot/load_save_slot.gd" type="Script" id=2]
[node name="slot" type="Button"]
margin_right = 665.0
margin_bottom = 86.0
rect_min_size = Vector2( 0, 100 )
size_flags_horizontal = 3
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="slot_name" type="Label" parent="VBoxContainer"]
margin_top = 27.0
margin_right = 665.0
margin_bottom = 48.0
custom_fonts/font = ExtResource( 1 )
text = "slot_name"
align = 1
[node name="date" type="Label" parent="VBoxContainer"]
margin_top = 52.0
margin_right = 665.0
margin_bottom = 73.0
custom_fonts/font = ExtResource( 1 )
text = "date"
align = 1

View File

@@ -25,9 +25,6 @@ func _on_continue_pressed():
pass pass
func switch_language(lang: String): func switch_language(lang: String):
TranslationServer.set_locale(lang) TranslationServer.set_locale(lang)
@@ -35,14 +32,18 @@ func switch_language(lang : String):
func _on_new_game_pressed(): func _on_new_game_pressed():
escoria.new_game() escoria.new_game()
func _on_load_game_pressed(): func _on_load_game_pressed():
# Show Loading screen $Panel/main.hide()
pass $Panel/load_game.refresh_savegames()
$Panel/load_game.show()
func _on_options_pressed(): func _on_options_pressed():
$Panel/main.hide() $Panel/main.hide()
$Panel/options.show() $Panel/options.show()
func _on_quit_pressed(): func _on_quit_pressed():
get_tree().quit() get_tree().quit()
@@ -50,8 +51,12 @@ func _on_quit_pressed():
########################################################################### ###########################################################################
# OPTIONS # OPTIONS
func _on_options_back_button_pressed():
func _on_back_pressed():
$Panel/options.hide() $Panel/options.hide()
$Panel/main.show() $Panel/main.show()
func _on_load_game_back_button_pressed():
$Panel/load_game.hide()
$Panel/main.show()

View File

@@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://game/ui/commons/main_menu/main_menu.gd" type="Script" id=1] [ext_resource path="res://game/ui/commons/main_menu/main_menu.gd" type="Script" id=1]
[ext_resource path="res://game/ui/commons/main_menu/main.tscn" type="PackedScene" id=2] [ext_resource path="res://game/ui/commons/main_menu/main.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/escoria-core/logo/escoria-logo-small.png" type="Texture" id=3] [ext_resource path="res://addons/escoria-core/logo/escoria-logo-small.png" type="Texture" id=3]
[ext_resource path="res://game/ui/commons/main_menu/options.tscn" type="PackedScene" id=4] [ext_resource path="res://game/ui/commons/options/options.tscn" type="PackedScene" id=4]
[ext_resource path="res://game/ui/commons/load/load_game.tscn" type="PackedScene" id=5]
[node name="main_menu" type="Control"] [node name="main_menu" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@@ -38,11 +39,14 @@ __meta__ = {
[node name="options" parent="Panel" instance=ExtResource( 4 )] [node name="options" parent="Panel" instance=ExtResource( 4 )]
visible = false visible = false
[node name="load_game" parent="Panel" instance=ExtResource( 5 )]
visible = false
[connection signal="pressed" from="Panel/main/new_game" to="." method="_on_new_game_pressed"] [connection signal="pressed" from="Panel/main/new_game" to="." method="_on_new_game_pressed"]
[connection signal="pressed" from="Panel/main/load_game" to="." method="_on_load_game_pressed"] [connection signal="pressed" from="Panel/main/load_game" to="." method="_on_load_game_pressed"]
[connection signal="pressed" from="Panel/main/options" to="." method="_on_options_pressed"] [connection signal="pressed" from="Panel/main/options" to="." method="_on_options_pressed"]
[connection signal="pressed" from="Panel/main/quit" to="." method="_on_quit_pressed"] [connection signal="pressed" from="Panel/main/quit" to="." method="_on_quit_pressed"]
[connection signal="pressed" from="Panel/options/back" to="." method="_on_back_pressed"] [connection signal="back_button_pressed" from="Panel/options" to="." method="_on_options_back_button_pressed"]
[connection signal="back_button_pressed" from="Panel/load_game" to="." method="_on_load_game_back_button_pressed"]
[editable path="Panel/main"] [editable path="Panel/main"]
[editable path="Panel/options"]

View File

@@ -1,35 +1,63 @@
extends Control extends Control
signal back_button_pressed
onready var settings_changed = false
onready var backup_settings
func _ready(): func _ready():
initialize_options(escoria.settings) initialize_options(escoria.settings)
func show():
backup_settings = escoria.settings.duplicate()
initialize_options(backup_settings)
visible = true
func initialize_options(p_settings): func initialize_options(p_settings):
$options/general_volume.value = p_settings["master_volume"] $options/general_volume.value = p_settings["master_volume"]
$options/sound_volume.value = p_settings["sfx_volume"] $options/sound_volume.value = p_settings["sfx_volume"]
$options/music_volume.value = p_settings["music_volume"] $options/music_volume.value = p_settings["music_volume"]
func greyout_other_languages(except_lang: String) -> void: func greyout_other_languages(except_lang: String) -> void:
pass pass
func _on_language_input(event: InputEvent, language: String): func _on_language_input(event: InputEvent, language: String):
if event.is_pressed(): if event.is_pressed():
TranslationServer.set_locale(language) TranslationServer.set_locale(language)
escoria.settings["text_lang"] = language escoria.settings["text_lang"] = language
escoria.save_data.save_settings(escoria.settings, null) settings_changed = true
func _on_sound_volume_changed(value): func _on_sound_volume_changed(value):
escoria.settings["sfx_volume"] = value escoria.settings["sfx_volume"] = value
escoria.save_data.save_settings(escoria.settings, null)
escoria._on_settings_loaded(escoria.settings) escoria._on_settings_loaded(escoria.settings)
settings_changed = true
func _on_music_volume_changed(value): func _on_music_volume_changed(value):
escoria.settings["music_volume"] = value escoria.settings["music_volume"] = value
escoria.save_data.save_settings(escoria.settings, null)
escoria._on_settings_loaded(escoria.settings) escoria._on_settings_loaded(escoria.settings)
settings_changed = true
func _on_general_volume_changed(value): func _on_general_volume_changed(value):
escoria.settings["master_volume"] = value escoria.settings["master_volume"] = value
escoria.save_data.save_settings(escoria.settings, null)
escoria._on_settings_loaded(escoria.settings) escoria._on_settings_loaded(escoria.settings)
settings_changed = true
func _on_apply_pressed():
escoria.save_manager.save_settings()
settings_changed = false
emit_signal("back_button_pressed")
func _on_back_pressed():
escoria.settings = backup_settings
escoria._on_settings_loaded(escoria.settings)
emit_signal("back_button_pressed")

View File

@@ -3,7 +3,7 @@
[ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=1] [ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=1]
[ext_resource path="res://game/ui/commons/main_menu/flags/en_EN_small.png" type="Texture" id=2] [ext_resource path="res://game/ui/commons/main_menu/flags/en_EN_small.png" type="Texture" id=2]
[ext_resource path="res://game/ui/commons/main_menu/flags/fr_FR_small.png" type="Texture" id=3] [ext_resource path="res://game/ui/commons/main_menu/flags/fr_FR_small.png" type="Texture" id=3]
[ext_resource path="res://game/ui/commons/main_menu/options.gd" type="Script" id=4] [ext_resource path="res://game/ui/commons/options/options.gd" type="Script" id=4]
[node name="options" type="Control"] [node name="options" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@@ -125,8 +125,21 @@ max_value = 1.0
step = 0.001 step = 0.001
value = 0.001 value = 0.001
[node name="apply" type="Button" parent="."]
margin_left = 364.0
margin_top = 712.0
margin_right = 544.0
margin_bottom = 767.0
custom_fonts/font = ExtResource( 1 )
text = "APPLY"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="back" to="." method="_on_back_pressed"]
[connection signal="gui_input" from="options/flags/fr" to="." method="_on_language_input" binds= [ "fr" ]] [connection signal="gui_input" from="options/flags/fr" to="." method="_on_language_input" binds= [ "fr" ]]
[connection signal="gui_input" from="options/flags/en" to="." method="_on_language_input" binds= [ "en" ]] [connection signal="gui_input" from="options/flags/en" to="." method="_on_language_input" binds= [ "en" ]]
[connection signal="value_changed" from="options/general_volume" to="." method="_on_general_volume_changed"] [connection signal="value_changed" from="options/general_volume" to="." method="_on_general_volume_changed"]
[connection signal="value_changed" from="options/sound_volume" to="." method="_on_sound_volume_changed"] [connection signal="value_changed" from="options/sound_volume" to="." method="_on_sound_volume_changed"]
[connection signal="value_changed" from="options/music_volume" to="." method="_on_music_volume_changed"] [connection signal="value_changed" from="options/music_volume" to="." method="_on_music_volume_changed"]
[connection signal="pressed" from="apply" to="." method="_on_apply_pressed"]

View File

@@ -6,12 +6,25 @@ func _on_continue_pressed():
func _on_save_game_pressed(): func _on_save_game_pressed():
pass $Panel/VBoxContainer.hide()
$save_game.show()
func _on_load_game_pressed(): func _on_load_game_pressed():
pass $Panel/VBoxContainer.hide()
$load_game.refresh_savegames()
$load_game.show()
func _on_quit_pressed(): func _on_quit_pressed():
get_tree().quit() get_tree().quit()
func _on_save_game_back_button_pressed():
$Panel/VBoxContainer.show()
$save_game.hide()
func _on_load_game_back_button_pressed():
$Panel/VBoxContainer.show()
$load_game.hide()

View File

@@ -1,8 +1,10 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://game/ui/commons/pause_menu/pause_menu.gd" type="Script" id=1] [ext_resource path="res://game/ui/commons/pause_menu/pause_menu.gd" type="Script" id=1]
[ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=2] [ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=2]
[ext_resource path="res://addons/escoria-core/logo/escoria-logo-small.png" type="Texture" id=3] [ext_resource path="res://addons/escoria-core/logo/escoria-logo-small.png" type="Texture" id=3]
[ext_resource path="res://game/ui/commons/save/save_game.tscn" type="PackedScene" id=4]
[ext_resource path="res://game/ui/commons/load/load_game.tscn" type="PackedScene" id=5]
[node name="pause_menu" type="Control"] [node name="pause_menu" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@@ -87,7 +89,15 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="save_game" parent="." instance=ExtResource( 4 )]
visible = false
[node name="load_game" parent="." instance=ExtResource( 5 )]
visible = false
[connection signal="pressed" from="Panel/VBoxContainer/continue" to="." method="_on_continue_pressed"] [connection signal="pressed" from="Panel/VBoxContainer/continue" to="." method="_on_continue_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/save_game" to="." method="_on_save_game_pressed"] [connection signal="pressed" from="Panel/VBoxContainer/save_game" to="." method="_on_save_game_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/load_game" to="." method="_on_load_game_pressed"] [connection signal="pressed" from="Panel/VBoxContainer/load_game" to="." method="_on_load_game_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/quit" to="." method="_on_quit_pressed"] [connection signal="pressed" from="Panel/VBoxContainer/quit" to="." method="_on_quit_pressed"]
[connection signal="back_button_pressed" from="save_game" to="." method="_on_save_game_back_button_pressed"]
[connection signal="back_button_pressed" from="load_game" to="." method="_on_load_game_back_button_pressed"]

View File

@@ -0,0 +1,59 @@
extends Control
signal back_button_pressed
export(PackedScene) var slot_ui_scene
var slot_pressed
func _ready():
refresh_savegames()
func _on_slot_pressed(p_slot_n: int):
slot_pressed = p_slot_n
if escoria.save_manager.save_game_exists(p_slot_n):
# TODO Manage save override, ask for confirmation
pass
else:
$save_name_popup.popup()
func refresh_savegames():
for slot in $ScrollContainer/slots.get_children():
$ScrollContainer/slots.remove_child(slot)
var saves_list = escoria.save_manager.get_saves_list()
for i in saves_list.size():
var save_data = saves_list[i+1]
var new_slot = slot_ui_scene.instance()
$ScrollContainer/slots.add_child(new_slot)
new_slot.set_slot_name_date(save_data["name"], save_data["date"])
new_slot.connect("pressed", self, "_on_slot_pressed", [i+1])
var datetime = OS.get_datetime()
var datetime_string = "%02d/%02d/%02d %02d:%02d" % [
datetime["day"],
datetime["month"],
datetime["year"],
datetime["hour"],
datetime["minute"],
]
var new_slot = slot_ui_scene.instance()
$ScrollContainer/slots.add_child(new_slot)
new_slot.set_slot_name_date(tr("New save"), datetime_string)
new_slot.connect("pressed", self, "_on_slot_pressed", [saves_list.size()+1])
func _on_back_pressed():
emit_signal("back_button_pressed")
func _on_save_name_popup_savegame_name_ok(p_savename: String):
escoria.save_manager.save_game(slot_pressed, p_savename)
refresh_savegames()
slot_pressed = null
func _on_save_name_popup_savegame_cancel():
pass

View File

@@ -0,0 +1,54 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://game/ui/commons/load_save_slot/load_save_slot.tscn" type="PackedScene" id=1]
[ext_resource path="res://game/ui/commons/save/save_game.gd" type="Script" id=2]
[ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=3]
[ext_resource path="res://game/ui/commons/save/save_name_popup.tscn" type="PackedScene" id=4]
[node name="save_game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
slot_ui_scene = ExtResource( 1 )
[node name="back" type="Button" parent="."]
margin_left = 130.0
margin_top = 329.0
margin_right = 304.0
margin_bottom = 383.0
custom_fonts/font = ExtResource( 3 )
text = "OPTIONS_BACK"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ScrollContainer" type="ScrollContainer" parent="."]
anchor_left = 0.284
anchor_top = 0.367
anchor_right = 0.709
anchor_bottom = 0.94
margin_left = 8.47998
margin_top = 0.699982
margin_right = 0.479919
margin_bottom = -6.10352e-05
__meta__ = {
"_edit_use_anchors_": false
}
[node name="slots" type="VBoxContainer" parent="ScrollContainer"]
margin_right = 536.0
margin_bottom = 515.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="save_name_popup" parent="." instance=ExtResource( 4 )]
[connection signal="pressed" from="back" to="." method="_on_back_pressed"]
[connection signal="savegame_cancel" from="save_name_popup" to="." method="_on_save_name_popup_savegame_cancel"]
[connection signal="savegame_name_ok" from="save_name_popup" to="." method="_on_save_name_popup_savegame_name_ok"]

View File

@@ -0,0 +1,14 @@
extends PopupDialog
signal savegame_name_ok(savegame_name)
signal savegame_cancel
func _on_cancel_pressed():
emit_signal("savegame_cancel")
hide()
func _on_ok_pressed():
if not $MarginContainer/VBoxContainer/LineEdit.text.empty():
emit_signal("savegame_name_ok", $MarginContainer/VBoxContainer/LineEdit.text)
$MarginContainer/VBoxContainer/LineEdit.clear()
hide()

View File

@@ -0,0 +1,81 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=1]
[ext_resource path="res://game/ui/commons/save/save_name_popup.gd" type="Script" id=2]
[node name="save_name_popup" type="PopupDialog"]
margin_left = 429.0
margin_top = 281.0
margin_right = 863.0
margin_bottom = 442.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
custom_constants/margin_right = 30
custom_constants/margin_top = 30
custom_constants/margin_left = 30
custom_constants/margin_bottom = 30
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
margin_left = 30.0
margin_top = 30.0
margin_right = 404.0
margin_bottom = 131.0
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
margin_right = 374.0
margin_bottom = 21.0
custom_fonts/font = ExtResource( 1 )
text = "ENTER_SAVE_NAME"
[node name="LineEdit" type="LineEdit" parent="MarginContainer/VBoxContainer"]
margin_top = 25.0
margin_right = 374.0
margin_bottom = 56.0
custom_fonts/font = ExtResource( 1 )
[node name="HBoxContainer" type="HBoxContainer" parent="."]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -224.0
margin_top = -56.0
margin_right = -30.0
margin_bottom = -20.0
custom_constants/separation = 10
__meta__ = {
"_edit_use_anchors_": false
}
[node name="cancel" type="Button" parent="HBoxContainer"]
margin_right = 96.0
margin_bottom = 36.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 1 )
text = "CANCEL"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ok" type="Button" parent="HBoxContainer"]
margin_left = 106.0
margin_right = 194.0
margin_bottom = 36.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 1 )
text = "OK"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="HBoxContainer/cancel" to="." method="_on_cancel_pressed"]
[connection signal="pressed" from="HBoxContainer/ok" to="." method="_on_ok_pressed"]

View File

@@ -135,6 +135,7 @@ func mousewheel_action(_direction : int):
func hide_ui(): func hide_ui():
$ui/panel_down.hide() $ui/panel_down.hide()
verbs_menu.hide() verbs_menu.hide()
$ui/panel_down/verbs_layer/room_select.hide()
$ui/panel_down/inventory_layer/inventory_ui.hide() $ui/panel_down/inventory_layer/inventory_ui.hide()
tooltip.hide() tooltip.hide()
@@ -142,6 +143,7 @@ func hide_ui():
func show_ui(): func show_ui():
$ui/panel_down.show() $ui/panel_down.show()
verbs_menu.show() verbs_menu.show()
$ui/panel_down/verbs_layer/room_select.show()
$ui/panel_down/inventory_layer/inventory_ui.show() $ui/panel_down/inventory_layer/inventory_ui.show()
tooltip.show() tooltip.show()

View File

@@ -87,17 +87,23 @@ func left_click_on_inventory_item(inventory_item_global_id : String, event : Inp
inventory_item_global_id inventory_item_global_id
).node ).node
if item.get_node("sprite").texture: if item.get_node("sprite").texture:
$ui/verbs_layer/verbs_menu.set_tool_texture(item.get_node("sprite").texture) $ui/verbs_layer/verbs_menu.set_tool_texture(
item.get_node("sprite").texture
)
elif item.inventory_item.texture_normal: elif item.inventory_item.texture_normal:
$ui/verbs_layer/verbs_menu.set_tool_texture(item.inventory_item.texture_normal) $ui/verbs_layer/verbs_menu.set_tool_texture(
item.inventory_item.texture_normal
)
func right_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void: func right_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
escoria.do("item_right_click", [inventory_item_global_id, event]) escoria.do("item_right_click", [inventory_item_global_id, event])
func left_double_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void: func left_double_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
pass pass
func inventory_item_focused(inventory_item_global_id: String) -> void: func inventory_item_focused(inventory_item_global_id: String) -> void:
$ui/tooltip_layer/tooltip.set_target( $ui/tooltip_layer/tooltip.set_target(
escoria.object_manager.get_object( escoria.object_manager.get_object(
@@ -105,6 +111,7 @@ func inventory_item_focused(inventory_item_global_id : String) -> void:
).node.tooltip_name ).node.tooltip_name
) )
func inventory_item_unfocused() -> void: func inventory_item_unfocused() -> void:
$ui/tooltip_layer/tooltip.set_target("") $ui/tooltip_layer/tooltip.set_target("")

View File

@@ -239,6 +239,21 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc_room.gd" "path": "res://addons/escoria-core/game/core-scripts/esc_room.gd"
}, { }, {
"base": "Resource",
"class": "ESCSaveGame",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/save_data/esc_savegame.gd"
}, {
"base": "Reference",
"class": "ESCSaveManager",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/save_data/esc_save_manager.gd"
}, {
"base": "Resource",
"class": "ESCSaveSettings",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/save_data/esc_savesettings.gd"
}, {
"base": "Object", "base": "Object",
"class": "ESCScheduledEvent", "class": "ESCScheduledEvent",
"language": "GDScript", "language": "GDScript",
@@ -400,6 +415,11 @@ _global_script_classes=[ {
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/teleport.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/teleport.gd"
}, { }, {
"base": "ESCBaseCommand", "base": "ESCBaseCommand",
"class": "TeleportPosCommand",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/teleport_pos.gd"
}, {
"base": "ESCBaseCommand",
"class": "TurnToCommand", "class": "TurnToCommand",
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/turn_to.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/turn_to.gd"
@@ -476,6 +496,9 @@ _global_script_class_icons={
"ESCPlayer": "", "ESCPlayer": "",
"ESCResourceCache": "", "ESCResourceCache": "",
"ESCRoom": "", "ESCRoom": "",
"ESCSaveGame": "",
"ESCSaveManager": "",
"ESCSaveSettings": "",
"ESCScheduledEvent": "", "ESCScheduledEvent": "",
"ESCScript": "", "ESCScript": "",
"ESCStatement": "", "ESCStatement": "",
@@ -508,6 +531,7 @@ _global_script_class_icons={
"SpawnCommand": "", "SpawnCommand": "",
"StopCommand": "", "StopCommand": "",
"TeleportCommand": "", "TeleportCommand": "",
"TeleportPosCommand": "",
"TurnToCommand": "", "TurnToCommand": "",
"WaitCommand": "", "WaitCommand": "",
"WalkBlockCommand": "", "WalkBlockCommand": "",
@@ -570,6 +594,11 @@ debug/log_level="DEBUG"
platform/skip_cache=false platform/skip_cache=false
platform/skip_cache.mobile=true platform/skip_cache.mobile=true
ui/items_autoregister_path="res://game/items/escitems/" ui/items_autoregister_path="res://game/items/escitems/"
main/game_version="0.1.0"
main/savegames_path="res://saves/"
main/settings_path="user://"
main/escoria_version=""
sound/speech_enabled=1
[input] [input]