I can't remember if I ever post this or not when on Blizzard Age, but just in case, I'll post this.
This is a simple Window_Base Extension, adding capabilities for Window_Base to draw FACE and BAR.
Usage:
draw_bar(curr_val, max_val, color, x, y, w, h)
draw_face(file, x, y)
The picture for face must be in 72x72 pixel, and imported in Pictures.
#==============================================================================
# Window_Base Extension
# © 2007 by Sthrattoff
#==============================================================================
class Window_Base < Window
# Add capability to draw a general bar
def draw_bar(curr_val, max_val, color, x, y, w, h)
#--------------------------------------------------------------------------
# curr_val : current value of bar
# max_val : maximum value of bar
# color : an array of color (RGB)
# x : bar's x position
# y : bar's y position
# w : bar's width
# h : bar's height
# -------------------------------------------------------------------------
much_to_fill = (curr_val * 1.0 / max_val) * (w - 2)
border = Rect.new(x, y, w, h)
empty = Rect.new(x + 1, y + 1, w - 2, h - 2)
fill = Rect.new(x + 1, y + 1, much_to_fill, h - 2)
self.contents.fill_rect(border, system_color)
self.contents.fill_rect(empty, Color.new(0, 0, 0, 255))
self.contents.fill_rect(fill, Color.new(color[0], color[1], color[2], 255))
end
# Add capability to draw face
def draw_face(file, x, y)
#--------------------------------------------------------------------------
# file : picture's file name (please include the file's extension)
# x : picture's x position
# y : picture's y position
#--------------------------------------------------------------------------
self.contents.blt(x, y, RPG::Cache.picture(file), Rect.new(0, 0, 72, 72))
end
end
Why are you adding the methods to Scene_Menu while you say it is a Window_Base extension.
You are missing the last end. You probably didn't copy it.
There are some syntax errors. I suggest at the least try to run once before posting. You can quickly sort out the syntax errors.
As for the usage I suggest you give some concrete examples in addition to what you have now.
I look forward to your revision ^_^
*hugs*
- Zeriab
Whoops...
edit: first post fixed.
I went ahead and added the last end. It was driving me crazy O_O lol.
Great job on the script BTW. ^_^
Hey, I want to add more capabilities, but I'm running out of idea.
Can somebody help? Subscribe anything, I'll give it a shot.
And, anybody test this thing?
No, but it looks like there are still syntax errors.
Just from a quick look, I think the second fill_rect in the bar method and the blt in the draw_face method are both missing end brackets.
As for suggestions, I don't have much. I would suggest maybe making your methods a little easier to use. As it is, your draw_face method only works for 72 x 72 facesets. It would be useful to perhaps either draw the entire file or at least allow a size argument to be passed to see how large the faceset should be.
How about drawing animated faces and bars? And how about making this for VX too? Or how about the ability to make ROUND windows? (It's needed for the CMS I am requesting in a couple days or so)
Quote from: modern algebra on April 20, 2008, 08:03:56 PM
No, but it looks like there are still syntax errors.
Just from a quick look, I think the second fill_rect in the bar method and the blt in the draw_face method are both missing end brackets.
As for suggestions, I don't have much. I would suggest maybe making your methods a little easier to use. As it is, your draw_face method only works for 72 x 72 facesets. It would be useful to perhaps either draw the entire file or at least allow a size argument to be passed to see how large the faceset should be.
Fixed the missing brackets.
Did you run out of topics to post in and instead gravedug your own from last year? :|
lol
Just a start of a resurrection. I am looking for an idea and begin working on it.