Anatomy of Windows

Fomar0153

Arkz
Restaff
Joined
Mar 13, 2012
Messages
1,316
Reaction score
454
First Language
English
Primarily Uses
RMMZ
Also viewable: http://cobbtocs.co.uk/wp/?p=401

So I’ve been meaning to do this for a while and today I finally got nudged into doing this so let’s jump right into the anatomy of windows!

Firstly there are a lot of windows in RPG Maker Ace by default and if you’re scripting at some point you’re going to need to make a window. Which can be quite daunting and also waste a lot of your time when you’re trying to get it right. First let’s have a look at all the windows, the arrows indicate inheritance.



As you can see all windows inherit from Window_Base and there are several windows that act as bases for the other windows. Let’s strip it down to just the windows that are inherited from:



That’s a bit easier on the eyes now isn’t it? Also in case you’re not sure what I mean by inheritance, I’ll explain it quickly. Inheritance is where one class inherits from another class which is to say that it effectively copies all of the original classes methods and variables. So we can literally do this:



Code:
class Window_Name < Window_Base

end
And our new window Window_Name has everything Window_Base has, pretty cool huh?

Ok so now we need to decide what window to inherit from, generally it is going to be one of four:



So our first question should be are you using the window to just display information or is the player going to be able to select something in the window? Well if you just want to display things then all you really need to do is look at the drawing methods in Window_Base. If you want to have the window selectable then you need to know a few more things and we’ll go through them. The easiest way I think would be to go through the methods you’ll use/edit most. So let’s start there.



Window_Base

line_height – this is by default 24, the hight of an icon and the default font size. Useful with fitting_height which calculate the minimum window height given a number of lines.

standard_padding – if you ever need to get closer to the edge of a window then decrease this also if the window itself is not visible (self.opacity = 0) then this padding is wasted. By default this is 12.

Now going into Window_Selectable assume that the above remains unchanged unless I mention it again.

Window_Selectable

col_max – the number of columns by default 1.

spacing – the space between the coloums. 32 by default.

item_max – 0 by default, you need to change that if you’re going to display anything. I’m going to advocate having an array that contains the data you need to draw your items and then you can make this something like @data.size

item_width – you are very unlikely to need to change this, in fact if you think you need to change this then you should probably be looking at standard_padding and spacing. This automatically calculates the width your item should have.

item_height -this is by default the same size as line_height, you should only need to change it if you for example have have the battle hud in columns and not rows and need to make the cursor bigger. Or maybe you want to display more information about items and want each items to have another row of space to work with.

item_rect -this gets you a rect based on the item number this rect is also the one which the cursor uses. In general you should use item_rect_for_text

item_rect_for_text -Basically item_rect but with four pixels cut off each side, basically stopping the cursor obscuring the first or last letters of anything you put.

Also in case you didn’t already know you need to write a draw_item method a standard one would get a rect from item_rect_for_text and then used it to position everything.

Window_Command

Right a few changes this time Window_Command uses @list to store the data for drawing (item_max is automatically done for you in Window_Command) and you should add them using add_command. Which accepts two to four parameters

name, symbol, enabled, ext

name is what’s displayed to the players, symbol is something like :identifier and enabled is whether or not they can click that option by default this is true and I don’t know what ext does I’ve never used it.

visible_line_number – how many rows before the command window scrolls.

make_command_list – this is where you should really be adding commands to the window, it’s called when the window is made and again everytime the command wndow is refreshed.

Window_HorzCommand

There’s no real difference for you between this and Window_Command except if you want this window to scroll. There is a bug with the default scripts and I don’t know if they fixed it yet. If when you make a scrolling HorzCommand window it scrolls but doesn’t work right add this code to your project:



Code:
class Window_HorzList < Window_HorzCommand
#--------------------------------------------------------------------------
# * Set Leading Digits - BUGFIX
#--------------------------------------------------------------------------
def top_col=(col)
col = 0 if col < 0 col = item_max - (col_max - 1) if col > item_max - 1
self.ox = col * (item_width + spacing)
end
end
 
Last edited by a moderator:

Rafael_Sol_Maker

Almighty God Jabu
Veteran
Joined
May 8, 2012
Messages
127
Reaction score
46
First Language
Portuguese
Primarily Uses
RMMV
Good schematic you posted. I really wanted something like this (a good hierarchical commented guide to Windows) do help me to develop some new Window_ classes. I already checked out your blog and I found lots of useful things!

As a suggestion, I would like to see the scheme of the basic battle processing (all battle phases), as I think it would be useful for someone who wants to edit the default battle system.
 

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
75
First Language
English
Primarily Uses
Im working on a script and I ran into a problem. Do you know of a way I can change the default opacity of all the windows without having to change each scene.
 

Fomar0153

Arkz
Restaff
Joined
Mar 13, 2012
Messages
1,316
Reaction score
454
First Language
English
Primarily Uses
RMMZ
Edit window_base then?
 

The_Sarah

Let's make great games together!
Veteran
Joined
Jul 18, 2020
Messages
100
Reaction score
79
First Language
English
Primarily Uses
RMVXA
Hella useful!
Thanks for this.
I'm currently trying to add an additional Actor Command Window in battles - to be used for Sub Commands in the same turn you select your initial Actor Command (made a post about it but no-one's replied yet :( ).
This at the very least has helped me understand what goes into those windows and what I need to consider when making my new ones.

Now if only I could figure out how to get the game to summon this new window after inputting your first (primary) battle action... lol.

Thanks again! I know more than I did before and will likely put this information into practice very soon.
You rock!
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
287
Reaction score
70
First Language
English
Primarily Uses
RMXP
If I remember clearly how Ace works, the most important calls would be...

@window = MyWindow.new(Pass parameters if needed)
@window.show
@window.hide
@window.dispose

show not only makes it visible, it also changes the window's index in case it was hidden and later activates the window.

Nope, you don't need to automatically show it just because you created it, actually it's up to you if you wanna do that at the same point or just wait for a better moment to do that like in a different method.

For those still using XP, you gotta know that show and hide didn't exist back then. Instead you'd need to use...

@window.visible = true
@window.active = true

And then set them to false to deactivate or hide them. IIRC active would make the cursor show up automatically.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Ami
--- Currency ---

Hero: This city cannot accept Gold to buy the items.
Merchant: You can exchange Gold into TC,depending the rate of TC this time.
Hero: Really? Then,i want to exchange 999999999G.
Merchant: Let's see……Wait a second,are you Cheating again?
Hero: Hell No!!! I earn it with myself!!!
There's always a time when you're super excited to create something but you already have no energy left. :I
I think of all the effects in my game, the light passing through fog has got to be my favorite....

...Also I spent all day trying to figure out how I had suddenly messed it up and made it start dropping frames like crazy. So I had all day to look at it... mocking me... with it's previous 60fps reduced to 30fps... At least it's fixed now.
Dalph wrote on slimmmeiske2's profile.
Slimmm, we should team one day and make "Reid in Wonderland" or "Aluxes in boots".

Forum statistics

Threads
103,480
Messages
999,645
Members
135,027
Latest member
Weaversenpai
Top