diff --git a/src/config.mm b/src/config.mm
index 88d74243..2af3d460 100644
--- a/src/config.mm
+++ b/src/config.mm
@@ -127,13 +127,12 @@ void Config::read(int argc, char *argv[])
OFEnumerator* e = [confData keyEnumerator];
for (id key = [e nextObject]; key != nil; key = [e nextObject])
- {
- Debug() << [[key description] UTF8String] << [[key className] UTF8String];
+ {
opts[key] = confData[key];
}
}
@catch(OFException *e){
- Debug() << [[e description] UTF8String];
+ Debug() << "OBJC:" << [[e description] UTF8String];
}
}
#define SET_OPT_CUSTOMKEY(var, key, type) GUARD( var = [opts[@#key] type]; )
@@ -231,41 +230,6 @@ void Config::readGameINI()
}
-/*
- std::string iniFilename = execName + ".ini";
- SDLRWStream iniFile(iniFilename.c_str(), "r");
-
- if (iniFile)
- {
- INIConfiguration ic;
- if(ic.load(iniFile.stream()))
- {
- GUARD_ALL( game.title = ic.getStringProperty("Game", "Title"); );
- GUARD_ALL( game.scripts = ic.getStringProperty("Game", "Scripts"); );
-
- strReplace(game.scripts, '\\', '/');
-
- if (game.title.empty())
- {
- Debug() << iniFilename + ": Could not find Game.Title property";
- }
-
- if (game.scripts.empty())
- {
- Debug() << iniFilename + ": Could not find Game.Scripts property";
- }
- }
- else
- {
- Debug() << iniFilename + ": Failed to parse ini file";
- }
- }
- else
- {
- Debug() << "FAILED to open" << iniFilename;
- }
-*/
-
if (game.title.empty())
{
game.title = "mkxp-z";
diff --git a/src/main.cpp b/src/main.mm
similarity index 92%
rename from src/main.cpp
rename to src/main.mm
index e5d790b3..94f0308b 100644
--- a/src/main.cpp
+++ b/src/main.mm
@@ -19,33 +19,35 @@
** along with mkxp. If not, see .
*/
-#include
+#import
-#include
-#include
-#include
-#include
+#import
+#import
+#import
+#import
-#include
-#include
-#include
-#include
+#import
+#import
+#import
+#import
-#include "sharedstate.h"
-#include "eventthread.h"
-#include "gl-debug.h"
-#include "debugwriter.h"
-#include "exception.h"
-#include "gl-fun.h"
+#import "sharedstate.h"
+#import "eventthread.h"
+#import "gl-debug.h"
+#import "debugwriter.h"
+#import "exception.h"
+#import "gl-fun.h"
-#include "binding.h"
+#import "binding.h"
#ifdef __WINDOWS__
-#include "resource.h"
-#include
+#import "resource.h"
+#import
#endif
-#include "icon.png.xxd"
+#import
+
+#import "icon.png.xxd"
#ifdef __APPLE__
#define GLINIT_SHOWERROR(s) showInitError(s)
@@ -112,8 +114,10 @@ int rgssThreadFun(void *userdata)
return 0;
}
- /* Start script execution */
- scriptBinding->execute();
+ @autoreleasepool{
+ /* Start script execution */
+ scriptBinding->execute();
+ }
threadData->rqTermAck.set();
threadData->ethread->requestTerminate();
@@ -161,7 +165,7 @@ static void setupWindowIcon(const Config &conf, SDL_Window *win)
}
int main(int argc, char *argv[])
-{
+{@autoreleasepool{
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
@@ -195,6 +199,8 @@ int main(int argc, char *argv[])
#endif
#endif
*/
+
+ OFFileManager* fm = [OFFileManager defaultManager];
#ifndef WORKDIR_CURRENT
char dataDir[512]{};
@@ -215,7 +221,7 @@ int main(int argc, char *argv[])
SDL_free(tmp);
}
}
- chdir(dataDir);
+ @try{[fm changeCurrentDirectoryPath:[OFString stringWithUTF8String:dataDir]];}@catch(...){}
#endif
/* now we load the config */
@@ -223,11 +229,15 @@ int main(int argc, char *argv[])
conf.read(argc, argv);
if (!conf.gameFolder.empty())
- if (chdir(conf.gameFolder.c_str()) != 0)
- {
+ {
+ @try{
+ [fm changeCurrentDirectoryPath:[OFString stringWithUTF8String:conf.gameFolder.c_str()]];
+ }
+ @catch(...){
showInitError(std::string("Unable to switch into gameFolder ") + conf.gameFolder);
return 0;
}
+ }
conf.readGameINI();
@@ -399,7 +409,7 @@ int main(int argc, char *argv[])
SDL_Quit();
return 0;
-}
+}}
static SDL_GLContext initGL(SDL_Window* win, Config& conf, RGSSThreadData* threadData)
{
@@ -445,4 +455,4 @@ static SDL_GLContext initGL(SDL_Window* win, Config& conf, RGSSThreadData* threa
//GLDebugLogger dLogger;
return glCtx;
-}
+}
\ No newline at end of file
diff --git a/src/meson.build b/src/meson.build
index 1511e9a5..60c621a4 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -38,7 +38,7 @@ if get_option('cjk_fallback_font') == true
endif
main_source = files(
- 'main.cpp',
+ 'main.mm',
'audio.cpp',
'bitmap.cpp',
'eventthread.cpp',