Skip to content

Commit 64bc195

Browse files
authored
Merge pull request #22 from defold/use-new-property-options-api
Use new propertyoptions API
2 parents 44de4be + 341d4ec commit 64bc195

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

defold-simpledata/src/comp_simple_data.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ namespace dmSimpleData
139139
SimpleDataComponent* component = GetComponentFromIndex(world, *params.m_UserData);
140140
dmGameSystemDDF::SimpleDataDesc* ddf = component->m_Resource->m_DDF;
141141

142+
int32_t value_index = 0;
143+
bool has_key = dmGameObject::GetPropertyOptionsIndex(params.m_Options, 0, &value_index) != dmGameObject::PROPERTY_RESULT_OK;
144+
142145
#define HANDLE_PROP(NAME, VALUE) \
143146
if (params.m_PropertyId == NAME) \
144147
{ \
@@ -149,14 +152,14 @@ namespace dmSimpleData
149152
#define HANDLE_ARRAY_PROP(NAME, VALUE) \
150153
if (params.m_PropertyId == NAME) \
151154
{ \
152-
if (params.m_Options.m_HasKey) \
155+
if (has_key) \
153156
return dmGameObject::PROPERTY_RESULT_INVALID_INDEX; \
154-
if (params.m_Options.m_Index < 0 || params.m_Options.m_Index >= (VALUE).m_Count) \
157+
if (value_index < 0 || value_index >= (VALUE).m_Count) \
155158
{ \
156-
dmLogError("Index %u is out of bounds. Array %s only has %u elements.", params.m_Options.m_Index, dmHashReverseSafe64(params.m_PropertyId), (VALUE).m_Count); \
159+
dmLogError("Index %u is out of bounds. Array %s only has %u elements.", value_index, dmHashReverseSafe64(params.m_PropertyId), (VALUE).m_Count); \
157160
return dmGameObject::PROPERTY_RESULT_INVALID_INDEX; \
158161
} \
159-
float value = (VALUE).m_Data[params.m_Options.m_Index]; \
162+
float value = (VALUE).m_Data[value_index]; \
160163
out_value.m_Variant = dmGameObject::PropertyVar(value); \
161164
return dmGameObject::PROPERTY_RESULT_OK; \
162165
}

game.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ title = extension-simpledata
1616

1717
[library]
1818
include_dirs = defold-simpledata
19+
defold_min_version = 1.12.2
1920

2021
[input]
2122
game_binding = /builtins/input/all.input_bindingc

0 commit comments

Comments
 (0)