Reviewed-on: StarOpenSource/core#1 Rewrote CORE and improved the startup process and startup time significantly. The documentation has been beefed up too and is now much better. Existing projects may need major refactoring however. Co-authored-by: JeremyStarTM <jeremystartm@staropensource.de> Co-committed-by: JeremyStarTM <jeremystartm@staropensource.de>
71 lines
2.7 KiB
GDScript
71 lines
2.7 KiB
GDScript
######################################
|
|
# THE CORE FRAMEWORK #
|
|
# MADE BY THE STAROPENSOURCE PROJECT #
|
|
# AND CONTRIBUTERS (THANK YOU!) #
|
|
# #
|
|
# COPYRIGHT 2023 THE STAROPENSOURCE #
|
|
# PROJECT AND CONTRIBUTERS #
|
|
# #
|
|
# LICENSED UNDER THE GNU GENERAL #
|
|
# PUBLIC LICENSE VERSION 3 (ONLY) #
|
|
######################################
|
|
extends Node
|
|
|
|
# CORE modules
|
|
var core: Node = null
|
|
var misc: Node = null
|
|
|
|
# Important nodes
|
|
@onready
|
|
var display: RichTextLabel = get_node("Display")
|
|
|
|
# Config
|
|
var config_enabled: bool = false
|
|
var config_fps: bool = false
|
|
var config_delta: bool = false
|
|
var config_rendertime: bool = false
|
|
var config_memory: bool = false
|
|
|
|
# Check if enabled
|
|
func _process(_delta) -> void:
|
|
if config_enabled:
|
|
update_display()
|
|
display.visible = true
|
|
else:
|
|
display.visible = false
|
|
|
|
# Updates the display with useful information
|
|
func update_display():
|
|
var displaytext: String = ""
|
|
var displaysize: int = 17
|
|
# Get memory information
|
|
var info_memory: Dictionary = OS.get_memory_info()
|
|
if config_memory:
|
|
info_memory.merge({"peak":OS.get_static_memory_peak_usage(),"percent":float(OS.get_static_memory_usage())/info_memory["physical"]*100,"used":OS.get_static_memory_usage()})
|
|
|
|
# If fps is enabled, add the fps counter
|
|
if config_fps:
|
|
displaysize = displaysize+17*1
|
|
displaytext = displaytext + "\nFPS: " + str(snappedf(misc.get_fps(false),0.01))
|
|
# If delta is enabled, add the delta counter
|
|
if config_delta:
|
|
displaysize = displaysize+17*1
|
|
displaytext = displaytext + "\nDelta: " + str(misc.get_delta())
|
|
# If rendertime is enabled, add the rendertime counter
|
|
if config_rendertime:
|
|
displaysize = displaysize+17*1
|
|
displaytext = displaytext + "\nRendertime: " + str(misc.get_rendertime())
|
|
# If memory is enabled, display memory information
|
|
if config_memory:
|
|
displaysize = displaysize+17*2
|
|
displaytext = displaytext + "\nMemory (Available|Used|Stack): " + str(misc.byte_to_mib(info_memory["available"],true)) + " MiB|" + str(misc.byte_to_mib(info_memory["used"],true)) + " MiB|" + str(misc.byte_to_mib(info_memory["stack"],true)) + " MiB"
|
|
displaytext = displaytext + "\nMemory (Physical|Peak|%): " + str(misc.byte_to_mib(info_memory["physical"],true)) + " MiB|" + str(misc.byte_to_mib(info_memory["peak"],true)) + " MiB|" + str(snappedf(info_memory["percent"],0.001)) + "%"
|
|
|
|
# Add CORE version and (if enabled) a dev mode notice
|
|
if core.development_mode:
|
|
displaytext = "CORE " + core.version["full"] + " [color=yellow](development mode)[/color]" + displaytext
|
|
else:
|
|
displaytext = "CORE " + core.version["full"] + displaytext
|
|
# Update display
|
|
display.text = displaytext
|
|
display.size = Vector2i(540,displaysize)
|