utopia-rise/godot-kotlin-native

EntryGenerator DefaultValues (1): Support for primitive Types & Enums

chippmann opened this issue · 0 comments

Implement default value support for primitiveTypes (expect array which are considered primitive in this case as well).

This includes the following:

  • Int
  • Long
  • Float
  • Double
  • String
  • Boolean
  • Enums

The user would have to write the following:

@RegisterProperty
var int = 100

@RegisterProperty
var long = 100L

@RegisterProperty
var float = 1.0f

@RegisterProperty
var double = 2.0

@RegisterProperty
var str = "hello"

@RegisterProperty
var bool = true

@RegisterProperty
var enum = TestEnum.ENUM1

Implementation hints:

  • Files that need to be changed: PropertyDefaultValueProvider and PropertyHintTypeMapper
  • Provide proper error messages (with Expcetions for now. MessageCollector will be implemented later)
  • Default values need to be wrapped in a Variant
  • A value type hint needs to be supplied at registration time
  • Registration should look like:
property("nameOfProperty", TestingClass::propertyReference, STRING /*This is the püroperty type*/, Variant("defaultValue") /*This is the default value*/, true /**visible in editor/, DISABLED /*RPCMode*/, GODOT_PROPERTY_HINT_GLOBAL_DIR /*hint type*/, "" /*hint string*/)