MZ Looking for window examples!

Hello! I'm an embedded firmware/hardware designer by day, and just recently started playing around with JavaScript to see if it's possible to learn any front-end work. Thought RMMZ would be a great place to start as I've always played around with the engines ever since RM2K3 came out, but never really messed with the coding side. Plus, I'd like to make some games for my kids!

Anyway, I'm having a heck of a time finding documentation for any of the JavaScript calls for the engine. I have stumbled across a few good references, but not a lot covering windows (menus, custom rects, etc.).

I'm just looking for other's existing code or links to good scripts already written that could illustrate this--bonus points if there's good comments in there! Didn't know if there was anything existing with this flavor of JavaScript compared to others, where you can identify containers or grids, etc.

Again, I'm just looking for some simple examples or links to a good resource that gives some instruction/documentation on how windows work in RMMZ.


Thanks and take care!
Personally, I learned by trawling through the core script files (rmmz_*.js in a project's /js subfolder). rmmz_core.js is well-commented, as evidenced by its auto-generated API docs:
The others are sparsely documented but generally much less complicated.

Some points on RMMZ's code structure:
  1. The engine is based on PIXI.js:
    Game elements are manually positioned on the canvas via JavaScript.

  2. Rectangle (rmmz_core.js) is a wrapper/alias for the simple PIXI.Rectangle:

  3. The basic in-game Window (rmmz_core.js) inherits directly from PIXI.Container:

  4. All scenes inherit from Scene_Base (rmmz_scenes.js), which itself inherits from PIXI.Container through Stage (rmmz_core.js). This defines various methods like addWindow to add a window to the scene, or the create, start, update, etc methods that are invoked/checked by the SceneManager (rmmz_managers.js).

  5. All default in-game windows further inherit from Window_Base (rmmz_windows.js).

  6. Selectable windows further inherit from Window_Selectable (rmmz_windows.js). Typically a scene will use a selectable window's setHandler method to bind callback functions to one or more possible "symbols", e.g. 'ok' or 'cancel'. The assigned handlers are invoked by the window when appropriate.
Generally speaking, you'll only need to patch/override certain methods to alter existing windows or even create your own. For a plugin example, maybe check out a quest journal type plugin, e.g.
These kinds of plugins usually implement a custom scene and several custom interactive windows, demonstrating how to create those windows and handle interactions between them.

(Slight caveat: as you may know, JavaScript implements inheritance via prototype chains rather than a more typical class structure. ES6 introduced optional class-like "sugar" syntax, but RMMZ's core scripts remain written in the older, prototype-based syntax. Example code you find may be written in either, or even both, of these styles.)

Hope that helps!

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-window-examples.144524/