Permalink
Browse files

restore sprite sheet window

  • Loading branch information...
1 parent 17f5ccb commit 6d7cc66c951ca4b633a421ad322b092dd2063f77 @mattrajca mattrajca committed Sep 22, 2012
@@ -5,7 +5,7 @@
// Copyright 2005-2012 Pixen Project. All rights reserved.
//
-@interface PXSpriteSheetExporter : NSWindowController < NSTableViewDataSource >
+@interface PXSpriteSheetExporter : NSWindowController < NSTableViewDataSource, NSWindowDelegate, NSWindowRestoration >
{
@private
BOOL closeOnEndSheet;
@@ -15,7 +15,7 @@
@property (nonatomic, strong) IBOutlet NSArrayController *documentRepresentationsController;
-+ (id)sharedSpriteSheetExporter;
++ (PXSpriteSheetExporter *)sharedSpriteSheetExporter;
- (IBAction)export:(id)sender;
@@ -20,7 +20,7 @@ @implementation PXSpriteSheetExporter
static NSString *const kSpriteSheetEntry = @"SpriteSheetEntry";
-+ (id)sharedSpriteSheetExporter
++ (PXSpriteSheetExporter *)sharedSpriteSheetExporter
{
static PXSpriteSheetExporter *sharedSpriteSheetExporter = nil;
static dispatch_once_t onceToken;
@@ -236,13 +236,26 @@ - (IBAction)updatePreview:(id)sender
- (void)windowDidLoad
{
+ [[self window] setDelegate:self];
+
[self recacheDocumentRepresentations];
+
+ [[self window] setRestorationClass:[self class]];
}
-- (void)showWindow:(id)sender
++ (void)restoreWindowWithIdentifier:(NSString *)identifier state:(NSCoder *)state completionHandler:(void (^)(NSWindow *, NSError *))completionHandler {
+
+ if ([identifier isEqualToString:@"SpriteSheetWindow"]) {
+ completionHandler([PXSpriteSheetExporter sharedSpriteSheetExporter].window, nil);
+ }
+ else {
+ completionHandler(nil, nil);
+ }
+}
+
+- (void)windowDidBecomeMain:(NSNotification *)notification
{
- [super showWindow:sender];
- [self updatePreview:self];
+ [self updatePreview:nil];
}
- (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(NSInteger)returnCode

0 comments on commit 6d7cc66

Please sign in to comment.