Revision: 1599
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1599&view=rev
Author:   rorthomas
Date:     2011-01-26 02:36:15 +0000 (Wed, 26 Jan 2011)

Log Message:
-----------
configurator is now sing the central settings class.
its now possible to relocate your user path

Modified Paths:
--------------
    trunk/source/configurator/CMakeLists.txt
    trunk/source/configurator/configurator.cpp
    trunk/source/main/Beam.cpp
    trunk/source/main/Settings.cpp
    trunk/source/main/errorutils.cpp

Modified: trunk/source/configurator/CMakeLists.txt
===================================================================
--- trunk/source/configurator/CMakeLists.txt    2011-01-26 01:44:56 UTC (rev 
1598)
+++ trunk/source/configurator/CMakeLists.txt    2011-01-26 02:36:15 UTC (rev 
1599)
@@ -77,9 +77,9 @@
 FILE(GLOB headers "*.h")
 
 IF(WIN32)
-       add_executable(rorconfig WIN32 ${sources} ${headers} ${OS_SOURCE} 
../main/InputEngine.cpp)
+       add_executable(rorconfig WIN32 ${sources} ${headers} ${OS_SOURCE} 
../main/InputEngine.cpp ../main/Settings.cpp ../main/errorutils.cpp)
 ELSE(WIN32)
-       add_executable(rorconfig ${sources} ${headers} ${OS_SOURCE} 
../main/InputEngine.cpp)
+       add_executable(rorconfig ${sources} ${headers} ${OS_SOURCE} 
../main/InputEngine.cpp ../main/Settings.cpp ../main/errorutils.cpp)
 ENDIF(WIN32)
 
 TARGET_LINK_LIBRARIES(rorconfig ${Ogre_LIBRARIES} ${Ois_LIBRARIES} ${OS_LIBS} 
${optional_libs} ${wxWidgets_LIBRARIES})

Modified: trunk/source/configurator/configurator.cpp
===================================================================
--- trunk/source/configurator/configurator.cpp  2011-01-26 01:44:56 UTC (rev 
1598)
+++ trunk/source/configurator/configurator.cpp  2011-01-26 02:36:15 UTC (rev 
1599)
@@ -84,6 +84,8 @@
 
 #include "treelistctrl.h"
 
+#include "Settings.h"
+
 #include "OISKeyboard.h"
 
 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
@@ -1369,79 +1371,9 @@
 
 bool MyApp::filesystemBootstrap()
 {
-       //find the root of the program and user directory
-       //these routines should set ProgramPath and UserPath
-#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
-       WCHAR Wuser_path[1024];
-       WCHAR Wprogram_path[1024];
-       if (!GetModuleFileNameW(NULL, Wprogram_path, 512))
-       {
-               return false;
-       }
-       GetShortPathName(Wprogram_path, Wprogram_path, 512); //this is legal
-       ProgramPath=wxFileName(wxString(Wprogram_path)).GetPath();
+       UserPath = conv(SETTINGS.getSetting("User Path"));
+       ProgramPath = conv(SETTINGS.getSetting("Program Path"));
 
-       if (SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, 
Wuser_path)!=S_OK)
-       {
-               return false;
-       }
-       GetShortPathName(Wuser_path, Wuser_path, 512); //this is legal
-       wxFileName tfn=wxFileName(Wuser_path, wxEmptyString);
-       tfn.AppendDir(wxT("Rigs of Rods"));
-       UserPath=tfn.GetPath();
-#endif
-#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
-       //true program path is impossible to get from POSIX functions
-       //lets hack!
-       pid_t pid = getpid();
-       char procpath[256];
-       char user_path[1024];
-       char program_path[1024];
-       sprintf(procpath, "/proc/%d/exe", pid);
-       int ch = readlink(procpath,program_path,240);
-       if (ch != -1)
-       {
-               program_path[ch] = 0;
-       } else return false;
-       ProgramPath=wxFileName(wxString(conv(program_path))).GetPath();
-       //user path is easy
-       strncpy(user_path, getenv ("HOME"), 240);
-       wxFileName tfn=wxFileName(conv(user_path), wxEmptyString);
-       tfn.AppendDir(_T(".rigsofrods"));
-       UserPath=tfn.GetPath();
-#endif
-#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
-       //found this code, will look later
-       std::string path = "./";
-       ProcessSerialNumber PSN;
-       ProcessInfoRec pinfo;
-       FSSpec pspec;
-       FSRef fsr;
-       OSStatus err;
-       /* set up process serial number */
-       PSN.highLongOfPSN = 0;
-       PSN.lowLongOfPSN = kCurrentProcess;
-       /* set up info block */
-       pinfo.processInfoLength = sizeof(pinfo);
-       pinfo.processName = NULL;
-       pinfo.processAppSpec = &pspec;
-       /* grab the vrefnum and directory */
-       err = GetProcessInformation(&PSN, &pinfo);
-       if (! err ) {
-       char c_path[2048];
-       FSSpec fss2;
-       int tocopy;
-       err = FSMakeFSSpec(pspec.vRefNum, pspec.parID, 0, &fss2);
-       if ( ! err ) {
-       err = FSpMakeFSRef(&fss2, &fsr);
-       if ( ! err ) {
-       char c_path[2049];
-       err = (OSErr)FSRefMakePath(&fsr, (UInt8*)c_path, 2048);
-       if (! err ) {
-       path = c_path;
-       }
-       }
-#endif
        //skeleton
        wxFileName tsk=wxFileName(ProgramPath, wxEmptyString);
        tsk.AppendDir(wxT("skeleton"));
@@ -1510,7 +1442,13 @@
 {
        buildmode=false;
        if (argc==2 && wxString(argv[1])==wxT("/buildmode")) buildmode=true;
+       
+       
        //setup the user filesystem
+       SETTINGS.setSetting("BuildMode", buildmode?"Yes":"No");
+       if(!SETTINGS.setupPaths())
+               return false;
+
        if (!filesystemBootstrap()) return false;
 
        initLogging();

Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp  2011-01-26 01:44:56 UTC (rev 1598)
+++ trunk/source/main/Beam.cpp  2011-01-26 02:36:15 UTC (rev 1599)
@@ -2795,7 +2795,6 @@
                                        {
                                                nodes[n].smoothpos = 
nodes[n].AbsPosition;
                                        }
-
                                } else
                                {
                                        Vector3 aposition = Vector3::ZERO;

Modified: trunk/source/main/Settings.cpp
===================================================================
--- trunk/source/main/Settings.cpp      2011-01-26 01:44:56 UTC (rev 1598)
+++ trunk/source/main/Settings.cpp      2011-01-26 02:36:15 UTC (rev 1599)
@@ -24,7 +24,10 @@
 #include <windows.h>
 #include <shlobj.h>
 #endif
-#include "language.h"
+
+//#include "language.h"
+#define _L
+
 #include "errorutils.h"
 
 using namespace std;
@@ -240,6 +243,7 @@
        char config_root[1024]="";
        char dirsep='/';
 
+
        if(!get_system_paths(program_path, user_path))
                return false;
 
@@ -303,6 +307,12 @@
                String configfile = settings["configfile"];
                if(!configfile.size()) configfile = "config.cfg";
                loadSettings(configfile, true);
+
+               // fix up time things...
+               settings["Config Root"] = settings["User Path"]+"config"+dirsep;
+               settings["ogre.cfg"]    = settings["User 
Path"]+"config"+dirsep+"ogre.cfg";
+               settings["ogre.log"]    = settings["User 
Path"]+"logs"+dirsep+"ogre.log";
+
        } catch(...)
        {
                // file not found or other error

Modified: trunk/source/main/errorutils.cpp
===================================================================
--- trunk/source/main/errorutils.cpp    2011-01-26 01:44:56 UTC (rev 1598)
+++ trunk/source/main/errorutils.cpp    2011-01-26 02:36:15 UTC (rev 1599)
@@ -21,9 +21,11 @@
 
 #include "errorutils.h"
 #include "Ogre.h"
-#include "language.h"
+//#include "language.h"
 
+#define _L
 
+
 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
 #include <windows.h>
 #include <shlobj.h> 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to