cmake build system + OS X support / cleanups for Humble Release #8

Merged
urkle merged 25 commits from OSX into boost 2014-01-01 23:13:17 +00:00
2 changed files with 27 additions and 21 deletions
Showing only changes of commit a18497ca7b - Show all commits

View File

@ -21,11 +21,10 @@
#include "config.h" #include "config.h"
#include <SDL2/SDL_filesystem.h>
#include <boost/program_options/options_description.hpp> #include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp> #include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp> #include <boost/program_options/variables_map.hpp>
#include <fstream> #include <fstream>
#include "debugwriter.h" #include "debugwriter.h"
@ -48,13 +47,7 @@ Config::Config()
solidFonts(false), solidFonts(false),
gameFolder("."), gameFolder("."),
allowSymlinks(false) allowSymlinks(false)
{ { }
char *dataDir = SDL_GetBasePath();
if (dataDir) {
gameFolder = dataDir;
SDL_free(dataDir);
}
}
void Config::read() void Config::read()
{ {
@ -74,6 +67,9 @@ void Config::read()
PO_DESC(allowSymlinks, bool) \ PO_DESC(allowSymlinks, bool) \
PO_DESC(customScript, std::string) PO_DESC(customScript, std::string)
// Not gonna take your shit boost
#define GUARD_ALL( exp ) try { exp } catch(...) {}
#define PO_DESC(key, type) (#key, po::value< type >()->default_value(key)) #define PO_DESC(key, type) (#key, po::value< type >()->default_value(key))
po::options_description podesc; po::options_description podesc;
@ -86,13 +82,14 @@ void Config::read()
confFile.open("mkxp.conf"); confFile.open("mkxp.conf");
po::variables_map vm; po::variables_map vm;
po::store(po::parse_config_file(confFile, podesc, true), vm);
po::notify(vm); if (confFile) {
GUARD_ALL( po::store(po::parse_config_file(confFile, podesc, true), vm); )
po::notify(vm);
}
confFile.close(); confFile.close();
// Not gonna take your shit boost
#define GUARD_ALL( exp ) try { exp } catch(...) {}
#undef PO_DESC #undef PO_DESC
#define PO_DESC(key, type) GUARD_ALL( key = vm[#key].as< type >(); ) #define PO_DESC(key, type) GUARD_ALL( key = vm[#key].as< type >(); )
@ -128,7 +125,7 @@ void Config::readGameINI()
iniFile.open((iniPath).c_str()); iniFile.open((iniPath).c_str());
po::variables_map vm; po::variables_map vm;
po::store(po::parse_config_file(iniFile, podesc, true), vm); GUARD_ALL( po::store(po::parse_config_file(iniFile, podesc, true), vm); )
po::notify(vm); po::notify(vm);
iniFile.close(); iniFile.close();

View File

@ -232,11 +232,7 @@ int rgssThreadFun(void *userdata)
int main(int, char *argv[]) int main(int, char *argv[])
{ {
Config conf; // initialize SDL first
conf.read();
conf.readGameINI();
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
{ {
Debug() << "Error initializing SDL:" << SDL_GetError(); Debug() << "Error initializing SDL:" << SDL_GetError();
@ -244,6 +240,19 @@ int main(int, char *argv[])
return 0; return 0;
} }
// set working directory
char *dataDir = SDL_GetBasePath();
if (dataDir) {
chdir(dataDir);
SDL_free(dataDir);
}
// now we load the config
Config conf;
conf.read();
conf.readGameINI();
int imgFlags = IMG_INIT_PNG | IMG_INIT_JPG; int imgFlags = IMG_INIT_PNG | IMG_INIT_JPG;
if (IMG_Init(imgFlags) != imgFlags) if (IMG_Init(imgFlags) != imgFlags)
{ {