X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FGUI%2FCocoaHelpers.mm;h=493e9458f6749c53c2aab5f4461ecebed24f353d;hb=5e4f212b846cd3eb4ce56a2823a9191d221d487c;hp=6ea15e2d5a52f58d97957aba1e2bfcb1f8cb74dc;hpb=fecb475145ba5b733f273354154beb59e4e94fe6;p=flightgear.git diff --git a/src/GUI/CocoaHelpers.mm b/src/GUI/CocoaHelpers.mm index 6ea15e2d5..493e9458f 100644 --- a/src/GUI/CocoaHelpers.mm +++ b/src/GUI/CocoaHelpers.mm @@ -24,14 +24,21 @@ #include // OS -#include + #include +#include +#include +#include +#include +#include // simgear #include // flightgear #include +#include
+#include
NSString* stdStringToCocoa(const std::string& s) { @@ -122,3 +129,39 @@ SGPath platformDefaultDataPath() appData.append("FlightGear"); return appData; } + +namespace flightgear +{ + +std::string Options::platformDefaultRoot() const +{ + CocoaAutoreleasePool ap; + + NSURL* url = [[NSBundle mainBundle] resourceURL]; + SGPath dataDir(URLToPath(url)); + dataDir.append("data"); + return dataDir.str(); +} + +} // of namespace flightgear + +string_list FGLocale::getUserLanguage() +{ + CocoaAutoreleasePool ap; + string_list result; + + for (NSString* lang in [NSLocale preferredLanguages]) { + result.push_back(stdStringFromCocoa(lang)); + } + + return result; +} + +void transformToForegroundApp() +{ + ProcessSerialNumber sn = { 0, kCurrentProcess }; + TransformProcessType(&sn,kProcessTransformToForegroundApplication); + + + [[NSApplication sharedApplication] activateIgnoringOtherApps: YES]; +}