OS X: Have the memory card images be represented as gif files.
This makes it less of a chore handling the animation, as the OS will do it automatically for us now. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@91357 e17a0e51-4ae3-4d35-97c3-1a29b211df97
This commit is contained in:
parent
20b807f045
commit
b96092d6fb
|
@ -102,7 +102,7 @@ static OSStatus GeneratePreviewForMemCard(void *thisInterface, QLPreviewRequestR
|
|||
NSDictionary *gifPrep = @{(NSString *) kCGImagePropertyGIFDictionary: @{(NSString *) kCGImagePropertyGIFDelayTime: @0.30f}};
|
||||
|
||||
for (PcsxrMemoryObject *obj in memCards) {
|
||||
if (obj.memImageIndex == -1 || obj.memIconCount == 1) {
|
||||
if (!obj.hasImages || obj.memIconCount == 1) {
|
||||
NSMutableData *pngData = [NSMutableData new];
|
||||
{
|
||||
CGImageDestinationRef dst = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)pngData, kUTTypePNG, 1, NULL);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6185.7" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6206.9" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1080" identifier="macosx"/>
|
||||
<development version="5100" identifier="xcode"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6185.7"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6206.9"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="ConfigurationController">
|
||||
|
@ -34,7 +34,7 @@
|
|||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="PCSXR Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" visibleAtLaunch="NO" animationBehavior="documentWindow" id="21">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" topStrut="YES"/>
|
||||
|
@ -1162,7 +1162,7 @@
|
|||
<constraint firstAttribute="width" constant="48" id="kIh-n8-gJw"/>
|
||||
<constraint firstAttribute="height" constant="48" id="vPq-qO-hYs"/>
|
||||
</constraints>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSAdvanced" id="986"/>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageScaling="proportionallyUpOrDown" image="NSAdvanced" id="986"/>
|
||||
<connections>
|
||||
<binding destination="958" name="value" keyPath="representedObject.memImage" id="1057"/>
|
||||
</connections>
|
||||
|
|
|
@ -169,16 +169,6 @@ NSString *const memCardChangeNumberKey = @"PcsxrMemoryCardThatChangedKey";
|
|||
}
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification
|
||||
{
|
||||
[memCardEdit stopMemoryAnimation];
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeMain:(NSNotification *)notification
|
||||
{
|
||||
[memCardEdit beginMemoryAnimation];
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
|
|
@ -24,7 +24,4 @@
|
|||
- (IBAction)deleteMemoryObject:(id)sender;
|
||||
- (void)loadMemoryCardInfoForCard:(int)theCard;
|
||||
|
||||
- (void)beginMemoryAnimation;
|
||||
- (void)stopMemoryAnimation;
|
||||
|
||||
@end
|
||||
|
|
|
@ -18,27 +18,12 @@
|
|||
@interface PcsxrMemCardController ()
|
||||
@property (readwrite, strong) PcsxrMemCardArray *memCard1Array;
|
||||
@property (readwrite, strong) PcsxrMemCardArray *memCard2Array;
|
||||
@property (strong) NSTimer *imageAnimateTimer;
|
||||
@end
|
||||
|
||||
@implementation PcsxrMemCardController
|
||||
@synthesize memCard1Array;
|
||||
@synthesize memCard2Array;
|
||||
|
||||
- (void)stopMemoryAnimation
|
||||
{
|
||||
[self.imageAnimateTimer invalidate];
|
||||
self.imageAnimateTimer = nil;
|
||||
}
|
||||
|
||||
- (void)beginMemoryAnimation
|
||||
{
|
||||
if (!_imageAnimateTimer) {
|
||||
self.imageAnimateTimer = [[NSTimer alloc] initWithFireDate:[NSDate date] interval:0.30 target:self selector:@selector(animateMemCards:) userInfo:nil repeats:YES];
|
||||
[[NSRunLoop mainRunLoop] addTimer:self.imageAnimateTimer forMode:NSRunLoopCommonModes];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setupValues:(int)theCards
|
||||
{
|
||||
NSParameterAssert(theCards < 4 && theCards > 0);
|
||||
|
@ -97,13 +82,6 @@
|
|||
[self setupValues:3];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(memoryCardDidChangeNotification:) name:memChangeNotifier object:nil];
|
||||
|
||||
[self beginMemoryAnimation];
|
||||
}
|
||||
|
||||
- (void)animateMemCards:(NSTimer*)theTimer
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:memoryAnimateTimerKey object:self];
|
||||
}
|
||||
|
||||
- (IBAction)moveBlock:(id)sender
|
||||
|
@ -232,7 +210,6 @@
|
|||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[self.imageAnimateTimer invalidate];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
#include "sio.h"
|
||||
|
||||
extern NSString *const memoryAnimateTimerKey;
|
||||
|
||||
typedef NS_ENUM(char, PCSXRMemFlags) {
|
||||
memFlagDeleted,
|
||||
memFlagFree,
|
||||
|
@ -35,13 +33,13 @@ typedef NS_ENUM(char, PCSXRMemFlags) {
|
|||
@property (readonly, strong) NSString *memName;
|
||||
@property (readonly, strong) NSString *memID;
|
||||
@property (readonly, strong) NSArray *memoryCardImages;
|
||||
@property (readonly, nonatomic) NSInteger memImageIndex;
|
||||
@property (readonly, strong, nonatomic) NSImage *memImage;
|
||||
@property (readonly) PCSXRMemFlags flagNameIndex;
|
||||
@property (readonly) uint8_t startingIndex;
|
||||
@property (readonly) uint8_t blockSize;
|
||||
@property (readonly) BOOL hasImages;
|
||||
|
||||
@property (readonly, copy) NSImage *firstMemImage;
|
||||
@property (readonly, unsafe_unretained, nonatomic) NSImage *memImage;
|
||||
@property (readonly, nonatomic) NSUInteger memIconCount;
|
||||
@property (readonly, unsafe_unretained, nonatomic) NSString *flagName;
|
||||
@property (readonly, unsafe_unretained, nonatomic) NSAttributedString *attributedFlagName;
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
#import "PcsxrMemoryObject.h"
|
||||
|
||||
NSString *const memoryAnimateTimerKey = @"PCSXR Memory Card Image Animate";
|
||||
|
||||
@interface PcsxrMemoryObject ()
|
||||
@property (readwrite, strong) NSString *englishName;
|
||||
@property (readwrite, strong) NSString *sjisName;
|
||||
|
@ -19,9 +17,10 @@ NSString *const memoryAnimateTimerKey = @"PCSXR Memory Card Image Animate";
|
|||
@property (readwrite) uint8_t startingIndex;
|
||||
@property (readwrite) uint8_t blockSize;
|
||||
|
||||
@property (readwrite, nonatomic) NSInteger memImageIndex;
|
||||
@property (readwrite, strong) NSArray *memoryCardImages;
|
||||
@property (readwrite) PCSXRMemFlags flagNameIndex;
|
||||
@property (readwrite, nonatomic, strong) NSImage *memImage;
|
||||
@property (readwrite) BOOL hasImages;
|
||||
@end
|
||||
|
||||
@implementation PcsxrMemoryObject
|
||||
|
@ -76,7 +75,7 @@ static NSString *MemLabelEndLink;
|
|||
|
||||
- (NSImage*)memoryImageAtIndex:(NSInteger)idx
|
||||
{
|
||||
if (memImageIndex == -1 || idx > self.memIconCount) {
|
||||
if (!self.hasImages || idx > self.memIconCount) {
|
||||
return [PcsxrMemoryObject blankImage];
|
||||
}
|
||||
return memImages[idx];
|
||||
|
@ -152,7 +151,7 @@ static NSString *MemLabelEndLink;
|
|||
self.flagNameIndex = [PcsxrMemoryObject memFlagsFromBlockFlags:infoBlock->Flags];
|
||||
if (self.flagNameIndex == memFlagFree) {
|
||||
self.memoryCardImages = @[];
|
||||
self.memImageIndex = -1;
|
||||
self.hasImages = NO;
|
||||
self.englishName = self.sjisName = @"Free block";
|
||||
self.memID = self.memName = @"";
|
||||
} else {
|
||||
|
@ -171,18 +170,9 @@ static NSString *MemLabelEndLink;
|
|||
}
|
||||
|
||||
if ([memImages count] == 0) {
|
||||
self.memImageIndex = -1;
|
||||
} else if ([memImages count] == 1) {
|
||||
self.memImageIndex = 0;
|
||||
self.hasImages = NO;
|
||||
} else {
|
||||
self.memImageIndex = 0;
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:memoryAnimateTimerKey object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
NSInteger index = memImageIndex;
|
||||
if (++index >= [memImages count]) {
|
||||
index = 0;
|
||||
}
|
||||
self.memImageIndex = index;
|
||||
}];
|
||||
self.hasImages = YES;
|
||||
}
|
||||
self.memName = @(infoBlock->Name);
|
||||
self.memID = @(infoBlock->ID);
|
||||
|
@ -194,20 +184,13 @@ static NSString *MemLabelEndLink;
|
|||
#pragma mark - Property Synthesizers
|
||||
@synthesize englishName;
|
||||
@synthesize sjisName;
|
||||
@synthesize memImageIndex;
|
||||
- (void)setMemImageIndex:(NSInteger)theMemImageIndex
|
||||
{
|
||||
[self willChangeValueForKey:@"memImage"];
|
||||
memImageIndex = theMemImageIndex;
|
||||
[self didChangeValueForKey:@"memImage"];
|
||||
}
|
||||
|
||||
@synthesize memName;
|
||||
@synthesize memID;
|
||||
@synthesize memoryCardImages = memImages;
|
||||
@synthesize flagNameIndex;
|
||||
@synthesize blockSize;
|
||||
@synthesize startingIndex;
|
||||
@synthesize memImage = _memImage;
|
||||
|
||||
#pragma mark Non-synthesized Properties
|
||||
- (NSUInteger)memIconCount
|
||||
|
@ -217,7 +200,7 @@ static NSString *MemLabelEndLink;
|
|||
|
||||
- (NSImage*)firstMemImage
|
||||
{
|
||||
if (memImageIndex == -1) {
|
||||
if (self.hasImages == NO) {
|
||||
return [PcsxrMemoryObject blankImage];
|
||||
}
|
||||
return memImages[0];
|
||||
|
@ -225,10 +208,25 @@ static NSString *MemLabelEndLink;
|
|||
|
||||
- (NSImage*)memImage
|
||||
{
|
||||
if (memImageIndex == -1) {
|
||||
if (self.hasImages == NO) {
|
||||
return [PcsxrMemoryObject blankImage];
|
||||
}
|
||||
return memImages[memImageIndex];
|
||||
|
||||
if (!_memImage) {
|
||||
NSMutableData *gifData = [NSMutableData new];
|
||||
|
||||
CGImageDestinationRef dst = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)gifData, kUTTypeGIF, self.memIconCount, NULL);
|
||||
NSDictionary *gifPrep = @{(NSString *) kCGImagePropertyGIFDictionary: @{(NSString *) kCGImagePropertyGIFDelayTime: @0.30f}};
|
||||
for (NSImage *theImage in memImages) {
|
||||
CGImageRef imageRef = [theImage CGImageForProposedRect:NULL context:nil hints:nil];
|
||||
CGImageDestinationAddImage(dst, imageRef,(__bridge CFDictionaryRef)(gifPrep));
|
||||
}
|
||||
CGImageDestinationFinalize(dst);
|
||||
CFRelease(dst);
|
||||
|
||||
_memImage = [[NSImage alloc] initWithData:gifData];
|
||||
}
|
||||
return _memImage;
|
||||
}
|
||||
|
||||
- (NSString*)flagName
|
||||
|
|
Loading…
Reference in New Issue