Forums

OverviewFelgo 2 Support (Qt 5) › LevelEditor public interface changes propositions

Tagged: 

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #16643

    Marcin

    Hello Felgo,

    I am playing a lot with levelEditor currently and found few cases which I come across very quickly, which could be a litter better handled in LevelEditor(imho).
    Apologize if I missed something in the docs but couldn’t find obvious solutions so I come with my own one, which I use currently.
    Potential improvements:

    1.
    Problem: Loading authorGenerated levels involves knowledge of implementation details of the LevelEditor.
    Current solution:
    levelEditor.loadAllLevelsFromStorageLocation(levelEditor.authorGeneratedLevelsLocation)
    Using that general purpose method is nice but, since you have shortcuts for loading community levels etc, some shorter could be useful, for example:

    
    // Inside LevelEditor
    function loadAuthorGeneratedLevels() {
    loadAllLevelsFromStorageLocation(authorGeneratedLevelsLocation)
    }
    
    // to call outside:
    levelEditor.loadAuthorGeneratedLevels()
    

    Not only it is shorter but it also hides implementation detail, just a little higher level abstraction that using generic loadAllLevelsFromStorageLocation method.

    2.
    Problem: Detecting if we are operating on new level or not.
    This is the only easy way I found to do it, if there are other sorry, missed them.
    Current solution: Comparing if level(levelEditor.currentLevelNameString) name is “UndefinedLevel”
    It works ok but there are few issues with this approach.
    It is highly tied to implementation, it is not easily available and it allows potential issues if somebody would like to save level this reserved name.
    I see two ways to handle this.
    First approach, just create a readonly property which holds reserved name for new levels.
    For example:

    
    //inside LevelEditor
    readonly property string newLevelName: 'UndefinedLevel'
    

    This way changes to this string value wouldn’t affect changes in the code, we would check the property not literal value.

    Second approach, extension of first one:
    We can keep the readonly property but also add a method which informs if the level is new, for example:

    
    // inside LevelEditor
    readonly property string newLevelName: 'UndefinedLevel'
    function isNewLevel() {
    return newLevelName === currentLevelNameString
    }
    

    In general these changes help to hide internal logic which shouldn’t be really used by clients of the object.
    I like the idea that there are low level methods which give more flexibility, but sometimes adding few more higher level ways to do stuff, can be helpful.

    I hope this has sense what I proposed, I am not saying current interface is bad, opposite is quite good, don’t get me wrong 🙂

    #16647

    GĂźnther
    Felgo Team

    Hi Marcin,

    Your suggestions are good imho, I noted them as possible future improvement of the LevelEditor API.

    And no worries, we don’t take suggestions personally – thanks for your motivation to make Felgo better! 😉

    Best,
    GĂźnther

    #16877

    Marcin

    Hi,
    I am not sure if this is the right place but I have one more suggestion.
    Didn’t want to create a new topic just for this.

    I would like to be able to know easier if current level is published or not.
    In one of your demos you use property:
    property bool isPublished: modelData["publishedLevelId"] !== undefined
    what is nice but if this logic is always right, then maybe it would be useful to have this on levelEditor itself.
    For example:
    levelEditor.isCurrentLevelPublished() or similar.

    #16878

    Marcin

    Ok, I am not so sure if the field "publishedLevelId" even exists on published levels.
    I don’t see it at all.
    What I use now to check if level is published is  storageLocation: "userGenerated", nevertheless still would be nice to have a shortcut to this.

    #16882

    Alex
    Felgo Team

    Hi Marcin,

    sounds reasonable, we will discuss adding this.

    The publishedLevelId is part of the levelMetaData of a level.

    Cheers,
    Alex

    #16885

    Marcin

    Hi Alex,
    Thank you feedback.

    In regards to publishedLevelId, I don’t see it among these keys(I took the json from the link you sent):

     {
       "levelId": 2,
       "levelName": "Level Name",
       "description": "Level description",
       "average_quality": 0,
       "average_difficulty": 0,
       "times_quality_rated": 0,
       "times_difficulty_rated": 0,
       "times_favored": 0,
       "times_downloaded": 0,
       "times_played": 0,
       "created_at": "2013-05-13T14:43:57Z",
       "updated_at": "2013-05-13T14:43:57Z",
       "rating": {
         "difficulty": 0,
         "quality": 1,
         "favored": false,
         "times_played": 0
       },
       "user": {
         "id": 8,
         "facebook_id": "asdf2",
         "profile_picture": null,
         "name": "Chris",
         "platform": "Android"
       },
       "storageLocation":"userGenerated"
     }

    Or maybe what you mean is the levelId on this json?

    #16886

    Alex
    Felgo Team

    Hi Marcin,

    you are right, this key is missing in the documentation. It is added to the levelMetaData upon publishing, we will update the documentation accordingly.

    Cheers,
    Alex

    #16887

    Marcin

    Hi Alex,

    Thank you for the update.
    I still had some issues to see that key when I read published posts.
    But will double check again if I am right, I am not 100% sure.
    If I see the issue will prepare maybe some simple example.

    #16919

    Marcin

    Hi Alex,
    Hmm I am not able to get the published id where I expect it.
    Maybe I am doing something wrong?
    Do you think you would be able to tell me what’s wrong with my approach?

    Simple example(I will hide gameId etc., but can send them trough emeail).
    I tested it with game with over 10 levels published:

    import Felgo 3.0
    import QtQuick 2.0
    
    GameWindow {
        id: gameWindow
    
        activeScene: scene
    
        screenWidth: 640
        screenHeight: 960
    
        VPlayGameNetwork {
            id: gameNetwork
            gameId: {HIDDEN}
            secret: {HIDDEN}
        }
    
        LevelEditor {
            id: levelEditor
            toRemoveEntityTypes: []
            toStoreEntityTypes: []
        }
    
        Scene {
            id: scene
            width: 320
            height: 480
    
            LevelSelectionList {
                id: levelsList
                levelItemDelegate: publishedLevelItemView
                levelMetaDataArray: levelEditor.communityLevels
            }
    
            Component {
                id: publishedLevelItemView
                Rectangle {
                    height: 150
                    width: gameWindow.width
    
                    StyledButton {
                        text: 'Name: ' + modelData.levelName
                              + '<br />Created: ' + modelData.creationTime
                              + '<br />Modified: ' + modelData.lastModificationTime
                              + '<br />User: ' + modelData.user.name
                              + '<br />ID: ' + modelData.levelId
                              + '<br />publishedLevelId: ' + modelData.publishedLevelId
                        onClicked: {
                            console.log(JSON.stringify(modelData))
                        }
                    }
                }
            }
        }
        Component.onCompleted: {
            levelEditor.loadCommunityLevels()
        }
    
    }
    

     

    I am not able to get pubshedLevelId here. It shows undefined.
    The documentation mentions level meta data but here it is more flat object in modelData.
    So what the console.log on click in this examples shows(some stuff is hidden by me):

    {
       "average_difficulty":0,
       "average_quality":0,
       "created_at":"2017-08-14T21:46:14Z",
       "creationTime":"Tue Aug 15 10:17:45 2017 GMT",
       "data":null,
       "description":"",
       "fields":{
    
       },
       "game_id":{HIDDEN},
       "id":6661,
       "lastModificationTime":"Tue Aug 15 10:17:45 2017 GMT",
       "levelId":6666,
       "levelName":"taki se",
       "name":"taki se",
       "picture_id":null,
       "pos":0,
       "storageLocation":"userGenerated",
       "times_difficulty_rated":0,
       "times_downloaded":0,
       "times_favored":0,
       "times_played":0,
       "times_quality_rated":0,
       "updated_at":"2017-08-14T21:46:14Z",
       "user":{
          "first_name":null,
          "gender":null,
          "id":{HIDDEN},
          "last_name":null,
          "locale":"pl_PL",
          "name":{HIDDEN},
          "platform":"Linux",
          "profile_picture":null,
          "screen_name":null
       }
    }

    Still no info about published level id.
    What am I doing wrong?

    PS. Just to clarify, in this example with my testing data I had levels without  any entities, just balance bits.

     

    #16926

    Alex
    Felgo Team

    Hi Marcin,

    I’ll try to shed some more light on this, it can indeed be a bit confusing, we’ll see if we can make this more clear in the documentation:

    For communityLevels there is only the levelId property, which equals the global id of the level after publishing.

    For autherGeneratedLevels the levelId equals the local id of the level, and after publishing the publishedLevelId property is added which equals the global id of the level after publishing.

    So to get the global level id you will have to distinguish between community levels and author levels, and take either the levelId or the publishedLevelId of the level. You can distinguish either by checking which levels you are currently displaying or by looking at the storageLocation property of the level meta data.

    Cheers,
    Alex

    #16927

    Marcin

    Hi Alex,

    Thank you for the clarification.
    The truth is that is what I thought but wanted to get the official info if I am right.
    After debugging one of your demos(Stack box with community editor) I got the same impression.
    That the published id depends on the type of storage.

    Now it is clear and I am fine with that.
    Thank you.

    PS. Hopefully the level editor topic is finished for me, for a while probably 🙂

Viewing 11 posts - 1 through 11 (of 11 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