JeremyStarTM
ab5b3ade52
- Rewrote mkdevprj/rmdevprj in Makefile - Add MOAM modloader - Add core.exception() - Add protection mode - Rewrote module initialization - Add experimental markdown parser - Many more very small changes
173 lines
6 KiB
GDScript
173 lines
6 KiB
GDScript
# core.gd
|
|
# CORE Holder
|
|
#
|
|
# This file is part of StarOpenSource CORE (SOSCORE)
|
|
# Made by the StarOpenSource Project and Contributers
|
|
# Licensed under GNU GPLv3
|
|
extends Node
|
|
|
|
const version = "source 0"
|
|
var protection_mode = false
|
|
var locked = false
|
|
var readycount = 0
|
|
var readylized = false # Fun Fact: "ready" is a signal from "Node" and I (JeremyStarTM) just added "lized" from "initialized" to it to avoid a error thrown by Godot
|
|
var config = null
|
|
var wmgr = null
|
|
var smgr = null
|
|
var resmgr = null
|
|
var events = null
|
|
var splash = null
|
|
var moam = null
|
|
var mkdown = null
|
|
enum Errors {UNKNOWN}
|
|
enum Responsibilities {UNKNOWN}
|
|
|
|
func attach(type:String,module,do_setup:bool = true) -> void:
|
|
if protection_mode: return
|
|
if locked:
|
|
return
|
|
Logger.diag("core","Attaching " + type + " to CORE")
|
|
var mod = module
|
|
if do_setup:
|
|
mod = Control.new()
|
|
mod.name = type
|
|
mod.set_script(module)
|
|
match(type):
|
|
"config": config = mod
|
|
"wmgr": wmgr = mod
|
|
"smgr": smgr = mod
|
|
"resmgr": resmgr = mod
|
|
"events": events = mod
|
|
"splash": splash = mod
|
|
"moam": moam = mod
|
|
"mkdown": mkdown = mod
|
|
_:
|
|
exception("core","Attaching \"" + type + "\" failed as it is not a valid module")
|
|
mod.free()
|
|
return
|
|
add_child(mod)
|
|
Logger.diag("core","Attached " + type + " successfully")
|
|
|
|
func setready() -> void:
|
|
if protection_mode: return
|
|
readycount = readycount+1
|
|
if readycount == 7:
|
|
readylized = true
|
|
|
|
func lock() -> void:
|
|
if protection_mode: return
|
|
locked = true
|
|
Logger.diag("core","CORE is now locked. No new attachments can be added.")
|
|
|
|
func welcome() -> void:
|
|
if protection_mode: return
|
|
Logger.info("core","CORE (" + version + ") welcomes you!<nl>It seems like everything is working :)")
|
|
|
|
func exception(script:String,error:String):
|
|
protection_mode = true
|
|
var exc_message = """
|
|
[color=red]################################
|
|
EXCEPTION! EXCEPTION! EXCEPTION!
|
|
|
|
The CORE Framework experienced a critical error in runtime.
|
|
Please report this crash to the CORE Framework repository (with
|
|
the full log file). You can submit a crash report at:
|
|
https://git.staropensource.de/StarOpenSource/core/issues/new
|
|
|
|
CORE INFORMATION
|
|
version = "%version%"
|
|
readylized = %readylized%
|
|
readycount = %readycount%
|
|
locked = %locked%
|
|
preprocessor_enabled = %preprocessor_enabled%
|
|
preprocessor_tests = %preprocessor_tests%
|
|
preprocessor_tests_executed = %preprocessor_tests_executed%
|
|
preprocessor_tests_success = %preprocessor_tests_success%
|
|
logger_enabled = %logger_enabled%
|
|
logger_diag = %logger_diag%
|
|
|
|
OPERATING SYSTEM
|
|
timezone = %timezone%
|
|
time_utc = "%time_utc%"
|
|
time_unix = %time_unix%
|
|
date = "%date%"
|
|
locale = "%locale%"
|
|
lang = "%lang%"
|
|
name = "%name%"
|
|
distro = "%distro%"
|
|
version = "%version_os%"
|
|
memory = %memory%
|
|
memory_peak = %memory_peak%
|
|
memory_usage = %memory_usage%
|
|
processor_count = %processor_count%
|
|
processor_name = "%processor_name%"
|
|
video_adapter = %video_adapter%
|
|
rendering_api = "%rendering_api%"
|
|
|
|
APPLICATION
|
|
cmdline = %cmdline%
|
|
permissions = %permissions%
|
|
debug_build = %debug_build%
|
|
|
|
ERROR INFORMATION
|
|
script = "%script%"
|
|
error = "%error%"
|
|
|
|
STACKTRACE
|
|
%stacktrace%
|
|
|
|
EXCEPTION! EXCEPTION! EXCEPTION!
|
|
################################
|
|
"""
|
|
|
|
exc_message = exc_message.replace("%version%",version)
|
|
exc_message = exc_message.replace("%readylized%",str(readylized))
|
|
exc_message = exc_message.replace("%readycount%",str(readycount))
|
|
exc_message = exc_message.replace("%locked%",str(locked))
|
|
exc_message = exc_message.replace("%preprocessor_enabled%",str(Preprocessor.enabled))
|
|
exc_message = exc_message.replace("%preprocessor_tests%",str(Preprocessor.tests_enabled))
|
|
exc_message = exc_message.replace("%preprocessor_tests_executed%",str(Preprocessor.tests_executed))
|
|
exc_message = exc_message.replace("%preprocessor_tests_success%",str(Preprocessor.tests_success))
|
|
exc_message = exc_message.replace("%logger_enabled%",str(Logger.enable))
|
|
exc_message = exc_message.replace("%logger_diag%",str(Logger.enable_diag))
|
|
|
|
exc_message = exc_message.replace("%timezone%",str(Time.get_time_zone_from_system()))
|
|
exc_message = exc_message.replace("%time_utc%",Time.get_time_string_from_system(true))
|
|
exc_message = exc_message.replace("%time_unix%",str(Time.get_unix_time_from_datetime_string(Time.get_time_string_from_system(true))))
|
|
exc_message = exc_message.replace("%date%",Time.get_date_string_from_system(true))
|
|
exc_message = exc_message.replace("%locale%",OS.get_locale())
|
|
exc_message = exc_message.replace("%lang%",OS.get_locale_language())
|
|
exc_message = exc_message.replace("%name%",OS.get_name())
|
|
exc_message = exc_message.replace("%distro%",OS.get_distribution_name())
|
|
exc_message = exc_message.replace("%version_os%",OS.get_version())
|
|
exc_message = exc_message.replace("%memory%",str(OS.get_memory_info()))
|
|
exc_message = exc_message.replace("%memory_peak%",str(OS.get_static_memory_peak_usage()))
|
|
exc_message = exc_message.replace("%memory_usage%",str(OS.get_static_memory_usage()))
|
|
exc_message = exc_message.replace("%processor_count%",str(OS.get_processor_count()))
|
|
exc_message = exc_message.replace("%processor_name%",OS.get_processor_name())
|
|
exc_message = exc_message.replace("%video_adapter%",str(OS.get_video_adapter_driver_info()))
|
|
exc_message = exc_message.replace("%rendering_api%",RenderingServer.get_video_adapter_api_version())
|
|
|
|
exc_message = exc_message.replace("%cmdline%",str(OS.get_cmdline_args()))
|
|
exc_message = exc_message.replace("%permissions%",str(OS.get_granted_permissions()))
|
|
exc_message = exc_message.replace("%debug_build%",str(OS.is_debug_build()))
|
|
|
|
exc_message = exc_message.replace("%script%",script)
|
|
exc_message = exc_message.replace("%error%",error)
|
|
exc_message = exc_message.replace("%stacktrace%",str(get_stack()))
|
|
|
|
print_rich(exc_message)
|
|
await get_tree().create_timer(0.25).timeout
|
|
get_tree().quit(255)
|
|
|
|
func error(module:String,respo:Responsibilities,error:Errors,error_info:Dictionary = {}) -> Dictionary:
|
|
var error_text = ""
|
|
match(respo):
|
|
Responsibilities["UNKNOWN"]:
|
|
pass
|
|
match(error):
|
|
Errors["UNKNOWN"]:
|
|
error_text = ""
|
|
_:
|
|
exception("core","Failed generating error: Invalid error \"" + str(error) + "\"")
|
|
return {}
|