Cocoa Port:
- Fix intermittent bugs with loading user defaults on app startup.
This commit is contained in:
parent
11ff936fa1
commit
48f20e49f7
|
@ -105,6 +105,7 @@
|
|||
- (void) update;
|
||||
- (void) selectDeviceByType:(NSInteger)theType;
|
||||
- (void) setDeviceViewByDevice:(CocoaDSSlot2Device *)theDevice;
|
||||
- (void) setupUserDefaults;
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Auto
|
||||
|
|
|
@ -237,6 +237,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void) setupUserDefaults
|
||||
{
|
||||
[self setMpcfFolderURL:[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"Slot2_MPCF_DirectoryPath"]]];
|
||||
[self setMpcfDiskImageURL:[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"Slot2_MPCF_DiskImagePath"]]];
|
||||
[self setGbaCartridgeURL:[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"Slot2_GBA_CartridgePath"]]];
|
||||
[self setGbaSRamURL:[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"Slot2_GBA_SRAMPath"]]];
|
||||
[self selectDeviceByType:[[NSUserDefaults standardUserDefaults] integerForKey:@"Slot2_LoadedDevice"]];
|
||||
[self applySettings:nil];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Auto
|
||||
|
||||
|
|
|
@ -115,6 +115,17 @@
|
|||
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
// Register the application's defaults.
|
||||
NSDictionary *prefsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultUserPrefs" ofType:@"plist"]];
|
||||
if (prefsDict == nil)
|
||||
{
|
||||
[[NSAlert alertWithMessageText:NSSTRING_ALERT_CRITICAL_FILE_MISSING_PRI defaultButton:nil alternateButton:nil otherButton:nil informativeTextWithFormat:NSSTRING_ALERT_CRITICAL_FILE_MISSING_SEC] runModal];
|
||||
[NSApp terminate:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:prefsDict];
|
||||
|
||||
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
|
||||
PreferencesWindowDelegate *prefWindowDelegate = (PreferencesWindowDelegate *)[prefWindow delegate];
|
||||
CheatWindowDelegate *cheatWindowDelegate = (CheatWindowDelegate *)[cheatListWindow delegate];
|
||||
|
@ -154,17 +165,6 @@
|
|||
|
||||
[aboutWindowController setContent:aboutWindowProperties];
|
||||
|
||||
// Register the application's defaults.
|
||||
NSDictionary *prefsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultUserPrefs" ofType:@"plist"]];
|
||||
if (prefsDict == nil)
|
||||
{
|
||||
[[NSAlert alertWithMessageText:NSSTRING_ALERT_CRITICAL_FILE_MISSING_PRI defaultButton:nil alternateButton:nil otherButton:nil informativeTextWithFormat:NSSTRING_ALERT_CRITICAL_FILE_MISSING_SEC] runModal];
|
||||
[NSApp terminate:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:prefsDict];
|
||||
|
||||
// Change the title colors of the NSBox objects in the ROM Info panel. We change the
|
||||
// colors manually here because you can't change them in Interface Builder. Boo!!!
|
||||
[self setRomInfoPanelBoxTitleColors];
|
||||
|
@ -208,14 +208,6 @@
|
|||
[romInfoPanelController setContent:[CocoaDSRom romNotLoadedBindings]];
|
||||
[prefWindowController setContent:[prefWindowDelegate bindings]];
|
||||
[cheatWindowController setContent:[cheatWindowDelegate bindings]];
|
||||
|
||||
// Setup the applications settings from the user defaults file.
|
||||
[self setupUserDefaults];
|
||||
|
||||
[inputPrefsView initSettingsSheets];
|
||||
[inputPrefsView populateInputProfileMenu];
|
||||
[[inputPrefsView inputPrefOutlineView] expandItem:nil expandChildren:YES];
|
||||
[[inputPrefsView inputProfileMenu] selectItemAtIndex:0];
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
|
@ -240,6 +232,15 @@
|
|||
appFirstTimeRunDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:isFirstTimeRunNumber, bundleVersionString, nil];
|
||||
}
|
||||
|
||||
// Setup the applications settings from the user defaults file.
|
||||
[self setupUserDefaults];
|
||||
|
||||
// Set up the input preferences view.
|
||||
[inputPrefsView initSettingsSheets];
|
||||
[inputPrefsView populateInputProfileMenu];
|
||||
[[inputPrefsView inputPrefOutlineView] expandItem:nil expandChildren:YES];
|
||||
[[inputPrefsView inputProfileMenu] selectItemAtIndex:0];
|
||||
|
||||
//Bring the application to the front
|
||||
[NSApp activateIgnoringOtherApps:TRUE];
|
||||
[self restoreDisplayWindowStates];
|
||||
|
@ -420,7 +421,6 @@
|
|||
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
|
||||
PreferencesWindowDelegate *prefWindowDelegate = [prefWindow delegate];
|
||||
Slot2WindowDelegate *slot2WindowDelegate = (Slot2WindowDelegate *)[slot2Window delegate];
|
||||
NSMutableDictionary *prefBindings = [prefWindowDelegate bindings];
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
|
||||
// Set the emulation flags.
|
||||
|
@ -512,78 +512,32 @@
|
|||
if (arm7BiosImagePath != nil)
|
||||
{
|
||||
[cdsCore setArm7ImageURL:[NSURL fileURLWithPath:arm7BiosImagePath]];
|
||||
[prefBindings setValue:[arm7BiosImagePath lastPathComponent] forKey:@"Arm7BiosImageName"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cdsCore setArm7ImageURL:nil];
|
||||
[prefBindings setValue:nil forKey:@"Arm7BiosImageName"];
|
||||
}
|
||||
|
||||
NSString *arm9BiosImagePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"BIOS_ARM9ImagePath"];
|
||||
if (arm9BiosImagePath != nil)
|
||||
{
|
||||
[cdsCore setArm9ImageURL:[NSURL fileURLWithPath:arm9BiosImagePath]];
|
||||
[prefBindings setValue:[arm9BiosImagePath lastPathComponent] forKey:@"Arm9BiosImageName"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cdsCore setArm9ImageURL:nil];
|
||||
[prefBindings setValue:nil forKey:@"Arm9BiosImageName"];
|
||||
}
|
||||
|
||||
NSString *firmwareImagePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"Emulation_FirmwareImagePath"];
|
||||
if (firmwareImagePath != nil)
|
||||
{
|
||||
[cdsCore setFirmwareImageURL:[NSURL fileURLWithPath:firmwareImagePath]];
|
||||
[prefBindings setValue:[firmwareImagePath lastPathComponent] forKey:@"FirmwareImageName"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cdsCore setFirmwareImageURL:nil];
|
||||
[prefBindings setValue:nil forKey:@"FirmwareImageName"];
|
||||
}
|
||||
|
||||
NSString *advansceneDatabasePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"Advanscene_DatabasePath"];
|
||||
if (advansceneDatabasePath != nil)
|
||||
{
|
||||
[prefBindings setValue:[advansceneDatabasePath lastPathComponent] forKey:@"AdvansceneDatabaseName"];
|
||||
}
|
||||
|
||||
NSString *cheatDatabasePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"R4Cheat_DatabasePath"];
|
||||
if (cheatDatabasePath != nil)
|
||||
{
|
||||
[prefBindings setValue:[cheatDatabasePath lastPathComponent] forKey:@"R4CheatDatabaseName"];
|
||||
}
|
||||
|
||||
// Update the SPU Sync controls in the Preferences window.
|
||||
if ([[NSUserDefaults standardUserDefaults] integerForKey:@"SPU_SyncMode"] == SPU_SYNC_MODE_DUAL_SYNC_ASYNC)
|
||||
{
|
||||
[[prefWindowDelegate spuSyncMethodMenu] setEnabled:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[prefWindowDelegate spuSyncMethodMenu] setEnabled:YES];
|
||||
}
|
||||
|
||||
// Set the name of the autoloaded ROM.
|
||||
NSString *autoloadRomPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"General_AutoloadROMSelectedPath"];
|
||||
if (autoloadRomPath != nil)
|
||||
{
|
||||
[prefBindings setValue:[autoloadRomPath lastPathComponent] forKey:@"AutoloadRomName"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[prefBindings setValue:NSSTRING_STATUS_NO_ROM_CHOSEN forKey:@"AutoloadRomName"];
|
||||
}
|
||||
|
||||
// Set the menu for the display rotation.
|
||||
const double displayRotation = (double)[[NSUserDefaults standardUserDefaults] floatForKey:@"DisplayView_Rotation"];
|
||||
[prefWindowDelegate updateDisplayRotationMenu:displayRotation];
|
||||
|
||||
// Set the default sound volume per user preferences.
|
||||
[prefWindowDelegate updateVolumeIcon:nil];
|
||||
|
||||
// Set up the user's default input settings.
|
||||
NSDictionary *userMappings = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"Input_ControllerMappings"];
|
||||
if (userMappings == nil)
|
||||
|
@ -596,13 +550,11 @@
|
|||
[inputManager setMappingsWithMappings:userMappings];
|
||||
[[inputManager hidManager] setDeviceListController:inputDeviceListController];
|
||||
|
||||
// Set up the preferences window.
|
||||
[prefWindowDelegate setupUserDefaults];
|
||||
|
||||
// Set up the default SLOT-2 device.
|
||||
[slot2WindowDelegate setMpcfFolderURL:[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"Slot2_MPCF_DirectoryPath"]]];
|
||||
[slot2WindowDelegate setMpcfDiskImageURL:[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"Slot2_MPCF_DiskImagePath"]]];
|
||||
[slot2WindowDelegate setGbaCartridgeURL:[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"Slot2_GBA_CartridgePath"]]];
|
||||
[slot2WindowDelegate setGbaSRamURL:[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"Slot2_GBA_SRAMPath"]]];
|
||||
[slot2WindowDelegate selectDeviceByType:[[NSUserDefaults standardUserDefaults] integerForKey:@"Slot2_LoadedDevice"]];
|
||||
[slot2WindowDelegate applySettings:nil];
|
||||
[slot2WindowDelegate setupUserDefaults];
|
||||
|
||||
// Set up the rest of the emulation-related user defaults.
|
||||
[emuControl setupUserDefaults];
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
@property (retain) NSMutableDictionary *inputSettingsInEdit;
|
||||
|
||||
- (void) initSettingsSheets;
|
||||
- (void) loadSavedProfilesList;
|
||||
- (void) populateInputProfileMenu;
|
||||
|
||||
- (BOOL) handleKeyboardEvent:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed;
|
||||
|
|
|
@ -99,38 +99,7 @@
|
|||
[defaultProfilesList addObject:[reconstructedProfile autorelease]];
|
||||
}
|
||||
|
||||
NSArray *userDefaultsSavedProfilesList = (NSArray *)[[NSUserDefaults standardUserDefaults] arrayForKey:@"Input_SavedProfiles"];
|
||||
savedProfilesList = [[NSMutableArray alloc] initWithCapacity:32];
|
||||
|
||||
for (NSDictionary *theProfile in userDefaultsSavedProfilesList)
|
||||
{
|
||||
NSMutableDictionary *reconstructedProfile = [[NSMutableDictionary alloc] initWithCapacity:[theProfile count]];
|
||||
|
||||
for (NSString *profileKey in theProfile)
|
||||
{
|
||||
if ([profileKey isEqualToString:@"Mappings"])
|
||||
{
|
||||
NSDictionary *profileMappings = (NSDictionary *)[theProfile objectForKey:profileKey];
|
||||
NSMutableDictionary *reconstructedMappings = [[NSMutableDictionary alloc] initWithCapacity:[profileMappings count]];
|
||||
|
||||
for (NSString *mappingKey in profileMappings)
|
||||
{
|
||||
NSArray *inputList = (NSArray *)[profileMappings objectForKey:mappingKey];
|
||||
NSMutableArray *newInputList = [[NSMutableArray alloc] initWithArray:inputList copyItems:YES];
|
||||
[reconstructedMappings setObject:[newInputList autorelease] forKey:mappingKey];
|
||||
}
|
||||
|
||||
[reconstructedProfile setObject:[reconstructedMappings autorelease] forKey:profileKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
[reconstructedProfile setObject:[theProfile objectForKey:profileKey] forKey:profileKey];
|
||||
}
|
||||
}
|
||||
|
||||
[savedProfilesList addObject:[reconstructedProfile autorelease]];
|
||||
}
|
||||
|
||||
configInputTargetID = nil;
|
||||
configInputList = [[NSMutableDictionary alloc] initWithCapacity:128];
|
||||
inputSettingsInEdit = nil;
|
||||
|
@ -191,6 +160,41 @@
|
|||
nil];
|
||||
}
|
||||
|
||||
- (void) loadSavedProfilesList
|
||||
{
|
||||
NSArray *userDefaultsSavedProfilesList = (NSArray *)[[NSUserDefaults standardUserDefaults] arrayForKey:@"Input_SavedProfiles"];
|
||||
[savedProfilesList removeAllObjects];
|
||||
|
||||
for (NSDictionary *theProfile in userDefaultsSavedProfilesList)
|
||||
{
|
||||
NSMutableDictionary *reconstructedProfile = [[NSMutableDictionary alloc] initWithCapacity:[theProfile count]];
|
||||
|
||||
for (NSString *profileKey in theProfile)
|
||||
{
|
||||
if ([profileKey isEqualToString:@"Mappings"])
|
||||
{
|
||||
NSDictionary *profileMappings = (NSDictionary *)[theProfile objectForKey:profileKey];
|
||||
NSMutableDictionary *reconstructedMappings = [[NSMutableDictionary alloc] initWithCapacity:[profileMappings count]];
|
||||
|
||||
for (NSString *mappingKey in profileMappings)
|
||||
{
|
||||
NSArray *inputList = (NSArray *)[profileMappings objectForKey:mappingKey];
|
||||
NSMutableArray *newInputList = [[NSMutableArray alloc] initWithArray:inputList copyItems:YES];
|
||||
[reconstructedMappings setObject:[newInputList autorelease] forKey:mappingKey];
|
||||
}
|
||||
|
||||
[reconstructedProfile setObject:[reconstructedMappings autorelease] forKey:profileKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
[reconstructedProfile setObject:[theProfile objectForKey:profileKey] forKey:profileKey];
|
||||
}
|
||||
}
|
||||
|
||||
[savedProfilesList addObject:[reconstructedProfile autorelease]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) populateInputProfileMenu
|
||||
{
|
||||
NSDictionary *defaultKeyMappingsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]];
|
||||
|
|
|
@ -116,5 +116,8 @@
|
|||
- (void) didEndFirmwareConfigSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
|
||||
|
||||
- (void) switchContentView:(NSView *)theView;
|
||||
- (void) updateVideoFilterPreview:(const NSInteger)vfType;
|
||||
- (void) updateBilinearPreview:(const BOOL)useBilinear;
|
||||
- (void) setupUserDefaults;
|
||||
|
||||
@end
|
||||
|
|
|
@ -71,47 +71,26 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
VideoFilterTypeID vfType = (VideoFilterTypeID)[[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_VideoFilter"];
|
||||
NSImage *videoFilterImage = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"VideoFilterPreview_64x64" ofType:@"png"]];
|
||||
|
||||
videoFilter = [[CocoaVideoFilter alloc] initWithSize:[videoFilterImage size] typeID:vfType];
|
||||
NSSize vfDestSize = [videoFilter destSize];
|
||||
NSUInteger vfWidth = (NSUInteger)vfDestSize.width;
|
||||
NSUInteger vfHeight = (NSUInteger)vfDestSize.height;
|
||||
|
||||
NSArray *imageRepArray = [videoFilterImage representations];
|
||||
// Load the preview image.
|
||||
NSImage *previewImage = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"VideoFilterPreview_64x64" ofType:@"png"]];
|
||||
NSArray *imageRepArray = [previewImage representations];
|
||||
const NSBitmapImageRep *imageRep = [imageRepArray objectAtIndex:0];
|
||||
RGBA8888ForceOpaqueBuffer((const uint32_t *)[imageRep bitmapData], (uint32_t *)[videoFilter srcBufferPtr], (64 * 64));
|
||||
[videoFilterImage release];
|
||||
const NSSize previewImageSize = [previewImage size];
|
||||
|
||||
BOOL useBilinear = [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_UseBilinearOutput"];
|
||||
// Create our video filters for preview.
|
||||
videoFilter = [[CocoaVideoFilter alloc] initWithSize:previewImageSize typeID:VideoFilterTypeID_Nearest2X];
|
||||
bilinearVideoFilter = [[CocoaVideoFilter alloc] initWithSize:[videoFilter destSize] typeID:VideoFilterTypeID_Nearest2X];
|
||||
|
||||
if (vfWidth <= 64 || vfHeight <= 64)
|
||||
{
|
||||
[videoFilter changeFilter:VideoFilterTypeID_Nearest2X];
|
||||
vfDestSize = [videoFilter destSize];
|
||||
vfWidth = (NSUInteger)vfDestSize.width;
|
||||
vfHeight = (NSUInteger)vfDestSize.height;
|
||||
|
||||
bilinearVideoFilter = [[CocoaVideoFilter alloc] initWithSize:vfDestSize typeID:(useBilinear) ? VideoFilterTypeID_Bilinear : VideoFilterTypeID_Nearest2X];
|
||||
}
|
||||
else if (vfWidth >= 256 || vfHeight >= 256)
|
||||
{
|
||||
bilinearVideoFilter = [[CocoaVideoFilter alloc] initWithSize:vfDestSize typeID:VideoFilterTypeID_None];
|
||||
}
|
||||
else
|
||||
{
|
||||
bilinearVideoFilter = [[CocoaVideoFilter alloc] initWithSize:vfDestSize typeID:(useBilinear) ? VideoFilterTypeID_Bilinear : VideoFilterTypeID_Nearest2X];
|
||||
}
|
||||
// Copy the preview image data into the video filter source buffer, then release it.
|
||||
RGBA8888ForceOpaqueBuffer((const uint32_t *)[imageRep bitmapData], (uint32_t *)[videoFilter srcBufferPtr], (size_t)previewImageSize.width * (size_t)previewImageSize.height);
|
||||
[self updateVideoFilterPreview:VideoFilterTypeID_None];
|
||||
[previewImage release];
|
||||
|
||||
RGBA8888ForceOpaqueBuffer((const uint32_t *)[videoFilter runFilter], (uint32_t *)[bilinearVideoFilter srcBufferPtr], (vfWidth * vfHeight));
|
||||
[bindings setObject:[bilinearVideoFilter image] forKey:@"VideoFilterPreviewImage"];
|
||||
|
||||
// Load the volume icons.
|
||||
iconVolumeFull = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_VolumeFull_16x16" ofType:@"png"]];
|
||||
iconVolumeTwoThird = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_VolumeTwoThird_16x16" ofType:@"png"]];
|
||||
iconVolumeOneThird = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_VolumeOneThird_16x16" ofType:@"png"]];
|
||||
iconVolumeMute = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_VolumeMute_16x16" ofType:@"png"]];
|
||||
|
||||
[bindings setObject:iconVolumeFull forKey:@"volumeIconImage"];
|
||||
|
||||
prefViewDict = nil;
|
||||
|
@ -127,6 +106,7 @@
|
|||
[iconVolumeMute release];
|
||||
[bindings release];
|
||||
[videoFilter release];
|
||||
[bilinearVideoFilter release];
|
||||
[prefViewDict release];
|
||||
|
||||
[super dealloc];
|
||||
|
@ -384,114 +364,49 @@
|
|||
|
||||
- (IBAction) setUseBilinear:(id)sender
|
||||
{
|
||||
const BOOL useBilinear = [CocoaDSUtil getIBActionSenderButtonStateBool:sender];
|
||||
const NSUInteger previewSrcWidth = (NSUInteger)[bilinearVideoFilter srcSize].width;
|
||||
const NSUInteger previewSrcHeight = (NSUInteger)[bilinearVideoFilter srcSize].height;
|
||||
|
||||
if (previewSrcWidth <= 128 || previewSrcHeight <= 128)
|
||||
{
|
||||
[bilinearVideoFilter changeFilter:(useBilinear) ? VideoFilterTypeID_Bilinear : VideoFilterTypeID_Nearest2X];
|
||||
}
|
||||
|
||||
NSBitmapImageRep *newPreviewImageRep = [bilinearVideoFilter bitmapImageRep];
|
||||
|
||||
NSImage *videoFilterPreviewImage = [bindings objectForKey:@"VideoFilterPreviewImage"];
|
||||
NSArray *imageRepArray = [videoFilterPreviewImage representations];
|
||||
NSImageRep *oldImageRep = [imageRepArray objectAtIndex:0];
|
||||
[videoFilterPreviewImage removeRepresentation:oldImageRep];
|
||||
[videoFilterPreviewImage addRepresentation:newPreviewImageRep];
|
||||
|
||||
const BOOL useBilinear = [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_UseBilinearOutput"];
|
||||
[self updateBilinearPreview:useBilinear];
|
||||
[previewImageView setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (IBAction) selectVideoFilterType:(id)sender
|
||||
{
|
||||
const VideoFilterTypeID vfType = (VideoFilterTypeID)[CocoaDSUtil getIBActionSenderTag:sender];
|
||||
const BOOL useBilinear = [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_UseBilinearOutput"];
|
||||
|
||||
const NSInteger vfType = [CocoaDSUtil getIBActionSenderTag:sender];
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:vfType forKey:@"DisplayView_VideoFilter"];
|
||||
|
||||
[videoFilter changeFilter:vfType];
|
||||
NSSize vfDestSize = [videoFilter destSize];
|
||||
NSUInteger vfWidth = (NSUInteger)[videoFilter destSize].width;
|
||||
NSUInteger vfHeight = (NSUInteger)[videoFilter destSize].height;
|
||||
|
||||
if (vfWidth <= 64 || vfHeight <= 64)
|
||||
{
|
||||
[videoFilter changeFilter:VideoFilterTypeID_Nearest2X];
|
||||
vfDestSize = [videoFilter destSize];
|
||||
vfWidth = (NSUInteger)vfDestSize.width;
|
||||
vfHeight = (NSUInteger)vfDestSize.height;
|
||||
|
||||
[bilinearVideoFilter setSourceSize:vfDestSize];
|
||||
[bilinearVideoFilter changeFilter:(useBilinear) ? VideoFilterTypeID_Bilinear : VideoFilterTypeID_Nearest2X];
|
||||
}
|
||||
else if (vfWidth >= 256 || vfHeight >= 256)
|
||||
{
|
||||
[bilinearVideoFilter setSourceSize:vfDestSize];
|
||||
[bilinearVideoFilter changeFilter:VideoFilterTypeID_None];
|
||||
}
|
||||
else
|
||||
{
|
||||
[bilinearVideoFilter setSourceSize:vfDestSize];
|
||||
[bilinearVideoFilter changeFilter:(useBilinear) ? VideoFilterTypeID_Bilinear : VideoFilterTypeID_Nearest2X];
|
||||
}
|
||||
|
||||
RGBA8888ForceOpaqueBuffer((const uint32_t *)[videoFilter runFilter], (uint32_t *)[bilinearVideoFilter srcBufferPtr], (vfWidth * vfHeight));
|
||||
NSBitmapImageRep *newPreviewImageRep = [bilinearVideoFilter bitmapImageRep];
|
||||
|
||||
NSImage *videoFilterPreviewImage = [bindings objectForKey:@"VideoFilterPreviewImage"];
|
||||
NSArray *imageRepArray = [videoFilterPreviewImage representations];
|
||||
NSImageRep *oldImageRep = [imageRepArray objectAtIndex:0];
|
||||
[videoFilterPreviewImage removeRepresentation:oldImageRep];
|
||||
[videoFilterPreviewImage addRepresentation:newPreviewImageRep];
|
||||
|
||||
[self updateVideoFilterPreview:vfType];
|
||||
[previewImageView setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (IBAction) updateVolumeIcon:(id)sender
|
||||
{
|
||||
NSImage *iconImage = (NSImage *)[bindings objectForKey:@"volumeIconImage"];
|
||||
NSImage *newIconImage = nil;
|
||||
const float vol = [[NSUserDefaults standardUserDefaults] floatForKey:@"Sound_Volume"];
|
||||
|
||||
if (vol <= 0.0f)
|
||||
{
|
||||
if (iconImage == iconVolumeMute)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iconImage = iconVolumeMute;
|
||||
newIconImage = iconVolumeMute;
|
||||
}
|
||||
else if (vol > 0.0f && vol <= VOLUME_THRESHOLD_LOW)
|
||||
{
|
||||
if (iconImage == iconVolumeOneThird)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iconImage = iconVolumeOneThird;
|
||||
newIconImage = iconVolumeOneThird;
|
||||
}
|
||||
else if (vol > VOLUME_THRESHOLD_LOW && vol <= VOLUME_THRESHOLD_HIGH)
|
||||
{
|
||||
if (iconImage == iconVolumeTwoThird)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iconImage = iconVolumeTwoThird;
|
||||
newIconImage = iconVolumeTwoThird;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iconImage == iconVolumeFull)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iconImage = iconVolumeFull;
|
||||
newIconImage = iconVolumeFull;
|
||||
}
|
||||
|
||||
[bindings setObject:iconImage forKey:@"volumeIconImage"];
|
||||
if (newIconImage == iconImage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
[bindings setObject:newIconImage forKey:@"volumeIconImage"];
|
||||
}
|
||||
|
||||
- (IBAction) selectSPUSyncMode:(id)sender
|
||||
|
@ -736,6 +651,112 @@
|
|||
[tempView release];
|
||||
}
|
||||
|
||||
- (void) updateVideoFilterPreview:(const NSInteger)vfType
|
||||
{
|
||||
const BOOL useBilinear = [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayView_UseBilinearOutput"];
|
||||
|
||||
[videoFilter changeFilter:(VideoFilterTypeID)vfType];
|
||||
const NSUInteger previewWidth = (NSUInteger)[videoFilter destSize].width;
|
||||
const NSUInteger previewHeight = (NSUInteger)[videoFilter destSize].height;
|
||||
|
||||
if (previewWidth <= 64 || previewHeight <= 64)
|
||||
{
|
||||
[videoFilter changeFilter:VideoFilterTypeID_Nearest2X];
|
||||
}
|
||||
|
||||
[videoFilter runFilter];
|
||||
[self updateBilinearPreview:useBilinear];
|
||||
}
|
||||
|
||||
- (void) updateBilinearPreview:(const BOOL)useBilinear
|
||||
{
|
||||
const NSUInteger previewWidth = (NSUInteger)[videoFilter destSize].width;
|
||||
const NSUInteger previewHeight = (NSUInteger)[videoFilter destSize].height;
|
||||
|
||||
if (previewWidth <= 128 || previewHeight <= 128)
|
||||
{
|
||||
[bilinearVideoFilter changeFilter:(useBilinear) ? VideoFilterTypeID_Bilinear : VideoFilterTypeID_Nearest2X];
|
||||
}
|
||||
else
|
||||
{
|
||||
[bilinearVideoFilter changeFilter:VideoFilterTypeID_None];
|
||||
}
|
||||
|
||||
[bilinearVideoFilter setSourceSize:[videoFilter destSize]];
|
||||
memcpy([bilinearVideoFilter srcBufferPtr], [videoFilter dstBufferPtr], previewWidth * previewHeight * sizeof(uint32_t));
|
||||
[bindings setObject:[bilinearVideoFilter image] forKey:@"VideoFilterPreviewImage"];
|
||||
}
|
||||
|
||||
- (void) setupUserDefaults
|
||||
{
|
||||
// Update input preferences.
|
||||
[viewInput loadSavedProfilesList];
|
||||
|
||||
// Update the SPU Sync controls in the Preferences window.
|
||||
if ([[NSUserDefaults standardUserDefaults] integerForKey:@"SPU_SyncMode"] == SPU_SYNC_MODE_DUAL_SYNC_ASYNC)
|
||||
{
|
||||
[[self spuSyncMethodMenu] setEnabled:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[self spuSyncMethodMenu] setEnabled:YES];
|
||||
}
|
||||
|
||||
// Set the menu for the display rotation.
|
||||
const double displayRotation = (double)[[NSUserDefaults standardUserDefaults] floatForKey:@"DisplayView_Rotation"];
|
||||
[self updateDisplayRotationMenu:displayRotation];
|
||||
|
||||
// Set the default sound volume per user preferences.
|
||||
[self updateVolumeIcon:nil];
|
||||
|
||||
// Set the default video filter per user preferences.
|
||||
const NSInteger vfType = [[NSUserDefaults standardUserDefaults] integerForKey:@"DisplayView_VideoFilter"];
|
||||
[self updateVideoFilterPreview:vfType];
|
||||
|
||||
// Set up file paths.
|
||||
NSString *arm7BiosImagePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"BIOS_ARM7ImagePath"];
|
||||
if (arm7BiosImagePath != nil)
|
||||
{
|
||||
[bindings setValue:[arm7BiosImagePath lastPathComponent] forKey:@"Arm7BiosImageName"];
|
||||
}
|
||||
|
||||
NSString *arm9BiosImagePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"BIOS_ARM9ImagePath"];
|
||||
if (arm9BiosImagePath != nil)
|
||||
{
|
||||
[bindings setValue:[arm9BiosImagePath lastPathComponent] forKey:@"Arm9BiosImageName"];
|
||||
}
|
||||
|
||||
NSString *firmwareImagePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"Emulation_FirmwareImagePath"];
|
||||
if (firmwareImagePath != nil)
|
||||
{
|
||||
[bindings setValue:[firmwareImagePath lastPathComponent] forKey:@"FirmwareImageName"];
|
||||
}
|
||||
|
||||
NSString *advansceneDatabasePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"Advanscene_DatabasePath"];
|
||||
if (advansceneDatabasePath != nil)
|
||||
{
|
||||
[bindings setValue:[advansceneDatabasePath lastPathComponent] forKey:@"AdvansceneDatabaseName"];
|
||||
}
|
||||
|
||||
NSString *cheatDatabasePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"R4Cheat_DatabasePath"];
|
||||
if (cheatDatabasePath != nil)
|
||||
{
|
||||
[bindings setValue:[cheatDatabasePath lastPathComponent] forKey:@"R4CheatDatabaseName"];
|
||||
}
|
||||
|
||||
NSString *autoloadRomPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"General_AutoloadROMSelectedPath"];
|
||||
if (autoloadRomPath != nil)
|
||||
{
|
||||
[bindings setValue:[autoloadRomPath lastPathComponent] forKey:@"AutoloadRomName"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[bindings setValue:NSSTRING_STATUS_NO_ROM_CHOSEN forKey:@"AutoloadRomName"];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark NSWindowDelegate Protocol
|
||||
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification
|
||||
{
|
||||
[prefWindowController setContent:bindings];
|
||||
|
|
Loading…
Reference in New Issue