diff --git a/Projects/Editor/Source/Editor/Components/Default/CDefaultEditor.cpp b/Projects/Editor/Source/Editor/Components/Default/CDefaultEditor.cpp index 9088f9fa5..9c2a9db39 100644 --- a/Projects/Editor/Source/Editor/Components/Default/CDefaultEditor.cpp +++ b/Projects/Editor/Source/Editor/Components/Default/CDefaultEditor.cpp @@ -363,15 +363,40 @@ namespace Skylicht } else if (valueProperty->getType() == EPropertyDataType::Object) { - // sub objects - CObjectSerializable* arrayObject = (CObjectSerializable*)valueProperty; - CSubject* subject = new CSubject(arrayObject); + CObjectSerializable* object = (CObjectSerializable*)valueProperty; + CSubject* subject = new CSubject(object); + // header GUI::CCollapsibleGroup* group = ui->addSubGroup(layout); group->getHeader()->setLabel(ui->getPrettyName(valueProperty->Name)); - GUI::CBoxLayout* layout = ui->createBoxLayout(group); - initDataGUI(arrayObject, layout, ui); + + if (object->isArray()) + { + CArraySerializable* arrayObject = (CArraySerializable*)object; + + if (arrayObject->OnCreateElement != nullptr) + { + // add input to add elements + CSubject* count = new CSubject(arrayObject->getElementCount()); + m_subjects.push_back(count); + + ui->addNumberTextBox(layout, L"Count", count); + + CObserver* observer = new CObserver(); + observer->Notify = [&, arrayObject, count, o = observer](ISubject* subject, IObserver* from) + { + if (from != o) + { + // updateData(); + } + }; + count->addObserver(observer, true); + } + } + + // Show child data + initDataGUI(object, layout, ui); m_subjects.push_back(subject); } diff --git a/Projects/Editor/Source/Editor/Space/Property/CSpaceProperty.cpp b/Projects/Editor/Source/Editor/Space/Property/CSpaceProperty.cpp index a72980a2c..1f416f0a6 100644 --- a/Projects/Editor/Source/Editor/Space/Property/CSpaceProperty.cpp +++ b/Projects/Editor/Source/Editor/Space/Property/CSpaceProperty.cpp @@ -594,6 +594,50 @@ namespace Skylicht boxLayout->endVertical(); } + void CSpaceProperty::addNumberTextBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject* value) + { + GUI::CLayout* layout = boxLayout->beginVertical(); + + GUI::CLabel* label = new GUI::CLabel(layout); + label->setPadding(GUI::SMargin(0.0f, 2.0, 0.0f, 0.0f)); + label->setString(name); + label->setTextAlignment(GUI::TextRight); + + GUI::CNumberInput* input = new GUI::CNumberInput(layout); + input->setNumberType(GUI::ENumberInputType::Integer); + input->alwayFocusTextbox(true); + + wchar_t text[32]; + swprintf(text, 32, L"%d", value->get()); + input->setString(text); + + CSpaceProperty::SGroup* group = getGroupByLayout(boxLayout); + if (group != NULL) + { + CObserver* onChange = new CObserver(); + onChange->Notify = [me = onChange, target = input](ISubject* subject, IObserver* from) + { + if (from != me) + { + CSubject* value = (CSubject*)subject; + target->setString(value->get()); + } + }; + + // when input text change + IObserver* observer = value->addObserver(onChange); + input->OnEnter = [value, input, observer](GUI::CBase* base) { + value->set(input->getValueInt()); + value->notify(observer); + }; + + // hold observer to release later + group->Observer.push_back(observer); + } + + boxLayout->endVertical(); + } + void CSpaceProperty::addCheckBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject* value) { GUI::CLayout* layout = boxLayout->beginVertical(); diff --git a/Projects/Editor/Source/Editor/Space/Property/CSpaceProperty.h b/Projects/Editor/Source/Editor/Space/Property/CSpaceProperty.h index b30833090..52210d556 100644 --- a/Projects/Editor/Source/Editor/Space/Property/CSpaceProperty.h +++ b/Projects/Editor/Source/Editor/Space/Property/CSpaceProperty.h @@ -105,6 +105,8 @@ namespace Skylicht void addTextBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject* value); + void addNumberTextBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject* value); + void addCheckBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject* value); void addComboBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject* value, const std::vector& listValue); diff --git a/Projects/Editor/Source/GUI/Controls/CNumberInput.cpp b/Projects/Editor/Source/GUI/Controls/CNumberInput.cpp index 8703f7e32..2c999f48e 100644 --- a/Projects/Editor/Source/GUI/Controls/CNumberInput.cpp +++ b/Projects/Editor/Source/GUI/Controls/CNumberInput.cpp @@ -41,6 +41,7 @@ namespace Skylicht m_mouseDownX(0.0f), m_mouseDownY(0.0f), m_focusTextbox(false), + m_alwayFocusTextbox(false), m_value(0.0f), m_stepValue(1.0f), m_mousePress(false), @@ -58,7 +59,7 @@ namespace Skylicht void CNumberInput::think() { - if (m_focusTextbox) + if (m_focusTextbox || m_alwayFocusTextbox) CTextBox::think(); else { @@ -84,6 +85,9 @@ namespace Skylicht { CTextBox::renderUnder(); + if (m_alwayFocusTextbox) + return; + if (m_drawTextbox && isHovered() && !m_focusTextbox) { CTheme* theme = CTheme::getTheme(); @@ -98,6 +102,15 @@ namespace Skylicht // disable default textbox focus } + void CNumberInput::alwayFocusTextbox(bool b) + { + m_alwayFocusTextbox = b; + if (b) + setCursor(ECursorType::Beam); + else + setCursor(ECursorType::SizeWE); + } + void CNumberInput::onTabableFocus() { CTextBox::onKeyboardFocus(); @@ -124,7 +137,22 @@ namespace Skylicht { m_mousePress = down; - if (m_focusTextbox == true) + if (m_alwayFocusTextbox) + { + if (down) + CTextBox::onKeyboardFocus(); + + CTextBox::onMouseClickLeft(x, y, down); + + if (down) + { + onSelectAll(this); + setCursor(ECursorType::Beam); + } + return; + } + + if (m_focusTextbox) { // default textbox function CTextBox::onMouseClickLeft(x, y, down); @@ -220,6 +248,8 @@ namespace Skylicht } else if (c == '\r') { + if (OnEnter != nullptr) + OnEnter(this); onLostKeyboardFocus(); return true; } diff --git a/Projects/Editor/Source/GUI/Controls/CNumberInput.h b/Projects/Editor/Source/GUI/Controls/CNumberInput.h index 1537c08b7..cea82a032 100644 --- a/Projects/Editor/Source/GUI/Controls/CNumberInput.h +++ b/Projects/Editor/Source/GUI/Controls/CNumberInput.h @@ -40,6 +40,7 @@ namespace Skylicht float m_cursorX; float m_cursorY; + bool m_alwayFocusTextbox; bool m_focusTextbox; float m_stepValue; @@ -100,6 +101,8 @@ namespace Skylicht m_numberType = type; } + void alwayFocusTextbox(bool b); + protected: void applyTextValue(); diff --git a/Projects/Editor/Source/ProjectSettings/CObjectLayer.cpp b/Projects/Editor/Source/ProjectSettings/CObjectLayer.cpp index 0c89f3cac..b2a105899 100644 --- a/Projects/Editor/Source/ProjectSettings/CObjectLayer.cpp +++ b/Projects/Editor/Source/ProjectSettings/CObjectLayer.cpp @@ -38,7 +38,7 @@ namespace Skylicht for (int i = 0; i < 16; i++) { sprintf(name, "%d", i); - addAutoRelease(new CStringProperty(this, name, "")); + autoRelease(new CStringProperty(this, name, "")); } setName(0, "Default"); diff --git a/Projects/Skylicht/Components/Source/SkyBox/CSkyBox.cpp b/Projects/Skylicht/Components/Source/SkyBox/CSkyBox.cpp index 4a90add76..4ae403f4c 100644 --- a/Projects/Skylicht/Components/Source/SkyBox/CSkyBox.cpp +++ b/Projects/Skylicht/Components/Source/SkyBox/CSkyBox.cpp @@ -72,9 +72,9 @@ namespace Skylicht std::vector textureExts = { "tga","png" }; - object->addAutoRelease(new CFilePathProperty(object, "texture", m_texture.c_str(), textureExts)); - object->addAutoRelease(new CColorProperty(object, "color", m_color)); - object->addAutoRelease(new CFloatProperty(object, "intensity", m_intensity, 0.0f, 3.0f)); + object->autoRelease(new CFilePathProperty(object, "texture", m_texture.c_str(), textureExts)); + object->autoRelease(new CColorProperty(object, "color", m_color)); + object->autoRelease(new CFloatProperty(object, "intensity", m_intensity, 0.0f, 3.0f)); return object; } diff --git a/Projects/Skylicht/Components/Source/SkyDome/CSkyDome.cpp b/Projects/Skylicht/Components/Source/SkyDome/CSkyDome.cpp index f19f73cb7..e000f1cee 100644 --- a/Projects/Skylicht/Components/Source/SkyDome/CSkyDome.cpp +++ b/Projects/Skylicht/Components/Source/SkyDome/CSkyDome.cpp @@ -74,9 +74,9 @@ namespace Skylicht std::vector textureExts = { "tga","png" }; - object->addAutoRelease(new CFilePathProperty(object, "texture", m_texture.c_str(), textureExts)); - object->addAutoRelease(new CColorProperty(object, "color", m_color)); - object->addAutoRelease(new CFloatProperty(object, "intensity", m_intensity, 0.0f, 3.0f)); + object->autoRelease(new CFilePathProperty(object, "texture", m_texture.c_str(), textureExts)); + object->autoRelease(new CColorProperty(object, "color", m_color)); + object->autoRelease(new CFloatProperty(object, "intensity", m_intensity, 0.0f, 3.0f)); return object; } diff --git a/Projects/Skylicht/Components/Source/SkySun/CSkySun.cpp b/Projects/Skylicht/Components/Source/SkySun/CSkySun.cpp index f5f7bf956..5fd5f7269 100644 --- a/Projects/Skylicht/Components/Source/SkySun/CSkySun.cpp +++ b/Projects/Skylicht/Components/Source/SkySun/CSkySun.cpp @@ -104,26 +104,26 @@ namespace Skylicht CFloatProperty* skyProperty = new CFloatProperty(object, "Intensity", m_skyIntensity, 0.0f); skyProperty->setUIHeader("Sky"); skyProperty->setUISpace(10.0f); - object->addAutoRelease(skyProperty); + object->autoRelease(skyProperty); CColorProperty* atmosphericProperty = new CColorProperty(object, "Atmospheric Color", m_atmosphericColor); atmosphericProperty->setUIHeader("Atmospheric"); - object->addAutoRelease(atmosphericProperty); - object->addAutoRelease(new CFloatProperty(object, "Atmospheric Intensity", m_atmosphericIntensity, 0.0f)); + object->autoRelease(atmosphericProperty); + object->autoRelease(new CFloatProperty(object, "Atmospheric Intensity", m_atmosphericIntensity, 0.0f)); CColorProperty* sunProperty = new CColorProperty(object, "Sun Color", m_sunColor); sunProperty->setUIHeader("Sun"); - object->addAutoRelease(sunProperty); - object->addAutoRelease(new CFloatProperty(object, "Sun Intensity", m_sunIntensity, 0.0f)); - object->addAutoRelease(new CFloatProperty(object, "Sun Size", m_sunSize, 1.0f, 5000.0f)); + object->autoRelease(sunProperty); + object->autoRelease(new CFloatProperty(object, "Sun Intensity", m_sunIntensity, 0.0f)); + object->autoRelease(new CFloatProperty(object, "Sun Size", m_sunSize, 1.0f, 5000.0f)); CColorProperty* glareProperty = new CColorProperty(object, "Glare1 Color", m_glare1Color); glareProperty->setUIHeader("Glare"); - object->addAutoRelease(glareProperty); - object->addAutoRelease(new CFloatProperty(object, "Glare1 Intensity", m_glare1Intensity, 0.0f)); + object->autoRelease(glareProperty); + object->autoRelease(new CFloatProperty(object, "Glare1 Intensity", m_glare1Intensity, 0.0f)); - object->addAutoRelease(new CColorProperty(object, "Glare2 Color", m_glare2Color)); - object->addAutoRelease(new CFloatProperty(object, "Glare2 Intensity", m_glare2Intensity, 0.0f)); + object->autoRelease(new CColorProperty(object, "Glare2 Color", m_glare2Color)); + object->autoRelease(new CFloatProperty(object, "Glare2 Intensity", m_glare2Intensity, 0.0f)); return object; } diff --git a/Projects/Skylicht/Engine/Source/Components/CComponentSystem.cpp b/Projects/Skylicht/Engine/Source/Components/CComponentSystem.cpp index 6e34c26fe..a64382ad2 100644 --- a/Projects/Skylicht/Engine/Source/Components/CComponentSystem.cpp +++ b/Projects/Skylicht/Engine/Source/Components/CComponentSystem.cpp @@ -85,7 +85,7 @@ namespace Skylicht CObjectSerializable* CComponentSystem::createSerializable() { CObjectSerializable* object = new CObjectSerializable(getTypeName().c_str()); - object->addAutoRelease(new CBoolProperty(object, "enable", isEnable())); + object->autoRelease(new CBoolProperty(object, "enable", isEnable())); return object; } diff --git a/Projects/Skylicht/Engine/Source/GameObject/CGameObject.cpp b/Projects/Skylicht/Engine/Source/GameObject/CGameObject.cpp index 4bca93f70..6cce14d11 100644 --- a/Projects/Skylicht/Engine/Source/GameObject/CGameObject.cpp +++ b/Projects/Skylicht/Engine/Source/GameObject/CGameObject.cpp @@ -387,16 +387,16 @@ namespace Skylicht CObjectSerializable* CGameObject::createSerializable() { CObjectSerializable* object = new CObjectSerializable(getTypeName().c_str()); - object->addAutoRelease(new CStringProperty(object, "id", getID().c_str())); - object->addAutoRelease(new CStringProperty(object, "name", getNameA())); - object->addAutoRelease(new CBoolProperty(object, "enable", isEnable())); - object->addAutoRelease(new CBoolProperty(object, "visible", isVisible())); - object->addAutoRelease(new CBoolProperty(object, "static", isStatic())); - object->addAutoRelease(new CUIntProperty(object, "culling", getCullingLayer())); + object->autoRelease(new CStringProperty(object, "id", getID().c_str())); + object->autoRelease(new CStringProperty(object, "name", getNameA())); + object->autoRelease(new CBoolProperty(object, "enable", isEnable())); + object->autoRelease(new CBoolProperty(object, "visible", isVisible())); + object->autoRelease(new CBoolProperty(object, "static", isStatic())); + object->autoRelease(new CUIntProperty(object, "culling", getCullingLayer())); CObjectSerializable* coms = new CObjectSerializable("Components"); object->addProperty(coms); - object->addAutoRelease(coms); + object->autoRelease(coms); size_t numComponents = m_components.size(); CComponentSystem** components = m_components.data(); @@ -412,7 +412,7 @@ namespace Skylicht if (data->Name != "CComponentSystem") { coms->addProperty(data); - coms->addAutoRelease(data); + coms->autoRelease(data); } else { diff --git a/Projects/Skylicht/Engine/Source/IndirectLighting/CIndirectLighting.cpp b/Projects/Skylicht/Engine/Source/IndirectLighting/CIndirectLighting.cpp index 26aedd700..bd8b8099c 100644 --- a/Projects/Skylicht/Engine/Source/IndirectLighting/CIndirectLighting.cpp +++ b/Projects/Skylicht/Engine/Source/IndirectLighting/CIndirectLighting.cpp @@ -121,10 +121,10 @@ namespace Skylicht enumType->addEnumString("Lightmap", EIndirectType::LightmapArray); enumType->addEnumString("Vertex Color", EIndirectType::VertexColor); enumType->addEnumString("SH9", EIndirectType::SH9); - object->addAutoRelease(enumType); + object->autoRelease(enumType); CArraySerializable* textureArray = new CArraySerializable("LMTextures", object); - object->addAutoRelease(textureArray); + object->autoRelease(textureArray); std::vector textureExts = { "tga","png" }; for (u32 i = 0, n = (u32)m_lightmapPaths.size(); i < n; i++) @@ -132,7 +132,7 @@ namespace Skylicht char name[43]; sprintf(name, "%d", i); - textureArray->addAutoRelease( + textureArray->autoRelease( new CFilePathProperty( textureArray, name, diff --git a/Projects/Skylicht/Engine/Source/LightProbes/CLightProbes.cpp b/Projects/Skylicht/Engine/Source/LightProbes/CLightProbes.cpp index 0a8c9c04a..943f8abab 100644 --- a/Projects/Skylicht/Engine/Source/LightProbes/CLightProbes.cpp +++ b/Projects/Skylicht/Engine/Source/LightProbes/CLightProbes.cpp @@ -78,13 +78,13 @@ namespace Skylicht CArraySerializable* probes = new CArraySerializable("Probes"); object->addProperty(probes); - object->addAutoRelease(probes); + object->autoRelease(probes); int numProbes = (int)m_entities.size(); for (int i = 0; i < numProbes; i++) { CProbeSerializable* probeData = new CProbeSerializable(probes); - probes->addAutoRelease(probeData); + probes->autoRelease(probeData); CWorldTransformData* world = (CWorldTransformData*)m_entities[i]->getDataByIndex(CWorldTransformData::DataTypeIndex); CLightProbeData* light = (CLightProbeData*)m_entities[i]->getDataByIndex(CLightProbeData::DataTypeIndex); diff --git a/Projects/Skylicht/Engine/Source/LightProbes/CProbeSerializable.cpp b/Projects/Skylicht/Engine/Source/LightProbes/CProbeSerializable.cpp index d5bfd3ce4..07c49743e 100644 --- a/Projects/Skylicht/Engine/Source/LightProbes/CProbeSerializable.cpp +++ b/Projects/Skylicht/Engine/Source/LightProbes/CProbeSerializable.cpp @@ -39,7 +39,7 @@ namespace Skylicht { sprintf(name, "sh%d", i); SH[i] = new CVector3Property(this, name); - addAutoRelease(SH[i]); + autoRelease(SH[i]); } } @@ -53,7 +53,7 @@ namespace Skylicht { sprintf(name, "sh%d", i); SH[i] = new CVector3Property(this, name); - addAutoRelease(SH[i]); + autoRelease(SH[i]); } } diff --git a/Projects/Skylicht/Engine/Source/Lighting/CLight.cpp b/Projects/Skylicht/Engine/Source/Lighting/CLight.cpp index db12acf34..a4565f29e 100644 --- a/Projects/Skylicht/Engine/Source/Lighting/CLight.cpp +++ b/Projects/Skylicht/Engine/Source/Lighting/CLight.cpp @@ -45,10 +45,10 @@ namespace Skylicht CObjectSerializable* CLight::createSerializable() { CObjectSerializable* object = CComponentSystem::createSerializable(); - object->addAutoRelease(new CUIntProperty(object, "bakeBounce", m_bakeBounce, 4)); - object->addAutoRelease(new CBoolProperty(object, "castShadow", m_castShadow)); - object->addAutoRelease(new CColorProperty(object, "color", m_color.toSColor())); - object->addAutoRelease(new CFloatProperty(object, "intensity", m_intensity, 0.0f, 10.0f)); + object->autoRelease(new CUIntProperty(object, "bakeBounce", m_bakeBounce, 4)); + object->autoRelease(new CBoolProperty(object, "castShadow", m_castShadow)); + object->autoRelease(new CColorProperty(object, "color", m_color.toSColor())); + object->autoRelease(new CFloatProperty(object, "intensity", m_intensity, 0.0f, 10.0f)); return object; } diff --git a/Projects/Skylicht/Engine/Source/Lighting/CPointLight.cpp b/Projects/Skylicht/Engine/Source/Lighting/CPointLight.cpp index 34895f91b..ba9803a3e 100644 --- a/Projects/Skylicht/Engine/Source/Lighting/CPointLight.cpp +++ b/Projects/Skylicht/Engine/Source/Lighting/CPointLight.cpp @@ -74,7 +74,7 @@ namespace Skylicht { CObjectSerializable* object = CLight::createSerializable(); - object->addAutoRelease(new CFloatProperty(object, "radius", m_radius, 0.0f)); + object->autoRelease(new CFloatProperty(object, "radius", m_radius, 0.0f)); return object; } diff --git a/Projects/Skylicht/Engine/Source/ReflectionProbe/CReflectionProbe.cpp b/Projects/Skylicht/Engine/Source/ReflectionProbe/CReflectionProbe.cpp index bd2f2f5c1..04dc4ec2b 100644 --- a/Projects/Skylicht/Engine/Source/ReflectionProbe/CReflectionProbe.cpp +++ b/Projects/Skylicht/Engine/Source/ReflectionProbe/CReflectionProbe.cpp @@ -111,7 +111,7 @@ namespace Skylicht CEnumProperty* enumType = new CEnumProperty(object, "type", m_type); enumType->addEnumString("Static", EReflectionType::Static); enumType->addEnumString("Bake", EReflectionType::Baked); - object->addAutoRelease(enumType); + object->autoRelease(enumType); CEnumProperty* bakeSizeType = new CEnumProperty(object, "size", m_size); bakeSizeType->setUIHeader("Bake Probe"); @@ -119,14 +119,14 @@ namespace Skylicht bakeSizeType->addEnumString("512", EReflectionSize::X512); bakeSizeType->addEnumString("1024", EReflectionSize::X1024); bakeSizeType->addEnumString("2048", EReflectionSize::X2048); - object->addAutoRelease(bakeSizeType); + object->autoRelease(bakeSizeType); std::vector exts; exts.push_back("tga"); exts.push_back("png"); CFilePathProperty* staticReflection = new CFilePathProperty(object, "static", m_staticPath.c_str(), exts); staticReflection->setUIHeader("Static Probe"); - object->addAutoRelease(staticReflection); + object->autoRelease(staticReflection); return object; } diff --git a/Projects/Skylicht/Engine/Source/RenderMesh/CRenderMesh.cpp b/Projects/Skylicht/Engine/Source/RenderMesh/CRenderMesh.cpp index 8788106f1..500decc64 100644 --- a/Projects/Skylicht/Engine/Source/RenderMesh/CRenderMesh.cpp +++ b/Projects/Skylicht/Engine/Source/RenderMesh/CRenderMesh.cpp @@ -96,15 +96,15 @@ namespace Skylicht { CObjectSerializable* object = CComponentSystem::createSerializable(); - object->addAutoRelease(new CBoolProperty(object, "load normal", m_loadNormal)); - object->addAutoRelease(new CBoolProperty(object, "inserse normal", m_fixInverseNormal)); - object->addAutoRelease(new CBoolProperty(object, "load texcoord2", m_loadTexcoord2)); + object->autoRelease(new CBoolProperty(object, "load normal", m_loadNormal)); + object->autoRelease(new CBoolProperty(object, "inserse normal", m_fixInverseNormal)); + object->autoRelease(new CBoolProperty(object, "load texcoord2", m_loadTexcoord2)); std::vector meshExts = { "dae","obj","smesh" }; std::vector materialExts = { "xml","mat" }; - object->addAutoRelease(new CFilePathProperty(object, "mesh", m_meshFile.c_str(), meshExts)); - object->addAutoRelease(new CFilePathProperty(object, "material", m_materialFile.c_str(), materialExts)); + object->autoRelease(new CFilePathProperty(object, "mesh", m_meshFile.c_str(), meshExts)); + object->autoRelease(new CFilePathProperty(object, "material", m_materialFile.c_str(), materialExts)); return object; } diff --git a/Projects/Skylicht/Engine/Source/Scene/CScene.cpp b/Projects/Skylicht/Engine/Source/Scene/CScene.cpp index 035bb3799..6606ce1a6 100644 --- a/Projects/Skylicht/Engine/Source/Scene/CScene.cpp +++ b/Projects/Skylicht/Engine/Source/Scene/CScene.cpp @@ -294,7 +294,7 @@ namespace Skylicht CObjectSerializable* CScene::createSerializable() { CObjectSerializable* object = new CObjectSerializable(getTypeName().c_str()); - object->addAutoRelease(new CStringProperty(object, "name", getNameA())); + object->autoRelease(new CStringProperty(object, "name", getNameA())); return object; } diff --git a/Projects/Skylicht/Engine/Source/Scene/CSceneExporter.cpp b/Projects/Skylicht/Engine/Source/Scene/CSceneExporter.cpp index 736ce3c97..952be19d7 100644 --- a/Projects/Skylicht/Engine/Source/Scene/CSceneExporter.cpp +++ b/Projects/Skylicht/Engine/Source/Scene/CSceneExporter.cpp @@ -31,7 +31,7 @@ namespace Skylicht { CObjectSerializable* childs = new CObjectSerializable("Childs"); data->addProperty(childs); - data->addAutoRelease(childs); + data->autoRelease(childs); ArrayGameObject* go = container->getChilds(); for (size_t i = 0, n = go->size(); i < n; i++) @@ -43,7 +43,7 @@ namespace Skylicht CObjectSerializable* childData = childObject->createSerializable(); childs->addProperty(childData); - childs->addAutoRelease(childData); + childs->autoRelease(childData); CContainerObject* childContainer = dynamic_cast(childObject); if (childContainer != NULL) @@ -95,7 +95,7 @@ namespace Skylicht loadChildObjectSerializable(zone, zoneData); data->addProperty(zoneData); - data->addAutoRelease(zoneData); + data->autoRelease(zoneData); ++i; } diff --git a/Projects/Skylicht/Engine/Source/Serializable/CArraySerializable.cpp b/Projects/Skylicht/Engine/Source/Serializable/CArraySerializable.cpp index 573d8096f..ddfbb11b0 100644 --- a/Projects/Skylicht/Engine/Source/Serializable/CArraySerializable.cpp +++ b/Projects/Skylicht/Engine/Source/Serializable/CArraySerializable.cpp @@ -43,6 +43,25 @@ namespace Skylicht } + bool CArraySerializable::resize(int count) + { + if (OnCreateElement == nullptr) + return false; + + if (getElementCount() < count) + { + // need delete + + } + else + { + // need grow + + } + + return true; + } + void CArraySerializable::removeElement(CValueProperty* element) { std::vector::iterator i = m_value.begin(), e = m_value.end(); diff --git a/Projects/Skylicht/Engine/Source/Serializable/CArraySerializable.h b/Projects/Skylicht/Engine/Source/Serializable/CArraySerializable.h index 6f63bbdb8..b97e3dfbf 100644 --- a/Projects/Skylicht/Engine/Source/Serializable/CArraySerializable.h +++ b/Projects/Skylicht/Engine/Source/Serializable/CArraySerializable.h @@ -52,6 +52,8 @@ namespace Skylicht return getPropertyID(i); } + bool resize(int count); + virtual void removeElement(CValueProperty* element); virtual bool isArray() diff --git a/Projects/Skylicht/Engine/Source/Serializable/CObjectSerializable.h b/Projects/Skylicht/Engine/Source/Serializable/CObjectSerializable.h index 9d0c9f7ca..9bd7a2d89 100644 --- a/Projects/Skylicht/Engine/Source/Serializable/CObjectSerializable.h +++ b/Projects/Skylicht/Engine/Source/Serializable/CObjectSerializable.h @@ -49,7 +49,7 @@ namespace Skylicht m_value.push_back(p); } - void addAutoRelease(CValueProperty* p) + void autoRelease(CValueProperty* p) { m_autoRelease.push_back(p); } diff --git a/Projects/Skylicht/Engine/Source/Serializable/CSerializableLoader.cpp b/Projects/Skylicht/Engine/Source/Serializable/CSerializableLoader.cpp index 7788f9651..8a3a7bfac 100644 --- a/Projects/Skylicht/Engine/Source/Serializable/CSerializableLoader.cpp +++ b/Projects/Skylicht/Engine/Source/Serializable/CSerializableLoader.cpp @@ -88,7 +88,7 @@ namespace Skylicht load(reader, data, exitNode); object->addProperty(data); - object->addAutoRelease(data); + object->autoRelease(data); // if end the node // // @@ -153,7 +153,7 @@ namespace Skylicht }; if (valueProperty) - object->addAutoRelease(valueProperty); + object->autoRelease(valueProperty); } } } \ No newline at end of file diff --git a/Projects/Skylicht/Engine/Source/Transform/CTransformEuler.cpp b/Projects/Skylicht/Engine/Source/Transform/CTransformEuler.cpp index 0d2728786..0129dfb56 100644 --- a/Projects/Skylicht/Engine/Source/Transform/CTransformEuler.cpp +++ b/Projects/Skylicht/Engine/Source/Transform/CTransformEuler.cpp @@ -265,9 +265,9 @@ namespace Skylicht CObjectSerializable* CTransformEuler::createSerializable() { CObjectSerializable* object = CComponentSystem::createSerializable(); - object->addAutoRelease(new CVector3Property(object, "position", getPosition())); - object->addAutoRelease(new CVector3Property(object, "rotation", getRotation())); - object->addAutoRelease(new CVector3Property(object, "scale", getScale())); + object->autoRelease(new CVector3Property(object, "position", getPosition())); + object->autoRelease(new CVector3Property(object, "rotation", getRotation())); + object->autoRelease(new CVector3Property(object, "scale", getScale())); return object; } diff --git a/Projects/Skylicht/Engine/Source/Transform/CTransformMatrix.cpp b/Projects/Skylicht/Engine/Source/Transform/CTransformMatrix.cpp index 4ecc76690..76b7b1d7f 100644 --- a/Projects/Skylicht/Engine/Source/Transform/CTransformMatrix.cpp +++ b/Projects/Skylicht/Engine/Source/Transform/CTransformMatrix.cpp @@ -74,7 +74,7 @@ namespace Skylicht CObjectSerializable* CTransformMatrix::createSerializable() { CObjectSerializable* object = CComponentSystem::createSerializable(); - object->addAutoRelease(new CMatrixProperty(object, "matrix", m_transform)); + object->autoRelease(new CMatrixProperty(object, "matrix", m_transform)); return object; } } \ No newline at end of file