2019-11-07 05:44:19 +01:00
|
|
|
/*****************************************************************************\
|
2021-04-26 02:44:40 +02:00
|
|
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
|
|
This file is licensed under the Snes9x License.
|
2019-11-07 05:44:19 +01:00
|
|
|
For further information, consult the LICENSE file in the root directory.
|
|
|
|
\*****************************************************************************/
|
|
|
|
|
|
|
|
/***********************************************************************************
|
|
|
|
SNES9X for Mac OS (c) Copyright John Stiles
|
|
|
|
|
|
|
|
Snes9x for Mac OS X
|
|
|
|
|
|
|
|
(c) Copyright 2001 - 2011 zones
|
|
|
|
(c) Copyright 2002 - 2005 107
|
|
|
|
(c) Copyright 2002 PB1400c
|
|
|
|
(c) Copyright 2004 Alexander and Sander
|
|
|
|
(c) Copyright 2004 - 2005 Steven Seeger
|
|
|
|
(c) Copyright 2005 Ryan Vogt
|
2021-04-26 02:44:40 +02:00
|
|
|
(c) Copyright 2019 - 2021 Michael Donald Buckley
|
2019-11-07 05:44:19 +01:00
|
|
|
***********************************************************************************/
|
|
|
|
|
|
|
|
#import <snes9x_framework/snes9x_framework.h>
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
#import "S9xButtonConfigTextField.h"
|
2021-04-26 02:44:40 +02:00
|
|
|
#import "S9xPreferencesConstants.h"
|
|
|
|
#import "S9xPreferencesWindowController.h"
|
2019-11-07 05:44:19 +01:00
|
|
|
|
2021-04-26 02:44:40 +02:00
|
|
|
#import "S9xPreferencesTabViewController.h"
|
|
|
|
#import "S9xControlsPreferencesViewController.h"
|
|
|
|
#import "S9xDisplayPreferencesViewController.h"
|
|
|
|
#import "S9xSoundPreferencesViewController.h"
|
|
|
|
#import "S9xEmulationPreferencesViewController.h"
|
|
|
|
#import "S9xFilesPreferencesViewController.h"
|
|
|
|
|
|
|
|
@interface S9xPreferencesWindowController ()
|
|
|
|
@property (nonatomic, readonly, strong) NSArray<S9xPreferencesViewController *> *tabs;
|
|
|
|
@property (nonatomic, readonly, strong) NSTabViewController *tabViewController;
|
|
|
|
@end
|
2020-09-22 18:17:14 +02:00
|
|
|
|
2020-09-14 23:31:56 +02:00
|
|
|
@implementation S9xPreferencesWindowController
|
2019-11-07 05:44:19 +01:00
|
|
|
|
2021-04-26 02:44:40 +02:00
|
|
|
- (NSArray<S9xPreferencesViewController *> *)tabs
|
2020-09-14 23:31:56 +02:00
|
|
|
{
|
2021-04-26 02:44:40 +02:00
|
|
|
return self.contentViewController.childViewControllers;
|
2020-09-14 23:31:56 +02:00
|
|
|
}
|
2019-11-07 05:44:19 +01:00
|
|
|
|
2021-04-26 02:44:40 +02:00
|
|
|
@dynamic tabViewController;
|
|
|
|
- (S9xPreferencesTabViewController *)tabViewController
|
2019-11-07 05:44:19 +01:00
|
|
|
{
|
2021-04-26 02:44:40 +02:00
|
|
|
return (S9xPreferencesTabViewController *)self.contentViewController;
|
2019-11-07 05:44:19 +01:00
|
|
|
}
|
|
|
|
|
2021-04-26 02:44:40 +02:00
|
|
|
- (void)windowDidLoad
|
2019-11-07 05:44:19 +01:00
|
|
|
{
|
2021-04-26 02:44:40 +02:00
|
|
|
[self refresh];
|
2020-09-14 23:31:56 +02:00
|
|
|
}
|
2019-11-10 22:02:21 +01:00
|
|
|
|
2021-04-26 02:44:40 +02:00
|
|
|
- (void)awakeFromNib
|
2020-09-14 23:31:56 +02:00
|
|
|
{
|
2021-04-26 02:44:40 +02:00
|
|
|
S9xPreferencesTabViewController *tabViewController = [S9xPreferencesTabViewController new];
|
|
|
|
tabViewController.tabStyle = NSTabViewControllerTabStyleToolbar;
|
|
|
|
self.contentViewController = tabViewController;
|
2020-09-14 23:31:56 +02:00
|
|
|
|
2021-04-26 02:44:40 +02:00
|
|
|
[self addPane:[S9xControlsPreferencesViewController new] to:tabViewController];
|
|
|
|
[self addPane:[S9xDisplayPreferencesViewController new] to:tabViewController];
|
|
|
|
[self addPane:[S9xSoundPreferencesViewController new] to:tabViewController];
|
|
|
|
[self addPane:[S9xEmulationPreferencesViewController new] to:tabViewController];
|
|
|
|
[self addPane:[S9xFilesPreferencesViewController new] to:tabViewController];
|
2020-09-14 23:31:56 +02:00
|
|
|
}
|
2019-11-10 22:02:21 +01:00
|
|
|
|
2021-04-26 02:44:40 +02:00
|
|
|
- (void)addPane:(S9xPreferencesViewController *)pane to:(NSTabViewController *)tabController
|
2020-09-14 23:31:56 +02:00
|
|
|
{
|
2021-04-26 02:44:40 +02:00
|
|
|
[tabController addChildViewController:pane];
|
|
|
|
tabController.tabView.tabViewItems.lastObject.image = pane.image;
|
2019-11-07 05:44:19 +01:00
|
|
|
}
|
|
|
|
|
2021-04-26 02:44:40 +02:00
|
|
|
- (void)refresh
|
2019-11-07 05:44:19 +01:00
|
|
|
{
|
2021-04-26 02:44:40 +02:00
|
|
|
for ( S9xPreferencesViewController *tab in self.tabs )
|
2020-12-29 06:13:01 +01:00
|
|
|
{
|
2021-04-26 02:44:40 +02:00
|
|
|
[tab refresh];
|
2020-12-29 06:13:01 +01:00
|
|
|
}
|
2020-09-13 04:02:42 +02:00
|
|
|
}
|
|
|
|
|
2021-04-26 02:44:40 +02:00
|
|
|
- (BOOL)handleInput:(S9xJoypadInput *)input fromJoypad:(S9xJoypad *)joypad
|
2020-09-14 23:31:56 +02:00
|
|
|
{
|
2021-04-26 02:44:40 +02:00
|
|
|
NSTabViewController *tabViewController = self.tabViewController;
|
|
|
|
NSUInteger index = self.tabViewController.selectedTabViewItemIndex;
|
|
|
|
if ( index >= 0 && index < tabViewController.childViewControllers.count )
|
2020-12-29 06:13:01 +01:00
|
|
|
{
|
2021-04-26 02:44:40 +02:00
|
|
|
S9xPreferencesViewController *viewController = tabViewController.childViewControllers[index];
|
|
|
|
if ( [viewController isKindOfClass:[S9xControlsPreferencesViewController class]] )
|
|
|
|
{
|
|
|
|
return [((S9xControlsPreferencesViewController *)viewController) handleInput:input fromJoypad:joypad];
|
|
|
|
}
|
2020-12-29 06:13:01 +01:00
|
|
|
}
|
2021-04-26 02:44:40 +02:00
|
|
|
|
|
|
|
return NO;
|
2020-09-14 23:31:56 +02:00
|
|
|
}
|
2020-12-29 06:13:01 +01:00
|
|
|
|
2019-11-07 05:44:19 +01:00
|
|
|
@end
|