Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5021 in orxonox.OLD for orxonox/trunk/src/lib/gui


Ignore:
Timestamp:
Aug 15, 2005, 12:10:07 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: writing, loading, and comments work

Location:
orxonox/trunk/src/lib/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/gui/gui_exec.cc

    r5016 r5021  
    202202void GuiExec::writeToFile(Widget* widget)
    203203{
    204   this->CONFIG_FILE = fopen(this->confFile, "w");
    205   if(this->CONFIG_FILE)
    206     this->writeFileText(widget, 0);
    207   fclose(this->CONFIG_FILE);
     204  IniParser iniParser;
     205  this->writeFileText(widget, &iniParser, 0);
     206  char* fileName = ResourceManager::homeDirCheck(confFile);
     207  iniParser.writeFile(fileName);
     208  delete fileName;
    208209}
    209210
     
    211212 *  Actually writes into the configuration file to the disk.
    212213 * @param widget from which Widget on should be saved.
     214 * @param parser the IniParser to write to.
    213215 * @param depth initially "0", and grows higher, while new Groups are bundeled.
    214216*/
    215 void GuiExec::writeFileText(Widget* widget, int depth)
    216 {
    217   int counter = 0;
    218   while(counter < depth &&((widget->optionType > GUI_NOTHING
    219                               &&(static_cast<Option*>(widget)->isSaveable()))
    220                              ||(widget->optionType < GUI_NOTHING
    221                                 && static_cast<Packer*>(widget)->getGroupName())))
    222     {
    223       fprintf(this->CONFIG_FILE, "  ", depth);
    224       counter++;
    225     }
     217void GuiExec::writeFileText(Widget* widget, IniParser* parser, int depth)
     218{
     219//   int counter = 0;
     220//   while(counter < depth &&((widget->optionType > GUI_NOTHING
     221//                               &&(static_cast<Option*>(widget)->isSaveable()))
     222//                              ||(widget->optionType < GUI_NOTHING
     223//                                 && static_cast<Packer*>(widget)->getGroupName())))
     224//     {
     225//       fprintf(this->CONFIG_FILE, "  ", depth);
     226//       counter++;
     227//     }
    226228
    227229  // check if it is a Packer, and if it is, check if it has a name and if there is something in it.
     
    230232      if(static_cast<Packer*>(widget)->getGroupName())
    231233        {
    232           fprintf(CONFIG_FILE, "[%s]\n", static_cast<Packer*>(widget)->getGroupName());
    233           this->writeFileText(static_cast<Packer*>(widget)->down, depth+1);
    234           fprintf(CONFIG_FILE, "\n");
     234          parser->addSection(static_cast<Packer*>(widget)->getGroupName());
     235          this->writeFileText(static_cast<Packer*>(widget)->down, parser, depth+1);
    235236        }
    236237      else
    237238        {
    238           this->writeFileText(static_cast<Packer*>(widget)->down, depth);
     239          this->writeFileText(static_cast<Packer*>(widget)->down, parser, depth);
    239240        }
    240241    }
     
    242243  if(widget->optionType > GUI_NOTHING)
    243244    if (static_cast<Option*>(widget)->isSaveable())
    244       fprintf(CONFIG_FILE, "%s = %s\n", static_cast<Option*>(widget)->title, static_cast<Option*>(widget)->save());
     245      parser->addVar(static_cast<Option*>(widget)->title, static_cast<Option*>(widget)->save());
    245246
    246247  if(widget->next != NULL)
    247     this->writeFileText(widget->next, depth);
     248    this->writeFileText(widget->next, parser, depth);
    248249}
    249250
  • orxonox/trunk/src/lib/gui/gui_exec.h

    r5015 r5021  
    1414class CheckButton;
    1515using namespace std;
     16class IniParser;
    1617
    1718//! Class that creates the execute-Options.
     
    4142  int shouldsave();
    4243  void writeToFile(Widget* widget);
    43   void writeFileText(Widget* widget, int depth);
     44  void writeFileText(Widget* widget, IniParser* parser, int depth);
    4445  void readFromFile(Widget* widget);
    4546  static void readFileText(Widget* widget, void* varInfo);
Note: See TracChangeset for help on using the changeset viewer.