aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorVincent Bénony2015-12-11 14:24:29 +0100
committerVincent Bénony2016-01-06 16:17:38 +0100
commitc99456ecff9ae645385ea5a8aa423d0115dce08e (patch)
tree7e1e06045bf88f054d7521655d12ee12ede76a64 /backends/platform
parent8d9b13059b82ea4b8a38203c34c4939abc0feb25 (diff)
downloadscummvm-rg350-c99456ecff9ae645385ea5a8aa423d0115dce08e.tar.gz
scummvm-rg350-c99456ecff9ae645385ea5a8aa423d0115dce08e.tar.bz2
scummvm-rg350-c99456ecff9ae645385ea5a8aa423d0115dce08e.zip
IOS: Brings support for FluidSynth
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/ios7/ios7_osys_main.cpp15
-rw-r--r--backends/platform/ios7/ios7_osys_main.h5
-rw-r--r--backends/platform/ios7/ios7_osys_video.mm32
3 files changed, 48 insertions, 4 deletions
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 76739423c1..cb712b9c38 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <pthread.h>
+#include <string.h>
#include <sys/time.h>
@@ -80,7 +81,7 @@ OSystem_iOS7::OSystem_iOS7() :
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0),
- _mouseCursorPaletteEnabled(false), _gfxTransactionError(kTransactionSuccess) {
+ _lastErrorMessage(NULL), _mouseCursorPaletteEnabled(false), _gfxTransactionError(kTransactionSuccess) {
_queuedInputEvent.type = Common::EVENT_INVALID;
_touchpadModeEnabled = !iOS7_isBigDevice();
#ifdef IPHONE_OFFICIAL
@@ -275,8 +276,9 @@ Audio::Mixer *OSystem_iOS7::getMixer() {
return _mixer;
}
-OSystem *OSystem_iOS7_create() {
- return new OSystem_iOS7();
+OSystem_iOS7 *OSystem_iOS7::sharedInstance() {
+ static OSystem_iOS7 *instance = new OSystem_iOS7();
+ return instance;
}
Common::String OSystem_iOS7::getDefaultConfigFileName() {
@@ -318,6 +320,11 @@ void OSystem_iOS7::logMessage(LogMessageType::Type type, const char *message) {
else
output = stderr;
+ if (type == LogMessageType::kError) {
+ free(_lastErrorMessage);
+ _lastErrorMessage = strdup(message);
+ }
+
fputs(message, output);
fflush(output);
}
@@ -353,7 +360,7 @@ void iOS7_main(int argc, char **argv) {
chdir("/var/mobile/");
#endif
- g_system = OSystem_iOS7_create();
+ g_system = OSystem_iOS7::sharedInstance();
assert(g_system);
// Invoke the actual ScummVM main entry point:
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index 26b147e2a1..eadb49e5ac 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -109,11 +109,15 @@ protected:
bool _fullScreenOverlayIsDirty;
int _screenChangeCount;
+ char *_lastErrorMessage;
+
public:
OSystem_iOS7();
virtual ~OSystem_iOS7();
+ static OSystem_iOS7 *sharedInstance();
+
virtual void initBackend();
virtual bool hasFeature(Feature f);
@@ -192,6 +196,7 @@ public:
virtual Common::String getDefaultConfigFileName();
virtual void logMessage(LogMessageType::Type type, const char *message);
+ virtual void fatalError() override;
protected:
void initVideoContext();
diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm
index 7cce56c800..0d183ce834 100644
--- a/backends/platform/ios7/ios7_osys_video.mm
+++ b/backends/platform/ios7/ios7_osys_video.mm
@@ -29,6 +29,38 @@
#include "graphics/conversion.h"
#import "iOS7AppDelegate.h"
+@interface iOS7AlertHandler : NSObject<UIAlertViewDelegate>
+@end
+
+@implementation iOS7AlertHandler
+
+- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
+ OSystem_iOS7::sharedInstance()->quit();
+ exit(1);
+}
+
+@end
+
+static void displayAlert(void *ctx) {
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Fatal Error"
+ message:[NSString stringWithCString:(const char *)ctx encoding:NSUTF8StringEncoding]
+ delegate:[[iOS7AlertHandler alloc] init]
+ cancelButtonTitle:@"OK"
+ otherButtonTitles:nil];
+ [alert show];
+ [alert autorelease];
+}
+
+void OSystem_iOS7::fatalError() {
+ if (_lastErrorMessage) {
+ dispatch_async_f(dispatch_get_main_queue(), _lastErrorMessage, displayAlert);
+ for(;;);
+ }
+ else {
+ OSystem::fatalError();
+ }
+}
+
void OSystem_iOS7::initVideoContext() {
_videoContext = [[iOS7AppDelegate iPhoneView] getVideoContext];
}