Adds missing data

This commit is contained in:
Michel 2025-02-03 19:17:20 +01:00
parent e6391d9fdd
commit 53cdcc3433
620 changed files with 47293 additions and 151 deletions

View file

@ -0,0 +1,27 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
class_name Collision
enum Type { NONE, STATIC, KINEMATIC, RIGID }

View file

@ -0,0 +1,31 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends RefCounted
class_name CyclopsLogger
enum LogLevel { ERROR, WARNING, INFO }
func log(message:String, level:LogLevel = LogLevel.ERROR):
print(message)

View file

@ -0,0 +1,228 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends Resource
class_name CyclopsSettings
@export var definition_map:Dictionary
@export var lookup:Dictionary
var float_regex_strn:String = "[+-]?([0-9]*[.])?[0-9]+"
var regex_int = RegEx.create_from_string("[0-9]+")
var regex_float = RegEx.create_from_string(float_regex_strn)
var regex_color = RegEx.create_from_string("color\\(" + float_regex_strn + "\\)")
class SettingDef:
var name:String
var default_value
var type:Variant.Type
var hint:PropertyHint
var hint_string:String
func value_to_text(value, type:int)->String:
match type:
TYPE_BOOL:
return "true" if value else "false"
TYPE_COLOR:
return JSON.stringify([value.r, value.g, value.b, value.a])
TYPE_FLOAT:
return str(value)
TYPE_INT:
return str(value)
TYPE_NODE_PATH:
return str(value)
TYPE_STRING:
return "\"" + value + "\""
TYPE_TRANSFORM2D:
var a:Transform2D = value
return JSON.stringify({"x": [a.x.x, a.x.y],
"y": [a.y.x, a.y.y],
"o": [a.origin.x, a.origin.y],
})
TYPE_TRANSFORM3D:
var a:Transform3D = value
return JSON.stringify({"x": [a.basis.x.x, a.basis.x.y, a.basis.x.z],
"y": [a.basis.y.x, a.basis.y.y, a.basis.y.z],
"z": [a.basis.z.x, a.basis.z.y, a.basis.z.z],
"o": [a.origin.x, a.origin.y, a.origin.z],
})
TYPE_VECTOR2:
var a:Vector2 = value
return JSON.stringify([a.x, a.y])
TYPE_VECTOR3:
var a:Vector3 = value
return JSON.stringify([a.x, a.y, a.z])
TYPE_VECTOR4:
var a:Vector4 = value
return JSON.stringify([a.x, a.y, a.z, a.w])
_:
return ""
func text_to_value(text:String, type:int):
text = text.lstrip(" ").rstrip(" ")
match type:
TYPE_BOOL:
return text.to_lower() == "true"
TYPE_COLOR:
var a:Array = JSON.parse_string(text)
return Color(a[0], a[1], a[2], a[3])
TYPE_FLOAT:
return float(text)
TYPE_INT:
return int(text)
TYPE_NODE_PATH:
return NodePath(text)
TYPE_STRING:
#Trim starting and ending quotes
return text.substr(1, text.length() - 2)
TYPE_TRANSFORM2D:
var a:Dictionary = JSON.parse_string(text)
return Transform2D(Vector2(a["x"][0], a["x"][1]),
Vector2(a["y"][0], a["y"][1]),
Vector2(a["o"][0], a["o"][1]))
TYPE_TRANSFORM3D:
var a:Dictionary = JSON.parse_string(text)
return Transform3D(Vector3(a["x"][0], a["x"][1], a["x"][2]),
Vector3(a["y"][0], a["y"][1], a["y"][2]),
Vector3(a["z"][0], a["z"][1], a["z"][2]),
Vector3(a["o"][0], a["o"][1], a["o"][2]))
TYPE_VECTOR2:
var a:Array = JSON.parse_string(text)
return Vector2(a[0], a[1])
TYPE_VECTOR3:
var a:Array = JSON.parse_string(text)
return Vector3(a[0], a[1], a[2])
TYPE_VECTOR4:
var a:Array = JSON.parse_string(text)
return Vector4(a[0], a[1], a[2], a[3])
_:
return null
func save_to_file(path:String):
var keys:Array = lookup.keys()
keys.sort()
var f:FileAccess = FileAccess.open(path, FileAccess.WRITE)
if !f:
return
for key in keys:
var def:SettingDef = definition_map[key]
f.store_line("%s=%s" % [key, value_to_text(lookup[key], def.type)])
f.close()
func load_from_file(path:String):
lookup.clear()
var f:FileAccess = FileAccess.open(path, FileAccess.READ)
while !f.eof_reached():
var line:String = f.get_line()
line = line.lstrip(" ")
if line.is_empty() || line[0] == "#":
continue
var idx = line.find("=")
if idx == -1:
continue
var name:String = line.substr(0, idx)
var value_text:String = line.substr(idx + 1)
if !definition_map.has(name):
continue
var def:SettingDef = definition_map[name]
set_property(name, text_to_value(value_text, def.type))
func add_setting(name:String, default_value, type:Variant.Type, hint:PropertyHint = PROPERTY_HINT_NONE, hint_string:String = ""):
var def:SettingDef = SettingDef.new()
def.name = name
def.default_value = default_value
def.type = type
def.hint = hint
def.hint_string = hint_string
definition_map[name] = def
func set_property(name:String, value):
if !definition_map.has(name):
push_error("Unknown setting name " + name)
return
var def:SettingDef = definition_map[name]
var var_type:int = typeof(value)
if var_type != def.type:
push_error("Settings error: Bad setting type. Needed %s but got %s" % [def.type, var_type])
return
lookup[name] = value
func has_property(name:String)->bool:
return definition_map.has(name)
func get_property(name:String):
#print("lookup ", name)
if !definition_map.has(name):
push_error("Unknown setting name " + name)
return null
#print("is defined ", name)
if lookup.has(name):
return lookup[name]
#print("returning default ", name)
var def:SettingDef = definition_map[name]
return def.default_value

View file

@ -0,0 +1,28 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
class_name DisplayMode
enum Type { WIRE, MESH, MATERIAL }

View file

@ -0,0 +1,71 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
class_name GeneralUtil
static func find_unique_name(parent:Node, base_name:String)->String:
#Check if numeric suffix already exists
var regex = RegEx.new()
regex.compile("(\\d+)")
var match_res:RegExMatch = regex.search(base_name)
var name_idx:int = 0
if match_res:
var suffix:String = match_res.get_string(1)
name_idx = int(suffix) + 1
base_name = base_name.substr(0, base_name.length() - suffix.length())
#Search for free index
while true:
var name = base_name + str(name_idx)
if !parent.find_child(name, false):
return name
name_idx += 1
return ""
static func calc_resource_name(res:Resource)->String:
var name:String = res.resource_name
if name.is_empty():
name = res.resource_path.get_file()
var idx:int = name.rfind(".")
if idx != -1:
name = name.substr(0, idx)
return name
static func format_planes_string(planes:Array[Plane])->String:
var result:String = ""
for p in planes:
result = result + "(%s, %s, %s, %s)," % [p.x, p.y, p.z, p.d]
return result
static func dump_properties(obj):
for prop in obj.get_property_list():
var name:String = prop["name"]
print ("%s: %s" % [name, str(obj.get(name))])

View file

@ -0,0 +1,28 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
class_name GeometryComponentType
enum Type { OBJECT, VERTEX, FACE, FACE_VERTEX }

View file

@ -0,0 +1,37 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
class_name Selection
enum Type { REPLACE, ADD, SUBTRACT, TOGGLE }
static func choose_type(shift_pressed:bool, ctrl_pressed)->Type:
if !shift_pressed and !ctrl_pressed:
return Type.REPLACE
elif shift_pressed and !ctrl_pressed:
return Type.TOGGLE
elif !shift_pressed and ctrl_pressed:
return Type.ADD
else:
return Type.SUBTRACT

View file

@ -0,0 +1,37 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
class_name SelectionList
enum Type { REPLACE, RANGE, TOGGLE }
static func choose_type(shift_pressed:bool, ctrl_pressed)->Type:
if !shift_pressed and !ctrl_pressed:
return Type.REPLACE
elif shift_pressed and !ctrl_pressed:
return Type.RANGE
elif !shift_pressed and ctrl_pressed:
return Type.TOGGLE
else:
return Type.REPLACE

View file

@ -0,0 +1,72 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
class_name SerialUtil
static func save_cache_vector3(value:Vector3)->Dictionary:
return {
"value": [value.x, value.y, value.z]
}
static func load_cache_vector3(cache:Dictionary, default_value:Vector3 = Vector3.ZERO)->Vector3:
if !cache:
return default_value
return Vector3(cache.value[0], cache.value[1], cache.value[2])
static func save_cache_color(value:Color)->Dictionary:
return {
"color": [value.r, value.g, value.b, value.a]
}
static func load_cache_color(cache:Dictionary, default_value:Color = Color.BLACK)->Color:
if !cache:
return default_value
return Color(cache.color[0], cache.color[1], cache.color[2], cache.color[3])
static func save_cache_transform_3d(t:Transform3D)->String:
return var_to_str(t)
#var dict:Dictionary = {
#"x": [t.basis.x.x, t.basis.x.y, t.basis.x.z],
#"y": [t.basis.y.x, t.basis.y.y, t.basis.y.z],
#"z": [t.basis.z.x, t.basis.z.y, t.basis.z.z],
#"o": [t.origin.x, t.origin.y, t.origin.z],
#}
#return JSON.stringify(dict)
static func load_cache_transform_3d(text:String, default_value:Transform3D = Transform3D.IDENTITY)->Transform3D:
if text.is_empty():
return default_value
return str_to_var(text)
#var cache:Dictionary = JSON.parse_string(text)
#var x:Vector3 = Vector3(cache.x[0], cache.x[1], cache.x[2])
#var y:Vector3 = Vector3(cache.y[0], cache.y[1], cache.y[2])
#var z:Vector3 = Vector3(cache.z[0], cache.z[1], cache.z[2])
#var o:Vector3 = Vector3(cache.o[0], cache.o[1], cache.o[2])
#
#return Transform3D(x, y, z, o)

View file

@ -0,0 +1,29 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
class_name TransformSpace
enum Type { GLOBAL, LOCAL, NORMAL, VIEW, PARENT }

View file

@ -0,0 +1,35 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends RefCounted
class_name TreeVisitor
static func visit(root:Node, callback:Callable):
visit_recursive(root, callback)
static func visit_recursive(node:Node, callback:Callable):
callback.call(node)
for child in node.get_children():
visit_recursive(child, callback)

View file

@ -0,0 +1,28 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
class_name UnitSystem
enum Type { NONE, METRIC, IMPERIAL }

View file

@ -0,0 +1,33 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends XMLNode
class_name XMLAttribute
@export var name:String
@export var value:String
func _init(name:String = "", value:String = ""):
self.name = name
self.value = value

View file

@ -0,0 +1,35 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends XMLNode
class_name XMLDocument
@export var root:XMLElement
func format_document(indent:String = "")->String:
return root.format_document_recursive("", indent) if root else ""
func format_document_recursive(cur_indent:String = "", indent_increment:String = "")->String:
assert(false, "Call to_string()")
return ""

View file

@ -0,0 +1,82 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends XMLNode
class_name XMLElement
@export var name:String
@export var attributes:Array[XMLAttribute]
@export var children:Array[XMLNode]
func _init(name:String = ""):
self.name = name
func format_document_recursive(cur_indent:String = "", indent_increment:String = " ")->String:
var result = cur_indent + "<" + name
for attr in attributes:
result += " " + attr.name + "=\"" + attr.value + "\""
if children.is_empty():
result += "/>"
else:
result += ">"
for child in children:
result += child.to_string_recursive(cur_indent + indent_increment, indent_increment)
result += "</" + name + ">"
return result
func add_child(node:XMLNode):
children.append(node)
func get_attribute(name:String)->XMLAttribute:
for attr in attributes:
if attr.name == name:
return attr
return null
func get_attribute_value(name:String, default_value:String = "")->String:
for attr in attributes:
if attr.name == name:
return attr.value
return default_value
func get_attribute_index(nane:String)->int:
for attr_idx in attributes.size():
if attributes[attr_idx].name == name:
return attr_idx
return -1
func set_attribute(name:String, value:String):
var idx = get_attribute_index(name)
if idx != -1:
attributes[idx].value = value
else:
attributes.append(XMLAttribute.new(name, value))
#func set_attribute_bool(name:String, value:bool):
#set_attribute(name, str(value))
#
#func set_attribute_int(name:String, value:int):
#set_attribute(name, str(value))

View file

@ -0,0 +1,29 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends Resource
class_name XMLNode
func format_document_recursive(cur_indent:String = "", indent_increment:String = " ")->String:
return ""

View file

@ -0,0 +1,31 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends XMLNode
class_name XMLText
@export var value:String
func format_document_recursive(cur_indent:String = "", indent_increment:String = " ")->String:
return value