Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-24-2011, 01:06 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
CuteGS2 GUI Builder

My latest (fun) side-project that consumed my scripting time these last couple days.

The main purpose of this was to create what I believe is "cuter" (and more flexible) GUI code.

Pretty much every function returns the object, or the object it created. Objects that are created are also joined to gui_builder which allows them access to the same functions. Which in practice allows me to write more "verbose" code. I.e:

PHP Code:
// assuming an object with the ID "Other" exists
createButton("New").  // Create Button with "New" as it's ID
  
position().         // Position it (Actually sets it position to 0,0 but below fixes the position)
    
below("Other").   // Below the "Other" object
    
offset(016).    // Offset it's position by 0 X and 16 Y
  
built();            // Button is now Built 
When you're done creating and manipulating an gui_builder object you call the built() function to leave the class, and it returns the parent of the object which allows you to traverse your creation in the same function call.

You can use catch/bind to catch events like onAction to your own functions. I.e: bind("onAction", "onButtonClicked").

I've also added dimensions(width, height) which allows you to change the clientwidth and clientheight of the object. This is much better explained with code however.

Example:

PHP Code:
function onCreated() {
  
this.join("gui_builder");
}

//#CLIENTSIDE
function onCreated() {
  
// Create Window
  // Calling it Test"Window" is kind of redundant since the builder automatically
  // places _Window at the end of it's ID.
  
createWindow("TestWindow").
    
features().
      
canclose().
    
dimensions(30010 32 13).
    
text("Test Window").
    
center();
  
  
// Add Buttons  
  
for (temp.button: {"Hello""Test""Winning"}) {
    
getWindow("TestWindow").
      
createButton(temp.button).
        
text(temp.button).
        
position(22).
        
sizing("width""").
        
dimensions(300 432).
        
below(temp.last2).
        
bind("onAction""onButtonClicked").
        
built();
    
temp.last temp.button;  
  }  
  
  
// Adding More Controls
  
getWindow("TestWindow").
    
// Add Text
    
createText("TestText").
      
profileMods().
        
profileMod("fontsize"20).
        
profileMod("fontstyle""b").
      
text("This is nifty!").
      
position().
        
below("Winning"2).     
        
center("x").
        
offset(-40).
      
built().
    
// Add Text Edit
    
createTextEdit("TestTextEdit").
      
copy("Winning""dimensions").
      
position().
        
below("TestText"2).
        
copy("Winning""x").
      
built();
      
  
// Add Checkboxes
  
for (temp.checkbox: {"A""B""C""D""E"}) {
    
getWindow("TestWindow").
      
createCheckBox(temp.checkbox).
        
dimensions(6016).
        
text(temp.checkbox).
        
position().
          
below("TestTextEdit"2).
          
offset(166).
          
rightOf(temp.last_check).
        
built();
    
temp.last_check temp.checkbox;
  }
  
  
// Add Radio Buttons
  
for (temp.radio: {"1""2""3""4""5"}) {
    
getWindow("TestWindow").
      
createRadioButton(temp.radio).
        
dimensions(6016).
        
text(temp.radio).
        
position().
          
below("A").
          
offset(016).
          
rightOf(temp.last_radio).
        
built();
    
temp.last_radio temp.radio;
  }
  
  
// TextList
  
getWindow("TestWindow").
    
createScroll("TestScroll").
      
copy("Winning""dimensions").
      
height(100).
      
position().
        
below("1"4).
        
offset(-160).
      
createTextList("List").
        
addRows({"Hello"player.account"OMG!""WTF?"}).
        
built().
      
built().
    
createScroll("TestMLScroll").
      
copy("TestScroll""dimensions").
      
position().
        
below("TestScroll"2).
      
createMLText("Description").
        
copy("TestScroll""dimensions").
        
adjust("width", -4).
        
text("What a nifty way to create GUIs fp4! Test 123 Hello World super star!!!").
        
built().
      
built();
  
  
// Window Finished
  
getWindow("TestWindow").built();

Output:





Functions:

PHP Code:
// See Script for Documentation
// GUI Creation Functions
createWindow(window_id)
createBitmapBorder(border_id)
createButton(button_id)
createCheckBox(checkBox_id)
createControl(control_id)
createMLText(mltext_id)
createMLTextEdit(mltextedit_id)
createPopUpMenu(popUpMenu_id)
createPopUpEdit(popUpEdit_id)
createProgress(progress_id)
createRadioButton(radioButton_id)
createScroll(scroll_id)
createSlider(slider_id)
createText(text_id)
createTextEdit(textEdit_id)
createTextList(textlist_id)

// GUI Accessors
getWindow(window_id)
getBorder(border_id)
getButton(button_id)
getCheckBox(checkbox_id)
getControl(control_id)
getMLText(mltext_id)
getMLTextEdit(mltextedit_id)
getPopUpMenu(popupmenu_id)
getPopUpEdit(popupedit_id)
getProgress(progress_id)
getRadioButton(radiobutton_id)
getScroll(scroll_id)
getSlider(slider_id)
getText(text_id)
getTextEdit(textedit_id)
getTextList(textlist_id)

// Debugging
debug(msg)

// GUI Object Positioning
above(objspace)
below(objspace)
leftOf(objspace)
rightOf(objspace)
position(txty)
center(center_pos)

// GUI Object Modifiers
adjust(av)
addRows(rows)
bind(ab)
built()
canResize()
canClose()
canMinimize()
canMaximize()
catch(
ab)
clear()
copy(cv)
dimensions(wh)
features(v)
height(v)
offset(txty)
profile(p)
profileMod(av)
profileMods(av)
set(av)
setValues(av)
setValue(av)
sizing(horizvert)
text(v)
width(v
Attached Files
File Type: txt gui_builder.txt (20.1 KB, 792 views)
__________________
Quote:
Reply With Quote
  #2  
Old 07-24-2011, 01:14 AM
MattKan MattKan is offline
the KattMan
Join Date: Aug 2010
Location: United States
Posts: 1,325
MattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to behold
Send a message via AIM to MattKan
<3
Reply With Quote
  #3  
Old 07-24-2011, 02:14 AM
fatcat123 fatcat123 is offline
Levels Artist
fatcat123's Avatar
Join Date: Aug 2010
Location: Wisconsin
Posts: 70
fatcat123 is an unknown quantity at this point
Nice
Reply With Quote
  #4  
Old 07-26-2011, 01:04 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I dunno...quite honestly i think the 'CuteGS2' code is more ugly that the original. Seems it just adds an unnecessary wrapper?
Reply With Quote
  #5  
Old 07-26-2011, 02:44 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Didn't see this earlier, very nice. I very much like this because it lets me avoid that weird object creation syntax.
Reply With Quote
  #6  
Old 07-26-2011, 09:44 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Twinny View Post
I dunno...quite honestly i think the 'CuteGS2' code is more ugly that the original. Seems it just adds an unnecessary wrapper?
It's interesting, but I agree...
__________________
Reply With Quote
  #7  
Old 07-26-2011, 10:01 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Twinny View Post
I dunno...quite honestly i think the 'CuteGS2' code is more ugly that the original. Seems it just adds an unnecessary wrapper?
To each their own, I just really like to chain function calls together.

Pretty sure my code should/would work like this too:

PHP Code:
with (createWindow("Test")) {
  
with (createButton("A")) {
    
// stuff...
    
built();
  }
  
built();

__________________
Quote:
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.