Changeset 5021 in orxonox.OLD for orxonox/trunk/src/lib/gui
- Timestamp:
- Aug 15, 2005, 12:10:07 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/gui/gui_exec.cc
r5016 r5021 202 202 void GuiExec::writeToFile(Widget* widget) 203 203 { 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; 208 209 } 209 210 … … 211 212 * Actually writes into the configuration file to the disk. 212 213 * @param widget from which Widget on should be saved. 214 * @param parser the IniParser to write to. 213 215 * @param depth initially "0", and grows higher, while new Groups are bundeled. 214 216 */ 215 void GuiExec::writeFileText(Widget* widget, int depth)216 { 217 int counter = 0;218 while(counter < depth &&((widget->optionType > GUI_NOTHING219 &&(static_cast<Option*>(widget)->isSaveable()))220 ||(widget->optionType < GUI_NOTHING221 && static_cast<Packer*>(widget)->getGroupName())))222 {223 fprintf(this->CONFIG_FILE, " ", depth);224 counter++;225 }217 void 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 // } 226 228 227 229 // check if it is a Packer, and if it is, check if it has a name and if there is something in it. … … 230 232 if(static_cast<Packer*>(widget)->getGroupName()) 231 233 { 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); 235 236 } 236 237 else 237 238 { 238 this->writeFileText(static_cast<Packer*>(widget)->down, depth);239 this->writeFileText(static_cast<Packer*>(widget)->down, parser, depth); 239 240 } 240 241 } … … 242 243 if(widget->optionType > GUI_NOTHING) 243 244 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()); 245 246 246 247 if(widget->next != NULL) 247 this->writeFileText(widget->next, depth);248 this->writeFileText(widget->next, parser, depth); 248 249 } 249 250 -
orxonox/trunk/src/lib/gui/gui_exec.h
r5015 r5021 14 14 class CheckButton; 15 15 using namespace std; 16 class IniParser; 16 17 17 18 //! Class that creates the execute-Options. … … 41 42 int shouldsave(); 42 43 void writeToFile(Widget* widget); 43 void writeFileText(Widget* widget, int depth);44 void writeFileText(Widget* widget, IniParser* parser, int depth); 44 45 void readFromFile(Widget* widget); 45 46 static void readFileText(Widget* widget, void* varInfo);
Note: See TracChangeset
for help on using the changeset viewer.