Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › Save all entity properties

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #9759

    Vladimir

    Hello,

    I’m using LevelEditor and I would like to know if it is possible to save all the data that contains an entity ?
    As I could see, there are always these data saved :

    {"entityData":{"fichierTest_5":{"entityId":"fichierTest_5","entityType":"fichierTest","variationType":"","x":90,"y":72,"rotation":0}}

    But my entity have other properties that I want to save. For example :

    EntityEntry{
        id: domainEntry
        entityType: "domainEntry"
        variationType: "domainEntry"
    
        property string name
        property string type
        property int memory
    
    
    }

    What should I do to solve this ?

     

    #9760

    Christian
    Felgo Team

    Hi Vladimir,

    excellent question! 🙂

    Are you also using the ItemEditor to change the properties at runtime for balancing during game creation? If you use it, the entities you use with ItemEditor are automatically stored with the LevelEditor.

    If you do not want to use ItemEditor (although I’d strongly recommend it), you can use EntityBase::toStoreProperties to define which properties you want to save in a call of LevelEditor::saveCurrentLevel().

    Cheers, Chris

    #9761

    Vladimir

    Thank you Chris for your solutions !
    I tried with “toStoreProperties” but my application crashed :

    qml: EntityManager: storeEntitesAsJson: storing entity Entity_QMLTYPE_52(0x2d4b320, "entity_switchEntity_5") of type entity and id entity_switchEntity_5
    qml: EntityManager: storing property from toStoreProperties array of entity entry with value SwitchEntry_QMLTYPE_187(0x313db10, "switchEntry_switchEntry_4")
    terminate called after throwing an instance of 'std::bad_alloc'
      what():  std::bad_alloc

    I have this structure :
    – Entity is a component specialized into SwitchEntity.
    – an Entity has an EntityEntry ( specialized into SwitchEntry )

    So we have
    “Abstract Components”

    //Entity.qml
    EntityBaseDraggable{
        id: entity
        entityType: "entity"
        toStoreProperties: ["entry"]
    
        property EntityEntry entry
    }
    
    //EntityEntry.qml
    Entry{
        id: entityEntry
        entityType: "entityEntry"
        variationType: "entityEntry"
    
        property bool saved: false
        property bool isTemplate: false
        property bool isModel: false
        property bool hasRessources: false
    
        property EntryProperties properties
    }

     

     

    “Concret Components”

    //SwitchEntity.qml
    Entity{
        id: switchEntity
        entityType: "entity"
        variationType: "switchEntity"
        entry: entry
    
        Image{
            id: image
            anchors.fill: parent
            source: "../../assets/switch.svg"
        }
    
    
        SwitchEntry{
            id: entry
        }
    }
    
    //SwitchEntry.qml
    EntityEntry{
        id: switchEntry
        entityType: "switchEntry"
        variationType: "switchEntry"
        properties: properties
    
        property string type
        property int ports
        property bool isHub
        property bool stpEnabled
        property int portMirroring
    
        SwitchEntryProperties{id: properties}
    
    
    }

     

    I don’t know why it is crashing when I’m saving the level ( It happens when I want to store a component property )
    I tried your first solution by putting an ItemEditor in my Scene but the data still are the same.

     

    • This reply was modified 8 years, 8 months ago by  Reyarc.
    • This reply was modified 8 years, 8 months ago by  Reyarc.
    #9767

    Christian
    Felgo Team

    The toStoreProperties must be basic types like int, string, arrays or variants and cannot be a custom QML type. Please try to change the structure to only save the stored properties within your EntityEntry.

    Cheers, Chris

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded