Anatomy of Windows

Fomar0153

Arkz
Restaff
Joined
Mar 13, 2012
Messages
1,240
Reaction score
231
First Language
English
Primarily Uses
N/A
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
125
Reaction score
45
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,240
Reaction score
231
First Language
English
Primarily Uses
N/A
Edit window_base then?
 

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

Latest Threads

Latest Profile Posts

Karen: Hi, I have a condition that prevents me from wearing a mask. :)

Employee: Can you tell me what it is?

Karen: >:(
Feeling a little overwhelmed... There are so many things to do.
- Building a simple website for portfolio
- Setup *******
- Manage social media
There are so many things inside of these tasks :(
Meet the cute little ghost, FhooFhoo. :kaopride:
If anyone here is looking for another high-potential RPGMaker game--besides She Dreams Elsewhere--be sure to follow Lawmage Academy. Good social media presence will take that game far.
Lol, I was about to write a small tutorial and realized it would belong to the MZ section ....that does not exist yet.

Forum statistics

Threads
99,575
Messages
966,825
Members
131,231
Latest member
Bektos
Top