From f2faa34bd941ba5805ebd1b33df504b86bb368ed Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sun, 3 Apr 2011 19:37:53 +0200 Subject: [PATCH 1/7] If there is an openmw.cfg in the current path, use it as global config --- apps/openmw/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 4d7e6595cc..64450157d3 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -59,7 +59,13 @@ 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 = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", "openmw.cfg"); + } std::cout << "Using global config file: " << cfgFile << std::endl; std::ifstream globalConfigFile(cfgFile.c_str()); From 0c4e9d92070c606ce0906572d6783973f286a55a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 24 Apr 2011 12:39:50 +0200 Subject: [PATCH 2/7] create local openmw.cfg file for uninstalled version --- CMakeLists.txt | 6 +++++- files/openmw.cfg.local | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 files/openmw.cfg.local diff --git a/CMakeLists.txt b/CMakeLists.txt index 22ba839b2c..3273ccef81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -336,6 +336,10 @@ endif (APPLE) # Other files +configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local + "${OpenMW_BINARY_DIR}/openmw.cfg" COPYONLY) + + if (WIN32) configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32 "${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY) @@ -424,7 +428,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_SOURCE_DIR}/openmw.cfg" DESTINATION "../etc/openmw/" 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/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 From 573090a07fb747f7a7399c0c305b3fabcb9aa3a4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 24 Apr 2011 12:41:55 +0200 Subject: [PATCH 3/7] improved description of openmw.cfg related cmake-variable --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3273ccef81..8de24f57f8 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) From 042c179ce792f001f7e3d55b9a1b5b104c2c31bd Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 28 Apr 2011 09:30:45 +0200 Subject: [PATCH 4/7] fixed the openmw.cfg install problem (I hope) --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8de24f57f8..949a6e5226 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,8 +337,9 @@ endif (APPLE) # Other files configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local - "${OpenMW_BINARY_DIR}/openmw.cfg" COPYONLY) - + "${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 @@ -428,7 +429,7 @@ if(DPKG_PROGRAM) endif() #Install global configuration files - INSTALL(FILES "${OpenMW_SOURCE_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 From 7131c08ca499d9718bfb916c9f4a72582c4073e2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 28 Apr 2011 09:39:40 +0200 Subject: [PATCH 5/7] moved path.hpp/path.cpp to a new component --- CMakeLists.txt | 12 ++++++++++-- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/engine.cpp | 3 ++- apps/openmw/main.cpp | 3 ++- {apps/openmw => components/files}/path.cpp | 0 {apps/openmw => components/files}/path.hpp | 0 6 files changed, 15 insertions(+), 5 deletions(-) rename {apps/openmw => components/files}/path.cpp (100%) rename {apps/openmw => components/files}/path.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 949a6e5226..7d02e50f48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 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..39ab430087 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" diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 7ba3fb4d6e..7546276028 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 diff --git a/apps/openmw/path.cpp b/components/files/path.cpp similarity index 100% rename from apps/openmw/path.cpp rename to components/files/path.cpp diff --git a/apps/openmw/path.hpp b/components/files/path.hpp similarity index 100% rename from apps/openmw/path.hpp rename to components/files/path.hpp From bdfd28f44d052905b05492262303c619c3c3b0cf Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 28 Apr 2011 09:56:50 +0200 Subject: [PATCH 6/7] adjusted components/files namespace; some related cleanup --- apps/openmw/engine.cpp | 6 ++---- apps/openmw/main.cpp | 4 ++-- components/files/path.cpp | 15 ++++++++++----- components/files/path.hpp | 26 +++++++++----------------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 39ab430087..c6b57efc02 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -323,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_ConfigUser, "openmw", ""); + std::string cfgUserDir = Files::getPath (Files::Path_ConfigGlobal, "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 7546276028..c5f53d7b56 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -79,12 +79,12 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) std::string cfgFile = "openmw.cfg"; if(!isFile(cfgFile.c_str())) { - cfgFile = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", "openmw.cfg"); + 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/components/files/path.cpp b/components/files/path.cpp index e7dbc04715..a7b66822fd 100644 --- a/components/files/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 index 84ff9ecab3..a426464040 100644 --- a/components/files/path.hpp +++ b/components/files/path.hpp @@ -1,25 +1,17 @@ -#ifndef PATH__HPP -#define PATH__HPP +#ifndef COMPONENTS_FILES_PATH_HPP +#define COMPONENTS_FILES_PATH_HPP -#include #include -#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE -#include -#endif - -namespace OMW +namespace Files { - class Path + enum PathTypeEnum { - public: - enum PathTypeEnum - { - USER_CFG_PATH, - GLOBAL_CFG_PATH - }; - - static std::string getPath(PathTypeEnum parType, const std::string parApp, const std::string parFile); + Path_ConfigUser, + Path_ConfigGlobal }; + + std::string getPath (PathTypeEnum parType, const std::string parApp, const std::string parFile); } + #endif From 8b9ee30924663155c2e87290bd80a4df102cebc7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 28 Apr 2011 10:15:04 +0200 Subject: [PATCH 7/7] user/global mixup --- apps/openmw/engine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index c6b57efc02..047bc3751d 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -325,8 +325,8 @@ void OMW::Engine::go() std::cout << "Data directory: " << mDataDir << "\n"; - std::string cfgDir = Files::getPath (Files::Path_ConfigUser, "openmw", ""); - std::string cfgUserDir = Files::getPath (Files::Path_ConfigGlobal, "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);