This commit is contained in:
2026-09-10 07:47:15 -04:00
parent 1f555ed3e4
commit 1c4d0ecbfe
39 changed files with 1499 additions and 2357 deletions
+108
View File
@@ -0,0 +1,108 @@
@tool
extends EditorPlugin
const SINGLETON_NAME = &"Console"
##FIXME: These should be maintained in one place.
const CONSOLE_THEME : String = &"console/theme"
const CONSOLE_SCALE : String = &"console/scale"
const CONSOLE_HEIGHT : String = &"console/height"
const CONSOLE_COLOR_WARNING : String = &"console/color_warning"
const CONSOLE_COLOR_ERROR : String = &"console/color_error"
const CONSOLE_COLOR_INFO : String = &"console/color_info"
const CONSOLE_COLOR_LITERAL : String = &"console/color_literal"
const CONSOLE_TABSTOP : String = &"console/tabstop"
const CONSOLE_CANVAS_LAYER : String = &"console/canvas_layer"
##FIXME: This is here because project settings do no return the default value naturally
##This should be fixed in 4.5
const color_dictionary : Dictionary[String, Color] = {
CONSOLE_COLOR_ERROR: Color.LIGHT_CORAL,
CONSOLE_COLOR_INFO: Color.LIGHT_BLUE,
CONSOLE_COLOR_LITERAL: Color.PALE_GREEN,
CONSOLE_COLOR_WARNING: Color.LIGHT_GOLDENROD
}
func add_setting(setting_name: String, property_info: Dictionary, default: Variant) -> void:
if not ProjectSettings.has_setting(setting_name):
ProjectSettings.set_setting(setting_name, default)
ProjectSettings.add_property_info(property_info)
ProjectSettings.set_initial_value(setting_name, default)
ProjectSettings.set_as_basic(setting_name, true)
func _setup_project_settings() -> void:
## Configure Console Theme
add_setting(CONSOLE_THEME, {
"name": CONSOLE_THEME,
"type": TYPE_STRING,
"hint": PROPERTY_HINT_FILE,
"hint_string": "*.tres",
}, "")
## Configure Console Scale
add_setting(CONSOLE_SCALE, {
"name": CONSOLE_SCALE,
"type": TYPE_FLOAT,
"hint": PROPERTY_HINT_RANGE,
"hint_string": "0,10,0.1,or_greater"
}, 1.0)
## Configure Console Height
add_setting(CONSOLE_HEIGHT, {
"name": CONSOLE_HEIGHT,
"type": TYPE_FLOAT,
"hint": PROPERTY_HINT_RANGE,
"hint_string": "0,1,0.1"
}, 0.5)
## Configure Tab Spaces
add_setting(CONSOLE_TABSTOP, {
"name": CONSOLE_TABSTOP,
"type": TYPE_INT,
"hint": PROPERTY_HINT_RANGE,
"hint_string": "0,8,1,or_greater"
},4)
## Configure Canvas Layer
add_setting(CONSOLE_CANVAS_LAYER, {
"name": CONSOLE_CANVAS_LAYER,
"type": TYPE_INT,
}, 3)
#Configure Colors
add_setting(CONSOLE_COLOR_ERROR, {
"name": CONSOLE_COLOR_ERROR,
"type": TYPE_COLOR,
"hint": PROPERTY_HINT_COLOR_NO_ALPHA,
}, color_dictionary[CONSOLE_COLOR_ERROR])
add_setting(CONSOLE_COLOR_INFO, {
"name": CONSOLE_COLOR_INFO,
"type": TYPE_COLOR,
"hint": PROPERTY_HINT_COLOR_NO_ALPHA,
}, color_dictionary[CONSOLE_COLOR_INFO])
add_setting(CONSOLE_COLOR_WARNING, {
"name": CONSOLE_COLOR_WARNING,
"type": TYPE_COLOR,
"hint": PROPERTY_HINT_COLOR_NO_ALPHA,
}, color_dictionary[CONSOLE_COLOR_WARNING])
add_setting(CONSOLE_COLOR_LITERAL, {
"name": CONSOLE_COLOR_LITERAL,
"type": TYPE_COLOR,
"hint": PROPERTY_HINT_COLOR_NO_ALPHA
}, color_dictionary[CONSOLE_COLOR_LITERAL])
ProjectSettings.save()
func _enable_plugin() -> void:
add_autoload_singleton(SINGLETON_NAME, "res://addons/console/console.gd")
_setup_project_settings()
print("Console plugin enabled.")
func _disable_plugin() -> void:
remove_autoload_singleton(SINGLETON_NAME)
print("Console plugin disabled.")