[Scummvm-cvs-logs] SF.net SVN: scummvm:[34220] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Sun Aug 31 08:14:46 CEST 2008
Revision: 34220
http://scummvm.svn.sourceforge.net/scummvm/?rev=34220&view=rev
Author: peres001
Date: 2008-08-31 06:14:45 +0000 (Sun, 31 Aug 2008)
Log Message:
-----------
Moved save/load code into SaveLoad class.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/callables_ns.cpp
scummvm/trunk/engines/parallaction/gui_br.cpp
scummvm/trunk/engines/parallaction/gui_ns.cpp
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/parallaction_br.cpp
scummvm/trunk/engines/parallaction/parallaction_ns.cpp
scummvm/trunk/engines/parallaction/saveload.cpp
Added Paths:
-----------
scummvm/trunk/engines/parallaction/saveload.h
Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp 2008-08-31 05:18:25 UTC (rev 34219)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp 2008-08-31 06:14:45 UTC (rev 34220)
@@ -32,6 +32,7 @@
#include "parallaction/input.h"
#include "parallaction/parallaction.h"
+#include "parallaction/saveload.h"
#include "parallaction/sound.h"
@@ -341,7 +342,7 @@
void Parallaction_ns::_c_finito(void *parm) {
- setPartComplete(_char);
+ _saveLoad->setPartComplete(_char.getBaseName());
cleanInventory();
cleanupGame();
Modified: scummvm/trunk/engines/parallaction/gui_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_br.cpp 2008-08-31 05:18:25 UTC (rev 34219)
+++ scummvm/trunk/engines/parallaction/gui_br.cpp 2008-08-31 06:14:45 UTC (rev 34220)
@@ -28,6 +28,7 @@
#include "parallaction/gui.h"
#include "parallaction/input.h"
#include "parallaction/parallaction.h"
+#include "parallaction/saveload.h"
namespace Parallaction {
@@ -223,7 +224,7 @@
_availItems = 4;
bool complete[3];
- _vm->getGamePartProgress(complete, 3);
+ _vm->_saveLoad->getGamePartProgress(complete, 3);
for (int i = 0; i < 3 && complete[i]; i++, _availItems++) ;
// TODO: keep track of and destroy menu item frames/surfaces
Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp 2008-08-31 05:18:25 UTC (rev 34219)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp 2008-08-31 06:14:45 UTC (rev 34220)
@@ -29,6 +29,7 @@
#include "parallaction/gui.h"
#include "parallaction/input.h"
#include "parallaction/parallaction.h"
+#include "parallaction/saveload.h"
#include "parallaction/sound.h"
@@ -284,7 +285,7 @@
}
virtual void enter() {
- _result = _vm->loadGame();
+ _result = _vm->_saveLoad->loadGame();
}
};
@@ -759,7 +760,7 @@
virtual void enter() {
bool completed[3];
- _vm->getGamePartProgress(completed, 3);
+ _vm->_saveLoad->getGamePartProgress(completed, 3);
_allPartsComplete = (completed[0] && completed[1] && completed[2]);
_vm->_input->setMouseState(MOUSE_DISABLED);
Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp 2008-08-31 05:18:25 UTC (rev 34219)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp 2008-08-31 06:14:45 UTC (rev 34220)
@@ -35,6 +35,7 @@
#include "parallaction/input.h"
#include "parallaction/parallaction.h"
#include "parallaction/debug.h"
+#include "parallaction/saveload.h"
#include "parallaction/sound.h"
@@ -307,13 +308,13 @@
switch (event) {
case kEvSaveGame:
_input->stopHovering();
- saveGame();
+ _saveLoad->saveGame();
_input->setArrowCursor();
break;
case kEvLoadGame:
_input->stopHovering();
- loadGame();
+ _saveLoad->loadGame();
_input->setArrowCursor();
break;
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2008-08-31 05:18:25 UTC (rev 34219)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2008-08-31 06:14:45 UTC (rev 34220)
@@ -205,6 +205,7 @@
};
+class SaveLoad;
#define NUM_LOCATIONS 120
@@ -218,9 +219,6 @@
int init();
- virtual bool loadGame() = 0;
- virtual bool saveGame() = 0;
-
Input *_input;
void processInput(int event);
@@ -296,10 +294,10 @@
Debugger *_debugger;
+ char _characterName1[50]; // only used in changeCharacter
protected: // data
uint32 _baseTime;
- char _characterName1[50]; // only used in changeCharacter
Common::String _saveFileName;
@@ -322,7 +320,6 @@
bool pickupItem(ZonePtr z);
-
public:
void scheduleLocationSwitch(const char *location);
virtual void changeCharacter(const char *name) = 0;
@@ -339,9 +336,9 @@
void showSlide(const char *name, int x = 0, int y = 0);
ZonePtr _zoneTrap;
+ SaveLoad *_saveLoad;
virtual void cleanupGame() = 0;
- virtual void getGamePartProgress(bool *complete, int size) = 0;
public:
void highlightInventoryItem(ItemPosition pos);
@@ -443,13 +440,9 @@
virtual void callFunction(uint index, void* parm);
- bool loadGame();
- bool saveGame();
-
void switchBackground(const char* background, const char* mask);
void cleanupGame();
- void getGamePartProgress(bool *complete, int size);
private:
bool _inTestResult;
@@ -459,22 +452,12 @@
void initFonts();
void freeFonts();
- void renameOldSavefiles();
- Common::String genSaveFileName(uint slot, bool oldStyle = false);
- Common::InSaveFile *getInSaveFile(uint slot);
- Common::OutSaveFile *getOutSaveFile(uint slot);
- void setPartComplete(const Character& character);
private:
void changeLocation(char *location);
void changeCharacter(const char *name);
void runPendingZones();
- void doLoadGame(uint16 slot);
- void doSaveGame(uint16 slot, const char* name);
- int buildSaveFileList(Common::StringList& l);
- int selectSaveFile(uint16 arg_0, const char* caption, const char* button);
-
void initResources();
static const Callable _dosCallables[25];
@@ -560,8 +543,6 @@
void setupSubtitles(char *s, char *s2, int y);
void clearSubtitles();
- void getGamePartProgress(bool *complete, int size);
-
public:
Table *_countersNames;
Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp 2008-08-31 05:18:25 UTC (rev 34219)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp 2008-08-31 06:14:45 UTC (rev 34220)
@@ -28,6 +28,7 @@
#include "parallaction/parallaction.h"
#include "parallaction/input.h"
+#include "parallaction/saveload.h"
#include "parallaction/sound.h"
namespace Parallaction {
@@ -82,6 +83,8 @@
_subtitle[0] = -1;
_subtitle[1] = -1;
+ _saveLoad = new SaveLoad_br(this, _saveFileMan);
+
Parallaction::init();
return 0;
Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp 2008-08-31 05:18:25 UTC (rev 34219)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp 2008-08-31 06:14:45 UTC (rev 34220)
@@ -29,6 +29,7 @@
#include "parallaction/parallaction.h"
#include "parallaction/input.h"
+#include "parallaction/saveload.h"
#include "parallaction/sound.h"
@@ -149,6 +150,8 @@
_location._animations.push_front(_char._ani);
+ _saveLoad = new SaveLoad_ns(this, _saveFileMan);
+
Parallaction::init();
return 0;
@@ -183,7 +186,7 @@
int Parallaction_ns::go() {
- renameOldSavefiles();
+ _saveLoad->renameOldSavefiles();
_globalFlagsNames = _disk->loadTable("global");
@@ -410,6 +413,10 @@
_location._animations.push_front(_char._ani);
_score = 0;
+ _soundMan->stopMusic();
+ _introSarcData3 = 200;
+ _introSarcData2 = 1;
+
return;
}
Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp 2008-08-31 05:18:25 UTC (rev 34219)
+++ scummvm/trunk/engines/parallaction/saveload.cpp 2008-08-31 06:14:45 UTC (rev 34220)
@@ -31,6 +31,7 @@
#include "gui/message.h"
#include "parallaction/parallaction.h"
+#include "parallaction/saveload.h"
#include "parallaction/sound.h"
@@ -57,12 +58,11 @@
GUI::StaticTextWidget *_time;
GUI::StaticTextWidget *_playtime;
GUI::ContainerWidget *_container;
- Parallaction_ns *_vm;
uint8 _fillR, _fillG, _fillB;
public:
- SaveLoadChooser(const String &title, const String &buttonLabel, Parallaction_ns *engine);
+ SaveLoadChooser(const String &title, const String &buttonLabel);
~SaveLoadChooser();
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
@@ -73,35 +73,40 @@
virtual void reflowLayout();
};
-Common::String Parallaction_ns::genSaveFileName(uint slot, bool oldStyle) {
+Common::String SaveLoad_ns::genOldSaveFileName(uint slot) {
assert(slot < NUM_SAVESLOTS || slot == SPECIAL_SAVESLOT);
char s[20];
- sprintf(s, (oldStyle ? "game.%i" : "nippon.%.3d"), slot );
+ sprintf(s, "game.%i", slot);
return Common::String(s);
}
-Common::InSaveFile *Parallaction_ns::getInSaveFile(uint slot) {
+
+Common::String SaveLoad::genSaveFileName(uint slot) {
+ assert(slot < NUM_SAVESLOTS || slot == SPECIAL_SAVESLOT);
+
+ char s[20];
+ sprintf(s, "%s.%.3d", _saveFilePrefix.c_str(), slot);
+
+ return Common::String(s);
+}
+
+Common::InSaveFile *SaveLoad::getInSaveFile(uint slot) {
Common::String name = genSaveFileName(slot);
return _saveFileMan->openForLoading(name.c_str());
}
-Common::OutSaveFile *Parallaction_ns::getOutSaveFile(uint slot) {
+Common::OutSaveFile *SaveLoad::getOutSaveFile(uint slot) {
Common::String name = genSaveFileName(slot);
return _saveFileMan->openForSaving(name.c_str());
}
-void Parallaction_ns::doLoadGame(uint16 slot) {
+void SaveLoad_ns::doLoadGame(uint16 slot) {
- _soundMan->stopMusic();
+ _vm->cleanupGame();
- cleanupGame();
-
- _introSarcData3 = 200;
- _introSarcData2 = 1;
-
Common::InSaveFile *f = getInSaveFile(slot);
if (!f) return;
@@ -116,10 +121,10 @@
f->readLine(l, 15);
f->readLine(s, 15);
- _location._startPosition.x = atoi(s);
+ _vm->_location._startPosition.x = atoi(s);
f->readLine(s, 15);
- _location._startPosition.y = atoi(s);
+ _vm->_location._startPosition.y = atoi(s);
f->readLine(s, 15);
_score = atoi(s);
@@ -135,23 +140,23 @@
// need to invoke freeZones here with kEngineQuit set, because the
// call in changeLocation preserve certain zones.
_engineFlags |= kEngineQuit;
- freeZones();
+ _vm->freeZones();
_engineFlags &= ~kEngineQuit;
- _numLocations = atoi(s);
+ _vm->_numLocations = atoi(s);
uint16 _si;
- for (_si = 0; _si < _numLocations; _si++) {
+ for (_si = 0; _si < _vm->_numLocations; _si++) {
f->readLine(s, 20);
s[strlen(s)] = '\0';
- strcpy(_locationNames[_si], s);
+ strcpy(_vm->_locationNames[_si], s);
f->readLine(s, 15);
- _localFlags[_si] = atoi(s);
+ _vm->_localFlags[_si] = atoi(s);
}
- cleanInventory(false);
+ _vm->cleanInventory(false);
ItemName name;
uint32 value;
@@ -162,24 +167,24 @@
f->readLine(s, 15);
name = atoi(s);
- addInventoryItem(name, value);
+ _vm->addInventoryItem(name, value);
}
delete f;
// force reload of character to solve inventory
// bugs, but it's a good maneuver anyway
- strcpy(_characterName1, "null");
+ strcpy(_vm->_characterName1, "null");
char tmp[PATH_LEN];
sprintf(tmp, "%s.%s" , l, n);
- scheduleLocationSwitch(tmp);
+ _vm->scheduleLocationSwitch(tmp);
return;
}
-void Parallaction_ns::doSaveGame(uint16 slot, const char* name) {
+void SaveLoad_ns::doSaveGame(uint16 slot, const char* name) {
Common::OutSaveFile *f = getOutSaveFile(slot);
if (f == 0) {
@@ -202,30 +207,30 @@
f->writeString(s);
f->writeString("\n");
- sprintf(s, "%s\n", _char.getFullName());
+ sprintf(s, "%s\n", _vm->_char.getFullName());
f->writeString(s);
sprintf(s, "%s\n", _saveData1);
f->writeString(s);
- sprintf(s, "%d\n", _char._ani->getX());
+ sprintf(s, "%d\n", _vm->_char._ani->getX());
f->writeString(s);
- sprintf(s, "%d\n", _char._ani->getY());
+ sprintf(s, "%d\n", _vm->_char._ani->getY());
f->writeString(s);
sprintf(s, "%d\n", _score);
f->writeString(s);
sprintf(s, "%u\n", _globalFlags);
f->writeString(s);
- sprintf(s, "%d\n", _numLocations);
+ sprintf(s, "%d\n", _vm->_numLocations);
f->writeString(s);
- for (uint16 _si = 0; _si < _numLocations; _si++) {
- sprintf(s, "%s\n%u\n", _locationNames[_si], _localFlags[_si]);
+ for (uint16 _si = 0; _si < _vm->_numLocations; _si++) {
+ sprintf(s, "%s\n%u\n", _vm->_locationNames[_si], _vm->_localFlags[_si]);
f->writeString(s);
}
const InventoryItem *item;
for (uint16 _si = 0; _si < 30; _si++) {
- item = getInventoryItem(_si);
+ item = _vm->getInventoryItem(_si);
sprintf(s, "%u\n%d\n", item->_id, item->_index);
f->writeString(s);
}
@@ -247,8 +252,8 @@
};
-SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, Parallaction_ns *engine)
- : Dialog("scummsaveload"), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) {
+SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel)
+ : Dialog("scummsaveload"), _list(0), _chooseButton(0), _gfxWidget(0) {
// _drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;
@@ -335,7 +340,7 @@
Dialog::reflowLayout();
}
-int Parallaction_ns::buildSaveFileList(Common::StringList& l) {
+int SaveLoad_ns::buildSaveFileList(Common::StringList& l) {
char buf[200];
@@ -359,9 +364,9 @@
}
-int Parallaction_ns::selectSaveFile(uint16 arg_0, const char* caption, const char* button) {
+int SaveLoad_ns::selectSaveFile(uint16 arg_0, const char* caption, const char* button) {
- SaveLoadChooser* slc = new SaveLoadChooser(caption, button, this);
+ SaveLoadChooser* slc = new SaveLoadChooser(caption, button);
Common::StringList l;
@@ -380,7 +385,7 @@
-bool Parallaction_ns::loadGame() {
+bool SaveLoad_ns::loadGame() {
int _di = selectSaveFile( 0, "Load file", "Load" );
if (_di == -1) {
@@ -392,15 +397,15 @@
GUI::TimedMessageDialog dialog("Loading game...", 1500);
dialog.runModal();
- _input->setArrowCursor();
+ _vm->_input->setArrowCursor();
return true;
}
-bool Parallaction_ns::saveGame() {
+bool SaveLoad_ns::saveGame() {
- if (!scumm_stricmp(_location._name, "caveau")) {
+ if (!scumm_stricmp(_vm->_location._name, "caveau")) {
return false;
}
@@ -418,7 +423,7 @@
}
-void Parallaction_ns::setPartComplete(const Character& character) {
+void SaveLoad_ns::setPartComplete(const char *part) {
char buf[30];
bool alreadyPresent = false;
@@ -429,7 +434,7 @@
inFile->readLine(buf, 29);
delete inFile;
- if (strstr(buf, character.getBaseName())) {
+ if (strstr(buf, part)) {
alreadyPresent = true;
}
}
@@ -437,7 +442,7 @@
if (!alreadyPresent) {
Common::OutSaveFile *outFile = getOutSaveFile(SPECIAL_SAVESLOT);
outFile->writeString(buf);
- outFile->writeString(character.getBaseName());
+ outFile->writeString(part);
outFile->finalize();
delete outFile;
}
@@ -445,7 +450,7 @@
return;
}
-void Parallaction_ns::getGamePartProgress(bool *complete, int size) {
+void SaveLoad_ns::getGamePartProgress(bool *complete, int size) {
assert(complete && size >= 3);
char buf[30];
@@ -458,25 +463,15 @@
complete[2] = strstr(buf, "dough");
}
-void Parallaction_br::getGamePartProgress(bool *complete, int size) {
- assert(complete && size >= 3);
+void SaveLoad_ns::renameOldSavefiles() {
- // TODO: implement progress loading
-
- complete[0] = true;
- complete[1] = true;
- complete[2] = true;
-}
-
-void Parallaction_ns::renameOldSavefiles() {
-
bool exists[NUM_SAVESLOTS];
uint num = 0;
uint i;
for (i = 0; i < NUM_SAVESLOTS; i++) {
exists[i] = false;
- Common::String name = genSaveFileName(i, true);
+ Common::String name = genOldSaveFileName(i);
Common::InSaveFile *f = _saveFileMan->openForLoading(name.c_str());
if (f) {
exists[i] = true;
@@ -504,8 +499,8 @@
uint success = 0;
for (i = 0; i < NUM_SAVESLOTS; i++) {
if (exists[i]) {
- Common::String oldName = genSaveFileName(i, true);
- Common::String newName = genSaveFileName(i, false);
+ Common::String oldName = genOldSaveFileName(i);
+ Common::String newName = genSaveFileName(i);
if (_saveFileMan->renameSavefile(oldName.c_str(), newName.c_str())) {
success++;
} else {
@@ -531,4 +526,28 @@
}
+bool SaveLoad_br::loadGame() {
+ // TODO: implement loadgame
+ return false;
+}
+
+bool SaveLoad_br::saveGame() {
+ // TODO: implement savegame
+ return false;
+}
+
+void SaveLoad_br::getGamePartProgress(bool *complete, int size) {
+ assert(complete && size >= 3);
+
+ // TODO: implement progress loading
+
+ complete[0] = true;
+ complete[1] = true;
+ complete[2] = true;
+}
+
+void SaveLoad_br::setPartComplete(const char *part) {
+ // TODO: implement progress saving
+}
+
} // namespace Parallaction
Added: scummvm/trunk/engines/parallaction/saveload.h
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.h (rev 0)
+++ scummvm/trunk/engines/parallaction/saveload.h 2008-08-31 06:14:45 UTC (rev 34220)
@@ -0,0 +1,96 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+
+#ifndef PARALLACTION_SAVELOAD_H
+#define PARALLACTION_SAVELOAD_H
+
+namespace Parallaction {
+
+struct Character;
+
+
+class SaveLoad {
+
+protected:
+ Common::SaveFileManager *_saveFileMan;
+ Common::String _saveFilePrefix;
+
+ Common::String genSaveFileName(uint slot);
+ Common::InSaveFile *getInSaveFile(uint slot);
+ Common::OutSaveFile *getOutSaveFile(uint slot);
+
+public:
+ SaveLoad(Common::SaveFileManager* saveFileMan, const char *prefix) : _saveFileMan(saveFileMan), _saveFilePrefix(prefix) { }
+ virtual ~SaveLoad() { }
+
+ virtual bool loadGame() = 0;
+ virtual bool saveGame() = 0;
+ virtual void getGamePartProgress(bool *complete, int size) = 0;
+ virtual void setPartComplete(const char *part) = 0;
+
+ virtual void renameOldSavefiles() { }
+};
+
+class SaveLoad_ns : public SaveLoad {
+
+ Parallaction_ns *_vm;
+
+ Common::String _saveFileName;
+ Common::String genOldSaveFileName(uint slot);
+
+protected:
+ void renameOldSavefiles();
+ void doLoadGame(uint16 slot);
+ void doSaveGame(uint16 slot, const char* name);
+ int buildSaveFileList(Common::StringList& l);
+ int selectSaveFile(uint16 arg_0, const char* caption, const char* button);
+
+public:
+ SaveLoad_ns(Parallaction_ns *vm, Common::SaveFileManager *saveFileMan) : SaveLoad(saveFileMan, "nippon"), _vm(vm) { }
+
+ virtual bool loadGame();
+ virtual bool saveGame();
+ virtual void getGamePartProgress(bool *complete, int size);
+ virtual void setPartComplete(const char *part);
+};
+
+class SaveLoad_br : public SaveLoad {
+
+ Parallaction_br *_vm;
+
+public:
+ SaveLoad_br(Parallaction_br *vm, Common::SaveFileManager *saveFileMan) : SaveLoad(saveFileMan, "bra"), _vm(vm) { }
+
+ virtual bool loadGame();
+ virtual bool saveGame();
+ virtual void getGamePartProgress(bool *complete, int size);
+ virtual void setPartComplete(const char *part);
+};
+
+
+}; // namespace Parallaction
+
+#endif
Property changes on: scummvm/trunk/engines/parallaction/saveload.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list