Skip to content

Commit

Permalink
added entity properties
Browse files Browse the repository at this point in the history
  • Loading branch information
rand0m-cloud committed Feb 1, 2020
1 parent 792d5ae commit 089f13e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func _run(context) -> Dictionary:
if entity_defintion_set.has(classname):
var entity_def_scene = load(entity_defintion_set[classname])
node = entity_def_scene.instance(PackedScene.GEN_EDIT_STATE_INSTANCE)
for property in entity_properties.keys():
print(property)
node.set(property, entity_properties[property])
is_child_scene = true
else:
node = Position3D.new()
Expand Down
2 changes: 1 addition & 1 deletion addons/qodot/src/nodes/qodot_map.gd
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export(String) var material_extension = '.tres'
export (SpatialMaterial) var default_material

# Entity defintions
export(Resource) var entity_definitions
export(QodotEntityDefinitionSet) var entity_definitions

# Threads
export(String) var threading = CATEGORY_STRING
Expand Down
29 changes: 29 additions & 0 deletions addons/qodot/src/resources/godot_entity_properties.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class_name QodotEntityProperties
extends Resource
tool

## Used to allow adding properties to exported definitions

enum PropertyType { IntegerProperty, StringProperty }
export (String) var name
export (PropertyType) var type = PropertyType.IntegerProperty
export (String) var short_description
export (String) var long_description
export (String) var default_value

func property_type_text() -> String:
match type:
PropertyType.IntegerProperty:
return "integer"
PropertyType.StringProperty:
return "string"
_:
return "impossible, only to please typechecker"
func get_properties_dictionary():
return {
"name": name,
"short_description": short_description,
"long_description": long_description,
"type_string": property_type_text(),
"default_value": default_value,
}
3 changes: 2 additions & 1 deletion addons/qodot/src/resources/qodot_entity_definition_set.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const base_text = """
#psuedo-button to export
export(bool) var export_file_button setget set_export_file_button
export(String, FILE, GLOBAL, "*.fgd") var target_export_file
export(Array, Resource) var entity_defintions
export(Array, QodotPointEntityDefinition) var entity_defintions


func set_export_file_button(new_export_file_button = true):
if new_export_file_button != export_file_button:
Expand Down
9 changes: 7 additions & 2 deletions addons/qodot/src/resources/qodot_point_entity_definition.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export var size_point_2 = Vector3(8, 8, 8)
# to the map
export(String, FILE, '*.tscn,*.scn') var scene_file

# the properties to be exported
export(Array, QodotEntityProperties) var entity_properties

func build_def_text() -> String:
var res = "@PointClass size(%s %s %s, %s %s %s) color(%s %s %s) = %s" % [int(size_point_1.x), int(size_point_1.y), int(size_point_1.z), int(size_point_2.x), int(size_point_2.y), int(size_point_2.z), color.r8, color.g8, color.b8, classname]
Expand All @@ -28,8 +30,11 @@ func build_def_text() -> String:
if normalized_description != "":
res += " : \"%s\"%s" % [normalized_description, QodotUtil.newline()]
res += "[" + QodotUtil.newline()
res += "\tangle(float) : \"0.0\"" + QodotUtil.newline()
#eventually custom properties would go here!
for property in entity_properties:
if(not (property is QodotEntityProperties)):
printerr("Property in Entity_Properties is not a QodotEntityProperties!")
continue
res += "\t{name}({type_string}) : \"{short_description}\" : {default_value} : \"{long_description}\"\n".format(property.get_properties_dictionary())
res += "]" + QodotUtil.newline()

return res
Expand Down

0 comments on commit 089f13e

Please sign in to comment.