--- hatari/src/gui-osx/SDLMain.m 2019/04/09 08:49:23 1.1.1.7 +++ hatari/src/gui-osx/SDLMain.m 2019/04/09 08:52:55 1.1.1.10 @@ -25,6 +25,7 @@ #include "avi_record.h" #include "../debug/debugui.h" #include "clocks_timings.h" +#include "change.h" // for Hatari @@ -335,9 +336,15 @@ static void CustomApplicationMain (int a --in_propdialog; } +- (IBAction) openPreferences:(id)sender +{ + [[PrefsController prefs] loadPrefs:sender]; +} + + - (IBAction)debugUI:(id)sender { - DebugUI(); + DebugUI(REASON_USER); } - (IBAction)warmReset:(id)sender @@ -352,7 +359,7 @@ static void CustomApplicationMain (int a //printf("b=%i\n",b); if (b == 1) Reset_Warm(); -} +} - (IBAction)coldReset:(id)sender { @@ -601,15 +608,95 @@ static void CustomApplicationMain (int a SDL_PushEvent((SDL_Event*)&event); // Send the F11 key release } + - (IBAction)help:(id)sender { - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://hatari.berlios.de/docs.html"]]; +NSString *l_aide ; + + l_aide = [[NSBundle mainBundle] pathForResource:@"manual" ofType:@"html" inDirectory:@"AideHatari"] ; + + if (![[NSWorkspace sharedWorkspace] openFile:l_aide withApplication:@"HelpViewer"]) + if (![[NSWorkspace sharedWorkspace] openFile:l_aide withApplication:@"Help Viewer"]) + [[NSWorkspace sharedWorkspace] openFile:l_aide] ; } +- (IBAction)compat:(id)sender +{ +NSString *C_aide ; + + C_aide = [[NSBundle mainBundle] pathForResource:@"compatibility" ofType:@"html" inDirectory:@"AideHatari"] ; + + if (![[NSWorkspace sharedWorkspace] openFile:C_aide withApplication:@"HelpViewer"]) + if (![[NSWorkspace sharedWorkspace] openFile:C_aide withApplication:@"Help Viewer"]) + [[NSWorkspace sharedWorkspace] openFile:C_aide] ; +} -- (IBAction)openConfig:(id)sender { +- (IBAction)openConfig:(id)sender +{ + BOOL applyChanges = true; + NSString *ConfigFile = [NSString stringWithCString:(sConfigFileName) encoding:NSASCIIStringEncoding]; + NSOpenPanel *openPanel = [ NSOpenPanel openPanel ]; + + CNF_PARAMS CurrentParams; + + + // Backup of configuration settings to CurrentParams (which we will only + // commit back to the configuration settings if choosing user confirm) + CurrentParams = ConfigureParams; + + GuiOsx_Pause(); + + if ( [ openPanel runModalForDirectory:nil file:ConfigFile types:nil ] ) + { + ConfigFile = [ [ openPanel filenames ] objectAtIndex:0 ]; + } + else + { + ConfigFile = nil; + } + + //[openPanel release]; + + if (ConfigFile != nil) + { + // Make a non-const C string out of it + const char* constSzPath = [ConfigFile cStringUsingEncoding:NSASCIIStringEncoding]; + size_t cbPath = strlen(constSzPath) + 1; + char szPath[cbPath]; + strncpy(szPath, constSzPath, cbPath); + + // Load the config into ConfigureParams + Configuration_Load(szPath); + strcpy(sConfigFileName,szPath); + // Refresh all the controls to match ConfigureParams + + if (Change_DoNeedReset(&CurrentParams, &ConfigureParams)) + { + applyChanges = ( 0 == NSRunAlertPanel ( + NSLocalizedStringFromTable(@"Reset the emulator",@"Localizable",@"comment"), + NSLocalizedStringFromTable(@"Must be reset",@"Localizable",@"comment"), + NSLocalizedStringFromTable(@"Don't reset",@"Localizable",@"comment"), + NSLocalizedStringFromTable(@"Reset",@"Localizable",@"comment"), nil) ); + } + + // Commit the new configuration + if (applyChanges) + { + Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, true); + } + else + { + ConfigureParams = CurrentParams; + } + + + } + + GuiOsx_Resume(); + //[ConfigFile release]; } + - (IBAction)saveConfig:(id)sender { }