mirror of
https://github.com/ksherlock/ample.git
synced 2024-06-17 00:29:28 +00:00
337b3eb1f2
validate the Mame executable path option for system mame (doesn't do anything yet...)
52 lines
1.1 KiB
Objective-C
52 lines
1.1 KiB
Objective-C
//
|
|
// PreferencesWindowController.m
|
|
// Ample
|
|
//
|
|
// Created by Kelvin Sherlock on 8/31/2020.
|
|
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
|
|
//
|
|
|
|
#import "PreferencesWindowController.h"
|
|
|
|
@interface PreferencesWindowController ()
|
|
@property (weak) IBOutlet NSTextField *pathField;
|
|
|
|
@end
|
|
|
|
@implementation PreferencesWindowController
|
|
|
|
-(NSString *)windowNibName {
|
|
return @"Preferences";
|
|
}
|
|
|
|
- (void)windowDidLoad {
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
[super windowDidLoad];
|
|
|
|
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
|
|
|
|
[self validateMamePath: [defaults stringForKey: @"MamePath"]];
|
|
|
|
}
|
|
|
|
-(void)validateMamePath: (NSString *)path {
|
|
NSFileManager * fm = [NSFileManager defaultManager];
|
|
|
|
if ([path length] == 0 || [fm isExecutableFileAtPath: path]) {
|
|
[_pathField setTextColor: [NSColor blackColor]];
|
|
} else {
|
|
[_pathField setTextColor: [NSColor redColor]];
|
|
}
|
|
}
|
|
|
|
- (IBAction)pathChanged:(id)sender {
|
|
|
|
NSString *path = [sender stringValue];
|
|
|
|
[self validateMamePath: path];
|
|
|
|
}
|
|
|
|
|
|
@end
|