mirror of
https://github.com/Relintai/broken_seals_2d.git
synced 2024-11-11 20:35:10 +01:00
Updated modules. Also brought back logger, so code is easier to move between projects.
This commit is contained in:
parent
606a2c25ac
commit
1bb9d7cbe7
2
HEADS
2
HEADS
@ -1 +1 @@
|
|||||||
{"engine": {"3.2": "3f57cb12b435f44d60ab813ba824b8bf7f44d5b3"}, "world_generator": {"master": "c10d7b7b8cb83e233cffd524f4931988208eb14a"}, "entity_spell_system": {"master": "28f2cc1f38612934a7bbd81dd30787215d74bbe5"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "texture_packer": {"master": "2993ed34f34cfa6a5e61b7913380231e9c55eda6"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "thread_pool": {"master": "93320fe864128d706bcc47fc7ed0731e6e9bcf69"}}
|
{"engine": {"3.2": "3f57cb12b435f44d60ab813ba824b8bf7f44d5b3"}, "world_generator": {"master": "9a4f9f9809cb4da6d0196a9b37ea480e3cd0c400"}, "entity_spell_system": {"master": "f343482bf6e2346c91d5a57603f67e3a7fbd684f"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "texture_packer": {"master": "2993ed34f34cfa6a5e61b7913380231e9c55eda6"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "thread_pool": {"master": "93320fe864128d706bcc47fc7ed0731e6e9bcf69"}}
|
637
game/autoload/Logger.gd
Normal file
637
game/autoload/Logger.gd
Normal file
@ -0,0 +1,637 @@
|
|||||||
|
# Copyright (c) 2016 KOBUGE Games
|
||||||
|
# Distributed under the terms of the MIT license.
|
||||||
|
# https://github.com/KOBUGE-Games/godot-logger/blob/master/LICENSE.md
|
||||||
|
#
|
||||||
|
# Upstream repo: https://github.com/KOBUGE-Games/godot-logger
|
||||||
|
|
||||||
|
extends Node # Needed to work as a singleton
|
||||||
|
|
||||||
|
##================##
|
||||||
|
## Inner classes ##
|
||||||
|
##================##
|
||||||
|
|
||||||
|
class Logfile:
|
||||||
|
# TODO: Godot doesn't support docstrings for inner classes, GoDoIt (GH-1320)
|
||||||
|
# """Class for log files that can be shared between various modules."""
|
||||||
|
var file = null
|
||||||
|
var path = ""
|
||||||
|
var queue_mode = QUEUE_NONE
|
||||||
|
var buffer = PoolStringArray()
|
||||||
|
var buffer_idx = 0
|
||||||
|
|
||||||
|
func _init(_path, _queue_mode = QUEUE_NONE):
|
||||||
|
file = File.new()
|
||||||
|
if validate_path(_path):
|
||||||
|
path = _path
|
||||||
|
queue_mode = _queue_mode
|
||||||
|
buffer.resize(FILE_BUFFER_SIZE)
|
||||||
|
|
||||||
|
func get_path():
|
||||||
|
return path
|
||||||
|
|
||||||
|
func set_queue_mode(new_mode):
|
||||||
|
queue_mode = new_mode
|
||||||
|
|
||||||
|
func get_queue_mode():
|
||||||
|
return queue_mode
|
||||||
|
|
||||||
|
func get_write_mode():
|
||||||
|
if not file.file_exists(path):
|
||||||
|
return File.WRITE # create
|
||||||
|
else:
|
||||||
|
return File.READ_WRITE # append
|
||||||
|
|
||||||
|
func validate_path(ppath):
|
||||||
|
"""Validate the path given as argument, making it possible to write to
|
||||||
|
the designated file or folder. Returns whether the path is valid."""
|
||||||
|
if !(ppath.is_abs_path() or ppath.is_rel_path()):
|
||||||
|
print("[ERROR] [logger] The given path '%s' is not valid." % ppath)
|
||||||
|
return false
|
||||||
|
var dir = Directory.new()
|
||||||
|
var base_dir = ppath.get_base_dir()
|
||||||
|
if not dir.dir_exists(base_dir):
|
||||||
|
# TODO: Move directory creation to the function that will actually *write*
|
||||||
|
var err = dir.make_dir_recursive(base_dir)
|
||||||
|
if err:
|
||||||
|
print("[ERROR] [logger] Could not create the '%s' directory; exited with error %d." \
|
||||||
|
% [base_dir, err])
|
||||||
|
return false
|
||||||
|
else:
|
||||||
|
print("[INFO] [logger] Successfully created the '%s' directory." % base_dir)
|
||||||
|
return true
|
||||||
|
|
||||||
|
func flush_buffer():
|
||||||
|
"""Flush the buffer, i.e. write its contents to the target file."""
|
||||||
|
if buffer_idx == 0:
|
||||||
|
return # Nothing to write
|
||||||
|
var err = file.open(path, get_write_mode())
|
||||||
|
if err:
|
||||||
|
print("[ERROR] [logger] Could not open the '%s' log file; exited with error %d." \
|
||||||
|
% [path, err])
|
||||||
|
return
|
||||||
|
file.seek_end()
|
||||||
|
for i in range(buffer_idx):
|
||||||
|
file.store_line(buffer[i])
|
||||||
|
file.close()
|
||||||
|
buffer_idx = 0 # We don't clear the memory, we'll just overwrite it
|
||||||
|
|
||||||
|
func write(output, level):
|
||||||
|
"""Write the string at the end of the file (append mode), following
|
||||||
|
the queue mode."""
|
||||||
|
var queue_action = queue_mode
|
||||||
|
if queue_action == QUEUE_SMART:
|
||||||
|
if level >= WARN: # Don't queue warnings and errors
|
||||||
|
queue_action = QUEUE_NONE
|
||||||
|
flush_buffer()
|
||||||
|
else: # Queue the log, not important enough for "smart"
|
||||||
|
queue_action = QUEUE_ALL
|
||||||
|
|
||||||
|
if queue_action == QUEUE_NONE:
|
||||||
|
var err = file.open(path, get_write_mode())
|
||||||
|
if err:
|
||||||
|
print("[ERROR] [logger] Could not open the '%s' log file; exited with error %d." \
|
||||||
|
% [path, err])
|
||||||
|
return
|
||||||
|
file.seek_end()
|
||||||
|
file.store_line(output)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
if queue_action == QUEUE_ALL:
|
||||||
|
buffer[buffer_idx] = output
|
||||||
|
buffer_idx += 1
|
||||||
|
if buffer_idx >= FILE_BUFFER_SIZE:
|
||||||
|
flush_buffer()
|
||||||
|
|
||||||
|
func get_config():
|
||||||
|
return {
|
||||||
|
"path": get_path(),
|
||||||
|
"queue_mode": get_queue_mode()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Module:
|
||||||
|
# """Class for customizable logging modules."""
|
||||||
|
var name = ""
|
||||||
|
var output_level = 0
|
||||||
|
var output_strategies = []
|
||||||
|
var logfile = null
|
||||||
|
|
||||||
|
func _init(_name, _output_level, _output_strategies, _logfile):
|
||||||
|
name = _name
|
||||||
|
set_output_level(_output_level)
|
||||||
|
|
||||||
|
if typeof(_output_strategies) == TYPE_INT: # Only one strategy, use it for all
|
||||||
|
#warning-ignore:unused_variable
|
||||||
|
for i in range(0, LEVELS.size()):
|
||||||
|
output_strategies.append(_output_strategies)
|
||||||
|
else:
|
||||||
|
for strategy in _output_strategies: # Need to force deep copy
|
||||||
|
output_strategies.append(strategy)
|
||||||
|
|
||||||
|
set_logfile(_logfile)
|
||||||
|
|
||||||
|
func get_name():
|
||||||
|
return name
|
||||||
|
|
||||||
|
func set_output_level(level):
|
||||||
|
"""Set the custom minimal level for the output of the module.
|
||||||
|
All levels greater or equal to the given once will be output based
|
||||||
|
on their respective strategies, while levels lower than the given one
|
||||||
|
will be discarded."""
|
||||||
|
if not level in range(0, LEVELS.size()):
|
||||||
|
print("[ERROR] [%s] The level must be comprised between 0 and %d." \
|
||||||
|
% [PLUGIN_NAME, LEVELS.size() - 1])
|
||||||
|
return
|
||||||
|
output_level = level
|
||||||
|
|
||||||
|
func get_output_level():
|
||||||
|
return output_level
|
||||||
|
|
||||||
|
func set_common_output_strategy(output_strategy_mask):
|
||||||
|
"""Set the common output strategy mask for all levels of the module."""
|
||||||
|
if not output_strategy_mask in range(0, MAX_STRATEGY + 1):
|
||||||
|
print("[ERROR] [%s] The output strategy mask must be comprised between 0 and %d." \
|
||||||
|
% [PLUGIN_NAME, MAX_STRATEGY])
|
||||||
|
return
|
||||||
|
for i in range(0, LEVELS.size()):
|
||||||
|
output_strategies[i] = output_strategy_mask
|
||||||
|
|
||||||
|
func set_output_strategy(output_strategy_mask, level = -1):
|
||||||
|
"""Set the output strategy for the given level or (by default) all
|
||||||
|
levels of the module."""
|
||||||
|
if not output_strategy_mask in range(0, MAX_STRATEGY + 1):
|
||||||
|
print("[ERROR] [%s] The output strategy mask must be comprised between 0 and %d." \
|
||||||
|
% [PLUGIN_NAME, MAX_STRATEGY])
|
||||||
|
return
|
||||||
|
if level == -1: # Set for all levels
|
||||||
|
for i in range(0, LEVELS.size()):
|
||||||
|
output_strategies[i] = output_strategy_mask
|
||||||
|
else:
|
||||||
|
if not level in range(0, LEVELS.size()):
|
||||||
|
print("[ERROR] [%s] The level must be comprised between 0 and %d." \
|
||||||
|
% [PLUGIN_NAME, LEVELS.size() - 1])
|
||||||
|
return
|
||||||
|
output_strategies[level] = output_strategy_mask
|
||||||
|
|
||||||
|
func get_output_strategy(level = -1):
|
||||||
|
if level == -1:
|
||||||
|
return output_strategies
|
||||||
|
else:
|
||||||
|
return output_strategies[level]
|
||||||
|
|
||||||
|
func set_logfile(new_logfile):
|
||||||
|
"""Set the Logfile instance for the module."""
|
||||||
|
logfile = new_logfile
|
||||||
|
|
||||||
|
func get_logfile():
|
||||||
|
return logfile
|
||||||
|
|
||||||
|
func get_config():
|
||||||
|
return {
|
||||||
|
"name": get_name(),
|
||||||
|
"output_level": get_output_level(),
|
||||||
|
"output_strategies": get_output_strategy(),
|
||||||
|
"logfile_path": get_logfile().get_path()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##=============##
|
||||||
|
## Constants ##
|
||||||
|
##=============##
|
||||||
|
|
||||||
|
const PLUGIN_NAME = "logger"
|
||||||
|
|
||||||
|
# Logging levels - the array and the integers should be matching
|
||||||
|
const LEVELS = ["VERBOSE", "DEBUG", "INFO", "WARN", "ERROR"]
|
||||||
|
const VERBOSE = 0
|
||||||
|
const DEBUG = 1
|
||||||
|
const INFO = 2
|
||||||
|
const WARN = 3
|
||||||
|
const ERROR = 4
|
||||||
|
|
||||||
|
# Output strategies
|
||||||
|
const STRATEGY_MUTE = 0
|
||||||
|
const STRATEGY_PRINT = 1
|
||||||
|
const STRATEGY_FILE = 2
|
||||||
|
const STRATEGY_MEMORY = 4
|
||||||
|
const MAX_STRATEGY = STRATEGY_MEMORY*2 - 1
|
||||||
|
|
||||||
|
# Output format identifiers
|
||||||
|
const FORMAT_IDS = {
|
||||||
|
"level": "{LVL}",
|
||||||
|
"module": "{MOD}",
|
||||||
|
"message": "{MSG}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Queue modes
|
||||||
|
const QUEUE_NONE = 0
|
||||||
|
const QUEUE_ALL = 1
|
||||||
|
const QUEUE_SMART = 2
|
||||||
|
|
||||||
|
const FILE_BUFFER_SIZE = 30
|
||||||
|
|
||||||
|
|
||||||
|
##=============##
|
||||||
|
## Variables ##
|
||||||
|
##=============##
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
var default_output_level = WARN
|
||||||
|
# TODO: Find (or implement in Godot) a more clever way to achieve that
|
||||||
|
var default_output_strategies = [STRATEGY_PRINT, STRATEGY_PRINT, STRATEGY_PRINT, STRATEGY_PRINT, STRATEGY_PRINT]
|
||||||
|
var default_logfile_path = "user://%s.log" % ProjectSettings.get_setting("application/config/name")
|
||||||
|
var default_configfile_path = "user://%s.cfg" % PLUGIN_NAME
|
||||||
|
|
||||||
|
# e.g. "[INFO] [main] The young alpaca started growing a goatie."
|
||||||
|
var output_format = "[{LVL}] [{MOD}] {MSG}"
|
||||||
|
|
||||||
|
# Specific to STRATEGY_MEMORY
|
||||||
|
var max_memory_size = 30
|
||||||
|
var memory_buffer = []
|
||||||
|
var memory_idx = 0
|
||||||
|
var memory_first_loop = true
|
||||||
|
var memory_cache = []
|
||||||
|
var invalid_memory_cache = false
|
||||||
|
|
||||||
|
# Holds default and custom modules and logfiles defined by the user
|
||||||
|
# Default modules are initialized in _init via add_module
|
||||||
|
var logfiles = {}
|
||||||
|
var modules = {}
|
||||||
|
|
||||||
|
|
||||||
|
##=============##
|
||||||
|
## Functions ##
|
||||||
|
##=============##
|
||||||
|
|
||||||
|
func put(level, message, module = "main"):
|
||||||
|
"""Log a message in the given module with the given logging level."""
|
||||||
|
var module_ref = get_module(module)
|
||||||
|
var output_strategy = module_ref.get_output_strategy(level)
|
||||||
|
if output_strategy == STRATEGY_MUTE or module_ref.get_output_level() > level:
|
||||||
|
return # Out of scope
|
||||||
|
|
||||||
|
var output = format(output_format, level, module, message)
|
||||||
|
|
||||||
|
if output_strategy & STRATEGY_PRINT:
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
if output_strategy & STRATEGY_FILE:
|
||||||
|
module_ref.get_logfile().write(output, level)
|
||||||
|
|
||||||
|
if output_strategy & STRATEGY_MEMORY:
|
||||||
|
memory_buffer[memory_idx] = output
|
||||||
|
memory_idx += 1
|
||||||
|
invalid_memory_cache = true
|
||||||
|
if memory_idx >= max_memory_size:
|
||||||
|
memory_idx = 0
|
||||||
|
memory_first_loop = false
|
||||||
|
|
||||||
|
# Helper functions for each level
|
||||||
|
# -------------------------------
|
||||||
|
|
||||||
|
func verbose(message, module = "main"):
|
||||||
|
"""Log a message in the given module with level VERBOSE."""
|
||||||
|
put(VERBOSE, message, module)
|
||||||
|
|
||||||
|
func debug(message, module = "main"):
|
||||||
|
"""Log a message in the given module with level DEBUG."""
|
||||||
|
put(DEBUG, message, module)
|
||||||
|
|
||||||
|
func info(message, module = "main"):
|
||||||
|
"""Log a message in the given module with level INFO."""
|
||||||
|
put(INFO, message, module)
|
||||||
|
|
||||||
|
func warn(message, module = "main"):
|
||||||
|
"""Log a message in the given module with level WARN."""
|
||||||
|
put(WARN, message, module)
|
||||||
|
|
||||||
|
func error(message, module = "main"):
|
||||||
|
"""Log a message in the given module with level ERROR."""
|
||||||
|
put(ERROR, message, module)
|
||||||
|
|
||||||
|
# Module management
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
func add_module(name, output_level = default_output_level, \
|
||||||
|
output_strategies = default_output_strategies, logfile = null):
|
||||||
|
"""Add a new module with the given parameter or (by default) the
|
||||||
|
default ones.
|
||||||
|
Returns a reference to the instanced module."""
|
||||||
|
if modules.has(name):
|
||||||
|
info("The module '%s' already exists; discarding the call to add it anew." \
|
||||||
|
% name, PLUGIN_NAME)
|
||||||
|
else:
|
||||||
|
if logfile == null:
|
||||||
|
logfile = get_logfile(default_logfile_path)
|
||||||
|
modules[name] = Module.new(name, output_level, output_strategies, logfile)
|
||||||
|
return modules[name]
|
||||||
|
|
||||||
|
func get_module(module = "main"):
|
||||||
|
"""Retrieve the given module if it exists; if not, it will be created."""
|
||||||
|
if not modules.has(module):
|
||||||
|
info("The requested module '%s' does not exist. It will be created with default values." \
|
||||||
|
% module, PLUGIN_NAME)
|
||||||
|
add_module(module)
|
||||||
|
return modules[module]
|
||||||
|
|
||||||
|
func get_modules():
|
||||||
|
"""Retrieve the dictionary containing all modules."""
|
||||||
|
return modules
|
||||||
|
|
||||||
|
# Logfiles management
|
||||||
|
# -------------------
|
||||||
|
|
||||||
|
func set_default_logfile_path(new_logfile_path, keep_old = false):
|
||||||
|
"""Sets the new default logfile path. Unless configured otherwise with
|
||||||
|
the optional keep_old argument, it will replace the logfile for all
|
||||||
|
modules which were configured for the previous logfile path."""
|
||||||
|
if new_logfile_path == default_logfile_path:
|
||||||
|
return # Nothing to do
|
||||||
|
|
||||||
|
var old_logfile = get_logfile(default_logfile_path)
|
||||||
|
var new_logfile = null
|
||||||
|
if logfiles.has(new_logfile_path): # Already exists
|
||||||
|
new_logfile = logfiles[new_logfile_path]
|
||||||
|
else: # Create a new logfile
|
||||||
|
new_logfile = add_logfile(new_logfile_path)
|
||||||
|
logfiles[new_logfile_path] = new_logfile
|
||||||
|
|
||||||
|
if not keep_old: # Replace the old defaut logfile in all modules that used it
|
||||||
|
for module in modules.values():
|
||||||
|
if module.get_logfile() == old_logfile:
|
||||||
|
module.set_logfile(new_logfile)
|
||||||
|
logfiles.erase(default_logfile_path)
|
||||||
|
default_logfile_path = new_logfile_path
|
||||||
|
|
||||||
|
func get_default_logfile_path():
|
||||||
|
"""Return the default logfile path."""
|
||||||
|
return default_logfile_path
|
||||||
|
|
||||||
|
func add_logfile(logfile_path = default_logfile_path):
|
||||||
|
"""Add a new logfile that can then be attached to one or more modules.
|
||||||
|
Returns a reference to the instanced logfile."""
|
||||||
|
if logfiles.has(logfile_path):
|
||||||
|
info("A logfile pointing to '%s' already exists; discarding the call to add it anew." \
|
||||||
|
% logfile_path, PLUGIN_NAME)
|
||||||
|
else:
|
||||||
|
logfiles[logfile_path] = Logfile.new(logfile_path)
|
||||||
|
return logfiles[logfile_path]
|
||||||
|
|
||||||
|
func get_logfile(logfile_path):
|
||||||
|
"""Retrieve the given logfile if it exists, otherwise returns null."""
|
||||||
|
if not logfiles.has(logfile_path):
|
||||||
|
warn("The requested logfile pointing to '%s' does not exist." % logfile_path, PLUGIN_NAME)
|
||||||
|
return null
|
||||||
|
else:
|
||||||
|
return logfiles[logfile_path]
|
||||||
|
|
||||||
|
func get_logfiles():
|
||||||
|
"""Retrieve the dictionary containing all logfiles."""
|
||||||
|
return logfiles
|
||||||
|
|
||||||
|
# Default output configuration
|
||||||
|
# ----------------------------
|
||||||
|
|
||||||
|
func set_default_output_strategy(output_strategy_mask, level = -1):
|
||||||
|
"""Set the default output strategy mask of the given level or (by
|
||||||
|
default) all levels for all modules without a custom strategy."""
|
||||||
|
if not output_strategy_mask in range(0, MAX_STRATEGY + 1):
|
||||||
|
error("The output strategy mask must be comprised between 0 and %d." \
|
||||||
|
% MAX_STRATEGY, PLUGIN_NAME)
|
||||||
|
return
|
||||||
|
if level == -1: # Set for all levels
|
||||||
|
for i in range(0, LEVELS.size()):
|
||||||
|
default_output_strategies[i] = output_strategy_mask
|
||||||
|
info("The default output strategy mask was set to '%d' for all levels." \
|
||||||
|
% [output_strategy_mask], PLUGIN_NAME)
|
||||||
|
else:
|
||||||
|
if not level in range(0, LEVELS.size()):
|
||||||
|
error("The level must be comprised between 0 and %d." % (int(LEVELS.size()) - 1), PLUGIN_NAME)
|
||||||
|
return
|
||||||
|
default_output_strategies[level] = output_strategy_mask
|
||||||
|
info("The default output strategy mask was set to '%d' for the '%s' level." \
|
||||||
|
% [output_strategy_mask, LEVELS[level]], PLUGIN_NAME)
|
||||||
|
|
||||||
|
func get_default_output_strategy(level):
|
||||||
|
"""Get the default output strategy mask of the given level or (by
|
||||||
|
default) all levels for all modules without a custom strategy."""
|
||||||
|
return default_output_strategies[level]
|
||||||
|
|
||||||
|
func set_default_output_level(level):
|
||||||
|
"""Set the default minimal level for the output of all modules without
|
||||||
|
a custom output level.
|
||||||
|
All levels greater or equal to the given once will be output based on
|
||||||
|
their respective strategies, while levels lower than the given one will
|
||||||
|
be discarded.
|
||||||
|
"""
|
||||||
|
if not level in range(0, LEVELS.size()):
|
||||||
|
error("The level must be comprised between 0 and %d." % (int(LEVELS.size()) - 1), PLUGIN_NAME)
|
||||||
|
return
|
||||||
|
default_output_level = level
|
||||||
|
info("The default output level was set to '%s'." % LEVELS[level], PLUGIN_NAME)
|
||||||
|
|
||||||
|
func get_default_output_level():
|
||||||
|
"""Get the default minimal level for the output of all modules without
|
||||||
|
a custom output level."""
|
||||||
|
return default_output_level
|
||||||
|
|
||||||
|
# Output formatting
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
static func format(template, level, module, message):
|
||||||
|
var output = template
|
||||||
|
output = output.replace(FORMAT_IDS.level, LEVELS[level])
|
||||||
|
output = output.replace(FORMAT_IDS.module, module)
|
||||||
|
output = output.replace(FORMAT_IDS.message, message)
|
||||||
|
return output
|
||||||
|
|
||||||
|
func set_output_format(new_format):
|
||||||
|
"""Set the output string format using the following identifiers:
|
||||||
|
{LVL} for the level, {MOD} for the module, {MSG} for the message.
|
||||||
|
The three identifiers should be contained in the output format string.
|
||||||
|
"""
|
||||||
|
for key in FORMAT_IDS:
|
||||||
|
if new_format.find(FORMAT_IDS[key]) == -1:
|
||||||
|
error("Invalid output string format. It lacks the '%s' identifier." \
|
||||||
|
% FORMAT_IDS[key], PLUGIN_NAME)
|
||||||
|
return
|
||||||
|
output_format = new_format
|
||||||
|
info("Successfully changed the output format to '%s'." % output_format, PLUGIN_NAME)
|
||||||
|
|
||||||
|
func get_output_format():
|
||||||
|
"""Get the output string format."""
|
||||||
|
return output_format
|
||||||
|
|
||||||
|
# Strategy "memory"
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
func set_max_memory_size(new_size):
|
||||||
|
"""Set the maximum amount of messages to be remembered when
|
||||||
|
using the STRATEGY_MEMORY output strategy."""
|
||||||
|
if new_size <= 0:
|
||||||
|
error("The maximum amount of remembered messages must be a positive non-null integer. Received %d." \
|
||||||
|
% new_size, PLUGIN_NAME)
|
||||||
|
return
|
||||||
|
|
||||||
|
var new_buffer = []
|
||||||
|
var new_idx = 0
|
||||||
|
new_buffer.resize(new_size)
|
||||||
|
|
||||||
|
# Better algorithm welcome :D
|
||||||
|
if memory_first_loop:
|
||||||
|
var offset = 0
|
||||||
|
if memory_idx > new_size:
|
||||||
|
offset = memory_idx - new_size
|
||||||
|
memory_first_loop = false
|
||||||
|
else:
|
||||||
|
new_idx = memory_idx
|
||||||
|
for i in range(0, min(memory_idx, new_size)):
|
||||||
|
new_buffer[i] = memory_buffer[i + offset]
|
||||||
|
else:
|
||||||
|
var delta = 0
|
||||||
|
if max_memory_size > new_size:
|
||||||
|
delta = max_memory_size - new_size
|
||||||
|
else:
|
||||||
|
new_idx = max_memory_size
|
||||||
|
memory_first_loop = true
|
||||||
|
for i in range(0, min(max_memory_size, new_size)):
|
||||||
|
new_buffer[i] = memory_buffer[(memory_idx + delta + i) % max_memory_size]
|
||||||
|
|
||||||
|
memory_buffer = new_buffer
|
||||||
|
memory_idx = new_idx
|
||||||
|
invalid_memory_cache = true
|
||||||
|
max_memory_size = new_size
|
||||||
|
info("Successfully set the maximum amount of remembered messages to %d." % max_memory_size, PLUGIN_NAME)
|
||||||
|
|
||||||
|
func get_max_memory_size():
|
||||||
|
"""Get the maximum amount of messages to be remembered when
|
||||||
|
using the STRATEGY_MEMORY output strategy."""
|
||||||
|
return max_memory_size
|
||||||
|
|
||||||
|
func get_memory():
|
||||||
|
"""Get an array of the messages remembered following STRATEGY_MEMORY.
|
||||||
|
The messages are sorted from the oldest to the newest."""
|
||||||
|
if invalid_memory_cache: # Need to recreate the cached ordered array
|
||||||
|
memory_cache = []
|
||||||
|
if not memory_first_loop: # else those would be uninitialized
|
||||||
|
for i in range(memory_idx, max_memory_size):
|
||||||
|
memory_cache.append(memory_buffer[i])
|
||||||
|
for i in range(0, memory_idx):
|
||||||
|
memory_cache.append(memory_buffer[i])
|
||||||
|
invalid_memory_cache = false
|
||||||
|
return memory_cache
|
||||||
|
|
||||||
|
func clear_memory():
|
||||||
|
"""Clear the buffer or remembered messages."""
|
||||||
|
memory_buffer.clear()
|
||||||
|
memory_idx = 0
|
||||||
|
memory_first_loop = true
|
||||||
|
invalid_memory_cache = true
|
||||||
|
|
||||||
|
|
||||||
|
# Configuration loading/saving
|
||||||
|
# ----------------------------
|
||||||
|
|
||||||
|
func save_config(configfile = default_configfile_path):
|
||||||
|
"""Save the default configuration as well as the set of modules and
|
||||||
|
their respective configurations.
|
||||||
|
The ConfigFile API is used to generate the config file passed as argument.
|
||||||
|
A unique section is used, so that it can be merged in a project's engine.cfg.
|
||||||
|
Returns an error code (OK or some ERR_*)."""
|
||||||
|
var config = ConfigFile.new()
|
||||||
|
|
||||||
|
# Store default config
|
||||||
|
config.set_value(PLUGIN_NAME, "default_output_level", default_output_level)
|
||||||
|
config.set_value(PLUGIN_NAME, "default_output_strategies", default_output_strategies)
|
||||||
|
config.set_value(PLUGIN_NAME, "default_logfile_path", default_logfile_path)
|
||||||
|
config.set_value(PLUGIN_NAME, "max_memory_size", max_memory_size)
|
||||||
|
|
||||||
|
# Logfiles config
|
||||||
|
var logfiles_arr = []
|
||||||
|
var sorted_keys = logfiles.keys()
|
||||||
|
sorted_keys.sort() # Sadly doesn't return the array, so we need to split it
|
||||||
|
for logfile in sorted_keys:
|
||||||
|
logfiles_arr.append(logfiles[logfile].get_config())
|
||||||
|
config.set_value(PLUGIN_NAME, "logfiles", logfiles_arr)
|
||||||
|
|
||||||
|
# Modules config
|
||||||
|
var modules_arr = []
|
||||||
|
sorted_keys = modules.keys()
|
||||||
|
sorted_keys.sort()
|
||||||
|
for module in sorted_keys:
|
||||||
|
modules_arr.append(modules[module].get_config())
|
||||||
|
config.set_value(PLUGIN_NAME, "modules", modules_arr)
|
||||||
|
|
||||||
|
# Save and return the corresponding error code
|
||||||
|
var err = config.save(configfile)
|
||||||
|
if err:
|
||||||
|
error("Could not save the config in '%s'; exited with error %d." \
|
||||||
|
% [configfile, err], PLUGIN_NAME)
|
||||||
|
return err
|
||||||
|
info("Successfully saved the config to '%s'." % configfile, PLUGIN_NAME)
|
||||||
|
return OK
|
||||||
|
|
||||||
|
func load_config(configfile = default_configfile_path):
|
||||||
|
"""Load the configuration as well as the set of defined modules and
|
||||||
|
their respective configurations. The expect file contents must be those
|
||||||
|
produced by the ConfigFile API.
|
||||||
|
Returns an error code (OK or some ERR_*)."""
|
||||||
|
# Look for the file
|
||||||
|
var dir = Directory.new()
|
||||||
|
if not dir.file_exists(configfile):
|
||||||
|
warn("Could not load the config in '%s', the file does not exist." % configfile, PLUGIN_NAME)
|
||||||
|
return ERR_FILE_NOT_FOUND
|
||||||
|
|
||||||
|
# Load its contents
|
||||||
|
var config = ConfigFile.new()
|
||||||
|
var err = config.load(configfile)
|
||||||
|
if err:
|
||||||
|
warn("Could not load the config in '%s'; exited with error %d." \
|
||||||
|
% [configfile, err], PLUGIN_NAME)
|
||||||
|
return err
|
||||||
|
|
||||||
|
# Load default config
|
||||||
|
default_output_level = config.get_value(PLUGIN_NAME, "default_output_level", default_output_level)
|
||||||
|
default_output_strategies = config.get_value(PLUGIN_NAME, "default_output_strategies", default_output_strategies)
|
||||||
|
default_logfile_path = config.get_value(PLUGIN_NAME, "default_logfile_path", default_logfile_path)
|
||||||
|
max_memory_size = config.get_value(PLUGIN_NAME, "max_memory_size", max_memory_size)
|
||||||
|
|
||||||
|
# Load logfiles config and initialize them
|
||||||
|
logfiles = {}
|
||||||
|
for logfile_cfg in config.get_value(PLUGIN_NAME, "logfiles"):
|
||||||
|
var logfile = Logfile.new(logfile_cfg["path"], logfile_cfg["queue_mode"])
|
||||||
|
logfiles[logfile_cfg["path"]] = logfile
|
||||||
|
|
||||||
|
# Load modules config and initialize them
|
||||||
|
modules = {}
|
||||||
|
for module_cfg in config.get_value(PLUGIN_NAME, "modules"):
|
||||||
|
var module = Module.new(module_cfg["name"], module_cfg["output_level"], \
|
||||||
|
module_cfg["output_strategies"], get_logfile(module_cfg["logfile_path"]))
|
||||||
|
modules[module_cfg["name"]] = module
|
||||||
|
|
||||||
|
info("Successfully loaded the config from '%s'." % configfile, PLUGIN_NAME)
|
||||||
|
return OK
|
||||||
|
|
||||||
|
|
||||||
|
##=============##
|
||||||
|
## Callbacks ##
|
||||||
|
##=============##
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
# Default logfile
|
||||||
|
add_logfile(default_logfile_path)
|
||||||
|
# Default modules
|
||||||
|
add_module(PLUGIN_NAME) # needs to be instanced first
|
||||||
|
add_module("main")
|
||||||
|
memory_buffer.resize(max_memory_size)
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
# Flush non-empty buffers
|
||||||
|
var processed_logfiles = []
|
||||||
|
var logfile = null
|
||||||
|
for module in modules:
|
||||||
|
logfile = modules[module].get_logfile()
|
||||||
|
if logfile in processed_logfiles:
|
||||||
|
continue
|
||||||
|
logfile.flush_buffer()
|
||||||
|
processed_logfiles.append(logfile)
|
6
game/autoload/Logger.tscn
Normal file
6
game/autoload/Logger.tscn
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://autoload/Logger.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Logger" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
@ -1,4 +1,4 @@
|
|||||||
[gd_resource type="ESSResourceDBStatic" load_steps=9 format=2]
|
[gd_resource type="ESSResourceDBStatic" load_steps=8 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://modules/core/item_templates/2_test.tres" type="ItemTemplate" id=1]
|
[ext_resource path="res://modules/core/item_templates/2_test.tres" type="ItemTemplate" id=1]
|
||||||
[ext_resource path="res://modules/core/item_templates/3_chest_of_the_infinite_wisdom.tres" type="ItemTemplate" id=2]
|
[ext_resource path="res://modules/core/item_templates/3_chest_of_the_infinite_wisdom.tres" type="ItemTemplate" id=2]
|
||||||
@ -7,10 +7,8 @@
|
|||||||
[ext_resource path="res://modules/core/item_templates/1_gold.tres" type="ItemTemplate" id=5]
|
[ext_resource path="res://modules/core/item_templates/1_gold.tres" type="ItemTemplate" id=5]
|
||||||
[ext_resource path="res://modules/core/crafting/1_test_craft.tres" type="CraftRecipe" id=6]
|
[ext_resource path="res://modules/core/crafting/1_test_craft.tres" type="CraftRecipe" id=6]
|
||||||
[ext_resource path="res://modules/core/entity_resources/1_mana_resource.tres" type="EntityResource" id=7]
|
[ext_resource path="res://modules/core/entity_resources/1_mana_resource.tres" type="EntityResource" id=7]
|
||||||
[ext_resource path="res://modules/core/xp/xp_data.tres" type="XPData" id=8]
|
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
xp_data = ExtResource( 8 )
|
|
||||||
entity_resources = [ ExtResource( 7 ) ]
|
entity_resources = [ ExtResource( 7 ) ]
|
||||||
entity_skills = [ ExtResource( 4 ) ]
|
entity_skills = [ ExtResource( 4 ) ]
|
||||||
craft_recipes = [ ExtResource( 6 ), ExtResource( 3 ) ]
|
craft_recipes = [ ExtResource( 6 ), ExtResource( 3 ) ]
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
[gd_resource type="XPData" format=2]
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
character_level_1 = 22
|
|
||||||
character_level_2 = 34
|
|
||||||
character_level_3 = 43
|
|
||||||
character_level_4 = 200
|
|
||||||
character_level_5 = 200
|
|
||||||
character_level_6 = 200
|
|
||||||
character_level_7 = 200
|
|
||||||
character_level_8 = 200
|
|
||||||
character_level_9 = 200
|
|
||||||
character_level_10 = 200
|
|
||||||
character_level_11 = 200
|
|
||||||
character_level_12 = 200
|
|
||||||
character_level_13 = 200
|
|
||||||
character_level_14 = 200
|
|
||||||
character_level_15 = 200
|
|
||||||
character_level_16 = 200
|
|
||||||
character_level_17 = 200
|
|
||||||
character_level_18 = 200
|
|
||||||
character_level_19 = 200
|
|
||||||
character_level_20 = 200
|
|
||||||
class_level_1 = 100
|
|
||||||
class_level_2 = 200
|
|
||||||
class_level_3 = 300
|
|
||||||
class_level_4 = 400
|
|
||||||
class_level_5 = 500
|
|
||||||
class_level_6 = 600
|
|
||||||
class_level_7 = 700
|
|
||||||
class_level_8 = 800
|
|
||||||
class_level_9 = 1000
|
|
||||||
class_level_10 = 1000
|
|
||||||
class_level_11 = 1000
|
|
||||||
class_level_12 = 1000
|
|
||||||
class_level_13 = 1000
|
|
||||||
class_level_14 = 1000
|
|
||||||
class_level_15 = 1000
|
|
||||||
class_level_16 = 1000
|
|
||||||
class_level_17 = 1000
|
|
||||||
class_level_18 = 1000
|
|
||||||
class_level_19 = 1000
|
|
||||||
class_level_20 = 1000
|
|
||||||
class_level_21 = 1000
|
|
||||||
class_level_22 = 1000
|
|
||||||
class_level_23 = 1000
|
|
||||||
class_level_24 = 1000
|
|
||||||
class_level_25 = 1000
|
|
||||||
class_level_26 = 1000
|
|
||||||
class_level_27 = 1000
|
|
||||||
class_level_28 = 1000
|
|
||||||
class_level_29 = 1000
|
|
||||||
class_level_30 = 1000
|
|
||||||
class_level_31 = 1000
|
|
||||||
class_level_32 = 1000
|
|
||||||
class_level_33 = 1000
|
|
||||||
class_level_34 = 1000
|
|
||||||
class_level_35 = 1000
|
|
||||||
class_level_36 = 1000
|
|
||||||
class_level_37 = 1000
|
|
||||||
class_level_38 = 1000
|
|
||||||
class_level_39 = 1000
|
|
||||||
class_level_40 = 1000
|
|
||||||
class_level_41 = 1000
|
|
||||||
class_level_42 = 1000
|
|
||||||
class_level_43 = 1000
|
|
||||||
class_level_44 = 1000
|
|
||||||
class_level_45 = 1000
|
|
||||||
class_level_46 = 1000
|
|
||||||
class_level_47 = 1000
|
|
||||||
class_level_48 = 1000
|
|
||||||
class_level_49 = 1000
|
|
||||||
class_level_50 = 1000
|
|
||||||
class_level_51 = 1000
|
|
||||||
class_level_52 = 1000
|
|
||||||
class_level_53 = 1000
|
|
||||||
class_level_54 = 1000
|
|
||||||
class_level_55 = 1000
|
|
||||||
class_level_56 = 1000
|
|
||||||
class_level_57 = 1000
|
|
||||||
class_level_58 = 1000
|
|
||||||
class_level_59 = 1000
|
|
||||||
class_level_60 = 1000
|
|
@ -74,7 +74,7 @@ func _notification_sdeath():
|
|||||||
|
|
||||||
dead = true
|
dead = true
|
||||||
|
|
||||||
var ldiff : float = scharacter_level - starget.scharacter_level + 10.0
|
var ldiff : float = slevel - starget.slevel + 10.0
|
||||||
|
|
||||||
if ldiff < 0:
|
if ldiff < 0:
|
||||||
ldiff = 0
|
ldiff = 0
|
||||||
@ -84,7 +84,7 @@ func _notification_sdeath():
|
|||||||
|
|
||||||
ldiff /= 10.0
|
ldiff /= 10.0
|
||||||
|
|
||||||
starget.xp_adds(int(5.0 * scharacter_level * ldiff))
|
starget.xp_adds(int(5.0 * slevel * ldiff))
|
||||||
|
|
||||||
starget = null
|
starget = null
|
||||||
|
|
||||||
@ -113,14 +113,14 @@ func _notification_cheal(what, info):
|
|||||||
WorldNumbers.heal(get_body().position, 1.6, info.heal, info.crit)
|
WorldNumbers.heal(get_body().position, 1.6, info.heal, info.crit)
|
||||||
|
|
||||||
func _notification_sxp_gained(value : int) -> void:
|
func _notification_sxp_gained(value : int) -> void:
|
||||||
if not ESS.get_resource_db().get_xp_data().can_character_level_up(gets_character_level()):
|
if not ESS.can_character_level_up(slevel):
|
||||||
return
|
return
|
||||||
|
|
||||||
var xpr : int = ESS.get_resource_db().get_xp_data().get_character_xp(gets_character_level());
|
var xpr : int = ESS.get_character_xp(slevel);
|
||||||
|
|
||||||
if xpr <= scharacter_xp:
|
if xpr <= sxp:
|
||||||
levelup_scharacter(1)
|
levelups(1)
|
||||||
scharacter_xp = 0
|
sxp = 0
|
||||||
|
|
||||||
func _notification_sclass_level_up(value: int):
|
func _notification_sclass_level_up(value: int):
|
||||||
._notification_sclass_level_up(value)
|
._notification_sclass_level_up(value)
|
||||||
|
@ -125,10 +125,10 @@ func spawn_player_for_menu(class_id : int, name : String, parent : Node) -> Enti
|
|||||||
createinfo.class_id = class_id
|
createinfo.class_id = class_id
|
||||||
createinfo.entity_data = cls
|
createinfo.entity_data = cls
|
||||||
createinfo.player_name = name
|
createinfo.player_name = name
|
||||||
createinfo.character_level = level
|
createinfo.level = level
|
||||||
createinfo.class_level = class_profile.level
|
# createinfo.class_level = class_profile.level
|
||||||
createinfo.character_xp = 0
|
createinfo.xp = 0
|
||||||
createinfo.class_xp = class_profile.xp
|
# createinfo.class_xp = class_profile.xp
|
||||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_DISPLAY
|
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_DISPLAY
|
||||||
createinfo.networked = false
|
createinfo.networked = false
|
||||||
@ -171,9 +171,9 @@ func spawn_networked_player(class_id : int, position : Vector3, name : String,
|
|||||||
createinfo.entity_data = cls
|
createinfo.entity_data = cls
|
||||||
createinfo.player_name = name
|
createinfo.player_name = name
|
||||||
createinfo.character_level = 1
|
createinfo.character_level = 1
|
||||||
createinfo.class_level = level
|
# createinfo.level = level
|
||||||
createinfo.character_xp = 0
|
createinfo.xp = 0
|
||||||
createinfo.class_xp = class_profile.xp
|
# createinfo.class_xp = class_profile.xp
|
||||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_NETWORKED
|
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_NETWORKED
|
||||||
createinfo.network_owner = sid
|
createinfo.network_owner = sid
|
||||||
@ -203,7 +203,7 @@ func spawn_player(class_id : int, position : Vector3, name : String, node_name
|
|||||||
createinfo.character_level = 1
|
createinfo.character_level = 1
|
||||||
createinfo.class_level = level
|
createinfo.class_level = level
|
||||||
createinfo.character_xp = 0
|
createinfo.character_xp = 0
|
||||||
createinfo.class_xp = class_profile.xp
|
# createinfo.class_xp = class_profile.xp
|
||||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_PLAYER
|
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_PLAYER
|
||||||
createinfo.network_owner = network_owner
|
createinfo.network_owner = network_owner
|
||||||
@ -225,8 +225,7 @@ func spawn_mob(class_id : int, level : int, position : Vector3) -> void:
|
|||||||
createinfo.class_id = class_id
|
createinfo.class_id = class_id
|
||||||
createinfo.entity_data = cls
|
createinfo.entity_data = cls
|
||||||
createinfo.player_name = "Mob"
|
createinfo.player_name = "Mob"
|
||||||
createinfo.character_level = level
|
createinfo.level = level
|
||||||
createinfo.class_level = level
|
|
||||||
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_AI
|
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_AI
|
||||||
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_AI
|
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_AI
|
||||||
createinfo.transform2d.origin = Vector2(position.x, position.y)
|
createinfo.transform2d.origin = Vector2(position.x, position.y)
|
||||||
|
@ -358,6 +358,7 @@ ThemeAtlas="*res://ui/autoload/ThemeAtlas.tscn"
|
|||||||
WorldNumbers="*res://ui/world_numbers_2d/WorldNumbers.tscn"
|
WorldNumbers="*res://ui/world_numbers_2d/WorldNumbers.tscn"
|
||||||
CursorManager="*res://cursors/autoload/CursorManager.tscn"
|
CursorManager="*res://cursors/autoload/CursorManager.tscn"
|
||||||
Settings="*res://ui/autoload/SettingsManager.tscn"
|
Settings="*res://ui/autoload/SettingsManager.tscn"
|
||||||
|
Logger="*res://autoload/Logger.tscn"
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
|
||||||
@ -378,19 +379,16 @@ window/size/viewport_scale=100
|
|||||||
|
|
||||||
[ess]
|
[ess]
|
||||||
|
|
||||||
spells/allow_class_spell_learning=true
|
|
||||||
spells/allow_class_recipe_learning=true
|
|
||||||
level/use_class_xp=true
|
|
||||||
level/automatic_class_levelups=true
|
|
||||||
level/use_global_class_level=true
|
|
||||||
level/max_character_level=10
|
|
||||||
level/max_class_level=60
|
|
||||||
data/ess_resource_db_path="res://data/resource_db.tres"
|
data/ess_resource_db_path="res://data/resource_db.tres"
|
||||||
data/ess_entity_spawner_path="res://player/bs_entity_spawner.tres"
|
data/ess_entity_spawner_path="res://player/bs_entity_spawner.tres"
|
||||||
enums/stats="Agility,Strength,Stamina,Intellect,Spirit,Health,Mana,Speed,Global Cooldown,Haste,Haste Rating,Resilience,Armor,Attack Power,Spell Power,Melee Crit,Melee Crit bonus,Spell Crit,Spell Crit Bonus,Block,Parry,Damage Reduction,Melee Damage Reduction,Spell Damage Reduction,Damage Taken,Heal Taken,Melee Damage,Spell Damage,Holy Resist,Shadow Resist,Nature Resist,Fire Resist,Frost Resist,Lightning Resist,Chaos Resist,Silence Resist,Fear Resist,Stun Resist,Energy,Rage,XP Rate"
|
enums/stats="Agility,Strength,Stamina,Intellect,Spirit,Health,Mana,Speed,Global Cooldown,Haste,Haste Rating,Resilience,Armor,Attack Power,Spell Power,Melee Crit,Melee Crit bonus,Spell Crit,Spell Crit Bonus,Block,Parry,Damage Reduction,Melee Damage Reduction,Spell Damage Reduction,Damage Taken,Heal Taken,Melee Damage,Spell Damage,Holy Resist,Shadow Resist,Nature Resist,Fire Resist,Frost Resist,Lightning Resist,Chaos Resist,Silence Resist,Fear Resist,Stun Resist,Energy,Rage,XP Rate"
|
||||||
enums/skeletons_bones=PoolStringArray( "", "root,pelvis,spine,spine_1,spine_2,neck,head,left_clavicle,left_upper_arm,left_forearm,left_hand,left_thumb_base,left_thumb_end,left_fingers_base,left_fingers_end,right_clavicle,right_upper_arm,right_forearm,right_hand,right_thumb_base,right_thumb_end,right_fingers_base,right_fingers_end,left_thigh,left_calf,left_foot,right_thigh,right_calf,right_foot" )
|
enums/skeletons_bones=PoolStringArray( "", "root,pelvis,spine,spine_1,spine_2,neck,head,left_clavicle,left_upper_arm,left_forearm,left_hand,left_thumb_base,left_thumb_end,left_fingers_base,left_fingers_end,right_clavicle,right_upper_arm,right_forearm,right_hand,right_thumb_base,right_thumb_end,right_fingers_base,right_fingers_end,left_thigh,left_calf,left_foot,right_thigh,right_calf,right_foot" )
|
||||||
enums/skeletons_bone_attachment_points=PoolStringArray( "", "left_hand,right_hand,torso,root,right_hip,left_hip,spine_2,weapon_left,weapon_right,weapon_left_back,weapon_right_back,weapon_shield_left" )
|
enums/skeletons_bone_attachment_points=PoolStringArray( "", "left_hand,right_hand,torso,root,right_hip,left_hip,spine_2,weapon_left,weapon_right,weapon_left_back,weapon_right_back,weapon_shield_left" )
|
||||||
|
xp/class_xps=PoolIntArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
|
||||||
|
xp/character_xps=PoolIntArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
|
||||||
profiles/automatic_save=true
|
profiles/automatic_save=true
|
||||||
|
level/max_character_level=60
|
||||||
|
level/max_class_level=60
|
||||||
|
|
||||||
[importer_defaults]
|
[importer_defaults]
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ export(NodePath) var renounce_button_path : NodePath
|
|||||||
export(NodePath) var create_button_path : NodePath
|
export(NodePath) var create_button_path : NodePath
|
||||||
|
|
||||||
export(bool) var automatic_character_load : bool = false
|
export(bool) var automatic_character_load : bool = false
|
||||||
|
export(bool) var only_one_character : bool = false
|
||||||
|
|
||||||
var container : Node
|
var container : Node
|
||||||
var player_display_container_node : Node
|
var player_display_container_node : Node
|
||||||
@ -40,8 +41,8 @@ func _ready():
|
|||||||
container = get_node(container_path)
|
container = get_node(container_path)
|
||||||
player_display_container_node = get_node(player_display_container_path)
|
player_display_container_node = get_node(player_display_container_path)
|
||||||
|
|
||||||
# if container == null:
|
if container == null:
|
||||||
# Logger.error("CharacterSelector not set up properly!")
|
Logger.error("CharacterSelector not set up properly!")
|
||||||
|
|
||||||
connect("visibility_changed", self, "visibility_changed")
|
connect("visibility_changed", self, "visibility_changed")
|
||||||
|
|
||||||
@ -74,14 +75,14 @@ func refresh():
|
|||||||
var json_err : String = validate_json(st)
|
var json_err : String = validate_json(st)
|
||||||
|
|
||||||
if json_err != "":
|
if json_err != "":
|
||||||
print("Save corrupted! " + file_name)
|
Logger.error("Save corrupted! " + file_name)
|
||||||
print(json_err)
|
Logger.error(json_err)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var p = parse_json(st)
|
var p = parse_json(st)
|
||||||
|
|
||||||
if typeof(p) != TYPE_DICTIONARY:
|
if typeof(p) != TYPE_DICTIONARY:
|
||||||
print("Save corrupted! Not Dict! " + file_name)
|
Logger.error("Save corrupted! Not Dict! " + file_name)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var display : Entity = ESS.entity_spawner.spawn_display_player(file_name, player_display_container_node.get_path())
|
var display : Entity = ESS.entity_spawner.spawn_display_player(file_name, player_display_container_node.get_path())
|
||||||
@ -105,7 +106,7 @@ func refresh():
|
|||||||
centry.pressed = true
|
centry.pressed = true
|
||||||
centry.connect("pressed", self, "character_selection_changed")
|
centry.connect("pressed", self, "character_selection_changed")
|
||||||
|
|
||||||
centry.setup(file_name, display.sentity_name, ESS.get_resource_db().get_entity_data(display.characterclass_id).text_name, display.scharacter_level, display.sclass_level, display)
|
centry.setup(file_name, display.sentity_name, ESS.get_resource_db().get_entity_data(display.characterclass_id).text_name, display.slevel, display.slevel, display)
|
||||||
|
|
||||||
if first_entry == null:
|
if first_entry == null:
|
||||||
first_entry = centry
|
first_entry = centry
|
||||||
@ -114,24 +115,31 @@ func refresh():
|
|||||||
first_entry.pressed = true
|
first_entry.pressed = true
|
||||||
|
|
||||||
if first_entry != null:
|
if first_entry != null:
|
||||||
get_node(container_path).show()
|
#note that this just disables the create button, and
|
||||||
get_node(load_button_path).show()
|
#will still allow character creation otherwise
|
||||||
|
if only_one_character:
|
||||||
get_node(create_button_path).hide()
|
get_node(create_button_path).hide()
|
||||||
|
get_node(container_path).show()
|
||||||
|
|
||||||
|
get_node(load_button_path).show()
|
||||||
get_node(renounce_button_path).show()
|
get_node(renounce_button_path).show()
|
||||||
|
|
||||||
if (automatic_character_load):
|
if (automatic_character_load):
|
||||||
load_character()
|
load_character()
|
||||||
else:
|
else:
|
||||||
get_node(container_path).hide()
|
if only_one_character:
|
||||||
get_node(load_button_path).hide()
|
|
||||||
get_node(create_button_path).show()
|
get_node(create_button_path).show()
|
||||||
|
get_node(container_path).hide()
|
||||||
|
|
||||||
|
get_node(load_button_path).hide()
|
||||||
get_node(renounce_button_path).hide()
|
get_node(renounce_button_path).hide()
|
||||||
else:
|
else:
|
||||||
dir.make_dir("user://" + character_folder)
|
dir.make_dir("user://" + character_folder)
|
||||||
|
if only_one_character:
|
||||||
get_node(container_path).hide()
|
get_node(container_path).hide()
|
||||||
get_node(load_button_path).hide()
|
|
||||||
get_node(create_button_path).show()
|
get_node(create_button_path).show()
|
||||||
|
|
||||||
|
get_node(load_button_path).hide()
|
||||||
get_node(renounce_button_path).hide()
|
get_node(renounce_button_path).hide()
|
||||||
|
|
||||||
func clear() -> void:
|
func clear() -> void:
|
||||||
@ -148,20 +156,20 @@ func renounce_character() -> void:
|
|||||||
if b == null:
|
if b == null:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if ESS.use_class_xp:
|
||||||
var class_profile : ClassProfile = ProfileManager.getc_player_profile().get_class_profile(b.entity.sentity_data.resource_path)
|
var class_profile : ClassProfile = ProfileManager.getc_player_profile().get_class_profile(b.entity.sentity_data.resource_path)
|
||||||
|
|
||||||
var xp_data : XPData = ESS.get_resource_db().get_xp_data()
|
if ESS.can_class_level_up(class_profile.level):
|
||||||
|
|
||||||
if xp_data.can_class_level_up(class_profile.level):
|
|
||||||
class_profile.xp += b.entity.sclass_xp
|
class_profile.xp += b.entity.sclass_xp
|
||||||
|
|
||||||
var xpr : int = xp_data.get_class_xp(class_profile.level)
|
|
||||||
|
|
||||||
while xp_data.can_class_level_up(class_profile.level) and class_profile.xp >= xpr:
|
var xpr : int = ESS.get_class_xp(class_profile.level)
|
||||||
|
|
||||||
|
while ESS.can_class_level_up(class_profile.level) and class_profile.xp >= xpr:
|
||||||
class_profile.level += 1
|
class_profile.level += 1
|
||||||
class_profile.xp -= xpr
|
class_profile.xp -= xpr
|
||||||
|
|
||||||
xpr = xp_data.get_class_xp(class_profile.level)
|
xpr = ESS.get_class_xp(class_profile.level)
|
||||||
|
|
||||||
ProfileManager.save()
|
ProfileManager.save()
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=20 format=2]
|
[gd_scene load_steps=17 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=1]
|
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=1]
|
||||||
[ext_resource path="res://ui/menu/CharacterEntry.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://ui/menu/CharacterEntry.tscn" type="PackedScene" id=2]
|
||||||
@ -15,51 +15,8 @@
|
|||||||
[ext_resource path="res://scenes/DisconnectButton.gd" type="Script" id=13]
|
[ext_resource path="res://scenes/DisconnectButton.gd" type="Script" id=13]
|
||||||
[ext_resource path="res://scenes/ConnectServerButton.gd" type="Script" id=14]
|
[ext_resource path="res://scenes/ConnectServerButton.gd" type="Script" id=14]
|
||||||
[ext_resource path="res://scenes/HostGameButton.gd" type="Script" id=15]
|
[ext_resource path="res://scenes/HostGameButton.gd" type="Script" id=15]
|
||||||
[ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=19]
|
|
||||||
[ext_resource path="res://ui/about/About.tscn" type="PackedScene" id=20]
|
[ext_resource path="res://ui/about/About.tscn" type="PackedScene" id=20]
|
||||||
|
|
||||||
[sub_resource type="ProceduralSky" id=2]
|
|
||||||
sky_top_color = Color( 0.447059, 0.780392, 0.854902, 1 )
|
|
||||||
sky_horizon_color = Color( 0.273637, 0.277344, 0.206924, 1 )
|
|
||||||
sky_curve = 0.263535
|
|
||||||
sky_energy = 0.3
|
|
||||||
ground_bottom_color = Color( 0.196078, 0.152941, 0.152941, 1 )
|
|
||||||
ground_horizon_color = Color( 0.223529, 0.192157, 0.164706, 1 )
|
|
||||||
ground_curve = 0.101965
|
|
||||||
ground_energy = 0.4
|
|
||||||
sun_color = Color( 0.45098, 0.352941, 0.113725, 1 )
|
|
||||||
sun_latitude = 39.71
|
|
||||||
sun_longitude = -8.09
|
|
||||||
sun_angle_min = 0.0
|
|
||||||
sun_angle_max = 23.15
|
|
||||||
sun_energy = 9.29
|
|
||||||
texture_size = 0
|
|
||||||
|
|
||||||
[sub_resource type="Environment" id=3]
|
|
||||||
background_mode = 2
|
|
||||||
background_sky = SubResource( 2 )
|
|
||||||
ambient_light_color = Color( 0.870588, 0.870588, 0.870588, 1 )
|
|
||||||
ambient_light_energy = 1.24
|
|
||||||
ambient_light_sky_contribution = 0.09
|
|
||||||
fog_enabled = true
|
|
||||||
fog_color = Color( 0.184314, 0.207843, 0.156863, 1 )
|
|
||||||
fog_sun_color = Color( 0.239216, 0.337255, 0.396078, 1 )
|
|
||||||
fog_sun_amount = 0.53
|
|
||||||
fog_depth_begin = 155.9
|
|
||||||
fog_depth_end = 379.9
|
|
||||||
fog_depth_curve = 1.18921
|
|
||||||
tonemap_mode = 2
|
|
||||||
tonemap_exposure = 0.83
|
|
||||||
auto_exposure_max_luma = 7.33
|
|
||||||
ss_reflections_enabled = true
|
|
||||||
ssao_enabled = true
|
|
||||||
glow_levels/3 = false
|
|
||||||
glow_intensity = 1.6
|
|
||||||
glow_strength = 1.1
|
|
||||||
glow_bloom = 0.1
|
|
||||||
glow_hdr_luminance_cap = 1.0
|
|
||||||
adjustment_enabled = true
|
|
||||||
|
|
||||||
[node name="Menu" type="Control"]
|
[node name="Menu" type="Control"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
@ -100,13 +57,13 @@ __meta__ = {
|
|||||||
"_editor_description_": ""
|
"_editor_description_": ""
|
||||||
}
|
}
|
||||||
menu_path = NodePath("..")
|
menu_path = NodePath("..")
|
||||||
container_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Container")
|
container_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/ScrollContainer/Container")
|
||||||
player_display_container_path = NodePath("../Char/CharacterDisplay")
|
player_display_container_path = NodePath("../Char/CharacterDisplay")
|
||||||
character_button_group = ExtResource( 4 )
|
character_button_group = ExtResource( 4 )
|
||||||
character_entry = ExtResource( 2 )
|
character_entry = ExtResource( 2 )
|
||||||
character_folder = "characters"
|
character_folder = "characters"
|
||||||
load_button_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Continue")
|
load_button_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Load")
|
||||||
renounce_button_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Renounce")
|
renounce_button_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Delete")
|
||||||
create_button_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/New")
|
create_button_path = NodePath("CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/New")
|
||||||
|
|
||||||
[node name="CharacterSelector" type="MarginContainer" parent="CharacterSelectorMenu"]
|
[node name="CharacterSelector" type="MarginContainer" parent="CharacterSelectorMenu"]
|
||||||
@ -131,9 +88,9 @@ margin_bottom = 580.0
|
|||||||
alignment = 2
|
alignment = 2
|
||||||
|
|
||||||
[node name="CharacterSelector" type="PanelContainer" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer"]
|
[node name="CharacterSelector" type="PanelContainer" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer"]
|
||||||
margin_top = 450.0
|
|
||||||
margin_right = 269.0
|
margin_right = 269.0
|
||||||
margin_bottom = 560.0
|
margin_bottom = 560.0
|
||||||
|
size_flags_vertical = 3
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
@ -142,34 +99,36 @@ __meta__ = {
|
|||||||
margin_left = 4.0
|
margin_left = 4.0
|
||||||
margin_top = 4.0
|
margin_top = 4.0
|
||||||
margin_right = 265.0
|
margin_right = 265.0
|
||||||
margin_bottom = 106.0
|
margin_bottom = 556.0
|
||||||
|
|
||||||
[node name="Container" type="VBoxContainer" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
|
[node name="ScrollContainer" type="ScrollContainer" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
|
||||||
margin_right = 261.0
|
margin_right = 261.0
|
||||||
size_flags_horizontal = 3
|
margin_bottom = 450.0
|
||||||
|
|
||||||
[node name="Continue" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
|
|
||||||
margin_top = 8.0
|
|
||||||
margin_right = 261.0
|
|
||||||
margin_bottom = 34.5702
|
|
||||||
text = "Continue"
|
|
||||||
|
|
||||||
[node name="Renounce" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
|
|
||||||
margin_top = 42.0
|
|
||||||
margin_right = 261.0
|
|
||||||
margin_bottom = 68.5702
|
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
text = "Renounce"
|
|
||||||
|
[node name="Container" type="VBoxContainer" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/ScrollContainer"]
|
||||||
|
margin_right = 261.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="Load" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
|
||||||
|
margin_top = 458.0
|
||||||
|
margin_right = 261.0
|
||||||
|
margin_bottom = 484.57
|
||||||
|
text = "Load"
|
||||||
|
|
||||||
[node name="New" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
|
[node name="New" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
|
||||||
margin_top = 76.0
|
margin_top = 492.0
|
||||||
margin_right = 261.0
|
margin_right = 261.0
|
||||||
margin_bottom = 102.57
|
margin_bottom = 518.57
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 3
|
|
||||||
text = "New"
|
text = "New"
|
||||||
|
|
||||||
|
[node name="Delete" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
|
||||||
|
margin_top = 526.0
|
||||||
|
margin_right = 261.0
|
||||||
|
margin_bottom = 552.57
|
||||||
|
text = "Delete"
|
||||||
|
|
||||||
[node name="PlayerDisplays" type="Node" parent="CharacterSelectorMenu"]
|
[node name="PlayerDisplays" type="Node" parent="CharacterSelectorMenu"]
|
||||||
|
|
||||||
[node name="CharacterCreationMenu" type="Control" parent="."]
|
[node name="CharacterCreationMenu" type="Control" parent="."]
|
||||||
@ -564,28 +523,9 @@ transform = Transform( 1, 1.49012e-08, 0, 0, 0.990268, -0.139173, -2.98023e-08,
|
|||||||
[node name="Camera" type="Camera" parent="Char"]
|
[node name="Camera" type="Camera" parent="Char"]
|
||||||
transform = Transform( 0.907555, -0.0761572, 0.41297, 0.0262364, 0.99178, 0.12524, -0.419113, -0.102827, 0.902093, 0.752064, 1.69463, 3.15021 )
|
transform = Transform( 0.907555, -0.0761572, 0.41297, 0.0262364, 0.99178, 0.12524, -0.419113, -0.102827, 0.902093, 0.752064, 1.69463, 3.15021 )
|
||||||
current = true
|
current = true
|
||||||
|
[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Load" to="CharacterSelectorMenu" method="load_character"]
|
||||||
[node name="World" type="Spatial" parent="." groups=[
|
|
||||||
"save",
|
|
||||||
]]
|
|
||||||
|
|
||||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="World"]
|
|
||||||
environment = SubResource( 3 )
|
|
||||||
__meta__ = {
|
|
||||||
"_editor_description_": ""
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="DirectionalLight" type="DirectionalLight" parent="World"]
|
|
||||||
transform = Transform( -0.797163, 0.45442, 0.397535, 0.124932, -0.520028, 0.844963, 0.590697, 0.723238, 0.357776, 0, 18.834, 0 )
|
|
||||||
layers = 3
|
|
||||||
light_color = Color( 1, 0.878431, 0.878431, 1 )
|
|
||||||
light_energy = 0.87
|
|
||||||
light_specular = 0.65
|
|
||||||
shadow_bias = 0.07
|
|
||||||
script = ExtResource( 19 )
|
|
||||||
[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Continue" to="CharacterSelectorMenu" method="load_character"]
|
|
||||||
[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Renounce" to="CharacterSelectorMenu" method="renounce_character"]
|
|
||||||
[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/New" to="." method="switch_to_menu" binds= [ 1 ]]
|
[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/New" to="." method="switch_to_menu" binds= [ 1 ]]
|
||||||
|
[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer/Delete" to="CharacterSelectorMenu" method="renounce_character"]
|
||||||
[connection signal="pressed" from="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer/Create" to="CharacterCreationMenu" method="create"]
|
[connection signal="pressed" from="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer/Create" to="CharacterCreationMenu" method="create"]
|
||||||
[connection signal="pressed" from="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer/Back" to="." method="switch_to_menu" binds= [ 0 ]]
|
[connection signal="pressed" from="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer/Back" to="." method="switch_to_menu" binds= [ 0 ]]
|
||||||
[connection signal="pressed" from="ConnectMenu/PanelContainer/VBoxContainer/Button2" to="ConnectMenu" method="hide"]
|
[connection signal="pressed" from="ConnectMenu/PanelContainer/VBoxContainer/Button2" to="ConnectMenu" method="hide"]
|
||||||
|
@ -84,7 +84,7 @@ func set_player(p_player: Entity) -> void:
|
|||||||
_health.connect("changed", self, "_on_player_health_changed")
|
_health.connect("changed", self, "_on_player_health_changed")
|
||||||
|
|
||||||
_name_text.text = _player.centity_name
|
_name_text.text = _player.centity_name
|
||||||
_level_text.text = str(_player.ccharacter_level)
|
_level_text.text = str(_player.clevel)
|
||||||
|
|
||||||
clevel_changed(_player, 0)
|
clevel_changed(_player, 0)
|
||||||
notification_cxp_gained(_player, 0)
|
notification_cxp_gained(_player, 0)
|
||||||
@ -132,9 +132,9 @@ func cname_changed(entity: Entity) -> void:
|
|||||||
_name_text.text = _player.centity_name
|
_name_text.text = _player.centity_name
|
||||||
|
|
||||||
func clevel_changed(entity: Entity, value : int) -> void:
|
func clevel_changed(entity: Entity, value : int) -> void:
|
||||||
_level_text.text = str(_player.ccharacter_level)
|
_level_text.text = str(_player.clevel)
|
||||||
|
|
||||||
var xpreq : int = ESS.get_resource_db().get_xp_data().get_character_xp(_player.ccharacter_level)
|
var xpreq : int = ESS.get_character_xp(_player.clevel)
|
||||||
|
|
||||||
if xpreq == 0:
|
if xpreq == 0:
|
||||||
_xp_range.value = 0
|
_xp_range.value = 0
|
||||||
@ -146,5 +146,5 @@ func clevel_changed(entity: Entity, value : int) -> void:
|
|||||||
_xp_range.max_value = xpreq
|
_xp_range.max_value = xpreq
|
||||||
|
|
||||||
func notification_cxp_gained(entity: Entity, val: int) -> void:
|
func notification_cxp_gained(entity: Entity, val: int) -> void:
|
||||||
_xp_range.value = _player.ccharacter_xp
|
_xp_range.value = _player.cxp
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user