aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorGregory Montoir2007-09-27 20:38:23 +0000
committerGregory Montoir2007-09-27 20:38:23 +0000
commitd8831b44da24c16eef5fcc368d8d54953f0c60b5 (patch)
treea7f860ac63e73565fa0cf4628da0f6417afba230 /engines
parentc1eacc03571b9afbedd188fbf26ff115dbf8e393 (diff)
downloadscummvm-rg350-d8831b44da24c16eef5fcc368d8d54953f0c60b5.tar.gz
scummvm-rg350-d8831b44da24c16eef5fcc368d8d54953f0c60b5.tar.bz2
scummvm-rg350-d8831b44da24c16eef5fcc368d8d54953f0c60b5.zip
simplified touche savegame listing
svn-id: r29112
Diffstat (limited to 'engines')
-rw-r--r--engines/touche/menu.cpp38
-rw-r--r--engines/touche/saveload.cpp9
-rw-r--r--engines/touche/touche.cpp2
-rw-r--r--engines/touche/touche.h4
4 files changed, 21 insertions, 32 deletions
diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp
index 48f49f7d7b..2dacab4132 100644
--- a/engines/touche/menu.cpp
+++ b/engines/touche/menu.cpp
@@ -92,8 +92,7 @@ struct MenuData {
uint buttonsCount;
bool quit;
bool exit;
- bool saveLoadMarks[100];
- char saveLoadDescriptionsTable[100][33];
+ char saveLoadDescriptionsTable[kMaxSaveStates][33];
void removeLastCharFromDescription(int slot) {
char *description = saveLoadDescriptionsTable[slot];
@@ -370,36 +369,15 @@ void ToucheEngine::handleOptions(int forceDisplay) {
setupMenu(menuData.mode, &menuData);
curMode = menuData.mode;
if (menuData.mode == kMenuLoadStateMode || menuData.mode == kMenuSaveStateMode) {
- assert(menuData.saveLoadMarks);
-
+ for (int i = 0; i < kMaxSaveStates; ++i) {
+ menuData.saveLoadDescriptionsTable[i][0] = 0;
+ }
char gameStateFileName[16];
generateGameStateFileName(999, gameStateFileName, 15, true);
- char slot[2];
- int slotNum;
- Common::StringList filenames;
-
- memset(menuData.saveLoadMarks, false, 100 * sizeof(bool)); //assume no savegames for this title
- filenames = _saveFileMan->listSavefiles(gameStateFileName);
-
- for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++){
- //Obtain the last 1 or 2 digits of the filename, since they correspond to the save slot
- //This engine can save games either with one or two digits, hence the additional if statement
- slot[0] = file->c_str()[file->size()-2];
- slot[1] = file->c_str()[file->size()-1];
-
- if (!atoi(&slot[0])){
- slotNum = atoi(&slot[1]);
- } else {
- slotNum = atoi(slot);
- }
-
- if (slotNum >= 0 && slotNum < 100)
- menuData.saveLoadMarks[slotNum] = true; //mark this slot as valid
- }
-
- for (int i = 0; i < 100; ++i) {
- menuData.saveLoadDescriptionsTable[i][0] = 0;
- if (menuData.saveLoadMarks[i]) {
+ Common::StringList filenames = _saveFileMan->listSavefiles(gameStateFileName);
+ for (Common::StringList::const_iterator it = filenames.begin(); it != filenames.end(); ++it) {
+ int i = getGameStateFileSlot(it->c_str());
+ if (i >= 0 && i < kMaxSaveStates) {
readGameStateDescription(i, menuData.saveLoadDescriptionsTable[i], 32);
}
}
diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp
index 7901e5c31f..46e3194644 100644
--- a/engines/touche/saveload.cpp
+++ b/engines/touche/saveload.cpp
@@ -407,4 +407,13 @@ void ToucheEngine::generateGameStateFileName(int num, char *dst, int len, bool p
dst[len] = 0;
}
+int ToucheEngine::getGameStateFileSlot(const char *filename) const {
+ int i = -1;
+ const char *slot = strrchr(filename, '.');
+ if (slot) {
+ i = atoi(slot + 1);
+ }
+ return i;
+}
+
} // namespace Touche
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index c91a2db2f1..d614257617 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -74,7 +74,7 @@ ToucheEngine::ToucheEngine(OSystem *system)
Common::addSpecialDebugLevel(kDebugOpcodes, "Opcodes", "Opcodes debug level");
Common::addSpecialDebugLevel(kDebugMenu, "Menu", "Menu debug level");
- system->getEventManager()->registerRandomSource(_rnd, "touche");
+ _eventMan->registerRandomSource(_rnd, "touche");
}
ToucheEngine::~ToucheEngine() {
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index f1f8d3bd6e..5c27f58c92 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -327,7 +327,8 @@ enum {
kCursorWidth = 58,
kCursorHeight = 42,
kTextHeight = 16,
- kMaxProgramDataSize = 61440
+ kMaxProgramDataSize = 61440,
+ kMaxSaveStates = 100
};
class MidiPlayer;
@@ -490,6 +491,7 @@ protected:
bool loadGameState(int num);
void readGameStateDescription(int num, char *description, int len);
void generateGameStateFileName(int num, char *dst, int len, bool prefixOnly = false) const;
+ int getGameStateFileSlot(const char *filename) const;
void setupOpcodes();
void op_nop();