View Single Post
  #13  
Old 10-07-2006, 01:35 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
And now : the conclusion

PHP Code:
/* Practical Lesson 2 */

function turnon()
{
  
this.on = true;
  
GUIContainer.addControl( Debugger_Window );
  
Debugger_Window.show();
  
getNodes();
}

function 
onPlayerEnters()
{
  if ( !
this.on )
    return;
  
Debugger_Tree.clearnodes();
  
getNodes();
}

function 
turnoff()
{
  
this.on = false;
  
Debugger_Tree.clearnodes();
  
Debugger_Window.hide();
}

function 
addGuiControls()
{
  new 
GuiWindowCtrl("Debugger_Window" )
  {
    
profile = "GuiBlueWindowProfile";
    
position = "440 0";
    
width = 600;
    
height = GUIContainer.height;
    
canMove = canClose = canMinimize = true;
    
canResize = canMaximize = false;
    
text = "Object Browser";
    
visible = false;

    new 
GuiScrollCtrl("Debugger_Scroll") {
      
profile = "GuiBlueScrollProfile";
      
horizSizing = "width";
      
vertSizing = "height";
      
position = "5 23";
      
extent = "590" SPC Debugger_Window.height - 28;
      
willFirstRespond = true;
      
hScrollBar = "dynamic";
      
vScrollBar = "alwaysOn";
      
tile = true;

      new 
GuiTreeViewCtrl("Debugger_Tree") {
        
profile = "GuiBlueTreeViewProfile";
        
x = y = 0;
        
fitparentwidth = true;
        
clearnodes();
      }
    }
  }
}

function 
getNodes()
{
  
CaddNode( Debugger_Tree, allplayers, "allplayers" );
  
CaddNode( Debugger_Tree, players, "players" );
  
CaddNode( Debugger_Tree, player, "player" );

  
CaddNode( Debugger_Tree, npcs, "npcs" );
  
CaddNode( Debugger_Tree, player.weapons, "weapons" );
  
CaddNode( Debugger_Tree, player.level, "level" );


  
CaddNode( Debugger_Tree, compus, "compus" );
  
CaddNode( Debugger_Tree, bombs, "bombs" );
  
CaddNode( Debugger_Tree, arrows, "arrows" );
  
CaddNode( Debugger_Tree, items, "items" );
  
CaddNode( Debugger_Tree, horses, "horses" );
  
CaddNode( Debugger_Tree, signs, "signs" );

  
CaddNode( Debugger_Tree, GUIContainer, "GUIContainer" );
  
CaddNode( Debugger_Tree, GraalControl, "GraalControl" );
}

function 
Debugger_Tree.onSelect( node )
{
  
with ( node )
  {
    
clearnodes();
    switch ( 
this.nodereturn.type() )
    {
      case 
"0": case "1":
        
CaddNode( node, node.nodereturn, node.nodeparent @"."@ node.nodename );

        
temp.i = getObjKeys( node.nodeparent @"."@ node.nodename @"." );
        for ( 
temp.v: temp.i )
          
CaddNode( node, node.nodereturn.(@ temp.v ), node.nodename @"."@ temp.v );
      break;
      case 
"2":
        
temp.f = node.nodereturn.getFunctions();
        
CaddNode( node, temp.f, "functions" );
        
temp.i = node.nodereturn.getVarNames();
        for ( 
temp.v: temp.i )
          {
          if ( (
temp.v in temp.check) )
            continue;
          
temp.check.add( temp.v );

          
temp.j = getObjKeys( node.nodereturn, temp.v @".");//.getVarNames();
          
for ( temp.k: temp.j )
            
CaddNode( node, makevar("node.nodereturn."@ temp.v @"."@temp.k) , temp.v @"."@ temp.k );
          
CaddNode( node, makevar("node.nodereturn."@ temp.v) , temp.v );
          }
      break;
      case 
"3":
        for ( 
temp.i = 0; temp.i < node.nodereturn.size(); temp.i ++ )
          
CaddNode( node, node.nodereturn[ temp.i ], "["@ temp.i @"]");
      break;
    }
  }
}

function 
CaddNode( node, obj, varname )
{
  
with ( node )
  {
    switch ( 
obj.type() )
    {
      case 
"0": case "1":
        
with ( addNode( varname SPC "=" SPC ParseValue(obj) @";" ) )
        {
          if ( 
node.returntype.type() == 3 )
            
this.parentnode = node.returntype;
          else 
this.parentnode = node.parentnode;
          return 
this;
        }
      break;
      case 
"2":
        
with ( addNode( varname SPC "=" SPC ParseValue( obj ) @";" ) )
        {
          if ( 
node.returntype.type() == 3 )
            
this.parentnode = node.returntype;
          else 
this.parentnode = node.parentnode;
          
this.nodereturn = obj;
          return 
this;
        }
      break;
      case 
"3":
        
with ( addNode( varname SPC "= new["@ obj.size() @"];" ) )
        {
          if ( 
node.returntype.type() == 3 )
            
this.parentnode = node.returntype;
          else 
this.parentnode = node.parentnode;

          
this.nodereturn = obj;

          return 
this;
        }
      break;
    }
  }
}
public function 
getObjKeys( obj, strNeedle ) 
{ 
  if ( 
obj.type() != 2 )
    return 
getstringkeys( obj );

  
temp.vars = obj.savevarstoarray( false ); 
  for ( 
temp.var: temp.vars ) 
    if ( 
temp.var.starts( strNeedle ) ) 
      
temp.keys.add( temp.var.substring( strNeedle.length(), temp.var.pos("=") - strNeedle.length()) );

  
this.toreturn = temp.keys;
  return 
this.toreturn;
} 
Both the scripts go in the same weapon. This weapon should be seperate from the weapon used to make Lesson 1.

[EDIT]: Fixed the problem. fitparentwidth = true; Good old Wiki =)

Last edited by Twinny; 07-14-2007 at 11:26 AM..
Reply With Quote