Changeset 4051 in orxonox.OLD for orxonox/branches/guiMerge/src/lib/gui/gui/gui_exec.cc
- Timestamp:
- May 5, 2005, 1:02:24 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/guiMerge/src/lib/gui/gui/gui_exec.cc
r4049 r4051 26 26 #include "gui_exec.h" 27 27 28 #include "resource_manager.h" 28 29 29 30 #include <string.h> … … 32 33 #include <sys/types.h> 33 34 34 35 35 HashTable* orxonoxFlagHash; 36 36 … … 40 40 OrxonoxGuiExec::OrxonoxGuiExec(void) 41 41 { 42 configFile = new char[512]; 43 44 this->execFrame = new Frame("Execute-Tags:"); 45 this->execBox = new Box('v'); 46 this->execFrame->setGroupName("misc"); 47 48 this->start = new Button("Start"); 49 #ifdef HAVE_GTK2 50 this->start->connectSignal("clicked", this, startOrxonox); 51 #endif /* HAVE_GTK2 */ 52 this->execBox->fill(start); 53 this->saveSettings = new CheckButton("Save Settings"); 54 this->saveSettings->value = 1; 55 this->saveSettings->saveability(); 56 this->execBox->fill(this->saveSettings); 57 this->verboseMode = new Menu("verbose mode", "nothing", "error", "warning", "info", "lastItem"); 58 this->verboseMode->setFlagName("verbose", "v", 0); 59 this->verboseMode->saveability(); 60 this->execBox->fill(this->verboseMode); 61 this->alwaysShow = new CheckButton("Always Show this Menu"); 62 this->alwaysShow->setFlagName("gui", "g", 0); 63 this->alwaysShow->saveability(); 64 this->execBox->fill(this->alwaysShow); 65 this->quit = new Button("Quit"); 66 #ifdef HAVE_GTK2 67 this->quit->connectSignal("clicked", this, OrxonoxGuiExec::quitGui); 68 // Window::mainWindow->connectSignal("remove", this, OrxonoxGuiExec::quitGui); 69 Window::mainWindow->connectSignal("destroy", this, OrxonoxGuiExec::quitGui); 70 #endif /* HAVE_GTK2 */ 71 this->execBox->fill(this->quit); 72 73 this->execFrame->fill(this->execBox); 74 75 this->setMainWidget(execFrame); 42 Frame* execFrame; //!< The Frame that holds the ExecutionOptions. 43 44 this->confFile = NULL; 45 this->confDir = NULL; 46 47 execFrame = new Frame("Execute-Tags:"); 48 { 49 Box* execBox; //!< The Box that holds the ExecutionOptions. 50 51 execBox = new Box('v'); 52 execFrame->setGroupName("misc"); 53 { 54 Button* start; //!< The start Button of orxonox. 55 Menu* verboseMode; //!< A Menu for setting the verbose-Mode. \todo setting up a verbose-class. 56 CheckButton* alwaysShow; //!< A CheckButton, for if orxonox should start with or without gui. 57 Button* quit; //!< A Button to quit the Gui without starting orxonox. 58 59 start = new Button("Start"); 60 #ifdef HAVE_GTK2 61 start->connectSignal("clicked", this, startOrxonox); 62 #endif /* HAVE_GTK2 */ 63 execBox->fill(start); 64 this->saveSettings = new CheckButton("Save Settings"); 65 this->saveSettings->value = 1; 66 this->saveSettings->saveability(); 67 execBox->fill(this->saveSettings); 68 verboseMode = new Menu("verbose mode", "nothing", "error", "warning", "info", "lastItem"); 69 verboseMode->setFlagName("verbose", "v", 0); 70 verboseMode->saveability(); 71 execBox->fill(verboseMode); 72 alwaysShow = new CheckButton("Always Show this Menu"); 73 alwaysShow->setFlagName("gui", "g", 0); 74 alwaysShow->saveability(); 75 execBox->fill(alwaysShow); 76 quit = new Button("Quit"); 77 #ifdef HAVE_GTK2 78 quit->connectSignal("clicked", this, OrxonoxGuiExec::quitGui); 79 // Window::mainWindow->connectSignal("remove", this, OrxonoxGuiExec::quitGui); 80 Window::mainWindow->connectSignal("destroy", this, OrxonoxGuiExec::quitGui); 81 #endif /* HAVE_GTK2 */ 82 execBox->fill(quit); 83 } 84 execFrame->fill(execBox); 85 } 86 setMainWidget(execFrame); 76 87 } 77 88 … … 81 92 OrxonoxGuiExec::~OrxonoxGuiExec(void) 82 93 { 83 if(this->configFile) 84 delete []this->configFile; 94 if(this->confFile) 95 delete []this->confFile; 96 if(this->confDir) 97 delete []this->confDir; 85 98 } 86 99 87 100 /* FILE HANDLING */ 88 89 /**90 \brief sets the confDir and File-name out of an input-string91 */92 void OrxonoxGuiExec::setConfFile(char* confFile)93 {94 char splitter =95 #ifdef __WIN32__96 '\\';97 #else98 '/';99 #endif100 char* tmpConfFile = new char[strlen(confFile)+1];101 strcpy(tmpConfFile, confFile);102 char* tmp = strrchr(tmpConfFile, splitter);103 if (tmp)104 {105 tmp[0] = '\0';106 this->setConfDir(tmpConfFile);107 this->setFileName(tmp+1);108 }109 else110 {111 this->setConfDir("~/");112 this->setFileName(tmpConfFile);113 }114 delete []tmp;115 delete []tmpConfFile;116 }117 101 118 102 /** … … 120 104 \param confDir the Directory for the configuration files 121 105 */ 122 void OrxonoxGuiExec::setConfDir(char* confDir) 123 { 124 if (!strncmp(confDir, "~/", 2)) 125 { 126 char tmp[500]; 127 #ifdef __WIN32__ 128 strcpy(tmp, getenv("USERPROFILE")); 129 #else 130 strcpy(tmp, getenv("HOME")); 131 #endif 132 this->confDir = new char[strlen(tmp)+strlen(confDir)]; 133 sprintf(this->confDir, "%s%s", tmp, confDir+1); 134 } 135 else 136 { 137 this->confDir = new char[strlen(confDir)+1]; 138 strcpy(this->confDir, confDir); 139 } 106 void OrxonoxGuiExec::setConfDir(const char* confDir) 107 { 108 this->confDir = ResourceManager::homeDirCheck(confDir); 109 140 110 PRINTF(3)("Config Directory is: %s.\n", this->confDir); 111 //! \todo F** Windows-support 141 112 mkdir(this->confDir, 0755); 142 113 } … … 146 117 \param fileName the location of the configFile 147 118 148 \todo: memory allocation could be better.149 150 119 The name will be parsed from ~/ to /home/[username] on unix and c:/Documents and Settings/username/Settings/ on Windows 151 120 */ 152 void OrxonoxGuiExec::set FileName(char* fileName)121 void OrxonoxGuiExec::setConfFile(const char* fileName) 153 122 { 154 123 if (!this->confDir) 155 124 this->setConfDir("~/"); 156 this->conf igFile = new char[strlen(this->confDir)+strlen(fileName)+2];157 sprintf(this->conf igFile, "%s/%s", this->confDir, fileName);158 PRINTF(3)("ConfigurationFile is %s.\n", this->conf igFile);125 this->confFile = new char[strlen(this->confDir)+strlen(fileName)+2]; 126 sprintf(this->confFile, "%s/%s", this->confDir, fileName); 127 PRINTF(3)("ConfigurationFile is %s.\n", this->confFile); 159 128 } 160 129 … … 162 131 \returns The name of the Configuration-File 163 132 */ 164 c har* OrxonoxGuiExec::getConfigFile(void) const165 { 166 return this->conf igFile;133 const char* OrxonoxGuiExec::getConfigFile(void) const 134 { 135 return this->confFile; 167 136 } 168 137 … … 184 153 void OrxonoxGuiExec::writeToFile(Widget* widget) 185 154 { 186 this->CONFIG_FILE = fopen( configFile, "w");155 this->CONFIG_FILE = fopen(this->confFile, "w"); 187 156 if(this->CONFIG_FILE) 188 157 this->writeFileText(widget, 0); … … 248 217 void OrxonoxGuiExec::readFromFile(Widget* widget) 249 218 { 250 this->CONFIG_FILE = fopen( configFile, "r");219 this->CONFIG_FILE = fopen(this->confFile, "r"); 251 220 VarInfo varInfo; 252 221 if(this->CONFIG_FILE) … … 302 271 PRINT(5)("Located Option %s.\n", widget->title); 303 272 if(widget->isOption >= 1) 304 273 static_cast<Option*>(widget)->load(info->variableValue); 305 274 } 306 275 } … … 328 297 if(widget->isOption < 0) 329 298 { 330 if(static_cast<Packer*>(widget)->getGroupName() && !strcmp(groupName, static_cast<Packer*>(widget)->getGroupName())) 299 if(static_cast<Packer*>(widget)->getGroupName() && 300 !strcmp(groupName, static_cast<Packer*>(widget)->getGroupName())) 331 301 { 332 302 return widget; … … 369 339 370 340 PRINT(3)("Starting Orxonox\n"); 341 OrxonoxGui::startOrxonox = true; 371 342 } 372 343
Note: See TracChangeset
for help on using the changeset viewer.