mirror of https://github.com/stella-emu/stella.git
Added preference to allow user to select the directory in which ROM images are stored. This simply sets the default directory to start the browsing in, and doesn't preclude the user from selecting a file outside that directory
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@333 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
c39b7f5322
commit
8401b26bfa
|
@ -4,7 +4,7 @@
|
|||
Mark Grebe <atarimac@cox.net>
|
||||
|
||||
*/
|
||||
/* $Id: Menus.h,v 1.2 2004-07-14 06:54:17 markgrebe Exp $ */
|
||||
/* $Id: Menus.h,v 1.3 2004-08-02 04:08:10 markgrebe Exp $ */
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
@ -15,11 +15,13 @@
|
|||
IBOutlet id videoModeMatrix;
|
||||
IBOutlet id volumeSlider;
|
||||
IBOutlet id aspectRatioField;
|
||||
IBOutlet id romDirField;
|
||||
int openGlEnabled;
|
||||
int gameMenusEnabled;
|
||||
}
|
||||
|
||||
+ (Menus *)sharedInstance;
|
||||
- (NSString *) browseDir;
|
||||
- (void)setSpeedLimitMenu:(int)limit;
|
||||
- (void)initVideoMenu:(int)openGl;
|
||||
- (void)setPaddleMenu:(int)number;
|
||||
|
@ -28,6 +30,7 @@
|
|||
- (void)pushKeyEvent:(int)key:(bool)shift;
|
||||
- (IBAction) paddleChange:(id) sender;
|
||||
- (IBAction) prefsOK:(id) sender;
|
||||
- (IBAction) romdirSelect:(id) sender;
|
||||
- (IBAction)prefsMenu:(id)sender;
|
||||
- (IBAction)biggerScreen:(id)sender;
|
||||
- (IBAction)smallerScreen:(id)sender;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Mark Grebe <atarimac@cox.net>
|
||||
|
||||
*/
|
||||
/* $Id: Menus.m,v 1.2 2004-07-14 06:54:17 markgrebe Exp $ */
|
||||
/* $Id: Menus.m,v 1.3 2004-08-02 04:08:10 markgrebe Exp $ */
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "Menus.h"
|
||||
|
@ -17,8 +17,10 @@
|
|||
#define QZ_COMMA 0x2B
|
||||
|
||||
extern void setPaddleMode(int mode);
|
||||
extern void getPrefsSettings(int *gl, int *volume, float *aspect);
|
||||
extern void setPrefsSettings(int gl, int volume, float aspect);
|
||||
extern void getPrefsSettings(int *gl, int *volume, float *aspect, const char **romdir);
|
||||
extern void setPrefsSettings(int gl, int volume, float aspect, const char *romdir);
|
||||
void getRomdirSetting(char *romdir);
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* releaseCmdKeys - This method fixes an issue when modal windows are used with
|
||||
|
@ -52,22 +54,29 @@ void releaseCmdKeys(NSString *character, int keyCode)
|
|||
char *browseFile(void) {
|
||||
NSOpenPanel *openPanel = nil;
|
||||
char *fileName;
|
||||
NSString *dirName;
|
||||
char cdirName[FILENAME_MAX];
|
||||
|
||||
fileName = malloc(FILENAME_MAX);
|
||||
if (fileName == NULL)
|
||||
return NULL;
|
||||
|
||||
getRomdirSetting(cdirName);
|
||||
dirName = [NSString stringWithCString:cdirName];
|
||||
|
||||
openPanel = [NSOpenPanel openPanel];
|
||||
[openPanel setCanChooseDirectories:NO];
|
||||
[openPanel setCanChooseFiles:YES];
|
||||
|
||||
if ([openPanel runModalForDirectory:nil file:nil types:nil] == NSOKButton) {
|
||||
if ([openPanel runModalForDirectory:dirName file:nil types:nil] == NSOKButton) {
|
||||
[[[openPanel filenames] objectAtIndex:0] getCString:fileName];
|
||||
releaseCmdKeys(@"o",QZ_o);
|
||||
[dirName release];
|
||||
return fileName;
|
||||
}
|
||||
else {
|
||||
releaseCmdKeys(@"o",QZ_o);
|
||||
[dirName release];
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +138,22 @@ static Menus *sharedInstance = nil;
|
|||
return(self);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* browseDir - Method which allows user to choose a directory.
|
||||
*-----------------------------------------------------------------------------*/
|
||||
- (NSString *) browseDir {
|
||||
NSOpenPanel *openPanel;
|
||||
|
||||
openPanel = [NSOpenPanel openPanel];
|
||||
[openPanel setCanChooseDirectories:YES];
|
||||
[openPanel setCanChooseFiles:NO];
|
||||
|
||||
if ([openPanel runModalForTypes:nil] == NSOKButton)
|
||||
return([[openPanel filenames] objectAtIndex:0]);
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setSpeedLimitMenu:(int)limit
|
||||
{
|
||||
if (limit)
|
||||
|
@ -167,20 +192,27 @@ static Menus *sharedInstance = nil;
|
|||
{
|
||||
int gl, volume;
|
||||
float aspectRatio;
|
||||
const char *romdir;
|
||||
const char *newRomdir;
|
||||
NSString *romDirString;
|
||||
|
||||
getPrefsSettings(&gl, &volume, &aspectRatio);
|
||||
getPrefsSettings(&gl, &volume, &aspectRatio, &romdir);
|
||||
romDirString = [NSString stringWithCString:romdir];
|
||||
|
||||
[volumeSlider setIntValue:volume];
|
||||
[videoModeMatrix selectCellWithTag:gl];
|
||||
[aspectRatioField setFloatValue:aspectRatio];
|
||||
[romDirField setStringValue:romDirString];
|
||||
|
||||
[NSApp runModalForWindow:[volumeSlider window]];
|
||||
|
||||
gl = [[videoModeMatrix selectedCell] tag];
|
||||
volume = [volumeSlider intValue];
|
||||
aspectRatio = [aspectRatioField floatValue];
|
||||
romDirString = [romDirField stringValue];
|
||||
newRomdir = [romDirString cString];
|
||||
|
||||
setPrefsSettings(gl, volume, aspectRatio);
|
||||
setPrefsSettings(gl, volume, aspectRatio, newRomdir);
|
||||
}
|
||||
|
||||
- (IBAction) prefsOK:(id) sender
|
||||
|
@ -188,6 +220,16 @@ static Menus *sharedInstance = nil;
|
|||
[NSApp stopModal];
|
||||
[[volumeSlider window] close];
|
||||
}
|
||||
|
||||
- (IBAction) romdirSelect:(id) sender
|
||||
{
|
||||
NSString *directory;
|
||||
|
||||
directory = [self browseDir];
|
||||
if (directory != nil)
|
||||
[romDirField setStringValue:directory];
|
||||
}
|
||||
|
||||
- (IBAction)prefsMenu:(id)sender
|
||||
{
|
||||
[[Menus sharedInstance] prefsStart];
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
prefsMenu = id;
|
||||
prefsOK = id;
|
||||
rightJoyChange = id;
|
||||
romdirSelect = id;
|
||||
smallerScreen = id;
|
||||
speedLimit = id;
|
||||
toggleGlFilter = id;
|
||||
|
@ -41,6 +42,7 @@
|
|||
filterMenu = id;
|
||||
limitSpeedMenu = id;
|
||||
paddlesMenu = id;
|
||||
romDirField = id;
|
||||
videoModeMatrix = id;
|
||||
volumeSlider = id;
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>495 397 359 316 0 0 1280 1002 </string>
|
||||
<string>451 517 359 316 0 0 1280 1002 </string>
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>29</key>
|
||||
|
@ -13,8 +13,8 @@
|
|||
<string>349.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>29</integer>
|
||||
<integer>578</integer>
|
||||
<integer>29</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>7H63</string>
|
||||
|
|
Binary file not shown.
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: SettingsMACOSX.cxx,v 1.1.1.1 2004-06-16 02:30:30 markgrebe Exp $
|
||||
// $Id: SettingsMACOSX.cxx,v 1.2 2004-08-02 04:08:10 markgrebe Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -41,6 +41,8 @@ void prefsSave(void);
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
SettingsMACOSX::SettingsMACOSX()
|
||||
{
|
||||
char workingDir[FILENAME_MAX];
|
||||
|
||||
// First set variables that the parent class needs
|
||||
myBaseDir = "./";
|
||||
string stelladir = myBaseDir;
|
||||
|
@ -65,6 +67,9 @@ SettingsMACOSX::SettingsMACOSX()
|
|||
#ifdef SNAPSHOT_SUPPORT
|
||||
set("ssdir", "./");
|
||||
#endif
|
||||
getwd(workingDir);
|
||||
set("romdir", workingDir);
|
||||
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: mainSDL.cxx,v 1.5 2004-08-02 00:28:48 markgrebe Exp $
|
||||
// $Id: mainSDL.cxx,v 1.6 2004-08-02 04:08:10 markgrebe Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <fstream>
|
||||
|
@ -56,8 +56,9 @@ int stellaMain(int argc, char* argv[]);
|
|||
void setPaddleMode(int mode);
|
||||
void setLeftJoystickMode(int mode);
|
||||
void setRightJoystickMode(int mode);
|
||||
void getPrefsSettings(int *gl, int *volume, float *aspect);
|
||||
void setPrefsSettings(int gl, int volume, float aspect);
|
||||
void getPrefsSettings(int *gl, int *volume, float *aspect, const char **romdir);
|
||||
void setPrefsSettings(int gl, int volume, float aspect, const char *romdir);
|
||||
void getRomdirSetting(char *romdir);
|
||||
char *browseFile(void);
|
||||
void prefsStart(void);
|
||||
void hideApp(void);
|
||||
|
@ -286,7 +287,7 @@ void setPaddleMode(int mode)
|
|||
theSettings->setInt("paddle",thePaddleMode);
|
||||
}
|
||||
|
||||
void getPrefsSettings(int *gl, int *volume, float *aspect)
|
||||
void getPrefsSettings(int *gl, int *volume, float *aspect, const char **romdir)
|
||||
{
|
||||
if (theSettings->getString("video") == "gl")
|
||||
*gl = 1;
|
||||
|
@ -298,9 +299,16 @@ void getPrefsSettings(int *gl, int *volume, float *aspect)
|
|||
*volume = 100;
|
||||
|
||||
*aspect = theSettings->getFloat("gl_aspect");
|
||||
|
||||
*romdir = theSettings->getString("romdir").c_str();
|
||||
}
|
||||
|
||||
void setPrefsSettings(int gl, int volume, float aspect)
|
||||
void getRomdirSetting(char *romdir)
|
||||
{
|
||||
strcpy(romdir, theSettings->getString("romdir").c_str());
|
||||
}
|
||||
|
||||
void setPrefsSettings(int gl, int volume, float aspect, const char *romdir)
|
||||
{
|
||||
if (gl)
|
||||
theSettings->setString("video","gl");
|
||||
|
@ -311,6 +319,8 @@ void setPrefsSettings(int gl, int volume, float aspect)
|
|||
theSound->setVolume(volume);
|
||||
|
||||
theSettings->setFloat("gl_aspect",aspect);
|
||||
|
||||
theSettings->setString("romdir",romdir);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -392,7 +392,7 @@
|
|||
<key>CFBundleExecutable</key>
|
||||
<string>StellaOSX</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>1.4</string>
|
||||
<string>1.4.1</string>
|
||||
<key>CFBundleHelpBookFolder</key>
|
||||
<string>docs</string>
|
||||
<key>CFBundleHelpBookName</key>
|
||||
|
@ -408,7 +408,7 @@
|
|||
<key>CFBundleSignature</key>
|
||||
<string>StLa</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.4</string>
|
||||
<string>1.4.1</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>SDLMain.nib</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
|
|
Loading…
Reference in New Issue