mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Mac Build - Fix bundle directory location
This commit is contained in:
parent
3bb9d06e58
commit
9c6fcc7be5
@ -56,7 +56,12 @@ void OMW::Engine::addResourcesDirectory (const boost::filesystem::path& path)
|
|||||||
|
|
||||||
void OMW::Engine::setDataDir (const boost::filesystem::path& dataDir)
|
void OMW::Engine::setDataDir (const boost::filesystem::path& dataDir)
|
||||||
{
|
{
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
mDataDir = boost::filesystem::system_complete (macBundlePath() + "/Contents/MacOS/" + dataDir.directory_string());
|
||||||
|
#else
|
||||||
mDataDir = boost::filesystem::system_complete (dataDir);
|
mDataDir = boost::filesystem::system_complete (dataDir);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set start cell name (only interiors for now)
|
// Set start cell name (only interiors for now)
|
||||||
@ -90,9 +95,16 @@ void OMW::Engine::go()
|
|||||||
|
|
||||||
std::cout << "Initializing OGRE\n";
|
std::cout << "Initializing OGRE\n";
|
||||||
|
|
||||||
const char* plugCfg = "plugins.cfg";
|
std::string plugin_cfg_location = "plugins.cfg";
|
||||||
|
std::string ogre_cfg_location = "ogre.cfg";
|
||||||
|
|
||||||
mOgre.configure(!isFile("ogre.cfg"), plugCfg, false);
|
#ifdef OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
std::cout << "[Apple]" << std::endl;
|
||||||
|
plugin_cfg_location = macBundlePath() + "/Contents/MacOS/" + plugin_cfg_location;
|
||||||
|
ogre_cfg_location = macBundlePath() + "/Contents/MacOS/" + ogre_cfg_location;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mOgre.configure(!isFile(ogre_cfg_location.c_str()), plugin_cfg_location.c_str(), false);
|
||||||
|
|
||||||
addResourcesDirectory (mDataDir / "Meshes");
|
addResourcesDirectory (mDataDir / "Meshes");
|
||||||
addResourcesDirectory (mDataDir / "Textures");
|
addResourcesDirectory (mDataDir / "Textures");
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
|
#include "tools/fileops.hpp"
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -30,18 +31,18 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
|||||||
|
|
||||||
boost::program_options::variables_map variables;
|
boost::program_options::variables_map variables;
|
||||||
|
|
||||||
std::ifstream configFile ("openmw.cfg");
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
std::string configFilePath(macBundlePath() + "/Contents/MacOS/openmw.cfg");
|
||||||
|
std::ifstream configFile (configFilePath.c_str());
|
||||||
|
#else
|
||||||
|
std::ifstream configFile ("openmw.cfg");
|
||||||
|
#endif
|
||||||
|
|
||||||
boost::program_options::parsed_options valid_opts =
|
boost::program_options::parsed_options valid_opts =
|
||||||
boost::program_options::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
|
boost::program_options::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
|
||||||
|
|
||||||
boost::program_options::store(valid_opts, variables);
|
boost::program_options::store(valid_opts, variables);
|
||||||
boost::program_options::notify(variables);
|
boost::program_options::notify(variables);
|
||||||
/*
|
|
||||||
boost::program_options::store (
|
|
||||||
boost::program_options::parse_command_line (argc, argv, desc), variables);
|
|
||||||
boost::program_options::notify (variables);
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (configFile.is_open())
|
if (configFile.is_open())
|
||||||
boost::program_options::store (
|
boost::program_options::store (
|
||||||
|
@ -1,8 +1,34 @@
|
|||||||
#include "fileops.hpp"
|
#include "fileops.hpp"
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
bool isFile(const char *name)
|
bool isFile(const char *name)
|
||||||
{
|
{
|
||||||
boost::filesystem::path cfg_file_path(name);
|
boost::filesystem::path cfg_file_path(name);
|
||||||
return boost::filesystem::exists(cfg_file_path);
|
return boost::filesystem::exists(cfg_file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
|
||||||
|
std::string macBundlePath()
|
||||||
|
{
|
||||||
|
char path[1024];
|
||||||
|
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||||
|
assert(mainBundle);
|
||||||
|
|
||||||
|
CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
|
||||||
|
assert(mainBundleURL);
|
||||||
|
|
||||||
|
CFStringRef cfStringRef = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
|
||||||
|
assert(cfStringRef);
|
||||||
|
|
||||||
|
CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
|
||||||
|
|
||||||
|
CFRelease(mainBundleURL);
|
||||||
|
CFRelease(cfStringRef);
|
||||||
|
|
||||||
|
return std::string(path);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
#ifndef __FILEOPS_H_
|
#ifndef __FILEOPS_H_
|
||||||
#define __FILEOPS_H_
|
#define __FILEOPS_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
/// Check if a given path is an existing file (not a directory)
|
/// Check if a given path is an existing file (not a directory)
|
||||||
bool isFile(const char *name);
|
bool isFile(const char *name);
|
||||||
|
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
std::string macBundlePath();
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user