summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Dermont <erihel@gmail.com>2014-06-20 23:41:38 +0200
committerKrzysztof Dermont <erihel@gmail.com>2014-06-20 23:51:28 +0200
commit2260f6bf4feb62929e32a1bea9cd3f403aa034b1 (patch)
treea9f830fe8ddfa57598a0802ced6540befb8c8c75
parentba62e6f8be5f7008939677ce70799ecc26adf420 (diff)
downloadcolobot-2260f6bf4feb62929e32a1bea9cd3f403aa034b1.tar.gz
colobot-2260f6bf4feb62929e32a1bea9cd3f403aa034b1.tar.bz2
colobot-2260f6bf4feb62929e32a1bea9cd3f403aa034b1.zip
Big part of PhysFS support
* removed -mod argument * removed -datadir argument * removed -lang argument * removed some dead ui code * added resource manager and file loaders (stream and SDL) * changed interface textures location to match new directory structure * removed CGameData for mod support * added PhysFS support
-rw-r--r--CMakeLists.txt1
-rw-r--r--cmake/FindPhysFS.cmake36
m---------data0
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/app/app.cpp44
-rw-r--r--src/app/app.h14
-rw-r--r--src/app/gamedata.cpp123
-rw-r--r--src/app/gamedata.h66
-rw-r--r--src/app/main.cpp3
-rw-r--r--src/app/system.cpp16
-rw-r--r--src/app/system.h9
-rw-r--r--src/app/system_linux.cpp28
-rw-r--r--src/app/system_linux.h1
-rw-r--r--src/app/system_macosx.cpp20
-rw-r--r--src/app/system_macosx.h3
-rw-r--r--src/app/system_windows.cpp19
-rw-r--r--src/app/system_windows.h1
-rw-r--r--src/common/image.cpp3
-rw-r--r--src/common/resources/inputstream.cpp53
-rw-r--r--src/common/resources/inputstream.h33
-rw-r--r--src/common/resources/resourcemanager.cpp200
-rw-r--r--src/common/resources/resourcemanager.h40
-rw-r--r--src/common/resources/resourcestreambuffer.cpp121
-rw-r--r--src/common/resources/resourcestreambuffer.h47
-rw-r--r--src/graphics/engine/engine.cpp25
-rw-r--r--src/graphics/engine/lightning.cpp2
-rw-r--r--src/graphics/engine/modelmanager.cpp7
-rw-r--r--src/graphics/engine/particle.cpp8
-rw-r--r--src/graphics/engine/terrain.cpp13
-rw-r--r--src/graphics/engine/text.cpp16
-rw-r--r--src/object/robotmain.cpp20
-rw-r--r--src/script/script.cpp31
-rw-r--r--src/sound/oalsound/alsound.cpp11
-rw-r--r--src/ui/button.cpp2
-rw-r--r--src/ui/check.cpp2
-rw-r--r--src/ui/color.cpp2
-rw-r--r--src/ui/compass.cpp2
-rw-r--r--src/ui/control.cpp16
-rw-r--r--src/ui/displayinfo.cpp282
-rw-r--r--src/ui/displayinfo.h1
-rw-r--r--src/ui/edit.cpp43
-rw-r--r--src/ui/gauge.cpp2
-rw-r--r--src/ui/group.cpp60
-rw-r--r--src/ui/image.cpp2
-rw-r--r--src/ui/key.cpp2
-rw-r--r--src/ui/list.cpp10
-rw-r--r--src/ui/maindialog.cpp24
-rw-r--r--src/ui/map.cpp28
-rw-r--r--src/ui/scroll.cpp8
-rw-r--r--src/ui/shortcut.cpp6
-rw-r--r--src/ui/slider.cpp6
-rw-r--r--src/ui/window.cpp38
52 files changed, 715 insertions, 841 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4405d1..0e2fee4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -204,6 +204,7 @@ find_package(SDL_image 1.2 REQUIRED)
find_package(SDL_ttf 2.0 REQUIRED)
find_package(PNG 1.2 REQUIRED)
find_package(Gettext REQUIRED)
+find_package(PhysFS REQUIRED)
set(Boost_USE_STATIC_LIBS ${BOOST_STATIC})
set(Boost_USE_MULTITHREADED ON)
diff --git a/cmake/FindPhysFS.cmake b/cmake/FindPhysFS.cmake
new file mode 100644
index 0000000..fae8378
--- /dev/null
+++ b/cmake/FindPhysFS.cmake
@@ -0,0 +1,36 @@
+# PHYSFS_FOUND
+# PHYSFS_INCLUDE_PATH
+# PHYSFS_LIBRARY
+#
+
+IF (WIN32)
+ FIND_PATH( PHYSFS_INCLUDE_PATH physfs.h
+ DOC "The directory where physfs.h resides")
+ FIND_LIBRARY( PHYSFS_LIBRARY
+ NAMES physfs
+ PATHS /mingw/lib
+ DOC "The PhysFS library")
+ELSE (WIN32)
+ FIND_PATH( PHYSFS_INCLUDE_PATH physfs.h
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ DOC "The directory where physfs.h resides")
+ FIND_LIBRARY( PHYSFS_LIBRARY
+ NAMES physfs
+ PATHS
+ /usr/lib64
+ /usr/lib
+ /usr/local/lib64
+ /usr/local/lib
+ /opt/local/lib
+ DOC "The PhysFS library")
+ENDIF (WIN32)
+
+IF (PHYSFS_INCLUDE_PATH)
+ SET( PHYSFS_FOUND 1 CACHE STRING "Set to 1 if PhysFS is found, 0 otherwise")
+ELSE (GLEW_INCLUDE_PATH)
+ SET( PHYSFS_FOUND 0 CACHE STRING "Set to 1 if PhysFS is found, 0 otherwise")
+ENDIF (PHYSFS_INCLUDE_PATH)
+
+MARK_AS_ADVANCED( PHYSFS_FOUND )
diff --git a/data b/data
-Subproject 3aa20285393ba9be6b5db7bc4559f2c90f2155b
+Subproject 8867360074568706afcede8cbaa11f8159c9683
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 12171f3..114793d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -61,7 +61,6 @@ endif()
# Source files
set(SOURCES
app/app.cpp
-app/gamedata.cpp
app/main.cpp
app/pausemanager.cpp
app/system.cpp
@@ -75,6 +74,9 @@ common/misc.cpp
common/profile.cpp
common/restext.cpp
common/stringutils.cpp
+common/resources/resourcemanager.cpp
+common/resources/resourcestreambuffer.cpp
+common/resources/inputstream.cpp
graphics/core/color.cpp
graphics/engine/camera.cpp
graphics/engine/cloud.cpp
@@ -202,6 +204,7 @@ ${Boost_LIBRARIES}
${LIBSNDFILE_LIBRARY}
${OPTIONAL_LIBS}
${PLATFORM_LIBS}
+${PHYSFS_LIBRARY}
)
# Local
@@ -224,6 +227,7 @@ ${LIBSNDFILE_INCLUDE_DIR}
${LOCALENAME_INCLUDE_DIR}
${OPTIONAL_INCLUDE_DIRS}
${CLIPBOARD_INCLUDE_DIR}
+${PHYSFS_INCLUDE_PATH}
)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 1efabb5..5b495c3 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -19,7 +19,6 @@
#include "app/app.h"
-#include "app/gamedata.h"
#include "app/system.h"
#include "common/logger.h"
@@ -27,6 +26,7 @@
#include "common/image.h"
#include "common/key.h"
#include "common/stringutils.h"
+#include "common/resources/resourcemanager.h"
#include "graphics/engine/modelmanager.h"
#include "graphics/opengl/gldevice.h"
@@ -101,7 +101,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,7 +111,6 @@ CApplication::CApplication()
m_exitCode = 0;
m_active = false;
m_debugModes = 0;
- m_customDataPath = false;
m_windowTitle = "COLOBOT GOLD";
@@ -149,9 +147,6 @@ CApplication::CApplication()
m_mouseButtonsState = 0;
m_trackedKeys = 0;
- m_dataPath = GetSystemUtils()->GetDataPath();
- m_langPath = GetSystemUtils()->GetLangPath();
-
m_runSceneName = "";
m_runSceneRank = 0;
@@ -266,8 +261,6 @@ 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(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n");
return PARSE_ARGS_HELP;
@@ -331,25 +324,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;
@@ -388,25 +362,17 @@ bool CApplication::Create()
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);
+ boost::filesystem::path dataPath(COLOBOT_DEFAULT_DATADIR);
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());
+ GetLogger()->Error("Data directory '%s' doesn't exist or is not a directory\n", COLOBOT_DEFAULT_DATADIR);
m_errorMessage = std::string("Could not read from data directory:\n") +
- std::string("'") + m_dataPath + std::string("'\n") +
+ std::string("'") + COLOBOT_DEFAULT_DATADIR + 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)) {
Language language;
@@ -1724,7 +1690,7 @@ void CApplication::SetLanguage(Language language)
setlocale(LC_ALL, "");
- bindtextdomain("colobot", m_langPath.c_str());
+ bindtextdomain("colobot", CResourceManager::GetLanguageLocation().c_str());
bind_textdomain_codeset("colobot", "UTF-8");
textdomain("colobot");
diff --git a/src/app/app.h b/src/app/app.h
index 86a757f..66b8900 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -42,7 +42,6 @@ class CInstanceManager;
class CEventQueue;
class CRobotMain;
class CSoundInterface;
-class CGameData;
namespace Gfx {
class CModelManager;
@@ -402,8 +401,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;
@@ -467,16 +464,7 @@ 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;
-
+
//@{
//! Scene to run on startup
std::string m_runSceneName;
diff --git a/src/app/gamedata.cpp b/src/app/gamedata.cpp
deleted file mode 100644
index 1bf3f36..0000000
--- a/src/app/gamedata.cpp
+++ /dev/null
@@ -1,123 +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;
- 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();
- }
- }
-
- std::stringstream str;
- str << m_dataDirs[0];
- str << "/";
- str << m_standardDataDirs[index];
- if (dir == DIR_HELP)
- {
- str << "/";
- str << CApplication::GetInstancePointer()->GetLanguageChar();
- }
- str << "/";
- str << subpath;
- return str.str();
-}
-
-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..324acc2 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -69,6 +69,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,6 +78,8 @@ extern "C"
int SDL_MAIN_FUNC(int argc, char *argv[])
{
CLogger logger; // single istance of logger
+ CResourceManager manager(argv[0]);
+ manager.AddLocation(COLOBOT_DEFAULT_DATADIR);
// Initialize static string arrays
InitializeRestext();
diff --git a/src/app/system.cpp b/src/app/system.cpp
index eaa9e4c..b2e6b47 100644
--- a/src/app/system.cpp
+++ b/src/app/system.cpp
@@ -192,23 +192,7 @@ float CSystemUtils::TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *afte
return result;
}
-std::string CSystemUtils::GetDataPath()
-{
- return COLOBOT_DEFAULT_DATADIR;
-}
-
-std::string CSystemUtils::GetLangPath()
-{
- return COLOBOT_I18N_DIR;
-}
-
std::string CSystemUtils::GetProfileFileLocation()
{
return std::string("colobot.ini");
}
-
-std::string CSystemUtils::GetSavegameDirectoryLocation()
-{
- return std::string("savegame");
-}
-
diff --git a/src/app/system.h b/src/app/system.h
index c2125fe..01f2672 100644
--- a/src/app/system.h
+++ b/src/app/system.h
@@ -130,17 +130,8 @@ public:
/** The difference is \a after - \a before. */
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) = 0;
- //! Returns the data path (containing textures, levels, helpfiles, etc)
- virtual std::string GetDataPath();
-
- //! 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();
};
//! Global function to get CSystemUtils instance
diff --git a/src/app/system_linux.cpp b/src/app/system_linux.cpp
index 492af7d..e584cd1 100644
--- a/src/app/system_linux.cpp
+++ b/src/app/system_linux.cpp
@@ -121,31 +121,3 @@ std::string CSystemUtilsLinux::GetProfileFileLocation()
return profileFile;
}
-
-std::string CSystemUtilsLinux::GetSavegameDirectoryLocation()
-{
- std::string savegameDir;
-
- // Determine savegame dir according to XDG Base Directory Specification
- char *envXDG_DATA_HOME = getenv("XDG_CONFIG_DATA");
- if (envXDG_DATA_HOME == NULL)
- {
- char *envHOME = getenv("HOME");
- if (envHOME == NULL)
- {
- savegameDir = "/tmp/colobot-savegame";
- }
- else
- {
- savegameDir = std::string(envHOME) + "/.local/share/colobot";
- }
- }
- else
- {
- savegameDir = std::string(envXDG_DATA_HOME) + "/colobot";
- }
- GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
-
- return savegameDir;
-}
-
diff --git a/src/app/system_linux.h b/src/app/system_linux.h
index 212d840..ad26454 100644
--- a/src/app/system_linux.h
+++ b/src/app/system_linux.h
@@ -47,7 +47,6 @@ public:
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
virtual std::string GetProfileFileLocation() override;
- virtual std::string GetSavegameDirectoryLocation() override;
private:
bool m_zenityAvailable;
diff --git a/src/app/system_macosx.cpp b/src/app/system_macosx.cpp
index 68f5c79..38885eb 100644
--- a/src/app/system_macosx.cpp
+++ b/src/app/system_macosx.cpp
@@ -87,16 +87,6 @@ void CSystemUtilsMacOSX::Init()
m_dataPath += "/Contents/Resources";
}
-std::string CSystemUtilsMacOSX::GetDataPath()
-{
- return m_dataPath;
-}
-
-std::string CSystemUtilsMacOSX::GetLangPath()
-{
- return m_dataPath + "/i18n";
-}
-
std::string CSystemUtilsMacOSX::GetProfileFileLocation()
{
std::string profileFile = m_ASPath + "/colobot.ini";
@@ -104,13 +94,3 @@ std::string CSystemUtilsMacOSX::GetProfileFileLocation()
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());
- 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..7360af1 100644
--- a/src/app/system_macosx.h
+++ b/src/app/system_macosx.h
@@ -28,10 +28,7 @@ class CSystemUtilsMacOSX : public CSystemUtilsOther
public:
virtual void Init() override;
- virtual std::string GetDataPath() override;
- virtual std::string GetLangPath() override;
virtual std::string GetProfileFileLocation() override;
- virtual std::string GetSavegameDirectoryLocation() override;
private:
std::string m_ASPath;
std::string m_dataPath;
diff --git a/src/app/system_windows.cpp b/src/app/system_windows.cpp
index f48d4e0..ffaa18a 100644
--- a/src/app/system_windows.cpp
+++ b/src/app/system_windows.cpp
@@ -128,22 +128,3 @@ std::string CSystemUtilsWindows::GetProfileFileLocation()
return profileFile;
}
-
-std::string CSystemUtilsWindows::GetSavegameDirectoryLocation()
-{
- std::string savegameDir;
-
- char* envUSERPROFILE = getenv("USERPROFILE");
- if (envUSERPROFILE == NULL)
- {
- savegameDir = "savegame";
- }
- else
- {
- savegameDir = std::string(envUSERPROFILE) + "\\colobot\\savegame";
- }
- 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..0a41c1a 100644
--- a/src/app/system_windows.h
+++ b/src/app/system_windows.h
@@ -45,7 +45,6 @@ public:
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
virtual std::string GetProfileFileLocation() override;
- virtual std::string GetSavegameDirectoryLocation() override;
private:
std::string UTF8_Encode(const std::wstring &wstr);
diff --git a/src/common/image.cpp b/src/common/image.cpp
index 8a876e3..aec3d4e 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -18,6 +18,7 @@
#include "common/image.h"
#include "math/func.h"
+#include "common/resources/resourcemanager.h"
#include <stdlib.h>
#include <stdio.h>
@@ -381,7 +382,7 @@ bool CImage::Load(const std::string& fileName)
m_error = "";
- m_data->surface = IMG_Load(fileName.c_str());
+ m_data->surface = IMG_Load_RW(CResourceManager::GetSDLFileHandler(fileName.c_str()), 1);
if (m_data->surface == nullptr)
{
delete m_data;
diff --git a/src/common/resources/inputstream.cpp b/src/common/resources/inputstream.cpp
new file mode 100644
index 0000000..e121971
--- /dev/null
+++ b/src/common/resources/inputstream.cpp
@@ -0,0 +1,53 @@
+// * 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 "common/resources/inputstream.h"
+#include "common/resources/resourcestreambuffer.h"
+
+
+CInputStream::CInputStream() : std::istream(new CResourceStreamBuffer())
+{
+}
+
+
+CInputStream::~CInputStream()
+{
+ delete rdbuf();
+}
+
+
+void CInputStream::open(const std::string& filename)
+{
+ static_cast<CResourceStreamBuffer *>(rdbuf())->open(filename);
+}
+
+
+void CInputStream::close()
+{
+ static_cast<CResourceStreamBuffer *>(rdbuf())->close();
+}
+
+
+bool CInputStream::is_open()
+{
+ return static_cast<CResourceStreamBuffer *>(rdbuf())->is_open();
+}
+
+
+size_t CInputStream::size()
+{
+ return static_cast<CResourceStreamBuffer *>(rdbuf())->size();
+}
diff --git a/src/common/resources/inputstream.h b/src/common/resources/inputstream.h
new file mode 100644
index 0000000..9d1c578
--- /dev/null
+++ b/src/common/resources/inputstream.h
@@ -0,0 +1,33 @@
+// * 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/.
+
+#pragma once
+
+#include <istream>
+#include <string>
+
+
+class CInputStream : public std::istream
+{
+public:
+ CInputStream();
+ virtual ~CInputStream();
+
+ void open(const std::string &filename);
+ void close();
+ bool is_open();
+ size_t size();
+};
diff --git a/src/common/resources/resourcemanager.cpp b/src/common/resources/resourcemanager.cpp
new file mode 100644
index 0000000..ccef2a3
--- /dev/null
+++ b/src/common/resources/resourcemanager.cpp
@@ -0,0 +1,200 @@
+// * 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 "common/resources/resourcemanager.h"
+
+#include "common/config.h"
+
+#include <physfs.h>
+
+
+CResourceManager::CResourceManager(const char *argv0)
+{
+ if (PHYSFS_init(argv0))
+ {
+ // TODO error
+ }
+}
+
+
+CResourceManager::~CResourceManager()
+{
+ if (PHYSFS_isInit())
+ {
+ if (PHYSFS_deinit())
+ {
+ // TODO error
+ }
+ }
+}
+
+
+bool CResourceManager::AddLocation(const std::string &location, bool prepend)
+{
+ if (PHYSFS_isInit())
+ {
+ if (PHYSFS_mount(location.c_str(), nullptr, prepend ? 0 : 1))
+ {
+ // TODO error
+ }
+ }
+
+ return false;
+}
+
+
+bool CResourceManager::RemoveLocation(const std::string &location)
+{
+ if (PHYSFS_isInit())
+ {
+ if (PHYSFS_removeFromSearchPath(location.c_str()))
+ {
+ // TODO error
+ }
+ }
+
+ return false;
+}
+
+
+bool CResourceManager::SetSaveLocation(const std::string &location)
+{
+ if (PHYSFS_isInit())
+ {
+ if (PHYSFS_setWriteDir(location.c_str()))
+ {
+ // TODO error
+ }
+ }
+
+ return false;
+}
+
+
+std::string CResourceManager::GetLanguageLocation()
+{
+ return COLOBOT_I18N_DIR;
+}
+
+
+SDL_RWops* CResourceManager::GetSDLFileHandler(const std::string &filename)
+{
+ SDL_RWops *handler = SDL_AllocRW();
+ if (!handler)
+ {
+ // TODO error
+ return nullptr;
+ }
+
+ if (!PHYSFS_isInit())
+ {
+ SDL_FreeRW(handler);
+ return nullptr;
+ }
+
+ PHYSFS_File *file = PHYSFS_openRead(filename.c_str());
+ if (!file)
+ {
+ SDL_FreeRW(handler);
+ return nullptr;
+ }
+
+ handler->seek = SDLSeek;
+ handler->read = SDLRead;
+ handler->write = SDLWrite;
+ handler->close = SDLClose;
+ handler->type = 0xc010b04f;
+ handler->hidden.unknown.data1 = file;
+
+ return handler;
+}
+
+
+int CResourceManager::SDLClose(SDL_RWops* context)
+{
+ if (CheckSDLContext(context))
+ {
+ PHYSFS_close(static_cast<PHYSFS_File *>(context->hidden.unknown.data1));
+ SDL_FreeRW(context);
+
+ return 0;
+ }
+
+ return 1;
+}
+
+
+int CResourceManager::SDLRead(SDL_RWops* context, void* ptr, int size, int maxnum)
+{
+ if (CheckSDLContext(context))
+ {
+ PHYSFS_File *file = static_cast<PHYSFS_File *>(context->hidden.unknown.data1);
+ SDL_memset(ptr, 0, size * maxnum);
+
+ return PHYSFS_read(file, ptr, size, maxnum);
+ }
+
+ return 0;
+}
+
+
+int CResourceManager::SDLWrite(SDL_RWops* context, const void* ptr, int size, int num)
+{
+ return 0;
+}
+
+
+int CResourceManager::SDLSeek(SDL_RWops* context, int offset, int whence)
+{
+ if (CheckSDLContext(context))
+ {
+ PHYSFS_File *file = static_cast<PHYSFS_File *>(context->hidden.unknown.data1);
+ int position, result;
+
+ switch (whence)
+ {
+ default:
+ case RW_SEEK_SET:
+ result = PHYSFS_seek(file, offset);
+ return result > 0 ? offset : -1;
+
+ case RW_SEEK_CUR:
+ position = offset + PHYSFS_tell(file);
+ result = PHYSFS_seek(file, position);
+ return result > 0 ? position : -1;
+
+ case RW_SEEK_END:
+ position = PHYSFS_fileLength(file) - offset;
+ result = PHYSFS_seek(file, position);
+ return result > 0 ? position : -1;
+ }
+ }
+
+ return -1;
+}
+
+
+bool CResourceManager::CheckSDLContext(SDL_RWops* context)
+{
+ if (context->type != 0xc010b04f)
+ {
+ SDL_SetError("Wrong kind of RWops");
+ return false;
+ }
+
+ return true;
+}
diff --git a/src/common/resources/resourcemanager.h b/src/common/resources/resourcemanager.h
new file mode 100644
index 0000000..ba11d73
--- /dev/null
+++ b/src/common/resources/resourcemanager.h
@@ -0,0 +1,40 @@
+// * 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/.
+
+#pragma once
+
+#include <string>
+#include <SDL.h>
+
+class CResourceManager
+{
+public:
+ CResourceManager(const char *argv0);
+ ~CResourceManager();
+
+ static bool AddLocation(const std::string &location, bool prepend = true);
+ static bool RemoveLocation(const std::string &location);
+ static bool SetSaveLocation(const std::string &location);
+ static std::string GetLanguageLocation();
+ static SDL_RWops* GetSDLFileHandler(const std::string &filename);
+
+private:
+ static int SDLSeek(SDL_RWops *context, int offset, int whence);
+ static int SDLRead(SDL_RWops *context, void *ptr, int size, int maxnum);
+ static int SDLWrite(SDL_RWops *context, const void *ptr, int size, int num);
+ static int SDLClose(SDL_RWops *context);
+ static bool CheckSDLContext(SDL_RWops *context);
+};
diff --git a/src/common/resources/resourcestreambuffer.cpp b/src/common/resources/resourcestreambuffer.cpp
new file mode 100644
index 0000000..e7be51d
--- /dev/null
+++ b/src/common/resources/resourcestreambuffer.cpp
@@ -0,0 +1,121 @@
+// * 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 "common/resources/resourcestreambuffer.h"
+
+#include <stdexcept>
+#include <sstream>
+
+CResourceStreamBuffer::CResourceStreamBuffer(size_t buffer_size) : m_buffer_size(buffer_size)
+{
+ if (buffer_size <= 0)
+ {
+ throw std::runtime_error("File buffer must be larger then 0 bytes");
+ }
+
+ m_buffer = new char[buffer_size];
+}
+
+
+CResourceStreamBuffer::~CResourceStreamBuffer()
+{
+ close();
+ delete m_buffer;
+}
+
+
+void CResourceStreamBuffer::open(const std::string &filename)
+{
+ if (PHYSFS_isInit())
+ {
+ m_file = PHYSFS_openRead(filename.c_str());
+ }
+}
+
+
+void CResourceStreamBuffer::close()
+{
+ if (is_open())
+ {
+ PHYSFS_close(m_file);
+ }
+}
+
+
+bool CResourceStreamBuffer::is_open()
+{
+ return m_file;
+}
+
+
+size_t CResourceStreamBuffer::size()
+{
+ return PHYSFS_fileLength(m_file);
+}
+
+
+std::streambuf::int_type CResourceStreamBuffer::underflow()
+{
+ if (PHYSFS_eof(m_file))
+ {
+ return traits_type::eof();
+ }
+
+ PHYSFS_sint64 read_count = PHYSFS_read(m_file, m_buffer, sizeof(char), m_buffer_size);
+ if (read_count <= 0)
+ {
+ return traits_type::eof();
+ }
+
+ setg(m_buffer, m_buffer, m_buffer + read_count);
+
+ return traits_type::to_int_type(*gptr());
+}
+
+
+std::streampos CResourceStreamBuffer::seekpos(std::streampos sp, std::ios_base::openmode which)
+{
+ return seekoff(off_type(sp), std::ios_base::beg, which);
+}
+
+
+std::streampos CResourceStreamBuffer::seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which)
+{
+ /* A bit of explanation:
+ We are reading file by m_buffer_size parts so our 3 internal pointers will be
+ * eback (not used here) - start of block
+ * gptr - position of read cursor in block
+ * egtpr - end of block
+ off argument is relative to way */
+
+ switch (way)
+ {
+ case std::ios_base::beg:
+ return pos_type(off_type(off));
+
+ case std::ios_base::cur:
+ // tell will give cursor at begining of block so we have to add where in block we currently are
+ return off + static_cast<off_type>(PHYSFS_tell(m_file)) - static_cast<off_type> (egptr() - gptr());
+
+ case std::ios_base::end:
+ return off + static_cast<off_type>(PHYSFS_fileLength(m_file));
+
+ default:
+ break;
+ }
+
+ return pos_type(off_type(-1));
+}
diff --git a/src/common/resources/resourcestreambuffer.h b/src/common/resources/resourcestreambuffer.h
new file mode 100644
index 0000000..a9ec0db
--- /dev/null
+++ b/src/common/resources/resourcestreambuffer.h
@@ -0,0 +1,47 @@
+// * 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/.
+
+#pragma once
+
+#include <streambuf>
+#include <string>
+#include <physfs.h>
+
+class CResourceStreamBuffer : public std::streambuf
+{
+public:
+ CResourceStreamBuffer(size_t buffer_size = 512);
+ virtual ~CResourceStreamBuffer();
+
+ void open(const std::string &filename);
+ void close();
+ bool is_open();
+ size_t size();
+
+private:
+ int_type underflow();
+ std::streampos seekpos(std::streampos sp, std::ios_base::openmode which);
+ std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which);
+
+ // copy ctor and assignment not implemented;
+ // copying not allowed
+ CResourceStreamBuffer(const CResourceStreamBuffer &);
+ CResourceStreamBuffer &operator= (const CResourceStreamBuffer &);
+
+ PHYSFS_File *m_file;
+ char *m_buffer;
+ size_t m_buffer_size;
+};
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index d6e4415..072261b 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -19,7 +19,6 @@
#include "graphics/engine/engine.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/image.h"
#include "common/key.h"
@@ -283,7 +282,7 @@ bool CEngine::Create()
params.minFilter = TEX_MIN_FILTER_NEAREST;
params.magFilter = TEX_MAG_FILTER_NEAREST;
params.mipmap = false;
- m_miceTexture = LoadTexture("mouse.png", params);
+ m_miceTexture = LoadTexture("textures/interface/mouse.png", params);
GetSystemUtils()->GetCurrentTimeStamp(m_currentFrameTime);
GetSystemUtils()->GetCurrentTimeStamp(m_lastFrameTime);
@@ -2247,7 +2246,7 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa
if (image == nullptr)
{
- if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName)))
+ if (!img.Load(texName))
{
std::string error = img.GetError();
GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
@@ -2298,15 +2297,15 @@ Texture CEngine::LoadTexture(const std::string& name, const TextureCreateParams&
bool CEngine::LoadAllTextures()
{
- LoadTexture("text.png");
- m_miceTexture = LoadTexture("mouse.png");
- LoadTexture("button1.png");
- LoadTexture("button2.png");
- LoadTexture("button3.png");
- LoadTexture("effect00.png");
- LoadTexture("effect01.png");
- LoadTexture("effect02.png");
- LoadTexture("map.png");
+ LoadTexture("textures/interface/text.png");
+ m_miceTexture = LoadTexture("textures/interface/mouse.png");
+ LoadTexture("textures/interface/button1.png");
+ LoadTexture("textures/interface/button2.png");
+ LoadTexture("textures/interface/button3.png");
+ LoadTexture("textures/interface/effect00.png");
+ LoadTexture("textures/interface/effect01.png");
+ LoadTexture("textures/interface/effect02.png");
+ LoadTexture("textures/interface/map.png");
if (! m_backgroundName.empty())
{
@@ -2415,7 +2414,7 @@ bool CEngine::ChangeTextureColor(const std::string& texName,
CImage img;
- if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName)))
+ if (!img.Load(texName))
{
std::string error = img.GetError();
GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp
index 4395eec..69d8a3c 100644
--- a/src/graphics/engine/lightning.cpp
+++ b/src/graphics/engine/lightning.cpp
@@ -235,7 +235,7 @@ void CLightning::Draw()
mat.LoadIdentity();
device->SetTransform(TRANSFORM_WORLD, mat);
- m_engine->SetTexture("effect00.png");
+ m_engine->SetTexture("textures/interface/effect00.png");
m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK);
Math::Point texInf;
diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp
index 0c0fb98..fc201fa 100644
--- a/src/graphics/engine/modelmanager.cpp
+++ b/src/graphics/engine/modelmanager.cpp
@@ -18,7 +18,6 @@
#include "graphics/engine/modelmanager.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/logger.h"
@@ -48,11 +47,9 @@ bool CModelManager::LoadModel(const std::string& fileName, bool mirrored)
if (CApplication::GetInstance().IsDebugModeActive(DEBUG_MODELS))
modelFile.SetPrintDebugInfo(true);
- std::string filePath = CGameData::GetInstancePointer()->GetFilePath(DIR_MODEL, fileName);
-
- if (!modelFile.ReadModel(filePath))
+ if (!modelFile.ReadModel(fileName))
{
- GetLogger()->Error("Loading model '%s' failed\n", filePath.c_str());
+ GetLogger()->Error("Loading model '%s' failed\n", fileName.c_str());
return false;
}
diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
index abee2e2..ead2387 100644
--- a/src/graphics/engine/particle.cpp
+++ b/src/graphics/engine/particle.cpp
@@ -198,10 +198,10 @@ void CParticle::FlushParticle(int sheet)
//! Returns file name of the effect effectNN.png, with NN = number
void NameParticle(std::string &name, int num)
{
- if (num == 1) name = "effect00.png";
- else if (num == 2) name = "effect01.png";
- else if (num == 3) name = "effect02.png";
- else if (num == 4) name = "text.png";
+ if (num == 1) name = "textures/interface/effect00.png";
+ else if (num == 2) name = "textures/interface/effect01.png";
+ else if (num == 3) name = "textures/interface/effect02.png";
+ else if (num == 4) name = "textures/interface/text.png";
else name = "";
}
diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp
index 5f37cd8..037cba6 100644
--- a/src/graphics/engine/terrain.cpp
+++ b/src/graphics/engine/terrain.cpp
@@ -19,7 +19,6 @@
#include "graphics/engine/terrain.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/image.h"
#include "common/logger.h"
@@ -190,10 +189,10 @@ void CTerrain::AddMaterial(int id, const std::string& texName, const Math::Point
bool CTerrain::LoadResources(const std::string& fileName)
{
CImage img;
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName);
- if (! img.Load(path))
+
+ if (! img.Load(fileName))
{
- GetLogger()->Error("Cannot load resource file: '%s'\n", path.c_str());
+ GetLogger()->Error("Cannot load resource file: '%s'\n", fileName.c_str());
return false;
}
@@ -287,10 +286,10 @@ bool CTerrain::LoadRelief(const std::string &fileName, float scaleRelief,
m_scaleRelief = scaleRelief;
CImage img;
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName);
- if (! img.Load(path))
+
+ if (! img.Load(fileName))
{
- GetLogger()->Error("Could not load relief file: '%s'!\n", path.c_str());
+ GetLogger()->Error("Could not load relief file: '%s'!\n", fileName.c_str());
return false;
}
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 8fd01b7..78cf7b8 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -19,11 +19,11 @@
#include "graphics/engine/text.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/image.h"
#include "common/logger.h"
#include "common/stringutils.h"
+#include "common/resources/resourcemanager.h"
#include "math/func.h"
@@ -78,12 +78,12 @@ bool CText::Create()
return false;
}
- m_fonts[FONT_COLOBOT] = new MultisizeFont("dvu_sans.ttf");
- m_fonts[FONT_COLOBOT_BOLD] = new MultisizeFont("dvu_sans_bold.ttf");
- m_fonts[FONT_COLOBOT_ITALIC] = new MultisizeFont("dvu_sans_italic.ttf");
+ m_fonts[FONT_COLOBOT] = new MultisizeFont("fonts/dvu_sans.ttf");
+ m_fonts[FONT_COLOBOT_BOLD] = new MultisizeFont("fonts/dvu_sans_bold.ttf");
+ m_fonts[FONT_COLOBOT_ITALIC] = new MultisizeFont("fonts/dvu_sans_italic.ttf");
- m_fonts[FONT_COURIER] = new MultisizeFont("dvu_sans_mono.ttf");
- m_fonts[FONT_COURIER_BOLD] = new MultisizeFont("dvu_sans_mono_bold.ttf");
+ m_fonts[FONT_COURIER] = new MultisizeFont("fonts/dvu_sans_mono.ttf");
+ m_fonts[FONT_COURIER_BOLD] = new MultisizeFont("fonts/dvu_sans_mono_bold.ttf");
for (auto it = m_fonts.begin(); it != m_fonts.end(); ++it)
{
@@ -866,10 +866,8 @@ CachedFont* CText::GetOrOpenFont(FontType font, float size)
return m_lastCachedFont;
}
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_FONT, mf->fileName);
-
m_lastCachedFont = new CachedFont();
- m_lastCachedFont->font = TTF_OpenFont(path.c_str(), pointSize);
+ m_lastCachedFont->font = TTF_OpenFontRW(CResourceManager::GetSDLFileHandler(mf->fileName), 1, pointSize);
if (m_lastCachedFont->font == nullptr)
m_error = std::string("TTF_OpenFont error ") + std::string(TTF_GetError());
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 2424938..1c75137 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -20,7 +20,6 @@
#include "CBot/CBotDll.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/event.h"
#include "common/global.h"
@@ -4082,8 +4081,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "Instructions") && !resetObject)
{
OpString(line, "name", name);
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
- strcpy(m_infoFilename[SATCOM_HUSTON], path.c_str());
+ strcpy(m_infoFilename[SATCOM_HUSTON], name);
m_immediatSatCom = OpInt(line, "immediat", 0);
if (m_version >= 2) m_beginSatCom = m_lockedSatCom = OpInt(line, "lock", 0);
@@ -4094,31 +4092,27 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "Satellite") && !resetObject)
{
OpString(line, "name", name);
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
- strcpy(m_infoFilename[SATCOM_SAT], path.c_str());
+ strcpy(m_infoFilename[SATCOM_SAT], name);
continue;
}
if (Cmd(line, "Loading") && !resetObject)
{
OpString(line, "name", name);
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
- strcpy(m_infoFilename[SATCOM_LOADING], path.c_str());
+ strcpy(m_infoFilename[SATCOM_LOADING], name);
continue;
}
if (Cmd(line, "HelpFile") && !resetObject)
{
OpString(line, "name", name);
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
- strcpy(m_infoFilename[SATCOM_PROG], path.c_str());
+ strcpy(m_infoFilename[SATCOM_PROG], name);
continue;
}
if (Cmd(line, "SoluceFile") && !resetObject)
{
OpString(line, "name", name);
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
- strcpy(m_infoFilename[SATCOM_SOLUCE], path.c_str());
+ strcpy(m_infoFilename[SATCOM_SOLUCE], name);
continue;
}
@@ -5308,12 +5302,12 @@ void CRobotMain::ChangeColor()
// PARTIPLOUF0 and PARTIDROP :
ts = Math::Point(0.500f, 0.500f);
ti = Math::Point(0.875f, 0.750f);
- m_engine->ChangeTextureColor("effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
+ m_engine->ChangeTextureColor("textures/interface/effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
// PARTIFLIC :
ts = Math::Point(0.00f, 0.75f);
ti = Math::Point(0.25f, 1.00f);
- m_engine->ChangeTextureColor("effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
+ m_engine->ChangeTextureColor("textures/interface/effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
}
//! Updates the number of unnecessary objects
diff --git a/src/script/script.cpp b/src/script/script.cpp
index f97ed08..11aa5c1 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -18,7 +18,6 @@
#include "script/script.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/global.h"
#include "common/iman.h"
@@ -4407,7 +4406,7 @@ void CScript::New(Ui::CEdit* edit, const char* name)
sf = m_main->GetScriptFile();
if ( sf[0] != 0 ) // Load an empty program specific?
{
- std::string filename = CGameData::GetInstancePointer()->GetFilePath(DIR_AI, sf);
+ std::string filename = sf;
file = fopen(filename.c_str(), "rb");
if ( file != NULL )
{
@@ -4497,20 +4496,8 @@ bool CScript::ReadScript(const char* filename)
{
FILE* file;
Ui::CEdit* edit;
- std::string name;
- if ( strchr(filename, '/') == 0 ) //we're reading non user script
- {
- name = CGameData::GetInstancePointer()->GetFilePath(DIR_AI, filename);
- }
- else
- {
- name = filename;
- //TODO: is this needed?
- // UserDir(name, filename, "");
- }
-
- file = fopen(name.c_str(), "rb");
+ file = fopen(filename, "rb");
if ( file == NULL ) return false;
fclose(file);
@@ -4520,7 +4507,7 @@ bool CScript::ReadScript(const char* filename)
edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9);
edit->SetMaxChar(Ui::EDITSTUDIOMAX);
edit->SetAutoIndent(m_engine->GetEditIndentMode());
- edit->ReadText(name.c_str());
+ edit->ReadText(filename);
GetScript(edit);
m_interface->DeleteControl(EVENT_EDIT9);
return true;
@@ -4531,16 +4518,6 @@ bool CScript::ReadScript(const char* filename)
bool CScript::WriteScript(const char* filename)
{
Ui::CEdit* edit;
- std::string name;
-
- if ( strchr(filename, '/') == 0 ) //we're writing non user script
- {
- name = CGameData::GetInstancePointer()->GetFilePath(DIR_AI, filename);
- }
- else
- {
- name = filename;
- }
if ( m_script == nullptr )
{
@@ -4552,7 +4529,7 @@ bool CScript::WriteScript(const char* filename)
edit->SetMaxChar(Ui::EDITSTUDIOMAX);
edit->SetAutoIndent(m_engine->GetEditIndentMode());
edit->SetText(m_script);
- edit->WriteText(name);
+ edit->WriteText(filename);
m_interface->DeleteControl(EVENT_EDIT9);
return true;
}
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index 8afbdd2..4d40c3b 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -18,8 +18,6 @@
#include "sound/oalsound/alsound.h"
-#include "app/gamedata.h"
-
#include <algorithm>
#include <iomanip>
@@ -165,7 +163,7 @@ int ALSound::GetMusicVolume()
bool ALSound::Cache(Sound sound, const std::string &filename)
{
Buffer *buffer = new Buffer();
- if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_SOUND, filename), sound))
+ if (buffer->LoadFromFile(filename, sound))
{
m_sounds[sound] = buffer;
return true;
@@ -178,7 +176,7 @@ bool ALSound::CacheMusic(const std::string &filename)
if (m_music.find(filename) == m_music.end())
{
Buffer *buffer = new Buffer();
- if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename), static_cast<Sound>(-1)))
+ if (buffer->LoadFromFile(filename, static_cast<Sound>(-1)))
{
m_music[filename] = buffer;
return true;
@@ -635,21 +633,20 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim
return false;
}
- std::string file = CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename);
Buffer *buffer;
// check if we have music in cache
if (m_music.find(filename) == m_music.end())
{
GetLogger()->Debug("Music %s was not cached!\n", filename.c_str());
- if (!boost::filesystem::exists(file))
+ if (!boost::filesystem::exists(filename))
{
GetLogger()->Debug("Requested music %s was not found.\n", filename.c_str());
return false;
}
buffer = new Buffer();
- if (!buffer->LoadFromFile(file, static_cast<Sound>(-1)))
+ if (!buffer->LoadFromFile(filename, static_cast<Sound>(-1)))
{
return false;
}
diff --git a/src/ui/button.cpp b/src/ui/button.cpp
index 810d365..d859fb7 100644
--- a/src/ui/button.cpp
+++ b/src/ui/button.cpp
@@ -176,7 +176,7 @@ void CButton::Draw()
(m_state & STATE_CARD ) == 0 &&
(m_state & STATE_SIMPLY) == 0 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
dp = 0.5f / 256.0f;
diff --git a/src/ui/check.cpp b/src/ui/check.cpp
index 6a92554..3410d2e 100644
--- a/src/ui/check.cpp
+++ b/src/ui/check.cpp
@@ -102,7 +102,7 @@ void CCheck::Draw()
DrawShadow(m_pos, m_dim);
}
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
zoomExt = 1.00f;
diff --git a/src/ui/color.cpp b/src/ui/color.cpp
index cbbc0dc..b8659e3 100644
--- a/src/ui/color.cpp
+++ b/src/ui/color.cpp
@@ -138,7 +138,7 @@ void CColor::Draw()
DrawShadow(m_pos, m_dim);
}
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
CControl::Draw();
diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp
index d0fe96f..ebe1908 100644
--- a/src/ui/compass.cpp
+++ b/src/ui/compass.cpp
@@ -88,7 +88,7 @@ void CCompass::Draw()
device = m_engine->GetDevice();
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
p1.x = m_pos.x;
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 501350e..c759505 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -437,7 +437,7 @@ void CControl::Draw()
if ( (m_state & STATE_VISIBLE) == 0 ) return;
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
zoomExt = 1.00f;
@@ -491,7 +491,7 @@ void CControl::Draw()
if ( m_state & STATE_OKAY )
{
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
icon = 3; // yellow with green point pressed
}
@@ -507,22 +507,22 @@ void CControl::Draw()
{
icon -= 192;
#if _POLISH
- m_engine->SetTexture("textp.png");
+ m_engine->SetTexture("textures/interface/textp.png");
#else
- m_engine->SetTexture("text.png");
+ m_engine->SetTexture("textures/interface/text.png");
#endif
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
}
else if ( icon >= 128 )
{
icon -= 128;
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
}
else if ( icon >= 64 )
{
icon -= 64;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
}
else
@@ -755,7 +755,7 @@ void CControl::DrawWarning(Math::Point pos, Math::Point dim)
dp = 0.5f / 256.0f;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f / 256.0f;
@@ -799,7 +799,7 @@ void CControl::DrawShadow(Math::Point pos, Math::Point dim, float deep)
dp = 0.5f/256.0f;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState( Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x += deep * 0.010f * 0.75f;
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 8db53c5..ee29e27 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -342,8 +342,6 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
m_index = index;
m_bSoluce = bSoluce;
-//? CreateObjectsFile();
-
m_bEditLock = m_main->GetEditLock();
if ( m_bEditLock ) // edition running program?
{
@@ -941,284 +939,4 @@ CObject* CDisplayInfo::SearchToto()
return 0;
}
-
-// Creating the list of objects.
-
-struct ObjectList
-{
- int total;
- ObjectType type;
-};
-
-void ObjectAdd(ObjectList list[], ObjectType type)
-{
- int i;
-
- for ( i=0 ; i<200 ; i++ )
- {
- if ( list[i].total == 0 )
- {
- list[i].total ++;
- list[i].type = type;
- list[i+1].total = 0;
- return;
- }
- if ( list[i].type == type )
- {
- list[i].total ++;
- return;
- }
- }
-}
-
-void ObjectWrite(FILE* file, ObjectList list[], int i)
-{
- std::string line;
-
- if ( list[i].total < 10 )
- {
- line = StrUtils::Format("\\c; %dx \\n;\\l;", list[i].total);
- }
- else
- {
- line = StrUtils::Format("\\c;%dx \\n;\\l;", list[i].total);
- }
-
- std::string res;
- GetResource(RES_OBJECT, list[i].type, res);
- if (res.empty())
- return;
-
- line += res;
-
- line += "\\u ";
-
- std::string helpFilename = GetHelpFilename(list[i].type);
- if (helpFilename.empty())
- return;
-
- line += helpFilename.substr(7); // skip "help\?\"
-
- auto pos = line.find(".txt");
- if (pos != std::string::npos)
- {
- line = line.substr(0, pos);
- }
-
- line += ";\n";
-
- fputs(line.c_str(), file);
-}
-
-// Creates the file containing the list of objects.
-
-void CDisplayInfo::CreateObjectsFile()
-{
- FILE* file;
- CObject* pObj;
- ObjectType type;
- ObjectList list[200];
- std::string line;
- int i;
- bool bRadar, bAtLeast;
-
- CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
-
- file = fopen((std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("objects.txt")).c_str(), "w");
- if ( file == 0 ) return;
-
- list[0].total = 0; // empty list
- bRadar = false;
- for ( i=0 ; i<1000000 ; i++ )
- {
- pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
- if ( pObj == 0 ) break;
-
- if ( !pObj->GetActif() ) continue;
- if ( !pObj->GetSelectable() ) continue;
- if ( pObj->GetProxyActivate() ) continue;
-
- type = pObj->GetType();
- if ( type == OBJECT_NULL ) continue;
- if ( type == OBJECT_FIX ) continue;
-
- ObjectAdd(list, type);
-
- if ( type == OBJECT_RADAR ) bRadar = true;
- }
-
- if ( bRadar )
- {
- GetResource(RES_TEXT, RT_SATCOM_LIST, line);
- fputs(line.c_str(), file);
- bAtLeast = false;
- for ( i=0 ; i<200 ; i++ )
- {
- if ( list[i].total == 0 ) break; // end of the list?
-
- if ( list[i].type == OBJECT_BASE ||
- list[i].type == OBJECT_HUMAN )
- {
- ObjectWrite(file, list, i);
- bAtLeast = true;
- }
- }
- if ( !bAtLeast )
- {
- GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line.c_str(), file);
- }
-
- fputs("\n", file);
- GetResource(RES_TEXT, RT_SATCOM_BOT, line);
- fputs(line.c_str(), file);
- bAtLeast = false;
- for ( i=0 ; i<200 ; i++ )
- {
- if ( list[i].total == 0 ) break; // end of the list?
-
- if ( list[i].type == OBJECT_MOBILEwt ||
- list[i].type == OBJECT_MOBILEtt ||
- list[i].type == OBJECT_MOBILEft ||
- list[i].type == OBJECT_MOBILEit ||
- list[i].type == OBJECT_MOBILEwa ||
- list[i].type == OBJECT_MOBILEta ||
- list[i].type == OBJECT_MOBILEfa ||
- list[i].type == OBJECT_MOBILEia ||
- list[i].type == OBJECT_MOBILEwc ||
- list[i].type == OBJECT_MOBILEtc ||
- list[i].type == OBJECT_MOBILEfc ||
- list[i].type == OBJECT_MOBILEic ||
- list[i].type == OBJECT_MOBILEwi ||
- list[i].type == OBJECT_MOBILEti ||
- list[i].type == OBJECT_MOBILEfi ||
- list[i].type == OBJECT_MOBILEii ||
- list[i].type == OBJECT_MOBILEws ||
- list[i].type == OBJECT_MOBILEts ||
- list[i].type == OBJECT_MOBILEfs ||
- list[i].type == OBJECT_MOBILEis ||
- list[i].type == OBJECT_MOBILErt ||
- list[i].type == OBJECT_MOBILErc ||
- list[i].type == OBJECT_MOBILErr ||
- list[i].type == OBJECT_MOBILErs ||
- list[i].type == OBJECT_MOBILEsa ||
- list[i].type == OBJECT_MOBILEtg ||
- list[i].type == OBJECT_MOBILEdr )
- {
- ObjectWrite(file, list, i);
- bAtLeast = true;
- }
- }
- if ( !bAtLeast )
- {
- GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line.c_str(), file);
- }
-
- fputs("\n", file);
- GetResource(RES_TEXT, RT_SATCOM_BUILDING, line);
- fputs(line.c_str(), file);
- bAtLeast = false;
- for ( i=0 ; i<200 ; i++ )
- {
- if ( list[i].total == 0 ) break; // end of the list?
-
- if ( list[i].type == OBJECT_DERRICK ||
- list[i].type == OBJECT_FACTORY ||
- list[i].type == OBJECT_STATION ||
- list[i].type == OBJECT_CONVERT ||
- list[i].type == OBJECT_REPAIR ||
- list[i].type == OBJECT_DESTROYER||
- list[i].type == OBJECT_TOWER ||
- list[i].type == OBJECT_NEST ||
- list[i].type == OBJECT_RESEARCH ||
- list[i].type == OBJECT_RADAR ||
- list[i].type == OBJECT_ENERGY ||
- list[i].type == OBJECT_LABO ||
- list[i].type == OBJECT_NUCLEAR ||
- list[i].type == OBJECT_START ||
- list[i].type == OBJECT_END ||
- list[i].type == OBJECT_INFO ||
- list[i].type == OBJECT_PARA ||
- list[i].type == OBJECT_TARGET1 ||
- list[i].type == OBJECT_TARGET2 ||
- list[i].type == OBJECT_SAFE ||
- list[i].type == OBJECT_HUSTON )
- {
- ObjectWrite(file, list, i);
- bAtLeast = true;
- }
- }
- if ( !bAtLeast )
- {
- GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line.c_str(), file);
- }
-
- fputs("\n", file);
- GetResource(RES_TEXT, RT_SATCOM_FRET, line);
- fputs(line.c_str(), file);
- bAtLeast = false;
- for ( i=0 ; i<200 ; i++ )
- {
- if ( list[i].total == 0 ) break; // end of the list?
-
- if ( list[i].type == OBJECT_STONE ||
- list[i].type == OBJECT_URANIUM ||
- list[i].type == OBJECT_METAL ||
- list[i].type == OBJECT_POWER ||
- list[i].type == OBJECT_ATOMIC ||
- list[i].type == OBJECT_BULLET ||
- list[i].type == OBJECT_BBOX ||
- list[i].type == OBJECT_TNT )
- {
- ObjectWrite(file, list, i);
- bAtLeast = true;
- }
- }
- if ( !bAtLeast )
- {
- GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line.c_str(), file);
- }
-
- fputs("\n", file);
- GetResource(RES_TEXT, RT_SATCOM_ALIEN, line);
- fputs(line.c_str(), file);
- bAtLeast = false;
- for ( i=0 ; i<200 ; i++ )
- {
- if ( list[i].total == 0 ) break; // end of the list?
-
- if ( list[i].type == OBJECT_MOTHER ||
- list[i].type == OBJECT_ANT ||
- list[i].type == OBJECT_BEE ||
- list[i].type == OBJECT_WORM ||
- list[i].type == OBJECT_SPIDER )
- {
- ObjectWrite(file, list, i);
- bAtLeast = true;
- }
- }
- if ( !bAtLeast )
- {
- GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line.c_str(), file);
- }
- }
- else
- {
- GetResource(RES_TEXT, RT_SATCOM_ERROR1, line);
- fputs(line.c_str(), file);
- GetResource(RES_TEXT, RT_SATCOM_ERROR2, line);
- fputs(line.c_str(), file);
- }
-
- fputs("\n", file);
-
- fclose(file);
-}
-
-
}
-
diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h
index 891551b..0942497 100644
--- a/src/ui/displayinfo.h
+++ b/src/ui/displayinfo.h
@@ -66,7 +66,6 @@ protected:
void UpdateCopyButton();
void ViewDisplayInfo();
CObject* SearchToto();
- void CreateObjectsFile();
protected:
Gfx::CEngine* m_engine;
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index 6602651..287d0f3 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -19,10 +19,11 @@
#include "ui/edit.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "clipboard/clipboard.h"
+#include "common/resources/inputstream.h"
+
#include <string.h>
namespace Ui {
@@ -782,15 +783,13 @@ void CEdit::HyperJump(std::string name, std::string marker)
sMarker = marker;
-//? sprintf(filename, "help\\%s.txt", name);
-
if ( name[0] == '%' )
{
filename = GetProfile().GetUserBasedPath(name, "") + ".txt";
}
else
{
- filename = std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + "/" + name + std::string(".txt");
+ filename = name + std::string(".txt");
}
if ( ReadText(filename) )
@@ -1145,7 +1144,7 @@ void CEdit::DrawImage(Math::Point pos, std::string name, float width,
float dp;
std::string filename;
- filename = GetProfile().GetUserBasedPath(name, "../icons") + ".png";
+ filename = name + ".png";
m_engine->SetTexture(filename);
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
@@ -1175,7 +1174,7 @@ void CEdit::DrawBack(Math::Point pos, Math::Point dim)
if ( m_bGeneric ) return;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
if ( m_bMulti )
@@ -1226,9 +1225,9 @@ void CEdit::DrawPart(Math::Point pos, Math::Point dim, int icon)
float dp;
#if _POLISH
- m_engine->SetTexture("textp.png");
+ m_engine->SetTexture("textures/interface/textp.png");
#else
- m_engine->SetTexture("text.png");
+ m_engine->SetTexture("textures/interface/text.png");
#endif
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
@@ -1427,7 +1426,7 @@ void CEdit::FreeImage()
for (int i = 0 ; i < m_imageTotal; i++ )
{
- filename = GetProfile().GetUserBasedPath(m_image[i].name, "../icons") + ".png";
+ filename = m_image[i].name + ".png";
m_engine->DeleteTexture(filename);
}
}
@@ -1437,7 +1436,7 @@ void CEdit::FreeImage()
void CEdit::LoadImage(std::string name)
{
std::string filename;
- filename = GetProfile().GetUserBasedPath(name, "../icons") + ".png";
+ filename = name + ".png";
m_engine->LoadTexture(filename);
}
@@ -1445,7 +1444,6 @@ void CEdit::LoadImage(std::string name)
bool CEdit::ReadText(std::string filename, int addSize)
{
- FILE *file = NULL;
char *buffer;
int len, i, j, n, font, iIndex, iLines, iCount, iLink, res;
char iName[50];
@@ -1457,24 +1455,17 @@ bool CEdit::ReadText(std::string filename, int addSize)
if ( filename[0] == 0 ) return false;
boost::replace_all(filename, "\\", "/");
-
- /* This is ugly but doesn't require many changes in code. If file doesn't
- exists it's posible filename is absolute not full path */
std::string path = filename;
- if (!fs::exists(path))
+
+ CInputStream stream;
+ stream.open(fs::path(path).make_preferred().string());
+
+ if (!stream.is_open())
{
- path = CGameData::GetInstancePointer()->GetDataPath(filename);
- }
-
- file = fopen(fs::path(path).make_preferred().string().c_str(), "rb");
- if ( file == NULL ) {
- CLogger::GetInstancePointer()->Error("Unable to read text from file \"%s\"\n", path.c_str());
return false;
}
- fseek(file, 0, SEEK_END);
- len = ftell(file);
- fseek(file, 0, SEEK_SET);
+ len = stream.size();
m_maxChar = len+addSize+100;
m_len = len;
@@ -1492,7 +1483,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
buffer = new char[m_maxChar+1];
memset(buffer, 0, m_maxChar+1);
- fread(buffer, 1, len, file);
+ stream.read(buffer, len);
m_format.clear();
m_format.reserve(m_maxChar+1);
@@ -1501,7 +1492,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
m_format.push_back(0);
}
- fclose(file);
+ stream.close();
bInSoluce = false;
font = m_fontType;
diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp
index a8ee41c..170db5b 100644
--- a/src/ui/gauge.cpp
+++ b/src/ui/gauge.cpp
@@ -75,7 +75,7 @@ void CGauge::Draw()
if ( (m_state & STATE_VISIBLE) == 0 ) return;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
dp = 0.5f/256.0f;
diff --git a/src/ui/group.cpp b/src/ui/group.cpp
index 64495e0..d90a9e6 100644
--- a/src/ui/group.cpp
+++ b/src/ui/group.cpp
@@ -87,7 +87,7 @@ void CGroup::Draw()
if ( m_icon == 0 ) // hollow frame?
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 160.0f / 256.0f;
uv1.y = 192.0f / 256.0f; // u-v texture
@@ -103,7 +103,7 @@ void CGroup::Draw()
}
if ( m_icon == 1 ) // orange solid opaque?
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 104.0f / 256.0f;
uv1.y = 48.0f / 256.0f;
@@ -117,7 +117,7 @@ void CGroup::Draw()
}
if ( m_icon == 2 ) // orange degrade -> transparent?
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 112.0f / 256.0f;
uv1.y = 48.0f / 256.0f;
@@ -131,7 +131,7 @@ void CGroup::Draw()
}
if ( m_icon == 3 ) // transparent gradient -> gray?
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 120.0f / 256.0f;
uv1.y = 48.0f / 256.0f;
@@ -145,7 +145,7 @@ void CGroup::Draw()
}
if ( m_icon == 4 ) // degrade blue corner?
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 192.0f / 256.0f;
uv1.y = 128.0f / 256.0f;
@@ -159,7 +159,7 @@ void CGroup::Draw()
}
if ( m_icon == 5 ) // degrade orange corner?
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 224.0f / 256.0f;
uv1.y = 128.0f / 256.0f;
@@ -173,7 +173,7 @@ void CGroup::Draw()
}
if ( m_icon == 6 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 0.0f / 256.0f; // brown transparent
uv1.y = 75.0f / 256.0f;
@@ -189,7 +189,7 @@ void CGroup::Draw()
}
if ( m_icon == 7 )
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f / 256.0f;
uv1.y = 0.0f / 256.0f;
@@ -203,7 +203,7 @@ void CGroup::Draw()
}
if ( m_icon == 8 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f / 256.0f; // green transparent
uv1.y = 160.0f / 256.0f;
@@ -217,7 +217,7 @@ void CGroup::Draw()
}
if ( m_icon == 9 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f / 256.0f; // red transparent
uv1.y = 176.0f/256.0f;
@@ -231,7 +231,7 @@ void CGroup::Draw()
}
if ( m_icon == 10 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f / 256.0f; // blue transparent
uv1.y = 192.0f / 256.0f;
@@ -245,7 +245,7 @@ void CGroup::Draw()
}
if ( m_icon == 11 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f / 256.0f; // yellow transparent
uv1.y = 224.0f / 256.0f;
@@ -262,7 +262,7 @@ void CGroup::Draw()
dim.x = m_dim.x / 2.0f;
dim.y = m_dim.y / 2.0f;
- m_engine->SetTexture("mouse.png");
+ m_engine->SetTexture("textures/interface/mouse.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/300.0f;
pos.y = m_pos.y+m_dim.y/300.0f+dim.y;
@@ -301,7 +301,7 @@ void CGroup::Draw()
}
if ( m_icon == 13 ) // corner upper / left?
{
- m_engine->SetTexture("mouse.png");
+ m_engine->SetTexture("textures/interface/mouse.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f;
@@ -322,7 +322,7 @@ void CGroup::Draw()
}
if ( m_icon == 14 ) // corner upper / right?
{
- m_engine->SetTexture("mouse.png");
+ m_engine->SetTexture("textures/interface/mouse.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f;
@@ -343,7 +343,7 @@ void CGroup::Draw()
}
if ( m_icon == 15 ) // corner lower / left?
{
- m_engine->SetTexture("mouse.png");
+ m_engine->SetTexture("textures/interface/mouse.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f;
@@ -364,7 +364,7 @@ void CGroup::Draw()
}
if ( m_icon == 16 ) // corner lower / left?
{
- m_engine->SetTexture("mouse.png");
+ m_engine->SetTexture("textures/interface/mouse.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f;
@@ -385,7 +385,7 @@ void CGroup::Draw()
}
if ( m_icon == 17 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f / 256.0f; // blue frame
uv1.y = 75.0f / 256.0f;
@@ -401,7 +401,7 @@ void CGroup::Draw()
}
if ( m_icon == 18 ) // arrow> for SatCom?
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 0.0f / 256.0f; // >
uv1.y = 192.0f / 256.0f;
@@ -415,7 +415,7 @@ void CGroup::Draw()
}
if ( m_icon == 19 ) // SatCom symbol?
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 224.0f / 256.0f; // SatCom symbol
uv1.y = 224.0f / 256.0f;
@@ -429,7 +429,7 @@ void CGroup::Draw()
}
if ( m_icon == 20 ) // solid blue background?
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 224.0f / 256.0f;
uv1.y = 32.0f / 256.0f;
@@ -443,7 +443,7 @@ void CGroup::Draw()
}
if ( m_icon == 21 ) // stand-by symbol?
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 160.0f / 256.0f;
uv1.y = 32.0f / 256.0f;
@@ -457,7 +457,7 @@ void CGroup::Draw()
}
if ( m_icon == 22 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f / 256.0f; // opaque yellow
uv1.y = 224.0f / 256.0f;
@@ -474,7 +474,7 @@ void CGroup::Draw()
if ( m_icon == 23 )
{
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f / 256.0f; // yellow
uv1.y = 192.0f / 256.0f;
@@ -490,7 +490,7 @@ void CGroup::Draw()
}
if ( m_icon == 24 )
{
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 80.0f / 256.0f; // orange
uv1.y = 192.0f / 256.0f;
@@ -506,7 +506,7 @@ void CGroup::Draw()
}
if ( m_icon == 25 )
{
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f / 256.0f; // orange
uv1.y = 208.0f / 256.0f;
@@ -522,7 +522,7 @@ void CGroup::Draw()
}
if ( m_icon == 26 )
{
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 80.0f / 256.0f; // red
uv1.y = 208.0f / 256.0f;
@@ -538,7 +538,7 @@ void CGroup::Draw()
}
if ( m_icon == 27 )
{
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 32.0f / 256.0f;
uv1.y = 0.0f / 256.0f;
@@ -556,7 +556,7 @@ void CGroup::Draw()
pos = m_pos;
dim = m_dim;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 32.0f / 256.0f;
uv1.y = 32.0f / 256.0f;
@@ -568,7 +568,7 @@ void CGroup::Draw()
uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2);
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
pos.x += 8.0f / 640.0f;
pos.y += 8.0f / 480.0f;
diff --git a/src/ui/image.cpp b/src/ui/image.cpp
index 8f9b5ca..bd261b3 100644
--- a/src/ui/image.cpp
+++ b/src/ui/image.cpp
@@ -110,7 +110,7 @@ void CImage::Draw()
if ( m_icon == 0 ) // hollow frame?
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 160.0f / 256.0f;
uv1.y = 192.0f / 256.0f; // u-v texture
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index aacc8d8..0b86a91 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -136,7 +136,7 @@ void CKey::Draw()
DrawShadow(m_pos, m_dim);
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); // was D3DSTATENORMAL
float zoomExt = 1.00f;
diff --git a/src/ui/list.cpp b/src/ui/list.cpp
index f6c3ed9..b5f7599 100644
--- a/src/ui/list.cpp
+++ b/src/ui/list.cpp
@@ -388,7 +388,7 @@ void CList::Draw()
if (m_icon == 0)
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f / 256.0f;
@@ -398,7 +398,7 @@ void CList::Draw()
}
else
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 132.0f / 256.0f;
@@ -434,7 +434,7 @@ void CList::Draw()
dim.y *= 0.4f;
pos.y -= dim.y;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw
uv1.x = 120.0f / 256.0f;
uv1.y = 64.0f / 256.0f;
@@ -509,7 +509,7 @@ void CList::Draw()
if ( m_check[i + m_firstLine] )
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f / 256.0f;
uv1.y = 0.0f / 256.0f;
@@ -534,7 +534,7 @@ void CList::Draw()
}
else
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw
if ( i + m_firstLine == m_selectLine )
{
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 1964531..9afad80 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -18,7 +18,6 @@
#include "ui/maindialog.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "app/system.h"
#include "common/config.h"
@@ -182,7 +181,7 @@ CMainDialog::CMainDialog()
#if DEV_BUILD
m_savegameDir = "savegame";
#else
- m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation();
+ m_savegameDir = "savegame";
#endif
m_publicDir = "program";
@@ -389,7 +388,7 @@ pb->SetState(STATE_SHADOW);
pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
- m_engine->SetBackground("interface.png",
+ m_engine->SetBackground("textures/interface/interface.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -509,7 +508,7 @@ pb->SetState(STATE_SHADOW);
UpdateNameControl();
UpdateNameFace();
- m_engine->SetBackground("interface.png",
+ m_engine->SetBackground("textures/interface/interface.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -973,7 +972,7 @@ pb->SetState(STATE_SHADOW);
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_BACK);
pb->SetState(STATE_SHADOW);
- m_engine->SetBackground("interface.png",
+ m_engine->SetBackground("textures/interface/interface.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1172,7 +1171,7 @@ pb->SetState(STATE_SHADOW);
if ( !m_bSimulSetup )
{
- m_engine->SetBackground("interface.png",
+ m_engine->SetBackground("textures/interface/interface.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1690,7 +1689,7 @@ pos.y -= 0.048f;
if ( m_phase == PHASE_READ )
{
- m_engine->SetBackground("interface.png",
+ m_engine->SetBackground("textures/interface/interface.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1740,7 +1739,7 @@ pos.y -= 0.048f;
pl->SetFontSize(12.0f);
pl->SetTextAlign(Gfx::TEXT_ALIGN_CENTER);
- m_engine->SetBackground("interface.png",
+ m_engine->SetBackground("textures/interface/interface.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1762,7 +1761,7 @@ pos.y -= 0.048f;
m_engine->SetOverColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f), Gfx::ENG_RSTATE_TCOLOR_BLACK); // TODO: color ok?
m_engine->SetOverFront(true);
- m_engine->SetBackground("ppc.png",
+ m_engine->SetBackground("textures/interface/ppc.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1781,7 +1780,7 @@ pos.y -= 0.048f;
m_engine->SetOverColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::ENG_RSTATE_TCOLOR_WHITE); // TODO: color ok?
m_engine->SetOverFront(true);
- m_engine->SetBackground("colobot.png",
+ m_engine->SetBackground("textures/interface/colobot.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1800,7 +1799,7 @@ pos.y -= 0.048f;
m_engine->SetOverColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::ENG_RSTATE_TCOLOR_WHITE); // TODO: color ok?
m_engine->SetOverFront(true);
- m_engine->SetBackground("epsitec.png",
+ m_engine->SetBackground("textures/interface/epsitec.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1925,7 +1924,7 @@ pos.y -= 0.048f;
pb->SetState(STATE_SHADOW);
// #endif
- m_engine->SetBackground("generico.png",
+ m_engine->SetBackground("textures/interface/generico.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -3589,7 +3588,6 @@ void CMainDialog::BuildSceneName(std::string &filename, char *base, int rank)
{
rankStream << std::setfill('0') << std::setw(3) << rank;
filename = base + rankStream.str() + ".txt";
- filename = CGameData::GetInstancePointer()->GetFilePath(DIR_LEVEL, filename);
}
}
diff --git a/src/ui/map.cpp b/src/ui/map.cpp
index c5f0062..1e77c08 100644
--- a/src/ui/map.cpp
+++ b/src/ui/map.cpp
@@ -322,7 +322,7 @@ void CMap::Draw()
m_offset = AdjustOffset(m_map[MAPMAXOBJECT - 1].pos);
if ( m_fixImage[0] == 0 ) { // drawing of the relief?
- m_engine->SetTexture("map.png");
+ m_engine->SetTexture("textures/interface/map.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.5f + (m_offset.x - (m_half / m_zoom)) / (m_half * 2.0f);
uv1.y = 0.5f - (m_offset.y + (m_half / m_zoom)) / (m_half * 2.0f);
@@ -469,7 +469,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
uv2.x = 126.0f/256.0f;
uv2.y = 255.0f/256.0f;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
bEnding = false;
@@ -529,7 +529,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
return; // flashes
}
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
if ( bUp )
{
@@ -672,7 +672,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
{
if ( bSelect )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
if ( m_bToy )
{
@@ -698,7 +698,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
{
if ( m_bRadar )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 64.5f/256.0f; // blue triangle
uv1.y = 240.5f/256.0f;
@@ -718,7 +718,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
if ( color == MAPCOLOR_WAYPOINTb )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 192.5f/256.0f; // blue cross
uv1.y = 240.5f/256.0f;
@@ -728,7 +728,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
}
if ( color == MAPCOLOR_WAYPOINTr )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 208.5f/256.0f; // red cross
uv1.y = 240.5f/256.0f;
@@ -738,7 +738,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
}
if ( color == MAPCOLOR_WAYPOINTg )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 224.5f/256.0f; // green cross
uv1.y = 240.5f/256.0f;
@@ -748,7 +748,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
}
if ( color == MAPCOLOR_WAYPOINTy )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 240.5f/256.0f; // yellow cross
uv1.y = 240.5f/256.0f;
@@ -758,7 +758,7 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
}
if ( color == MAPCOLOR_WAYPOINTv )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 192.5f/256.0f; // violet cross
uv1.y = 224.5f/256.0f;
@@ -779,7 +779,7 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
dp = 0.5f/256.0f;
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
if ( color == MAPCOLOR_MOVE )
{
@@ -894,7 +894,7 @@ void CMap::DrawHighlight(Math::Point pos)
dim.x *= 2.0f+cosf(m_time*8.0f)*0.5f;
dim.y *= 2.0f+cosf(m_time*8.0f)*0.5f;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 160.5f/256.0f; // hilite
uv1.y = 224.5f/256.0f;
@@ -1052,8 +1052,8 @@ void CMap::UpdateTerrain()
}
}
- m_engine->DeleteTexture("map.png");
- m_engine->LoadTexture("map.png", &img);
+ m_engine->DeleteTexture("textures/interface/map.png");
+ m_engine->LoadTexture("textures/interface/map.png", &img);
}
// Updates the field in the map.
diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp
index b3422ec..680f647 100644
--- a/src/ui/scroll.cpp
+++ b/src/ui/scroll.cpp
@@ -379,7 +379,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
if ( icon == 0 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // yellow rectangle
uv1.y = 32.0f/256.0f;
@@ -389,7 +389,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 1 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // gray rectangle
uv1.y = 32.0f/256.0f;
@@ -399,7 +399,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 2 )
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; // blue rectangle
uv1.y = 0.0f/256.0f;
@@ -409,7 +409,7 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 104.0f/256.0f; // blue line -
uv1.y = 32.0f/256.0f;
diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp
index a01864a..8971e9d 100644
--- a/src/ui/shortcut.cpp
+++ b/src/ui/shortcut.cpp
@@ -114,7 +114,7 @@ void CShortcut::Draw()
zoom = 1.0f;
}
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
if ( icon != -1 )
{
@@ -130,7 +130,7 @@ void CShortcut::Draw()
Math::Point p1, p2, c, uv1, uv2;
float dp;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
zoom = 0.9f+sinf(m_time*8.0f)*0.1f;
@@ -170,7 +170,7 @@ void CShortcut::Draw()
Math::Point uv1, uv2;
float dp;
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 160.0f/256.0f;
diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp
index 33293d1..7e41083 100644
--- a/src/ui/slider.cpp
+++ b/src/ui/slider.cpp
@@ -498,7 +498,7 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
if ( icon == 0 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // yellow rectangle
uv1.y = 32.0f/256.0f;
@@ -510,7 +510,7 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 1 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // gray rectangle
uv1.y = 32.0f/256.0f;
@@ -522,7 +522,7 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 224.0f/256.0f; // cursor
uv1.y = 32.0f/256.0f;
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index ed18ce4..70bb2d5 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -1174,7 +1174,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
if ( icon == 0 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 64.0f/256.0f; // dark blue transparent
uv1.y = 64.0f/256.0f;
@@ -1190,7 +1190,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 1 )
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // white tooltip
uv1.y = 0.0f/256.0f;
@@ -1204,7 +1204,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 2 )
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // yellow
uv1.y = 16.0f/256.0f;
@@ -1218,7 +1218,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 3 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 0.0f/256.0f; // transparent blue bar with yellow upper
uv1.y = 64.0f/256.0f;
@@ -1237,7 +1237,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.x += 100.0f/640.0f;
dim.y += 60.0f/480.0f;
- m_engine->SetTexture("human.png");
+ m_engine->SetTexture("textures/interface/human.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 140.0f/256.0f;
uv1.y = 32.0f/256.0f;
@@ -1254,7 +1254,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.x -= 20.0f/640.0f;
dim.y += 0.0f/480.0f;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 192.0f/256.0f;
uv1.y = 32.0f/256.0f;
@@ -1273,7 +1273,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.x -= 20.0f/640.0f;
dim.y -= 20.0f/480.0f;
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f;
uv1.y = 0.0f/256.0f;
@@ -1309,7 +1309,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.x -= 20.0f/640.0f;
dim.y -= 20.0f/480.0f;
- m_engine->SetTexture("button3.png");
+ m_engine->SetTexture("textures/interface/button3.png");
uv1.x = 0.0f/256.0f;
uv1.y = 224.0f/256.0f;
uv2.x = 32.0f/256.0f;
@@ -1320,7 +1320,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2); // dark blue background
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
uv1.x = 224.0f/256.0f;
uv1.y = 224.0f/256.0f;
uv2.x = 249.0f/256.0f;
@@ -1392,7 +1392,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 5 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent green
uv1.y = 160.0f/256.0f;
@@ -1406,7 +1406,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 6 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent red
uv1.y = 176.0f/256.0f;
@@ -1420,7 +1420,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 7 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent blue
uv1.y = 192.0f/256.0f;
@@ -1434,7 +1434,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 8 )
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // opaque orange
uv1.y = 0.0f/256.0f;
@@ -1450,7 +1450,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 9 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 32.0f/256.0f; // opaque gray
uv1.y = 32.0f/256.0f;
@@ -1470,7 +1470,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 11 )
{
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent yellow
uv1.y = 224.0f/256.0f;
@@ -1484,7 +1484,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 12 )
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // dirty opaque gray
uv1.y = 128.0f/256.0f;
@@ -1500,7 +1500,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 13 )
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 192.0f/256.0f; // dirty opaque blue
uv1.y = 128.0f/256.0f;
@@ -1516,7 +1516,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 14 )
{
- m_engine->SetTexture("button1.png");
+ m_engine->SetTexture("textures/interface/button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 160.0f/256.0f; // dirty opaque red
uv1.y = 128.0f/256.0f;
@@ -1544,7 +1544,7 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim)
dp = 0.5f/256.0f;
- m_engine->SetTexture("button2.png");
+ m_engine->SetTexture("textures/interface/button2.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; // hatching
uv1.y = 208.0f/256.0f;