Browse Source

sync iOS resource checking list with android
add pull to refresh for instant forcing recheck
fix a crash when scale quality not configured

Pal Lockheart 6 years ago
parent
commit
7604e8bf6a

+ 16 - 0
ios/SDLPal/SDLPal.xcodeproj/project.pbxproj

@@ -98,6 +98,7 @@
 		71DCB6961ED9CBB000F120DB /* aviplay.c in Sources */ = {isa = PBXBuildFile; fileRef = 71DCB6941ED9CBB000F120DB /* aviplay.c */; };
 		71DCB6991ED9CCFE00F120DB /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C622BE731E474CE2000C8970 /* GameController.framework */; };
 		C60441781ED9AF3C006C7A7C /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C604417A1ED9AF3C006C7A7C /* Settings.storyboard */; };
+		C6153B9D1EEE2ECD00DFFCAA /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C6153B9F1EEE2ECD00DFFCAA /* Localizable.strings */; };
 		C622BE661E474B5E000C8970 /* audio.c in Sources */ = {isa = PBXBuildFile; fileRef = C622BE641E474B5E000C8970 /* audio.c */; };
 		C622BE6C1E474C01000C8970 /* palcfg.c in Sources */ = {isa = PBXBuildFile; fileRef = C622BE6A1E474C01000C8970 /* palcfg.c */; };
 		C622BE701E474CA9000C8970 /* overlay.c in Sources */ = {isa = PBXBuildFile; fileRef = C622BE6F1E474CA9000C8970 /* overlay.c */; };
@@ -348,6 +349,9 @@
 		C604417B1ED9B500006C7A7C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Settings.storyboard; sourceTree = "<group>"; };
 		C604417D1ED9B521006C7A7C /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Settings.strings"; sourceTree = "<group>"; };
 		C604417E1ED9B60C006C7A7C /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Settings.strings"; sourceTree = "<group>"; };
+		C6153B9E1EEE2ECD00DFFCAA /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
+		C6153BA01EEE2ED300DFFCAA /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
+		C6153BA11EEE2ED600DFFCAA /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		C622BE4E1E474AAF000C8970 /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = "../../3rd/SDL/Xcode-iOS/SDL/SDL.xcodeproj"; sourceTree = "<group>"; };
 		C622BE641E474B5E000C8970 /* audio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = audio.c; path = ../../../audio.c; sourceTree = "<group>"; };
 		C622BE651E474B5E000C8970 /* audio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = audio.h; path = ../../../audio.h; sourceTree = "<group>"; };
@@ -660,6 +664,7 @@
 				C604417A1ED9AF3C006C7A7C /* Settings.storyboard */,
 				C6743A851ECCAFC600AEF782 /* SettingsTableViewController.h */,
 				C6743A831ECCAFA700AEF782 /* SettingsTableViewController.m */,
+				C6153B9F1EEE2ECD00DFFCAA /* Localizable.strings */,
 			);
 			name = "Supporting Files";
 			path = SDLPal;
@@ -887,6 +892,7 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				C6153B9D1EEE2ECD00DFFCAA /* Localizable.strings in Resources */,
 				71655073195BB372006E1227 /* Default.png in Resources */,
 				71655075195BB372006E1227 /* Default@2x.png in Resources */,
 				71655077195BB372006E1227 /* Default-568h@2x.png in Resources */,
@@ -1076,6 +1082,16 @@
 			name = Settings.storyboard;
 			sourceTree = "<group>";
 		};
+		C6153B9F1EEE2ECD00DFFCAA /* Localizable.strings */ = {
+			isa = PBXVariantGroup;
+			children = (
+				C6153B9E1EEE2ECD00DFFCAA /* Base */,
+				C6153BA01EEE2ED300DFFCAA /* zh-Hant */,
+				C6153BA11EEE2ED600DFFCAA /* zh-Hans */,
+			);
+			name = Localizable.strings;
+			sourceTree = "<group>";
+		};
 /* End PBXVariantGroup section */
 
 /* Begin XCBuildConfiguration section */

+ 7 - 0
ios/SDLPal/SDLPal/Base.lproj/Localizable.strings

@@ -0,0 +1,7 @@
+/* 
+  Localizable.strings
+  SDLPal
+
+  Created by palxex on 2017/6/12.
+  Copyright © 2017年 SDLPAL team. All rights reserved.
+*/

+ 48 - 14
ios/SDLPal/SDLPal/SettingsTableViewController.m

@@ -12,6 +12,8 @@
 
 #include "palcfg.h"
 
+#define UIKitLocalizedString(key) [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] localizedStringForKey:key value:@"" table:nil]
+
 @implementation SettingsTableViewController {
     NSArray *AudioSampleRates;
     NSArray *AudioBufferSizes;
@@ -22,6 +24,8 @@
     NSArray *LogLevels;
     NSArray *allFiles;
     NSMutableArray *AvailFiles;
+    BOOL checkAllFilesIncluded;
+    NSString *resourceStatus;
     
     AbstractActionSheetPicker *picker;
     
@@ -78,27 +82,50 @@
     OPLFormats = @[ @"DOSBOX", @"MAME", @"DOSBOXNEW" ];
     LogLevels = @[ @"VERBOSE", @"DEBUG", @"INFO", @"WARNING", @"ERROR", @"FATAL" ];
     
+    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
+    tap.cancelsTouchesInView = NO;
+    [self.view addGestureRecognizer:tap];
+    
+    UIRefreshControl *refreshController = [[UIRefreshControl alloc] init];
+    [refreshController addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
+    [self.tableView addSubview:refreshController];
+
+    [self recheckSharingFolder];
+    [self readConfigs];
+}
+-(void)dismissKeyboard
+{
+    [self.view endEditing:YES];
+}
+-(void)handleRefresh : (id)sender
+{
+    UIRefreshControl *refreshController = sender;
+    [self recheckSharingFolder];
+    [refreshController endRefreshing];
+}
+
+- (void)recheckSharingFolder {
     AvailFiles = [NSMutableArray new];
     NSArray *builtinList = @[ @"wor16.fon", @"wor16.asc", @"m.msg"];
     NSArray *builtinExtensionList = @[@"exe",@"drv",@"dll",@"rpg",@"mkf",@"avi",@"dat",@"cfg",@"ini"];
     allFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[NSString stringWithUTF8String:UTIL_BasePath()] error:nil];
     for( NSString *filename in allFiles ) {
         if( ![self includedInList:builtinExtensionList name:filename.pathExtension] &&
-            ![self includedInList:builtinList name:filename] ) {
+           ![self includedInList:builtinList name:filename] ) {
             [AvailFiles addObject:filename];
         }
     }
-    
-    [self readConfigs];
-    
-    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
-    tap.cancelsTouchesInView = NO;
-    [self.view addGestureRecognizer:tap];
-}
--(void)dismissKeyboard
-{
-    [self.view endEditing:YES];
+    checkAllFilesIncluded = YES;
+    for( NSString *checkFile in @[@"abc.mkf", @"ball.mkf", @"data.mkf", @"f.mkf", @"fbp.mkf", @"fire.mkf", @"gop.mkf", @"m.msg", @"map.mkf", @"mgo.mkf", @"rgm.mkf", @"rng.mkf", @"sss.mkf", @"word.dat"] ) {
+        if( ![self includedInList:allFiles name:checkFile] ) {
+            checkAllFilesIncluded = NO;
+            break;
+        }
+    }
+    if(!resourceStatus) resourceStatus = lblResourceStatus.text;
+    lblResourceStatus.text  = [NSString stringWithFormat:@"%@%@", resourceStatus, checkAllFilesIncluded ? @"✅" : @"❌" ];
 }
+
 typedef void(^SelectedBlock)(NSString *selected);
 
 - (void)showPickerWithTitle:(NSString *)title toLabel:(UILabel*)label inArray:(NSArray*)array {
@@ -189,6 +216,15 @@ typedef void(^SelectedBlock)(NSString *selected);
 }
 
 - (IBAction)btnConfirmClicked:(id)sender {
+    if(!checkAllFilesIncluded){
+        UIAlertController  *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Cannot find data file in the iTunes File Sharing directory",nil)
+                                                                        message:NSLocalizedString(@"NOTE: For copyright reasons data files required to run the game are NOT included.",nil)
+                                                                 preferredStyle:UIAlertControllerStyleAlert];
+        UIAlertAction *cacelAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"OK") style:UIAlertActionStyleDefault handler:nil];
+        [alert addAction:cacelAction];
+        [self presentViewController:alert animated:YES completion:nil];
+        return;
+    }
     [UIView animateWithDuration:0.65
                           delay:0.0
          usingSpringWithDamping:1.0
@@ -209,8 +245,6 @@ typedef void(^SelectedBlock)(NSString *selected);
 - (void)readConfigs {
     gConfig.fFullScreen = YES; //iOS specific; need this to make sure statusbar hidden in game completely
     
-    lblResourceStatus.text  = [NSString stringWithFormat:@"%@%@",lblResourceStatus.text, [self includedInList:allFiles name:@"fbp.mkf"] ? @"✅" : @"❌" ];
-    
     lblLanguageFile.text    = [NSString stringWithUTF8String:gConfig.pszMsgFile  ? gConfig.pszMsgFile  : ""];
     lblFontFile.text        = [NSString stringWithUTF8String:gConfig.pszFontFile ? gConfig.pszFontFile : ""];
     textLogFile.text        = [NSString stringWithUTF8String:gConfig.pszLogFile  ? gConfig.pszLogFile  : ""];
@@ -220,7 +254,7 @@ typedef void(^SelectedBlock)(NSString *selected);
     
     toggleTouchScreenOverlay.on = gConfig.fUseTouchOverlay;
     toggleKeepAspect.on         = gConfig.fKeepAspectRatio;
-    toggleSmoothScaling.on      = strncmp(gConfig.pszScaleQuality, "0", sizeof(char)) != 0;
+    toggleSmoothScaling.on      = gConfig.pszScaleQuality ? strncmp(gConfig.pszScaleQuality, "0", sizeof(char)) != 0 : NO;
     
     lblMusicType.text       = MusicFormats[gConfig.eMusicType];
     lblOPLType.text         = OPLFormats[gConfig.eOPLType];

+ 10 - 0
ios/SDLPal/SDLPal/zh-Hans.lproj/Localizable.strings

@@ -0,0 +1,10 @@
+/* 
+  Localizable.strings
+  SDLPal
+
+  Created by palxex on 2017/6/12.
+  Copyright © 2017年 SDLPAL team. All rights reserved.
+*/
+"Cannot find data file in the iTunes File Sharing directory" = "无法在iTunes共享文件夹中找到游戏数据文件";
+
+"NOTE: For copyright reasons data files required to run the game are NOT included." = "注意:由于版权问题,数据文件无法提供。请自行从百游官方下载并解压拷贝到手机中。";

+ 10 - 0
ios/SDLPal/SDLPal/zh-Hant.lproj/Localizable.strings

@@ -0,0 +1,10 @@
+/* 
+  Localizable.strings
+  SDLPal
+
+  Created by palxex on 2017/6/12.
+  Copyright © 2017年 SDLPAL team. All rights reserved.
+*/
+"Cannot find data file in the iTunes File Sharing directory" = "無法在iTunes檔案共享資料夾中找到遊戲資料檔";
+
+"NOTE: For copyright reasons data files required to run the game are NOT included." = "說明:為防止侵害大宇公司版權,恕不提供遊戲資料檔。请自行將正版PAL的資料檔復製到手機中。";