add two preferences for enabling/disabling blurry land and multitasking
authorkoda
Thu, 16 Dec 2010 01:45:15 +0100
changeset 4540 9b614e420de5
parent 4539 bad3411cba49
child 4541 c77c4f5d49d3
add two preferences for enabling/disabling blurry land and multitasking
project_files/HedgewarsMobile/Classes/GameSetup.m
project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m
project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m
project_files/HedgewarsMobile/Resources/Settings/settings.plist
--- a/project_files/HedgewarsMobile/Classes/GameSetup.m	Thu Dec 16 00:48:32 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameSetup.m	Thu Dec 16 01:45:15 2010 +0100
@@ -570,19 +570,19 @@
     NSString *verticalSize = [[NSString alloc] initWithFormat:@"%d", height];
     const char **gameArgs = (const char**) malloc(sizeof(char *) * 10);
     NSInteger tmpQuality;
+    BOOL enhanced = [[self.systemSettings objectForKey:@"enhanced"] boolValue];
 
     NSString *modelId = modelType();
-    if ([modelId hasPrefix:@"iPhone1"] ||                                   // = iPhone or iPhone 3G
-        [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])   // = iPod Touch or iPod Touch 2G
-        tmpQuality = 0x00000001 | 0x00000002 | 0x00000008 | 0x00000040;  // rqLowRes | rqBlurryLand | rqSimpleRope | rqKillFlakes
-    else if ([modelId hasPrefix:@"iPhone2"] ||                              // = iPhone 3GS
-             [modelId hasPrefix:@"iPod3"])                                  // = iPod Touch 3G
-            tmpQuality = 0x00000002 | 0x00000040;           // rqBlurryLand | rqKillFlakes
-        else if ([modelId hasPrefix:@"iPad1"])                              // = iPad
-                tmpQuality = 0x00000002;                    // rqBlurryLand
-            else                                                            // = everything else
-                tmpQuality = 0;                             // full quality
-    if (IS_IPAD() == NO)             // = disable tooltips on phone
+    if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])     // = iPhone and iPhone 3G or iPod Touch or iPod Touch 2G
+        tmpQuality = 0x00000001 | 0x00000002 | 0x00000008 | 0x00000040;                 // rqLowRes | rqBlurryLand | rqSimpleRope | rqKillFlakes
+    else if ([modelId hasPrefix:@"iPhone2"] || [modelId hasPrefix:@"iPod3"])                                    // = iPhone 3GS or iPod Touch 3G
+        tmpQuality = 0x00000002 | 0x00000040;                                           // rqBlurryLand | rqKillFlakes
+    else if ([modelId hasPrefix:@"iPad1"] || enhanced == NO)                                                    // = iPad 1G or not enhanced mode
+        tmpQuality = 0x00000002;                                                        // rqBlurryLand
+    else                                                                                                        // = everything else
+        tmpQuality = 0;                                                                 // full quality
+
+    if (IS_IPAD() == NO)                                                                                        // = disable tooltips on phone
         tmpQuality = tmpQuality | 0x00000400;
 
     // prevents using an empty nickname
--- a/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m	Thu Dec 16 00:48:32 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m	Thu Dec 16 01:45:15 2010 +0100
@@ -76,7 +76,13 @@
         case 30:    //alternateSwitch
             [self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"alternate"];
             break;
-        case 60:    //getReady
+        case 70:    //enhanced graphics
+            [self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"enhanced"];
+            break;
+        case 80:    //nomultitasking
+            [self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"multitasking"];
+            break;
+        case 60:    //classic menu
             [self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"menu"];
             break;
         default:
@@ -109,10 +115,10 @@
             return 2;
             break;
         case 2:     // other stuff
-            if (IS_IPAD())
-                return 2;
+            if (IS_IPAD() == YES)
+                return 4;
             else
-                return 1;
+                return 3;
             break;
         default:
             DLog(@"Nope");
@@ -218,16 +224,34 @@
             }
             
             switchContent = (UISwitch *)cell.accessoryView;
-            if (row == 0) {
-                cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @"");
-                cell.detailTextLabel.text = NSLocalizedString(@"Damage popups will notify you on every single hit", @"");
-                switchContent.on = [[self.settingsDictionary objectForKey:@"alternate"] boolValue];
-                switchContent.tag = 30;
-            } else {
-                cell.textLabel.text = NSLocalizedString(@"Classic Ammo Menu", @"");
-                cell.detailTextLabel.text = NSLocalizedString(@"Select which style of ammo menu you prefer",@"");
-                switchContent.on = [[self.settingsDictionary objectForKey:@"menu"] boolValue];
-                switchContent.tag = 60;
+            switch (row) {
+                case 0:
+                    cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @"");
+                    cell.detailTextLabel.text = NSLocalizedString(@"Damage popups will notify you on every single hit", @"");
+                    switchContent.on = [[self.settingsDictionary objectForKey:@"alternate"] boolValue];
+                    switchContent.tag = 30;
+                    break;
+                case 1:
+                    cell.textLabel.text = NSLocalizedString(@"Enanched Graphics Mode", @"");
+                    cell.detailTextLabel.text = NSLocalizedString(@"The game will use more memory so it could crash!", @"");
+                    switchContent.on = [[self.settingsDictionary objectForKey:@"enhanced"] boolValue];
+                    switchContent.tag = 70;
+                    break;
+                case 2:
+                    cell.textLabel.text = NSLocalizedString(@"Multitasking Enabled", @"");
+                    cell.detailTextLabel.text = NSLocalizedString(@"Disable it in case of issues when returing in game", @"");
+                    switchContent.on = [[self.settingsDictionary objectForKey:@"multitasking"] boolValue];
+                    switchContent.tag = 80;
+                    break;
+                case 3:
+                    cell.textLabel.text = NSLocalizedString(@"Classic Ammo Menu", @"");
+                    cell.detailTextLabel.text = NSLocalizedString(@"Select which style of ammo menu you prefer",@"");
+                    switchContent.on = [[self.settingsDictionary objectForKey:@"menu"] boolValue];
+                    switchContent.tag = 60;
+                    break;
+                default:
+                    DLog(@"Nope");
+                    break;
             }
             break;
         default:
--- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m	Thu Dec 16 00:48:32 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m	Thu Dec 16 01:45:15 2010 +0100
@@ -232,8 +232,9 @@
     if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
          device.multitaskingSupported &&
          self.isInGame) {
-        // multiasking in-game works only for ios >= 4.2, returns a black screen on other verions
-        if (NSClassFromString(@"UIPrintInfo"))
+        // let's try to be permissive with multitasking here...
+        NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
+        if ([[settings objectForKey:@"multitasking"] boolValue])
             HW_suspend();
         else {
             // so the game returns to the configuration view
@@ -246,6 +247,7 @@
                 longjmp(*(jump_env()), 1);
             }
         }
+        [settings release];
     }
 }
 
--- a/project_files/HedgewarsMobile/Resources/Settings/settings.plist	Thu Dec 16 00:48:32 2010 +0100
+++ b/project_files/HedgewarsMobile/Resources/Settings/settings.plist	Thu Dec 16 01:45:15 2010 +0100
@@ -16,5 +16,9 @@
 	<false/>
 	<key>password_length</key>
 	<integer>0</integer>
+	<key>enhanced</key>
+	<false/>
+	<key>multitasking</key>
+	<true/>
 </dict>
 </plist>