diff --git a/CMakeLists.txt b/CMakeLists.txt index 22ba839b2c..7d02e50f48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,15 +14,15 @@ find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems") # Location of morrowind data files if(DPKG_PROGRAM) set(MORROWIND_DATA_FILES "/usr/share/games/openmw/data/" CACHE PATH "location of Morrowind data files") - set(MORROWIND_RESOURCE_FILES "/usr/share/games/openmw/resources/" CACHE PATH "location of Morrowind data files") + set(MORROWIND_RESOURCE_FILES "/usr/share/games/openmw/resources/" CACHE PATH "location of OpenMW resources files") else() if (APPLE) # set path inside bundle set(MORROWIND_DATA_FILES "../data" CACHE PATH "location of Morrowind data files") - set(MORROWIND_RESOURCE_FILES "Contents/Resources/resources" CACHE PATH "location of Morrowind data files") + set(MORROWIND_RESOURCE_FILES "Contents/Resources/resources" CACHE PATH "location of OpenMW resources files") else() set(MORROWIND_DATA_FILES "data" CACHE PATH "location of Morrowind data files") - set(MORROWIND_RESOURCE_FILES "resources" CACHE PATH "location of Morrowind data files") + set(MORROWIND_RESOURCE_FILES "resources" CACHE PATH "location of OpenMW resources files") endif(APPLE) endif(DPKG_PROGRAM) @@ -181,6 +181,14 @@ set(MISC_HEADER ${COMP_DIR}/misc/stringops.hpp) source_group(components\\misc FILES ${MISC} ${MISC_HEADER}) +set(FILES + ${COMP_DIR}/files/path.cpp + ) +set(FILES_HEADER + ${COMP_DIR}/files/path.hpp + ) +source_group(components\\files FILES ${FILES} ${FILES_HEADER}) + file(GLOB COMPILER ${COMP_DIR}/compiler/*.cpp) file(GLOB COMPILER_HEADER ${COMP_DIR}/compiler/*.hpp) source_group(components\\compiler FILES ${COMPILER} ${COMPILER_HEADER}) @@ -190,10 +198,10 @@ file(GLOB INTERPRETER_HEADER ${COMP_DIR}/interpreter/*.hpp) source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER}) set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC} ${TO_UTF8} - ${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET}) + ${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET} ${FILES}) set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER} ${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} ${TO_UTF8_HEADER} - ${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER}) + ${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER} ${FILES_HEADER}) # source directory: libs @@ -336,6 +344,11 @@ endif (APPLE) # Other files +configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local + "${OpenMW_BINARY_DIR}/openmw.cfg") +configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg + "${OpenMW_BINARY_DIR}/openmw.cfg.install") + if (WIN32) configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32 "${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY) @@ -424,7 +437,7 @@ if(DPKG_PROGRAM) endif() #Install global configuration files - INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") + INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "../etc/openmw/" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") #Install resources diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 0fa027f0c6..9bc27b16dd 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -5,7 +5,7 @@ project(OpenMW) set(GAME main.cpp engine.cpp - path.cpp) + ) set(GAME_HEADER engine.hpp) source_group(game FILES ${GAME} ${GAME_HEADER}) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 78ddffbe8c..047bc3751d 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -14,6 +14,8 @@ #include #include #include +#include + #include #include "mwgui/window_manager.hpp" @@ -47,7 +49,6 @@ #include #include "mwgui/class.hpp" -#include "path.hpp" #include "components/nifbullet/bullet_nif_loader.hpp" @@ -322,12 +323,10 @@ void OMW::Engine::go() test.name = ""; total = 0; - - std::cout << "Data directory: " << mDataDir << "\n"; - std::string cfgDir = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", ""); - std::string cfgUserDir = OMW::Path::getPath(OMW::Path::USER_CFG_PATH, "openmw", ""); + std::string cfgDir = Files::getPath (Files::Path_ConfigGlobal, "openmw", ""); + std::string cfgUserDir = Files::getPath (Files::Path_ConfigUser, "openmw", ""); std::string plugCfg = "plugins.cfg"; std::string ogreCfg = "ogre.cfg"; ogreCfg.insert(0, cfgUserDir); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index f6f0235920..c5f53d7b56 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -6,8 +6,9 @@ #include #include +#include + #include "engine.hpp" -#include "path.hpp" #if defined(_WIN32) && !defined(_CONSOLE) #include @@ -73,11 +74,17 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) bpo::variables_map variables; - std::string cfgFile = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", "openmw.cfg"); + //If there is an openmw.cfg in the current path use that as global config + //Otherwise try getPath + std::string cfgFile = "openmw.cfg"; + if(!isFile(cfgFile.c_str())) + { + cfgFile = Files::getPath (Files::Path_ConfigGlobal, "openmw", "openmw.cfg"); + } std::cout << "Using global config file: " << cfgFile << std::endl; std::ifstream globalConfigFile(cfgFile.c_str()); - cfgFile = OMW::Path::getPath(OMW::Path::USER_CFG_PATH, "openmw", "openmw.cfg"); + cfgFile = Files::getPath (Files::Path_ConfigUser, "openmw", "openmw.cfg"); std::cout << "Using user config file: " << cfgFile << std::endl; std::ifstream userConfigFile(cfgFile.c_str()); diff --git a/apps/openmw/path.hpp b/apps/openmw/path.hpp deleted file mode 100644 index 84ff9ecab3..0000000000 --- a/apps/openmw/path.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef PATH__HPP -#define PATH__HPP - -#include -#include - -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE -#include -#endif - -namespace OMW -{ - class Path - { - public: - enum PathTypeEnum - { - USER_CFG_PATH, - GLOBAL_CFG_PATH - }; - - static std::string getPath(PathTypeEnum parType, const std::string parApp, const std::string parFile); - }; -} -#endif diff --git a/apps/openmw/path.cpp b/components/files/path.cpp similarity index 82% rename from apps/openmw/path.cpp rename to components/files/path.cpp index e7dbc04715..a7b66822fd 100644 --- a/apps/openmw/path.cpp +++ b/components/files/path.cpp @@ -2,15 +2,21 @@ #include +#include +#include + +#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE +#include +#endif + #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX #include //getenv #endif - -std::string OMW::Path::getPath(PathTypeEnum parType, const std::string parApp, const std::string parFile) +std::string Files::getPath (PathTypeEnum parType, const std::string parApp, const std::string parFile) { std::string theBasePath; - if(parType == GLOBAL_CFG_PATH) + if (parType==Path_ConfigGlobal) { #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE theBasePath = Ogre::macBundlePath() + "/Contents/MacOS/"; //FIXME do we have global/local with OSX? @@ -21,7 +27,7 @@ std::string OMW::Path::getPath(PathTypeEnum parType, const std::string parApp, c #endif } - else + else if (parType==Path_ConfigUser) { #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE theBasePath = Ogre::macBundlePath() + "/Contents/MacOS/"; //FIXME do we have global/local with OSX? @@ -53,4 +59,3 @@ std::string OMW::Path::getPath(PathTypeEnum parType, const std::string parApp, c theBasePath.append(parFile); return theBasePath; } - diff --git a/components/files/path.hpp b/components/files/path.hpp new file mode 100644 index 0000000000..a426464040 --- /dev/null +++ b/components/files/path.hpp @@ -0,0 +1,17 @@ +#ifndef COMPONENTS_FILES_PATH_HPP +#define COMPONENTS_FILES_PATH_HPP + +#include + +namespace Files +{ + enum PathTypeEnum + { + Path_ConfigUser, + Path_ConfigGlobal + }; + + std::string getPath (PathTypeEnum parType, const std::string parApp, const std::string parFile); +} + +#endif diff --git a/files/openmw.cfg.local b/files/openmw.cfg.local new file mode 100644 index 0000000000..dd116e1080 --- /dev/null +++ b/files/openmw.cfg.local @@ -0,0 +1,2 @@ +data=./data +resources=./resources