The script pieces I posted are used inside window's class. Since I've got a little bit of free time, I'll break down how a window works and how to use the script pieces I posted. It's a bit much to take in all at once so you might want to read part of it and then finish the rest later.
This is the standard MenuStatus window from the vanilla(unaltered) database. The only time a window class inherits from Window_Selectable is when the window will be used as an interface, like the actor window in the default menu.
class Window_MenuStatus < Window_Selectable
def initialize
super(0, 0, 480, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
refresh
self.active = false
self.index = -1
end
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 116
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x, y + 32)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_exp(actor, x, y + 64)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
def initialize
Obviously, the start of the method.Like the method name suggests, this is what is done when the window is created inside a scene. Read the notes inside here for a bit by bit break down on how the first method works.
super(0, 0, 480, 480)
super(x, y, width, height)
self.contents = Bitmap.new(width - 32, height - 32)
This creates the bitmap everything is put on. It is one of the FIRST things you should do after using super to set the windows dimensions and such.
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
#Main cause of the "I can't see the text" issue. Any time I do a CMS or project that uses windows, I tend to define $defaultfontsize and $defaultfonttype at the top of the script to ensure that there are no "I can't see text!" issues.
refresh
This calls the method refresh.
self.active = false
If this isn't the main command window of the scene, then you probably want this set to false. The only time you define this is when the window inherits from Window_Selectable.
self.index = -1
#Window_Selectable removes the window selection bracket on this window if the index is -1.
end
End of the method. When using "if" statements and such, it is wise to leave a comment stating which of your end syntax is used to end what syntax like I did below.
def method_name
if foo == bar
do_something
end#of if foo == bar
end
Completely unrelated but still useful to know. If you are checking to see if two variables are the same or equal to each other, you want to use == instead of = since a lone equal sign is quite often interpreted as "Let's store this variable in this one!" even when it's clearly a conditional branch. I was quite frustrated with conditional branches until someone pointed this out to me.
Remember those script pieces I posted in this thread back in March? This is where they'd go. I don't look at other peoples scripts very often any more but this is where I put EVERYTHING that shows up in a window.
def refresh
Obviously, defines the method name.
self.contents.clear
Clears the bitmap of everything.
@item_max = $game_party.actors.size
Stores the number of party members you have in @item_max.
for i in 0...$game_party.actors.size
for 0(zero) to maximum number of party members you have. For a full party, "i" would be 0, 1, 2, and 3. You'll see what I mean in just a moment. Although...Enterbrain COULD have "for i in 0...@item_max"...
x = 64
Stores 64 in x.
y = i * 116
y = i * 116 is basically the same as below.
y1 = 0 * 116 #means the same as y1 = 0
y2 = 1 * 116 #means the same as y2 = 116
y3 = 2 * 116 #means the same as y3 = 232
y4 = 3 * 116 #means the same as y4 = 348
The "for" syntax eliminates the need for defining several variables that are used for the same task. You'll plenty more examples of this in a moment and how important what we just stored in y is as well as how i plays into it.
actor = $game_party.actors[i]
This stores each actor of the party in the variable actor. This is passed on to the methods in Window_Base that make up the things displayed in a window.
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x, y + 32)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_exp(actor, x, y + 64)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
Would you like to have to call each of those methods four(4) times? No? Well, this is why the "for" syntax is useful. It cuts down on the amount of variables and lines you use. The best way to learn how to use the "for" syntax is by using it. Actually, the the best way to learn anything in RGSS is by trying it out...or so it was for me but every one is different. Just remember that more lines=more lag generated. RGSS isn't a compiled language so it requires a bit more processing power to convert the scripts into a form that the computer can understand and process.
end#of "for i"
end#of refresh
Remember what I said about noting your "end" syntax? It helps you remember which "end" syntax is for the other syntax
To use the script pieces I posted way back in March, you'd do something like this. Just remember that the width and height variables are defined in "initialize" the moment you use "super".
class Window < Window_Base
def initialize
super(x, y, width, height)
self.contents = Bitmap.new(width, height)
refresh
end#of initialize
def refresh
self.contents.clear
bitmap = RPG::Cache.icon("034-Item03")
self.contents.blt(100, 4, bitmap, Rect.new(0, 0, 24, 24))
end#of refresh
end#of class
I attached three of the CMS's I've made that I actually like but the All-in-One-Menu I did for Trenzor was a bitch to get working. The menu I did for Chibidestiny requires a small faceset inside a folder called "Faces" inside the Character folder. Just use a black or white picture scaled 66X66. I uploaded the three menus in .txt file format because they're small and quick d/ls even for 56k users as well as easy on my hard drive space. These are for your learning purposes mainly.