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

Would you like this feature?

  • Yes

    Votes: 37 92.5%
  • No

    Votes: 2 5.0%
  • Yes, but not important

    Votes: 1 2.5%

  • Total voters
    40

SumRndmDde

Follower of RNGesus
Veteran
Joined
Jul 30, 2013
Messages
225
Reaction score
418
First Language
English
Primarily Uses
RMMV
I thought about this a bit.

The MV code base is huge and mapping the x,y,width, height would be a pain and lead to a lot of edits as a community script.

So, instead from a programming perspective I have a solution.

Every Scene and Window has a name in MV.

We can give users a list of Windows & Scene Names. Then place a single function in Window_Base that will overwrite the Window properties on initialization and refresh the contents based on what names are in the list.

If a Scene name is provided only the scene is effected with the window changes.

If a Window name is provided, the changes are global.

This makes changing the properties optional using the struct type now available in the PluginManager list. Devs just have to make sure their new Window class is available in the global context.

Meaning as a dev and as a creator life is a lot easier; add changes you want, leave the ones you don't want to edit off the list.
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:

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
525
Reaction score
739
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.
is there a script call that return how much turn has passed in battle?
Does anyone find this hard to read?

Enjoying my weekend at home to stay Covid free. How is everyone else doing?

Forum statistics

Threads
100,603
Messages
977,734
Members
132,214
Latest member
qwertyben
Top