diff --git a/core/src/datatypes/ref.cpp b/core/src/datatypes/ref.cpp index 20fc26d..21704ff 100644 --- a/core/src/datatypes/ref.cpp +++ b/core/src/datatypes/ref.cpp @@ -145,7 +145,7 @@ static int inst_index(lua_State* L) { // Read property std::optional meta = inst->GetPropertyMeta(key); if (meta) { - Variant value = inst->GetPropertyValue(key).expect(); + Variant value = inst->GetProperty(key).expect(); value.PushLuaValue(L); return 1; } @@ -181,7 +181,7 @@ static int inst_newindex(lua_State* L) { if (value.isError()) return luaL_error(L, "%s", value.errorMessage().value().c_str()); - inst->SetPropertyValue(key, value.expect()).expect(); + inst->SetProperty(key, value.expect()).expect(); return 0; } diff --git a/core/src/objects/base/instance.cpp b/core/src/objects/base/instance.cpp index b162b9f..fc1d2c8 100644 --- a/core/src/objects/base/instance.cpp +++ b/core/src/objects/base/instance.cpp @@ -182,12 +182,12 @@ void Instance::OnWorkspaceRemoved(std::shared_ptr oldWorkspace) { // Properties -result Instance::GetPropertyValue(std::string name) { +result Instance::GetProperty(std::string name) { name[0] = toupper(name[0]); // Ignore case of first character return InternalGetPropertyValue(name); } -fallible Instance::SetPropertyValue(std::string name, Variant value, bool sendUpdateEvent) { +fallible Instance::SetProperty(std::string name, Variant value, bool sendUpdateEvent) { name[0] = toupper(name[0]); // Ignore case of first character auto result = InternalSetPropertyValue(name, value); if (result.isSuccess() && sendUpdateEvent) { @@ -290,7 +290,7 @@ void Instance::Serialize(pugi::xml_node parent, RefStateSerialize state) { // Update std::shared_ptr properties using map above if (meta.type.descriptor == &InstanceRef::TYPE) { - std::weak_ptr refWeak = GetPropertyValue(name).expect("Declared property is missing").get(); + std::weak_ptr refWeak = GetProperty(name).expect("Declared property is missing").get(); if (refWeak.expired()) continue; auto ref = refWeak.lock(); @@ -306,7 +306,7 @@ void Instance::Serialize(pugi::xml_node parent, RefStateSerialize state) { state->refsAwaitingRemap[ref] = refs; } } else { - GetPropertyValue(name).expect("Declared property is missing").Serialize(propertyNode); + GetProperty(name).expect("Declared property is missing").Serialize(propertyNode); } } @@ -360,14 +360,14 @@ result, NoSuchInstance> Instance::Deserialize(pugi::xm if (remappedRef) { // If the instance has already been remapped, set the new value - object->SetPropertyValue(propertyName, InstanceRef(remappedRef)).expect(); + object->SetProperty(propertyName, InstanceRef(remappedRef)).expect(); } else { // Otheriise, queue this property to be updated later, and keep its current value auto& refs = state->refsAwaitingRemap[refId]; refs.push_back(std::make_pair(object, propertyName)); state->refsAwaitingRemap[refId] = refs; - object->SetPropertyValue(propertyName, InstanceRef()).expect(); + object->SetProperty(propertyName, InstanceRef()).expect(); } } else { auto valueResult = Variant::Deserialize(propertyNode, meta.type); @@ -376,7 +376,7 @@ result, NoSuchInstance> Instance::Deserialize(pugi::xm continue; } auto value = valueResult.expect(); - object->SetPropertyValue(propertyName, value).expect("Declared property was missing"); + object->SetProperty(propertyName, value).expect("Declared property was missing"); } } @@ -386,7 +386,7 @@ result, NoSuchInstance> Instance::Deserialize(pugi::xm // Remap queued properties for (std::pair, std::string> ref : state->refsAwaitingRemap[remappedId]) { - ref.first->SetPropertyValue(ref.second, InstanceRef(object)).expect(); + ref.first->SetProperty(ref.second, InstanceRef(object)).expect(); } state->refsAwaitingRemap[remappedId].clear(); @@ -460,7 +460,7 @@ std::optional> Instance::Clone(RefStateClone state) { // Update std::shared_ptr properties using map above if (meta.type.descriptor == &InstanceRef::TYPE) { - std::weak_ptr refWeak = GetPropertyValue(property).expect().get(); + std::weak_ptr refWeak = GetProperty(property).expect().get(); if (refWeak.expired()) continue; auto ref = refWeak.lock(); @@ -468,18 +468,18 @@ std::optional> Instance::Clone(RefStateClone state) { if (remappedRef) { // If the instance has already been remapped, set the new value - newInstance->SetPropertyValue(property, InstanceRef(remappedRef)).expect(); + newInstance->SetProperty(property, InstanceRef(remappedRef)).expect(); } else { // Otheriise, queue this property to be updated later, and keep its current value auto& refs = state->refsAwaitingRemap[ref]; refs.push_back(std::make_pair(newInstance, property)); state->refsAwaitingRemap[ref] = refs; - newInstance->SetPropertyValue(property, InstanceRef(ref)).expect(); + newInstance->SetProperty(property, InstanceRef(ref)).expect(); } } else { - Variant value = GetPropertyValue(property).expect(); - newInstance->SetPropertyValue(property, value).expect(); + Variant value = GetProperty(property).expect(); + newInstance->SetProperty(property, value).expect(); } } @@ -488,7 +488,7 @@ std::optional> Instance::Clone(RefStateClone state) { // Remap queued properties for (std::pair, std::string> ref : state->refsAwaitingRemap[shared_from_this()]) { - ref.first->SetPropertyValue(ref.second, InstanceRef(newInstance)).expect(); + ref.first->SetProperty(ref.second, InstanceRef(newInstance)).expect(); } state->refsAwaitingRemap[shared_from_this()].clear(); @@ -511,7 +511,7 @@ std::vector>> Instance::GetRefe PropertyMeta meta = GetPropertyMeta(property).expect(); if (meta.type.descriptor != &InstanceRef::TYPE) continue; - std::weak_ptr ref = GetPropertyValue(property).expect().get(); + std::weak_ptr ref = GetProperty(property).expect().get(); if (ref.expired()) continue; referenceProperties.push_back(std::make_pair(property, ref.lock())); } diff --git a/core/src/objects/base/instance.h b/core/src/objects/base/instance.h index 0efc218..7ae77fb 100644 --- a/core/src/objects/base/instance.h +++ b/core/src/objects/base/instance.h @@ -114,8 +114,8 @@ public: std::string GetFullName(); // Properties - result GetPropertyValue(std::string name); - fallible SetPropertyValue(std::string name, Variant value, bool sendUpdateEvent = true); + result GetProperty(std::string name); + fallible SetProperty(std::string name, Variant value, bool sendUpdateEvent = true); result GetPropertyMeta(std::string name); // Manually trigger the update of a property. Useful internally when setting properties directly void UpdateProperty(std::string name); diff --git a/core/src/objects/datamodel.cpp b/core/src/objects/datamodel.cpp index a0cf1f7..4c63ef9 100644 --- a/core/src/objects/datamodel.cpp +++ b/core/src/objects/datamodel.cpp @@ -133,7 +133,7 @@ std::shared_ptr DataModel::CloneModel() { // Update std::shared_ptr properties using map above if (meta.type.descriptor == &InstanceRef::TYPE) { - std::weak_ptr refWeak = GetPropertyValue(property).expect().get(); + std::weak_ptr refWeak = GetProperty(property).expect().get(); if (refWeak.expired()) continue; auto ref = refWeak.lock(); @@ -141,18 +141,18 @@ std::shared_ptr DataModel::CloneModel() { if (remappedRef) { // If the instance has already been remapped, set the new value - newModel->SetPropertyValue(property, InstanceRef(remappedRef)).expect(); + newModel->SetProperty(property, InstanceRef(remappedRef)).expect(); } else { // Otheriise, queue this property to be updated later, and keep its current value auto& refs = state->refsAwaitingRemap[ref]; refs.push_back(std::make_pair(newModel, property)); state->refsAwaitingRemap[ref] = refs; - newModel->SetPropertyValue(property, InstanceRef(ref)).expect(); + newModel->SetProperty(property, InstanceRef(ref)).expect(); } } else { - Variant value = GetPropertyValue(property).expect(); - newModel->SetPropertyValue(property, value).expect(); + Variant value = GetProperty(property).expect(); + newModel->SetProperty(property, value).expect(); } } @@ -161,7 +161,7 @@ std::shared_ptr DataModel::CloneModel() { // Remap queued properties for (std::pair, std::string> ref : state->refsAwaitingRemap[shared_from_this()]) { - ref.first->SetPropertyValue(ref.second, InstanceRef(newModel)).expect(); + ref.first->SetProperty(ref.second, InstanceRef(newModel)).expect(); } // Clone services diff --git a/editor/panes/propertiesview.cpp b/editor/panes/propertiesview.cpp index a8a1d02..fb0c823 100644 --- a/editor/panes/propertiesview.cpp +++ b/editor/panes/propertiesview.cpp @@ -55,7 +55,7 @@ public: std::string propertyName = !isComposite ? view->itemFromIndex(index)->data(0, Qt::DisplayRole).toString().toStdString() : view->itemFromIndex(index.parent())->data(0, Qt::DisplayRole).toString().toStdString(); PropertyMeta meta = inst->GetPropertyMeta(propertyName).expect(); - Variant currentValue = inst->GetPropertyValue(propertyName).expect(); + Variant currentValue = inst->GetProperty(propertyName).expect(); if (isComposite) { if (meta.type.descriptor == &Vector3::TYPE) { @@ -144,7 +144,7 @@ public: std::string propertyName = !index.parent().parent().isValid() ? view->itemFromIndex(index)->data(0, Qt::DisplayRole).toString().toStdString() : view->itemFromIndex(index.parent())->data(0, Qt::DisplayRole).toString().toStdString(); PropertyMeta meta = inst->GetPropertyMeta(propertyName).expect(); - Variant currentValue = inst->GetPropertyValue(propertyName).expect(); + Variant currentValue = inst->GetProperty(propertyName).expect(); if (isComposite) { if (meta.type.descriptor == &Vector3::TYPE) { @@ -211,12 +211,12 @@ public: QDoubleSpinBox* spinBox = dynamic_cast(editor); float value = spinBox->value(); - Vector3 prev = inst->GetPropertyValue(propertyName).expect().get(); + Vector3 prev = inst->GetProperty(propertyName).expect().get(); Vector3 newVector = componentName == "X" ? Vector3(value, prev.Y(), prev.Z()) : componentName == "Y" ? Vector3(prev.X(), value, prev.Z()) : componentName == "Z" ? Vector3(prev.X(), prev.Y(), value) : prev; - inst->SetPropertyValue(propertyName, newVector).expect(); + inst->SetProperty(propertyName, newVector).expect(); view->rebuildCompositeProperty(view->itemFromIndex(index.parent()), &Vector3::TYPE, newVector); return; } @@ -227,24 +227,24 @@ public: if (meta.type.descriptor == &FLOAT_TYPE) { QDoubleSpinBox* spinBox = dynamic_cast(editor); - inst->SetPropertyValue(propertyName, (float)spinBox->value()).expect(); + inst->SetProperty(propertyName, (float)spinBox->value()).expect(); model->setData(index, spinBox->value()); } else if (meta.type.descriptor == &INT_TYPE) { QSpinBox* spinBox = dynamic_cast(editor); - inst->SetPropertyValue(propertyName, (int)spinBox->value()).expect(); + inst->SetProperty(propertyName, (int)spinBox->value()).expect(); model->setData(index, spinBox->value()); } else if (meta.type.descriptor == &STRING_TYPE) { QLineEdit* lineEdit = dynamic_cast(editor); - inst->SetPropertyValue(propertyName, lineEdit->text().toStdString()).expect(); + inst->SetProperty(propertyName, lineEdit->text().toStdString()).expect(); model->setData(index, lineEdit->text()); } else if (meta.type.descriptor == &Color3::TYPE) { QColorDialog* colorDialog = dynamic_cast(editor); QColor color = colorDialog->currentColor(); Color3 color3(color.redF(), color.greenF(), color.blueF()); - inst->SetPropertyValue(propertyName, color3).expect(); + inst->SetProperty(propertyName, color3).expect(); model->setData(index, QString::fromStdString(color3.ToString()), Qt::DisplayRole); model->setData(index, color, Qt::DecorationRole); } else if (meta.type.descriptor == &EnumItem::TYPE) { @@ -252,7 +252,7 @@ public: std::vector siblingItems = meta.type.enum_->GetEnumItems(); EnumItem newItem = siblingItems[comboBox->currentIndex()]; - inst->SetPropertyValue(propertyName, newItem).expect("Failed to set enum value in properties pane"); + inst->SetProperty(propertyName, newItem).expect("Failed to set enum value in properties pane"); model->setData(index, QString::fromStdString(newItem.Name()), Qt::DisplayRole); } else if (meta.type.descriptor->fromString) { QLineEdit* lineEdit = dynamic_cast(editor); @@ -260,7 +260,7 @@ public: result parsedResult = meta.type.descriptor->fromString(lineEdit->text().toStdString(), meta.type); if (!parsedResult) return; Variant parsedValue = parsedResult.expect(); - inst->SetPropertyValue(propertyName, parsedValue).expect(); + inst->SetProperty(propertyName, parsedValue).expect(); model->setData(index, QString::fromStdString(parsedValue.ToString())); view->rebuildCompositeProperty(view->itemFromIndex(index), meta.type.descriptor, parsedValue); } @@ -342,7 +342,7 @@ void PropertiesView::setSelected(std::optional> instan for (std::string property : properties) { PropertyMeta meta = inst->GetPropertyMeta(property).expect(); - Variant currentValue = inst->GetPropertyValue(property).expect(); + Variant currentValue = inst->GetProperty(property).expect(); if (meta.type.descriptor == &CFrame::TYPE || meta.flags & PROP_HIDDEN) continue; @@ -401,7 +401,7 @@ void PropertiesView::propertyChanged(QTreeWidgetItem *item, int column) { PropertyMeta meta = inst->GetPropertyMeta(propertyName).expect(); if (meta.type.descriptor == &BOOL_TYPE) { - inst->SetPropertyValue(propertyName, item->checkState(1) == Qt::Checked).expect(); + inst->SetProperty(propertyName, item->checkState(1) == Qt::Checked).expect(); } } @@ -438,7 +438,7 @@ void PropertiesView::onPropertyUpdated(std::shared_ptr inst, std::stri // lastUpdateTime = std::chrono::steady_clock::now(); PropertyMeta meta = inst->GetPropertyMeta(property).expect(); - Variant currentValue = inst->GetPropertyValue(property).expect(); + Variant currentValue = inst->GetProperty(property).expect(); if (meta.type.descriptor == &CFrame::TYPE) return;