GUI -> My Widgets Classes

Widget
Version: 2.02

Introduction

You've dreamed of text boxes, mouse support interfaces or drag and drop windows/icon?
This script is for you

Features
The actual support:
  • Button
  • Check_Box
  • Icon
  • Progress Bar
  • Scroll Bar
  • Text Box(including a scrollbar for it)
  • Menu button
  • Menu_CheckButton
  • Drag&Drop for icons and windows(including all widgets within it)
  • Close window button
  • Window_Selectable works with the mouse too
  • On"Eventname" methods(On_close, on_click_left, etc...)
  • Don't need to be updated or disposed
  • Easily usable, and extendable
  • Tool Tip/Help message

Ressource
http://rmxp.trebor777.net/rmxp/widget_skin.png[/img]

Screenshots
these pictures are quite old, but it didn't change a lot :p Spoiler


Demo

Link

Scripts:

RSC file

Here we go!!
Paste the scripts in the same order as here. right after the Aleworks scripts

http://rmxp.trebor777.net/rmxp/widgets/01_Added_functions_for_Input_module.txt
http://rmxp.trebor777.net/rmxp/widgets/02_widgets.txt
http://rmxp.trebor777.net/rmxp/widgets/03_button.txt
http://rmxp.trebor777.net/rmxp/widgets/04_check_box.txt
http://rmxp.trebor777.net/rmxp/widgets/05_Icon.txt
http://rmxp.trebor777.net/rmxp/widgets/06_Progress_bar.txt
http://rmxp.trebor777.net/rmxp/widgets/07_Scroll_bar.txt
http://rmxp.trebor777.net/rmxp/widgets/08_Text_box.txt
http://rmxp.trebor777.net/rmxp/widgets/09_Text_Box_Scroll_bar.txt
http://rmxp.trebor777.net/rmxp/widgets/10_Menu_Button.txt
http://rmxp.trebor777.net/rmxp/widgets/11_Menu_check_button.txt
http://rmxp.trebor777.net/rmxp/widgets/12_Window_Base.txt

Instructions

It requires 2 set of scripts in order to work properly:
the SDK 2.2
Aleworks Input Module 2.00

All the instructions are at the beginning at of each script.

You need to know:
Declarations can be done almost everywhere, usually inside a scene or a window.
Icons don't need a window(in this case use nil), if you use one, the icon will be inside that window.
The tooltip feature is defined in the widget class.

Widgets inherits the window's visibility at creation or each time the window's visibility changes, but not the contrary. So you can hide a window and not a text box in it.

the drag area is: the top margin.
the close window button area: is the right top corner, a square of 10px.
scroll bars appear/disappear when needed

About the progress bar... you need, in your loop/process or whatever, to increase/decrease the current_step value in order to show the progress.

Only one window or icon(see icon class) can be drag at the same time

The update or disposal widgets are executed when the window is updated or disposed. Except for Icons.

The windows features can be set dynamically, using these properties:
dragable, if true, the window can be dragged and dropped on screen.
scalable, if true, the window can be resized with the mouse by click & drag on the right bottom corner, in a square of 10px. A set of scrollbars should be defined by users.
clickable, if true, when the window is cliked, (right or left), call the On_click_left/right methods(empty by default). (Windows selectable are set to "active=true"). Also detects clicks outside the window and execute the out_click method(Windows selectable are then set to "active=false").
closable, if true, the window can be closed by clicking the right top corner,(set invisible and inactive, including all the widgets).

The widget class also provides the click event methods.
  #--------------------------------------------------------------------------
  # * On Click Left - Called when the mouse left button clicks the widget.
  #      block : A block must past trough here.
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # * Out Click Left - Called when the mouse left button clicks outside the widget.
  #      block : A block must past trough here.
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # * On Click Right - Called when the mouse right button clicks the widget.
  #      block : A block must past trough here.
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # * Out Click Right - Called when the mouse rightt button clicks outside the widget.
  #      block : A block must past trough here.
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # Clicked - This method is called when the mouse left clicks the widget.
  #          Can be used if the class is child of Widget class.
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # OutClicked - This method is called when the mouse left clicks outside
  #              the widget. Can be used if the class is child of Widget class.
  #--------------------------------------------------------------------------

About tool tip:
It can be change dynamically.
It uses a string or an array of strings(for displaying more than one line). But other types will be converted to a string and then to an array of strings, just in case.

'Code Example for text box' Spoiler
my_window = Window_Base.new(10,10,128,96)
my_text_box = Text_Box.new(my_window,0,0,100,50,1)
# Create a 100px wide Text Field at 0,0 in my_window, which allows to write 50 characters.
# The text box contains 1 line.

#...in the update method in your scene, just update the window:
my_window.update

#to use the text from the text box:
my_text_box.text
# you can set it:
my_text_box.text='blabalbla'

# if the box covers more than 1 line, you can need to allow new line entry:
my_text_box.nl_able=true
# If true, you need to press Shift+Enter to create a new line, (like in MSN Messenger).
# It's disabled by default.

#===========================
# if you define a window class, you can of course define widgets into it, using self:
class My_Window < Window_Base
   def initialize(....)
       ...
       @my_text_box = Text_Box.new(self,0,0,100,50,1)
   end
   ...
end


Expand to see the code.



FAQ

I got some errors...?
- Well, tell me, exactly what you done, it's a bit in beta for the moment ;p, i need more test:p so go people test it!

I'm not a scripter.. how I use it??
- Hell ! What are doing here?! Go learn ruby my friend!


Compatibility

Well use some features of the SDK, but not compliant to all the rules... >_>

Credits and Thanks

MrMo for helping me, in the documentation and some correcting some code.
Author's Notes
Written originally for Netplay+ 2.0
As it's really usefull, I'm releasing it for everybody.
Nice stuff here. I might use this in RMPaint ;) Also, I PMed you with the rsc editor. I'm sure you can figure out how to use it. (It's a near-replica of RMXP's script editor)
Please, upload a demo, please^^

Fof far i can see, they are good scripts^^
Quote:
As it's really usefull, I'm releasing it for everybody.


No kidding. Sure would've liked to see this a couple months ago :)

You might want to toss something in there about commercial use. For anyone making one of those games, implementing this sort of stuff well will help with sales
rsc file done.:p thx to you Yeyinde^^ nice application^^

First post edited:p
Hmm..honestly, I don't understand what it does. Can someone tell me what this is? lol
xD no way...
you don't know what is a text box or a progress bar ? or those kind of interface tools?
Lol, I do. But like...whats being added thats not already in RMXP? Text box is there, and progress bar meh...
xD... text box= text_field :p where you can type text using your keyboard, not display it...
and... read the features >_< everything is there...


EDIT
I've added old screenshots from Netplay+ 2.0 dev...
Trebor, you should release the Dialog Box(Window_Dialog and Show_Dialog), which are one of my favorite classes because it is SO simple, yet SO useful. Perhaps the Listbox and DropDown Menu as well. They are all documented. You need the DropDown Menu to use the Menu buttons anyways.

[QUOTE=Gir;212584]Lol, I do. But like...whats being added thats not already in
RMXP? Text box is there, and progress bar meh...[/QUOTE]

What? Sir, do you know RGSS?
I didn't released them cause it require the CG::Window librairy from Selwyn.
(as you use the margin feature.)
oh, yeah.

CG::Window should be used in every game ;)
I'll probably release an add-on :p with your stuff and the CG::window.
Amazing job trebor777! Way to think outside the box :P
I've edited the first post to include a basic window_skin for this script. (so you can see where you can drag/close/resize the window)
Some things:
Quote:
Aleworks Input Module 2.20

It is on version 2.00.
Quote:
AIM Add On 3

Can do you change the name? I reserve the AIM Add On # for official(Maked by me) add ons.
And change the "AIM Add On 3" description, it's equal to the AIM Add On 2 description.
arf ok, no problem ^_^
I'll edit the rsc file later.
please give demo
i tried to do that and i faild
so please give us a demo
i saw it the N+ 2.00 beta and this is very cool thing
if you do not know how to script, don't use this....
this is show me an error that the input script is missing and i putted them in the list
You have to add the complete ALEWORKS Input Module v2.00, and the SDK 2.2
before my script.
I suggest you used the rsc file that I provide. and use the rsc files for the SDK and Input Module.

Look at Yelinde's thread: http://www.rmxp.org/forums/showthread.php?t=21163
can you up load an example of what to do?
the RSC file works but 1 script is missing "AIM Add On 3"
>___< it's not possible....as this script is inside the rsc file.
btw I've updated the rsc file, in order to respect vgvgf request. - nothing have change, in the code.

here is a rsc file for the Input module: http://rmxp.trebor777.net/rmxp/Aleworks_Input_2.0.rsc

So your script list must look like something like this:

"RSC loader" ( the script given in Yelinde Thread)
all default scripts except "Main"
The "Require" script: which contain this code (adapted to the name and location of rsc files), in this case, the rsc files are in the Data folder:
require 'Data/SDK'
require 'Data/Aleworks_Input_2.0'
require 'Data/Widget'
Expand to see the code.

and the "Main" script

An example, create a scene, create a window
in this window...just create a widget object...following instructions given in the comments.

If you don't know how to create the first 2 things, don't bother trying yo use my widgets.

EDIT:
I've added an example for text box in the first post.
now it's works
This library is very useful for scripters, no need to reinvent the wheel anymore.
Just a quick suggestion about Window Features : you should make the rectangles which command dragging/scaling/closing attr_accessor. Right now, if you want to change one of those (example : a window you can drag by clicking anywhere) or if you use a slightly different window skin, you have to create your own class .

Did I say this script was excellent ?
hum yes you're right ^^ I should make them editable more easily.
I think there is still a lot to improve in this script. But I don't always see what to improve.

Thanks^^ for your comment.
I'm not sure if you've noticed this bug or not, but whenever the mouse moves outside of the game window, An error pops up because @mouse_pos is nil and thus input.mouse_x and Input.mouse_y will return errors. I added the following to your AIM edits and that bug disappeared, though it may cause other errors, I'm not sure. I think it should be fine though.

  #---------------------------------------------------------------------------
  # * Mouse X Coordinate
  #---------------------------------------------------------------------------
  def Input.mouse_x?
    unless @mouse_pos == nil
      @mouse_pos[0]
    else
      return -1
    end
  end
  #---------------------------------------------------------------------------
  # * Mouse Y Coordinate
  #---------------------------------------------------------------------------
  def Input.mouse_y?
    unless @mouse_pos == nil
      @mouse_pos[1]
    else
      return -1
    end
  end
Expand to see the code.
It doesn't crash in my project...
not even in the title screen? or whenever a window is shown? oh well. It does for me...

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=21182