Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4051 in orxonox.OLD


Ignore:
Timestamp:
May 5, 2005, 1:02:24 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/guiMerge: better fileReadIn (more like orxonox)

Location:
orxonox/branches/guiMerge/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/guiMerge/src/lib/gui/gui/gui.cc

    r4047 r4051  
    9595  }
    9696  // Reading Values from File
    97   exec->setConfFile(ORXONOX_GUI_DEFAULT_CONFIG_FILE);
     97  exec->setConfDir(GUI_DEFAULT_CONF_DIR);
     98  exec->setConfFile(GUI_DEFAULT_CONF_FILE);
    9899  exec->readFromFile(Window::mainWindow);
    99100  // Merging changes to the Options from appended flags.
     
    125126}
    126127
     128bool OrxonoxGui::startOrxonox = false;
    127129
    128130/**
  • orxonox/branches/guiMerge/src/lib/gui/gui/gui.h

    r4049 r4051  
    1616using namespace std;
    1717
    18 #define ORXONOX_GUI_DEFAULT_CONFIG_FILE "~/.orxonox/orxonox.conf"
     18#define GUI_DEFAULT_CONF_DIR "~/.orxonox"
     19#define GUI_DEFAULT_CONF_FILE "orxonox.conf"
    1920
    2021class OrxonoxGuiElement;
     
    2627  OrxonoxGui(int argc, char *argv[]);
    2728  ~OrxonoxGui(void);
     29
     30  static bool startOrxonox;
    2831};
    2932
  • orxonox/branches/guiMerge/src/lib/gui/gui/gui_banner.cc

    r4050 r4051  
    5959  }
    6060  // Banner Window //
    61   logoWindow = new Window("Logo");
     61  logoWindow = new Window(PACKAGE_NAME " is:");
    6262  {
    6363  EventBox* logoEventBox;   //!< The EventBox that holds the Orxonox-CrewLogo. it has to be an eventbox, because Images can not receive clicks.
     
    7070    logoEventBox = new EventBox();
    7171    logoBox = new Box('v');
    72     logoLabel = new Label("orxonox, version: " PACKAGE_VERSION);
     72    logoLabel = new Label(PACKAGE_NAME " v." PACKAGE_VERSION);
    7373    logoBox->fill(logoLabel);
    7474    logoImage = new Image(logo_xpm);
     
    7676
    7777    //! \todo add the names of all the guys working on orxonox
    78     orxIsLabel = new Label("orxonox is:\nPatrick Boenzli - main Developer\nBenjamin Grauer - right Hand\n....");
     78    orxIsLabel = new Label(PACKAGE_NAME " is:\nPatrick Boenzli - main Developer\nBenjamin Grauer - right Hand\n....");
    7979    logoBox->fill(orxIsLabel);
    8080    logoEventBox->fill(logoBox);
  • orxonox/branches/guiMerge/src/lib/gui/gui/gui_exec.cc

    r4049 r4051  
    2626#include "gui_exec.h"
    2727
     28#include "resource_manager.h"
    2829
    2930#include <string.h>
     
    3233#include <sys/types.h>
    3334
    34 
    3535HashTable* orxonoxFlagHash;
    3636
     
    4040OrxonoxGuiExec::OrxonoxGuiExec(void)
    4141{
    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);
    7687}
    7788
     
    8192OrxonoxGuiExec::~OrxonoxGuiExec(void)
    8293{
    83   if(this->configFile)
    84     delete []this->configFile;
     94  if(this->confFile)
     95    delete []this->confFile;
     96  if(this->confDir)
     97    delete []this->confDir;
    8598}
    8699
    87100/* FILE HANDLING */
    88 
    89 /**
    90    \brief sets the confDir and File-name out of an input-string
    91 */
    92 void OrxonoxGuiExec::setConfFile(char* confFile)
    93 {
    94   char splitter =
    95 #ifdef __WIN32__
    96     '\\';
    97 #else
    98   '/';
    99 #endif
    100   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   else
    110     {
    111       this->setConfDir("~/");
    112       this->setFileName(tmpConfFile);
    113     }
    114   delete []tmp;
    115   delete []tmpConfFile;
    116 }
    117101
    118102/**
     
    120104   \param confDir the Directory for the configuration files
    121105*/
    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     }
     106void OrxonoxGuiExec::setConfDir(const char* confDir)
     107{
     108  this->confDir = ResourceManager::homeDirCheck(confDir);
     109
    140110  PRINTF(3)("Config Directory is: %s.\n", this->confDir);
     111  //! \todo F** Windows-support
    141112  mkdir(this->confDir, 0755);
    142113}
     
    146117   \param fileName the location of the configFile
    147118
    148    \todo: memory allocation could be better.
    149 
    150119   The name will be parsed from ~/ to /home/[username] on unix and c:/Documents and Settings/username/Settings/ on Windows
    151120*/
    152 void OrxonoxGuiExec::setFileName(char* fileName)
     121void OrxonoxGuiExec::setConfFile(const char* fileName)
    153122{
    154123  if (!this->confDir)
    155124    this->setConfDir("~/");
    156   this->configFile = new char[strlen(this->confDir)+strlen(fileName)+2];
    157   sprintf(this->configFile, "%s/%s", this->confDir, fileName);
    158   PRINTF(3)("ConfigurationFile is %s.\n", this->configFile);
     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);
    159128}
    160129
     
    162131   \returns The name of the Configuration-File
    163132*/
    164 char* OrxonoxGuiExec::getConfigFile(void) const
    165 {
    166   return this->configFile;
     133const char* OrxonoxGuiExec::getConfigFile(void) const
     134{
     135  return this->confFile;
    167136}
    168137
     
    184153void OrxonoxGuiExec::writeToFile(Widget* widget)
    185154{
    186   this->CONFIG_FILE = fopen(configFile, "w");
     155  this->CONFIG_FILE = fopen(this->confFile, "w");
    187156  if(this->CONFIG_FILE)
    188157    this->writeFileText(widget, 0);
     
    248217void OrxonoxGuiExec::readFromFile(Widget* widget)
    249218{
    250   this->CONFIG_FILE = fopen(configFile, "r");
     219  this->CONFIG_FILE = fopen(this->confFile, "r");
    251220  VarInfo varInfo;
    252221  if(this->CONFIG_FILE)
     
    302271      PRINT(5)("Located Option %s.\n", widget->title);
    303272      if(widget->isOption >= 1)
    304           static_cast<Option*>(widget)->load(info->variableValue);
     273        static_cast<Option*>(widget)->load(info->variableValue);
    305274    }
    306275}
     
    328297  if(widget->isOption < 0)
    329298    {
    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()))
    331301        {
    332302          return widget;
     
    369339
    370340  PRINT(3)("Starting Orxonox\n");
     341  OrxonoxGui::startOrxonox = true;
    371342}
    372343
  • orxonox/branches/guiMerge/src/lib/gui/gui/gui_exec.h

    r4049 r4051  
    99#include "gui.h"
    1010#include "gui_element.h"
     11#include "gui_gtk.h"
    1112
    12 #include "gui_gtk.h"
     13class Widget;
     14class CheckButton;
    1315using namespace std;
    1416
     
    1719{
    1820 private:
    19   Frame* execFrame;            //!< The Frame that holds the ExecutionOptions.
    20   Box* execBox;                //!< The Box that holds the ExecutionOptions.
    21   Button* start;               //!< The start Button of orxonox.
    2221  CheckButton* saveSettings;   //!< A CheckBox for if the Options should be saved.
    23   Menu* verboseMode;           //!< A Menu for setting the verbose-Mode. \todo setting up a verbose-class.
    24   CheckButton* alwaysShow;     //!< A CheckButton, for if orxonox should start with or without gui.
    25   Button* quit;                //!< A Button to quit the Gui without starting orxonox.
     22
    2623  char* confDir;               //!< The directory of the orxonox-configuration-files.
    27   char* configFile;            //!< The name of the .orxonox.conf(ig)-file.
     24  char* confFile;              //!< The name of the .orxonox.conf(ig)-file.
    2825  FILE* CONFIG_FILE;           //!< Filehandler for reading and writing.
    29  
     26
    3027  //! A struct that holds informations about variables.
    3128  struct VarInfo
     
    3936  ~OrxonoxGuiExec(void);
    4037 
    41   void setConfFile(char* confFile);
    42   void setConfDir(char* confDir);
    43   void setFileName(char* fileName);
    44   char* getConfigFile(void) const;
     38  void setConfDir(const char* confDir);
     39  void setConfFile(const char* confFile);
     40  const char* getConfigFile(void) const;
    4541  int shouldsave(void);
    4642  void writeToFile(Widget* widget);
  • orxonox/branches/guiMerge/src/orxonox.cc

    r4048 r4051  
    342342      //      sprintf(guiExec,"%sGui --gui", argv[0]);
    343343      OrxonoxGui* gui = new OrxonoxGui(argc, argv);
     344      if (! gui->startOrxonox)
     345        return 0;
     346     
    344347      delete gui;
    345348      //      delete guiExec;
  • orxonox/branches/guiMerge/src/util/resource_manager.h

    r4032 r4051  
    8181  static bool touchFile(const char* fileName);
    8282  static bool deleteFile(const char* fileName);
     83  static char* homeDirCheck(const char* name);
    8384
    8485 private:
     
    9495  Resource* locateResourceByPointer(const void* pointer);
    9596 
    96   static char* homeDirCheck(const char* name);
    9797};
    9898
Note: See TracChangeset for help on using the changeset viewer.