Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7661 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
May 18, 2006, 12:55:34 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the QT_GUI back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/qt_gui . -r7607:HEAD

absolutely no conflicts :)

Location:
trunk/src
Files:
1 deleted
30 edited
27 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r7462 r7661  
    1212bin_PROGRAMS = orxonox
    1313
    14 orxonox_CPPFLAGS = -DIS_ORXONOX
    15 orxonox_LDFLAGS = -u global_ModelParticles_Factory
     14orxonox_CPPFLAGS = \
     15                -DIS_ORXONOX \
     16                @QT_CXXFLAGS@
     17
     18orxonox_LDFLAGS = @QT_LDFLAGS@
    1619
    1720orxonox_DEPENDENCIES = \
     
    2427                util/libORXutils.a \
    2528                $(libORXlibs_a_LIBRARIES_) \
    26                 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
     29                $(CURL_LIBS) \
     30                @QT_LIBS@
    2731
    2832orxonox_SOURCES = \
     
    6670
    6771## orxonox.conf will be used from home-dir instead.
    68 EXTRA_DIST = proto/proto_class.h \
    69              proto/proto_class.cc \
    70              proto/proto_singleton.h \
    71              proto/proto_singleton.cc \
    72              proto/proto_world_entity.h \
    73              proto/proto_world_entity.cc \
    74              defs/include_paths.am \
    75              story_entities/Makefile.am
     72EXTRA_DIST = \
     73                proto/proto_class.h \
     74                proto/proto_class.cc \
     75                proto/proto_singleton.h \
     76                proto/proto_singleton.cc \
     77                proto/proto_world_entity.h \
     78                proto/proto_world_entity.cc \
     79                defs/include_paths.am \
     80                story_entities/Makefile.am
    7681
    7782if SUB_PROJECTS
     
    8186endif
    8287
    83 SUBDIRS = lib \
    84           util \
    85           world_entities \
    86           . \
    87           $(SUB_PROGS)
     88SUBDIRS = \
     89                lib \
     90                util \
     91                world_entities \
     92                . \
     93                $(SUB_PROGS)
    8894
    8995
  • trunk/src/defs/class_id.h

    r7486 r7661  
    322322  CL_GLGUI_BAR                  =    0x00000b30,
    323323
     324  // QT_GUI
     325  CL_GUI_SAVEABLE               =    0x00b10000,
     326  CL_QTGUI_BUTTON               =    0x00000ba0,
     327  CL_QTGUI_PUSHBUTTON           =    0x00000ba3,
     328  CL_QTGUI_CHECKBUTTON          =    0x00000ba4,
     329  CL_QTGUI_RADIOBUTTON          =    0x00000ba5,
     330  CL_QTGUI_CONTAINER            =    0x00b200a0,
     331  CL_QTGUI_BOX                  =    0x00000ba7,
     332  CL_QTGUI_FRAME                =    0x00000ba8,
     333  CL_QTGUI_WINDOW               =    0x00000ba9,
     334  CL_QTMENU_IMAGE_SCREEN        =    0x00000ba0,
     335  CL_QTGUI_BAR                  =    0x00000ba0,
     336
    324337  /// AUDIO stuff (range from 0x00000c00 to 0x00000cff)
    325338  CL_SOUND_BUFFER               =    0x00000c01,
  • trunk/src/defs/debug.h

    r7374 r7661  
    2828#include "confincl.h"
    2929#ifndef NO_SHELL
    30  #include "shell_buffer.h"
     30#include "lib/shell/shell_buffer.h"
    3131#endif /* NO_SHELL */
    3232
  • trunk/src/defs/globals.h

    r7256 r7661  
    2525#define   DEFAULT_CONFIG_FILE              "~/.orxonox/orxonox.conf"
    2626#define   DEFAULT_LOCK_FILE                "~/.orxonox/orxonox.lock"
    27 #define   DEFAULT_DATA_DIR                 DATADIR "/orxonox/"
     27#define   DEFAULT_DATA_DIR                 ORX_DATADIR "/orxonox/"
    2828#define   DEFAULT_DATA_DIR_CHECKFILE       "data.oxd"
    2929
     
    3333//! Name of Section Misc in the config-File
    3434#define   CONFIG_SECTION_MISC              "misc"
    35 #define   CONFIG_SECTION_MISC_KEYS         "miscKeys"
    36 #define   CONFIG_SECTION_PLAYER            "player"
     35#define   CONFIG_SECTION_CONTROL           "control"
    3736#define   CONFIG_SECTION_VIDEO             "video"
    3837#define   CONFIG_SECTION_VIDEO_ADVANCED    "video_advanced"
    3938#define   CONFIG_SECTION_AUDIO             "audio"
    40 #define   CONFIG_SECTION_EXEC              "exec"
    41 #define   CONFIG_SECTION_DATA              "data"
     39#define   CONFIG_SECTION_GENERAL           "general"
    4240
    4341/*
     
    5452#define   CONFIG_NAME_FOG                  "Fog"
    5553#define   CONFIG_NAME_REFLECTIONS          "Reflections"
    56 #define   CONFIG_NAME_TEXTURES             "TEXTURES"
     54#define   CONFIG_NAME_TEXTURES             "Textures"
    5755#define   CONFIG_NAME_TEXTURE_DETAIL       "Texture-Detail"
    5856#define   CONFIG_NAME_MODEL_DETAIL         "Model-Detail"
     
    6159#define   CONFIG_NAME_FILTER_METHOD        "Filtering-Method"
    6260
     61#define   CONFIG_NAME_SOUNDCARD            "Soundcard"
    6362#define   CONFIG_NAME_DISABLE_AUDIO        "Disable-Audio"
    6463#define   CONFIG_NAME_AUDIO_CHANNELS       "Audio-Channels"
     
    6968#define   CONFIG_NAME_VERBOSE_MODE         "Verbose-Mode"
    7069#define   CONFIG_NAME_ALWAYS_SHOW_GUI      "Always-Show-The-Gui"
     70#define   CONFIG_NAME_DEBUG_LEVEL          "Debug-Level"
     71
    7172// evenets
    7273#define   CONFIG_NAME_PLAYER_FORWARD       "Forward"
     
    8081
    8182#define   CONFIG_NAME_PLAYER_FIRE          "Fire"
    82 #define   CONFIG_NAME_PLAYER_NEXT_WEAPON   "Next"
    83 #define   CONFIG_NAME_PLAYER_PREV_WEAPON   "Prev"
    84 #define   CONFIG_NAME_PLAYER_CHANGE_SHIP   "Change_Ship"
     83#define   CONFIG_NAME_PLAYER_NEXT_WEAPON   "Next-Weapon"
     84#define   CONFIG_NAME_PLAYER_PREV_WEAPON   "Previous-Weapon"
     85#define   CONFIG_NAME_PLAYER_CHANGE_SHIP   "Change-Ship"
    8586
    8687#define   CONFIG_NAME_QUIT                 "Quit"
  • trunk/src/lib/BuildLibs.am

    r7457 r7661  
    33                $(LIB_PREFIX)/libORXlibs.a \
    44                $(LIB_PREFIX)/shell/libORXshell.a \
    5                 $(LIB_PREFIX)/gui/gtk_gui/libORXgui.a \
     5                $(LIB_PREFIX)/gui/qt_gui/libORXqtgui.a \
    66                $(LIB_PREFIX)/gui/gl_gui/libORXglgui.a \
     7                $(LIB_PREFIX)/gui/libORXbasegui.a \
    78                $(LIB_PREFIX)/graphics/importer/libORXimporter.a \
    89                $(LIB_PREFIX)/graphics/libORXgraphics.a \
  • trunk/src/lib/Makefile.am

    r7422 r7661  
    2525                util/preferences.cc \
    2626                util/threading.cc \
     27                util/file.cc \
     28                util/directory.cc \
    2729                \
    2830                data/data_tank.cc
     
    4345                util/preferences.h \
    4446                util/threading.h \
    45                 util/osdir.h \
     47                util/file.h \
     48                util/directory.h \
    4649                \
    4750                util/loading/resource_manager.h \
  • trunk/src/lib/event/key_mapper.cc

    r7256 r7661  
    2727#include "util/preferences.h"
    2828#include "key_names.h"
     29#include "event_def.h"
    2930#include "debug.h"
    3031
     
    7172 * and you do not have to care about The namings, as they might change
    7273 */
    73 orxKeyMapping map[] = {
    74   {&KeyMapper::PEV_FORWARD,              CONFIG_NAME_PLAYER_FORWARD},
    75   {&KeyMapper::PEV_BACKWARD,             CONFIG_NAME_PLAYER_BACKWARD},
    76   {&KeyMapper::PEV_UP,                   CONFIG_NAME_PLAYER_UP},
    77   {&KeyMapper::PEV_DOWN,                 CONFIG_NAME_PLAYER_DOWN},
    78   {&KeyMapper::PEV_LEFT,                 CONFIG_NAME_PLAYER_LEFT},
    79   {&KeyMapper::PEV_RIGHT,                CONFIG_NAME_PLAYER_RIGHT},
    80   {&KeyMapper::PEV_ROLL_LEFT,            CONFIG_NAME_PLAYER_ROLL_RIGHT},
    81   {&KeyMapper::PEV_ROLL_RIGHT,           CONFIG_NAME_PLAYER_ROLL_LEFT},
    82   {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft"},
    83   {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight"},
    84 
    85   {&KeyMapper::PEV_FIRE1,                CONFIG_NAME_PLAYER_FIRE},
    86   {&KeyMapper::PEV_FIRE1,                "Fire1"},
    87   {&KeyMapper::PEV_FIRE2,                "Fire2"},
    88   {&KeyMapper::PEV_NEXT_WEAPON,          CONFIG_NAME_PLAYER_NEXT_WEAPON},
    89   {&KeyMapper::PEV_PREVIOUS_WEAPON,      CONFIG_NAME_PLAYER_PREV_WEAPON},
    90 
    91   {&KeyMapper::PEV_CHANGE_SHIP,          CONFIG_NAME_PLAYER_CHANGE_SHIP},
    92 
    93 
    94   {&KeyMapper::PEV_VIEW0,                CONFIG_NAME_VIEW0},
    95   {&KeyMapper::PEV_VIEW1,                CONFIG_NAME_VIEW1},
    96   {&KeyMapper::PEV_VIEW2,                CONFIG_NAME_VIEW2},
    97   {&KeyMapper::PEV_VIEW3,                CONFIG_NAME_VIEW3},
    98   {&KeyMapper::PEV_VIEW4,                CONFIG_NAME_VIEW4},
    99   {&KeyMapper::PEV_VIEW5,                CONFIG_NAME_VIEW5},
    100 
    101   {&KeyMapper::PEV_NEXT_WORLD,           CONFIG_NAME_NEXT_WORLD},
    102   {&KeyMapper::PEV_PREVIOUS_WORLD,       CONFIG_NAME_PREV_WORLD},
    103 
    104   {&KeyMapper::PEV_PAUSE,                CONFIG_NAME_PAUSE},
    105   {&KeyMapper::PEV_QUIT,                 CONFIG_NAME_QUIT},
    106   {NULL, NULL}
     74KeyMapper::KeyMapping KeyMapper::map[] = {
     75  {&KeyMapper::PEV_FORWARD,              CONFIG_NAME_PLAYER_FORWARD,         SDLK_w},
     76  {&KeyMapper::PEV_BACKWARD,             CONFIG_NAME_PLAYER_BACKWARD,        SDLK_s},
     77  {&KeyMapper::PEV_UP,                   CONFIG_NAME_PLAYER_UP,              SDLK_r},
     78  {&KeyMapper::PEV_DOWN,                 CONFIG_NAME_PLAYER_DOWN,            SDLK_f},
     79  {&KeyMapper::PEV_LEFT,                 CONFIG_NAME_PLAYER_LEFT,            SDLK_a},
     80  {&KeyMapper::PEV_RIGHT,                CONFIG_NAME_PLAYER_RIGHT,           SDLK_d},
     81  {&KeyMapper::PEV_ROLL_RIGHT,           CONFIG_NAME_PLAYER_ROLL_LEFT,       SDLK_z},
     82  {&KeyMapper::PEV_ROLL_LEFT,            CONFIG_NAME_PLAYER_ROLL_RIGHT,      SDLK_c},
     83  {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft",                       SDLK_q},
     84  {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight",                      SDLK_e},
     85
     86  {&KeyMapper::PEV_FIRE1,                CONFIG_NAME_PLAYER_FIRE,            EV_MOUSE_BUTTON_LEFT},
     87  {&KeyMapper::PEV_FIRE2,                "Fire2",                            EV_MOUSE_BUTTON_RIGHT},
     88  {&KeyMapper::PEV_NEXT_WEAPON,          CONFIG_NAME_PLAYER_NEXT_WEAPON,     EV_MOUSE_BUTTON_WHEELUP},
     89  {&KeyMapper::PEV_PREVIOUS_WEAPON,      CONFIG_NAME_PLAYER_PREV_WEAPON,     EV_MOUSE_BUTTON_WHEELDOWN},
     90
     91  {&KeyMapper::PEV_CHANGE_SHIP,          CONFIG_NAME_PLAYER_CHANGE_SHIP,     SDLK_g},
     92
     93
     94  {&KeyMapper::PEV_VIEW0,                CONFIG_NAME_VIEW0,                  SDLK_1},
     95  {&KeyMapper::PEV_VIEW1,                CONFIG_NAME_VIEW1,                  SDLK_2},
     96  {&KeyMapper::PEV_VIEW2,                CONFIG_NAME_VIEW2,                  SDLK_3},
     97  {&KeyMapper::PEV_VIEW3,                CONFIG_NAME_VIEW3,                  SDLK_4},
     98  {&KeyMapper::PEV_VIEW4,                CONFIG_NAME_VIEW4,                  SDLK_5},
     99  {&KeyMapper::PEV_VIEW5,                CONFIG_NAME_VIEW5,                  SDLK_6},
     100
     101  {&KeyMapper::PEV_NEXT_WORLD,           CONFIG_NAME_NEXT_WORLD,             SDLK_x},
     102  {&KeyMapper::PEV_PREVIOUS_WORLD,       CONFIG_NAME_PREV_WORLD,             SDLK_z},
     103
     104  {&KeyMapper::PEV_PAUSE,                CONFIG_NAME_PAUSE,                  SDLK_p},
     105  {&KeyMapper::PEV_QUIT,                 CONFIG_NAME_QUIT,                   SDLK_ESCAPE},
     106  {NULL, "", 0}
    107107};
    108108
     
    138138void KeyMapper::loadKeyBindings(IniParser* iniParser)
    139139{
    140   if( !iniParser->getSection (CONFIG_SECTION_PLAYER "1"))
    141   {
    142     PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1\n");
     140  if( !iniParser->getSection (CONFIG_SECTION_CONTROL))
     141  {
     142    PRINTF(1)("Could not find key bindings " CONFIG_SECTION_CONTROL "\n");
    143143    return;
    144144  }
     
    158158
    159159  // PARSE MISC SECTION
    160   if( !iniParser->getSection (CONFIG_SECTION_MISC_KEYS))
    161   {
    162     PRINTF(1)("Could not find key bindings" CONFIG_SECTION_MISC_KEYS "\n");
     160//   if( !iniParser->getSection (CONFIG_SECTION_MISC_KEYS))
     161//   {
     162//     PRINTF(1)("Could not find key bindings" CONFIG_SECTION_MISC_KEYS "\n");
     163//     return;
     164//   }
     165//
     166//   iniParser->firstVar();
     167//   while( iniParser->getCurrentName() != "" )
     168//   {
     169//     PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
     170//     index = nameToIndex (iniParser->getCurrentValue());
     171//     this->mapKeys(iniParser->getCurrentName(), index);
     172//     iniParser->nextVar();
     173//   }
     174}
     175
     176void KeyMapper::loadKeyBindings()
     177{
     178  if( !Preferences::getInstance()->sectionExists(CONFIG_SECTION_CONTROL))
     179  {
     180    PRINTF(1)("Could not find key bindings " CONFIG_SECTION_CONTROL "\n");
    163181    return;
    164182  }
    165 
    166   iniParser->firstVar();
    167   while( iniParser->getCurrentName() != "" )
    168   {
    169     PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
    170     index = nameToIndex (iniParser->getCurrentValue());
    171     this->mapKeys(iniParser->getCurrentName(), index);
    172     iniParser->nextVar();
    173   }
    174 }
    175 
    176 void KeyMapper::loadKeyBindings()
    177 {
    178   if( !Preferences::getInstance()->sectionExists(CONFIG_SECTION_PLAYER "1"))
    179   {
    180     PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1\n");
    181     return;
    182   }
    183183  int* index;
    184184
    185   std::list<std::string> keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_PLAYER "1");
     185  std::list<std::string> keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_CONTROL);
    186186  for ( std::list<std::string>::const_iterator it = keys.begin(); it!=keys.end(); it++ )
    187187  {
    188     PRINTF(3)("Keys: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_PLAYER "1", *it, "").c_str());
     188    PRINTF(3)("Keys: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_CONTROL, *it, "").c_str());
    189189    // map the name to an sdl index
    190     index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_PLAYER "1", *it, ""));
     190    index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_CONTROL, *it, ""));
    191191    // map the index to a internal name
    192     this->mapKeys(*it, index);
    193   }
    194 
    195 
    196   // PARSE MISC SECTION
    197   if( !Preferences::getInstance()->sectionExists (CONFIG_SECTION_MISC_KEYS))
    198   {
    199     PRINTF(1)("Could not find key bindings " CONFIG_SECTION_MISC_KEYS "\n");
    200     return;
    201   }
    202 
    203   keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_MISC_KEYS);
    204   for ( std::list<std::string>::const_iterator it = keys.begin(); it!=keys.end(); it++ )
    205   {
    206     PRINTF(3)("MISC: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_MISC_KEYS, *it, "").c_str());
    207     index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_MISC_KEYS, *it, ""));
    208192    this->mapKeys(*it, index);
    209193  }
     
    266250  for(int i = 0; map[i].pValue != NULL; ++i)
    267251    {
    268       PRINT(0)("%s = %i\n",map[i].pName, *map[i].pValue);
     252      PRINT(0)("%s = %i\n",map[i].pName.c_str(), *map[i].pValue);
    269253    }
    270254  PRINT(0)("=======================================================\n");
  • trunk/src/lib/event/key_mapper.h

    r7256 r7661  
    1010
    1111#include "base_object.h"
    12 //#include "event_def.h"
    13 
     12#include <string>
    1413class IniParser;
    1514
    16 //! A mapping from key-name to key-id
    17 typedef struct orxKeyMapping
     15//! The map class functionalities
     16class KeyMapper : public BaseObject
    1817{
    19   int* pValue;
    20   char* pName;
    21 };
     18public:
     19  //! A mapping from key-name to key-id
     20  typedef struct KeyMapping
     21  {
     22    int*              pValue;
     23    const std::string pName;
     24    int               defaultValue;
     25  };
    2226
    23 
    24 //! The map class functionalities
    25 class KeyMapper : public BaseObject {
    26 
    27  public:
     27public:
    2828  KeyMapper();
    2929  virtual ~KeyMapper();
     
    3333  void loadKeyBindings(IniParser* iniParser);
    3434
     35  static const KeyMapping* getKeyMapping() { return KeyMapper::map; };
     36
    3537  void debug();
    3638
    37  private:
     39private:
    3840  int* nameToIndex (const std::string& name);
    3941  void mapKeys(const std::string& name, int* index);
    4042
    41  public:
     43public:
    4244  static int PEV_FORWARD;           //!< forward button
    4345  static int PEV_BACKWARD;          //!< backward buttton
     
    7375  static int PEV_QUIT;              //!< quit button
    7476
    75  private:
    76   int         coord[2];              //!< temp place to save variables in nameToIndex() function
     77private:
     78  int                coord[2];      //!< temp place to save variables in nameToIndex() function
     79  static KeyMapping  map[];         //!< The KeyMapping that maps strings to ID's and Vice Versa
    7780};
    7881
  • trunk/src/lib/event/key_names.cc

    r7221 r7661  
    1717#include "event_def.h"
    1818
    19 #include "stdincl.h"
    20 
    21 #include <string.h>
    22 
    23 using namespace std;
     19std::string EVToKeyName(int key)
     20{
     21  std::string name = SDLBToButtonname( key );
     22  if (name != "UNKNOWN")
     23    return name;
     24  else
     25    return SDLKToKeyname( key );
     26}
     27
     28int KeyNameToEV(const std::string& keyName)
     29{
     30  int key = buttonnameToSDLB( keyName );
     31  if (key != -1)
     32    return key;
     33  else
     34    return keynameToSDLK( keyName );
     35}
     36
    2437
    2538int buttonnameToSDLB(const std::string& name)
     
    3346}
    3447
    35 const char* SDLBToButtonname( int button)
     48std::string SDLBToButtonname( int button)
    3649{
    3750        if( button == EV_MOUSE_BUTTON_LEFT) return "BUTTON_LEFT";
     
    181194}
    182195
    183 const char* SDLKToKeyname(int key)
     196std::string SDLKToKeyname(int key)
    184197{
    185198        if( key == SDLK_BACKSPACE) return "BACKSPACE";
  • trunk/src/lib/event/key_names.h

    r7221 r7661  
    1111
    1212/**
    13  *  converts a button name string to a integer representing the corresponding SDL mouse button identifier
     13 * @brief converts an EVKey into a String, naming the Event.
     14 * @param key the Key (either key or button) to convert.
     15 * @returns the String containing the Event.
     16 */
     17std::string EVToKeyName(int key);
     18/**
     19 * @brief converts a KeyName into an Event.
     20 * @param keyName the Key to transform.
     21 * @returns the Event-Number
     22 */
     23int KeyNameToEV(const std::string& keyName);
     24
     25
     26/**
     27 * @brief converts a button name string to a integer representing the corresponding SDL mouse button identifier
    1428 * @param name: the name of the mouse button
    1529 * @return an int containing the SDL identifier of the mouse button or -1 if the button name is not valid
     
    1832
    1933/**
    20  * converst a SDL mouse button identifier to a name string
     34 * @brief converst a SDL mouse button identifier to a name string
    2135 * @param button: an SDL mouse button identifier
    2236 * @return a pointer to a string containing the name of the mouse button
    2337 */
    24 const char* SDLBToButtonname( int button);
     38std::string SDLBToButtonname( int button);
    2539
    2640/**
    27  * converts a key name string to a integer representing the corresponding SDLK sym
     41 * @brief converts a key name string to a integer representing the corresponding SDLK sym
    2842 * @param name: the name of the key
    2943 * @return the SDLK sym of the named key or -1 if the key name is not valid
     
    3246
    3347/**
    34  * converts an SDLK sym to a name string
     48 * @brief converts an SDLK sym to a name string
    3549 * @param key: the SDLK sym
    3650 * @return a pointer to a string containig the name of the key
    3751 */
    38 const char* SDLKToKeyname( int key);
    39 
     52std::string SDLKToKeyname( int key);
    4053
    4154#endif /* _KEY_NAMES_H */
  • trunk/src/lib/graphics/graphics_engine.cc

    r7428 r7661  
    155155{
    156156  // looking if we are in fullscreen-mode
    157   const std::string fullscreen = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_FULLSCREEN, "0");
    158 
    159   if (fullscreen[0] == '1' || fullscreen == "true")
     157  MultiType fullscreen = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_FULLSCREEN, "0");
     158
     159  if (fullscreen.getBool())
    160160    this->fullscreenFlag = SDL_FULLSCREEN;
    161161
    162162  // looking if we are in fullscreen-mode
    163   const std::string textures = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO_ADVANCED, CONFIG_NAME_TEXTURES, "0");
    164   if (textures[0] == '1' || textures == "true")
    165     Texture::setTextureEnableState(true);
    166   else
    167     Texture::setTextureEnableState(false);
     163  MultiType textures = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO_ADVANCED, CONFIG_NAME_TEXTURES, "1");
     164    Texture::setTextureEnableState(textures.getBool());
    168165
    169166  // searching for a usefull resolution
  • trunk/src/lib/gui/Makefile.am

    r5315 r7661  
    1 SUBDIRS = gtk_gui \
    2           gl_gui
     1MAINSRCDIR=../..
     2include $(MAINSRCDIR)/defs/include_paths.am
     3
     4AM_LDFLAGS =
     5
     6noinst_LIBRARIES = libORXbasegui.a
     7
     8
     9libORXbasegui_a_SOURCES = \
     10                gui_element.cc \
     11                gui_saveable.cc \
     12                gui.cc
     13
     14
     15noinst_HEADERS= \
     16                gui_element.h \
     17                gui_saveable.h \
     18                gui.h
     19
     20
     21EXTRA_DIST =
     22
     23SUBDIRS = \
     24        . \
     25        gl_gui \
     26        qt_gui
     27
     28#       gtk_gui
  • trunk/src/lib/gui/gtk_gui/Makefile.am

    r5463 r7661  
    22include $(MAINSRCDIR)/defs/include_paths.am
    33
    4 noinst_LIBRARIES = libORXgui.a
     4noinst_LIBRARIES = libORXgtkgui.a
    55
    6 libORXgui_a_CPPFLAGS = -DBUILD_ORXONOX \
    7                         $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
     6libORXgtkgui_a_CPPFLAGS = \
     7                -DBUILD_ORXONOX \
     8                $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
    89
    9 libORXgui_a_SOURCES = gui.cc \
    10                       gui_gtk.cc \
    11                       gui_element.cc \
    12                       gui_video.cc \
    13                       gui_audio.cc \
    14                       gui_exec.cc \
    15                       gui_flags.cc \
    16                       gui_banner.cc \
    17                       gui_keys.cc \
    18                       gui_update.cc
     10libORXgtkgui_a_SOURCES = \
     11                gui.cc \
     12                gui_gtk.cc \
     13                gui_element.cc \
     14                gui_video.cc \
     15                gui_audio.cc \
     16                gui_exec.cc \
     17                gui_flags.cc \
     18                gui_banner.cc \
     19                gui_keys.cc \
     20                gui_update.cc
    1921
    2022noinst_HEADERS= gui.h \
    21                 gui_gtk.h \
    22                 gui_element.h \
    23                 gui_video.h \
    24                 gui_audio.h \
    25                 gui_exec.h \
    26                 gui_flags.h \
    27                 gui_banner.h \
    28                 gui_keys.h \
    29                 gui_update.h
     23                gui_gtk.h \
     24                gui_element.h \
     25                gui_video.h \
     26                gui_audio.h \
     27                gui_exec.h \
     28                gui_flags.h \
     29                gui_banner.h \
     30                gui_keys.h \
     31                gui_update.h
    3032
    3133EXTRA_DIST = rc \
  • trunk/src/lib/gui/gtk_gui/gui_element.h

    r5039 r7661  
    1 /*! 
     1/*!
    22 * @file gui_element.h
    3   *  Definition of ...
     3 *  Definition of ...
    44
    55*/
     
    1616  GuiElement();
    1717  virtual ~GuiElement();
    18  
     18
    1919  /** @returns the main Widget of this GuiElement. */
    20   Widget* getWidget() {return this->mainWidget;}
     20  Widget* getWidget() { return this->mainWidget; }
    2121 protected:
    2222  void setMainWidget(Widget* widget);
    23  
     23
    2424 private:
    2525  Widget* mainWidget;
  • trunk/src/lib/gui/gtk_gui/gui_exec.cc

    r7221 r7661  
    2626#include "gui_exec.h"
    2727
     28#include "file.h"
    2829#include "util/loading/resource_manager.h"
    2930#include "parser/ini_parser/ini_parser.h"
     
    3334#include <sys/stat.h>
    3435#include <sys/types.h>
     36
    3537
    3638
     
    147149void GuiExec::setConfDir(const char* confDir)
    148150{
    149   this->confDir = ResourceManager::homeDirCheck(confDir);
     151  this->confDir = File(confDir).name();
    150152
    151153  PRINTF(5)("Config Directory is: %s.\n", this->confDir);
     
    199201  IniParser iniParser;
    200202  this->writeFileText(widget, &iniParser, 0);
    201   std::string fileName = ResourceManager::homeDirCheck(confFile);
    202   iniParser.writeFile(fileName);
     203  iniParser.writeFile(File(confFile).name());
    203204}
    204205
     
    253254void GuiExec::readFromFile(Widget* widget)
    254255{
    255   std::string fileName = ResourceManager::homeDirCheck(confFile);
     256  std::string fileName = File(confFile).name();
    256257  IniParser iniParser(fileName);
    257258  if (!iniParser.isOpen())
  • trunk/src/lib/gui/gtk_gui/gui_update.cc

    r5766 r7661  
    5151
    5252  this->updateFrame = new Frame("Update-Options:");
    53   this->updateFrame->setGroupName(CONFIG_SECTION_DATA);
     53  this->updateFrame->setGroupName(CONFIG_SECTION_GENERAL);
    5454  this->updateBox = new Box('v');
    5555
  • trunk/src/lib/lang/base_object.cc

    r7429 r7661  
    2020
    2121#include "util/loading/load_param.h"
    22 #include "compiler.h"
    2322#include "class_list.h"
    2423
     
    3231 * @param root the element to load from
    3332 */
    34 BaseObject::BaseObject()
     33BaseObject::BaseObject(const std::string& objectName)
    3534{
    3635  this->classID = CL_BASE_OBJECT;
    3736  this->className = "BaseObject";
    3837
    39   this->objectName = "";
     38  this->objectName = objectName;
    4039  this->classList = NULL;
    4140  this->xmlElem = NULL;
  • trunk/src/lib/lang/base_object.h

    r7221 r7661  
    2727
    2828 public:
    29   BaseObject ();
     29   BaseObject (const std::string& objectName = "");
    3030  virtual ~BaseObject ();
    3131
  • trunk/src/lib/parser/ini_parser/ini_parser.cc

    r7256 r7661  
    108108  if( (stream = fopen (fileName.c_str(), "r")) == NULL)
    109109  {
    110     PRINTF(1)("IniParser could not open %s\n", fileName.c_str());
     110    PRINTF(1)("IniParser could not open %s for reading\n", fileName.c_str());
    111111    return false;
    112112  }
     
    216216  if( (stream = fopen (fileName.c_str(), "w")) == NULL)
    217217  {
    218     PRINTF(1)("IniParser could not open %s\n", fileName.c_str());
     218    PRINTF(1)("IniParser could not open %s for writing\n", fileName.c_str());
    219219    return false;
    220220  }
     
    401401 * @return true if everything is ok false on error
    402402 */
    403 bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName)
     403bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName, bool createMissing)
    404404{
    405405  std::list<IniSection>::iterator section;
     
    416416  if (section == this->sections.end())
    417417  {
    418     IniSection sec;
    419     sec.comment = "";
    420     sec.name = sectionName;
    421     section = this->sections.insert(this->sections.end(), sec);
    422   }
    423 
    424   if (section == this->sections.end())
    425   {
    426     PRINTF(2)("section '%s' not found for value '%s'\n", sectionName.c_str(), entryName.c_str());
    427     return false;
    428   }
    429   else
    430   {
    431     //try find item
    432     std::list<IniEntry>::iterator entry;
    433     for (entry = section->entries.begin(); entry!=section->entries.end(); entry++)
    434       if (entry->name == entryName )
     418    this->addSection(sectionName);
     419    for (section = this->sections.begin(); section != this->sections.end(); section++)
     420      if ((*section).name == sectionName)
    435421        break;
    436 
    437     //found it?
    438     if ( entry != section->entries.end() )
    439     {
    440       entry->value = value;
    441 
    442       return true;
    443     }
    444 
     422  }
     423
     424  //try find item
     425  std::list<IniEntry>::iterator entry;
     426  for (entry = section->entries.begin(); entry!=section->entries.end(); entry++)
     427    if (entry->name == entryName )
     428      break;
     429
     430  //found it?
     431  if ( entry != section->entries.end() )
     432  {
     433    entry->value = value;
     434
     435    return true;
     436  }
     437  else
     438  {
    445439    //not found -> create it
    446440    (*section).entries.push_back(IniEntry());
     
    448442    (*section).entries.back().name = entryName;
    449443    (*section).entries.back().value = value;
    450     PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",
    451     (*section).entries.back().name.c_str(),
    452     (*section).entries.back().value.c_str(),
    453     (*section).name);
     444    PRINTF(5)("Added Entry '%s' with Value '%s' to Section '%s'\n",
     445              (*section).entries.back().name.c_str(),
     446              (*section).entries.back().value.c_str(),
     447              (*section).name);
    454448    this->currentEntry = --(*section).entries.end();
    455449    return true;
    456450  }
     451  return false;
    457452}
    458453
     
    725720void IniParser::debug() const
    726721{
    727   PRINTF(0)("Iniparser %s - debug\n", this->fileName.c_str());
     722  PRINT(0)("Iniparser '%s' - debug\n", this->fileName.c_str());
    728723  if (!this->comment.empty())
    729     PRINTF(0)("FileComment:\n %s\n\n", this->comment.c_str());
     724    PRINT(0)("FileComment:\n '%s'\n\n", this->comment.c_str());
    730725
    731726  if (!this->fileName.empty())
    732727  {
     728    if (sections.empty())
     729      PRINT(0)("No Sections defined\n");
    733730    std::list<IniSection>::const_iterator section;
    734731    for (section = this->sections.begin(); section != this->sections.end(); section++)
     
    737734        PRINTF(0)(" %s\n", (*section).comment.c_str());
    738735      PRINTF(0)(" [%s]\n", (*section).name.c_str());
     736
     737      if ((*section).entries.empty())
     738        PRINT(0)("No Entries defined within Section '%s'\n", (*section).name.c_str());
    739739
    740740      std::list<IniEntry>::const_iterator entry;
     
    748748  }
    749749  else
    750     PRINTF(1)("no opened ini-file.\n");
    751 }
    752 
     750    PRINTF(0)("no opened ini-file.\n");
     751}
     752
  • trunk/src/lib/parser/ini_parser/ini_parser.h

    r7256 r7661  
    1010
    1111#define PARSELINELENGHT     512       //!< how many chars to read at once
    12 #ifndef NULL
    13  #define NULL 0x0                     //!< NULL
    14 #endif
    1512
     13#include "src/lib/util/file.h"
    1614#include <list>
    17 #include <string>
    1815
    1916//! ini-file parser
     
    2118 * This class can be used to load an initializer file and parse it's contents for variablename=value pairs.
    2219 */
    23 class IniParser
     20class IniParser : public File
    2421{
    2522  private:
     
    4744
    4845    /** @returns true if the file is opened, false otherwise*/
    49     bool isOpen() const { return (!this->fileName.empty())? true : false; };
     46    bool isOpen() const { return true; } ///HACK //(this->fileName.empty()) ? false : true; };
    5047    /** @returns the fileName we have opened. */
    5148    const std::string& getFileName() const { return this->fileName; };
     
    6966    bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" );
    7067    const std::string& getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue = "") const;
    71     bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "");
     68    bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "", bool createMissing = true);
    7269    void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName);
    7370    const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const;
  • trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc

    r7256 r7661  
    2828  IniParser iniParser;
    2929
     30 
     31  Preferences* prefs = Preferences::getInstance();
     32 
     33  prefs->setUserIni( fileName );
     34 
    3035  if ( !iniParser.readFile( fileName ) )
    3136    return;
    32 
    33   Preferences* prefs = Preferences::getInstance();
    3437
    3538  iniParser.firstSection();
  • trunk/src/lib/particles/dot_emitter.cc

    r7302 r7661  
    2323#include "util/loading/factory.h"
    2424#include "debug.h"
    25 #include "stdlibincl.h"
    2625
    2726using namespace std;
  • trunk/src/lib/shell/shell_buffer.h

    r7374 r7661  
    1010#include <stdarg.h>
    1111#include <list>
    12 #include "threading.h"
     12#include "lib/util/threading.h"
    1313
    1414#define      SHELL_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
  • trunk/src/lib/shell/shell_completion_plugin.cc

    r7424 r7661  
    2525#include "loading/resource_manager.h"
    2626
    27 #include "osdir.h"
     27#include "directory.h"
    2828#include "debug.h"
    2929
     
    9494  void CompletorFileSystem::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const
    9595  {
    96     OS::Directory dir;
     96    Directory dir;
    9797
    9898    if (completionBegin.empty()) // if we do not yet have the beginning of the line, start with the chosen startDir.
    9999    {
    100       dir.open(ResourceManager::getInstance()->getDataDir() + this->_subDir);
     100      dir.setFileName(ResourceManager::getInstance()->getDataDir() + this->_subDir);
     101      dir.open();
    101102      while(dir)
    102103      {
     
    112113        directoryName = completionBegin.substr(0, pos);
    113114
    114       dir.open(ResourceManager::getInstance()->getDataDir() + directoryName);
     115      dir.setFileName(ResourceManager::getInstance()->getDataDir() + directoryName);
     116      dir.open();
    115117
    116118      std::string fileName;
     
    136138        printf("%s\n", (ResourceManager::getInstance()->getDataDir() + fileName).c_str());
    137139        if (!nocaseCmp(completionBegin, fileName, completionBegin.size()) &&
    138              ResourceManager::isDir(ResourceManager::getInstance()->getDataDir() + fileName))
     140             ResourceManager::isInDataDir(fileName))
    139141        {
    140142          printf("Dir %s\n", fileName.c_str());
  • trunk/src/lib/util/loading/resource_manager.cc

    r7460 r7661  
    1717
    1818#include "util/loading/resource_manager.h"
    19 
     19#include "file.h"
    2020#include "substring.h"
    2121#include "debug.h"
     
    6060
    6161  this->dataDir = "./";
    62   this->_cwd = "";
    6362  this->tryDataDir("./data");
    6463}
     
    8786bool ResourceManager::setDataDir(const std::string& dataDir)
    8887{
    89   std::string realDir = ResourceManager::homeDirCheck(dataDir);
    90   if (isDir(realDir))
    91   {
    92     if (dataDir[dataDir.size()-1] == '/' || dataDir[dataDir.size()-1] == '\\')
     88  File dataDirectory(dataDir);
     89  if (dataDirectory.isDirectory())
     90  {
     91    this->dataDir = dataDirectory.name();
     92
     93    if (dataDir[dataDir.size()-1] != '/' && dataDir[dataDir.size()-1] != '\\')
    9394    {
    94       this->dataDir = realDir;
    95     }
    96     else
    97     {
    98       this->dataDir = realDir;
    9995      this->dataDir += '/';
    10096    }
     
    10399  else
    104100  {
    105     PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir.c_str(), this->dataDir.c_str());
     101    PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", dataDir.c_str(), this->dataDir.c_str());
    106102    return false;
    107103  }
     
    116112bool ResourceManager::tryDataDir(const std::string& dataDir)
    117113{
    118   std::string realDir = ResourceManager::homeDirCheck(dataDir);
    119   if (isDir(realDir))
    120   {
    121     if (dataDir[dataDir.size()-1] == '/' || dataDir[dataDir.size()-1] == '\\')
     114  File dataDirectory(dataDir);
     115  if (dataDirectory.isDirectory())
     116  {
     117    this->dataDir = dataDirectory.name();
     118
     119    if (dataDir[dataDir.size()-1] != '/' && dataDir[dataDir.size()-1] != '\\')
    122120    {
    123       this->dataDir = realDir;
    124     }
    125     else
    126     {
    127       this->dataDir = realDir;
    128121      this->dataDir += '/';
    129122    }
     
    140133bool ResourceManager::verifyDataDir(const std::string& fileInside)
    141134{
    142   bool retVal;
    143   if (!isDir(this->dataDir))
    144   {
    145     PRINTF(1)("%s is not a directory\n", this->dataDir.c_str());
     135  File dataDirectory(this->dataDir);
     136  if (!dataDirectory.isDirectory())
     137  {
     138    PRINTF(1)("'%s' is not a directory\n", this->dataDir.c_str());
    146139    return false;
    147140  }
    148141
    149   std::string testFile = this->dataDir + fileInside;
    150   retVal = isFile(testFile);
    151   return retVal;
     142  File testFile(this->dataDir + fileInside);
     143  return testFile.isFile();
    152144}
    153145
     
    161153bool ResourceManager::addImageDir(const std::string& imageDir)
    162154{
    163   std::string newDir;
    164   if (imageDir[imageDir.size()-1] == '/' || imageDir[imageDir.size()-1] == '\\')
    165   {
    166     newDir = imageDir;
    167   }
    168   else
    169   {
    170     newDir = imageDir;
     155  std::string newDir = imageDir;
     156  if (imageDir[imageDir.size()-1] != '/' && imageDir[imageDir.size()-1] != '\\')
     157  {
    171158    newDir += '/';
    172159  }
    173160  // check if the param is a Directory
    174   if (isDir(newDir))
     161  if (File(newDir).isDirectory())
    175162  {
    176163    // check if the Directory has been added before
     
    381368        tmpResource->param[0] = 1.0f;
    382369
    383       if(ResourceManager::isFile(fullName))
     370      if(File(fullName).isFile())
    384371        tmpResource->pointer = new OBJModel(fullName, tmpResource->param[0].getFloat());
    385372      else
     
    407394      break;
    408395    case MD2:
    409       if(ResourceManager::isFile(fullName))
     396      if(File(fullName).isFile())
    410397      {
    411398        tmpResource->param[0] = param0;
     
    425412        tmpResource->param[0] = FONT_DEFAULT_RENDER_SIZE;
    426413
    427       if(isFile(fullName))
     414      if(File(fullName).isFile())
    428415        tmpResource->pointer = new Font(fullName, (unsigned int) tmpResource->param[0].getInt());
    429416      else
     
    433420#ifndef NO_AUDIO
    434421    case WAV:
    435       if(isFile(fullName))
     422      if(File(fullName).isFile())
    436423        tmpResource->pointer = new OrxSound::SoundBuffer(fullName);
    437424      break;
    438425    case OGG:
    439       if (isFile(fullName))
     426      if (File(fullName).isFile())
    440427        tmpResource->pointer = new OrxSound::OggPlayer(fullName);
    441428      break;
     
    447434      else
    448435        tmpResource->param[0] = GL_TEXTURE_2D;
    449       if(isFile(fullName))
     436      if(File(fullName).isFile())
    450437      {
    451438        PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
     
    458445        {
    459446          std::string imgName = *imageDir + fileName;
    460           if(isFile(imgName))
     447          if(File(imgName).isFile())
    461448          {
    462449            PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
     
    472459#ifndef NO_SHADERS
    473460    case SHADER:
    474       if(ResourceManager::isFile(fullName))
     461      if(File(fullName).isFile())
    475462      {
    476463        if (param0 != MT_NULL)
     
    478465          MultiType param = param0; /// HACK
    479466          std::string secFullName = ResourceManager::getFullName(param.getCString());
    480           if (ResourceManager::isFile(secFullName))
     467          if (File(secFullName).isFile())
    481468          {
    482469            tmpResource->param[0] = secFullName;
     
    750737
    751738/**
    752  * @brief Checks if it is a Directory
    753  * @param directoryName the Directory to check for
    754  * @returns true if it is a directory/symlink false otherwise
    755 */
    756 bool ResourceManager::isDir(const std::string& directoryName)
    757 {
    758   std::string tmpDirName = directoryName;
    759   struct stat status;
    760 
    761   // checking for the termination of the string given. If there is a "/" at the end cut it away
    762   if (directoryName[directoryName.size()-1] == '/' ||
    763       directoryName[directoryName.size()-1] == '\\')
    764   {
    765     tmpDirName.erase(tmpDirName.size()-1);
    766   }
    767 
    768   if(!stat(tmpDirName.c_str(), &status))
    769   {
    770     if (status.st_mode & (S_IFDIR
    771 #ifndef __WIN32__
    772                           | S_IFLNK
    773 #endif
    774                          ))
    775     {
    776       return true;
    777     }
    778     else
    779       return false;
    780   }
    781   else
    782     return false;
    783 }
    784 
    785 /**
    786  * @brief Checks if the file is either a Regular file or a Symlink
    787  * @param fileName the File to check for
    788  * @returns true if it is a regular file/symlink, false otherwise
    789 */
    790 bool ResourceManager::isFile(const std::string& fileName)
    791 {
    792   if (fileName.empty())
    793     return false;
    794   std::string tmpFileName = ResourceManager::homeDirCheck(fileName);
    795   // actually checks the File
    796   struct stat status;
    797   if (!stat(tmpFileName.c_str(), &status))
    798   {
    799     if (status.st_mode & (S_IFREG
    800 #ifndef __WIN32__
    801                           | S_IFLNK
    802 #endif
    803                          ))
    804     {
    805       return true;
    806     }
    807     else
    808       return false;
    809   }
    810   else
    811     return false;
    812 }
    813 
    814 /**
    815  * @brief touches a File on the disk (thereby creating it)
    816  * @param fileName The file to touch
    817 */
    818 bool ResourceManager::touchFile(const std::string& fileName)
    819 {
    820   std::string tmpName = ResourceManager::homeDirCheck(fileName);
    821   if (tmpName.empty())
    822     return false;
    823   FILE* stream;
    824   if( (stream = fopen (tmpName.c_str(), "w")) == NULL)
    825   {
    826     PRINTF(1)("could not open %s fro writing\n", fileName.c_str());
    827     return false;
    828   }
    829   fclose(stream);
    830 }
    831 
    832 /**
    833  * @brief deletes a File from disk
    834  * @param fileName the File to delete
    835 */
    836 bool ResourceManager::deleteFile(const std::string& fileName)
    837 {
    838   std::string tmpName = ResourceManager::homeDirCheck(fileName);
    839   unlink(tmpName.c_str());
    840 }
    841 
    842 /**
    843  * @param name the Name of the file to check
    844  * @returns The name of the file, including the HomeDir
    845  */
    846 std::string ResourceManager::homeDirCheck(const std::string& name)
    847 {
    848   if (name.size() >= 2 && name[0] == '~' && name[1] == '/')
    849   {
    850     std::string homeDir;
    851     std::string newName = name.substr(1);
    852 #ifdef __WIN32__
    853     homeDir = getenv("USERPROFILE");
    854 #else
    855     homeDir = getenv("HOME");
    856 #endif
    857     return homeDir + newName;
    858   }
    859   else
    860     return name;
    861 }
    862 
    863 /**
    864  * @param name the relative name of the File/Directory.
    865  * @returns a new std::string with the name in abs-dir-format
    866  */
    867 std::string ResourceManager::getAbsDir(const std::string& name)
    868 {
    869   if (name.empty())
    870     return "";
    871   std::string retName = name;
    872   if (strncmp(name.c_str(), "/", 1))
    873   {
    874     if (name[0] == '.' && name[1] != '.')
    875       retName.erase(0);
    876     const std::string& absDir = ResourceManager::cwd();
    877     retName = absDir + retName;
    878   }
    879   return retName;
    880 }
    881 
    882 
    883 /**
    884739 * @param fileName the Name of the File to check
    885740 * @returns The full name of the file, including the DataDir, and NULL if the file does not exist
     
    892747
    893748  std::string retName = ResourceManager::getInstance()->getDataDir() +fileName;
    894   if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName))
     749  if (File(retName).isFile() || File(retName).isDirectory())
    895750    return retName;
    896751  else
    897752    return "";
    898 }
    899 
    900 #ifdef __unix__
    901   #include <unistd.h>
    902 #elif __WIN32__ || _MS_DOS_
    903   #include <dir.h>
    904 #else
    905   #include <direct.h> /* Visual C++ */
    906 #endif
    907 /**
    908  * @returns the Current Woring Directory
    909  */
    910 const std::string& ResourceManager::cwd()
    911 {
    912   if (ResourceManager::getInstance()->_cwd.empty())
    913   {
    914     char cwd[1024];
    915     char* errorCode = getcwd(cwd, 1024);
    916     if (errorCode == 0)
    917       return ResourceManager::getInstance()->_cwd;
    918 
    919     ResourceManager::getInstance()->_cwd = cwd;
    920   }
    921   return ResourceManager::getInstance()->_cwd;
    922753}
    923754
     
    936767  std::string checkFile = ResourceManager::getInstance()->getDataDir() + fileName;
    937768
    938   if (ResourceManager::isFile(checkFile) || ResourceManager::isDir(checkFile))
     769  if (File(checkFile).exists())
    939770    retVal = true;
    940771  else
  • trunk/src/lib/util/loading/resource_manager.h

    r7225 r7661  
    2121
    2222#include "base_object.h"
     23#include "file.h"
     24
    2325#include "multi_type.h"
    24 
    2526#include <vector>
    2627
     
    130131
    131132  // utility functions for handling files in and around the data-directory
    132   static bool isDir(const std::string& directory);
    133   static bool isFile(const std::string& fileName);
    134   static bool touchFile(const std::string& fileName);
    135   static bool deleteFile(const std::string& fileName);
    136   static std::string homeDirCheck(const std::string& fileName);
    137133  static std::string getFullName(const std::string& fileName);
    138134  static bool isInDataDir(const std::string& fileName);
    139   static std::string getAbsDir(const std::string& fileName);
    140   static const std::string& cwd();
    141135
    142136  static const char* ResourceTypeToChar(ResourceType type);
     
    151145  static ResourceManager*    singletonRef;       //!< singleton Reference
    152146
    153   std::string                _cwd;               //!< The currend Working directory.
    154147  std::string                dataDir;            //!< The Data Directory, where all relevant Data is stored.
    155148  std::vector<std::string>   imageDirs;          //!< A list of directories in which images are stored.
  • trunk/src/lib/util/preferences.cc

    r7256 r7661  
    1717
    1818#include "preferences.h"
    19 
    20 using namespace std;
     19#include "lib/parser/ini_parser/ini_parser.h"
    2120
    2221
     
    137136 * @return value of the item if found. defaultValue else
    138137 */
    139 const std::string Preferences::getString(const std::string& section, const std::string& name, const std::string& defaultValue)
     138std::string Preferences::getString(const std::string& section, const std::string& name, const std::string& defaultValue)
    140139{
    141140  return getMultiType(section, name, MultiType(defaultValue)).getString();
     
    260259  IniParser iniParser(this->fileName);
    261260
    262   if ( !iniParser.isOpen() )
    263     return false;
    264 
    265261  std::list<prefSection>::iterator it = data.begin();
    266262  bool didChanges = false;
     
    278274    }
    279275  }
    280 
    281   if ( didChanges )
     276  /// HACK DO WE HAVE TO CHECK THIS??
     277  //if ( didChanges )
    282278  {
    283279    iniParser.writeFile( this->fileName );
     
    314310{
    315311  std::list<std::string> lst;
    316  
     312
    317313  std::list<prefSection>::const_iterator it = data.begin();
    318314
  • trunk/src/lib/util/preferences.h

    r7256 r7661  
    99#include "base_object.h"
    1010#include "multi_type.h"
    11 #include "lib/parser/ini_parser/ini_parser.h"
    1211
    1312// FORWARD DECLARATION
     
    4443   void setMultiType(const std::string& section, const std::string& name, const MultiType& value, bool dontSetModified = false);
    4544
    46    const std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue);
     45   std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue);
    4746   int getInt(const std::string& section, const std::string& name, int defaultValue);
    4847   float getFloat(const std::string& section, const std::string& name, float defaultValue);
     
    5453
    5554   void debug();
    56    
     55
    5756   std::list<std::string> listKeys( const std::string section );
    5857
  • trunk/src/orxonox.cc

    r7460 r7661  
    3030#include "globals.h"
    3131
    32 #include "gui.h"
    33 
     32#include "gui/qt_gui/qt_gui.h"
     33
     34#include "file.h"
    3435#include "parser/ini_parser/ini_parser.h"
    3536#include "util/loading/game_loader.h"
     
    189190const std::string& Orxonox::getConfigFile ()
    190191{
    191   if (ResourceManager::isFile("orxonox.conf"))
     192  File orxConfFile("orxonox.conf");
     193  if (orxConfFile.isFile())
    192194  {
    193195    this->configFileName =  "orxonox.conf";
    194196  }
    195197  else
    196     this->configFileName = ResourceManager::homeDirCheck(DEFAULT_CONFIG_FILE);
     198    this->configFileName = File(DEFAULT_CONFIG_FILE).name();
    197199
    198200  PRINTF(3)("Parsed Config File: '%s'\n", this->configFileName);
     
    280282  PRINT(3)("> Initializing input\n");
    281283
     284  EventHandler::getInstance()->
    282285  EventHandler::getInstance()->init();
    283286  EventHandler::getInstance()->subscribe(GraphicsEngine::getInstance(), ES_ALL, EV_VIDEO_RESIZE);
     
    319322  // init the resource manager
    320323  std::string dataPath;
    321   if ((dataPath = Preferences::getInstance()->getString(CONFIG_SECTION_DATA, CONFIG_NAME_DATADIR, ""))!= "")
     324  if ((dataPath = Preferences::getInstance()->getString(CONFIG_SECTION_GENERAL, CONFIG_NAME_DATADIR, ""))!= "")
    322325  {
    323326    if (!ResourceManager::getInstance()->setDataDir(dataPath) &&
     
    334337    ResourceManager::getInstance()->getDataDir().c_str(),
    335338    this->configFileName.c_str(),
    336               CONFIG_SECTION_DATA,
     339              CONFIG_SECTION_GENERAL,
    337340              CONFIG_NAME_DATADIR );
    338     Gui* gui = new Gui(argc, argv);
     341    OrxGui::Gui* gui = new OrxGui::QtGui(argc, argv);
    339342    gui->startGui();
    340343    delete gui;
     
    425428  CmdLinePrefsReader prefs;
    426429
    427   IniFilePrefsReader ini(ResourceManager::homeDirCheck(DEFAULT_CONFIG_FILE));
     430  IniFilePrefsReader ini(File(DEFAULT_CONFIG_FILE).name());
     431  Preferences::getInstance()->setUserIni(File(DEFAULT_CONFIG_FILE).name());
    428432
    429433  prefs.parse(argc, argv);
     
    501505{
    502506  // checking for existence of the configuration-files, or if the lock file is still used
    503   if (showGui || (!ResourceManager::isFile("./orxonox.conf") &&
    504                   !ResourceManager::isFile(DEFAULT_CONFIG_FILE))
     507  if (showGui || (!File("./orxonox.conf").isFile() &&
     508      !File(DEFAULT_CONFIG_FILE).isFile())
    505509#if DEBUG < 3 // developers do not need to see the GUI, when orxonox fails
    506510      || ResourceManager::isFile(DEFAULT_LOCK_FILE)
     
    508512     )
    509513  {
    510     if (ResourceManager::isFile(DEFAULT_LOCK_FILE))
    511       ResourceManager::deleteFile(DEFAULT_LOCK_FILE);
     514    File lockFile(DEFAULT_LOCK_FILE);
     515    if (lockFile.isFile())
     516      lockFile.remove();
    512517
    513518    // starting the GUI
    514     Gui* gui = new Gui(argc, argv);
    515     gui->startGui();
    516 
    517     if (! gui->startOrxonox)
     519    OrxGui::QtGui gui(argc, argv);
     520    gui.startGui();
     521
     522    if (gui.getState() & OrxGui::Gui::Quitting)
    518523      return 0;
    519524
    520     delete gui;
    521525  }
    522526
    523527  PRINT(0)(">>> Starting Orxonox <<<\n");
    524528
    525   ResourceManager::touchFile(DEFAULT_LOCK_FILE);
     529  File(DEFAULT_LOCK_FILE).touch();
    526530
    527531  Orxonox *orx = Orxonox::getInstance();
     
    537541
    538542  delete orx;
    539   ResourceManager::deleteFile("~/.orxonox/orxonox.lock");
    540 }
     543  File("~/.orxonox/orxonox.lock").remove();
     544}
  • trunk/src/story_entities/story_entity.cc

    r7283 r7661  
    2222#include "story_entity.h"
    2323
     24#include "util/file.h"
     25#include "util/loading/load_param.h"
    2426#include "util/loading/resource_manager.h"
    25 #include "util/loading/load_param.h"
    2627
    2728
     
    102103void StoryEntity::setLoadFile(const std::string& fileName)
    103104{
    104   if (ResourceManager::isFile(fileName))
     105  if (File(fileName).isFile())
    105106  {
    106107    this->loadFile =  fileName;
Note: See TracChangeset for help on using the changeset viewer.