simplified touche savegame listing
svn-id: r29112
This commit is contained in:
parent
c1eacc0357
commit
d8831b44da
4 changed files with 21 additions and 32 deletions
|
@ -92,8 +92,7 @@ struct MenuData {
|
||||||
uint buttonsCount;
|
uint buttonsCount;
|
||||||
bool quit;
|
bool quit;
|
||||||
bool exit;
|
bool exit;
|
||||||
bool saveLoadMarks[100];
|
char saveLoadDescriptionsTable[kMaxSaveStates][33];
|
||||||
char saveLoadDescriptionsTable[100][33];
|
|
||||||
|
|
||||||
void removeLastCharFromDescription(int slot) {
|
void removeLastCharFromDescription(int slot) {
|
||||||
char *description = saveLoadDescriptionsTable[slot];
|
char *description = saveLoadDescriptionsTable[slot];
|
||||||
|
@ -370,36 +369,15 @@ void ToucheEngine::handleOptions(int forceDisplay) {
|
||||||
setupMenu(menuData.mode, &menuData);
|
setupMenu(menuData.mode, &menuData);
|
||||||
curMode = menuData.mode;
|
curMode = menuData.mode;
|
||||||
if (menuData.mode == kMenuLoadStateMode || menuData.mode == kMenuSaveStateMode) {
|
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];
|
char gameStateFileName[16];
|
||||||
generateGameStateFileName(999, gameStateFileName, 15, true);
|
generateGameStateFileName(999, gameStateFileName, 15, true);
|
||||||
char slot[2];
|
Common::StringList filenames = _saveFileMan->listSavefiles(gameStateFileName);
|
||||||
int slotNum;
|
for (Common::StringList::const_iterator it = filenames.begin(); it != filenames.end(); ++it) {
|
||||||
Common::StringList filenames;
|
int i = getGameStateFileSlot(it->c_str());
|
||||||
|
if (i >= 0 && i < kMaxSaveStates) {
|
||||||
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]) {
|
|
||||||
readGameStateDescription(i, menuData.saveLoadDescriptionsTable[i], 32);
|
readGameStateDescription(i, menuData.saveLoadDescriptionsTable[i], 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,4 +407,13 @@ void ToucheEngine::generateGameStateFileName(int num, char *dst, int len, bool p
|
||||||
dst[len] = 0;
|
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
|
} // namespace Touche
|
||||||
|
|
|
@ -74,7 +74,7 @@ ToucheEngine::ToucheEngine(OSystem *system)
|
||||||
Common::addSpecialDebugLevel(kDebugOpcodes, "Opcodes", "Opcodes debug level");
|
Common::addSpecialDebugLevel(kDebugOpcodes, "Opcodes", "Opcodes debug level");
|
||||||
Common::addSpecialDebugLevel(kDebugMenu, "Menu", "Menu debug level");
|
Common::addSpecialDebugLevel(kDebugMenu, "Menu", "Menu debug level");
|
||||||
|
|
||||||
system->getEventManager()->registerRandomSource(_rnd, "touche");
|
_eventMan->registerRandomSource(_rnd, "touche");
|
||||||
}
|
}
|
||||||
|
|
||||||
ToucheEngine::~ToucheEngine() {
|
ToucheEngine::~ToucheEngine() {
|
||||||
|
|
|
@ -327,7 +327,8 @@ enum {
|
||||||
kCursorWidth = 58,
|
kCursorWidth = 58,
|
||||||
kCursorHeight = 42,
|
kCursorHeight = 42,
|
||||||
kTextHeight = 16,
|
kTextHeight = 16,
|
||||||
kMaxProgramDataSize = 61440
|
kMaxProgramDataSize = 61440,
|
||||||
|
kMaxSaveStates = 100
|
||||||
};
|
};
|
||||||
|
|
||||||
class MidiPlayer;
|
class MidiPlayer;
|
||||||
|
@ -490,6 +491,7 @@ protected:
|
||||||
bool loadGameState(int num);
|
bool loadGameState(int num);
|
||||||
void readGameStateDescription(int num, char *description, int len);
|
void readGameStateDescription(int num, char *description, int len);
|
||||||
void generateGameStateFileName(int num, char *dst, int len, bool prefixOnly = false) const;
|
void generateGameStateFileName(int num, char *dst, int len, bool prefixOnly = false) const;
|
||||||
|
int getGameStateFileSlot(const char *filename) const;
|
||||||
|
|
||||||
void setupOpcodes();
|
void setupOpcodes();
|
||||||
void op_nop();
|
void op_nop();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue