aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Autoload/Argument/ArgumentOption.gd
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-06-04 02:17:28 +0200
committer GitHub <noreply@github.com>2023-06-04 02:17:28 +0200
commit3236f51d700674aee6ee6572109ffb3d5fa5fed2 (patch)
treeb898150a8a45e7c0d814459e7f12f39429acefeb /game/src/Game/Autoload/Argument/ArgumentOption.gd
parent73e29d02e48739aba5ca5db1b9575c67e795400f (diff)
parentb98166b28c47cccff731d30959b8250fb27ff408 (diff)
Merge pull request #130 from Spartan322/organize/godot-project
Diffstat (limited to 'game/src/Game/Autoload/Argument/ArgumentOption.gd')
-rw-r--r--game/src/Game/Autoload/Argument/ArgumentOption.gd60
1 files changed, 60 insertions, 0 deletions
diff --git a/game/src/Game/Autoload/Argument/ArgumentOption.gd b/game/src/Game/Autoload/Argument/ArgumentOption.gd
new file mode 100644
index 0000000..f14cef0
--- /dev/null
+++ b/game/src/Game/Autoload/Argument/ArgumentOption.gd
@@ -0,0 +1,60 @@
+@tool
+class_name ArgumentOption
+extends Resource
+
+@export var name : StringName
+@export var aliases : Array[StringName] = []
+@export var type : Variant.Type :
+ get: return type
+ set(v):
+ type = v
+ match v:
+ TYPE_BOOL: default_value = false
+ TYPE_INT: default_value = 0
+ TYPE_FLOAT: default_value = 0.0
+ TYPE_STRING: default_value = ""
+ TYPE_STRING_NAME: default_value = &""
+ TYPE_COLOR: default_value = Color()
+ _: default_value = null
+ notify_property_list_changed()
+var default_value
+@export var description : String
+
+func _init(_name = "", _type = TYPE_NIL, _description = "", default = null):
+ name = _name
+ type = _type
+ if default != null and typeof(default) == type:
+ default_value = default
+ description = _description
+
+func add_alias(alias : StringName) -> ArgumentOption:
+ aliases.append(alias)
+ return self
+
+func get_type_string() -> StringName:
+ match type:
+ TYPE_NIL: return "null"
+ TYPE_BOOL: return "boolean"
+ TYPE_INT: return "integer"
+ TYPE_FLOAT: return "float"
+ TYPE_STRING, TYPE_STRING_NAME: return "string"
+ TYPE_COLOR: return "color"
+ return "<invalid type>"
+
+func _get(property):
+ if property == "default_value": return default_value
+
+func _set(property, value):
+ if property == "default_value":
+ default_value = value
+ return true
+
+func _get_property_list():
+ var properties := []
+
+ properties.append({
+ "name": "default_value",
+ "type": type
+ })
+
+ return properties