This commit is contained in:
JeremyStar™ 2024-02-12 20:24:12 +01:00
parent 22b1904fea
commit 3656b1fb6e
31 changed files with 391 additions and 293 deletions

7
.gitattributes vendored Normal file
View file

@ -0,0 +1,7 @@
# Normalize line endings for all files that Git considers text files.
* text=auto eol=lf
# Only include the addons folder when downloading from the Asset Library.
/** export-ignore
/addons !export-ignore
/addons/** !export-ignore

15
.gitignore vendored Normal file
View file

@ -0,0 +1,15 @@
# Godot 4+ specific ignores
.godot/
# Godot-specific ignores
.import/
export.cfg
export_presets.cfg
# Imported translations (automatically generated from CSV files)
*.translation
# Mono-specific ignores
.mono/
data_*/
mono_crash.*.json

View file

@ -1,35 +0,0 @@
##############################################################################
### CORE FRAMEWORK SOURCE FILE ###
### Copyright (c) 2024 The StarOpenSource Project & Contributors ###
### Licensed under the GNU General Public License v3 ###
### ###
### This program is free software: you can redistribute it and/or modify ###
### it under the terms of the GNU General Public License as published by ###
### the Free Software Foundation, either version 3 of the License, or ###
### (at your option) any later version. ###
### ###
### This program is distributed in the hope that it will be useful, ###
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
### GNU General Public License for more details. ###
### ###
### You should have received a copy of the GNU General Public License ###
### along with this program. If not, see <https://www.gnu.org/licenses/>. ###
##############################################################################
### src/classes/basemodule.gd (CORE Base Module) ###
### ###
### This source file is a basic CORE module template. It provides ###
### common functions and variables for all CORE modules. ###
##############################################################################
extends Node
class_name CoreBaseModule
# CORE Object
var core: Core
# CORE's logger implementation
@onready var logger: Node = core.logger
# Replacement for _init()
func _initialize() -> void: pass
# Called on configuration update
func _pull_config() -> void: pass

View file

@ -1,58 +0,0 @@
##############################################################################
### CORE FRAMEWORK SOURCE FILE ###
### Copyright (c) 2024 The StarOpenSource Project & Contributors ###
### Licensed under the GNU General Public License v3 ###
### ###
### This program is free software: you can redistribute it and/or modify ###
### it under the terms of the GNU General Public License as published by ###
### the Free Software Foundation, either version 3 of the License, or ###
### (at your option) any later version. ###
### ###
### This program is distributed in the hope that it will be useful, ###
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
### GNU General Public License for more details. ###
### ###
### You should have received a copy of the GNU General Public License ###
### along with this program. If not, see <https://www.gnu.org/licenses/>. ###
##############################################################################
### src/classes/config.gd (CORE Configuration) ###
### ###
### This source file contains the default configuration for the CORE ###
### Framework. ###
##############################################################################
extends Node
class_name CoreConfiguration
@export_category("Global")
@export var headless: bool
@export var debugging: bool
@export var custom_modules: bool
@export_category("Logger")
@export var logger_level: CoreTypes.LoggerLevel
@export var logger_colored: bool
@export var logger_format: String
@export var logger_newlines_override: bool
@export var logger_newlines_sizelimit: int
@export_category("LogUI")
@export var logui_enabled: bool
@export var logui_background_color: Color
@export var logui_font_size: int
# Default settings
func _init() -> void:
# Global
headless = false
debugging = false
custom_modules = false
# Logger
logger_level = CoreTypes.LoggerLevel.INFO
logger_colored = true
logger_format = "%color%[%time%] [%level% %source%:%line%] %message%"
logger_newlines_override = true
logger_newlines_sizelimit = 40
# LogUI
logui_enabled = true
logui_background_color = Color.BLACK # To disable the background, use Color.TRANSPARENT
logui_font_size = 14

View file

@ -1,29 +0,0 @@
##############################################################################
### CORE FRAMEWORK SOURCE FILE ###
### Copyright (c) 2024 The StarOpenSource Project & Contributors ###
### Licensed under the GNU General Public License v3 ###
### ###
### This program is free software: you can redistribute it and/or modify ###
### it under the terms of the GNU General Public License as published by ###
### the Free Software Foundation, either version 3 of the License, or ###
### (at your option) any later version. ###
### ###
### This program is distributed in the hope that it will be useful, ###
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
### GNU General Public License for more details. ###
### ###
### You should have received a copy of the GNU General Public License ###
### along with this program. If not, see <https://www.gnu.org/licenses/>. ###
##############################################################################
### src/classes/types.gd (CORE Global Types) ###
### ###
### This source file contains globally accessible custom enums and types ###
### used throughout the CORE Framework's source code. ###
##############################################################################
extends Node
class_name CoreTypes
enum VersionType { RELEASE, RELEASECANDIDATE, BETA, ALPHA }
enum LoggerLevel { NONE, ERROR, WARN, INFO, VERB, DIAG }
enum SceneType { NONE, DEBUG, CUTSCENE, MENU, MAIN, BACKGROUND }

View file

@ -1,46 +0,0 @@
##############################################################################
### CORE FRAMEWORK SOURCE FILE ###
### Copyright (c) 2024 The StarOpenSource Project & Contributors ###
### Licensed under the GNU General Public License v3 ###
### ###
### This program is free software: you can redistribute it and/or modify ###
### it under the terms of the GNU General Public License as published by ###
### the Free Software Foundation, either version 3 of the License, or ###
### (at your option) any later version. ###
### ###
### This program is distributed in the hope that it will be useful, ###
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
### GNU General Public License for more details. ###
### ###
### You should have received a copy of the GNU General Public License ###
### along with this program. If not, see <https://www.gnu.org/licenses/>. ###
##############################################################################
### src/misc.gd (Miscellaneous) ###
### ###
### Contains various functions that don't fit into other modules. ###
##############################################################################
extends CoreBaseModule
func quit_safely(exitcode: int = 0) -> void:
logger.info("Shutting down (code " + str(exitcode) + ")")
logger.diag("Waiting for log messages to be flushed")
await get_tree().create_timer(0.25).timeout
get_tree().quit(exitcode)
@warning_ignore("integer_division")
func byte2mib(bytes: int, flatten: bool = true) -> float:
if flatten: return bytes/1048576
return bytes/float(1048576)
func mib2byte(mib: float, flatten: bool = true) -> float:
if flatten: return int(mib*1048576)
return mib*1048576
func mib2gib(mib: float, flatten: bool = true) -> float:
if flatten: return int(mib/1024)
return mib/1024
func gib2mib(gib: float, flatten: bool = true) -> float:
if flatten: return int(gib*1024)
return gib*1024

View file

5
addons/CORE/README.md Normal file
View file

@ -0,0 +1,5 @@
# CORE Framework distribution repository
This repository is used for distributing CORE in the [Godot Asset Library](https://godotengine.org/asset-library/).
## [CORE Repository](https://git.staropensource.de/StarOpenSource/CORE)
## [Documentation](https://core.staropensource.de)

View file

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

View file

@ -0,0 +1,39 @@
# CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Template for CORE modules.
##
## Provides a basic template and a common foundation for building CORE modules.
## It provides common functions and variables used in all CORE modules.
extends Node
class_name CoreBaseModule
## Contains a reference to the CORE Object[br]
## [br]
## Set before loading the module into the SceneTree.
var core: Core
## Reference to CORE's logger implementation.[br]
## [br]
## Will be set before [method Node._ready]
@onready var logger: CoreBaseModule = core.logger
## CORE's replacement for [method Object._init] and [method Node._ready]
## It's [b]strongly[/b] recommended to initialize your module here.
func _initialize() -> void: pass
## Called by [method Core.apply_configuration].
## This should be used to update your module configuration.
func _pull_config() -> void: pass

View file

@ -0,0 +1,79 @@
# CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## The default configuration file for the CORE Framework.
##
## The [code]%CoreConfiguration[/code] class holds the Framework's settings.
## The default configuration is designed to not interfere with the developer experience
## and your project without any customization.
extends Node
class_name CoreConfiguration
@export_category("Global")
## Controls CORE's functionality.
## Renders GUI-related modules useless when set to [code]false[/code], which is the recommended behaviour on servers. For CORE's full functionality, set this to [code]true[/code].
@export var headless: bool
## Allows debugging functionality if set to [code]true[/code], or not if set to [code]false[/code].[br]
## [br]
## Note: This will not enable the development mode automaticall, only if you're developing on CORE itself.
@export var debugging: bool
## Allows or disallows custom modules.
@export var custom_modules: bool
@export_category("Logger")
## I don't have to explain this, do I?
@export var logger_level: CoreTypes.LoggerLevel
## Toggles colored output. Set to [code]false[/code] if you don't want that.
@export var logger_colored: bool
## The format string the logger will operate on. Available placeholders are: [code]%time%[/code], [code]%time_ms%[/code], [code]%level%[/code], [code]%color%[/code], [code]%message%[/code], [code]%source%[/code], [code]%source_raw%[/code], [code]%function%[/code] and [code]%line%[/code]
@export var logger_format: String
## This example should make it clear, what this does:
## [codeblock]
## logger_newlines_override = true:
## [09:47:00] [INFO Test.gd:69] This is a test message...
## with a newline!
## logger_newlines_override = false:
## [09:47:00] [INFO Test.gd:69] This is a test message...
## with a newline!
## [/codeblock]
@export var logger_newlines_override: bool
## The maximum amount of characters than can appear before [code]%message%[/code] before newlines won't be overriden. Setting this variable to [code]-1[/code] disables this behaviour.
@export var logger_newlines_sizelimit: int
@export_category("LogUI")
## Determines if [code]LogUI[/code] should be visible or not.
@export var logui_enabled: bool
## The color the [code]LogUI[/code] background will have. Set to [code]Color.TRANSPARENT[/code] for a transparent background.
@export var logui_background_color: Color
## What size the graphical log should have.
@export var logui_font_size: int
# Default settings
func _init() -> void:
# Global
headless = false
debugging = false
custom_modules = false
# Logger
logger_level = CoreTypes.LoggerLevel.INFO
logger_colored = true
logger_format = "%color%[%time%] [%level% %source%:%line%] %message%"
logger_newlines_override = true
logger_newlines_sizelimit = 40
# LogUI
logui_enabled = true
logui_background_color = Color.BLACK # To disable the background, use Color.TRANSPARENT
logui_font_size = 14

View file

@ -0,0 +1,26 @@
# CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Types and enums for the CORE Framework.
##
## Contains enums and types shared across the CORE Framework.
extends Node
class_name CoreTypes
enum VersionType { RELEASE, RELEASECANDIDATE, BETA, ALPHA }
enum LoggerLevel { NONE, ERROR, WARN, INFO, VERB, DIAG }
enum SceneType { NONE, DEBUG, CUTSCENE, MENU, MAIN, BACKGROUND }

View file

@ -1,50 +1,63 @@
##############################################################################
### CORE FRAMEWORK SOURCE FILE ###
### Copyright (c) 2024 The StarOpenSource Project & Contributors ###
### Licensed under the GNU General Public License v3 ###
### ###
### This program is free software: you can redistribute it and/or modify ###
### it under the terms of the GNU General Public License as published by ###
### the Free Software Foundation, either version 3 of the License, or ###
### (at your option) any later version. ###
### ###
### This program is distributed in the hope that it will be useful, ###
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
### GNU General Public License for more details. ###
### ###
### You should have received a copy of the GNU General Public License ###
### along with this program. If not, see <https://www.gnu.org/licenses/>. ###
##############################################################################
### src/core.gd (CORE Object) ###
### ###
### This source file is responsible for initializing CORE's modules, ###
### handling communication between them and much more. ###
##############################################################################
# CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Initializes and manages the framework.
##
## The [b]CORE Object[/b] is responsible for initializing, managing and
## serving the CORE Framework to the developer.
extends Node
class_name Core
# Constants
## The release number
const version_release: int = 1
## The release type
const version_type: CoreTypes.VersionType = CoreTypes.VersionType.BETA
const version_typerelease: int = 1
## The release type number. Resets on every new release and release type.
const version_typerelease: int = 2
# Modules
## Use this to access CORE's logging implementation.
var logger: CoreBaseModule
## Use this to access various useful functions.
var misc: CoreBaseModule
## Use this to access the scene management system.
var sms: CoreBaseModule
## Use this to access the graphical log. Serves no importance to you (probably).
var logui: CoreBaseModule
## Use this to access CORE's builtin HTTP request maker.
var edl: CoreBaseModule
# Variables
## Contains CORE's load path
var basepath: String
## Holds the configuration[br]
## [br]
## [b]NEVER access this yourself. To change the configuration file, use [method Core.reload_configuration] instead.[/b]
var config: CoreConfiguration
## Contains all loaded custom modules.
var custom_modules: Dictionary = {}
## Contains the custom modules node.
var custom_modules_node: Node
# Preinitialization
func _init(new_config: CoreConfiguration = CoreConfiguration.new()) -> void:
name = "CORE"
if !check_godot_version(): queue_free()
if !determine_basepath(): queue_free()
custom_modules_node = Node.new()
reload_configuration(new_config)
@ -59,6 +72,9 @@ func _ready() -> void:
logger.info("Initialized CORE successfully")
# Initialize modules
## Initializes all modules during the first initialization phase.[br]
## [br]
## [b]NEVER call this yourself! You will break everything and risk a crash![/b]
func initialize_modules() -> void:
# Create Nodes
logger = CoreBaseModule.new()
@ -92,6 +108,9 @@ func initialize_modules() -> void:
edl._initialize()
# Inject modules into the SceneTree
## Injects CORE's builtin modules into the SceneTree.[br]
## [br]
## [b]NEVER call this yourself! You will break everything and risk a crash![/b]
func inject_modules() -> void:
add_child(logger)
add_child(misc)
@ -100,6 +119,7 @@ func inject_modules() -> void:
add_child(edl)
# Registers a custom module
## Registers a new custom module.
func register_custom_module(module_name: String, module_class: CoreBaseModule) -> bool:
logger.verb("Registering new custom module \"" + module_name + "\"")
if !config.custom_modules:
@ -120,6 +140,7 @@ func register_custom_module(module_name: String, module_class: CoreBaseModule) -
return true
# Unregisters a custom module
## Unregisters a custom module, making it no longer function.
func unregister_custom_module(module_name: String) -> void:
logger.verb("Unregistering custom module \"" + module_name + "\"")
if !custom_modules.has(module_name):
@ -129,6 +150,7 @@ func unregister_custom_module(module_name: String) -> void:
custom_modules.erase(module_name)
# Returns a custom module
## Returns a loaded custom module for access.
func get_custom_module(module_name: String) -> CoreBaseModule:
logger.diag("Getting custom module \"" + module_name + "\"")
if !custom_modules.has(module_name):
@ -137,6 +159,7 @@ func get_custom_module(module_name: String) -> CoreBaseModule:
return custom_modules[module_name]
# (Re-)Load configuration
## Loads a (new) configuration file and applies it to all modules.
func reload_configuration(new_config: CoreConfiguration = CoreConfiguration.new()) -> void:
var initialized = config != null
if initialized: logger.verb("Reloading CORE's configuration")
@ -147,6 +170,9 @@ func reload_configuration(new_config: CoreConfiguration = CoreConfiguration.new(
if initialized: apply_configuration()
# Call _pull_config() functions
## Applies the newly applied configuration.[br]
## [br]
## [b]NEVER call this yourself unless you know what you are doing![/b]
func apply_configuration() -> void:
logger.verb("Applying configuration")
if is_devmode(): logger.warn("The CORE Framework is in development mode. Here be dragons!")
@ -164,24 +190,20 @@ func apply_configuration() -> void:
logger.diag("Updating configuration for custom module \"" + module.name + "\"")
module._pull_config()
# Determines CORE's installation/base path
func determine_basepath() -> bool:
if FileAccess.file_exists("res://.corebasepath"):
basepath = "res://"
elif FileAccess.file_exists("res://CORE/.corebasepath"):
basepath = "res://CORE/"
elif FileAccess.file_exists("res://addons/CORE/.corebasepath"):
basepath = "res://addons/CORE/"
else:
assert(false, "CORE is not located at 'res://CORE/', aborting initialization")
return false
return true
# Return development mode status
## Returns if the CORE Framework is in development mode.
func is_devmode() -> bool:
return config.debugging and basepath == "res://" and OS.is_debug_build()
# Replaces variables with human-friendly strings
## Replaces placeholders with human-friendly strings You can use the following placeholders:[br]
## - `%release%`: Returns the release number.[br]
## - `%release_type%`: Returns the typerelease number[br]
## - `%release_semantic%`: Returns the result of [method Core.get_version_semantic], example [i]5.2.3[/i][br]
## - `%type%`: Returns the release type as a word, for example [i]Release Candidate[/i][br]
## - `%type_technical%`: Returns the release type as one or two lowercase letters, for example [i]rc[/i][br]
## - `%devmode%`: Returns the development mode status[br]
## - `%headless%`: Returns the headless mode status
func get_formatted_string(string: String) -> String:
# Version strings
string = string.replace("%release%", str(version_release))
@ -214,6 +236,8 @@ func get_formatted_string(string: String) -> String:
return string
# Return CORE's version in the semantic versioning scheme
## Returns CORE's versioning scheme into the semantic versioning scheme.[br]
## The first integer contains the release number, the second integer contains the release type ([code]0[/code] for alpha, [code]1[/code] for beta, [code]2[/code] for rc and [code]3[/code] for release and the last integer contains the typerelease number.
func get_version_semantic() -> Array[int]:
var version_type_int: int
match(version_type):
@ -222,3 +246,36 @@ func get_version_semantic() -> Array[int]:
CoreTypes.VersionType.BETA: version_type_int = 1
CoreTypes.VersionType.ALPHA: version_type_int = 0
return [version_release, version_type_int, version_typerelease]
# Determines CORE's installation/base path
## Determines CORE's installation/base path[br]
## [br]
## [b]Calling this function is likely to be safe, but shouldn't be done nonetheless![/b]
func determine_basepath() -> bool:
if FileAccess.file_exists("res://.corebasepath"):
basepath = "res://"
elif FileAccess.file_exists("res://CORE/.corebasepath"):
basepath = "res://CORE/"
elif FileAccess.file_exists("res://addons/CORE/.corebasepath"):
basepath = "res://addons/CORE/"
else:
assert(false, "CORE is not located at 'res://CORE/', aborting initialization")
return false
return true
# Checks Godot's version
## Checks compatibility with the running version.
func check_godot_version() -> bool:
var version: Dictionary = Engine.get_version_info()
match(version["major"]):
4: pass
_:
assert(true, "The CORE Framework does not support Godot versions older or newer than 4.x.x")
return true
match(version["minor"]):
0: print("The CORE Framework does not support Godot versions older than 4.2.x. Please update to Godot 4.2.x to ensure full compatibility.")
1: print("The CORE Framework does not support Godot versions older than 4.2.x. Please update to Godot 4.2.x to ensure full compatibility.")
2: pass
_: print("The CORE Framework does not support Godot versions newer than 4.2.x. Please downgrade to Godot 4.2.x to ensure full compatibility.")
if version["status"] != "stable": print("The CORE Framework does not support unstable Godot versions. Please switch to Godot stable 4.2.1 to ensure full compatibility.")
return true

View file

@ -1,25 +1,23 @@
##############################################################################
### CORE FRAMEWORK SOURCE FILE ###
### Copyright (c) 2024 The StarOpenSource Project & Contributors ###
### Licensed under the GNU General Public License v3 ###
### ###
### This program is free software: you can redistribute it and/or modify ###
### it under the terms of the GNU General Public License as published by ###
### the Free Software Foundation, either version 3 of the License, or ###
### (at your option) any later version. ###
### ###
### This program is distributed in the hope that it will be useful, ###
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
### GNU General Public License for more details. ###
### ###
### You should have received a copy of the GNU General Public License ###
### along with this program. If not, see <https://www.gnu.org/licenses/>. ###
##############################################################################
### src/edl.gd (Easy DownLoader) ###
### ###
### This source file allows for awaited and/or batched downloads. ###
##############################################################################
# CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## A easy download/request maker.
##
## Allows for awaited and/or batched requests.
extends CoreBaseModule
var list_queue: Dictionary = {}

View file

@ -1,25 +1,24 @@
##############################################################################
### CORE FRAMEWORK SOURCE FILE ###
### Copyright (c) 2024 The StarOpenSource Project & Contributors ###
### Licensed under the GNU General Public License v3 ###
### ###
### This program is free software: you can redistribute it and/or modify ###
### it under the terms of the GNU General Public License as published by ###
### the Free Software Foundation, either version 3 of the License, or ###
### (at your option) any later version. ###
### ###
### This program is distributed in the hope that it will be useful, ###
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
### GNU General Public License for more details. ###
### ###
### You should have received a copy of the GNU General Public License ###
### along with this program. If not, see <https://www.gnu.org/licenses/>. ###
##############################################################################
### src/logger.gd (Logger implementation) ###
### ###
### Prints formatted strings into the console/log. ###
##############################################################################
# CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Your usual basic logger implementation, with some extra features.
##
## Allows for colored output, better newlines, multiple logger levels and a
## large variety of placeholders usable in [param config_format].
extends CoreBaseModule
# Signals

View file

@ -1,25 +1,23 @@
##############################################################################
### CORE FRAMEWORK SOURCE FILE ###
### Copyright (c) 2024 The StarOpenSource Project & Contributors ###
### Licensed under the GNU General Public License v3 ###
### ###
### This program is free software: you can redistribute it and/or modify ###
### it under the terms of the GNU General Public License as published by ###
### the Free Software Foundation, either version 3 of the License, or ###
### (at your option) any later version. ###
### ###
### This program is distributed in the hope that it will be useful, ###
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
### GNU General Public License for more details. ###
### ###
### You should have received a copy of the GNU General Public License ###
### along with this program. If not, see <https://www.gnu.org/licenses/>. ###
##############################################################################
### src/logui.gd (LogUI) ###
### ###
### Displays the log/console output graphically. ###
##############################################################################
# CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Displays the log graphically.
##
## Displays the log output graphically in the background of the application.
extends CoreBaseModule
# Objects

45
addons/CORE/src/misc.gd Normal file
View file

@ -0,0 +1,45 @@
# CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Contains various useful functions that do not fit into other modules.
##
## Contains various useful functions that you can use to save yourself some time
## programming or searching.
extends CoreBaseModule
func quit_safely(exitcode: int = 0) -> void:
logger.info("Shutting down (code " + str(exitcode) + ")")
logger.diag("Waiting for log messages to be flushed")
await get_tree().create_timer(0.25).timeout
get_tree().quit(exitcode)
@warning_ignore("integer_division")
func byte2mib(bytes: int, flatten: bool = true) -> float:
if flatten: return bytes/1048576
return bytes/float(1048576)
func mib2byte(mib: float, flatten: bool = true) -> float:
if flatten: return int(mib*1048576)
return mib*1048576
func mib2gib(mib: float, flatten: bool = true) -> float:
if flatten: return int(mib/1024)
return mib/1024
func gib2mib(gib: float, flatten: bool = true) -> float:
if flatten: return int(gib*1024)
return gib*1024

View file

@ -1,25 +1,23 @@
##############################################################################
### CORE FRAMEWORK SOURCE FILE ###
### Copyright (c) 2024 The StarOpenSource Project & Contributors ###
### Licensed under the GNU General Public License v3 ###
### ###
### This program is free software: you can redistribute it and/or modify ###
### it under the terms of the GNU General Public License as published by ###
### the Free Software Foundation, either version 3 of the License, or ###
### (at your option) any later version. ###
### ###
### This program is distributed in the hope that it will be useful, ###
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
### GNU General Public License for more details. ###
### ###
### You should have received a copy of the GNU General Public License ###
### along with this program. If not, see <https://www.gnu.org/licenses/>. ###
##############################################################################
### src/sms.gd (Scene Management System) ###
### ###
### Makes scene management way smarter and easier. ###
##############################################################################
# CORE FRAMEWORK SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
## Manages scenes more efficiently.
##
## Allows for organized scene management, making development much faster.
extends CoreBaseModule
# Objects