mirror of
https://github.com/libretro/Play-.git
synced 2024-12-13 11:35:30 +00:00
74 lines
1.9 KiB
Plaintext
74 lines
1.9 KiB
Plaintext
#import <Foundation/Foundation.h>
|
|
#import "PreferencesWindowController.h"
|
|
#import "VideoSettingsViewController.h"
|
|
#import "AudioSettingsViewController.h"
|
|
#import "VfsManagerViewController.h"
|
|
#include "../AppConfig.h"
|
|
|
|
@implementation PreferencesWindowController
|
|
|
|
@synthesize currentViewController;
|
|
|
|
static PreferencesWindowController* g_sharedInstance = nil;
|
|
|
|
+(PreferencesWindowController*)defaultController
|
|
{
|
|
if(g_sharedInstance == nil)
|
|
{
|
|
g_sharedInstance = [[self alloc] initWithWindowNibName: @"PreferencesWindow"];
|
|
}
|
|
return g_sharedInstance;
|
|
}
|
|
|
|
-(void)show
|
|
{
|
|
[self.window center];
|
|
[NSApp runModalForWindow: self.window];
|
|
CAppConfig::GetInstance().Save();
|
|
}
|
|
|
|
-(void)windowWillClose: (NSNotification*)notification
|
|
{
|
|
[NSApp stopModal];
|
|
[self release];
|
|
g_sharedInstance = nil;
|
|
}
|
|
|
|
-(void)awakeFromNib
|
|
{
|
|
NSToolbarItem* item = [toolbar.items objectAtIndex: 0];
|
|
toolbar.selectedItemIdentifier = item.itemIdentifier;
|
|
[self onToolBarButtonPressed: item];
|
|
}
|
|
|
|
-(IBAction)onToolBarButtonPressed: (id)sender
|
|
{
|
|
NSToolbarItem* item = (NSToolbarItem*)sender;
|
|
switch(item.tag)
|
|
{
|
|
case 0:
|
|
currentViewController = [[VideoSettingsViewController alloc] init];
|
|
break;
|
|
case 1:
|
|
currentViewController = [[AudioSettingsViewController alloc] init];
|
|
break;
|
|
case 2:
|
|
currentViewController = [[VfsManagerViewController alloc] init];
|
|
break;
|
|
default:
|
|
assert(false);
|
|
break;
|
|
}
|
|
NSView* contentView = currentViewController.view;
|
|
self.window.contentView = nil;
|
|
auto currentFrame = self.window.frame;
|
|
auto currentTop = currentFrame.origin.y + currentFrame.size.height;
|
|
auto windowFrame = [self.window frameRectForContentRect: contentView.frame];
|
|
auto newY = currentTop - windowFrame.size.height;
|
|
windowFrame = NSMakeRect(currentFrame.origin.x, newY, windowFrame.size.width, windowFrame.size.height);
|
|
[self.window setFrame: windowFrame display: YES animate: YES];
|
|
self.window.contentView = contentView;
|
|
}
|
|
|
|
@end
|