Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Oct 22, 2004, 1:30:23 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: export to file now nicer. (danger heavy if-expression)

Location:
orxonox/trunk/gui
Files:
2 edited

Legend:

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

    r2614 r2615  
    110110  CONFIG_FILE = fopen (configFile, "w");
    111111  if (CONFIG_FILE)
    112     writeFileText (widget);
     112    writeFileText (widget, 0);
    113113  fclose (CONFIG_FILE);
    114114}
     
    117117   \brief Actually writes into the configuration file to the disk.
    118118   \param widget from which Widget on should be saved.
    119 */
    120 void OrxonoxGuiExec::writeFileText (Widget* widget)
    121 {
     119   \param depth initially "0", and grows higher, while new Groups are bundeled.
     120*/
     121void OrxonoxGuiExec::writeFileText (Widget* widget, int depth)
     122{
     123  int counter = 0;
     124  while (counter < depth && ((widget->is_option>0
     125                              && (strcmp (static_cast<Option*>(widget)->flag_name, "")
     126                                  || strcmp (static_cast<Option*>(widget)->flag_name_short, "")) )
     127                             || (widget->is_option<0
     128                                 && strcmp (static_cast<Packer*>(widget)->getGroupName(), ""))))
     129    {
     130      fprintf (CONFIG_FILE, "  ", depth);
     131      counter++;
     132    }
     133 
     134  // check if it is a Packer, and if it is, check if it has a name and if there is something in it.
    122135  if (widget->is_option <0)
    123     if (strcmp (static_cast<Packer*>(widget)->getGroupName(), ""))
    124       fprintf (CONFIG_FILE, "[%s]\n", static_cast<Packer*>(widget)->getGroupName());
    125 
     136    {
     137      if (strcmp (static_cast<Packer*>(widget)->getGroupName(), ""))
     138        {
     139          fprintf (CONFIG_FILE, "[%s]\n", static_cast<Packer*>(widget)->getGroupName());
     140          writeFileText (static_cast<Packer*>(widget)->down, depth+1);
     141        }
     142      else
     143        {
     144          writeFileText (static_cast<Packer*>(widget)->down, depth);
     145        }
     146    }
     147 
    126148  if (widget->is_option >= 1)
    127149    if  (strcmp (static_cast<Option*>(widget)->flag_name, "") || strcmp (static_cast<Option*>(widget)->flag_name_short, ""))
     
    138160        fprintf (CONFIG_FILE, "%s = %i\n", Buffer, static_cast<Option*>(widget)->value);
    139161      }
    140   if (widget->is_option<0)
    141     {
    142       writeFileText (static_cast<Packer*>(widget)->down);
    143     }
    144  
     162
    145163  if (widget->next != NULL)
    146     writeFileText (widget->next);
     164    writeFileText (widget->next, depth);
    147165}
    148166
  • orxonox/trunk/gui/orxonox_gui_exec.h

    r2595 r2615  
    3333  int shouldsave ();
    3434  void writeToFile (Widget* widget);
    35   void writeFileText (Widget* widget);
     35  void writeFileText (Widget* widget, int depth);
    3636  void readFromFile (Widget* widget);
    3737  void readFileText (Widget* widget, char* variableName, int variableValue);
Note: See TracChangeset for help on using the changeset viewer.