-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add a property tree in the extension editor #8095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+4,741
−2,674
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0f82a6b
Add property list editor
D8H 43640f5
Scroll at selection
D8H 733f958
Follow selection both ways
D8H 9ccd4a9
Move the context menu in the tree
D8H 53be9a1
Merge the properties editor for behavior and object
D8H 9874093
Rename files
D8H 193a603
Move files
D8H a5008a7
Fix property renaming
D8H c977b04
Fix stories
D8H 63d2f55
Handle shared properties
D8H 153ab36
Fix shared property creation not updating
D8H 00ecdaf
Make it works on mobile
D8H 1895ed5
Keep the "Add property" button on mobile
D8H 5cd4319
Fix copy paste
D8H 1ad8cec
Factorize paste function
D8H 9e24bf4
Remove unused code.
D8H e104dab
Add property folders in Core
D8H 69df477
Update the tree when inserting and removing properties
D8H 163e99b
Handle property folders in the tree
D8H 5b7842c
Use the same order as the tree in the editor
D8H ca260ba
Fix updating the groups
D8H c98583a
Fix copy paste
D8H 26210d4
Expand all property folders by default
D8H 5fea626
Ensure group names are in sync with the tree when unserializing
D8H 6fa170b
Fix property removing and pasted property group
D8H 1ed94ff
Add an icon for resource properties
D8H cdc616f
Typo
D8H 6869586
Remove the field for property group that is now useless
D8H 9314e9e
Remove commented code.
D8H 0239fb4
Fix attribute name
D8H File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,8 @@ | |
| * Copyright 2008-2023 Florian Rival ([email protected]). All rights | ||
| * reserved. This project is released under the MIT License. | ||
| */ | ||
| #ifndef GDCORE_OBJECTFOLDEROROBJECT_H | ||
| #define GDCORE_OBJECTFOLDEROROBJECT_H | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <vector> | ||
|
|
||
|
|
@@ -210,5 +210,3 @@ class GD_CORE_API ObjectFolderOrObject { | |
| }; | ||
|
|
||
| } // namespace gd | ||
|
|
||
| #endif // GDCORE_OBJECTFOLDEROROBJECT_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| /* | ||
| * GDevelop Core | ||
| * Copyright 2008-2025 Florian Rival ([email protected]). All rights | ||
| * reserved. This project is released under the MIT License. | ||
| */ | ||
| #include "GDCore/Project/PropertiesContainer.h" | ||
| #include "GDCore/Project/NamedPropertyDescriptor.h" | ||
|
|
||
| namespace gd { | ||
|
|
||
| PropertiesContainer::PropertiesContainer( | ||
| EventsFunctionsContainer::FunctionOwner owner) | ||
| : properties(), owner(owner) { | ||
| rootFolder = gd::make_unique<gd::PropertyFolderOrProperty>("__ROOT"); | ||
| } | ||
|
|
||
| PropertiesContainer::PropertiesContainer(const PropertiesContainer &other) | ||
| : properties(other.properties), owner(other.owner) { | ||
| // The properties folders are not copied. | ||
| // It's not an issue because the UI uses the serialization for duplication. | ||
| rootFolder = gd::make_unique<gd::PropertyFolderOrProperty>("__ROOT"); | ||
| } | ||
|
|
||
| PropertiesContainer & | ||
| PropertiesContainer::operator=(const PropertiesContainer &other) { | ||
| if (this != &other) { | ||
| properties = other.properties; | ||
| owner = other.owner; | ||
| // The properties folders are not copied. | ||
| // It's not an issue because the UI uses the serialization for duplication. | ||
| rootFolder = gd::make_unique<gd::PropertyFolderOrProperty>("__ROOT"); | ||
| } | ||
| return *this; | ||
| } | ||
|
|
||
| NamedPropertyDescriptor & | ||
| PropertiesContainer::Insert(const NamedPropertyDescriptor &property, | ||
| size_t position) { | ||
| auto &newProperty = properties.Insert(property, position); | ||
| rootFolder->InsertProperty(&newProperty); | ||
| return newProperty; | ||
| } | ||
|
|
||
| NamedPropertyDescriptor &PropertiesContainer::InsertNew(const gd::String &name, | ||
| size_t position) { | ||
|
|
||
| auto &newlyCreatedProperty = properties.InsertNew(name, position); | ||
| rootFolder->InsertProperty(&newlyCreatedProperty); | ||
| return newlyCreatedProperty; | ||
| } | ||
|
|
||
| bool PropertiesContainer::Has(const gd::String &name) const { | ||
| return properties.Has(name); | ||
| } | ||
|
|
||
| NamedPropertyDescriptor &PropertiesContainer::Get(const gd::String &name) { | ||
| return properties.Get(name); | ||
| } | ||
|
|
||
| const NamedPropertyDescriptor & | ||
| PropertiesContainer::Get(const gd::String &name) const { | ||
| return properties.Get(name); | ||
| } | ||
|
|
||
| NamedPropertyDescriptor &PropertiesContainer::Get(size_t index) { | ||
| return properties.Get(index); | ||
| } | ||
|
|
||
| const NamedPropertyDescriptor &PropertiesContainer::Get(size_t index) const { | ||
| return properties.Get(index); | ||
| } | ||
|
|
||
| void PropertiesContainer::Remove(const gd::String &name) { | ||
| rootFolder->RemoveRecursivelyPropertyNamed(name); | ||
| properties.Remove(name); | ||
| } | ||
|
|
||
| void PropertiesContainer::Move(std::size_t oldIndex, std::size_t newIndex) { | ||
| properties.Move(oldIndex, newIndex); | ||
| } | ||
|
|
||
| bool PropertiesContainer::IsEmpty() const { return properties.IsEmpty(); }; | ||
|
|
||
| size_t PropertiesContainer::GetCount() const { return properties.GetCount(); } | ||
|
|
||
| std::size_t | ||
| PropertiesContainer::GetPosition(const NamedPropertyDescriptor &element) const { | ||
| return properties.GetPosition(element); | ||
| } | ||
|
|
||
| const std::vector<std::unique_ptr<NamedPropertyDescriptor>> & | ||
| PropertiesContainer::GetInternalVector() const { | ||
| return properties.GetInternalVector(); | ||
| }; | ||
|
|
||
| std::vector<std::unique_ptr<NamedPropertyDescriptor>> & | ||
| PropertiesContainer::GetInternalVector() { | ||
| return properties.GetInternalVector(); | ||
| }; | ||
|
|
||
| gd::NamedPropertyDescriptor &PropertiesContainer::InsertNewPropertyInFolder( | ||
| const gd::String &name, | ||
| gd::PropertyFolderOrProperty &propertyFolderOrProperty, | ||
| std::size_t position) { | ||
| gd::NamedPropertyDescriptor &newlyCreatedProperty = | ||
| properties.InsertNew(name, properties.GetCount()); | ||
| propertyFolderOrProperty.InsertProperty(&newlyCreatedProperty, position); | ||
| return newlyCreatedProperty; | ||
| } | ||
|
|
||
| std::vector<const PropertyFolderOrProperty *> | ||
| PropertiesContainer::GetAllPropertyFolderOrProperty() const { | ||
| std::vector<const PropertyFolderOrProperty *> results; | ||
|
|
||
| std::function<void(const PropertyFolderOrProperty &folder)> | ||
| addChildrenOfFolder = [&](const PropertyFolderOrProperty &folder) { | ||
| for (size_t i = 0; i < folder.GetChildrenCount(); ++i) { | ||
| const auto &child = folder.GetChildAt(i); | ||
| results.push_back(&child); | ||
|
|
||
| if (child.IsFolder()) { | ||
| addChildrenOfFolder(child); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| addChildrenOfFolder(*rootFolder); | ||
|
|
||
| return results; | ||
| } | ||
|
|
||
| void PropertiesContainer::AddMissingPropertiesInRootFolder() { | ||
| for (std::size_t i = 0; i < properties.GetCount(); ++i) { | ||
| auto &property = properties.Get(i); | ||
| if (!rootFolder->HasPropertyNamed(property.GetName())) { | ||
| const gd::String &group = property.GetGroup(); | ||
| auto &folder = !group.empty() ? rootFolder->GetOrCreateChildFolder(group) | ||
| : *rootFolder; | ||
| folder.InsertProperty(&property); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void PropertiesContainer::SerializeElementsTo( | ||
| const gd::String &elementName, SerializerElement &element) const { | ||
| properties.SerializeElementsTo(elementName, element); | ||
| } | ||
|
|
||
| void PropertiesContainer::UnserializeElementsFrom( | ||
| const gd::String &elementName, const SerializerElement &element) { | ||
| properties.UnserializeElementsFrom(elementName, element); | ||
| } | ||
|
|
||
| void PropertiesContainer::SerializeFoldersTo(SerializerElement &element) const { | ||
| rootFolder->SerializeTo(element); | ||
| } | ||
|
|
||
| void PropertiesContainer::UnserializeFoldersFrom( | ||
| gd::Project &project, const SerializerElement &element) { | ||
| rootFolder->UnserializeFrom(project, element, *this); | ||
| rootFolder->UpdateGroupNameOfAllProperties(); | ||
| } | ||
|
|
||
| } // namespace gd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.