Bind all windows x,y,width and height to variables that users can easily edit

Discussion in 'Editor Suggestions and Improvement' started by Archeia, Jul 4, 2017.

?

Would you like this feature?

  1. Yes

    36 vote(s)
    92.3%
  2. No

    2 vote(s)
    5.1%
  3. Yes, but not important

    1 vote(s)
    2.6%
  1. SumRndmDde

    SumRndmDde Follower of RNGesus Veteran

    Messages:
    224
    Likes Received:
    409
    Location:
    an alternate dimension.
    First Language:
    English
    Primarily Uses:
    RMMV
    Yeah, that's pretty much how the STE's Menu Editor saves everything.

    For example:
    Code:
    {
        "Scene_Title": {
            "Window_TitleCommand": {
                "x": "100",
                "y": "500"
            }
        },
        "Scene_Item": {
            "Window_ItemCategory": {
                "width": "1000"
            },
            "Window_Help": {
                "x": "0",
                "y": "100",
                "width": "Graphics.boxWidth",
                "height": "win.fittingHeight(2)"
            }
        }
    }
    

    And then everything can be simply read doing something like:
    Code:
    //$dataWindows contains JSON info
    
    var _SceneManager_onSceneStart = SceneManager.onSceneStart;
    SceneManager.onSceneStart = function() {
        _SceneManager_onSceneStart.apply(this, arguments);
        this._scene.setupWindowProperties();
    };
    
    Scene_Base.prototype.setupWindowProperties = function() {
        //Check if window layer exists and if there is any saved data for this scene.
        if(!this._windowLayer || !$dataWindows[this.constructor.name]) return;
        var children = this._windowLayer.children;
        var sceneInfo = $dataWindows[this.constructor.name];
        children.forEach(function(win) {
            //Check and make sure window exists and if there's any data saved for it.
            if(win && win.constructor && sceneInfo[win.constructor.name]) {
                //Apply data, but only if it exists.
                var info = sceneInfo[win.constructor.name];
                if(info.x) win.x = eval(info.x);
                if(info.y) win.y = eval(info.y);
                if(info.width) win.width = eval(info.width);
                if(info.height) win.height = eval(info.height);
            }
        });
    }
    

    Therefore, when someone's creating their own custom scene, they could simply do this to set up position/size of windows:
    Code:
    $dataWindows["Scene_Custom"] = {};
    $dataWindows["Scene_Custom"]["Window_Custom1"] = {
      x: "200",
      y: "400"
    }
    

    Don't know if this code helps, but please feel free to use it if it'll help make this feature happen. ¯\_(ツ)_/¯
     
    Last edited: Jul 5, 2017
    #21
    boomy and Kino like this.
  2. Kino

    Kino EIS Game Dev Veteran

    Messages:
    515
    Likes Received:
    669
    Location:
    United States
    First Language:
    English
    Primarily Uses:
    RMMV
    We have the same idea then and yea, I had a similar thought.

    I think I'll do children looping also. Right now I'm injecting params into Windows directly. But instead going through SceneManager._scene to check but using SceneBase will be cleaner.
     
    #22

Share This Page