Update notice and add documentation to classes

This commit is contained in:
JeremyStar™ 2024-02-12 19:47:28 +01:00
parent ad302671f8
commit 291c7c5349
9 changed files with 260 additions and 207 deletions

View file

@ -1,35 +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/>. ###
##############################################################################
### 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. ###
##############################################################################
# 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
# CORE Object
## Contains a reference to the CORE Object[br]
## [br]
## Set before loading the module into the SceneTree.
var core: Core
# CORE's logger implementation
@onready var logger: Node = core.logger
## Reference to CORE's logger implementation.[br]
## [br]
## Will be set before [method Node._ready]
@onready var logger: CoreBaseModule = core.logger
# Replacement for _init()
## 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 on configuration update
## Called by [method Core.apply_configuration].
## This should be used to update your module configuration.
func _pull_config() -> void: pass

View file

@ -1,42 +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/classes/config.gd (CORE Configuration) ###
### ###
### This source file contains the default configuration for the CORE ###
### Framework. ###
##############################################################################
# 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

View file

@ -1,26 +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/classes/types.gd (CORE Global Types) ###
### ###
### This source file contains globally accessible custom enums and types ###
### used throughout the CORE Framework's source code. ###
##############################################################################
# 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

View file

@ -1,45 +1,57 @@
##############################################################################
### 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
## The release type number. Resets on every new release and release type.
const version_typerelease: int = 1
# 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
@ -59,6 +71,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 +107,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 +118,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 +139,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 +149,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 +158,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 +169,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!")
@ -165,6 +190,9 @@ func apply_configuration() -> void:
module._pull_config()
# 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://"
@ -178,10 +206,19 @@ func determine_basepath() -> bool:
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 +251,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):

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

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/misc.gd (Miscellaneous) ###
### ###
### Contains various functions that don't fit into other modules. ###
##############################################################################
# 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:

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