diff --git a/desmume/src/cocoa/DefaultUserPrefs.plist b/desmume/src/cocoa/DefaultUserPrefs.plist index 2146924db..0142877f6 100644 Binary files a/desmume/src/cocoa/DefaultUserPrefs.plist and b/desmume/src/cocoa/DefaultUserPrefs.plist differ diff --git a/desmume/src/cocoa/translations/English.lproj/MainMenu.strings b/desmume/src/cocoa/translations/English.lproj/MainMenu.strings index 676a414c0..e42ab5697 100644 Binary files a/desmume/src/cocoa/translations/English.lproj/MainMenu.strings and b/desmume/src/cocoa/translations/English.lproj/MainMenu.strings differ diff --git a/desmume/src/cocoa/translations/English.lproj/MainMenu.xib b/desmume/src/cocoa/translations/English.lproj/MainMenu.xib index 8efc6bf81..e4f10ca4b 100644 --- a/desmume/src/cocoa/translations/English.lproj/MainMenu.xib +++ b/desmume/src/cocoa/translations/English.lproj/MainMenu.xib @@ -2,9 +2,9 @@ 1050 - 12D78 + 12E55 851 - 1187.37 + 1187.39 626.00 com.apple.InterfaceBuilder.CocoaPlugin @@ -2688,7 +2688,7 @@ YES - + 268 YES @@ -2707,6 +2707,7 @@ 268 {{175, 50}, {199, 21}} + YES 613417024 @@ -2725,6 +2726,7 @@ 268 {{376, 43}, {96, 32}} + YES 67108864 @@ -2746,6 +2748,7 @@ 268 {{15, 53}, {155, 17}} + YES 68157504 @@ -2763,6 +2766,7 @@ 268 {{15, 14}, {454, 28}} + YES 69206017 @@ -2779,10 +2783,12 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA {{1, 1}, {484, 81}} + {{17, 16}, {486, 97}} + {0, 0} 67108864 @@ -2821,6 +2827,7 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{148, 14}, {226, 21}} + YES 613417024 @@ -2839,6 +2846,7 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{376, 7}, {96, 32}} + YES 67108864 @@ -2860,6 +2868,7 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{15, 17}, {128, 17}} + YES 68157504 @@ -2875,10 +2884,12 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA {{1, 1}, {484, 45}} + {{17, 117}, {486, 61}} + {0, 0} 67108864 @@ -2912,6 +2923,7 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{92, 12}, {314, 18}} + YES 67108864 @@ -2940,6 +2952,7 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{141, 33}, {217, 32}} + YES 67108864 @@ -2959,10 +2972,12 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA {{1, 1}, {484, 75}} + {{17, 182}, {486, 91}} + {0, 0} 67108864 @@ -2996,11 +3011,12 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{16, 111}, {366, 18}} + YES -2080374784 0 - Automatically Execute Emulation When Loading a ROM + Automatically execute emulation when loading a ROM 1211912448 @@ -3014,16 +3030,41 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA NO + + + 268 + {{16, 133}, {247, 18}} + + + YES + + -2080374784 + 0 + Restore display windows on startup + + + 1211912448 + 2 + + + + + 200 + 25 + + NO + 268 - {{16, 71}, {274, 18}} + {{16, 71}, {254, 18}} + YES 67108864 0 - Automatically Load a ROM Upon Launch + Automatically load a ROM on startup 1211912448 @@ -3042,6 +3083,7 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{34, 41}, {227, 26}} + YES -2076180416 @@ -3099,6 +3141,7 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{114, 14}, {260, 21}} + YES 613417024 @@ -3117,6 +3160,7 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{376, 7}, {96, 32}} + YES 67108864 @@ -3138,6 +3182,7 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXA268 {{15, 17}, {94, 17}} + YES 68157504 @@ -3151,17 +3196,19 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXANO - {{1, 1}, {484, 137}} + {{1, 1}, {484, 159}} + - {{17, 277}, {486, 153}} + {{17, 277}, {486, 175}} + {0, 0} 67108864 0 - ROM Behavior + General Behavior @@ -3176,7 +3223,9 @@ L3d3dy5hZHZhbnNjZW5lLmNvbS9vZmZsaW5lL2RhdGFzL0FEVkFOc0NFbmVfUlRvb2xEUy56aXANO - {520, 450} + {520, 472} + + NSView @@ -14002,7 +14051,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {1.7976931348623157e+308, 1.7976931348623157e+308} - + 256 YES @@ -14011,7 +14060,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{14, 12}, {168, 32}} - YES 67108864 @@ -14033,7 +14081,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{181, 22}, {105, 17}} - YES 68157504 @@ -14051,7 +14098,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 12 {{12, 51}, {616, 5}} - {0, 0} 67108864 @@ -14074,7 +14120,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{288, 22}, {330, 17}} - YES 70254657 @@ -14103,7 +14148,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{18, 14}, {260, 128}} - YES NO 5 @@ -14336,7 +14380,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{85, 15}, {409, 21}} - YES 78643265 @@ -14356,7 +14399,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{496, 8}, {96, 32}} - YES 67108864 @@ -14378,7 +14420,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{15, 150}, {482, 28}} - YES 67108864 @@ -14399,7 +14440,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{496, 146}, {96, 32}} - YES 67108864 @@ -14419,12 +14459,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{1, 1}, {604, 188}} - {{17, 140}, {606, 204}} - {0, 0} 67108864 @@ -14470,7 +14508,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{18, 16}, {30, 30}} - YES 134217728 @@ -14489,7 +14526,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 265 {{50, 18}, {168, 28}} - YES 69206017 @@ -14507,7 +14543,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 1292 {{18, 14}, {32, 32}} - 28682 100 @@ -14516,7 +14551,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 {{220, 17}, {201, 26}} - YES -2076180416 @@ -14623,12 +14657,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {{1, 1}, {604, 56}} - {{17, 64}, {606, 72}} - {0, 0} 67108864 @@ -14649,8 +14681,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {640, 355} - - {{0, 0}, {1920, 1178}} {1.7976931348623157e+308, 1.7976931348623157e+308} @@ -23151,6 +23181,11 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES + + YES + General_WillRestoreWindows + General_WillRestoreDisplayWindows + YES @@ -32951,6 +32986,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 8299 + + + value: values.General_WillRestoreDisplayWindows + + + + + + value: values.General_WillRestoreDisplayWindows + value + values.General_WillRestoreDisplayWindows + 2 + + + 8306 + @@ -34617,12 +34668,13 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES + - + @@ -44847,6 +44899,20 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA + + 8302 + + + YES + + + + + + 8303 + + + @@ -44899,6 +44965,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 1298.IBPluginDependency 1299.IBAttributePlaceholdersKey 1299.IBPluginDependency + 1299.IBViewBoundsToFrameTransform 130.IBPluginDependency 1300.IBPluginDependency 131.IBPluginDependency @@ -44926,14 +44993,19 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 1531.IBPluginDependency 1532.IBPluginDependency 1538.IBPluginDependency + 1538.IBViewBoundsToFrameTransform 1539.IBPluginDependency + 1539.IBViewBoundsToFrameTransform 1540.IBPluginDependency 1541.IBPluginDependency + 1541.IBViewBoundsToFrameTransform 1542.IBPluginDependency + 1543.IBEditorWindowLastContentRect 1543.IBPluginDependency 1544.IBPluginDependency 1545.IBPluginDependency 1547.IBPluginDependency + 1547.IBViewBoundsToFrameTransform 1548.IBPluginDependency 1577.IBAttributePlaceholdersKey 1577.IBPluginDependency @@ -45046,6 +45118,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 2299.IBPluginDependency 23.IBPluginDependency 2320.IBPluginDependency + 2320.IBViewBoundsToFrameTransform 2321.IBPluginDependency 2327.IBPluginDependency 2328.IBPluginDependency @@ -45235,6 +45308,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 3061.IBPluginDependency 3062.IBPluginDependency 3063.IBPluginDependency + 3063.IBViewBoundsToFrameTransform 3146.IBPluginDependency 3148.IBPluginDependency 3204.IBPluginDependency @@ -45248,6 +45322,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 3213.IBPluginDependency 3214.IBPluginDependency 3285.IBPluginDependency + 3285.IBViewBoundsToFrameTransform 3286.IBPluginDependency 3456.IBPluginDependency 3456.IBWindowTemplateEditedContentRect @@ -45771,6 +45846,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 4947.IBPluginDependency 5.IBPluginDependency 5003.IBPluginDependency + 5003.IBViewBoundsToFrameTransform 5004.IBPluginDependency 5005.IBPluginDependency 5006.IBPluginDependency @@ -45821,6 +45897,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 5168.IBPluginDependency 5169.IBPluginDependency 5171.IBPluginDependency + 5171.IBViewBoundsToFrameTransform 5172.IBPluginDependency 5173.IBPluginDependency 5174.IBPluginDependency @@ -46600,6 +46677,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 8295.IBPluginDependency 83.IBPluginDependency 830.IBPluginDependency + 8302.IBAttributePlaceholdersKey + 8302.IBPluginDependency + 8302.IBViewBoundsToFrameTransform + 8303.IBPluginDependency 831.IBPluginDependency 832.IBPluginDependency 833.IBPluginDependency @@ -46760,7 +46841,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{343, 372}, {520, 450}} + {{296, 505}, {520, 472}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -46770,6 +46851,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABBgAAAwv4AAA + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -46811,14 +46895,27 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + AUGIAABDqAAAA + + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABBgAAAwq4AAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABCCAAAwoIAAA + + com.apple.InterfaceBuilder.CocoaPlugin + {{537, 693}, {227, 43}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABC5AAAwgQAAA + com.apple.InterfaceBuilder.CocoaPlugin ToolTip @@ -46973,6 +47070,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABDvAAAwhQAAA + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -47288,6 +47388,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + AUGIAABDNgAAA + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -47301,6 +47404,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABBcAAAwgAAAA + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin {{1241, 208}, {335, 163}} @@ -48264,6 +48370,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + AUGIAABC6gAAA + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -48321,6 +48430,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + AUGIAABBgAAAA + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -49388,6 +49500,18 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + YES + + + YES + + + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABBqAAAwygAAA + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -49521,7 +49645,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 8301 + 8306 @@ -52363,7 +52487,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA {20, 20} {15, 15} {8, 8} - {128, 128} + {512, 512} {11, 11} {10, 3} {32, 32} diff --git a/desmume/src/cocoa/userinterface/DisplayWindowController.h b/desmume/src/cocoa/userinterface/DisplayWindowController.h index ba2c2960c..b8b1061df 100644 --- a/desmume/src/cocoa/userinterface/DisplayWindowController.h +++ b/desmume/src/cocoa/userinterface/DisplayWindowController.h @@ -70,7 +70,7 @@ GLubyte vtxIndexBuffer[12]; BOOL isShaderSupported; - unsigned int vtxBufferOffset; + size_t vtxBufferOffset; } @property (retain) InputManager *inputManager; diff --git a/desmume/src/cocoa/userinterface/DisplayWindowController.mm b/desmume/src/cocoa/userinterface/DisplayWindowController.mm index f6ba4d7f4..696848784 100644 --- a/desmume/src/cocoa/userinterface/DisplayWindowController.mm +++ b/desmume/src/cocoa/userinterface/DisplayWindowController.mm @@ -1119,7 +1119,7 @@ static std::tr1::unordered_map _screenMap [view setInputManager:[emuControl inputManager]]; [[emuControl windowList] addObject:self]; [emuControl updateAllWindowTitles]; - + // Set up the video output thread. cdsVideoOutput = [[CocoaDSDisplayVideo alloc] init]; [cdsVideoOutput setDelegate:view]; @@ -1220,10 +1220,6 @@ static std::tr1::unordered_map _screenMap [emuControl closeRom:nil]; shouldClose = NO; } - else // If no ROM is loaded, close the window and terminate the application. - { - [NSApp terminate:sender]; - } return shouldClose; } @@ -1236,6 +1232,18 @@ static std::tr1::unordered_map _screenMap [self setCdsVideoOutput:nil]; [[emuControl windowList] removeObject:self]; + + if ([[emuControl windowList] count] < 1) + { + if ([emuControl currentRom] != nil) + { + [emuControl closeRom:nil]; + } + + [NSApp terminate:[notification object]]; + return; + } + [emuControl updateAllWindowTitles]; } @@ -1316,6 +1324,8 @@ static std::tr1::unordered_map _screenMap return self; } + inputManager = nil; + // Initialize the OpenGL context NSOpenGLPixelFormatAttribute attributes[] = { NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24, @@ -1330,11 +1340,6 @@ static std::tr1::unordered_map _screenMap [format release]; cglDisplayContext = (CGLContextObj)[context CGLContextObj]; - CGLContextObj prevContext = CGLGetCurrentContext(); - CGLSetCurrentContext(cglDisplayContext); - [self startupOpenGL]; - CGLSetCurrentContext(prevContext); - _currentDisplayMode = DS_DISPLAY_TYPE_COMBO; _currentDisplayOrientation = DS_DISPLAY_ORIENTATION_VERTICAL; _currentGapScalar = 0.0f; @@ -1347,7 +1352,20 @@ static std::tr1::unordered_map _screenMap glTexBackSize = NSMakeSize(w, h); vtxBufferOffset = 0; - inputManager = nil; + [self updateDisplayVerticesUsingDisplayMode:_currentDisplayMode orientation:_currentDisplayOrientation gap:_currentGapScalar]; + [self updateTexCoordS:1.0f T:2.0f]; + + // Set up initial vertex elements + vtxIndexBuffer[0] = 0; vtxIndexBuffer[1] = 1; vtxIndexBuffer[2] = 2; + vtxIndexBuffer[3] = 2; vtxIndexBuffer[4] = 3; vtxIndexBuffer[5] = 0; + + vtxIndexBuffer[6] = 4; vtxIndexBuffer[7] = 5; vtxIndexBuffer[8] = 6; + vtxIndexBuffer[9] = 6; vtxIndexBuffer[10] = 7; vtxIndexBuffer[11] = 4; + + CGLContextObj prevContext = CGLGetCurrentContext(); + CGLSetCurrentContext(cglDisplayContext); + [self startupOpenGL]; + CGLSetCurrentContext(prevContext); return self; } @@ -1373,16 +1391,6 @@ static std::tr1::unordered_map _screenMap - (void) startupOpenGL { - [self updateDisplayVerticesUsingDisplayMode:_currentDisplayMode orientation:_currentDisplayOrientation gap:_currentGapScalar]; - [self updateTexCoordS:1.0f T:2.0f]; - - // Set up initial vertex elements - vtxIndexBuffer[0] = 0; vtxIndexBuffer[1] = 1; vtxIndexBuffer[2] = 2; - vtxIndexBuffer[3] = 2; vtxIndexBuffer[4] = 3; vtxIndexBuffer[5] = 0; - - vtxIndexBuffer[6] = 4; vtxIndexBuffer[7] = 5; vtxIndexBuffer[8] = 6; - vtxIndexBuffer[9] = 6; vtxIndexBuffer[10] = 7; vtxIndexBuffer[11] = 4; - // Check the OpenGL capabilities for this renderer const GLubyte *glExtString = glGetString(GL_EXTENSIONS); @@ -1795,7 +1803,7 @@ static std::tr1::unordered_map _screenMap const size_t inputCount = inputList.size(); - for (unsigned int i = 0; i < inputCount; i++) + for (size_t i = 0; i < inputCount; i++) { const InputAttributes &inputAttr = inputList[i]; @@ -1943,7 +1951,6 @@ static std::tr1::unordered_map _screenMap [context update]; DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate]; [CocoaDSUtil messageSendOneWayWithRect:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_RESIZE_VIEW rect:rect]; - [self setNeedsDisplay:YES]; } } diff --git a/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm b/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm index c8b0e2881..2039798fe 100644 --- a/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm +++ b/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm @@ -430,8 +430,6 @@ - (IBAction) newDisplayWindow:(id)sender { DisplayWindowController *newWindowController = [[DisplayWindowController alloc] initWithWindowNibName:@"DisplayWindow" emuControlDelegate:self]; - [[newWindowController window] makeKeyAndOrderFront:self]; - [[newWindowController window] makeMainWindow]; if ([self currentRom] == nil) { @@ -441,6 +439,9 @@ { [[newWindowController view] setNeedsDisplay:YES]; } + + [[newWindowController window] makeKeyAndOrderFront:self]; + [[newWindowController window] makeMainWindow]; } - (IBAction) openRom:(id)sender diff --git a/desmume/src/cocoa/userinterface/appDelegate.h b/desmume/src/cocoa/userinterface/appDelegate.h index 03c4dd07c..fb789684d 100644 --- a/desmume/src/cocoa/userinterface/appDelegate.h +++ b/desmume/src/cocoa/userinterface/appDelegate.h @@ -95,5 +95,7 @@ - (NSMenuItem *) addSlotMenuItem:(NSMenu *)menu slotNumber:(NSUInteger)slotNumber; - (void) setupUserDefaults; - (void) setRomInfoPanelBoxTitleColors; +- (void) restoreDisplayWindowStates; +- (void) saveDisplayWindowStates; @end diff --git a/desmume/src/cocoa/userinterface/appDelegate.mm b/desmume/src/cocoa/userinterface/appDelegate.mm index 15dda2c8e..9d0eb8a3b 100644 --- a/desmume/src/cocoa/userinterface/appDelegate.mm +++ b/desmume/src/cocoa/userinterface/appDelegate.mm @@ -81,6 +81,7 @@ return self; } +#pragma mark NSApplicationDelegate Protocol - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename { BOOL result = NO; @@ -237,6 +238,10 @@ appFirstTimeRunDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:isFirstTimeRunNumber, bundleVersionString, nil]; } + //Bring the application to the front + [NSApp activateIgnoringOtherApps:TRUE]; + [self restoreDisplayWindowStates]; + // Load a new ROM on launch per user preferences. const BOOL loadROMOnLaunch = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_AutoloadROMOnLaunch"]; if (loadROMOnLaunch && [emuControl currentRom] == nil) @@ -263,10 +268,6 @@ } } - //Bring the application to the front - [NSApp activateIgnoringOtherApps:TRUE]; - [emuControl newDisplayWindow:nil]; - // Present the file migration window to the user (if they haven't disabled it). if (![[NSUserDefaults standardUserDefaults] boolForKey:@"General_DoNotAskMigrate"] || !isFirstTimeRun) { @@ -310,6 +311,7 @@ CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; // Save some settings to user defaults before app termination + [self saveDisplayWindowStates]; [[NSUserDefaults standardUserDefaults] setBool:[cdsCore isSpeedLimitEnabled] forKey:@"CoreControl_EnableSpeedLimit"]; [[NSUserDefaults standardUserDefaults] setBool:[cdsCore isFrameSkipEnabled] forKey:@"CoreControl_EnableAutoFrameSkip"]; [[NSUserDefaults standardUserDefaults] setBool:[cdsCore isCheatingEnabled] forKey:@"CoreControl_EnableCheats"]; @@ -317,6 +319,7 @@ [cdsCoreController setContent:nil]; } +#pragma mark IBActions - (IBAction) launchWebsite:(id)sender { [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@STRING_DESMUME_WEBSITE]]; @@ -345,6 +348,7 @@ [troubleshootingWindow makeKeyAndOrderFront:sender]; } +#pragma mark Class Methods - (void) setupSlotMenuItems { NSMenuItem *loadItem = nil; @@ -582,4 +586,151 @@ [boxMisc setNeedsDisplay:YES]; } +- (void) restoreDisplayWindowStates +{ + EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content]; + NSArray *windowPropertiesList = [[NSUserDefaults standardUserDefaults] arrayForKey:@"General_DisplayWindowRestorableStates"]; + const BOOL willRestoreWindows = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_WillRestoreDisplayWindows"]; + + if (!willRestoreWindows || windowPropertiesList == nil || [windowPropertiesList count] < 1) + { + // If no windows were saved for restoring (the user probably closed all windows before + // app termination), then simply create a new display window per user defaults. + [emuControl newDisplayWindow:self]; + } + else + { + for (NSDictionary *windowProperties in windowPropertiesList) + { + DisplayWindowController *windowController = [[DisplayWindowController alloc] initWithWindowNibName:@"DisplayWindow" emuControlDelegate:emuControl]; + + if (windowController == nil) + { + continue; + } + + const NSInteger displayMode = [(NSNumber *)[windowProperties valueForKey:@"displayMode"] integerValue]; + const double displayScale = [(NSNumber *)[windowProperties valueForKey:@"displayScale"] doubleValue]; + const double displayRotation = [(NSNumber *)[windowProperties valueForKey:@"displayRotation"] doubleValue]; + const NSInteger displayOrientation = [(NSNumber *)[windowProperties valueForKey:@"displayOrientation"] integerValue]; + const NSInteger displayOrder = [(NSNumber *)[windowProperties valueForKey:@"displayOrder"] integerValue]; + const double displayGap = [(NSNumber *)[windowProperties valueForKey:@"displayGap"] doubleValue]; + const NSInteger videoFilterType = [(NSNumber *)[windowProperties valueForKey:@"videoFilterType"] integerValue]; + const NSInteger screenshotFileFormat = [(NSNumber *)[windowProperties valueForKey:@"screenshotFileFormat"] integerValue]; + const BOOL useBilinearOutput = [(NSNumber *)[windowProperties valueForKey:@"useBilinearOutput"] boolValue]; + const BOOL useVerticalSync = [(NSNumber *)[windowProperties valueForKey:@"useVerticalSync"] boolValue]; + const BOOL isMinSizeNormal = [(NSNumber *)[windowProperties valueForKey:@"isMinSizeNormal"] boolValue]; + const BOOL isShowingStatusBar = [(NSNumber *)[windowProperties valueForKey:@"isShowingStatusBar"] boolValue]; + const BOOL isInFullScreenMode = [(NSNumber *)[windowProperties valueForKey:@"isInFullScreenMode"] boolValue]; + const NSUInteger screenIndex = [(NSNumber *)[windowProperties valueForKey:@"screenIndex"] unsignedIntegerValue]; + NSString *windowFrameStr = (NSString *)[windowProperties valueForKey:@"windowFrame"]; + + int frameX = 0; + int frameY = 0; + int frameWidth = GPU_DISPLAY_WIDTH; + int frameHeight = GPU_DISPLAY_HEIGHT; + const char *frameCStr = [windowFrameStr cStringUsingEncoding:NSUTF8StringEncoding]; + sscanf(frameCStr, "%i %i %i %i", &frameX, &frameY, &frameWidth, &frameHeight); + + [windowController setIsMinSizeNormal:isMinSizeNormal]; + [windowController setIsShowingStatusBar:isShowingStatusBar]; + [windowController setVideoFilterType:videoFilterType]; + [windowController setDisplayMode:displayMode]; + [windowController setDisplayRotation:displayRotation]; + [windowController setDisplayOrientation:displayOrientation]; + [windowController setDisplayOrder:displayOrder]; + [windowController setDisplayGap:displayGap]; + [windowController setScreenshotFileFormat:screenshotFileFormat]; + [windowController setUseBilinearOutput:useBilinearOutput]; + [windowController setUseVerticalSync:useVerticalSync]; + [windowController setDisplayScale:displayScale]; + + [[windowController masterWindow] setFrameOrigin:NSMakePoint(frameX, frameY)]; + + // If this is the last window in the list, make this window key and main. + // Otherwise, just order the window to the front so that the windows will + // stack in a deterministic order. + if (windowProperties == [windowPropertiesList lastObject]) + { + [[windowController window] makeKeyAndOrderFront:self]; + [[windowController window] makeMainWindow]; + } + else + { + [[windowController window] orderFront:self]; + } + + // Draw the display view now so that we guarantee that its drawn at least once. + if ([emuControl currentRom] == nil) + { + [[windowController view] clearToBlack]; + } + else + { + [[windowController view] setNeedsDisplay:YES]; + } + + // If this window is set to full screen mode, its associated screen index must + // exist. If not, this window will not enter full screen mode. This is necessary, + // since the user's screen configuration could change in between app launches, + // and since we don't want a window to go full screen on the wrong screen. + if (isInFullScreenMode && + ([[NSScreen screens] indexOfObject:[[windowController window] screen]] == screenIndex)) + { + [windowController enterFullScreen]; + [[windowController window] makeKeyAndOrderFront:self]; + [[windowController window] makeMainWindow]; + } + } + } +} + +- (void) saveDisplayWindowStates +{ + EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content]; + NSArray *windowList = [emuControl windowList]; + const BOOL willRestoreWindows = [[NSUserDefaults standardUserDefaults] boolForKey:@"General_WillRestoreDisplayWindows"]; + + if (willRestoreWindows && [windowList count] > 0) + { + NSMutableArray *windowPropertiesList = [NSMutableArray arrayWithCapacity:[windowList count]]; + + for (DisplayWindowController *windowController in windowList) + { + const BOOL isInFullScreenMode = ([windowController assignedScreen] != nil); + const NSUInteger screenIndex = [[NSScreen screens] indexOfObject:[[windowController masterWindow] screen]]; + + const NSRect windowFrame = [[windowController masterWindow] frame]; + NSString *windowFrameStr = [NSString stringWithFormat:@"%i %i %i %i", + (int)windowFrame.origin.x, (int)windowFrame.origin.y, (int)windowFrame.size.width, (int)windowFrame.size.height]; + + NSDictionary *windowProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithInteger:[windowController displayMode]], @"displayMode", + [NSNumber numberWithDouble:[windowController displayScale]], @"displayScale", + [NSNumber numberWithDouble:[windowController displayRotation]], @"displayRotation", + [NSNumber numberWithInteger:[windowController displayOrientation]], @"displayOrientation", + [NSNumber numberWithInteger:[windowController displayOrder]], @"displayOrder", + [NSNumber numberWithDouble:[windowController displayGap]], @"displayGap", + [NSNumber numberWithInteger:[windowController videoFilterType]], @"videoFilterType", + [NSNumber numberWithInteger:[windowController screenshotFileFormat]], @"screenshotFileFormat", + [NSNumber numberWithBool:[windowController useBilinearOutput]], @"useBilinearOutput", + [NSNumber numberWithBool:[windowController useVerticalSync]], @"useVerticalSync", + [NSNumber numberWithBool:[windowController isMinSizeNormal]], @"isMinSizeNormal", + [NSNumber numberWithBool:[windowController isShowingStatusBar]], @"isShowingStatusBar", + [NSNumber numberWithBool:isInFullScreenMode], @"isInFullScreenMode", + [NSNumber numberWithUnsignedInteger:screenIndex], @"screenIndex", + windowFrameStr, @"windowFrame", + nil]; + + [windowPropertiesList addObject:windowProperties]; + } + + [[NSUserDefaults standardUserDefaults] setObject:windowPropertiesList forKey:@"General_DisplayWindowRestorableStates"]; + } + else + { + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"General_DisplayWindowRestorableStates"]; + } +} + @end