SettingsTableViewController.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. //
  2. // Settings.m
  3. // SDLPal
  4. //
  5. // Created by palxex on 2017/5/18.
  6. // Copyright © 2017年 SDLPAL team. All rights reserved.
  7. //
  8. #import "SettingsTableViewController.h"
  9. #import "SPWebViewController.h"
  10. #import "SDLPal_AppDelegate.h"
  11. #import "ActionSheetStringPicker.h"
  12. #import "AFNetworking.h"
  13. #import "SSZipArchive.h"
  14. #include "palcfg.h"
  15. #define UIKitLocalizedString(key) [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] localizedStringForKey:key value:@"" table:nil]
  16. @implementation SettingsTableViewController {
  17. NSArray *AudioSampleRates;
  18. NSArray *AudioBufferSizes;
  19. NSArray *OPLSampleRates;
  20. NSArray *CDFormats;
  21. NSArray *MusicFormats;
  22. NSArray *OPLFormats;
  23. NSArray *LogLevels;
  24. NSArray *allFiles;
  25. NSMutableArray *AvailFiles;
  26. BOOL checkAllFilesIncluded;
  27. NSString *resourceStatus;
  28. NSArray *officialLinks;
  29. NSInteger linkSelected;
  30. UIAlertController *customURLAlert;
  31. IBOutlet UIView *transitionView;
  32. IBOutlet UILabel *lblResourceStatus;
  33. IBOutlet UILabel *lblLanguageFile;
  34. IBOutlet UILabel *lblFontFile;
  35. IBOutlet UISwitch *toggleTouchScreenOverlay;
  36. IBOutlet UISwitch *toggleKeepAspect;
  37. IBOutlet UISwitch *toggleSmoothScaling;
  38. IBOutlet UILabel *lblMusicType;
  39. IBOutlet UILabel *lblOPLType;
  40. IBOutlet UILabel *lblOPLRate;
  41. IBOutlet UILabel *lblCDAudioSource;
  42. IBOutlet UISwitch *toggleStereo;
  43. IBOutlet UISwitch *toggleSurroundOPL;
  44. IBOutlet UILabel *lblResampleRate;
  45. IBOutlet UILabel *lblAudioBufferSize;
  46. IBOutlet UISlider *sliderResampleQuality;
  47. IBOutlet UISlider *sliderMusicVolume;
  48. IBOutlet UISlider *sliderSFXVolume;
  49. IBOutlet UILabel *lblLogLevel;
  50. IBOutlet UITextField *textLogFile;
  51. }
  52. - (BOOL)includedInList:(NSArray*)array name:(NSString *)filename {
  53. for( NSString *item in array ) {
  54. if( [filename caseInsensitiveCompare:item] == NSOrderedSame )
  55. return YES;
  56. }
  57. return NO;
  58. }
  59. - (void)viewDidLoad {
  60. [super viewDidLoad];
  61. [transitionView setFrame:self.view.frame];
  62. UILabel* tlabel=[[UILabel alloc] initWithFrame:CGRectMake(0,0, 300, 40)];
  63. tlabel.text=[NSString stringWithUTF8String:PAL_GIT_REVISION];
  64. tlabel.backgroundColor =[UIColor clearColor];
  65. tlabel.adjustsFontSizeToFitWidth=YES;
  66. self.navigationItem.titleView=tlabel;
  67. AudioSampleRates = @[ @"11025", @"22050", @"44100", @"49716" ];
  68. AudioBufferSizes = @[ @"512", @"1024", @"2048", @"4096", @"8192" ];
  69. OPLSampleRates = @[ @"12429", @"24858", @"49716", @"11025", @"22050", @"44100" ];
  70. CDFormats = @[ @"MP3", @"OGG" ];
  71. MusicFormats = @[ @"MIDI", @"RIX", @"MP3", @"OGG" ];
  72. OPLFormats = @[ @"DOSBOX", @"MAME", @"DOSBOXNEW" ];
  73. LogLevels = @[ @"VERBOSE", @"DEBUG", @"INFO", @"WARNING", @"ERROR", @"FATAL" ];
  74. officialLinks = @[ @[@"BAIYOU",@"http://pal5q.baiyou100.com/pal5/download/98xjrq.html", @"Pal98rqp.zip"],
  75. // @[@"ROO GAMES",@"http://gamelib.roogames.com/WDetail/WDJDetail?gameid=10256", @"NEED client to parse & handle, ignore"],
  76. // @[@"CUBE GAME",@"http://ku.cubejoy.com/GameDetail/Detail/1000038", @"NEED client to parse & handle, ignore"],
  77. ];
  78. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
  79. tap.cancelsTouchesInView = NO;
  80. [self.view addGestureRecognizer:tap];
  81. UIRefreshControl *refreshController = [[UIRefreshControl alloc] init];
  82. [refreshController addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
  83. [self.tableView addSubview:refreshController];
  84. [self recheckSharingFolder];
  85. }
  86. -(void)dismissKeyboard
  87. {
  88. [self.view endEditing:YES];
  89. }
  90. -(void)handleRefresh : (id)sender
  91. {
  92. UIRefreshControl *refreshController = sender;
  93. [self recheckSharingFolder];
  94. [refreshController endRefreshing];
  95. }
  96. - (void)recheckSharingFolder {
  97. AvailFiles = [NSMutableArray new];
  98. NSArray *builtinList = @[ @"wor16.fon", @"wor16.asc", @"m.msg"];
  99. NSArray *builtinExtensionList = @[@"exe",@"drv",@"dll",@"rpg",@"mkf",@"avi",@"dat",@"cfg",@"ini"];
  100. allFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[NSString stringWithUTF8String:UTIL_BasePath()] error:nil];
  101. for( NSString *filename in allFiles ) {
  102. if( ![self includedInList:builtinExtensionList name:filename.pathExtension] &&
  103. ![self includedInList:builtinList name:filename] ) {
  104. [AvailFiles addObject:filename];
  105. }
  106. }
  107. checkAllFilesIncluded = YES;
  108. 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"] ) {
  109. if( ![self includedInList:allFiles name:checkFile] ) {
  110. checkAllFilesIncluded = NO;
  111. break;
  112. }
  113. }
  114. if(!resourceStatus) resourceStatus = lblResourceStatus.text;
  115. lblResourceStatus.text = [NSString stringWithFormat:@"%@%@", resourceStatus, checkAllFilesIncluded ? @"✅" : @"❌" ];
  116. [self readConfigs];
  117. }
  118. typedef void(^SelectedBlock)(NSString *selected);
  119. - (void)showPickerWithTitle:(NSString *)title toLabel:(UILabel*)label inArray:(NSArray*)array {
  120. [self showPickerWithTitle:title toLabel:label inArray:array origin:self.navigationController.navigationBar allowEmpty:NO];
  121. }
  122. - (void)showPickerWithTitle:(NSString *)title toLabel:(UILabel*)label inArray:(NSArray*)array origin:(UIView*)origin {
  123. [self showPickerWithTitle:title toLabel:label inArray:array origin:origin allowEmpty:NO];
  124. }
  125. - (void)showPickerWithTitle:(NSString *)title toLabel:(UILabel*)label inArray:(NSArray*)array origin:(UIView*)origin allowEmpty:(BOOL)allowEmpty {
  126. [self showPickerWithTitle:title toLabel:label inArray:array origin:origin allowEmpty:allowEmpty doneBlock:nil];
  127. }
  128. - (void)showPickerWithTitle:(NSString *)title toLabel:(UILabel*)label inArray:(NSArray*)array origin:(UIView*)origin allowEmpty:(BOOL)allowEmpty doneBlock:(SelectedBlock)doneBlock {
  129. array = allowEmpty ? [array arrayByAddingObject:@""] : array;
  130. [ActionSheetStringPicker showPickerWithTitle:nil
  131. rows:array
  132. initialSelection:[array containsObject:label.text] ? [array indexOfObject:label.text] : 0
  133. doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {
  134. label.text = array[selectedIndex];
  135. if(doneBlock) doneBlock(label.text);
  136. }
  137. cancelBlock:nil
  138. origin:origin];
  139. }
  140. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  141. //need manually sync with storyboard...
  142. int rows = 1;
  143. switch(section) {
  144. case 0:
  145. rows = 1;
  146. break;
  147. case 1:
  148. rows = 2;
  149. break;
  150. case 2:
  151. rows = 3;
  152. break;
  153. case 3:
  154. rows = [lblMusicType.text isEqualToString:@"RIX"] ? 11 : 4;
  155. break;
  156. case 4:
  157. rows = 2;
  158. break;
  159. default:
  160. break;
  161. }
  162. return rows;
  163. }
  164. - (void)capturedURL:(NSURL *)url{
  165. UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Copyright Claim",nil)
  166. message:[NSString stringWithFormat:NSLocalizedString(@"This App is about to download the free & publicly available game resource from %@ to the iTunes File Sharing folder.\nPlease notice that all the copyright of the downloaded game resource belongs to its creator, Softstar, Inc. This App provides the download function here only for convenient purpose, and Softstar, Inc. may remove the download links at any time. Furthermore, you should take full responsibility for using the downloaded game resource which is completely irrelevant to the developers of this App.\nYou have to agree the above declaration before you click 'ok' to start the downloading process. Otherwise, please click 'cancel' to return.",nil),url.host]
  167. preferredStyle:UIAlertControllerStyleAlert];
  168. UIAlertAction *ensureAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"OK") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  169. [self downloadURL:url];
  170. }];
  171. [alert addAction:ensureAction];
  172. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"Cancel") style:UIAlertActionStyleCancel handler:nil];
  173. [alert addAction:cancelAction];
  174. [self presentViewController:alert animated:YES completion:nil];
  175. }
  176. - (void)downloadURL:(NSURL *)url{
  177. UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Downloading",nil)
  178. message:@"\n"
  179. preferredStyle:UIAlertControllerStyleAlert];
  180. __block NSURLSessionDownloadTask *downloadTask;
  181. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"Cancel") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  182. if(downloadTask) {
  183. [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
  184. [downloadTask cancel];
  185. }
  186. }];
  187. [alert addAction:cancelAction];
  188. UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(10, 60, 250, 2.0)];
  189. [progressView setProgress:0];
  190. [alert.view addSubview:progressView];
  191. [self presentViewController:alert animated:YES completion:nil];
  192. AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
  193. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  194. downloadTask = [manager downloadTaskWithRequest:request
  195. progress:^(NSProgress * _Nonnull downloadProgress) {
  196. progressView.progress = downloadProgress.fractionCompleted;
  197. }
  198. destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
  199. return [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[response suggestedFilename]]];
  200. }
  201. completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
  202. downloadTask = nil;
  203. [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
  204. if( error ) {
  205. [alert dismissViewControllerAnimated:YES completion:nil];
  206. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
  207. message:[error localizedDescription]
  208. preferredStyle:UIAlertControllerStyleAlert];
  209. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"OK") style:UIAlertActionStyleDefault handler:nil];
  210. [alert addAction:cancelAction];
  211. [self presentViewController:alert animated:YES completion:nil];
  212. }else{
  213. alert.title = @"Extracting";
  214. progressView.progress = 0.0f;
  215. [SSZipArchive unzipFileAtPath:filePath.path
  216. toDestination:[NSString stringWithUTF8String:UTIL_BasePath()]
  217. overwrite:YES
  218. password:nil
  219. progressHandler:^(NSString * _Nonnull entry, unz_file_info zipInfo, long entryNumber, long total) {
  220. progressView.progress = (float)entryNumber/total;
  221. }
  222. completionHandler:^(NSString * _Nonnull path, BOOL succeeded, NSError * _Nonnull error) {
  223. [alert dismissViewControllerAnimated:YES completion:nil];
  224. if( error ) {
  225. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
  226. message:[error localizedDescription]
  227. preferredStyle:UIAlertControllerStyleAlert];
  228. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"OK") style:UIAlertActionStyleDefault handler:nil];
  229. [alert addAction:cancelAction];
  230. [self presentViewController:alert animated:YES completion:nil];
  231. }else{
  232. [self recheckSharingFolder];
  233. }
  234. }];
  235. }
  236. }];
  237. [downloadTask resume];
  238. [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
  239. }
  240. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  241. UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
  242. if( indexPath.section == 1 && indexPath.row == 0 ) { //language file
  243. [self showPickerWithTitle:nil toLabel:lblLanguageFile inArray:AvailFiles origin:cell allowEmpty:YES];
  244. }else if( indexPath.section == 1 && indexPath.row == 1 ) { //font file
  245. [self showPickerWithTitle:nil toLabel:lblFontFile inArray:AvailFiles origin:cell allowEmpty:YES];
  246. }else if( indexPath.section == 2 && indexPath.row == 0 ) { //touch overlay
  247. toggleTouchScreenOverlay.on = !toggleTouchScreenOverlay.isOn;
  248. }else if( indexPath.section == 2 && indexPath.row == 1 ) { //keep aspect
  249. toggleKeepAspect.on = !toggleKeepAspect.isOn;
  250. }else if( indexPath.section == 2 && indexPath.row == 2 ) { //smooth scaling
  251. toggleSmoothScaling.on = !toggleSmoothScaling.isOn;
  252. }else if( indexPath.section == 3 && indexPath.row == 0 ) { //BGM
  253. [self showPickerWithTitle:nil toLabel:lblMusicType inArray:MusicFormats origin:cell allowEmpty:NO doneBlock:^(NSString *selected) {
  254. [self.tableView reloadData];
  255. }];
  256. }else if( indexPath.section == 3 && indexPath.row == 4 ) { //OPL Type
  257. [self showPickerWithTitle:nil toLabel:lblOPLType inArray:OPLFormats origin:cell];
  258. }else if( indexPath.section == 3 && indexPath.row == 5 ) { //OPL Rate
  259. [self showPickerWithTitle:nil toLabel:lblOPLRate inArray:OPLSampleRates origin:cell];
  260. }else if( indexPath.section == 3 && indexPath.row == 1 ) { //CD Source
  261. [self showPickerWithTitle:nil toLabel:lblCDAudioSource inArray:CDFormats origin:cell];
  262. }else if( indexPath.section == 3 && indexPath.row == 8 ) { //Stereo
  263. toggleStereo.on = !toggleStereo.isOn;
  264. }else if( indexPath.section == 3 && indexPath.row == 9 ) { //Surround
  265. toggleSurroundOPL.on = !toggleSurroundOPL.isOn;
  266. }else if( indexPath.section == 3 && indexPath.row == 6 ) { //SampleRate
  267. [self showPickerWithTitle:nil toLabel:lblResampleRate inArray:AudioSampleRates origin:cell];
  268. }else if( indexPath.section == 3 && indexPath.row == 7 ) { //Buffer size
  269. [self showPickerWithTitle:nil toLabel:lblAudioBufferSize inArray:AudioBufferSizes origin:cell];
  270. }else if( indexPath.section == 4 && indexPath.row == 0 ) { //Log Level
  271. [self showPickerWithTitle:nil toLabel:lblLogLevel inArray:LogLevels origin:cell];
  272. }
  273. }
  274. - (IBAction)btnDefaultClicked:(id)sender {
  275. PAL_LoadConfig(NO);
  276. [self readConfigs];
  277. }
  278. - (void)customURLDidChanged:(id)textField {
  279. NSURL *url = [NSURL URLWithString:customURLAlert.textFields[0].text];
  280. customURLAlert.actions[0].enabled = [NSURLConnection canHandleRequest:[NSURLRequest requestWithURL:url]] && url.host;
  281. }
  282. - (IBAction)btnConfirmClicked:(id)sender {
  283. if(!checkAllFilesIncluded){
  284. __weak id weakSelf = self;
  285. UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Cannot find data file in the iTunes File Sharing directory",nil)
  286. message:NSLocalizedString(@"NOTE: For copyright reasons data files required to run the game are NOT included. You can obtain them by visiting official links, or copy them via iTunes File Sharing. Which do you prefer?",nil)
  287. preferredStyle:UIAlertControllerStyleAlert];
  288. for( NSArray *linkInfo in officialLinks ) {
  289. UIAlertAction *selectAction = [UIAlertAction actionWithTitle:NSLocalizedString(linkInfo[0],nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  290. linkSelected = [officialLinks indexOfObject:linkInfo];
  291. [self performSegueWithIdentifier:@"showWebView" sender:self];
  292. }];
  293. [alert addAction:selectAction];
  294. }
  295. UIAlertAction *customAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Custom URL",nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  296. customURLAlert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Custom URL",nil)
  297. message:@""
  298. preferredStyle:UIAlertControllerStyleAlert];
  299. [customURLAlert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
  300. textField.placeholder = NSLocalizedString(@"Custom URL",nil);
  301. [textField addTarget:weakSelf action:@selector(customURLDidChanged:) forControlEvents:UIControlEventEditingChanged];
  302. }];
  303. UIAlertAction *ensureAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"OK") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  304. NSURL *url = [NSURL URLWithString:customURLAlert.textFields[0].text];
  305. [weakSelf downloadURL:url];
  306. }];
  307. ensureAction.enabled = NO;
  308. [customURLAlert addAction:ensureAction];
  309. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"Cancel") style:UIAlertActionStyleCancel handler:nil];
  310. [customURLAlert addAction:cancelAction];
  311. [self presentViewController:customURLAlert animated:YES completion:nil];
  312. }];
  313. [alert addAction:customAction];
  314. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:UIKitLocalizedString(@"Cancel") style:UIAlertActionStyleCancel handler:nil];
  315. [alert addAction:cancelAction];
  316. [self presentViewController:alert animated:YES completion:nil];
  317. return;
  318. }
  319. [UIView animateWithDuration:0.65
  320. delay:0.0
  321. usingSpringWithDamping:1.0
  322. initialSpringVelocity:0.0
  323. options:UIViewAnimationOptionCurveEaseInOut
  324. animations:^{
  325. CGPoint point = self.navigationController.view.center;
  326. point.y += self.navigationController.view.frame.size.height;
  327. [self.navigationController.view setCenter:point];
  328. } completion:^(BOOL finished) {
  329. [self saveConfigs];
  330. gConfig.fLaunchSetting = NO;
  331. PAL_SaveConfig();
  332. [[SDLPalAppDelegate sharedAppDelegate] launchGame];
  333. }];
  334. }
  335. - (void)readConfigs {
  336. gConfig.fFullScreen = YES; //iOS specific; need this to make sure statusbar hidden in game completely
  337. lblLanguageFile.text = [NSString stringWithUTF8String:gConfig.pszMsgFile ? gConfig.pszMsgFile : ""];
  338. lblFontFile.text = [NSString stringWithUTF8String:gConfig.pszFontFile ? gConfig.pszFontFile : ""];
  339. textLogFile.text = [NSString stringWithUTF8String:gConfig.pszLogFile ? gConfig.pszLogFile : ""];
  340. toggleStereo.on = gConfig.iAudioChannels == 2;
  341. toggleSurroundOPL.on = gConfig.fUseSurroundOPL;
  342. toggleTouchScreenOverlay.on = gConfig.fUseTouchOverlay;
  343. toggleKeepAspect.on = gConfig.fKeepAspectRatio;
  344. toggleSmoothScaling.on = gConfig.pszScaleQuality ? strncmp(gConfig.pszScaleQuality, "0", sizeof(char)) != 0 : NO;
  345. lblMusicType.text = MusicFormats[gConfig.eMusicType];
  346. lblOPLType.text = OPLFormats[gConfig.eOPLType];
  347. lblOPLRate.text = [NSString stringWithFormat:@"%d",gConfig.iOPLSampleRate];
  348. lblCDAudioSource.text = CDFormats[gConfig.eCDType-MUSIC_OGG];
  349. lblResampleRate.text = [NSString stringWithFormat:@"%d",gConfig.iSampleRate];
  350. lblAudioBufferSize.text = [NSString stringWithFormat:@"%d",gConfig.wAudioBufferSize];
  351. sliderMusicVolume.value = gConfig.iMusicVolume;
  352. sliderSFXVolume.value = gConfig.iSoundVolume;
  353. sliderResampleQuality.value = gConfig.iResampleQuality;
  354. lblLogLevel.text = LogLevels[gConfig.iLogLevel];
  355. [self.tableView reloadData];
  356. }
  357. - (void)saveConfigs {
  358. gConfig.pszMsgFile = [lblLanguageFile.text length] == 0 ? NULL : strdup([[lblLanguageFile text] UTF8String]);
  359. gConfig.pszFontFile = [lblLanguageFile.text length] == 0 ? NULL : strdup([[lblFontFile text] UTF8String]);
  360. gConfig.pszLogFile = [lblLanguageFile.text length] == 0 ? NULL : strdup([[textLogFile text] UTF8String]);
  361. gConfig.iAudioChannels = toggleStereo.isOn ? 2 : 1;
  362. gConfig.fUseSurroundOPL = toggleSurroundOPL.isOn;
  363. gConfig.fKeepAspectRatio = toggleKeepAspect.isOn;
  364. gConfig.fUseTouchOverlay = toggleTouchScreenOverlay.isOn;
  365. gConfig.pszScaleQuality = strdup(toggleSmoothScaling.on ? "1" : "0");
  366. gConfig.eMusicType = (MUSICTYPE)[MusicFormats indexOfObject:lblMusicType.text];
  367. gConfig.eOPLType = (OPLTYPE )[OPLFormats indexOfObject:lblOPLType.text];
  368. gConfig.iOPLSampleRate = [lblOPLRate.text intValue];
  369. gConfig.eCDType = (MUSICTYPE)[CDFormats indexOfObject:lblCDAudioSource.text]+MUSIC_OGG;
  370. gConfig.iSampleRate = [lblResampleRate.text intValue];
  371. gConfig.wAudioBufferSize = [lblAudioBufferSize.text intValue];
  372. gConfig.iMusicVolume = sliderMusicVolume.value;
  373. gConfig.iSoundVolume = sliderSFXVolume.value;
  374. gConfig.iResampleQuality = sliderResampleQuality.value;
  375. gConfig.iLogLevel = (LOGLEVEL)[LogLevels indexOfObject:lblLogLevel.text];
  376. }
  377. #pragma mark - Navigation
  378. // In a storyboard-based application, you will often want to do a little preparation before navigation
  379. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  380. if( [segue.identifier isEqualToString:@"showWebView"] ) {
  381. SPWebViewController *webView = segue.destinationViewController;
  382. webView.delegate = self;
  383. webView.url = officialLinks[linkSelected][1];
  384. webView.signature = officialLinks[linkSelected][2];
  385. }
  386. }
  387. @end