Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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, 828 views)
__________________
Quote:
Reply With Quote
 


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 11:25 PM.


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