Re: [hatari-devel] Troed's MacOS build |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
Here is my build with the "Load Config" confirmation button working.
It's a full frameworks build, should work for 10.6+, may be 10.5, but I
do not have anything to test.
https://www.dropbox.com/s/ci64phvgn767amv/Hatari1.9.0fb10.zip?dl=0
And a diff file for the changes (among other code cleaning/comments).
A PPC (G4 and specific G5) can be done, but I really don't want to
maintain a specific 10.4/10.5 preference screen, I think. Too much work,
because I need to do things twice, one for XCode 4+ (.xib) and one for
XCode 3.2 (.nib) and no way to go from XCode 7 .xib files to XCode 3.2
.xib files.
JV
diff -r 1f73df77a7b5 src/gui-osx/AlertHooks.m
--- a/src/gui-osx/AlertHooks.m Sun Oct 09 08:50:31 2016 +0200
+++ b/src/gui-osx/AlertHooks.m Mon Oct 10 22:38:24 2016 +0200
@@ -30,20 +30,20 @@
firstPv = [message rangeOfString:@"'"] ;
lastPv = [message rangeOfString:@"'" options:NSBackwardsSearch] ;
- if ((cantTOS.location == NSNotFound) || (firstPv.location==lastPv.location)) // traitement normal
+ if ((cantTOS.location == NSNotFound) || (firstPv.location==lastPv.location)) // TOS can be found
return ([NSApp myAlerte:NSInformationalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:localize(@"Cancel")
otherB:nil informativeTxt:message ] == NSAlertFirstButtonReturn
//NSAlertDefaultReturn
);
- else // traitement can not load
+ else // TOS can be found
return ([NSApp myAlerte:NSCriticalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:nil otherB:nil
informativeTxt:localize(@"Can not load TOS file:") ] == NSAlertFirstButtonReturn) ;
}
-/*-----------------------------------------------------------------------*/
-/*
- Displays a Cocoa alert with a choice (OK and Cancel buttons)
-*/
+/*----------------------------------------------------------------------*/
+/* Displays a Cocoa alert with a choice (OK and Cancel buttons) */
+/*----------------------------------------------------------------------*/
+
int HookedAlertQuery(const char* szMessage)
{
NSString *message ;
diff -r 1f73df77a7b5 src/gui-osx/Hatari.icns
Binary file src/gui-osx/Hatari.icns has changed
diff -r 1f73df77a7b5 src/gui-osx/PrefsController.m
--- a/src/gui-osx/PrefsController.m Sun Oct 09 08:50:31 2016 +0200
+++ b/src/gui-osx/PrefsController.m Mon Oct 10 22:38:24 2016 +0200
@@ -33,8 +33,8 @@
#include "joy.h"
// Macros to transfer data between Cocoa controls and Hatari data structures
+// de l'affichage vers la structure (saveAllControls)
-// de l'affichage vers la structure (saveAllControls)
#define EXPORT_TEXTFIELD(mutablStrng, target) [mutablStrng getCString:target maxLength:sizeof((target))-1 encoding:NSASCIIStringEncoding]
#define EXPORT_NTEXTFIELD(nstextfield, target) target = [nstextfield intValue]
#define EXPORT_SWITCH(nsbutton, target) target = ([(nsbutton) state] == NSOnState)
@@ -53,7 +53,7 @@
#define INITIAL_DIR(dossier) [dossier length] < 2 ? @"~" : dossier
// Back up of the current configuration parameters
-//
+
CNF_PARAMS CurrentParams;
@@ -229,14 +229,13 @@
char szPath[FILENAME_MAX];
-
+// not used
- (IBAction)finished:(id)sender
{
//Main_RequestQuit(0) ;
}
/*-----------------------------------------------------------------------*/
-/* */
/* Helper method for Choose buttons */
/* Returns: TRUE is the user selected a path, FALSE if he/she aborted */
/*-----------------------------------------------------------------------*/
@@ -267,12 +266,11 @@
}
-//-----------------------------------------------------------------------*/
-//
-// Helper method to insert a floppy image
-// TODO: Add code to restrict to known file types
-//
-/*-----------------------------------------------------------------------*/
+/*----------------------------------------------------------------------*/
+/* */
+/* Helper method to insert a floppy image */
+/* TODO: Add code to restrict to known file types */
+/*----------------------------------------------------------------------*/
- (void)insertFloppyImageIntoDrive:(int)drive forTextField:(NSTextField*)floppyTextField
realPath:(NSMutableString *)realPath
@@ -316,24 +314,24 @@
- (IBAction)chooseFloppyImageA:(id)sender
{
- [self insertFloppyImageIntoDrive:0 forTextField:floppyImageA realPath:floppyA]; // floppy A
+ [self insertFloppyImageIntoDrive:0 forTextField:floppyImageA realPath:floppyA]; // floppy A
}
- (IBAction)chooseFloppyImageB:(id)sender
{
- [self insertFloppyImageIntoDrive:1 forTextField:floppyImageB realPath:floppyB]; // floppy B
+ [self insertFloppyImageIntoDrive:1 forTextField:floppyImageB realPath:floppyB]; // floppy B
}
-- (IBAction)chooseGemdosImage:(id)sender // directory for Gemdos
+- (IBAction)chooseGemdosImage:(id)sender // directory for Gemdos
{
- [self choosePathForControl: gemdosImage chooseDirectories:YES defaultInitialDir:INITIAL_DIR(gemdos) // gemdos
+ [self choosePathForControl: gemdosImage chooseDirectories:YES defaultInitialDir:INITIAL_DIR(gemdos) // gemdos
mutString:gemdos what:nil] ;
if (gemdos.length >2 ) [gemdosImage setStringValue:[NSApp pathUser:gemdos]] ;
}
- (IBAction)chooseHdImage:(id)sender
{
- [self choosePathForControl: hdImage chooseDirectories:NO defaultInitialDir:[self initial:hrdDisk] // HD image ?
+ [self choosePathForControl: hdImage chooseDirectories:NO defaultInitialDir:[self initial:hrdDisk] // HD image ?
mutString:hrdDisk what:@[@"img",@"hdv"]] ;
}
@@ -386,10 +384,9 @@
}
-/*-----------------------------------------------------------------------*/
-/* */
-/* Methods for the "Eject" buttons */
-/*-----------------------------------------------------------------------*/
+//-----------------------------------------------------------------------
+// Methods for the "Eject" buttons
+//-----------------------------------------------------------------------
- (IBAction)ejectFloppyA:(id)sender
{
Floppy_SetDiskFileNameNone(0);
@@ -440,10 +437,8 @@
slaveIDE.string = @"" ;
}
-/*-----------------------------------------------------------------------*/
-/**
- * Methods for the "Load Config" button
- */
+/*----------------------------------------------------------------------*/
+/* Methods for the "Load Config" button */
- (IBAction)loadConfigFrom:(id)sender
{
@@ -456,17 +451,17 @@
opnPanel.canChooseDirectories = NO ;
opnPanel.canChooseFiles = YES ;
opnPanel.accessoryView = partage ;
-//10.5 ?
-// if ([opnPanel respondsToSelector:@selector(setDirectoryURL:)])
+ //10.5 ?
+ // if ([opnPanel respondsToSelector:@selector(setDirectoryURL:)])
{ opnPanel.directoryURL = [NSURL fileURLWithPath:ru isDirectory:YES] ;
opnPanel.nameFieldStringValue = @"hatari" ;
- btOk = [opnPanel runModal] == NSModalResponseOK; // Ok ?
+ btOk = [opnPanel runModal] == NSModalResponseOK; // Ok ?
}
-// 10.5 ?
-// else
-// btOk = [opnPanel runModalForDirectory:ru file:@"hatari"] == NSModalResponseOK; //NSOKButton ;
+ // 10.5 ?
+ // else
+ // btOk = [opnPanel runModalForDirectory:ru file:@"hatari"] == NSModalResponseOK; //NSOKButton ;
- if (!btOk) return ; // Cancel
+ if (!btOk) return ; // Cancel
lesURLs = opnPanel.URLs ;
if ((lesURLs == nil) || (lesURLs.count == 0))
@@ -474,36 +469,36 @@
[configNm setString:[[lesURLs objectAtIndex:0] path]] ;
- // Make a non-const C string out of it
+ // Make a non-const C string out of it
[configNm getCString:sConfigFileName maxLength:FILENAME_MAX encoding:NSASCIIStringEncoding];
- // Load the config into ConfigureParams
+ // Load the config into ConfigureParams
Configuration_Load(sConfigFileName);
- // Refresh all the controls to match ConfigureParams
+ // Refresh all the controls to match ConfigureParams
[self setAllControls];
}
-/**
- * Methods for the "Save Config" button (bottom preference window)
- */
+//---------------------------------------------------------------------
+// Methods for the "Save Config" button (bottom preference window)
+//---------------------------------------------------------------------
- (IBAction)saveConfigAs:(id)sender
{
-NSString *ru ;
-BOOL btOk ;
+ NSString *ru ;
+ BOOL btOk ;
ru = [NSString stringWithCString:(Paths_GetHatariHome()) encoding:NSASCIIStringEncoding] ;
savPanel.allowedFileTypes = @[@"cfg"] ;
savPanel.accessoryView = hartage ;
-//10.5
-// if ([savPanel respondsToSelector:@selector(setDirectoryURL:)])
+ //10.5
+ // if ([savPanel respondsToSelector:@selector(setDirectoryURL:)])
{ savPanel.directoryURL = [NSURL fileURLWithPath:ru isDirectory:YES] ; // Since OS X 10.6
savPanel.nameFieldStringValue = @"hatari" ;
btOk = [savPanel runModal] == NSModalResponseOK ; // Ok ?
}
-//10.5
-// else
-// btOk = [savPanel runModalForDirectory:ru file:@"hatari"] == NSModalResponseOK; //NSOKButton ; // avant 10.6
+ //10.5
+ // else
+ // btOk = [savPanel runModalForDirectory:ru file:@"hatari"] == NSModalResponseOK; //NSOKButton ; // avant 10.6
if (!btOk)
return ; // Cancel
@@ -518,31 +513,29 @@
- (IBAction)aller:(id)sender
{
-NSString *defaultDirectory ;
+ NSString *defaultDirectory ;
defaultDirectory = [NSString stringWithCString:(Paths_GetHatariHome()) encoding:NSASCIIStringEncoding] ;
-// if ([opnPanel respondsToSelector:@selector(setDirectoryURL:)])
+ // if ([opnPanel respondsToSelector:@selector(setDirectoryURL:)])
opnPanel.directoryURL = [NSURL fileURLWithPath:defaultDirectory isDirectory:YES] ;
-// else
-// [opnPanel setDirectory:defaultDirectory] ;
+ // else
+ // [opnPanel setDirectory:defaultDirectory] ;
}
- (IBAction)halle:(id)sender
{
-NSString *defaultDirectory ;
+ NSString *defaultDirectory ;
defaultDirectory = [NSString stringWithCString:(Paths_GetHatariHome()) encoding:NSASCIIStringEncoding] ;
-// if ([savPanel respondsToSelector:@selector(setDirectoryURL:)])
+ // if ([savPanel respondsToSelector:@selector(setDirectoryURL:)])
savPanel.directoryURL = [NSURL fileURLWithPath:defaultDirectory isDirectory:YES] ;
-// else
-// [savPanel setDirectory:defaultDirectory] ;
+ // else
+ // [savPanel setDirectory:defaultDirectory] ;
}
-/*-----------------------------------------------------------------------*/
-/*
- Commits and closes Ok button in preferences window
-*/
+//----------------------------------------------------------------------
+//Commits and closes Ok button in preferences window
- (IBAction)commitAndClose:(id)sender
{
@@ -570,9 +563,9 @@
}
-/*--------------------------------------------------------------------------*/
-/*Displays the Preferences dialog Ouverture de la fenêtre des préférences */
-/*--------------------------------------------------------------------------*/
+//--------------------------------------------------------------------------
+//Displays the Preferences dialog Ouverture de la fenêtre des préférences
+//--------------------------------------------------------------------------
- (IBAction)loadPrefs:(id)sender
{
[configNm setString:[NSString stringWithCString:sConfigFileName encoding:NSASCIIStringEncoding]] ;
@@ -631,7 +624,7 @@
// M. Saro, 2013
//if(Ok button in preferences Windows)
- {
+ //{
// Check if change need reset
if (Change_DoNeedReset(&CurrentParams, &ConfigureParams))
{
@@ -645,7 +638,7 @@
}
else
Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, false); //Apply config without reset
- }
+ //}
// else // not OK button
// {
// ConfigureParams = CurrentParams; //Restore backup params
@@ -653,10 +646,8 @@
}
-/*-----------------------------------------------------------------------*/
-/*
- Updates the controls following a change in the joystick selection
-*/
+//----------------------------------------------------------------------
+//Updates the controls following a change in the joystick selection
- (IBAction)changeViewedJoystick:(id)sender
{
// Save the pre-joystick controls, as we are about to change them
@@ -670,10 +661,8 @@
}
-/*-----------------------------------------------------------------------*/
-/*
- Initializes all controls, transfert des préférences dans la fenêtre
-*/
+//----------------------------------------------------------------------
+//Initializes all controls, transfert des préférences dans la fenêtre
- (void)setAllControls
{
@@ -788,12 +777,12 @@
[FPUType selectCellWithTag:3];
IMPORT_SWITCH(CompatibleFPU, ConfigureParams.System.bCompatibleFPU);
#endif
-
+
int i;
for (i = 0; i <= DLGSOUND_50KHZ-DLGSOUND_11KHZ; i++)
{
if (ConfigureParams.Sound.nPlaybackFreq > nSoundFreqs[i]-500
- && ConfigureParams.Sound.nPlaybackFreq < nSoundFreqs[i]+500)
+ && ConfigureParams.Sound.nPlaybackFreq < nSoundFreqs[i]+500)
{
[playbackQuality selectCellWithTag:(i)];
break;
@@ -897,13 +886,13 @@
// Data validation: If the JoyID is out of bounds, correct it and, if set to use real joystick, change to disabled
if ( (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId < 0)
- || (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId >= cRealJoysticks) )
+ || (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId >= cRealJoysticks) )
{
ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId = 0;
if (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode == JOYSTICK_REALSTICK)
{
ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode = JOYSTICK_DISABLED;
- }
+ }
}
// Don't change the realJoystick dropdown if none is available (to keep "(None available)" selected)
@@ -922,8 +911,8 @@
}
-/*-----------------------------------------------------------------------*/
-/* Saves the setting for the joystick currently being viewed */
+//-----------------------------------------------------------------------
+// Saves the setting for the joystick currently being viewed
- (void)saveJoystickControls
{
EXPORT_RADIO(joystickMode, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode);
@@ -937,8 +926,8 @@
}
-/*-----------------------------------------------------------------------*/
-/* Saves the settings for all controls */
+//-----------------------------------------------------------------------
+// Saves the settings for all controls
- (void)saveAllControls
{
// Export the preference controls into their vars
@@ -1137,7 +1126,7 @@
prefs = [[PrefsController alloc] init];
return prefs;
-} // */
+}
- (void)awakeFromNib
{
diff -r 1f73df77a7b5 src/gui-osx/SDLMain.m
--- a/src/gui-osx/SDLMain.m Sun Oct 09 08:50:31 2016 +0200
+++ b/src/gui-osx/SDLMain.m Mon Oct 10 22:38:24 2016 +0200
@@ -34,6 +34,8 @@
#import "clocks_timings.h"
#import "change.h"
+//Avoid a warning
+void Main_RequestQuit(int);
#ifdef SDL_USE_CPS
// Portions of CPS.h
@@ -59,7 +61,7 @@
//
@implementation HatariAppDelegate
-char szPath[FILENAME_MAX] ; // for general use
+char szPath[FILENAME_MAX] ; // for general use
// Set the working directory to the .app's parent directory
- (void) setupWorkingDirectory:(BOOL)shouldChdir
@@ -150,24 +152,24 @@
--in_propdialog;
}
-/*- (IBAction) openPreferences:(id)sender
-{
- [[PrefsController prefs] loadPrefs:sender];
-} // */
+// Launch DebugUI ??
- (IBAction)debugUI:(id)sender
{
DebugUI(REASON_USER);
}
+//warnReset: FirstButton
+
- (IBAction)warmReset:(id)sender
{
if ([NSApp myAlerte:NSInformationalAlertStyle Txt:localize(@"Warm reset!") firstB:localize(@"OK") alternateB:localize(@"Cancel")
otherB:nil informativeTxt:localize(@"Really reset the emulator?")] == NSAlertFirstButtonReturn )
Reset_Warm();
-}
+}
+//coldReset: FirstButton
- (IBAction)coldReset:(id)sender
{
if ([NSApp myAlerte:NSInformationalAlertStyle Txt:localize(@"Cold reset") firstB:localize(@"OK") alternateB:localize(@"Cancel")
@@ -175,6 +177,7 @@
Reset_Cold();
}
+//Disks menus
- (IBAction)insertDiskA:(id)sender
{
[self insertDisk:0] ;
@@ -196,15 +199,17 @@
Floppy_SetDiskFileName(disque, szPath, NULL) ;
Floppy_InsertDiskIntoDrive(disque) ;
}
+
+//Quit, from Menu
- (IBAction)quit:(id)sender
{
Main_RequestQuit(0) ;
}
-/*-----------------------------------------------------------------------*/
-/*
- Controls the enabled state of the menu items
- */
+/*------------------------------------------------------------------*/
+/* Controls the enabled state of the menu items */
+/*------------------------------------------------------------------*/
+
- (BOOL)validateMenuItem:(NSMenuItem*)item
{
if (item == beginCaptureAnim)
@@ -227,6 +232,8 @@
return YES;
}
+//Wrapper to display some OPenFile dialog
+
- (NSString*)displayFileSelection:(const char*)pathInParams preferredFileName:(NSString*)preferredFileName allowedExtensions:(NSArray*)allowedExtensions
{
// BOOL test ;
@@ -262,6 +269,7 @@
return nil;
}
+//Screen Capture
- (IBAction)captureScreen:(id)sender
{
GuiOsx_Pause();
@@ -345,10 +353,12 @@
if ((oldPath != nil) && (oldPath.length > 0)) // Determine directory and filename
{ directoryToOpen = oldPath.stringByDeletingLastPathComponent ; // existing path: we use it.
- fileToPreselect = oldPath.lastPathComponent ; }
+ fileToPreselect = oldPath.lastPathComponent ;
+ }
else
{ directoryToOpen = @"~".stringByExpandingTildeInPath ; // Currently no path: we use user's directory
- fileToPreselect = nil; } ;
+ fileToPreselect = nil;
+ };
newPath = [NSApp hopenfile:NO defoDir:directoryToOpen defoFile:fileToPreselect types:@[@"sav"] ] ;
if (newPath.length != 0) // Perform the memory snapshot load
@@ -408,12 +418,15 @@
}
}
+//openConfig from menu
- (IBAction)openConfig:(id)sender
{
BOOL applyChanges ;
NSString *ConfigFile, *newCfg ;
CNF_PARAMS CurrentParams;
+ GuiOsx_Pause();
+
applyChanges = true ;
ConfigFile = [NSString stringWithCString:(sConfigFileName) encoding:NSASCIIStringEncoding];
@@ -421,8 +434,6 @@
// commit back to the configuration settings if choosing user confirm)
CurrentParams = ConfigureParams;
- GuiOsx_Pause();
-
newCfg = [NSApp hopenfile:NO defoDir:nil defoFile:ConfigFile types:@[@"cfg"] ] ;
if (newCfg.length != 0)
@@ -432,20 +443,23 @@
strcpy(sConfigFileName,szPath) ;
// Refresh all the controls to match ConfigureParams
+ // Check if Reset is needed
if (Change_DoNeedReset(&CurrentParams, &ConfigureParams))
applyChanges = [NSApp myAlerte:NSInformationalAlertStyle Txt:localize(@"Reset the emulator") firstB:localize(@"Don't reset")
- alternateB:localize(@"Reset") otherB:nil informativeTxt:@"" ] == NSAlertFirstButtonReturn ;
+ alternateB:localize(@"Reset") otherB:nil informativeTxt:@"" ] == NSAlertSecondButtonReturn ;
if (applyChanges)
Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, true); // Ok with Reset
else
- ConfigureParams = CurrentParams; //Restore previous Params.
+ ConfigureParams = CurrentParams; //Restore previous Params (do nothing).
} ;
GuiOsx_Resume();
}
-- (IBAction)saveConfig:(id)sender {
+- (IBAction)saveConfig:(id)sender
+{
+ //something have to be done here....
}
@end
@@ -457,15 +471,19 @@
return (cwd && (strcmp(cwd, "/") == 0));
}
+//check MacOsX version
+//need to be tested before 10.9
+
static int IsTenPointNineOrLater()
{
// OK for 10.9, but before ??
NSOperatingSystemVersion systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
int r=(systemVersion.majorVersion==10) && (systemVersion.minorVersion>=9);
-
return r;
}
+//check if launched from Finder or from terminal
+//not fully tested...
static int IsFinderLaunch(const int argc, char **argv)
{
/* -psn_XXX is passed if we are launched from Finder in 10.8 and earlier */
@@ -478,7 +496,7 @@
command line, and if our current working directory is "/". */
return 1;
}
- return 0; /* not a Finder launch. */
+ return 0; /* not a Finder launch. */
}
#ifdef main
@@ -510,4 +528,4 @@
CustomApplicationMain (argc, argv);
#endif
return 0;
-}
+}
\ No newline at end of file