Game Development Community

Directory Tree and File list

by Gellyware · in Torque Game Builder · 01/19/2007 (9:41 pm) · 4 replies

Can someone please post an example of how to get the Directory Tree and Directory File list gadgets working properly?

I can not get any values from the directory tree and I'd like to know how these two coordinate.

Thanks!

#1
01/21/2007 (2:13 am)
I guess the GUI bewilders others as well.

If anyone has any comment as to how to get these two working, I'd appreciate it.
#2
01/21/2007 (9:41 pm)
I would recommend taking a look at how the TGB level editor does it.
games/tools/gui/savefiledlg.ed.gui
games/tools/gui/filedialogdase.ed.cs
#3
01/22/2007 (8:21 am)
Good idea, Guy.

I was trying to figure out how to use some of the gui controls this past week, and grepping the tools directory for usages of that gui control was extremely helpful in figuring out how it worked.

Another thing that I've found extremely helpful is doing a .dump() in the console on the GUI controls to see what methods are available to me.

Enter the GUI builder, create a new GUI, drop a control onto it (such as a directorytree), name it something like "MyDirectoryTree", press apply, press F10 to run the GUI, hit ~ to bring up the console, then type "MyDirectoryTree.dump();"

That will give the following output:
==>MyDirectoryTree.dump();
Member Fields:
  Accelerator = ""
  AltCommand = ""
  canSave = "1"
  canSaveDynamicFields = "0"
  class = ""
  Command = ""
  DeleteObjectAllowed = "1"
  destroyTreeOnSleep = "0"
  DragToItemAllowed = "1"
  Extent = "101 63"
  fullRowSelect = "0"
  HorizSizing = "right"
  hovertime = "1000"
  itemHeight = "21"
  langTableMod = ""
  MinExtent = "8 2"
  MouseDragging = "0"
  MultipleSelections = "0"
  position = "0 0"
  Profile = "GuiDirectoryTreeProfile"
  superclass = ""
  tabSize = "16"
  textOffset = "2"
  tooltip = ""
  tooltipprofile = ""
  Variable = ""
  VertSizing = "bottom"
  Visible = "1"
Tagged Fields:
Methods:
  add() - set.add(obj1,...)
  addChildSelectionByValue() - addChildSelectionByValue(TreeItemId parent, value)
  addGuiControl() - S32 controlId
  addSelection() - (selects an item)
  bringToFront() - set.bringToFront(object)
[b]  buildIconTable() - (builds an icon table)
  buildVisibleTree() - Build the visible tree
  clear() - () - empty tree
  clearSelection() - (clears selection)[/b]
  delete() - obj.delete()
  deleteSelection() - (deletes the selected items)
  dump() - obj.dump()
  dumpClassHierarchy() - obj.dumpClassHierarchy()
[b]  editItem() - (TreeItemId item, string newText, string newValue)
  expandItem() - (TreeItemId item, bool expand=true)
  findItemByName() - (find item by name and returns the mId)
  findItemByObjectId() - (find item by object id and returns the mId)[/b]
  findObjectByInternalName() - string InternalName
  getCenter() -  returns center of control, as space seperated ints
  getChild() - (TreeItemId item)
  getClassName() - obj.getClassName()
  getCount() - set.getCount()
  getDynamicField() - obj.getDynamicField(index)
  getDynamicFieldCount() - obj.getDynamicFieldCount()
  getExtent() - Get the width and height of the control.
  getFieldValue() - obj.getFieldValue(fieldName);
[b]  getFirstRootItem() - Get id for root item.[/b]
  getGlobalCenter() -  returns center of control, as space seperated ints
  getGlobalPosition() - 
  getGroup() - obj.getGroup()
  getHelpPage() - 
  getId() - obj.getId()
  getInternalName() - getInternalName returns the objects internal name
  getItemCount() - 
  getItemText() - (TreeItemId item)
  getItemValue() - (TreeItemId item)
  getMinExtent() - Get the minimum allowed size of the control.
  getName() - obj.getName()
  getNextSibling() - (TreeItemId item)
  getObject() - set.getObject(objIndex)
  getParent() - (TreeItemId item)
  getPosition() - 
  getPrevSibling() - (TreeItemId item)
[b]  getSelectedItem() - 
  getSelectedItemList() - returns a space seperated list of mulitple item ids
  getSelectedItemsCount() - 
  getSelectedObject() - returns the currently selected simObject in inspector mode or -1
  getSelectedPath() - getSelectedPath() - returns the currently selected path in the tree
  getTextToRoot() - (TreeItemId item,Delimiter=none) gets the text from the current node to the root, concatenating at each branch upward, with a specified delimiter optionally[/b]
  getType() - obj.getType()
  getValue() - 
  insertItem() - (TreeItemId parent, name, value, icon, normalImage=0, expandedImage=0)
  isActive() - 
  isAwake() - 
  isChildOfGroup() -  returns true, if we are in the specified simgroup - or a subgroup thereof
  isMember() - set.isMember(object)
  isMemberOfClass() -  isMemberOfClass(string classname) -- returns true if this object is a member of the specified class
  isMethod() - obj.isMethod(string method name)
  isVisible() - 
  listObjects() - set.listObjects();
  lockSelection() - (locks selections)
  makeFirstResponder() - (bool isFirst)
  moveItemDown() - (TreeItemId item)
  moveItemUp() - (TreeItemId item)
  onChanged() - 
[b]  open() - (SimSet obj, bool okToEdit=true) Set the root of the tree view to the specified object, or to the root set.[/b]
  pointInControl() - returns true if the point is in the control, point is in parent coords
  pushToBack() - set.pushToBack(object)
  remove() - set.remove(obj1,...)
  removeAllChildren() - removeAllChildren(TreeItemId parent)
  removeChildSelectionByValue() - removeChildSelectionByValue(TreeItemId parent, value)
  removeItem() - (TreeItemId item)
  removeSelection() - (deselects an item)
  reorderChild() -  (child1, child2) uses simset reorder to push child 1 after child 2 - both must already be child controls of this control
  resize() - (int x, int y, int w, int h)
  save() - obj.save(fileName, <selectedOnly>)
  schedule() - object.schedule(time, command, <arg1...argN>);
  scrollVisible() - (TreeItemId item)
  selectItem() - (TreeItemId item, bool select=true)
  setActive() - (bool active)
  setCanSave() - Sets whether this control can serialize itself to the hard disk
  setCenter() -  sets control position, by center - coords are local not global
  setExtent() -  sets the width & height of the control.
  setFieldValue() - obj.setFieldValue(fieldName,value);
  setFirstResponder() - Sets this control as the first responder
  setInternalName() - string InternalName
  setName() - obj.setName(newName)
  setPosition() - int x,y in local space
  setPositionGlobal() - int x,y in global screen space
  setProfile() - (GuiControlProfile p)
[b]  setSelectedPath() - setSelectedPath(path) - expands the tree to the specified path[/b]
  setValue() - (string value)
  setVisible() - (bool visible)

Creating a dump of the directory file list control is left as an excercise up to the reader.

I've bolded some of the more interesting methods on just a first glance through the control, but as Guy Lewis said, really the best thing is to see how they are used in the TGB editors.

Cheers!

--clint
#4
01/22/2007 (1:18 pm)
Thanks for the posts! Very informative!