From 180f0e16b02139f9b14c639431f6af79cc5f7c93 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 18 Jun 2016 17:43:39 +0300 Subject: [PATCH] Cocoa port now remembers the previous window size --- Cocoa/Document.h | 1 + Cocoa/Document.m | 8 ++++++++ Cocoa/Document.xib | 1 + 3 files changed, 10 insertions(+) diff --git a/Cocoa/Document.h b/Cocoa/Document.h index 869abe6..6a47aa7 100644 --- a/Cocoa/Document.h +++ b/Cocoa/Document.h @@ -6,6 +6,7 @@ @property (strong) IBOutlet NSTextView *consoleOutput; @property (strong) IBOutlet NSPanel *consoleWindow; @property (strong) IBOutlet NSTextField *consoleInput; +@property (strong) IBOutlet NSWindow *mainWindow; @end diff --git a/Cocoa/Document.m b/Cocoa/Document.m index df5b007..ea4f765 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -173,6 +173,12 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, unsigned char r, unsigned char g, un self.consoleOutput.textContainerInset = NSMakeSize(4, 4); [self.view becomeFirstResponder]; self.view.shouldBlendFrameWithPrevious = ![[NSUserDefaults standardUserDefaults] boolForKey:@"DisableFrameBlending"]; + CGRect window_frame = self.mainWindow.frame; + window_frame.size.width = MAX([[NSUserDefaults standardUserDefaults] integerForKey:@"LastWindowWidth"], + window_frame.size.width); + window_frame.size.height = MAX([[NSUserDefaults standardUserDefaults] integerForKey:@"LastWindowHeight"], + window_frame.size.height); + [self.mainWindow setFrame:window_frame display:YES]; [self start]; } @@ -199,6 +205,8 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, unsigned char r, unsigned char g, un - (void)close { + [[NSUserDefaults standardUserDefaults] setInteger:self.mainWindow.frame.size.width forKey:@"LastWindowWidth"]; + [[NSUserDefaults standardUserDefaults] setInteger:self.mainWindow.frame.size.height forKey:@"LastWindowHeight"]; [self stop]; [self.consoleWindow close]; [super close]; diff --git a/Cocoa/Document.xib b/Cocoa/Document.xib index d2cd3f9..b306689 100644 --- a/Cocoa/Document.xib +++ b/Cocoa/Document.xib @@ -9,6 +9,7 @@ +