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>
|
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>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
@ -15,11 +15,13 @@
|
||||||
IBOutlet id videoModeMatrix;
|
IBOutlet id videoModeMatrix;
|
||||||
IBOutlet id volumeSlider;
|
IBOutlet id volumeSlider;
|
||||||
IBOutlet id aspectRatioField;
|
IBOutlet id aspectRatioField;
|
||||||
|
IBOutlet id romDirField;
|
||||||
int openGlEnabled;
|
int openGlEnabled;
|
||||||
int gameMenusEnabled;
|
int gameMenusEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (Menus *)sharedInstance;
|
+ (Menus *)sharedInstance;
|
||||||
|
- (NSString *) browseDir;
|
||||||
- (void)setSpeedLimitMenu:(int)limit;
|
- (void)setSpeedLimitMenu:(int)limit;
|
||||||
- (void)initVideoMenu:(int)openGl;
|
- (void)initVideoMenu:(int)openGl;
|
||||||
- (void)setPaddleMenu:(int)number;
|
- (void)setPaddleMenu:(int)number;
|
||||||
|
@ -28,6 +30,7 @@
|
||||||
- (void)pushKeyEvent:(int)key:(bool)shift;
|
- (void)pushKeyEvent:(int)key:(bool)shift;
|
||||||
- (IBAction) paddleChange:(id) sender;
|
- (IBAction) paddleChange:(id) sender;
|
||||||
- (IBAction) prefsOK:(id) sender;
|
- (IBAction) prefsOK:(id) sender;
|
||||||
|
- (IBAction) romdirSelect:(id) sender;
|
||||||
- (IBAction)prefsMenu:(id)sender;
|
- (IBAction)prefsMenu:(id)sender;
|
||||||
- (IBAction)biggerScreen:(id)sender;
|
- (IBAction)biggerScreen:(id)sender;
|
||||||
- (IBAction)smallerScreen:(id)sender;
|
- (IBAction)smallerScreen:(id)sender;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Mark Grebe <atarimac@cox.net>
|
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 <Cocoa/Cocoa.h>
|
||||||
#import "Menus.h"
|
#import "Menus.h"
|
||||||
|
@ -17,8 +17,10 @@
|
||||||
#define QZ_COMMA 0x2B
|
#define QZ_COMMA 0x2B
|
||||||
|
|
||||||
extern void setPaddleMode(int mode);
|
extern void setPaddleMode(int mode);
|
||||||
extern void getPrefsSettings(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);
|
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
|
* 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) {
|
char *browseFile(void) {
|
||||||
NSOpenPanel *openPanel = nil;
|
NSOpenPanel *openPanel = nil;
|
||||||
char *fileName;
|
char *fileName;
|
||||||
|
NSString *dirName;
|
||||||
|
char cdirName[FILENAME_MAX];
|
||||||
|
|
||||||
fileName = malloc(FILENAME_MAX);
|
fileName = malloc(FILENAME_MAX);
|
||||||
if (fileName == NULL)
|
if (fileName == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
getRomdirSetting(cdirName);
|
||||||
|
dirName = [NSString stringWithCString:cdirName];
|
||||||
|
|
||||||
openPanel = [NSOpenPanel openPanel];
|
openPanel = [NSOpenPanel openPanel];
|
||||||
[openPanel setCanChooseDirectories:NO];
|
[openPanel setCanChooseDirectories:NO];
|
||||||
[openPanel setCanChooseFiles:YES];
|
[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];
|
[[[openPanel filenames] objectAtIndex:0] getCString:fileName];
|
||||||
releaseCmdKeys(@"o",QZ_o);
|
releaseCmdKeys(@"o",QZ_o);
|
||||||
|
[dirName release];
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
releaseCmdKeys(@"o",QZ_o);
|
releaseCmdKeys(@"o",QZ_o);
|
||||||
|
[dirName release];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,6 +138,22 @@ static Menus *sharedInstance = nil;
|
||||||
return(self);
|
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
|
- (void)setSpeedLimitMenu:(int)limit
|
||||||
{
|
{
|
||||||
if (limit)
|
if (limit)
|
||||||
|
@ -167,20 +192,27 @@ static Menus *sharedInstance = nil;
|
||||||
{
|
{
|
||||||
int gl, volume;
|
int gl, volume;
|
||||||
float aspectRatio;
|
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];
|
[volumeSlider setIntValue:volume];
|
||||||
[videoModeMatrix selectCellWithTag:gl];
|
[videoModeMatrix selectCellWithTag:gl];
|
||||||
[aspectRatioField setFloatValue:aspectRatio];
|
[aspectRatioField setFloatValue:aspectRatio];
|
||||||
|
[romDirField setStringValue:romDirString];
|
||||||
|
|
||||||
[NSApp runModalForWindow:[volumeSlider window]];
|
[NSApp runModalForWindow:[volumeSlider window]];
|
||||||
|
|
||||||
gl = [[videoModeMatrix selectedCell] tag];
|
gl = [[videoModeMatrix selectedCell] tag];
|
||||||
volume = [volumeSlider intValue];
|
volume = [volumeSlider intValue];
|
||||||
aspectRatio = [aspectRatioField floatValue];
|
aspectRatio = [aspectRatioField floatValue];
|
||||||
|
romDirString = [romDirField stringValue];
|
||||||
|
newRomdir = [romDirString cString];
|
||||||
|
|
||||||
setPrefsSettings(gl, volume, aspectRatio);
|
setPrefsSettings(gl, volume, aspectRatio, newRomdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction) prefsOK:(id) sender
|
- (IBAction) prefsOK:(id) sender
|
||||||
|
@ -188,6 +220,16 @@ static Menus *sharedInstance = nil;
|
||||||
[NSApp stopModal];
|
[NSApp stopModal];
|
||||||
[[volumeSlider window] close];
|
[[volumeSlider window] close];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction) romdirSelect:(id) sender
|
||||||
|
{
|
||||||
|
NSString *directory;
|
||||||
|
|
||||||
|
directory = [self browseDir];
|
||||||
|
if (directory != nil)
|
||||||
|
[romDirField setStringValue:directory];
|
||||||
|
}
|
||||||
|
|
||||||
- (IBAction)prefsMenu:(id)sender
|
- (IBAction)prefsMenu:(id)sender
|
||||||
{
|
{
|
||||||
[[Menus sharedInstance] prefsStart];
|
[[Menus sharedInstance] prefsStart];
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
prefsMenu = id;
|
prefsMenu = id;
|
||||||
prefsOK = id;
|
prefsOK = id;
|
||||||
rightJoyChange = id;
|
rightJoyChange = id;
|
||||||
|
romdirSelect = id;
|
||||||
smallerScreen = id;
|
smallerScreen = id;
|
||||||
speedLimit = id;
|
speedLimit = id;
|
||||||
toggleGlFilter = id;
|
toggleGlFilter = id;
|
||||||
|
@ -41,6 +42,7 @@
|
||||||
filterMenu = id;
|
filterMenu = id;
|
||||||
limitSpeedMenu = id;
|
limitSpeedMenu = id;
|
||||||
paddlesMenu = id;
|
paddlesMenu = id;
|
||||||
|
romDirField = id;
|
||||||
videoModeMatrix = id;
|
videoModeMatrix = id;
|
||||||
volumeSlider = id;
|
volumeSlider = id;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>IBDocumentLocation</key>
|
<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>
|
<key>IBEditorPositions</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>29</key>
|
<key>29</key>
|
||||||
|
@ -13,8 +13,8 @@
|
||||||
<string>349.0</string>
|
<string>349.0</string>
|
||||||
<key>IBOpenObjects</key>
|
<key>IBOpenObjects</key>
|
||||||
<array>
|
<array>
|
||||||
<integer>29</integer>
|
|
||||||
<integer>578</integer>
|
<integer>578</integer>
|
||||||
|
<integer>29</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>7H63</string>
|
<string>7H63</string>
|
||||||
|
|
Binary file not shown.
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// 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>
|
#include <cassert>
|
||||||
|
@ -41,6 +41,8 @@ void prefsSave(void);
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
SettingsMACOSX::SettingsMACOSX()
|
SettingsMACOSX::SettingsMACOSX()
|
||||||
{
|
{
|
||||||
|
char workingDir[FILENAME_MAX];
|
||||||
|
|
||||||
// First set variables that the parent class needs
|
// First set variables that the parent class needs
|
||||||
myBaseDir = "./";
|
myBaseDir = "./";
|
||||||
string stelladir = myBaseDir;
|
string stelladir = myBaseDir;
|
||||||
|
@ -65,6 +67,9 @@ SettingsMACOSX::SettingsMACOSX()
|
||||||
#ifdef SNAPSHOT_SUPPORT
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
set("ssdir", "./");
|
set("ssdir", "./");
|
||||||
#endif
|
#endif
|
||||||
|
getwd(workingDir);
|
||||||
|
set("romdir", workingDir);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// 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>
|
#include <fstream>
|
||||||
|
@ -56,8 +56,9 @@ int stellaMain(int argc, char* argv[]);
|
||||||
void setPaddleMode(int mode);
|
void setPaddleMode(int mode);
|
||||||
void setLeftJoystickMode(int mode);
|
void setLeftJoystickMode(int mode);
|
||||||
void setRightJoystickMode(int mode);
|
void setRightJoystickMode(int mode);
|
||||||
void getPrefsSettings(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);
|
void setPrefsSettings(int gl, int volume, float aspect, const char *romdir);
|
||||||
|
void getRomdirSetting(char *romdir);
|
||||||
char *browseFile(void);
|
char *browseFile(void);
|
||||||
void prefsStart(void);
|
void prefsStart(void);
|
||||||
void hideApp(void);
|
void hideApp(void);
|
||||||
|
@ -286,7 +287,7 @@ void setPaddleMode(int mode)
|
||||||
theSettings->setInt("paddle",thePaddleMode);
|
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")
|
if (theSettings->getString("video") == "gl")
|
||||||
*gl = 1;
|
*gl = 1;
|
||||||
|
@ -298,9 +299,16 @@ void getPrefsSettings(int *gl, int *volume, float *aspect)
|
||||||
*volume = 100;
|
*volume = 100;
|
||||||
|
|
||||||
*aspect = theSettings->getFloat("gl_aspect");
|
*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)
|
if (gl)
|
||||||
theSettings->setString("video","gl");
|
theSettings->setString("video","gl");
|
||||||
|
@ -311,6 +319,8 @@ void setPrefsSettings(int gl, int volume, float aspect)
|
||||||
theSound->setVolume(volume);
|
theSound->setVolume(volume);
|
||||||
|
|
||||||
theSettings->setFloat("gl_aspect",aspect);
|
theSettings->setFloat("gl_aspect",aspect);
|
||||||
|
|
||||||
|
theSettings->setString("romdir",romdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -392,7 +392,7 @@
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>StellaOSX</string>
|
<string>StellaOSX</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>1.4</string>
|
<string>1.4.1</string>
|
||||||
<key>CFBundleHelpBookFolder</key>
|
<key>CFBundleHelpBookFolder</key>
|
||||||
<string>docs</string>
|
<string>docs</string>
|
||||||
<key>CFBundleHelpBookName</key>
|
<key>CFBundleHelpBookName</key>
|
||||||
|
@ -408,7 +408,7 @@
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>StLa</string>
|
<string>StLa</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.4</string>
|
<string>1.4.1</string>
|
||||||
<key>NSMainNibFile</key>
|
<key>NSMainNibFile</key>
|
||||||
<string>SDLMain.nib</string>
|
<string>SDLMain.nib</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
|
|
Loading…
Reference in New Issue