Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 22, 2005, 1:37:59 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the branches/updater back to the trunk.
merged with command
svn merge -r 3423:HEAD branches/updater/src/gui trunk/src/lib/graphics/gui/gui.

I do not wish to make such jokes again, because it is even worse than copy-pasting. All Files had to be eddited manually, and many diffs where a little bit strange (artifacts).

File:
1 edited

Legend:

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

    r3423 r3625  
    2525
    2626#include "orxonox_gui_exec.h"
     27
    2728#include <iostream>
    2829#include <string>
     30
     31#include <sys/stat.h>
     32#include <sys/types.h>
     33
    2934
    3035HashTable* orxonoxFlagHash;
     
    5055  this->saveSettings->saveability();
    5156  this->execBox->fill(this->saveSettings);
    52   this->verboseMode = new Menu("verbose mode", "no output", "error", "warning", "info", "lastItem");
     57  this->verboseMode = new Menu("verbose mode", "nothing", "error", "warning", "info", "lastItem");
    5358  this->verboseMode->setFlagName("verbose", "v", 0);
    5459  this->verboseMode->saveability();
     
    9095
    9196/**
     97   \brief sets the confDir and File-name out of an input-string
     98*/
     99void OrxonoxGuiExec::setConfFile(char* confFile)
     100{
     101  char splitter =
     102#ifdef __WIN32__
     103    '\\';
     104#else
     105  '/';
     106#endif
     107  char* tmpConfFile = new char[strlen(confFile)+1];
     108  strcpy(tmpConfFile, confFile);
     109  char* tmp = strrchr(tmpConfFile, splitter);
     110  if (tmp)
     111    {
     112      tmp[0] = '\0';
     113      this->setConfDir(tmpConfFile);
     114      this->setFileName(tmp+1);
     115    }
     116  else
     117    {
     118      this->setConfDir("~/");
     119      this->setFileName(tmpConfFile);
     120    }
     121  delete []tmp;
     122  delete []tmpConfFile;
     123}
     124
     125/**
     126   \brief sets the Directory of the configuration files
     127   \param confDir the Directory for the configuration files
     128*/
     129void OrxonoxGuiExec::setConfDir(char* confDir)
     130{
     131  if (!strncmp(confDir, "~/", 2))
     132    {
     133      char tmp[500];
     134#ifdef __WIN32__
     135      strcpy(tmp, getenv("USERPROFILE"));
     136#else
     137      strcpy(tmp, getenv("HOME"));
     138#endif
     139      this->confDir = new char[strlen(tmp)+strlen(confDir)];
     140      sprintf(this->confDir, "%s%s", tmp, confDir+1);
     141    }
     142  else
     143    {
     144      this->confDir = new char[strlen(confDir)+1];
     145      strcpy(this->confDir, confDir);
     146    }
     147  PRINTF(3)("Config Directory is: %s.\n", this->confDir);
     148  mkdir(this->confDir, 0755);
     149}
     150
     151/**
    92152   \brief Sets the location of the configuration File.
    93    \param filename the location of the configFile
     153   \param fileName the location of the configFile
    94154
    95155   \todo: memory allocation could be better.
     
    97157   The name will be parsed from ~/ to /home/[username] on unix and c:/Documents and Settings/username/Settings/ on Windows
    98158*/
    99 void OrxonoxGuiExec::setFilename(char* filename)
    100 {
    101   char* buffer = (char*)malloc(2048*sizeof(char));
    102   sprintf(buffer, "%s", filename);
    103   if(!strncmp(buffer, "~/", 2))
    104   {
    105 #ifdef __WIN32__
    106     sprintf(configFile, "%s/%s", getenv("USERPROFILE"), buffer+2);
    107 #else
    108     sprintf(configFile, "%s/%s", getenv("HOME"), buffer+2);
    109 #endif
    110   }
    111   else if(buffer)
    112     strcpy(this->configFile, buffer);
    113   free (buffer);
     159void OrxonoxGuiExec::setFileName(char* fileName)
     160{
     161  if (!this->confDir)
     162    this->setConfDir("~/");
     163  this->configFile = new char[strlen(this->confDir)+strlen(fileName)+2];
     164  sprintf(this->configFile, "%s/%s", this->confDir, fileName);
     165  PRINTF(3)("ConfigurationFile is %s.\n", this->configFile);
    114166}
    115167
     
    117169   \returns The name of the Configuration-File
    118170*/
    119 char* OrxonoxGuiExec::getConfigFile(void)
     171char* OrxonoxGuiExec::getConfigFile(void) const
    120172{
    121173  return this->configFile;
     
    190242            space2under[0] = '_';
    191243          }
    192         if(widget->isOption <=3)
    193           fprintf(CONFIG_FILE, "%s = %d\n", Buffer, static_cast<Option*>(widget)->value);
    194         else if(widget->isOption == 5)
    195           fprintf(CONFIG_FILE, "%s = %s\n", Buffer, static_cast<OptionLabel*>(widget)->cValue);
     244          fprintf(CONFIG_FILE, "%s = %s\n", Buffer, static_cast<Option*>(widget)->save());
    196245      }
    197246
     
    259308    {
    260309      PRINT(3)("Located Option %s.\n", widget->title);
    261       if(widget->isOption >= 1 && widget->isOption <= 3)
    262         {
    263           static_cast<Option*>(widget)->value = atoi(info->variableValue);
    264           static_cast<Option*>(widget)->redraw(); //!< \todo change this to setValue.
    265         }
    266       else if(widget->isOption == 5)
    267         static_cast<OptionLabel*>(widget)->setValue(info->variableValue);
     310      if(widget->isOption >= 1)
     311          static_cast<Option*>(widget)->load(info->variableValue);
    268312    }
    269313}
Note: See TracChangeset for help on using the changeset viewer.