Author Topic: How do I script changes to a GuiPopupMenuCtrl?  (Read 5418 times)

I'm working on a script that would search a particular GuiPopupMenuCtrl for a particular string of text.  The search returns the id of the row containing that text.  How do I delete that row from the GuiPopupMenuCtrl?
« Last Edit: March 21, 2007, 12:58:51 AM by Trader »

So you're done with the search/return ID part? To delete a line I'd store the whole file in an array (split by rows) and rewrite it line by line except the line you want to delete.

Pseudo code (assuming you have already loaded the file row by row into arrayWithRows):
Code: [Select]
arrayWithRows[666];

deleteline(id)
{
   for(i=0;i<lengthOf(arrayWithRows);i++) if(arrayWithRows[i]!=id) writeLineToFile(arrayWithRows[i]);
}

I hope this helps, but TorqueScript is not my native language :P

It's not a file with lines.  It's a popup menu with contents stored in game memory.


Noobs, lol.  I have access to the GUI file.  The list is not in the file.  It's a dynamically filled GuiPopupMenuCtrl.  I know the ID of the row; I know the the text contained on that row.  How do I delete that row?
« Last Edit: March 15, 2007, 02:03:43 PM by Trader »

The dump on a GuiPopupMenuCtrl reveals the following commands:

Code: [Select]
Methods:
  add() - (string name, int idNum, int scheme=0)
  addScheme() - (int id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL)
  bringToFront() - set.bringToFront(object)
  clear() - Clear the popup list.
  delete() - obj.delete()
  dump() - obj.dump()
  findText() - (string text)Returns the position of the first entry containing the specified text.
  forceClose() -
  forceOnAction() -
  getClassName() - obj.getClassName()
  getCount() - set.getCount()
  getExtent() - Get the width and height of the control.
  getGroup() - obj.getGroup()
  getHelpPage() -
  getId() - obj.getId()
  getMinExtent() - Get the minimum allowed size of the control.
  getName() - obj.getName()
  getObject() - set.getObject(objIndex)
  getPixelWidth() - obj.getPixelWidth()
  getPosition() -
  getSelected() -
  getText() -
  getTextById() - (int id)
  getType() - obj.getType()
  getValue() -
  isActive() -
  isAwake() -
  isMember() - set.isMember(object)
  isVisible() -
  listObjects() - set.listObjects();
  makeFirstResponder() - (bool isFirst)
  pushToBack() - set.pushToBack(object)
  remove() - set.remove(obj1,...)
  replaceText() - (bool doReplaceText)
  resize() - (int x, int y, int w, int h)
  save() - obj.save(fileName, <selectedOnly>)
  schedule() - object.schedule(time, command, <arg1...argN>);
  setActive() - (bool active)
  setEnumContent() - (string class, string enum)This fills the popup with a classrep's field enumeration type info.

More of a helper function than anything.   If console access to the field list is added, at least for the enumerated types, then this should go away..
  setName() - obj.setName(newName)
  setProfile() - (GuiControlProfile p)
  setSelected() - (int id)
  setText() - (string text)
  setValue() - (string value)
  setVisible() - (bool visible)
  size() - Get the size of the menu - the number of entries in it.
  sort() - Sort the list alphabetically.

I'll leave it to you for experiments.

Yeah, I've already read over that and played with various commands.  I probably won't post things here unless I'm really stuck.

rudyman

  • Guest
This is a ghetto way to do it and i'm not sure if it'll work.

Code: [Select]
function GuiPopupMenuCtrl::addItem(%this,%id,%text)
{
%this.add(%id,%text);
%this.item[%this.itemCount++]=%id;
%this.text[%this.itemCount]=%text;
}
function GuiPopupMenuCtrl::removeRowByText(%this,%text)
{
   for(%i=0;%i<=%this.itemCount;%i++)
   {
   %currItem=%this.item[%i];
   %currText=%this.text[%i];
      if(%currText $= %text){%remove=%currItem;}
   }
%this.clear();
   for(%i=0;%i<=%this.itemCount;%i++)
   {
      if(%this.item[%i] !$= %remove){%this.addItem(%this.item[%i],%this.text[%i]);}
   }
%this.itemCount=0;
}

I'll try it out when I get home.

Nope, it doesn't work.  Any other suggestions?

Uh, maybe use strReplace? Example:
Code: [Select]
strReplace(%string_to_search_through, %what2replace, %What2replace_with);You can use "" for what to replace with if you just wanna delete it. (This could be totally the oposite of what your looking for, sorry :|)

Umm.  I guess no one understands what I'm wanting to know.  In retail, open your wrench gui.  Do you see the drop down boxes for item spawns, emitters, and lights?  I want to remove a particular row from one of those lists.  How do I do it?

Uhh, control.visible = 0;?

No, I don't want to hide it.  I actually want to remove it from the drop down.

You cannot control the actions of a clients gui to the level of completely removing a part of it. I'm not saying delete, but you can't jsut tell the client to make soemthing not visiable