mirror of https://github.com/stella-emu/stella.git
A few more 'ROM browse mode' updates. Selecting a directory entry now
descends into that directory. Next I have to add a 'Go Up' button to exit go in the other direction. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1025 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
7ab6afbd74
commit
5b4d441d36
|
@ -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: GameList.cxx,v 1.7 2006-03-08 20:03:03 stephena Exp $
|
// $Id: GameList.cxx,v 1.8 2006-03-09 00:29:52 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from KStella - Stella frontend
|
// Based on code from KStella - Stella frontend
|
||||||
// Copyright (C) 2003-2005 Stephen Anthony
|
// Copyright (C) 2003-2005 Stephen Anthony
|
||||||
|
@ -37,12 +37,12 @@ GameList::~GameList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void GameList::appendGame(const string& rom, const string& name,
|
void GameList::appendGame(const string& name, const string& path,
|
||||||
const string& note, bool isDir)
|
const string& note, bool isDir)
|
||||||
{
|
{
|
||||||
Entry g;
|
Entry g;
|
||||||
g._rom = rom;
|
|
||||||
g._name = name;
|
g._name = name;
|
||||||
|
g._path = path;
|
||||||
g._note = note;
|
g._note = note;
|
||||||
g._isdir = isDir;
|
g._isdir = isDir;
|
||||||
|
|
||||||
|
|
|
@ -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: GameList.hxx,v 1.8 2006-03-08 20:03:03 stephena Exp $
|
// $Id: GameList.hxx,v 1.9 2006-03-09 00:29:52 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from KStella - Stella frontend
|
// Based on code from KStella - Stella frontend
|
||||||
// Copyright (C) 2003-2005 Stephen Anthony
|
// Copyright (C) 2003-2005 Stephen Anthony
|
||||||
|
@ -32,8 +32,8 @@ class GameList
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct Entry {
|
struct Entry {
|
||||||
string _rom;
|
|
||||||
string _name;
|
string _name;
|
||||||
|
string _path;
|
||||||
string _note;
|
string _note;
|
||||||
bool _isdir;
|
bool _isdir;
|
||||||
};
|
};
|
||||||
|
@ -45,14 +45,15 @@ class GameList
|
||||||
GameList();
|
GameList();
|
||||||
~GameList();
|
~GameList();
|
||||||
|
|
||||||
inline const string& rom(int i) { return myArray[i]._rom; }
|
|
||||||
inline const string& name(int i) { return myArray[i]._name; }
|
inline const string& name(int i) { return myArray[i]._name; }
|
||||||
|
inline const string& path(int i) { return myArray[i]._path; }
|
||||||
inline const string& note(int i) { return myArray[i]._note; }
|
inline const string& note(int i) { return myArray[i]._note; }
|
||||||
inline const bool isDir(int i) { return myArray[i]._isdir; }
|
inline const bool isDir(int i) { return myArray[i]._isdir; }
|
||||||
|
|
||||||
inline int size() { return myArray.size(); }
|
inline int size() { return myArray.size(); }
|
||||||
|
|
||||||
void clear() { myArray.clear(); }
|
void clear() { myArray.clear(); }
|
||||||
void appendGame(const string& rom, const string& name, const string& note,
|
void appendGame(const string& name, const string& path, const string& note,
|
||||||
bool isDir = false);
|
bool isDir = false);
|
||||||
void sortByName();
|
void sortByName();
|
||||||
};
|
};
|
||||||
|
|
|
@ -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: LauncherDialog.cxx,v 1.43 2006-03-08 20:03:03 stephena Exp $
|
// $Id: LauncherDialog.cxx,v 1.44 2006-03-09 00:29:52 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -191,12 +191,10 @@ void LauncherDialog::updateListing(bool fullReload)
|
||||||
// Start with empty list
|
// Start with empty list
|
||||||
myGameList->clear();
|
myGameList->clear();
|
||||||
|
|
||||||
string romdir = instance()->settings().getString("romdir");
|
|
||||||
string cacheFile = instance()->cacheFile();
|
|
||||||
|
|
||||||
// If this is the first time using Stella, the romdir won't be set.
|
// If this is the first time using Stella, the romdir won't be set.
|
||||||
// In that case, display the options dialog, and don't let Stella proceed
|
// In that case, display the options dialog, and don't let Stella proceed
|
||||||
// until the options are set.
|
// until the options are set.
|
||||||
|
string romdir = instance()->settings().getString("romdir");
|
||||||
if(romdir == "")
|
if(romdir == "")
|
||||||
{
|
{
|
||||||
myOptionsButton->setEnabled(true);
|
myOptionsButton->setEnabled(true);
|
||||||
|
@ -212,7 +210,7 @@ void LauncherDialog::updateListing(bool fullReload)
|
||||||
if(myCurrentDir == "")
|
if(myCurrentDir == "")
|
||||||
myCurrentDir = romdir;
|
myCurrentDir = romdir;
|
||||||
|
|
||||||
loadDirListing(myCurrentDir);
|
loadDirListing();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -224,7 +222,7 @@ void LauncherDialog::updateListing(bool fullReload)
|
||||||
|
|
||||||
if(currentModTime != oldModTime) // romdir has changed
|
if(currentModTime != oldModTime) // romdir has changed
|
||||||
loadListFromDisk();
|
loadListFromDisk();
|
||||||
else if(FilesystemNode::fileExists(cacheFile) && !fullReload)
|
else if(FilesystemNode::fileExists(instance()->cacheFile()) && !fullReload)
|
||||||
loadListFromCache();
|
loadListFromCache();
|
||||||
else // we have no other choice
|
else // we have no other choice
|
||||||
loadListFromDisk();
|
loadListFromDisk();
|
||||||
|
@ -275,11 +273,11 @@ void LauncherDialog::updateListing(bool fullReload)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void LauncherDialog::loadDirListing(const string& path)
|
void LauncherDialog::loadDirListing()
|
||||||
{
|
{
|
||||||
cerr << "browse path = " << path << endl;
|
cerr << "browse path = " << myCurrentDir << endl;
|
||||||
|
|
||||||
FilesystemNode dir(path);
|
FilesystemNode dir(myCurrentDir);
|
||||||
FSList files = dir.listDir(FilesystemNode::kListAll);
|
FSList files = dir.listDir(FilesystemNode::kListAll);
|
||||||
|
|
||||||
for(unsigned int idx = 0; idx < files.size(); idx++)
|
for(unsigned int idx = 0; idx < files.size(); idx++)
|
||||||
|
@ -289,7 +287,7 @@ cerr << "browse path = " << path << endl;
|
||||||
if(isDir)
|
if(isDir)
|
||||||
name = " [" + name + "]";
|
name = " [" + name + "]";
|
||||||
|
|
||||||
myGameList->appendGame(files[idx].path(), name, "", isDir);
|
myGameList->appendGame(name, files[idx].path(), "", isDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the list by rom name (since that's what we see in the listview)
|
// Sort the list by rom name (since that's what we see in the listview)
|
||||||
|
@ -306,25 +304,23 @@ void LauncherDialog::loadListFromDisk()
|
||||||
// Create a progress dialog box to show the progress of processing
|
// Create a progress dialog box to show the progress of processing
|
||||||
// the ROMs, since this is usually a time-consuming operation
|
// the ROMs, since this is usually a time-consuming operation
|
||||||
ProgressDialog progress(this, instance()->launcherFont(),
|
ProgressDialog progress(this, instance()->launcherFont(),
|
||||||
"Loading ROM's from disk ...");
|
"Loading ROM info from disk ...");
|
||||||
progress.setRange(0, files.size() - 1, 10);
|
progress.setRange(0, files.size() - 1, 10);
|
||||||
|
|
||||||
// Create a entry for the GameList for each file
|
// Create a entry for the GameList for each file
|
||||||
Properties props;
|
Properties props;
|
||||||
string path = dir.path(), rom, md5, name, note;
|
string md5, name, note;
|
||||||
for (unsigned int idx = 0; idx < files.size(); idx++)
|
for (unsigned int idx = 0; idx < files.size(); idx++)
|
||||||
{
|
{
|
||||||
rom = path + files[idx].displayName();
|
|
||||||
|
|
||||||
// Calculate the MD5 so we can get the rest of the info
|
// Calculate the MD5 so we can get the rest of the info
|
||||||
// from the PropertiesSet (stella.pro)
|
// from the PropertiesSet (stella.pro)
|
||||||
md5 = MD5FromFile(rom);
|
md5 = MD5FromFile(files[idx].path());
|
||||||
instance()->propSet().getMD5(md5, props);
|
instance()->propSet().getMD5(md5, props);
|
||||||
name = props.get(Cartridge_Name);
|
name = props.get(Cartridge_Name);
|
||||||
note = props.get(Cartridge_Note);
|
note = props.get(Cartridge_Note);
|
||||||
|
|
||||||
// Indicate that this ROM doesn't have a properties entry
|
// Indicate that this ROM doesn't have a properties entry
|
||||||
myGameList->appendGame(rom, name, note);
|
myGameList->appendGame(name, files[idx].path(), note);
|
||||||
|
|
||||||
// Update the progress bar, indicating one more ROM has been processed
|
// Update the progress bar, indicating one more ROM has been processed
|
||||||
progress.setProgress(idx);
|
progress.setProgress(idx);
|
||||||
|
@ -358,7 +354,7 @@ void LauncherDialog::loadListFromCache()
|
||||||
// It seems terribly ugly that we need to use char arrays
|
// It seems terribly ugly that we need to use char arrays
|
||||||
// instead of strings. Or maybe I don't know the correct way ??
|
// instead of strings. Or maybe I don't know the correct way ??
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
string line, rom, name, note;
|
string line, name, path, note;
|
||||||
string::size_type pos1, pos2; // The locations of the two '|' characters
|
string::size_type pos1, pos2; // The locations of the two '|' characters
|
||||||
|
|
||||||
// Keep reading until all lines have been inspected
|
// Keep reading until all lines have been inspected
|
||||||
|
@ -373,13 +369,13 @@ void LauncherDialog::loadListFromCache()
|
||||||
pos2 = line.find("|", pos1+1);
|
pos2 = line.find("|", pos1+1);
|
||||||
if(pos2 == string::npos) continue;
|
if(pos2 == string::npos) continue;
|
||||||
|
|
||||||
rom = line.substr(0, pos1);
|
path = line.substr(0, pos1);
|
||||||
name = line.substr(pos1+1, pos2-pos1-1);
|
name = line.substr(pos1+1, pos2-pos1-1);
|
||||||
note = line.substr(pos2+1);
|
note = line.substr(pos2+1);
|
||||||
|
|
||||||
// Add this game to the list
|
// Add this game to the list
|
||||||
// We don't do sorting, since it's assumed to be done by loadListFromDisk()
|
// We don't do sorting, since it's assumed to be done by loadListFromDisk()
|
||||||
myGameList->appendGame(rom, name, note);
|
myGameList->appendGame(name, path, note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +388,7 @@ void LauncherDialog::createListCache()
|
||||||
// Write the gamelist to the cachefile (sorting is already done)
|
// Write the gamelist to the cachefile (sorting is already done)
|
||||||
for (int i = 0; i < (int) myGameList->size(); ++i)
|
for (int i = 0; i < (int) myGameList->size(); ++i)
|
||||||
{
|
{
|
||||||
out << myGameList->rom(i) << "|"
|
out << myGameList->path(i) << "|"
|
||||||
<< myGameList->name(i) << "|"
|
<< myGameList->name(i) << "|"
|
||||||
<< myGameList->note(i)
|
<< myGameList->note(i)
|
||||||
<< endl;
|
<< endl;
|
||||||
|
@ -489,17 +485,20 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
item = myList->getSelected();
|
item = myList->getSelected();
|
||||||
if(item >= 0)
|
if(item >= 0)
|
||||||
{
|
{
|
||||||
|
string entry = myGameList->path(item);
|
||||||
|
|
||||||
// Directory's should be selected (ie, enter them and redisplay)
|
// Directory's should be selected (ie, enter them and redisplay)
|
||||||
if(myBrowseModeFlag && myGameList->isDir(item))
|
if(myBrowseModeFlag && myGameList->isDir(item))
|
||||||
{
|
{
|
||||||
cerr << "enter \'" << myGameList->rom(item) << "\' directory\n";
|
myCurrentDir = entry;
|
||||||
|
updateListing();
|
||||||
}
|
}
|
||||||
else if(instance()->createConsole(myGameList->rom(item)))
|
else if(instance()->createConsole(entry))
|
||||||
{
|
{
|
||||||
#if !defined(GP2X) // Quick GP2X hack to spare flash-card saves
|
#if !defined(GP2X) // Quick GP2X hack to spare flash-card saves
|
||||||
// Make sure the console creation actually succeeded
|
// Make sure the console creation actually succeeded
|
||||||
string selected = myList->getSelectedString();
|
instance()->settings().setString("lastrom",
|
||||||
instance()->settings().setString("lastrom", selected);
|
myList->getSelectedString());
|
||||||
#endif
|
#endif
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: LauncherDialog.hxx,v 1.15 2006-03-08 20:03:03 stephena Exp $
|
// $Id: LauncherDialog.hxx,v 1.16 2006-03-09 00:29:52 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -75,7 +75,7 @@ class LauncherDialog : public Dialog
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void enableButtons(bool enable);
|
void enableButtons(bool enable);
|
||||||
void loadDirListing(const string& path);
|
void loadDirListing();
|
||||||
void loadListFromDisk();
|
void loadListFromDisk();
|
||||||
void loadListFromCache();
|
void loadListFromCache();
|
||||||
void createListCache();
|
void createListCache();
|
||||||
|
|
Loading…
Reference in New Issue