Main Menu
  • Welcome to The RPG Maker Resource Kit.

Window_Base Extension

Started by Sthrattoff, January 02, 2008, 11:10:23 AM

0 Members and 1 Guest are viewing this topic.

Sthrattoff

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
 
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

Zeriab

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

Sthrattoff

Whoops...

edit: first post fixed.
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

Tsunokiette

I went ahead and added the last end. It was driving me crazy O_O lol.

Great job on the script BTW. ^_^
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They're bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I'm the only one, I'm the only one."

Sthrattoff

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?
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

modern algebra

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.

Demonic Blade

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)
I wonder how many of my-reps are there for a reason, and not just because some jackass wanted to show off in front of some other jackasses...?
Probably a lot of them - and those people sure as hell don't deserve my pity, let alone my disgust.
That's right, let's see some more -Rep'ing! BOOYEAH!!

Sthrattoff

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.
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

Grafikal

Did you run out of topics to post in and instead gravedug your own from last year? :|

lol

Sthrattoff

Just a start of a resurrection. I am looking for an idea and begin working on it.
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%