2016-01-07 19:48:21 -05:00
|
|
|
#import "SettingsViewController.h"
|
2019-04-08 20:27:54 -04:00
|
|
|
#import "ResolutionFactorSelectorViewController.h"
|
2016-01-07 19:48:21 -05:00
|
|
|
#include "../AppConfig.h"
|
|
|
|
#include "PreferenceDefs.h"
|
2017-02-11 19:34:36 -05:00
|
|
|
#include "../gs/GSH_OpenGL/GSH_OpenGL.h"
|
2016-01-07 19:48:21 -05:00
|
|
|
|
|
|
|
@implementation SettingsViewController
|
|
|
|
|
2020-12-02 18:37:31 -05:00
|
|
|
- (void)updateResolutionFactorLabel
|
2019-04-08 20:27:54 -04:00
|
|
|
{
|
|
|
|
int factor = CAppConfig::GetInstance().GetPreferenceInteger(PREF_CGSH_OPENGL_RESOLUTION_FACTOR);
|
2020-12-02 18:37:31 -05:00
|
|
|
[resolutionFactor setText:[NSString stringWithFormat:@"%dx", factor]];
|
2019-04-08 20:27:54 -04:00
|
|
|
}
|
|
|
|
|
2020-12-02 18:37:31 -05:00
|
|
|
- (void)viewDidLoad
|
2016-01-07 19:48:21 -05:00
|
|
|
{
|
2020-12-02 18:37:31 -05:00
|
|
|
[showFpsSwitch setOn:CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_UI_SHOWFPS)];
|
|
|
|
[showVirtualPadSwitch setOn:CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_UI_SHOWVIRTUALPAD)];
|
2016-01-08 10:16:11 -05:00
|
|
|
|
2019-04-08 20:27:54 -04:00
|
|
|
[self updateResolutionFactorLabel];
|
2020-12-26 12:17:37 -05:00
|
|
|
[resizeOutputToWidescreen setOn:CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSHANDLER_WIDESCREEN)];
|
2020-12-02 18:37:31 -05:00
|
|
|
[forceBilinearFiltering setOn:CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES)];
|
2016-04-04 12:14:23 -04:00
|
|
|
|
2020-12-02 18:37:31 -05:00
|
|
|
[enableAudioOutput setOn:CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_AUDIO_ENABLEOUTPUT)];
|
|
|
|
|
|
|
|
NSString* versionString = [NSString stringWithFormat:@"%s - %s", PLAY_VERSION, __DATE__];
|
2016-01-08 10:16:11 -05:00
|
|
|
versionInfoLabel.text = versionString;
|
2016-01-07 19:48:21 -05:00
|
|
|
}
|
|
|
|
|
2020-12-02 18:37:31 -05:00
|
|
|
- (void)viewDidDisappear:(BOOL)animated
|
2016-01-07 19:48:21 -05:00
|
|
|
{
|
|
|
|
CAppConfig::GetInstance().SetPreferenceBoolean(PREFERENCE_UI_SHOWFPS, showFpsSwitch.isOn);
|
|
|
|
CAppConfig::GetInstance().SetPreferenceBoolean(PREFERENCE_UI_SHOWVIRTUALPAD, showVirtualPadSwitch.isOn);
|
2020-12-02 18:37:31 -05:00
|
|
|
|
2020-12-26 12:17:37 -05:00
|
|
|
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_CGSHANDLER_WIDESCREEN, resizeOutputToWidescreen.isOn);
|
2016-01-19 10:32:11 -05:00
|
|
|
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES, forceBilinearFiltering.isOn);
|
2020-12-02 18:37:31 -05:00
|
|
|
|
2016-04-04 12:14:23 -04:00
|
|
|
CAppConfig::GetInstance().SetPreferenceBoolean(PREFERENCE_AUDIO_ENABLEOUTPUT, enableAudioOutput.isOn);
|
2020-12-02 18:37:31 -05:00
|
|
|
|
2016-01-07 19:48:21 -05:00
|
|
|
CAppConfig::GetInstance().Save();
|
2021-06-19 15:43:12 -04:00
|
|
|
|
|
|
|
if(self.completionHandler)
|
|
|
|
{
|
|
|
|
self.completionHandler();
|
|
|
|
}
|
2016-01-07 19:48:21 -05:00
|
|
|
}
|
|
|
|
|
2020-12-02 18:37:31 -05:00
|
|
|
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
|
2019-04-08 20:27:54 -04:00
|
|
|
{
|
2020-12-02 18:37:31 -05:00
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
2019-04-08 20:27:54 -04:00
|
|
|
}
|
|
|
|
|
2020-12-02 18:37:31 -05:00
|
|
|
- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender
|
2019-04-08 20:27:54 -04:00
|
|
|
{
|
2020-12-02 18:37:31 -05:00
|
|
|
if([segue.destinationViewController isKindOfClass:[ResolutionFactorSelectorViewController class]])
|
2019-04-08 20:27:54 -04:00
|
|
|
{
|
|
|
|
ResolutionFactorSelectorViewController* selector = (ResolutionFactorSelectorViewController*)segue.destinationViewController;
|
|
|
|
selector.factor = CAppConfig::GetInstance().GetPreferenceInteger(PREF_CGSH_OPENGL_RESOLUTION_FACTOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-02 18:37:31 -05:00
|
|
|
- (IBAction)returnToSettings:(UIStoryboardSegue*)segue
|
2019-04-08 20:27:54 -04:00
|
|
|
{
|
2020-12-02 18:37:31 -05:00
|
|
|
if([segue.sourceViewController isKindOfClass:[ResolutionFactorSelectorViewController class]])
|
2019-04-08 20:27:54 -04:00
|
|
|
{
|
|
|
|
ResolutionFactorSelectorViewController* selector = (ResolutionFactorSelectorViewController*)segue.sourceViewController;
|
|
|
|
CAppConfig::GetInstance().SetPreferenceInteger(PREF_CGSH_OPENGL_RESOLUTION_FACTOR, selector.factor);
|
|
|
|
[self updateResolutionFactorLabel];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-22 10:15:17 -04:00
|
|
|
- (IBAction)returnToParent
|
|
|
|
{
|
2021-06-22 11:02:55 -04:00
|
|
|
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
2021-06-22 10:15:17 -04:00
|
|
|
}
|
|
|
|
|
2016-01-07 19:48:21 -05:00
|
|
|
@end
|