Fixed issues with sorting ROMs in the ROM launcher. Moved to C++ STL

sorting, since it seems to be faster.  Fixed issue with directories
sometimes not being sorted correctly.

Bumped version number for next bugfix release.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1085 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-04-12 13:32:06 +00:00
parent dc11eb4d5c
commit 13f5924721
5 changed files with 45 additions and 88 deletions

View File

@ -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: FrameBufferGL.cxx,v 1.60 2006-03-25 00:34:17 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.61 2006-04-12 13:32:06 stephena Exp $
//============================================================================
#ifdef DISPLAY_OPENGL
@ -399,6 +399,12 @@ void FrameBufferGL::postFrameUpdate()
p_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, myTexture->w, myTexture->h,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, myTexture->pixels);
p_glBegin(GL_QUADS);
/* Upside down !
p_glTexCoord2f(myTexCoord[2], myTexCoord[3]); p_glVertex2i(0, 0);
p_glTexCoord2f(myTexCoord[0], myTexCoord[3]); p_glVertex2i(w, 0);
p_glTexCoord2f(myTexCoord[0], myTexCoord[1]); p_glVertex2i(w, h);
p_glTexCoord2f(myTexCoord[2], myTexCoord[1]); p_glVertex2i(0, h);
*/
p_glTexCoord2f(myTexCoord[0], myTexCoord[1]); p_glVertex2i(0, 0);
p_glTexCoord2f(myTexCoord[2], myTexCoord[1]); p_glVertex2i(w, 0);
p_glTexCoord2f(myTexCoord[2], myTexCoord[3]); p_glVertex2i(w, h);

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Version.hxx,v 1.15 2006-04-05 16:06:59 stephena Exp $
// $Id: Version.hxx,v 1.16 2006-04-12 13:32:06 stephena Exp $
//============================================================================
#ifndef VERSION_HXX
#define VERSION_HXX
#define STELLA_BASE_VERSION "2.2"
#define STELLA_BASE_VERSION "2.2.1_cvs"
#ifdef NIGHTLY_BUILD
#define STELLA_VERSION STELLA_BASE_VERSION "pre-" NIGHTLY_BUILD

View File

@ -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: GameList.cxx,v 1.9 2006-03-10 00:29:46 stephena Exp $
// $Id: GameList.cxx,v 1.10 2006-04-12 13:32:06 stephena Exp $
//
// Based on code from KStella - Stella frontend
// Copyright (C) 2003-2005 Stephen Anthony
@ -40,90 +40,43 @@ GameList::~GameList()
void GameList::appendGame(const string& name, const string& path,
const string& note, bool isDir)
{
Entry* g = new Entry;
g->_name = name;
g->_path = path;
g->_note = note;
g->_isdir = isDir;
Entry g;
g._name = name;
g._path = path;
g._note = note;
g._isdir = isDir;
myArray.push_back(g);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameList::clear()
{
for(unsigned int i = 0; i < myArray.size(); ++i)
delete myArray[i];
myArray.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameList::sortByName()
{
if(myArray.size() <= 1)
return;
QuickSort(myArray, 0, myArray.size()-1);
sort(myArray.begin(), myArray.end());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameList::QuickSort(EntryList& a, int left, int right)
bool GameList::Entry::operator< (const Entry& g) const
{
int l_hold = left;
int r_hold = right;
Entry* pivot_entry = a[left];
string::const_iterator it1 = _name.begin();
string::const_iterator it2 = g._name.begin();
while (left < right)
{
while ((compare(a[right]->_name, pivot_entry->_name) >= 0) && (left < right))
right--;
if (left != right)
{
a[left] = a[right];
left++;
}
while ((compare(a[left]->_name, pivot_entry->_name) <= 0) && (left < right))
left++;
if (left != right)
{
a[right] = a[left];
right--;
}
}
a[left] = pivot_entry;
int pivot = left;
left = l_hold;
right = r_hold;
if (left < pivot)
QuickSort(a, left, pivot-1);
if (right > pivot)
QuickSort(a, pivot+1, right);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int GameList::compare(const string& s1, const string& s2)
{
string::const_iterator it1=s1.begin();
string::const_iterator it2=s2.begin();
// Account for ending ']' character in directory entries
string::const_iterator end1 = _isdir ? _name.end() - 1 : _name.end();
string::const_iterator end2 = g._isdir ? g._name.end() - 1 : g._name.end();
// Stop when either string's end has been reached
while( (it1 != s1.end()) && (it2 != s2.end()) )
while((it1 != end1) && (it2 != end2))
{
if(::toupper(*it1) != ::toupper(*it2)) // letters differ?
// return -1 to indicate smaller than, 1 otherwise
return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1;
if(toupper(*it1) != toupper(*it2)) // letters differ?
return toupper(*it1) < toupper(*it2);
// proceed to the next character in each string
++it1;
++it2;
}
size_t size1 = s1.size(), size2 = s2.size(); // cache lengths
// return -1,0 or 1 according to strings' lengths
if (size1 == size2)
return 0;
else
return (size1 < size2) ? -1 : 1;
return _name.size() < g._name.size();
}

View File

@ -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: GameList.hxx,v 1.10 2006-03-10 00:29:46 stephena Exp $
// $Id: GameList.hxx,v 1.11 2006-04-12 13:32:06 stephena Exp $
//
// Based on code from KStella - Stella frontend
// Copyright (C) 2003-2005 Stephen Anthony
@ -22,7 +22,7 @@
#ifndef GAME_LIST_HXX
#define GAME_LIST_HXX
#include "Array.hxx"
#include <vector>
#include "bspf.hxx"
/**
@ -30,40 +30,37 @@
*/
class GameList
{
private:
struct Entry {
string _name;
string _path;
string _note;
bool _isdir;
};
typedef Common::Array<Entry*> EntryList;
EntryList myArray;
public:
GameList();
~GameList();
inline const string& name(int i)
{ return i < (int)myArray.size() ? myArray[i]->_name : EmptyString; }
{ return i < (int)myArray.size() ? myArray[i]._name : EmptyString; }
inline const string& path(int i)
{ return i < (int)myArray.size() ? myArray[i]->_path : EmptyString; }
{ return i < (int)myArray.size() ? myArray[i]._path : EmptyString; }
inline const string& note(int i)
{ return i < (int)myArray.size() ? myArray[i]->_note : EmptyString; }
{ return i < (int)myArray.size() ? myArray[i]._note : EmptyString; }
inline const bool isDir(int i)
{ return i < (int)myArray.size() ? myArray[i]->_isdir: false; }
{ return i < (int)myArray.size() ? myArray[i]._isdir: false; }
inline int size() { return myArray.size(); }
void clear();
inline void clear() { myArray.clear(); }
void appendGame(const string& name, const string& path, const string& note,
bool isDir = false);
void sortByName();
private:
static void QuickSort(EntryList& list, int l, int r);
inline static int compare(const string& s1, const string& s2);
class Entry {
public:
string _name;
string _path;
string _note;
bool _isdir;
bool operator < (const Entry& a) const;
};
vector<Entry> myArray;
};
#endif

View File

@ -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.52 2006-03-20 13:23:13 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.53 2006-04-12 13:32:06 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -84,6 +84,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
myList->setNumberingMode(kListNumberingOff);
myList->setEditable(false);
myList->setFlags(WIDGET_STICKY_FOCUS);
//wid.push_back(myList);
// Add note textwidget to show any notes for the currently selected ROM
xpos += 5; ypos += myList->getHeight() + 4;