--- previous/src/gui-osx/SDLMain.m 2018/04/24 19:25:10 1.1 +++ previous/src/gui-osx/SDLMain.m 2018/04/24 19:30:05 1.1.1.3 @@ -16,8 +16,13 @@ #include "reset.h" #include "screenSnapShot.h" #include "memorySnapShot.h" +#include "screen.h" +#include "PrefsController.h" +#include "Shared.h" #include "video.h" #include "avi_record.h" +#include "../debug/debugui.h" +#include "clocks_timings.h" // for Hatari @@ -309,7 +314,7 @@ static void CustomApplicationMain (int a /* Hand off to main application code */ gCalledAppMainline = TRUE; - status = SDL_main (gArgc, gArgv); + //status = SDL_main (gArgc, gArgv); /* We're done, thank you for playing */ exit(status); @@ -434,34 +439,12 @@ static void CustomApplicationMain (int a return YES; } -- (IBAction)captureScreen:(id)sender +- (NSString*)displayFileSelection:(const char*)pathInParams preferredFileName:(NSString*)preferredFileName allowedExtensions:(NSArray*)allowedExtensions { - GuiOsx_Pause(); - ScreenSnapShot_SaveScreen(); - GuiOsx_Resume(); -} - -- (IBAction)captureAnimation:(id)sender -{ - GuiOsx_Pause(); -// Avi_StartRecording ( AviRecordFile , AviRecordDefaultCrop , nScreenRefreshRate , AviRecordDefaultVcodec ); - GuiOsx_Resume(); -} - -- (IBAction)endCaptureAnimation:(id)sender -{ - GuiOsx_Pause(); -// Avi_StopRecording(); - GuiOsx_Resume(); -} - -- (IBAction)captureSound:(id)sender -{ - GuiOsx_Pause(); - + // Get the path from the user settings - NSString *preferredPath = [[NSString stringWithCString:(ConfigureParams.Sound.szYMCaptureFileName) encoding:NSASCIIStringEncoding] stringByAbbreviatingWithTildeInPath]; - + NSString *preferredPath = [[NSString stringWithCString:(pathInParams) encoding:NSASCIIStringEncoding] stringByAbbreviatingWithTildeInPath]; + // Determine the directory and filename NSString *directoryToOpen; NSString *fileToPreselect; @@ -475,28 +458,66 @@ static void CustomApplicationMain (int a { // Currently no path: we will open the user's directory with no file selected. directoryToOpen = [@"~" stringByExpandingTildeInPath]; - fileToPreselect = @"hatari.wav"; + fileToPreselect = preferredFileName; } - + // Create and configure a SavePanel for choosing what file to write NSSavePanel *savePanel = [NSSavePanel savePanel]; - [savePanel setAllowedFileTypes:[NSArray arrayWithObjects:@"ym", @"wav", nil]]; + [savePanel setAllowedFileTypes:allowedExtensions]; [savePanel setExtensionHidden:NO]; - [savePanel setMessage:@"Please specify an .ym or a .wav file."]; // TODO: Move to localizable resources + NSString* extensionList = [allowedExtensions componentsJoinedByString:@" or a ."]; + [savePanel setMessage:[NSString stringWithFormat:@"Please specify a .%@ file",extensionList]]; // TODO: Move to localizable resources // Run the SavePanel, then check if the user clicked OK and selected at least one file if (NSFileHandlingPanelOKButton == [savePanel runModalForDirectory:directoryToOpen file:fileToPreselect] ) - { - // Get the path to the selected file - NSString *path = [savePanel filename]; + return [[savePanel URL] path]; + return nil; +} + +- (IBAction)captureScreen:(id)sender +{ + GuiOsx_Pause(); + ScreenSnapShot_SaveScreen(); + GuiOsx_Resume(); +} + +- (IBAction)captureAnimation:(id)sender +{ +// GuiOsx_Pause(); +// if(!Avi_AreWeRecording()) { +// NSString* path = [self displayFileSelection:ConfigureParams.Video.AviRecordFile preferredFileName:@"hatari.avi" +// allowedExtensions:[NSArray arrayWithObjects:@"avi", nil]]; - // Store the path in the user settings - GuiOsx_ExportPathString(path, ConfigureParams.Sound.szYMCaptureFileName, sizeof(ConfigureParams.Sound.szYMCaptureFileName)); +// if(path) { +// GuiOsx_ExportPathString(path, ConfigureParams.Video.AviRecordFile, sizeof(ConfigureParams.Video.AviRecordFile)); +// Avi_StartRecording ( ConfigureParams.Video.AviRecordFile , ConfigureParams.Screen.bCrop , +// ConfigureParams.Video.AviRecordFps == 0 ? +// ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) : +// (Uint32)ConfigureParams.Video.AviRecordFps << CLOCKS_TIMINGS_SHIFT_VBL , +// 1 << CLOCKS_TIMINGS_SHIFT_VBL , +// ConfigureParams.Video.AviRecordVcodec ); +// } - // Begin capture -// Sound_BeginRecording(ConfigureParams.Sound.szYMCaptureFileName); - } +// } else { +// Avi_StopRecording(); +// } +// GuiOsx_Resume(); +} + +- (IBAction)endCaptureAnimation:(id)sender +{ + //? +} +- (IBAction)captureSound:(id)sender +{ + GuiOsx_Pause(); +// NSString* path = [self displayFileSelection:ConfigureParams.Sound.szYMCaptureFileName preferredFileName:@"hatari.wav" +// allowedExtensions:[NSArray arrayWithObjects:@"ym", @"wav", nil]]; +// if(path) { +// GuiOsx_ExportPathString(path, ConfigureParams.Sound.szYMCaptureFileName, sizeof(ConfigureParams.Sound.szYMCaptureFileName)); +// Sound_BeginRecording(ConfigureParams.Sound.szYMCaptureFileName); +// } GuiOsx_Resume(); } @@ -511,42 +532,13 @@ static void CustomApplicationMain (int a { GuiOsx_Pause(); - // Get the path from the user settings - NSString *preferredPath = [[NSString stringWithCString:(ConfigureParams.Memory.szMemoryCaptureFileName) encoding:NSASCIIStringEncoding] stringByAbbreviatingWithTildeInPath]; - - // Determine the directory and filename - NSString *directoryToOpen; - NSString *fileToPreselect; - if ((preferredPath != nil) && ([preferredPath length] > 0)) - { - // There is existing path: we will open its directory with its file pre-selected. - directoryToOpen = [preferredPath stringByDeletingLastPathComponent]; - fileToPreselect = [preferredPath lastPathComponent]; - } - else - { - // Currently no path: we will open the user's directory with the default filename. - directoryToOpen = [@"~" stringByExpandingTildeInPath]; - fileToPreselect = @"hatari.sav"; - } - - // Create and configure a SavePanel for choosing what file to write - NSSavePanel *savePanel = [NSSavePanel savePanel]; - [savePanel setExtensionHidden:NO]; - - // Run the SavePanel, then check if the user clicked OK and selected at least one file - if (NSFileHandlingPanelOKButton == [savePanel runModalForDirectory:directoryToOpen file:fileToPreselect] ) - { - // Get the path to the selected file - NSString *path = [savePanel filename]; - - // Store the path in the user settings + NSString* path = [self displayFileSelection:ConfigureParams.Memory.szMemoryCaptureFileName preferredFileName:@"hatari.sav" + allowedExtensions:[NSArray arrayWithObjects:@"sav",nil]]; + if(path) { GuiOsx_ExportPathString(path, ConfigureParams.Memory.szMemoryCaptureFileName, sizeof(ConfigureParams.Memory.szMemoryCaptureFileName)); - - // Perform the memory snapshot save MemorySnapShot_Capture(ConfigureParams.Memory.szMemoryCaptureFileName, TRUE); } - + GuiOsx_Resume(); } @@ -597,7 +589,7 @@ static void CustomApplicationMain (int a SDL_KeyboardEvent event; event.type = SDL_KEYDOWN; - event.which = 0; + //event.which = 0; event.state = SDL_PRESSED; event.keysym.sym = SDLK_F11; SDL_PushEvent((SDL_Event*)&event); // Send the F11 key press @@ -666,7 +658,7 @@ static void CustomApplicationMain (int a # undef main #endif - +#if 0 /* Main entry point to executable - should *not* be SDL_main! */ int main (int argc, char **argv) { @@ -688,10 +680,10 @@ int main (int argc, char **argv) } #if SDL_USE_NIB_FILE - NSApplicationMain (argc, argv); + NSApplicationMain (argc, (const char**)argv); #else CustomApplicationMain (argc, argv); #endif return 0; } - +#endif