RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Window_Base Extension

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 89
I am yourself!
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.

Code: [Select]
#==============================================================================
# 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
  
« Last Edit: November 16, 2009, 10:17:21 AM by Sthrattoff »
Symphony of Alderra : Memoirs of Life

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

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
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

***
Rep:
Level 89
I am yourself!
Whoops...

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

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

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
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."

***
Rep:
Level 89
I am yourself!
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%

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.

***
Rep:
Level 86
I hate everyone except the ones I don't hate...
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!!

***
Rep:
Level 89
I am yourself!
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%

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
Did you run out of topics to post in and instead gravedug your own from last year? :|

lol

***
Rep:
Level 89
I am yourself!
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%