Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-12-2010, 01:19 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
GUI Explorer

Well I was needing a way to navigate throughout GUI Objects, to see what kind of things I could find. An hour later, I finished this tool to do so.

Weapon script:

PHP Code:
//#CLIENTSIDE

// Variables
function onCreated() {
  
this.defaultGUI "GUIContainer";
}

// Allows opening of GUIExplorer with
// Chat command: /guiexplorer 

function ChatBar.onAction() {
  if (
ChatBar.text == "/guiexplorer") {
    
ChatBar.text "";
    
createGUI();
  }
}

// Create Main GUIExplorer

function createGUI() {
  new 
GuiWindowCtrl("GUIExplorer") {
    
profile GuiBlueWindowProfile;
    
isexternal true;
    
clientextent true;
    
extent "600,600";
    
canresize false;
    
destroyonhide true;
    
text "GUI Explorer";
    new 
GuiScrollCtrl("GUIExplorer_Scroll") {
      
profile GuiBlueScrollProfile;
      
10;
      
extent "280,280";
      
hScrollBar "dynamic";
      
vScrollBar "dynamic";
      new 
GuiTreeViewCtrl("GUIExplorer_Tree") {
        
profile GuiBlueTreeViewProfile;
        
0;
        
fitparentwidth true;
        
clearnodes();
      }  
    }
    new 
GuiTextEditCtrl("GUIExplorer_Source") {
      
profile GuiBlueTextEditProfile;
      
10;
      
GUIExplorer.height 56;
      
height 20;
      
width GUIExplorer.width 32;
      
text "";
      
thiso.catchevent(this.name"onAction""onLoadSource");
    }
  }
  
onLoadSource(GUIExplorer_Source);
  
  
setTimer(0.05);
}

// Create Object Dump GUI

function createObjectDump(obj) {
  new 
GuiWindowCtrl("GUIExplorerDump_" obj.name) {
    
profile GuiBlueWindowProfile;
    
isexternal true;
    
clientextent true;
    
extent "600,600";
    
canresize false;
    
destroyonhide true;
    
text "GUI Object Dump";
    new 
GuiScrollCtrl("GUIExplorerDump_Scroll_" obj.name) {
      
profile GuiBlueScrollProfile;
      
10;
      
extent "570,550";
      
hScrollBar "dynamic";
      
vScrollBar "dynamic";
      new 
GuiMLTextCtrl("GUIExplorerDump_Text_" obj.name) {
        
profile GuiBlueMLTextProfile;
        
0;
        
width 540;
        
height 540;
        
text "";
        
temp.textobj this;
      }
    }
  }

  
// Display Object Dump
  
temp.textobj.text getDump(obj);
}

// Sets Root Node and Repopulates Tree.

function onLoadSource(obj) {
  
// Trim text
  
obj.text obj.text.trim();
  
// Default Text
  
if (obj.text == ""obj.text this.defaultGUI;
  
// Populate Tree
  
GUIExplorer_Tree.clearnodes();
  
populateNode(GUIExplorer_Treemakevar(obj.text));
}

// Recursively populates node with children.

function populateNode(parentNodeparentObj) {
  
// Idiot Protection
  
if (parentObj.name == "GUIExplorer_Tree") return;
  
// Check if parentObj is Object
  
if (parentObj.type() == 0) {
    
temp.node parentNode.addNode("Could not locate object!");
    
with (temp.node) {
      
image selectedimage 2;
    }
    return;
  }
  
// Add Node
  
temp.newNode parentNode.addNode(parentObj.name);
  
// Populate Children Data
  
if (parentObj.controls.size() > 0) {
    
// Children found
    
for (temp.childObjparentObj.controls) {
      
populateNode(temp.newNodetemp.childObj);
    }
  } else {
    
// Does not have Children
    
with (temp.newNode) {
      
image selectedimage 2;
    }
  }
}

// Opens Object Dump when a Node is Double-clicked.

function GUIExplorer_Tree.onDblClick(node) {
  
// Avoid Error Node
  
if (node == "Could not locate object!") return;
  
// Display Dump
  
createObjectDump(makevar(node));
}

// Resizes Appropriately

function GUIExplorer.onResize() {
  
with (GUIExplorer_Scroll) {
    
width GUIExplorer.width 20;
    
height GUIExplorer.height 40;
  }
  
with (GUIExplorer_Source) {
    
GUIExplorer.height 26;
    
width GUIExplorer.width 20;
  }
}

// Dump Functions
function getDump(obj) {
  
temp.dump getVal(obj);
  
temp.dump @= " {\n";
  
temp.vars obj.getvarnames();
  for ( 
temp.0temp.temp.vars.size(); temp.++ )
    
temp.dump @= "  "temp.vars[i] @" = "getValobj.(@ temp.vars[i] ) ) @";\n";
  
temp.dump @= "};";
  return 
temp.dump;
}

// Credits to Novo for this function.
function getValval )
{
  switch ( 
val.type() )
  {
    case 
0: case 1:
      return 
"\""val @"\"";
    break;
    case 
2:
      return 
val.objecttype() @"("val.name @")";
    break;
    case 
3:
      
temp.dump "{";
      
temp.count 0;
      for ( 
temp.count 0temp.count val.size(); temp.count ++ )
      {
        if ( 
count != )
          
temp.dump @= ", ";

        
temp.dump @= getValvaltemp.count ] );
      }
      
temp.dump @= "}";
      
      return 
temp.dump;
    break;
  }
  
  return 
"\"\"";

You can get an object dump by double-clicking a node in the tree.

To change the root object, just type it in to the text-box and press enter.

Possible Future Features:
- Live Editing of Values
- Improved Tree Navigation (See parent, etc.)

See attachments for imagery.

Enjoy, and happy GUI exploring.
Attached Thumbnails
Click image for larger version

Name:	guiexplorer1.png
Views:	714
Size:	83.6 KB
ID:	50396   Click image for larger version

Name:	guiexplorer2.png
Views:	643
Size:	94.7 KB
ID:	50397  
__________________
Quote:

Last edited by fowlplay4; 02-12-2010 at 02:51 AM..
Reply With Quote
  #2  
Old 02-12-2010, 01:56 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Cool stuff

I like how you set up the tree system... does it take into consideration children of children? If it doesn't, I think that'd be a good set-up.

Also, while the dump is useful I think it's fairly messy. I think it should be better formatted. For one, use a fixed width font like courier new. Two, better divide the GUI's. Maybe a format like:

PHP Code:
NameOfGui (typeGUIWindowCtrl):
  var = 
[integer]
  
var2 "foo" [string]
  
var3 = {0,0} [array] 
As well as spacing between the GUI's, to quickly differentiate one GUI from the next.
Reply With Quote
  #3  
Old 02-12-2010, 02:09 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
Quote:
Originally Posted by DustyPorViva View Post
Cool stuff

I like how you set up the tree system... does it take into consideration children of children? If it doesn't, I think that'd be a good set-up.
Thanks, and yeah it recursively travels all the way down each branch until it can't find any child controls. So you'll be able to see all that GUIContainer offers.

Modified the script so people can write their own dumping functions.
__________________
Quote:
Reply With Quote
  #4  
Old 02-12-2010, 02:15 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Excellent, nice work .
__________________
Reply With Quote
  #5  
Old 02-12-2010, 02:16 AM
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
Sweet job, been thinking about something like this lately.
Reply With Quote
  #6  
Old 02-12-2010, 02:42 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Just noticed, you should probably start with GUIContainer as the base GUI, not GraalControl.
__________________
Reply With Quote
  #7  
Old 02-12-2010, 02:53 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
Quote:
Originally Posted by cbk1994 View Post
Just noticed, you should probably start with GUIContainer as the base GUI, not GraalControl.
Noted, added a default GUI variable.
__________________
Quote:
Reply With Quote
  #8  
Old 02-28-2010, 07:30 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura about
Send a message via AIM to adam
Nice.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:18 AM.


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