Skip to content

Commit b15518d

Browse files
init
0 parents  commit b15518d

32 files changed

Lines changed: 2005 additions & 0 deletions

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Normalize EOL for all files that Git considers text files.
2+
* text=auto eol=lf

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Godot 4+ specific ignores
2+
.godot/
3+
/android/

DataConfig.gd

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Config for Data
2+
static var config: Dictionary[String, Variant] = {
3+
"custom_type_to_string_method": custom_type_to_string,
4+
"get_object_name_signal_method": get_object_name_changed_signal,
5+
}
6+
7+
8+
## Converts a custom data type to a string, with a human readable name
9+
@warning_ignore("unused_parameter")
10+
static func custom_type_to_string(p_variant: String, p_orignal_type: Data.Type) -> Variant:
11+
## return a String to override default convertion
12+
# return "Value"
13+
14+
## else return false to use default convertion
15+
return false
16+
17+
18+
## Returns the signal emitted when the name of an object is changed
19+
static func get_object_name_changed_signal(p_module: SettingsModule) -> Variant:
20+
var object: Variant = p_module.get_getter().call()
21+
22+
## return Signal() if the object type is invalid, or has no name signal
23+
if typeof(object) != TYPE_OBJECT or not is_instance_valid(object):
24+
return Signal()
25+
26+
## check object type and return correct signal
27+
#if object is Node:
28+
#return (object as Node).renamed
29+
30+
## else return false to use default
31+
return false

DataConfig.gd.uid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://chaisuh8pwhmd

icon.svg

Lines changed: 1 addition & 0 deletions
Loading

icon.svg.import

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://dnvs74pchcocw"
6+
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://icon.svg"
14+
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/uastc_level=0
22+
compress/rdo_quality_loss=0.0
23+
compress/hdr_compression=1
24+
compress/normal_map=0
25+
compress/channel_pack=0
26+
mipmaps/generate=false
27+
mipmaps/limit=-1
28+
roughness/mode=0
29+
roughness/src_normal=""
30+
process/channel_remap/red=0
31+
process/channel_remap/green=1
32+
process/channel_remap/blue=2
33+
process/channel_remap/alpha=3
34+
process/fix_alpha_border=true
35+
process/premult_alpha=false
36+
process/normal_map_invert_y=false
37+
process/hdr_as_srgb=false
38+
process/hdr_clamp_exposure=false
39+
process/size_limit=0
40+
detect_3d/compress_to=1
41+
svg/scale=1.0
42+
editor/scale_with_editor_scale=false
43+
editor/convert_colors_with_editor_theme=false

project.godot

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; Engine configuration file.
2+
; It's best edited using the editor UI and not directly,
3+
; since the parameters that go here are not all obvious.
4+
;
5+
; Format:
6+
; [section] ; section goes between []
7+
; param=value ; assign values to parameters
8+
9+
config_version=5
10+
11+
[application]
12+
13+
config/name="Utils"
14+
config/features=PackedStringArray("4.5", "GL Compatibility")
15+
config/icon="res://icon.svg"
16+
17+
[rendering]
18+
19+
renderer/rendering_method="gl_compatibility"
20+
renderer/rendering_method.mobile="gl_compatibility"

static/Data.gd

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Copyright (c) 2026 Liam Sherwin. All rights reserved.
2+
# This file is part of the Spectrum Lighting Engine, licensed under the GPL v3.0 or later.
3+
# See the LICENSE file for details.
4+
5+
class_name Data extends Object
6+
## Class to manage custom data types
7+
8+
9+
## Enum for Type
10+
enum Type {
11+
NULL, ## Represents no value (null / None)
12+
STRING, ## A standard text string
13+
BOOL, ## A true/false boolean value
14+
INT, ## A 64-bit integer number
15+
FLOAT, ## A floating-point number
16+
ARRAY, ## A dynamic array of values
17+
DICTIONARY, ## A key/value map (hash table)
18+
VECTOR2, ## A 2D vector (x, y) with floats
19+
VECTOR2I, ## A 2D vector (x, y) with integers
20+
RECT2, ## A 2D rectangle defined by position and size (floats)
21+
RECT2I, ## A 2D rectangle defined by position and size (integers)
22+
VECTOR3, ## A 3D vector (x, y, z) with floats
23+
VECTOR3I, ## A 3D vector (x, y, z) with integers
24+
VECTOR4, ## A 4D vector (x, y, z, w) with floats
25+
VECTOR4I, ## A 4D vector (x, y, z, w) with integers
26+
COLOR, ## A color with red, green, blue, and alpha channels
27+
OBJECT, ## A reference to any Godot Object (Node, Resource, etc.)
28+
CALLABLE, ## A callable function reference
29+
SIGNAL, ## A signal reference (connectable event)
30+
ENUM, ## An enumerator
31+
BITFLAGS, ## Bit Flags
32+
NAME, ## A symbolic name or identifier
33+
IP, ## An IP address
34+
INPUTEVENT, ## An InputEvent
35+
SETTINGSMANAGER, ## A SettingsManager
36+
PACKEDSCENE, ## A PackedScene object
37+
ACTION, ## An Action that can be triggred
38+
}
39+
40+
41+
## Map custom Type to Godot Variant.Type
42+
static var custom_type_map: Dictionary[Type, Variant.Type] = {
43+
Type.NULL: TYPE_NIL,
44+
Type.STRING: TYPE_STRING,
45+
Type.BOOL: TYPE_BOOL,
46+
Type.INT: TYPE_INT,
47+
Type.FLOAT: TYPE_FLOAT,
48+
Type.ARRAY: TYPE_ARRAY,
49+
Type.DICTIONARY: TYPE_DICTIONARY,
50+
Type.VECTOR2: TYPE_VECTOR2,
51+
Type.VECTOR2I: TYPE_VECTOR2,
52+
Type.RECT2: TYPE_RECT2,
53+
Type.RECT2I: TYPE_RECT2,
54+
Type.VECTOR3: TYPE_VECTOR3,
55+
Type.VECTOR3I: TYPE_VECTOR3,
56+
Type.VECTOR4: TYPE_VECTOR4,
57+
Type.VECTOR4I: TYPE_VECTOR4,
58+
Type.COLOR: TYPE_COLOR,
59+
Type.OBJECT: TYPE_OBJECT,
60+
Type.CALLABLE: TYPE_CALLABLE,
61+
Type.SIGNAL: TYPE_SIGNAL,
62+
Type.ENUM: TYPE_INT,
63+
Type.BITFLAGS: TYPE_INT,
64+
Type.NAME: TYPE_STRING,
65+
Type.IP: TYPE_STRING,
66+
Type.INPUTEVENT: TYPE_OBJECT,
67+
Type.SETTINGSMANAGER: TYPE_OBJECT,
68+
Type.PACKEDSCENE: TYPE_OBJECT,
69+
Type.ACTION: TYPE_NIL,
70+
}
71+
72+
73+
## User config
74+
static var _config: Dictionary[String, Variant]
75+
76+
## User config method to convert a custom type into a string
77+
static var _custom_type_to_string_method: Callable
78+
79+
## User config method to get a name changed signal from an object
80+
static var _get_object_name_signal_method: Callable
81+
82+
83+
## static init
84+
static func _static_init() -> void:
85+
var script: Variant = load("res://DataConfig.gd")
86+
87+
if script is GDScript and script.get("config") is Dictionary:
88+
_config = script.get("config")
89+
90+
_custom_type_to_string_method = type_convert(_config.get("custom_type_to_string_method"), TYPE_CALLABLE)
91+
_get_object_name_signal_method = type_convert(_config.get("get_object_name_signal_method"), TYPE_CALLABLE)
92+
93+
94+
## Returns true if the 2 given types have a matching Variant.Type base
95+
static func do_types_match_base(p_type_one: Type, p_type_two: Type) -> bool:
96+
var type_one_base: Variant.Type = custom_type_map[p_type_one]
97+
var type_two_base: Variant.Type = custom_type_map[p_type_two]
98+
99+
return type_one_base == type_two_base
100+
101+
102+
## Converts a custom data type to a string, with a human readable name
103+
static func custom_type_to_string(p_variant: String, p_orignal_type: Type) -> String:
104+
if _custom_type_to_string_method.is_valid():
105+
var result: Variant = _custom_type_to_string_method.call(p_variant, p_orignal_type)
106+
107+
if typeof(result) == TYPE_STRING:
108+
return result
109+
110+
return type_convert(p_variant, TYPE_STRING)
111+
112+
113+
## Returns the signal emitted when the name of an object is changed
114+
static func get_object_name_changed_signal(p_module: SettingsModule) -> Signal:
115+
if _get_object_name_signal_method.is_valid():
116+
var result: Variant = _get_object_name_signal_method.call(p_module)
117+
118+
if typeof(result) == TYPE_SIGNAL:
119+
return result
120+
121+
var object: Variant = p_module.get_getter().call()
122+
if typeof(object) != TYPE_OBJECT or not is_instance_valid(object):
123+
return Signal()
124+
125+
if object is Node:
126+
return (object as Node).renamed
127+
128+
return Signal()

static/Data.gd.uid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://b7ytsd12k7w5h

0 commit comments

Comments
 (0)