summaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/app.cpp301
-rw-r--r--src/app/app.h66
-rw-r--r--src/app/gamedata.cpp136
-rw-r--r--src/app/gamedata.h66
-rw-r--r--src/app/main.cpp98
-rw-r--r--src/app/pausemanager.cpp52
-rw-r--r--src/app/pausemanager.h34
-rw-r--r--src/app/system.cpp44
-rw-r--r--src/app/system.h41
-rw-r--r--src/app/system_linux.cpp68
-rw-r--r--src/app/system_linux.h37
-rw-r--r--src/app/system_macosx.cpp48
-rw-r--r--src/app/system_macosx.h37
-rw-r--r--src/app/system_other.cpp34
-rw-r--r--src/app/system_other.h34
-rw-r--r--src/app/system_windows.cpp59
-rw-r--r--src/app/system_windows.h37
17 files changed, 522 insertions, 670 deletions
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 8b310c9..6f33389 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -1,25 +1,26 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
#include "common/config.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "app/system.h"
#include "common/logger.h"
@@ -27,8 +28,10 @@
#include "common/image.h"
#include "common/key.h"
#include "common/stringutils.h"
+#include "common/resources/resourcemanager.h"
#include "graphics/engine/modelmanager.h"
+#include "graphics/core/nulldevice.h"
#include "graphics/opengl/gldevice.h"
#include "object/robotmain.h"
@@ -101,7 +104,6 @@ CApplication::CApplication()
m_objMan = new CObjectManager();
m_eventQueue = new CEventQueue();
m_profile = new CProfile();
- m_gameData = new CGameData();
m_engine = nullptr;
m_device = nullptr;
@@ -112,9 +114,9 @@ CApplication::CApplication()
m_exitCode = 0;
m_active = false;
m_debugModes = 0;
- m_customDataPath = false;
+ m_restart = false;
- m_windowTitle = "COLOBOT GOLD";
+ m_windowTitle = "Colobot: Gold Edition";
m_simulationSuspended = false;
@@ -149,19 +151,30 @@ CApplication::CApplication()
m_mouseButtonsState = 0;
m_trackedKeys = 0;
+ #ifdef PORTABLE
+ m_dataPath = "./data";
+ m_langPath = "./lang";
+ #else
m_dataPath = GetSystemUtils()->GetDataPath();
m_langPath = GetSystemUtils()->GetLangPath();
+ #endif
+
+ #ifdef DEV_BUILD
+ m_savePath = "./saves";
+ #else
+ m_savePath = GetSystemUtils()->GetSaveDir();
+ #endif
m_runSceneName = "";
m_runSceneRank = 0;
-
+
m_sceneTest = false;
+ m_headless = false;
+ m_resolutionOverride = false;
m_language = LANGUAGE_ENV;
m_lowCPU = true;
-
- m_protoMode = false;
}
CApplication::~CApplication()
@@ -180,9 +193,6 @@ CApplication::~CApplication()
delete m_iMan;
m_iMan = nullptr;
-
- delete m_gameData;
- m_gameData = nullptr;
GetSystemUtils()->DestroyTimeStamp(m_baseTimeStamp);
GetSystemUtils()->DestroyTimeStamp(m_curTimeStamp);
@@ -215,10 +225,13 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
OPT_SCENETEST,
OPT_LOGLEVEL,
OPT_LANGUAGE,
+ OPT_LANGDIR,
OPT_DATADIR,
+ OPT_SAVEDIR,
OPT_MOD,
- OPT_LANGDIR,
- OPT_VBO
+ OPT_VBO,
+ OPT_RESOLUTION,
+ OPT_HEADLESS
};
option options[] =
@@ -229,10 +242,13 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
{ "scenetest", no_argument, nullptr, OPT_SCENETEST },
{ "loglevel", required_argument, nullptr, OPT_LOGLEVEL },
{ "language", required_argument, nullptr, OPT_LANGUAGE },
+ { "langdir", required_argument, nullptr, OPT_LANGDIR },
{ "datadir", required_argument, nullptr, OPT_DATADIR },
+ { "savedir", required_argument, nullptr, OPT_SAVEDIR },
{ "mod", required_argument, nullptr, OPT_MOD },
- { "langdir", required_argument, nullptr, OPT_LANGDIR },
{ "vbo", required_argument, nullptr, OPT_VBO },
+ { "resolution", required_argument, nullptr, OPT_RESOLUTION },
+ { "headless", no_argument, nullptr, OPT_HEADLESS },
{ nullptr, 0, nullptr, 0}
};
@@ -269,10 +285,13 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
GetLogger()->Message(" -scenetest win every mission right after it's loaded\n");
GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n");
GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl, ru)\n");
- GetLogger()->Message(" -datadir path set custom data directory path\n");
- GetLogger()->Message(" -mod path run mod\n");
GetLogger()->Message(" -langdir path set custom language directory path\n");
+ GetLogger()->Message(" -datadir path set custom data directory path\n");
+ GetLogger()->Message(" -savedir path set custom save directory path (must be writable)\n");
+ GetLogger()->Message(" -mod path load datadir mod from given path\n");
GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n");
+ GetLogger()->Message(" -resolution WxH set resolution\n");
+ GetLogger()->Message(" -headless headless mode - disables graphics, sound and user interaction\n");
return PARSE_ARGS_HELP;
}
case OPT_DEBUG:
@@ -334,25 +353,6 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
m_language = language;
break;
}
- case OPT_DATADIR:
- {
- m_dataPath = optarg;
- m_customDataPath = true;
- GetLogger()->Info("Using datadir: '%s'\n", optarg);
- break;
- }
- case OPT_MOD:
- {
- m_gameData->AddMod(std::string(optarg));
- GetLogger()->Info("Running mod from path: '%s'\n", optarg);
- break;
- }
- case OPT_LANGDIR:
- {
- m_langPath = optarg;
- GetLogger()->Info("Using language dir: '%s'\n", m_langPath.c_str());
- break;
- }
case OPT_VBO:
{
std::string vbo;
@@ -371,6 +371,47 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
break;
}
+ case OPT_DATADIR:
+ {
+ m_dataPath = optarg;
+ GetLogger()->Info("Using data dir: '%s'\n", optarg);
+ break;
+ }
+ case OPT_LANGDIR:
+ {
+ m_langPath = optarg;
+ GetLogger()->Info("Using language dir: '%s'\n", optarg);
+ break;
+ }
+ case OPT_SAVEDIR:
+ {
+ m_savePath = optarg;
+ GetLogger()->Info("Using save dir: '%s'\n", optarg);
+ break;
+ }
+ case OPT_MOD:
+ {
+ GetLogger()->Info("Loading mod: '%s'\n", optarg);
+ CResourceManager::AddLocation(optarg, true);
+ break;
+ }
+ case OPT_RESOLUTION:
+ {
+ std::istringstream resolution(optarg);
+ std::string w, h;
+ std::getline(resolution, w, 'x');
+ std::getline(resolution, h, 'x');
+
+ m_deviceConfig.size.x = atoi(w.c_str());
+ m_deviceConfig.size.y = atoi(h.c_str());
+ m_resolutionOverride = true;
+ break;
+ }
+ case OPT_HEADLESS:
+ {
+ m_headless = true;
+ break;
+ }
default:
assert(false); // should never get here
}
@@ -386,32 +427,36 @@ bool CApplication::Create()
GetLogger()->Info("Creating CApplication\n");
- if (!GetProfile().InitCurrentDirectory())
- {
- GetLogger()->Warn("Config not found. Default values will be used!\n");
- defaultValues = true;
- }
- else
- {
- if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Data", path))
- m_dataPath = path;
- }
-
boost::filesystem::path dataPath(m_dataPath);
if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) )
{
GetLogger()->Error("Data directory '%s' doesn't exist or is not a directory\n", m_dataPath.c_str());
m_errorMessage = std::string("Could not read from data directory:\n") +
- std::string("'") + m_dataPath + std::string("'\n") +
- std::string("Please check your installation, or supply a valid data directory by -datadir option.");
+ std::string("'") + m_dataPath + std::string("'\n") +
+ std::string("Please check your installation, or supply a valid data directory by -datadir option.");
m_exitCode = 1;
return false;
}
-
- m_gameData->SetDataDir(std::string(m_dataPath));
- m_gameData->Init();
- if (GetProfile().GetLocalProfileString("Language", "Lang", path)) {
+ boost::filesystem::create_directories(m_savePath);
+ boost::filesystem::create_directories(m_savePath+"/mods");
+
+ LoadModsFromDir(m_dataPath+"/mods");
+ LoadModsFromDir(m_savePath+"/mods");
+
+ GetLogger()->Info("Data path: %s\n", m_dataPath.c_str());
+ GetLogger()->Info("Save path: %s\n", m_savePath.c_str());
+ CResourceManager::AddLocation(m_dataPath, false);
+ CResourceManager::SetSaveLocation(m_savePath);
+ CResourceManager::AddLocation(m_savePath, true);
+
+ if (!GetProfile().Init())
+ {
+ GetLogger()->Warn("Config not found. Default values will be used!\n");
+ defaultValues = true;
+ }
+
+ if (GetProfile().GetStringProperty("Language", "Lang", path)) {
Language language;
if (ParseLanguage(path, language)) {
m_language = language;
@@ -425,7 +470,11 @@ bool CApplication::Create()
//Create the sound instance.
#ifdef OPENAL_SOUND
- m_sound = static_cast<CSoundInterface *>(new ALSound());
+ if(!m_headless) {
+ m_sound = static_cast<CSoundInterface *>(new ALSound());
+ } else {
+ m_sound = new CSoundInterface();
+ }
#else
GetLogger()->Info("No sound support.\n");
m_sound = new CSoundInterface();
@@ -470,35 +519,37 @@ bool CApplication::Create()
return false;
}
- // load settings from profile
- int iValue;
- if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) )
- {
- std::vector<Math::IntPoint> modes;
- GetVideoResolutionList(modes, true, true);
- if (static_cast<unsigned int>(iValue) < modes.size())
- m_deviceConfig.size = modes.at(iValue);
- }
+ if(!m_headless) {
+ // load settings from profile
+ int iValue;
+ if ( GetProfile().GetIntProperty("Setup", "Resolution", iValue) && !m_resolutionOverride )
+ {
+ std::vector<Math::IntPoint> modes;
+ GetVideoResolutionList(modes, true, true);
+ if (static_cast<unsigned int>(iValue) < modes.size())
+ m_deviceConfig.size = modes.at(iValue);
+ }
- if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) )
- {
- m_deviceConfig.fullScreen = (iValue == 1);
- }
+ if ( GetProfile().GetIntProperty("Setup", "Fullscreen", iValue) && !m_resolutionOverride )
+ {
+ m_deviceConfig.fullScreen = (iValue == 1);
+ }
- if (! CreateVideoSurface())
- return false; // dialog is in function
+ if (! CreateVideoSurface())
+ return false; // dialog is in function
- if (m_private->surface == nullptr)
- {
- m_errorMessage = std::string("SDL error while setting video mode:\n") +
- std::string(SDL_GetError());
- GetLogger()->Error(m_errorMessage.c_str());
- m_exitCode = 4;
- return false;
+ if (m_private->surface == nullptr)
+ {
+ m_errorMessage = std::string("SDL error while setting video mode:\n") +
+ std::string(SDL_GetError());
+ GetLogger()->Error(m_errorMessage.c_str());
+ m_exitCode = 4;
+ return false;
+ }
+
+ SDL_WM_SetCaption(m_windowTitle.c_str(), m_windowTitle.c_str());
}
- SDL_WM_SetCaption(m_windowTitle.c_str(), m_windowTitle.c_str());
-
// Enable translating key codes of key press events to unicode chars
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
@@ -506,8 +557,12 @@ bool CApplication::Create()
// Don't generate joystick events
SDL_JoystickEventState(SDL_IGNORE);
- // The video is ready, we can create and initalize the graphics device
- m_device = new Gfx::CGLDevice(m_deviceConfig);
+ if(!m_headless) {
+ // The video is ready, we can create and initalize the graphics device
+ m_device = new Gfx::CGLDevice(m_deviceConfig);
+ } else {
+ m_device = new Gfx::CNullDevice();
+ }
if (! m_device->Create() )
{
m_errorMessage = std::string("Error in CDevice::Create()\n") + standardInfoMessage;
@@ -568,8 +623,8 @@ bool CApplication::CreateVideoSurface()
if (m_deviceConfig.fullScreen)
videoFlags |= SDL_FULLSCREEN;
- if (m_deviceConfig.resizeable)
- videoFlags |= SDL_RESIZABLE;
+ //if (m_deviceConfig.resizeable)
+ // videoFlags |= SDL_RESIZABLE;
// Set OpenGL attributes
@@ -594,27 +649,35 @@ bool CApplication::CreateVideoSurface()
return true;
}
+void CApplication::LoadModsFromDir(const std::string &dir)
+{
+ try {
+ boost::filesystem::directory_iterator iterator(dir);
+ for(; iterator != boost::filesystem::directory_iterator(); ++iterator)
+ {
+ std::string fn = iterator->path().string();
+ CLogger::GetInstancePointer()->Info("Loading mod: '%s'\n", fn.c_str());
+ CResourceManager::AddLocation(fn, false);
+ }
+ }
+ catch(std::exception &e)
+ {
+ CLogger::GetInstancePointer()->Warn("Unable to load mods from directory '%s': %s\n", dir.c_str(), e.what());
+ }
+}
+
void CApplication::Destroy()
{
m_joystickEnabled = false;
- if (m_robotMain != nullptr)
- {
- delete m_robotMain;
- m_robotMain = nullptr;
- }
+ delete m_robotMain;
+ m_robotMain = nullptr;
- if (m_sound != nullptr)
- {
- delete m_sound;
- m_sound = nullptr;
- }
+ delete m_sound;
+ m_sound = nullptr;
- if (m_modelManager != nullptr)
- {
- delete m_modelManager;
- m_modelManager = nullptr;
- }
+ delete m_modelManager;
+ m_modelManager = nullptr;
if (m_engine != nullptr)
{
@@ -649,6 +712,17 @@ void CApplication::Destroy()
SDL_Quit();
}
+void CApplication::Restart()
+{
+ m_restart = true;
+ m_eventQueue->AddEvent(Event(EVENT_SYS_QUIT));
+}
+
+bool CApplication::IsRestarting()
+{
+ return m_restart;
+}
+
bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
{
static bool restore = false;
@@ -674,7 +748,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
std::string(SDL_GetError()) + std::string("\n") +
std::string("Previous mode will be restored");
GetLogger()->Error(error.c_str());
- GetSystemUtils()->SystemDialog( SDT_ERROR, "COLOBT - Error", error);
+ GetSystemUtils()->SystemDialog( SDT_ERROR, "COLOBOT - Error", error);
restore = true;
ChangeVideoConfig(m_lastDeviceConfig);
@@ -687,7 +761,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
std::string error = std::string("SDL error while restoring previous video mode:\n") +
std::string(SDL_GetError());
GetLogger()->Error(error.c_str());
- GetSystemUtils()->SystemDialog( SDT_ERROR, "COLOBT - Fatal Error", error);
+ GetSystemUtils()->SystemDialog( SDT_ERROR, "COLOBOT - Fatal Error", error);
// Fatal error, so post the quit event
@@ -699,6 +773,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
( static_cast<Gfx::CGLDevice*>(m_device) )->ConfigChanged(m_deviceConfig);
m_engine->ResetAfterDeviceChanged();
+ m_robotMain->ResetAfterDeviceChanged();
return true;
}
diff --git a/src/app/app.h b/src/app/app.h
index 86a757f..52ed77a 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
/**
* \file app/app.h
@@ -42,7 +44,6 @@ class CInstanceManager;
class CEventQueue;
class CRobotMain;
class CSoundInterface;
-class CGameData;
namespace Gfx {
class CModelManager;
@@ -226,6 +227,11 @@ public:
//! Cleans up before exit
void Destroy();
+
+ //! Restart
+ void Restart();
+ //! Should we restart after app quits?
+ bool IsRestarting();
//! Returns a list of possible video modes
VideoQueryResult GetVideoResolutionList(std::vector<Math::IntPoint> &resolutions,
@@ -355,6 +361,9 @@ public:
protected:
//! Creates the window's SDL_Surface
bool CreateVideoSurface();
+
+ //! Loads all mods from given directory
+ void LoadModsFromDir(const std::string &dir);
//! Processes the captured SDL event to Event struct
Event ProcessSystemEvent();
@@ -402,8 +411,6 @@ protected:
CRobotMain* m_robotMain;
//! Profile (INI) reader/writer
CProfile* m_profile;
- //! Game data
- CGameData* m_gameData;
//! Code to return at exit
int m_exitCode;
@@ -411,6 +418,8 @@ protected:
bool m_active;
//! Bit array of active debug modes
long m_debugModes;
+ //! If we are restarting the app
+ bool m_restart;
//! Message to be displayed as error to the user
std::string m_errorMessage;
@@ -467,16 +476,16 @@ protected:
std::vector<int> m_joyAxeState;
//! Current state of joystick buttons; may be updated from another thread
std::vector<bool> m_joyButtonState;
-
+
//! Path to directory with data files
std::string m_dataPath;
-
- //! True if datadir was passed in command line
- bool m_customDataPath;
-
+
//! Path to directory with language files
std::string m_langPath;
+ //! Path to directory with save files
+ std::string m_savePath;
+
//@{
//! Scene to run on startup
std::string m_runSceneName;
@@ -491,8 +500,11 @@ protected:
//! Low cpu mode
bool m_lowCPU;
-
- //! Show prototype levels
- bool m_protoMode;
+
+ //! Screen resoultion overriden by commandline
+ bool m_resolutionOverride;
+
+ //! Headles mode
+ bool m_headless;
};
diff --git a/src/app/gamedata.cpp b/src/app/gamedata.cpp
deleted file mode 100644
index ceeb7b3..0000000
--- a/src/app/gamedata.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2014, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-#include "app/gamedata.h"
-
-
-#include "app/app.h"
-
-#include <boost/filesystem.hpp>
-
-template<> CGameData* CSingleton<CGameData>::m_instance = nullptr;
-
-CGameData::CGameData()
-{
- m_dataDirSet = false;
-
- for (int i = 0; i < DIR_MAX; ++i)
- m_standardDataDirs[i] = nullptr;
-
- m_standardDataDirs[DIR_AI] = "ai";
- m_standardDataDirs[DIR_FONT] = "fonts";
- m_standardDataDirs[DIR_HELP] = "help";
- m_standardDataDirs[DIR_ICON] = "icons";
- m_standardDataDirs[DIR_LEVEL] = "levels";
- m_standardDataDirs[DIR_MODEL] = "models";
- m_standardDataDirs[DIR_MUSIC] = "music";
- m_standardDataDirs[DIR_SOUND] = "sounds";
- m_standardDataDirs[DIR_TEXTURE] = "textures";
-}
-
-CGameData::~CGameData()
-{
-}
-
-void CGameData::SetDataDir(std::string path)
-{
- assert(!m_dataDirSet);
- m_dataDirSet = true;
-
- m_dataDirs.insert(m_dataDirs.begin(), path);
-}
-
-void CGameData::AddMod(std::string path)
-{
- m_dataDirs.push_back(path);
-}
-
-void CGameData::Init()
-{
- std::string out = "Using datadirs: ";
- bool first = true;
- for(std::vector<std::string>::reverse_iterator rit = m_dataDirs.rbegin(); rit != m_dataDirs.rend(); ++rit) {
- if(!first) out += ", ";
- first = false;
- out += *rit;
- }
- out += "\n";
- CLogger::GetInstancePointer()->Info(out.c_str());
-}
-
-std::string CGameData::GetFilePath(DataDir dir, const std::string& subpath)
-{
- int index = static_cast<int>(dir);
- assert(index >= 0 && index < DIR_MAX);
-
- for(std::vector<std::string>::reverse_iterator rit = m_dataDirs.rbegin(); rit != m_dataDirs.rend(); ++rit) {
- std::stringstream str;
-
- if ( subpath.find("save") == std::string::npos ){ // if its NOT a path to a savefile screenshot
- str << *rit;
- str << "/";
- str << m_standardDataDirs[index];
-
- if (dir == DIR_HELP)
- {
- str << "/";
- str << CApplication::GetInstancePointer()->GetLanguageChar();
- }
- str << "/";
- }
-
- str << subpath;
-
- boost::filesystem::path path(str.str());
- if(boost::filesystem::exists(path))
- {
- return str.str();
- }
- }
-
- if(m_dataDirs.size() > 0) {
- std::stringstream str;
- if ( subpath.find("save") == std::string::npos ){ // if its NOT a path to a savefile screenshot
- str << m_dataDirs[0];
- str << "/";
- str << m_standardDataDirs[index];
-
- if (dir == DIR_HELP)
- {
- str << "/";
- str << CApplication::GetInstancePointer()->GetLanguageChar();
- }
- str << "/";
- }
- str << subpath;
- return str.str();
- }
-
- return subpath;
-}
-
-std::string CGameData::GetDataPath(const std::string &subpath)
-{
- for(std::vector<std::string>::reverse_iterator rit = m_dataDirs.rbegin(); rit != m_dataDirs.rend(); ++rit) {
- std::string path = *rit + "/" + subpath;
- boost::filesystem::path boostPath(path);
- if(boost::filesystem::exists(boostPath))
- {
- return path;
- }
- }
- return m_dataDirs[0] + "/" + subpath;
-}
diff --git a/src/app/gamedata.h b/src/app/gamedata.h
deleted file mode 100644
index b7536a2..0000000
--- a/src/app/gamedata.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2014, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-/**
- * \file app/gamedata.h
- * \brief Game data
- */
-
-#pragma once
-
-#include "common/singleton.h"
-
-#include <string>
-#include <vector>
-
-/**
- * \enum DataDir
- * \brief Directories in data directory
- */
-enum DataDir
-{
- DIR_AI, //! < ai scripts
- DIR_FONT, //! < fonts
- DIR_HELP, //! < help files
- DIR_ICON, //! < icons & images
- DIR_LEVEL, //! < levels
- DIR_MODEL, //! < models
- DIR_MUSIC, //! < music
- DIR_SOUND, //! < sounds
- DIR_TEXTURE, //! < textures
-
- DIR_MAX //! < number of dirs
-};
-
-class CGameData : public CSingleton<CGameData>
-{
-public:
- CGameData();
- ~CGameData();
-
- void Init();
- void SetDataDir(std::string path);
- void AddMod(std::string path);
-
- std::string GetFilePath(DataDir dir, const std::string &subpath);
- std::string GetDataPath(const std::string &subpath);
-
-private:
- bool m_dataDirSet;
- std::vector<std::string> m_dataDirs;
- const char* m_standardDataDirs[DIR_MAX];
-};
-
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 5c0afd3..88a7a73 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
/**
* \file app/main.cpp
@@ -69,6 +71,7 @@ The current layout is the following:
- src/script - link with the CBot library
*/
+#include "common/resources/resourcemanager.h"
//! Entry point to the program
extern "C"
@@ -77,47 +80,52 @@ extern "C"
int SDL_MAIN_FUNC(int argc, char *argv[])
{
CLogger logger; // single istance of logger
+ CResourceManager manager(argv[0]);
// Initialize static string arrays
InitializeRestext();
InitializeEventTypeTexts();
- CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils
- systemUtils->Init();
-
logger.Info("Colobot starting\n");
-
- CApplication* app = new CApplication(); // single instance of the application
-
- ParseArgsStatus status = app->ParseArguments(argc, argv);
- if (status == PARSE_ARGS_FAIL)
- {
- systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
- return app->GetExitCode();
- }
- else if (status == PARSE_ARGS_HELP)
- {
- return app->GetExitCode();
- }
-
+
int code = 0;
+ while(true) {
+ CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils
+ systemUtils->Init();
+
+ CApplication* app = new CApplication(); // single instance of the application
+
+ ParseArgsStatus status = app->ParseArguments(argc, argv);
+ if (status == PARSE_ARGS_FAIL)
+ {
+ systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
+ return app->GetExitCode();
+ }
+ else if (status == PARSE_ARGS_HELP)
+ {
+ return app->GetExitCode();
+ }
- if (! app->Create())
- {
- app->Destroy(); // ensure a clean exit
- code = app->GetExitCode();
- if ( code != 0 && !app->GetErrorMessage().empty() )
+
+ if (! app->Create())
{
- systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app->GetErrorMessage());
+ app->Destroy(); // ensure a clean exit
+ code = app->GetExitCode();
+ if ( code != 0 && !app->GetErrorMessage().empty() )
+ {
+ systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app->GetErrorMessage());
+ }
+ logger.Info("Didn't run main loop. Exiting with code %d\n", code);
+ return code;
}
- logger.Info("Didn't run main loop. Exiting with code %d\n", code);
- return code;
- }
- code = app->Run();
+ code = app->Run();
+ bool restarting = app->IsRestarting();
- delete app;
- delete systemUtils;
+ delete app;
+ delete systemUtils;
+ if(!restarting) break;
+ }
logger.Info("Exiting with code %d\n", code);
return code;
diff --git a/src/app/pausemanager.cpp b/src/app/pausemanager.cpp
index d357bba..b28565f 100644
--- a/src/app/pausemanager.cpp
+++ b/src/app/pausemanager.cpp
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
#include "app/app.h"
#include "app/pausemanager.h"
@@ -29,7 +31,7 @@ template<> CPauseManager* CSingleton<CPauseManager>::m_instance = nullptr;
CPauseManager::CPauseManager()
{
m_sound = CApplication::GetInstancePointer()->GetSound();
-
+
m_pause = PAUSE_NONE;
}
@@ -40,24 +42,28 @@ CPauseManager::~CPauseManager()
void CPauseManager::SetPause(PauseType pause)
{
- if(pause != PAUSE_NONE) {
- if(m_pause != pause) {
+ if (pause != PAUSE_NONE)
+ {
+ if (m_pause != pause)
+ {
CLogger::GetInstancePointer()->Info("Game paused - %s\n", GetPauseName(pause).c_str());
CRobotMain::GetInstancePointer()->StartPauseMusic(pause);
}
-
+
m_pause = pause;
- } else
+ }
+ else
ClearPause();
}
void CPauseManager::ClearPause()
{
- if(m_pause != PAUSE_NONE) {
+ if(m_pause != PAUSE_NONE)
+ {
CLogger::GetInstancePointer()->Info("Game resumed\n");
m_sound->StopPauseMusic();
}
-
+
m_pause = PAUSE_NONE;
}
diff --git a/src/app/pausemanager.h b/src/app/pausemanager.h
index fefc4a5..411742e 100644
--- a/src/app/pausemanager.h
+++ b/src/app/pausemanager.h
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
/**
* \file app/pausemanager.h
diff --git a/src/app/system.cpp b/src/app/system.cpp
index eaa9e4c..2ceea6a 100644
--- a/src/app/system.cpp
+++ b/src/app/system.cpp
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
#include "app/system.h"
@@ -202,13 +204,7 @@ std::string CSystemUtils::GetLangPath()
return COLOBOT_I18N_DIR;
}
-std::string CSystemUtils::GetProfileFileLocation()
+std::string CSystemUtils::GetSaveDir()
{
- return std::string("colobot.ini");
+ return std::string("save");
}
-
-std::string CSystemUtils::GetSavegameDirectoryLocation()
-{
- return std::string("savegame");
-}
-
diff --git a/src/app/system.h b/src/app/system.h
index c2125fe..d52020b 100644
--- a/src/app/system.h
+++ b/src/app/system.h
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
/**
* \file app/system.h
@@ -136,11 +138,8 @@ public:
//! Returns the translations path
virtual std::string GetLangPath();
- //! Returns the profile (colobot.ini) file location
- virtual std::string GetProfileFileLocation();
-
- //! Returns the savegame directory location
- virtual std::string GetSavegameDirectoryLocation();
+ //! Returns the save dir location
+ virtual std::string GetSaveDir();
};
//! Global function to get CSystemUtils instance
diff --git a/src/app/system_linux.cpp b/src/app/system_linux.cpp
index 492af7d..6fbfb05 100644
--- a/src/app/system_linux.cpp
+++ b/src/app/system_linux.cpp
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
#include "app/system_linux.h"
@@ -25,7 +27,7 @@
void CSystemUtilsLinux::Init()
{
m_zenityAvailable = true;
- if (system("zenity --version") != 0)
+ if (system("zenity --version 1> /dev/null 2> /dev/null") != 0)
{
m_zenityAvailable = false;
GetLogger()->Warn("Zenity not available, will fallback to console users dialogs.\n");
@@ -95,34 +97,7 @@ long long CSystemUtilsLinux::TimeStampExactDiff(SystemTimeStamp *before, SystemT
(after->clockTime.tv_sec - before->clockTime.tv_sec) * 1000000000ll;
}
-std::string CSystemUtilsLinux::GetProfileFileLocation()
-{
- std::string profileFile;
-
- // Determine profileFile according to XDG Base Directory Specification
- char* envXDG_CONFIG_HOME = getenv("XDG_CONFIG_HOME");
- if (envXDG_CONFIG_HOME == NULL)
- {
- char *envHOME = getenv("HOME");
- if (envHOME == NULL)
- {
- profileFile = "colobot.ini";
- }
- else
- {
- profileFile = std::string(envHOME) + "/.config/colobot.ini";
- }
- }
- else
- {
- profileFile = std::string(envXDG_CONFIG_HOME) + "/colobot.ini";
- }
- GetLogger()->Trace("Profile configuration is %s\n", profileFile.c_str());
-
- return profileFile;
-}
-
-std::string CSystemUtilsLinux::GetSavegameDirectoryLocation()
+std::string CSystemUtilsLinux::GetSaveDir()
{
std::string savegameDir;
@@ -133,7 +108,7 @@ std::string CSystemUtilsLinux::GetSavegameDirectoryLocation()
char *envHOME = getenv("HOME");
if (envHOME == NULL)
{
- savegameDir = "/tmp/colobot-savegame";
+ savegameDir = "/tmp/colobot-save";
}
else
{
@@ -148,4 +123,3 @@ std::string CSystemUtilsLinux::GetSavegameDirectoryLocation()
return savegameDir;
}
-
diff --git a/src/app/system_linux.h b/src/app/system_linux.h
index 212d840..5f4fcc3 100644
--- a/src/app/system_linux.h
+++ b/src/app/system_linux.h
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
/**
* \file app/system_linux.h
@@ -46,8 +48,7 @@ public:
virtual long long GetTimeStampExactResolution() override;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
- virtual std::string GetProfileFileLocation() override;
- virtual std::string GetSavegameDirectoryLocation() override;
+ virtual std::string GetSaveDir() override;
private:
bool m_zenityAvailable;
diff --git a/src/app/system_macosx.cpp b/src/app/system_macosx.cpp
index 68f5c79..208b4a7 100644
--- a/src/app/system_macosx.cpp
+++ b/src/app/system_macosx.cpp
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2013, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
#include "app/system_macosx.h"
@@ -97,20 +99,10 @@ std::string CSystemUtilsMacOSX::GetLangPath()
return m_dataPath + "/i18n";
}
-std::string CSystemUtilsMacOSX::GetProfileFileLocation()
+std::string CSystemUtilsMacOSX::GetSaveDir()
{
- std::string profileFile = m_ASPath + "/colobot.ini";
-
- GetLogger()->Trace("Profile file is %s\n", profileFile.c_str());
- return profileFile;
-}
-
-std::string CSystemUtilsMacOSX::GetSavegameDirectoryLocation()
-{
- std::string savegameDir = m_ASPath + "/savegame";
- boost::filesystem::create_directories(savegameDir.c_str());
+ std::string savegameDir = m_ASPath;
GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
return savegameDir;
}
-
diff --git a/src/app/system_macosx.h b/src/app/system_macosx.h
index b6a044b..9063aab 100644
--- a/src/app/system_macosx.h
+++ b/src/app/system_macosx.h
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
/**
* \file app/system_macosx.h
@@ -30,8 +32,7 @@ public:
virtual std::string GetDataPath() override;
virtual std::string GetLangPath() override;
- virtual std::string GetProfileFileLocation() override;
- virtual std::string GetSavegameDirectoryLocation() override;
+ virtual std::string GetSaveDir() override;
private:
std::string m_ASPath;
std::string m_dataPath;
diff --git a/src/app/system_other.cpp b/src/app/system_other.cpp
index 9d9f76a..c21314c 100644
--- a/src/app/system_other.cpp
+++ b/src/app/system_other.cpp
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
#include "app/system_other.h"
diff --git a/src/app/system_other.h b/src/app/system_other.h
index 7eccf3f..3be6d59 100644
--- a/src/app/system_other.h
+++ b/src/app/system_other.h
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
/**
* \file app/system_other.h
diff --git a/src/app/system_windows.cpp b/src/app/system_windows.cpp
index f48d4e0..a2ea18f 100644
--- a/src/app/system_windows.cpp
+++ b/src/app/system_windows.cpp
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
#include "app/system_windows.h"
@@ -111,39 +113,20 @@ std::wstring CSystemUtilsWindows::UTF8_Decode(const std::string& str)
}
-std::string CSystemUtilsWindows::GetProfileFileLocation()
-{
- std::string profileFile;
-
- char* envUSERPROFILE = getenv("USERPROFILE");
- if (envUSERPROFILE == NULL)
- {
- profileFile = "colobot.ini";
- }
- else
- {
- profileFile = std::string(envUSERPROFILE) + "\\colobot\\colobot.ini";
- }
- GetLogger()->Trace("Profile configuration is %s\n", profileFile.c_str());
-
- return profileFile;
-}
-
-std::string CSystemUtilsWindows::GetSavegameDirectoryLocation()
+std::string CSystemUtilsWindows::GetSaveDir()
{
std::string savegameDir;
char* envUSERPROFILE = getenv("USERPROFILE");
if (envUSERPROFILE == NULL)
{
- savegameDir = "savegame";
+ savegameDir = "save";
}
else
{
- savegameDir = std::string(envUSERPROFILE) + "\\colobot\\savegame";
+ savegameDir = std::string(envUSERPROFILE) + "\\colobot";
}
GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
return savegameDir;
}
-
diff --git a/src/app/system_windows.h b/src/app/system_windows.h
index fbc71a1..9175a44 100644
--- a/src/app/system_windows.h
+++ b/src/app/system_windows.h
@@ -1,19 +1,21 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
/**
* \file app/system_windows.h
@@ -44,8 +46,7 @@ public:
virtual long long GetTimeStampExactResolution() override;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
- virtual std::string GetProfileFileLocation() override;
- virtual std::string GetSavegameDirectoryLocation() override;
+ virtual std::string GetSaveDir() override;
private:
std::string UTF8_Encode(const std::wstring &wstr);