Many improvements (see commit description)

Added more things to roadmap, removed autoload singleton check, added support for Godot 4.1, all startup messages now use Logger.diag() instead of Logger.info() (making them disappear but can be shown if needed), removed autoload.gd, fixes syntax.
This commit is contained in:
JeremyStar™ 2023-07-07 10:58:49 +02:00
parent e4094e1aa1
commit b57d00e9cd
10 changed files with 119 additions and 101 deletions

View file

@ -13,9 +13,53 @@ CORE is under heavy development and can be very unstable. Please do not use CORE
- Better documentation (docs4everything)
- Everything commented and explained
- Documentation page explaining what does what (for CORE noobies)
- Autoload singleton check removal
- ~~Autoload singleton check removal~~
- More wmgr functions
- Website
- ~~Silencing startup messages (info -> diag)~~
- ~~Remove autoload component~~
- ~~Fix syntax (set return types missing)~~
- Implement preprocessor placeholders
- Clipboard content
- CORE version
- Dark mode
- Dark mode support
- Delta
- Device hardware
- Device model
- CPU name
- CPU count
- FPS
- Game process
- Executable
- Command line options
- PID
- Debug build
- Language
- Operating system
- Operating system name
- Operating system version
- Distribution name
- Project name
- Project description
- Rendertime
- Window
- Size
- Size with decorations
- Position
- Title
- Mode
- Minimal size
- Maximal size
- Vsync status
- Screen
- Size
- ID (main window)
- Count
- DPI
- Orientation
- Refresh rate
- Scale
# Documentaton
[You can access the documentation by clicking this text](https://git.staropensource.de/StarOpenSource/core/wiki)[.](https://takeb1nzyto.space)
@ -43,4 +87,4 @@ Yes, in theory you can refactor your entire codebase and make a giant mess, but
Open the CORE manager, enter the path to your Godot project and click `Update`. Check [this documentation page](https://git.staropensource.de/StarOpenSource/core/wiki/Breaking-commits) for important commits that can cause breakage.
# Why is CORE not a addon?
CORE does not add one single functionality that can be easily removed, no, it is a whole framework providing many useful functions for your game and removing it would mean lots of refactoring and headaches for you. So no, no addon.
CORE does not add one single functionality that can be easily removed, no, it is a whole framework providing many useful functions for your game and removing it would mean lots of refactoring and headaches for you. So no, no addon.

21
core.gd
View file

@ -14,7 +14,6 @@ var config = null
var wmgr = null
var smgr = null
var resmgr = null
var autoload = null
var events = null
var splash = null
@ -28,20 +27,12 @@ func attach(type:String,component,do_setup:bool = true) -> void:
comp.name = type
comp.set_script(component)
match(type):
"config":
config = comp
"wmgr":
wmgr = comp
"smgr":
smgr = comp
"resmgr":
resmgr = comp
"autoload":
autoload = comp
"events":
events = comp
"splash":
splash = comp
"config": config = comp
"wmgr": wmgr = comp
"smgr": smgr = comp
"resmgr": resmgr = comp
"events": events = comp
"splash": splash = comp
_:
Logger.error("core","Failed attaching " + type + " to CORE: Invalid component")
comp.free()

View file

@ -9,15 +9,15 @@ extends Node
@onready
var engine_version = Engine.get_version_info()
func _ready():
func _ready() -> void:
print("coreinit -> Checking CORE requirements")
if engine_version["major"] != 4:
print("coreinit -> CORE only supports Godot 4.x.x. Please upgrade/downgrade your Godot Project to Godot 4.")
print("coreinit -> CORE only supports Godot 4. Please upgrade/downgrade your Godot Project to Godot 4.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(141)
return
if engine_version["minor"] != 0:
print("coreinit -> CORE only supports Godot 4.0.x. Please upgrade/downgrade your Godot Project to Godot 4.0.")
if engine_version["minor"] != 0 and engine_version["minor"] != 1:
print("coreinit -> CORE only supports Godot 4.0 and 4.1. Please upgrade/downgrade your Godot Project to Godot 4.0 or 4.1.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(142)
return
@ -36,17 +36,6 @@ func _ready():
await get_tree().create_timer(0.1).timeout
get_tree().quit(145)
return
if get_tree().root.get_children().size() != 3:
print("coreinit -> CORE only supports projects without autoload singletons (excluding CORE). Please remove them from your project settings and register them using core.autoloader in your init script.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(146)
return
for i in get_tree().root.get_children():
if i.name != "coreinit" and i.name != "Logger" and i.name != "Preprocessor":
print("coreinit -> CORE only supports projects without autoload singletons (excluding CORE). Please remove them from your project settings and register them using core.autoloader in your init script.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(147)
return
print("coreinit -> Constructing coreloader")
var coreloader = Control.new()
coreloader.name = "coreloader"

View file

@ -8,50 +8,47 @@ extends Node
func _ready() -> void:
await get_tree().create_timer(1.5).timeout
Logger.info("coreloader","Starting initialization")
Logger.info("coreloader","Loading configuration file")
Logger.diag("coreloader","Starting initialization")
Logger.diag("coreloader","Loading configuration file")
var scr_config = ResourceLoader.load("res://CORE/config.gd")
Logger.info("coreloader","Preloading core scripts")
Logger.diag("coreloader","Preloading core scripts")
var scr_core = ResourceLoader.load("res://CORE/core.gd")
var scr_wmgr = ResourceLoader.load("res://CORE/wmgr.gd")
var scr_smgr = ResourceLoader.load("res://CORE/smgr.gd")
var scr_resmgr = ResourceLoader.load("res://CORE/resmgr.gd")
var scr_autoload = ResourceLoader.load("res://CORE/autoload.gd")
var scr_events = ResourceLoader.load("res://CORE/events.gd")
var scr_splash = ResourceLoader.load("res://CORE/splash.tscn").instantiate()
Logger.info("coreloader","Constructing CORE")
Logger.diag("coreloader","Constructing CORE")
var core = Control.new()
core.name = "core"
core.script = scr_core
Logger.info("coreloader","Attaching CORE to /root/")
Logger.diag("coreloader","Attaching CORE to /root/")
get_tree().root.add_child(core)
Logger.info("coreloader","Attaching configuration file to CORE")
Logger.diag("coreloader","Attaching configuration file to CORE")
core.attach("config",scr_config)
Logger.info("coreloader","Attaching wmgr to CORE")
Logger.diag("coreloader","Attaching wmgr to CORE")
core.attach("wmgr",scr_wmgr)
Logger.info("coreloader","Attaching smgr to CORE")
Logger.diag("coreloader","Attaching smgr to CORE")
core.attach("smgr",scr_smgr)
Logger.info("coreloader","Attaching resmgr to CORE")
Logger.diag("coreloader","Attaching resmgr to CORE")
core.attach("resmgr",scr_resmgr)
Logger.info("coreloader","Attaching autoload to CORE")
core.attach("autoload",scr_autoload)
Logger.info("coreloader","Attaching events to CORE")
Logger.diag("coreloader","Attaching events to CORE")
core.attach("events",scr_events)
Logger.info("coreloader","Attaching splash to CORE")
Logger.diag("coreloader","Attaching splash to CORE")
core.attach("splash",scr_splash,false)
Logger.info("coreloader","Locking CORE")
Logger.diag("coreloader","Locking CORE")
core.lock()
Logger.info("coreloader","Waiting for CORE to fully initialize")
Logger.diag("coreloader","Waiting for CORE to fully initialize")
while !core.readylized:
await get_tree().create_timer(1).timeout
Logger.info("coreloader","CORE has been initialized and is ready.")
Logger.info("coreloader","Preloading project init script")
Logger.diag("coreloader","CORE has been initialized and is ready.")
Logger.diag("coreloader","Preloading project init script")
var initscr = ResourceLoader.load(core.config.core_startscript)
Logger.info("coreloader","Constructing project init script")
Logger.diag("coreloader","Constructing project init script")
var initscr_obj = Control.new()
initscr_obj.name = "ProjectInitScript"
initscr_obj.set_script(initscr)
Logger.info("coreloader","Adding project init script to /root/")
Logger.diag("coreloader","Adding project init script to /root/")
get_tree().root.add_child(initscr_obj)
Logger.info("coreloader","Removing coreloader")
Logger.diag("coreloader","Removing coreloader")
queue_free()

View file

@ -6,11 +6,10 @@
# Licensed under GNU GPLv3
extends RichTextLabel
var log_first = true
var log_prefix = ""
var log_suffix = ""
func _ready():
func _ready() -> void:
# Enable recieving of log messages
Logger.connect("logevent",Callable(self,"logevent"))
# Disable VScrollBar functionality & visibility
@ -24,7 +23,7 @@ func _ready():
# Make RichTextLabel ignore all mouse events (to disable scrolling)
mouse_filter = Control.MOUSE_FILTER_IGNORE
func _process(_delta):
func _process(_delta) -> void:
var windowsize = DisplayServer.window_get_size()
$".".size = windowsize
get_parent().size = windowsize
@ -32,11 +31,7 @@ func _process(_delta):
func logevent(_type:String,_script:String,_message:String,logcomp:String) -> void:
# Appends log to RichTextLabel
if log_first:
log_first = false
text = text + log_prefix + logcomp + log_suffix
else:
text = text + "\n" + log_prefix + logcomp + log_suffix
text = text + "\n" + log_prefix + logcomp + log_suffix
func rmconnect() -> void:
# Disables recieving of log messages

View file

@ -26,7 +26,7 @@ func _ready() -> void:
print("logger -> Preprocessor is not loaded. Shutting application down...")
get_tree().quit(1)
await get_tree().create_timer(1).timeout
info("Logger","Logger is ready.")
diag("Logger","Logger is ready.")
func diag(script:String,message:String,preproc:bool = false) -> void:
if enable and enable_diag:

View file

@ -48,23 +48,23 @@ func _ready() -> void:
await get_tree().create_timer(0.05).timeout
do_tests(false)
if enabled:
logger.info("Preprocessor","Preprocessor ready.",false)
logger.diag("Preprocessor","Preprocessor ready.",false)
else:
logger.info("Preprocessor","Preprocessor disabled.",false)
logger.diag("Preprocessor","Preprocessor disabled.",false)
# Performs tests on all Preprocessor features to help catch bugs while debugging.
# Recommended to leave enabled because log output might look weird if the a faulty commit is installed.
# Use tests_executed to check if the tests have been executed, use tests_log for the test log and
# read tests_success if you want the number of successful tests.
func do_tests(ignore_flag:bool = false) -> void:
logger.info("Preprocessor","Testing preprocessor...",false)
logger.diag("Preprocessor","Testing preprocessor...",false)
# If tests are disaled and ignore_flag is false return
if !tests_enabled and !ignore_flag:
logger.info("Preprocessor","Testing failed: Tests are disabled.",false)
logger.diag("Preprocessor","Testing failed: Tests are disabled.",false)
return
# If the Preprocessor is not enabled return
if !enabled:
logger.info("Preprocessor","Testing failed: Preprocessor is disabled.",false)
logger.diag("Preprocessor","Testing failed: Preprocessor is disabled.",false)
return
# Expected test resulsts
var tests_newlines = "test_prefix_Line 1.\n _Line 2.\n _Line 3."
@ -161,14 +161,14 @@ func do_tests(ignore_flag:bool = false) -> void:
# Checks if all tests were successful. If not disable the Preprocessor and print log.
if tests_success == 12:
enabled = true
logger.info("Preprocessor","Testing complete: All preprocessor features are working as intended.",false)
logger.diag("Preprocessor","Testing complete: All preprocessor features are working as intended.",false)
if tests_level == 2:
logger.info("Preprocessor","Log:\n" + tests_log)
logger.diag("Preprocessor","Log:\n" + tests_log)
else:
enabled = false
logger.info("Preprocessor","Testing failed: Preprocessor is malfunctioning and is now disabled.",false)
logger.error("Preprocessor","Testing failed: Preprocessor is malfunctioning and is now disabled.",false)
if tests_level >= 1:
logger.info("Preprocessor","Log:\n" + tests_log)
logger.error("Preprocessor","Log:\n" + tests_log)
# Processes <nl> tags
func _newline(msg:String,prefix:String,pre_msg:String,post_msg:String,exclusion_filter:Array) -> String:

View file

@ -37,6 +37,7 @@ func unloadbatch(batch:Array) -> void:
for i in batch:
unloadres(i)
# No set return type here as it can return literally everything.
func getres(resname:String):
if !resources.has(resname):
return null

51
smgr.gd
View file

@ -19,7 +19,7 @@ var ccr_debug = null
var ccr_debug_names = []
func add_game(resname:String) -> bool:
Logger.info("smgr","Adding game scene")
Logger.diag("smgr","Adding game scene")
if ccr_game_inuse:
Logger.error("smgr","Failed adding game scene: Only one game scene is allowed")
return false
@ -29,21 +29,21 @@ func add_game(resname:String) -> bool:
return false
ccr_game.add_child(res.instantiate())
ccr_game_inuse = true
Logger.info("smgr","Added game scene")
Logger.diag("smgr","Added game scene")
return true
func remove_game() -> bool:
Logger.info("smgr","Removing game scene")
Logger.diag("smgr","Removing game scene")
if !ccr_game_inuse:
Logger.error("smgr","Failed removing game scene: No game scene is active")
return false
ccr_game.remove_child(ccr_game.get_child(0))
ccr_game_inuse = false
Logger.info("smgr","Removed game scene")
Logger.diag("smgr","Removed game scene")
return true
func add_menu(resname:String) -> bool:
Logger.info("smgr","Adding menu scene \"" + resname + "\"")
Logger.diag("smgr","Adding menu scene \"" + resname + "\"")
if ccr_menu_names.has(resname):
Logger.error("smgr","Failed adding menu scene: Menu scene with name \"" + resname + "\" already exists")
return false
@ -53,11 +53,11 @@ func add_menu(resname:String) -> bool:
return false
ccr_menu.add_child(res.instantiate())
ccr_menu_names.append(resname)
Logger.info("smgr","Added menu scene \"" + resname + "\"")
Logger.diag("smgr","Added menu scene \"" + resname + "\"")
return true
func remove_menu(scene_name:String) -> bool:
Logger.info("smgr","Removing menu scene \"" + scene_name + "\"")
Logger.diag("smgr","Removing menu scene \"" + scene_name + "\"")
if !ccr_menu_names.has(scene_name):
Logger.error("smgr","Failed removing menu scene: Menu scene with name \"" + scene_name + "\" does not exist")
return false
@ -66,10 +66,11 @@ func remove_menu(scene_name:String) -> bool:
ccr_menu.remove_child(i)
break
ccr_menu_names.erase(scene_name)
Logger.diag("smgr","Removed menu scene \"" + scene_name + "\"")
return true
func add_cutscene(resname:String) -> bool:
Logger.info("smgr","Adding cutscene scene")
Logger.diag("smgr","Adding cutscene scene")
if ccr_cutscene_inuse:
Logger.error("smgr","Failed adding cutscene scene: Only one cutscene scene is allowed")
return false
@ -79,21 +80,21 @@ func add_cutscene(resname:String) -> bool:
return false
ccr_cutscene.add_child(res.instantiate())
ccr_cutscene_inuse = true
Logger.info("smgr","Added cutscene scene")
Logger.diag("smgr","Added cutscene scene")
return true
func remove_cutscene() -> bool:
Logger.info("smgr","Removing cutscene scene")
Logger.diag("smgr","Removing cutscene scene")
if !ccr_cutscene_inuse:
Logger.error("smgr","Failed removing cutscene scene: No cutscene scene is active")
return false
ccr_cutscene.remove_child(ccr_cutscene.get_child(0))
ccr_cutscene_inuse = false
Logger.info("smgr","Removed cutscene scene")
Logger.diag("smgr","Removed cutscene scene")
return true
func add_debug(resname:String) -> bool:
Logger.info("smgr","Adding debug scene \"" + resname + "\"")
Logger.diag("smgr","Adding debug scene \"" + resname + "\"")
if ccr_debug_names.has(resname):
Logger.error("smgr","Failed adding debug scene: Debug scene with name \"" + resname + "\" already exists")
return false
@ -103,11 +104,11 @@ func add_debug(resname:String) -> bool:
return false
ccr_debug.add_child(res.instantiate())
ccr_debug_names.append(resname)
Logger.info("smgr","Added debug scene \"" + resname + "\"")
Logger.diag("smgr","Added debug scene \"" + resname + "\"")
return true
func remove_debug(scene_name:String) -> bool:
Logger.info("smgr","Removing debug scene \"" + scene_name + "\"")
Logger.diag("smgr","Removing debug scene \"" + scene_name + "\"")
if !ccr_menu_names.has(scene_name):
Logger.error("smgr","Failed removing debug scene: Debug scene with name \"" + scene_name + "\" does not exist")
return false
@ -116,43 +117,43 @@ func remove_debug(scene_name:String) -> bool:
ccr_debug.remove_child(i)
break
ccr_debug_names.erase(scene_name)
Logger.diag("smgr","Removed debug scene \"" + scene_name + "\"")
return true
func _ready() -> void:
Logger.info("smgr","Constructing CORE Scene Root (CCR)")
Logger.diag("smgr","Constructing CORE Scene Root (CCR)")
ccr = Control.new()
ccr.name = "ccr"
Logger.info("smgr","Adding CCR to /root/")
Logger.diag("smgr","Adding CCR to /root/")
get_tree().root.add_child(ccr)
Logger.info("smgr","Migrating COREBackground to CCR")
Logger.diag("smgr","Migrating COREBackground to CCR")
var corebg = get_tree().current_scene
Logger.info("smgr","Reconstructing COREBackground to CCR")
Logger.diag("smgr","Reconstructing COREBackground to CCR")
var corebg_log = corebg.get_node(NodePath("Background/Log")).text
corebg.get_node(NodePath("Background/Log")).rmconnect()
get_tree().current_scene.queue_free()
var corebg_new = ResourceLoader.load("res://CORE/background.tscn").instantiate()
ccr.add_child(corebg_new)
corebg_new.get_node(NodePath("Background/Log")).text = corebg_log
corebg_new.get_node(NodePath("Background/Log")).log_first = false
Logger.info("smgr","COREBackground migration complete.")
Logger.info("smgr","Adding overlays")
Logger.diag("smgr","COREBackground migration complete.")
Logger.diag("smgr","Adding overlays")
add_overlays()
core.setready()
func add_overlays() -> void:
Logger.info("smgr","Adding game overlay")
Logger.diag("smgr","Adding game overlay")
ccr_game = Control.new()
ccr_game.name = "GameOverlay"
ccr.add_child(ccr_game)
Logger.info("smgr","Adding menu overlay")
Logger.diag("smgr","Adding menu overlay")
ccr_menu = Control.new()
ccr_menu.name = "MenuOverlay"
ccr.add_child(ccr_menu)
Logger.info("smgr","Adding cutscene overlay")
Logger.diag("smgr","Adding cutscene overlay")
ccr_cutscene = Control.new()
ccr_cutscene.name = "CutsceneOverlay"
ccr.add_child(ccr_cutscene)
Logger.info("smgr","Adding debug overlay")
Logger.diag("smgr","Adding debug overlay")
ccr_debug = Control.new()
ccr_debug.name = "DebugOverlay"
ccr.add_child(ccr_debug)

10
wmgr.gd
View file

@ -23,20 +23,20 @@ func _process(deltap) -> void:
delta = deltap
func set_size(x:int,y:int) -> void:
Logger.info("wmgr","Applying new window size (" + str(x) + "x" + str(y) + ")")
Logger.diag("wmgr","Applying new window size (" + str(x) + "x" + str(y) + ")")
DisplayServer.window_set_size(Vector2i(x,y))
func set_position(x:int,y:int) -> void:
Logger.info("wmgr","Applying new window position (X" + str(x) + " Y" + str(y) + ")")
Logger.diag("wmgr","Applying new window position (X" + str(x) + " Y" + str(y) + ")")
DisplayServer.window_set_position(Vector2i(x,y))
func set_title(title:String) -> void:
Logger.info("wmgr","Applying new window title (" + title + ")")
Logger.diag("wmgr","Applying new window title (" + title + ")")
DisplayServer.window_set_title(title)
window_title = title
func set_mode(mode:String) -> bool:
Logger.info("wmgr","Applying new window mode (" + mode + ")")
Logger.diag("wmgr","Applying new window mode (" + mode + ")")
match(mode):
"WINDOWED": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
"MINIMIZED": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED)
@ -81,7 +81,7 @@ func get_delta() -> float:
return delta
func _ready() -> void:
Logger.info("wmgr","Configuring window")
Logger.diag("wmgr","Configuring window")
DisplayServer.window_set_size(Vector2i(window_size_x,window_size_y))
DisplayServer.window_set_min_size(Vector2i(960,540))
DisplayServer.window_set_title(window_title)