Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2634 in orxonox.OLD for orxonox/trunk/gui


Ignore:
Timestamp:
Oct 23, 2004, 9:14:22 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: load now more efficient. Loads first searches for a group, then inside the group for the option.

Location:
orxonox/trunk/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/gui/orxonox_gui_exec.cc

    r2625 r2634  
    175175  if (CONFIG_FILE)
    176176    {
     177      Widget* groupWidget = widget;
    177178      char Buffer[256] = "";
    178179      char Variable[256]= "";
     
    180181      while (fscanf (CONFIG_FILE, "%s", Buffer) != EOF)
    181182        {
     183          if (!strncmp (Buffer, "[", 1))
     184            {
     185              if ((groupWidget = locateGroup (widget, Buffer, 1))==NULL)
     186                {
     187                  cout << "the input " << Buffer << "does not belong to any group\n";
     188                  groupWidget = widget;
     189                }
     190            }
    182191          if (!strcmp (Buffer, "="))
    183192            {
     
    190199              fscanf (CONFIG_FILE, "%s", Buffer);
    191200              Value = atoi(Buffer);
    192               readFileText (widget, Variable, Value);
     201              readFileText (groupWidget, Variable, Value, 0);
    193202              sprintf (Variable, "");
    194203            }
     
    198207    }
    199208}
    200 
    201209/**
    202210   \brief Maps Confugurations to the Options.
     
    204212   \param variableName the name of the Variable that should be set up.
    205213   \param variableValue the Value of the Variable that should be set up
    206 */
    207 void OrxonoxGuiExec::readFileText (Widget* widget, char* variableName, int variableValue)
     214   \param depth the depth of the local Widget
     215*/
     216void OrxonoxGuiExec::readFileText (Widget* widget, char* variableName, int variableValue, int depth)
    208217{
    209218  if (widget->is_option >= 1)
     
    213222  if (widget->is_option < 0)
    214223    {
    215 
    216       readFileText (static_cast<Packer*>(widget)->down, variableName, variableValue);
     224      readFileText (static_cast<Packer*>(widget)->down, variableName, variableValue, depth+1);
    217225    }
    218226
    219   if (widget->next != NULL)
    220     readFileText (widget->next, variableName, variableValue);
     227  if (widget->next != NULL && depth !=0)
     228    readFileText (widget->next, variableName, variableValue, depth);
     229}
     230
     231/**
     232   \brief locates a Group member
     233*/
     234Widget* OrxonoxGuiExec::locateGroup(Widget* widget, char* groupName, int depth)
     235{
     236  Widget* tmp;
     237
     238  // removes the trailing and ending [ ].
     239  if (!strncmp (groupName, "[", 1))
     240    {
     241      groupName = groupName+1;
     242      groupName[strlen(groupName)-1] = '\0';
     243    }
     244
     245  if (widget->is_option < 0)
     246    {
     247      if (!strcmp(groupName, static_cast<Packer*>(widget)->getGroupName()))
     248        {
     249          return widget;
     250        }
     251      else
     252        {
     253          if ((tmp = locateGroup (static_cast<Packer*>(widget)->down, groupName, depth+1)) != NULL)
     254            return tmp;
     255        }
     256    }
     257 
     258  if (widget->next != NULL && depth != 0)
     259    {
     260      if ((tmp = locateGroup (widget->next, groupName, depth)) != NULL)
     261        return tmp;
     262    }
     263  return NULL;
    221264}
    222265
  • orxonox/trunk/gui/orxonox_gui_exec.h

    r2615 r2634  
    3535  void writeFileText (Widget* widget, int depth);
    3636  void readFromFile (Widget* widget);
    37   void readFileText (Widget* widget, char* variableName, int variableValue);
     37  void readFileText (Widget* widget, char* variableName, int variableValue, int depth);
     38  Widget* locateGroup(Widget* widget, char* groupName, int depth);
    3839
    3940};
Note: See TracChangeset for help on using the changeset viewer.