- Timestamp:
- Jun 22, 2004, 10:47:35 AM (20 years ago)
- Location:
- orxonox/branches/gui/guicc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/gui/guicc/orxonox_gui.cc
r2003 r2007 28 28 gtk_init (&argc, &argv); 29 29 gtk_rc_parse( "rc" ); 30 30 31 31 orxonoxGUI = new Window("Graphical Orxonox Launcher"); 32 32 orxonoxGUI->connectSignal ("destroy", orxonoxGUI->orxonox_gui_quit); … … 51 51 52 52 orxonoxGUI->fill (windowBox); 53 flags->setTextFromFlags (orxonoxGUI); 54 55 exec->setFilename ("test"); 56 exec->readFromFile (orxonoxGUI); 53 57 orxonoxGUI->listOptions(); 54 flags->setTextFromFlags (orxonoxGUI); 55 56 /* TEST ENVIRONMENT 57 Frame* Frametest = new Frame ("Test"); 58 orxonoxGUI->fill((Frame*) Frametest); 59 Box* box = new Box ('v'); 60 Frametest->fill(box); 61 62 CheckButton* button = new CheckButton("button"); 63 button->connectSignal ("clicked", orxonoxGUI->orxonox_gui_quit); 64 box->fill(button); 65 Slider* slider = new Slider("slider", 0, 100); 66 slider->connectSignal ("value_changed", slider->OptionChange); 67 box->fill(slider); 68 Menu* menu = new Menu("menu1", "no output", "verbose", "debug", "lastItem"); 69 menu->connectSignal ("changed", menu->OptionChange); 70 box->fill(menu); 71 Menu* menu2 = new Menu("menu2", "no output", "verbose", "debug", "lastItem"); 72 menu2->connectSignal ("changed", menu->OptionChange); 73 box->fill(menu2); 74 orxonoxGUI->listOptions(); 75 */ 58 76 59 orxonoxGUI->showall (); 77 60 … … 206 189 * Quits the orxonox_GUI 207 190 */ 191 exec->writeToFile (orxonoxGUI); 192 208 193 gtk_main_quit(); 209 194 return FALSE; -
orxonox/branches/gui/guicc/orxonox_gui_exec.cc
r1996 r2007 1 1 #include "orxonox_gui_exec.h" 2 #include <iostream> 3 #include <string> 2 4 3 5 OrxonoxGuiExec::OrxonoxGuiExec (Window* orxonoxGUI) 4 6 { 7 configFile = (char*)malloc(256*sizeof(char)); 8 5 9 execFrame = new Frame ("Execute-Tags:"); 6 10 execBox = new Box ('v'); … … 27 31 return execFrame; 28 32 } 33 34 /* FILE HANDLING */ 35 36 void OrxonoxGuiExec::setFilename (char* filename) 37 { 38 39 if (filename) 40 sprintf(configFile, "%s", filename); 41 } 42 43 void OrxonoxGuiExec::writeToFile (Widget* widget) 44 { 45 CONFIG_FILE = fopen (configFile, "w"); 46 if (CONFIG_FILE) 47 writeFileText (widget); 48 fclose (CONFIG_FILE); 49 } 50 51 void OrxonoxGuiExec::writeFileText (Widget* widget) 52 { 53 if (widget->is_option >= 1) 54 if (strcmp (static_cast<Option*>(widget)->flag_name, "") || strcmp (static_cast<Option*>(widget)->flag_name_short, "")) 55 { 56 char Buffer[256]; 57 char* space2under; 58 sprintf (Buffer, "%s", static_cast<Option*>(widget)->option_name); 59 if (strchr (Buffer, '_')) 60 cout << "Warning Optionname" << Buffer << " is not Valid for Saving, because it includes an underscore" << endl; 61 while (space2under = strchr(Buffer, ' ')) 62 { 63 sprintf (space2under, "_%s", space2under+1); 64 } 65 fprintf (CONFIG_FILE, "%s = %i\n", Buffer, static_cast<Option*>(widget)->value); 66 } 67 switch (widget->is_option) 68 { 69 case -1: 70 writeFileText (static_cast<Container*>(widget)->down); 71 break; 72 case -2: 73 writeFileText (static_cast<Box*>(widget)->down); 74 break; 75 } 76 77 if (widget->next != NULL) 78 writeFileText (widget->next); 79 } 80 81 void OrxonoxGuiExec::readFromFile (Widget* widget) 82 { 83 CONFIG_FILE = fopen (configFile, "r"); 84 if (CONFIG_FILE) 85 { 86 char Buffer[256] = ""; 87 char Variable[256]= ""; 88 int Value; 89 while (fscanf (CONFIG_FILE, "%s", Buffer) != EOF) 90 { 91 if (!strcmp (Buffer, "=")) 92 { 93 char* under2space; 94 while (under2space = strchr(Variable, '_')) 95 { 96 sprintf (under2space, " %s", under2space+1); 97 } 98 99 fscanf (CONFIG_FILE, "%s", Buffer); 100 Value = atoi(Buffer); 101 readFileText (widget, Variable, Value); 102 sprintf (Variable, ""); 103 } 104 sprintf (Variable, "%s", Buffer); 105 } 106 107 } 108 109 } 110 111 void OrxonoxGuiExec::readFileText (Widget* widget, char* variableName, int variableValue) 112 { 113 if (widget->is_option >= 1) 114 if (!strcmp (static_cast<Option*>(widget)->option_name, variableName)) 115 static_cast<Option*>(widget)->value = variableValue; 116 117 switch (widget->is_option) 118 { 119 case -1: 120 readFileText (static_cast<Container*>(widget)->down, variableName, variableValue); 121 break; 122 case -2: 123 readFileText (static_cast<Box*>(widget)->down, variableName, variableValue); 124 break; 125 } 126 127 if (widget->next != NULL) 128 readFileText (widget->next, variableName, variableValue); 129 130 131 } -
orxonox/branches/gui/guicc/orxonox_gui_exec.h
r1980 r2007 3 3 4 4 #include "orxonox_gui.h" 5 #include <stdio.h> 6 using namespace std; 5 7 6 8 class OrxonoxGuiExec … … 14 16 CheckButton* alwaysShow; 15 17 Button* quit; 16 18 char* configFile; 19 FILE* CONFIG_FILE; 17 20 public: 18 21 OrxonoxGuiExec (Window* orxonoxGUI); … … 20 23 21 24 Frame* getFrame (); 25 26 void setFilename (char* filename); 27 void writeToFile (Widget* widget); 28 void writeFileText (Widget* widget); 29 void readFromFile (Widget* widget); 30 void readFileText (Widget* widget, char* variableName, int variableValue); 31 22 32 }; 23 33 #endif /* _ORXONOX_GUI_EXEC_H */
Note: See TracChangeset
for help on using the changeset viewer.