mirror of https://github.com/stella-emu/stella.git
Changed some FIXME's to TODO's, since they probably won't be done for the
next release. Added support for inspecting the modification time of the rom directory, and forcing a reload if that directory has been changed. So, if you add or delete a ROM from the romdir, the next time you start Stella, it will automatically reload the rom listing for you. Pretty cool I think :) Added support for each derived OSystem to set its video drivers, and support to the VideoDialog to show them in a dropdown menu. That means that Win32 users will be able to select between 'windib' and 'directx' in the VideoDialog (when I update the Win32 code to do so). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@440 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
9722d7f554
commit
1017bd3222
|
@ -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: FSNode.hxx,v 1.4 2005-05-25 17:17:37 stephena Exp $
|
||||
// $Id: FSNode.hxx,v 1.5 2005-05-26 18:56:57 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -140,6 +140,11 @@ class AbstractFilesystemNode
|
|||
*/
|
||||
static bool makeDir(const string& path);
|
||||
|
||||
/**
|
||||
Return a string representing the last modification time of this file/dir.
|
||||
*/
|
||||
static string modTime(const string& path);
|
||||
|
||||
/* TODO:
|
||||
bool isReadable();
|
||||
bool isWriteable();
|
||||
|
|
|
@ -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: OSystem.cxx,v 1.20 2005-05-25 17:17:37 stephena Exp $
|
||||
// $Id: OSystem.cxx,v 1.21 2005-05-26 18:56:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -81,6 +81,8 @@ OSystem::OSystem()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
OSystem::~OSystem()
|
||||
{
|
||||
myDriverList.clear();
|
||||
|
||||
delete myMenu;
|
||||
delete myLauncher;
|
||||
|
||||
|
@ -152,7 +154,7 @@ bool OSystem::createFrameBuffer(bool showmessage)
|
|||
if(mySettings->getBool("showinfo"))
|
||||
{
|
||||
buf = "Video driver: " + videodriver;
|
||||
cout << buf << endl;
|
||||
cout << buf << endl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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: OSystem.hxx,v 1.17 2005-05-25 17:17:37 stephena Exp $
|
||||
// $Id: OSystem.hxx,v 1.18 2005-05-26 18:56:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef OSYSTEM_HXX
|
||||
|
@ -29,6 +29,7 @@ class Launcher;
|
|||
#include "Sound.hxx"
|
||||
#include "Settings.hxx"
|
||||
#include "Console.hxx"
|
||||
#include "StringList.hxx"
|
||||
#include "bspf.hxx"
|
||||
|
||||
|
||||
|
@ -38,7 +39,7 @@ class Launcher;
|
|||
other objects belong.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: OSystem.hxx,v 1.17 2005-05-25 17:17:37 stephena Exp $
|
||||
@version $Id: OSystem.hxx,v 1.18 2005-05-26 18:56:58 stephena Exp $
|
||||
*/
|
||||
class OSystem
|
||||
{
|
||||
|
@ -237,6 +238,13 @@ class OSystem
|
|||
*/
|
||||
const string& features() { return myFeatures; }
|
||||
|
||||
/**
|
||||
The features which are conditionally compiled into Stella.
|
||||
|
||||
@return The supported features
|
||||
*/
|
||||
const StringList& driverList() { return myDriverList; }
|
||||
|
||||
/**
|
||||
Open the given ROM and return an array containing its contents.
|
||||
|
||||
|
@ -324,6 +332,9 @@ class OSystem
|
|||
// Time per frame for a video update, based on the current framerate
|
||||
uInt32 myTimePerFrame;
|
||||
|
||||
// Holds the types of SDL video driver supported by this OSystem
|
||||
StringList myDriverList;
|
||||
|
||||
private:
|
||||
string myBaseDir;
|
||||
string myStateDir;
|
||||
|
|
|
@ -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: Settings.cxx,v 1.45 2005-05-19 18:42:37 stephena Exp $
|
||||
// $Id: Settings.cxx,v 1.46 2005-05-26 18:56:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -67,6 +67,7 @@ Settings::Settings(OSystem* osystem)
|
|||
|
||||
set("romdir", "");
|
||||
set("lastrom", "");
|
||||
set("modtime", ""); // romdir last modification time
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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: AudioDialog.cxx,v 1.6 2005-05-13 18:28:05 stephena Exp $
|
||||
// $Id: AudioDialog.cxx,v 1.7 2005-05-26 18:56:58 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -170,7 +170,6 @@ void AudioDialog::setDefaults()
|
|||
myVolumeSlider->setValue(100);
|
||||
myVolumeLabel->setLabel("100");
|
||||
|
||||
// FIXME - get defaults from OSystem or Settings
|
||||
#ifdef WIN32
|
||||
myFragsizePopup->setSelectedTag(4);
|
||||
#else
|
||||
|
|
|
@ -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: Dialog.cxx,v 1.17 2005-05-26 15:43:44 stephena Exp $
|
||||
// $Id: Dialog.cxx,v 1.18 2005-05-26 18:56:58 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -204,25 +204,6 @@ void Dialog::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
if(_focusedWidget)
|
||||
if (_focusedWidget->handleKeyDown(ascii, keycode, modifiers))
|
||||
return;
|
||||
|
||||
// Hotkey handling
|
||||
if(ascii != 0)
|
||||
{
|
||||
Widget* w = _firstWidget;
|
||||
ascii = toupper(ascii);
|
||||
while(w)
|
||||
{
|
||||
if(0)//FIXME - don't let it access a protected variable w->_type == kButtonWidget && ascii == toupper(((ButtonWidget *)w)->_hotkey))
|
||||
{
|
||||
// The hotkey for widget w was pressed. We fake a mouse click into the
|
||||
// button by invoking the appropriate methods.
|
||||
w->handleMouseDown(0, 0, 1, 1);
|
||||
w->handleMouseUp(0, 0, 1, 1);
|
||||
return;
|
||||
}
|
||||
w = w->_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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: LauncherDialog.cxx,v 1.17 2005-05-25 17:17:38 stephena Exp $
|
||||
// $Id: LauncherDialog.cxx,v 1.18 2005-05-26 18:56:58 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -148,27 +148,27 @@ void LauncherDialog::updateListing(bool fullReload)
|
|||
{
|
||||
enableButtons(false);
|
||||
|
||||
// Figure out if the ROM dir has changed since we last accessed it.
|
||||
// If so, we do a full reload from disk (takes quite some time).
|
||||
// Otherwise, we can use the cache file (which is much faster).
|
||||
// FIXME - actually implement the following code, where we use
|
||||
// a function to detect last modification time, and compare
|
||||
// it to the current modification time
|
||||
/*
|
||||
if(ROM_DIR_CHANGED)
|
||||
loadListFromDisk();
|
||||
else if(CACHE_FILE_EXISTS)
|
||||
loadListFromCache();
|
||||
else // we have no other choice
|
||||
loadListFromDisk();
|
||||
*/
|
||||
// Start with empty list
|
||||
myGameList->clear();
|
||||
|
||||
string romdir = instance()->settings().getString("romdir");
|
||||
string cacheFile = instance()->cacheFile();
|
||||
if(FilesystemNode::fileExists(cacheFile) && !fullReload)
|
||||
|
||||
// Figure out if the ROM dir has changed since we last accessed it.
|
||||
// If so, we do a full reload from disk (takes quite some time).
|
||||
// Otherwise, we can use the cache file (which is much faster).
|
||||
string currentModTime = FilesystemNode::modTime(romdir);
|
||||
string oldModTime = instance()->settings().getString("modtime");
|
||||
/*
|
||||
cerr << "old: \'" << oldModTime << "\'\n"
|
||||
<< "current: \'" << currentModTime << "\'\n"
|
||||
<< endl;
|
||||
*/
|
||||
if(currentModTime != oldModTime) // romdir has changed
|
||||
loadListFromDisk();
|
||||
else if(FilesystemNode::fileExists(cacheFile) && !fullReload)
|
||||
loadListFromCache();
|
||||
else
|
||||
else // we have no other choice
|
||||
loadListFromDisk();
|
||||
|
||||
// Now fill the list widget with the contents of the GameList
|
||||
|
@ -260,6 +260,11 @@ void LauncherDialog::loadListFromDisk()
|
|||
// And create a cache file, so that the next time Stella starts,
|
||||
// we don't have to do this time-consuming operation again
|
||||
createListCache();
|
||||
|
||||
// Finally, update the modification time so we don't have to needlessly
|
||||
// call this method again
|
||||
string currentModTime = FilesystemNode::modTime(romdir);
|
||||
instance()->settings().setString("modtime", currentModTime);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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: VideoDialog.cxx,v 1.13 2005-05-19 18:42:38 stephena Exp $
|
||||
// $Id: VideoDialog.cxx,v 1.14 2005-05-26 18:56:58 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -52,23 +52,27 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
|
|||
// Video driver (query OSystem for what's supported)
|
||||
myDriverPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight,
|
||||
"Driver: ", labelWidth);
|
||||
// myDriverPopup->appendEntry("First one", 1);
|
||||
// myDriverPopup->appendEntry("Another one", 2);
|
||||
unsigned int itemNum = 1;
|
||||
StringList::const_iterator iter;
|
||||
if(instance()->driverList().size() > 0)
|
||||
{
|
||||
for (iter = instance()->driverList().begin(); iter != instance()->driverList().end();
|
||||
++iter, ++itemNum)
|
||||
{
|
||||
myDriverPopup->appendEntry(*iter, itemNum);
|
||||
}
|
||||
}
|
||||
else
|
||||
myDriverPopup->setEnabled(false);
|
||||
yoff += kVideoRowHeight + 4;
|
||||
|
||||
// FIXME - get list of video drivers from OSystem
|
||||
// const Common::LanguageDescription *l = Common::g_languages;
|
||||
// for (; l->code; ++l) {
|
||||
// _langPopUp->appendEntry(l->description, l->id);
|
||||
// }
|
||||
|
||||
// FIXME - get list of renderers from OSystem
|
||||
// Also, make these options work without requiring a restart
|
||||
// Video renderer
|
||||
myRendererPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight,
|
||||
"Renderer: ", labelWidth, kRendererChanged);
|
||||
myRendererPopup->appendEntry("Software", 1);
|
||||
#ifdef DISPLAY_OPENGL
|
||||
myRendererPopup->appendEntry("OpenGL", 2);
|
||||
#endif
|
||||
yoff += kVideoRowHeight + 4;
|
||||
|
||||
// Video filter
|
||||
|
@ -151,7 +155,18 @@ void VideoDialog::loadConfig()
|
|||
double f;
|
||||
|
||||
// Driver setting
|
||||
myDriverPopup->setSelectedTag(0); // FIXME
|
||||
s = instance()->settings().getString("video_driver");
|
||||
unsigned int itemNum = 1;
|
||||
StringList::const_iterator iter;
|
||||
for (iter = instance()->driverList().begin(); iter != instance()->driverList().end();
|
||||
++iter, ++itemNum)
|
||||
{
|
||||
if(*iter == s)
|
||||
{
|
||||
myDriverPopup->setSelectedTag(itemNum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Renderer setting
|
||||
s = instance()->settings().getString("video");
|
||||
|
@ -159,6 +174,8 @@ void VideoDialog::loadConfig()
|
|||
myRendererPopup->setSelectedTag(1);
|
||||
else if(s == "gl")
|
||||
myRendererPopup->setSelectedTag(2);
|
||||
else
|
||||
myRendererPopup->setSelectedTag(1);
|
||||
|
||||
// Filter setting
|
||||
s = instance()->settings().getString("gl_filter");
|
||||
|
@ -224,11 +241,7 @@ void VideoDialog::saveConfig()
|
|||
|
||||
// Driver setting
|
||||
s = myDriverPopup->getSelectedString();
|
||||
if(s != instance()->settings().getString("video_driver"))
|
||||
{
|
||||
instance()->settings().setString("video_driver", s);
|
||||
restart = true;
|
||||
}
|
||||
instance()->settings().setString("video_driver", s);
|
||||
|
||||
// Renderer setting
|
||||
i = myRendererPopup->getSelectedTag();
|
||||
|
@ -305,10 +318,8 @@ void VideoDialog::saveConfig()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void VideoDialog::setDefaults()
|
||||
{
|
||||
// FIXME - for now, this option isn't available
|
||||
myDriverPopup->setSelectedTag(0);
|
||||
myDriverPopup->setEnabled(false);
|
||||
|
||||
if(myDriverPopup->isEnabled())
|
||||
myDriverPopup->setSelectedTag(1);
|
||||
myRendererPopup->setSelectedTag(1);
|
||||
myFilterPopup->setSelectedTag(1);
|
||||
myPalettePopup->setSelectedTag(1);
|
||||
|
|
|
@ -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: Widget.cxx,v 1.10 2005-05-16 00:02:32 stephena Exp $
|
||||
// $Id: Widget.cxx,v 1.11 2005-05-26 18:56:58 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -141,7 +141,7 @@ void StaticTextWidget::setValue(int value)
|
|||
_label = buf;
|
||||
|
||||
// Refresh the screen when the text has changed
|
||||
// FIXME - eventually, this should be a dirty rectangle
|
||||
// TODO - eventually, this should be a dirty rectangle
|
||||
_boss->instance()->frameBuffer().refresh();
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ void CheckboxWidget::setState(bool state)
|
|||
sendCommand(_cmd, _state);
|
||||
|
||||
// Refresh the screen after the checkbox is drawn
|
||||
// FIXME - eventually, this should be a dirty rectangle
|
||||
// TODO - eventually, this should be a dirty rectangle
|
||||
_boss->instance()->frameBuffer().refresh();
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,7 @@ void SliderWidget::handleMouseMoved(int x, int y, int button)
|
|||
sendCommand(_cmd, _value);
|
||||
}
|
||||
// Refresh the screen while the slider is being redrawn
|
||||
// FIXME - eventually, this should be a dirty rectangle
|
||||
// TODO - eventually, this should be a dirty rectangle
|
||||
_boss->instance()->frameBuffer().refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: FSNodePOSIX.cxx,v 1.5 2005-05-25 17:17:38 stephena Exp $
|
||||
// $Id: FSNodePOSIX.cxx,v 1.6 2005-05-26 18:56:58 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -32,6 +32,8 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/*
|
||||
* Implementation of the Stella file system API based on POSIX (for Linux and OSX)
|
||||
*/
|
||||
|
@ -230,3 +232,16 @@ bool AbstractFilesystemNode::makeDir(const string& path)
|
|||
{
|
||||
return mkdir(path.c_str(), 0777) == 0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string AbstractFilesystemNode::modTime(const string& path)
|
||||
{
|
||||
struct stat st;
|
||||
if(stat(path.c_str(), &st) != 0)
|
||||
return "";
|
||||
|
||||
ostringstream buf;
|
||||
buf << st.st_mtime;
|
||||
|
||||
return buf.str();
|
||||
}
|
||||
|
|
|
@ -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: OSystemUNIX.cxx,v 1.10 2005-05-26 15:43:44 stephena Exp $
|
||||
// $Id: OSystemUNIX.cxx,v 1.11 2005-05-26 18:56:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cstdlib>
|
||||
|
@ -43,6 +43,10 @@
|
|||
setConfigFiles()
|
||||
setCacheFile()
|
||||
|
||||
And for initializing the following variables:
|
||||
|
||||
myDriverList (a StringList)
|
||||
|
||||
See OSystem.hxx for a further explanation
|
||||
*/
|
||||
|
||||
|
@ -66,6 +70,8 @@ OSystemUNIX::OSystemUNIX()
|
|||
|
||||
string cacheFile = basedir + "/stella.cache";
|
||||
setCacheFile(cacheFile);
|
||||
|
||||
// No drivers are specified for Unix
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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: OSystemWin32.cxx,v 1.2 2005-05-25 17:17:38 stephena Exp $
|
||||
// $Id: OSystemWin32.cxx,v 1.3 2005-05-26 18:56:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -34,13 +34,17 @@
|
|||
setConfigFiles()
|
||||
setCacheFile()
|
||||
|
||||
And for initializing the following variables:
|
||||
|
||||
myDriverList (a StringList)
|
||||
|
||||
See OSystem.hxx for a further explanation
|
||||
*/
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
OSystemWin32::OSystemWin32()
|
||||
{
|
||||
// FIXME - there really should be code here to determine which version
|
||||
// TODO - there really should be code here to determine which version
|
||||
// of Windows is being used.
|
||||
// If using a version which supports multiple users (NT and above),
|
||||
// the relevant directories should be created in per-user locations.
|
||||
|
@ -60,6 +64,9 @@ OSystemWin32::OSystemWin32()
|
|||
|
||||
string cacheFile = basedir + "stella.cache";
|
||||
setCacheFile(cacheFile);
|
||||
|
||||
myDriverList.push_back("windib");
|
||||
myDriverList.push_back("directx");
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
Loading…
Reference in New Issue