How to make Windows not layer on top of each other

Because I design my own menus within the menu system, this has become a huge issue for my project. I've done a lot of research on how to make windows stop covering each other up even after being made transparent with no success so far... until now. I downloaded http://sumrndm.site/window-layers/ SumRandomDude's plugin but unfortunately it didn't work for my MZ project, but his code pointed me in the right direction.

After more frustration, I bowed my head, said a prayer, and asked Jesus to help me find the answer to this... and He did.

Here's a screenshot when my windows are visible
1699674238721.png



Here's a screenshot when my windows are transparent. As you can see, the window IS transparent, but still overlaps the image behind it.
1699674317682.png



After Jesus showed me what code I needed to put in, here's what I got.
1699674398370.png



The last line is the code that made all the difference. When creating the window in a function, you need to tell the window that it's actually NOT a real window, which will then make the window itself invisible while keeping the graphic assigned to it still visible. BRILLIANT!!

Code:
Scene_Menu.prototype.createWaxSealWindow = function() {
    const rect = this.waxSealWindowRect();
    this._waxSealWindow = new Window_WaxSeal(rect);
    this.addWindow(this._waxSealWindow);
    this._waxSealWindow._isWindow = false;
};

Code that made the difference: --> this._waxSealWindow._isWindow = false;
If you need help setting this up in JS, send me a PM. Hope this helps someone because this is a big find for me tonight!!
Short answer: don't use addWindow() in this scenario; use addChild().

Do you need to be using windows for this? If all you're doing is drawing an image, use a sprite. Add the sprite as a child to the scene's spriteset (or perhaps to a relevant window), or your own container sprite that you add to the scene separately.
I'm using Eli's Background Manager Pro plugin which allows me to assign sprites to Windows based on conditions (Switch/Variable). This allows me to always have the sprite I want based on those conditions. Is there a better way to do this?
I don't really think you've provided enough context for anyone to suggest an alternative approach.

However, what I am saying is that if the only purpose of your "wax seal window" is to display the wax seal image, then it would be more effective to add the wax seal as a sprite—not a window—to whatever its parent object is. Which appears to be a status menu or something.

I can't really tell, because, again, you've provided minimum context and your images are super-cropped, which leaves very little room for us to infer.
Yes, the only purpose of the "Wax Seal Window" is to display the Wax Seal image, but which image to display is based on conditions, which is why I made it a window instead of a simple sprite.
I've done a lot of research on how to make windows stop covering each other up even after being made transparent
Does this work for you?
I haven't personally done any tests or measurements, but I think you can skip the custom WindowLayer renderer with a small plugin like this:
  • MZ:
    JavaScript:
    /*:
     * @target MZ
     * @plugindesc Skips window layer scissor masking, to minimise draw calls.
     * @help Free to use and/or modify for any purpose, no credit required.
     */
    WindowLayer.prototype.render = function() {
      PIXI.Container.prototype.render.apply(this, arguments);
    };
  • MV:
    JavaScript:
    /*:
     * @target MV
     * @plugindesc Skips window layer scissor masking, to minimise draw calls.
     * @help Free to use and/or modify for any purpose, no credit required.
     */
    WindowLayer.prototype.renderCanvas = function() {
      PIXI.Container.prototype.renderCanvas.apply(this, arguments);
    };
    WindowLayer.prototype.renderWebGL = function() {
      PIXI.Container.prototype.renderWebGL.apply(this, arguments);
    };
Note that skipping the custom scissor masking like this will also cause game windows to be rendered on top of one another.
Alternatively, the plugin code I personally use for MZ is:
JavaScript:
delete WindowLayer.prototype.render;
I.e. "forget the WindowLayer render override" (it'll use the inherited one instead).
Does this work for you?
So far _isWindow = false; has been working fantastic for me. Last night I spent several hours building a window in my menu that displays icon highlights in the character menu if the player has an armor set and it works like a charm.

My only concern is that I'm about to make another menu scene that needs to have around 60 of these windows so I'm not sure how the performance will be when opening that scene, or closing it. I know it's going to work, but at what cost performance if any. I'll let you know how it goes as soon as I'm finished building it. If the performance is bad, I'll start trying your suggestions or @Kenen above.

On a side note, your PictureTouch 1.5 plugin is a gift that just keeps on giving. Seriously bro, that plugin is a masterpiece of code that allows infinite amounts of flexibility for custom menus. I can't believe you aren't charging for it, but I'd be more than happy to donate just because of what it's done for my project. God bless you for that!
@caethyril

I finished my new menu Scene and I ended up creating 56 windows in total using the _isWindow = false; method. Each window has a condition tied to it to see whether or not the graphic displays and which graphic if it does. To my surprise, the performance is fantastic, there's absolutely no lag when opening the scene what so ever. I'm sure there was a better way of achieving this, but the performance is good and I got what I wanted so I'm happy.

Here's a screenshot with my Window.png file displaying the windows. As you can see all 56 windows are there overlapping each other.
1699938613067.png


This is a screenshot with my Windows.png made transparent. With the windows invisible and _isWindow = false; preventing "layer scissor masking", we can achieve some pretty outstanding menus both in the Menu_Scene and custom menus when in the Map_Scene. 😀
1699938784048.png
Yea, that works. The plugin code I suggested would simply remove the masking altogether, kind of like setting _isWindow to false for all game windows.

I'm not personally a fan of your approach, since the objects are windows. Kenen suggested adding this kind of thing as a Sprite child of the respective window instead, which would:
  • Ensure the image automatically moves with the window it's "in"; and
  • Bypass all the window rendering issues.
Rough example:
JavaScript:
Window_MyStuff.prototype.initialize = function() {
  // ...code goes here...
  // Add wax seal at 20, 20 in this window.
  this._waxSeal = new Sprite(ImageManager.loadPicture("WaxSeal"));
  this._waxSeal.move(20, 20);
  this.addChild(this._waxSeal);
};
For a sprite that scrolls with a window's content, consider addInnerChild instead.

Some technical info: addWindow adds to the scene's window layer, whereas addChild adds directly to the scene. WindowLayer is the one with the custom renderer, so using addChild would also avoid that. However, the window layer is determined by UI area coords (typically different from scene coords) and is manipulated in some situations, e.g. it's made invisible when taking a snapshot for the battle background.

(It's possible that some plugin may check _isWindow for some reason, in which case your approach could cause strange compatibility issues. I think that's unlikely, though.)

Also, just to note: single-user framerate is NOT a good indicator of "performance". It's dependent on OS/drivers/hardware, it's threshold-based (only drops below the intended framerate are seen, regardless of system ability), and it can be affected by other active applications.
As caethyril said, it's really visually unclear why those are 56 windows instead of just one window with the checkmark sprite drawn in the appropriate place.

The purpose of windows is to demarcate where you have selectable items vs. displayed information; and, after that, to physically arrange the information on the screen in the combinations of rectangles.

Since you don't appear to have anything to choose from on this screen (the checkmarks are, presumably, automatic based on what you have) and it's already a rectangle, there's not really a reason for it to be more than one window.
@caethyril @ATT_Turan @Kenen

First off, I want to take a moment to thank all three of you for taking time out of your busy lives to steer me in the right direction. Your posts have taught me a lot of thing about js that I didn't know before.

Secondly, I wanted to let you know that using Eli's Background Manager Pro plugin to make the little checkmarks display as the background of the windows, was causing all the checkmarks to appear for a split second when first opening the status_scene, at which then it removes them based on the condition. It's not super noticeable as they appear for probably only 10-15 frames (1/6 of a second) but I notice it and I'm super anal about things like that. I didn't realize this was happening until AFTER I made my post that the performance was good... turns out it wasn't good. I've already contacted Eli about this...

Because it wasn't performing the way I wanted I decided to utilize your advice... AND I'M SO GLAD I DID! I made Window_Status large enough to cover all the check boxes and used the code @caethyril gave me and it worked like a charm. I then set the condition right in the js code instead of the Background Manager Pro plugin, and now the checkmarks appear only when the condition is met, not before - then removed. Not only this, but now I only have 3 windows on my scene instead of 56, hahaha!!

Here's the code...

Code:
Window_Status.prototype.initialize = function(rect) {
    Window_StatusBase.prototype.initialize.call(this, rect);
    this.activate();
    const HandClub = $gameVariables.value(141);
    this._handClub = new Sprite(ImageManager.loadPicture("Checkmark_1"));
    if (HandClub == 1) {
        this._handClub.move(109, 76);
        this.addChild(this._handClub);
    }
};

Here's a screenshot of what it looks like now. I haven't set it all up yet but the first checkmark is working perfectly...
1699984878822.png


Praise God for you guys, I'm learning so much from all the js gurus on these forums. CT_Bolt, Hakuen Studio, and you three, have been instrumental in the development of Age of Tribulation. I can't thank you enough!

- Take care

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-windows-not-layer-on-top-of-each-other.162826/