Forums

OverviewV-Play 2 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
    V-Play 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 3 years, 3 months ago by  Reyarc.
    • This reply was modified 3 years, 3 months ago by  Reyarc.
    #9767

    Christian
    V-Play 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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support