Permalink
Browse files

RING: Update start game code

 - Bail out of event handler when starting a new game
 - Correct display of missing cd
 - Fix checking for presence of zone folder
  • Loading branch information...
1 parent 8618cf0 commit 4a943f6f4f668e734ce43923fd8c4d5c1009413d @Templier committed Oct 21, 2011
@@ -379,7 +379,7 @@ void Application::setupZone(ZoneId zone, SetupType type) {
} else {
_saveManager->setSetupType(type);
- messageFormat("InsertCD", Common::String::format("%d", getEpisodeCd(zone)));
+ messageFormat("InsertCD", getEpisodeCd(zone));
messageInsertCd(zone);
}
}
@@ -1290,6 +1290,11 @@ bool Application::messageGet(Common::String messageId) {
return false;
}
+void Application::messageFormat(Common::String messageId, int argument) {
+ if (messageGet(messageId))
+ _message = Common::String::format(_message.c_str(), argument);
+}
+
void Application::messageFormat(Common::String messageId, Common::String argument) {
if (messageGet(messageId))
_message = Common::String::format(_message.c_str(), argument.c_str());
@@ -84,7 +84,7 @@ class Application : public Common::Serializable, public EventHandler {
virtual void startMenu(bool savegame) = 0;
virtual void showMenu(ZoneId zone, MenuAction menuAction) = 0;
virtual void showCredits() = 0;
- virtual void loadPreferences() = 0;
+ virtual void startGame() = 0;
//////////////////////////////////////////////////////////////////////////
// Timer & update
@@ -150,6 +150,7 @@ class Application : public Common::Serializable, public EventHandler {
virtual void messageHideQuestion(uint32 accelerationIndex);
bool messageGet(Common::String messageId);
+ void messageFormat(Common::String messageId, int argument);
void messageFormat(Common::String messageId, Common::String argument);
void messageFormat(Common::String messageId, int arg1, int arg2);
@@ -771,8 +771,8 @@ void ApplicationFaust::showCredits() {
soundStop(52000, 1024);
}
-void ApplicationFaust::loadPreferences() {
- error("[ApplicationFaust::loadPreferences] Not implemented");
+void ApplicationFaust::startGame() {
+ error("[ApplicationFaust::startGame] Not implemented");
}
#pragma endregion
@@ -1021,7 +1021,7 @@ void ApplicationFaust::setupZone(ZoneId zone, SetupType type) {
if (hasData)
messageGet("TurnDVD");
else {
- messageFormat("InsertCD", Common::String::format("%d", getEpisodeCd(zone)));
+ messageFormat("InsertCD", getEpisodeCd(zone));
}
messageInsertCd(zone);
@@ -63,7 +63,7 @@ class ApplicationFaust : public Application {
virtual void startMenu(bool savegame);
virtual void showMenu(ZoneId zone, MenuAction menuAction);
virtual void showCredits();
- virtual void loadPreferences();
+ virtual void startGame();
//////////////////////////////////////////////////////////////////////////
// Drawing
@@ -192,8 +192,8 @@ void ApplicationJerusalem::showCredits() {
error("[ApplicationJerusalem::showCredits] Not implemented");
}
-void ApplicationJerusalem::loadPreferences() {
- error("[ApplicationJerusalem::loadPreferences] Not implemented");
+void ApplicationJerusalem::startGame() {
+ error("[ApplicationJerusalem::startGame] Not implemented");
}
#pragma endregion
@@ -57,7 +57,7 @@ class ApplicationJerusalem : public Application {
virtual void startMenu(bool savegame);
virtual void showMenu(ZoneId zone, MenuAction menuAction);
virtual void showCredits();
- virtual void loadPreferences();
+ virtual void startGame();
//////////////////////////////////////////////////////////////////////////
// Drawing
@@ -170,8 +170,8 @@ void ApplicationPilgrim2::showCredits() {
error("[ApplicationPilgrim2::showCredits] Not implemented");
}
-void ApplicationPilgrim2::loadPreferences() {
- error("[ApplicationPilgrim2::loadPreferences] Not implemented");
+void ApplicationPilgrim2::startGame() {
+ error("[ApplicationPilgrim2::startGame] Not implemented");
}
#pragma endregion
@@ -52,7 +52,7 @@ class ApplicationPilgrim2 : public Application {
virtual void startMenu(bool savegame);
virtual void showMenu(ZoneId zone, MenuAction menuAction);
virtual void showCredits();
- virtual void loadPreferences();
+ virtual void startGame();
//////////////////////////////////////////////////////////////////////////
// Drawing
@@ -170,8 +170,8 @@ void ApplicationPilgrim3::showCredits() {
error("[ApplicationPilgrim3::showCredits] Not implemented");
}
-void ApplicationPilgrim3::loadPreferences() {
- error("[ApplicationPilgrim3::loadPreferences] Not implemented");
+void ApplicationPilgrim3::startGame() {
+ error("[ApplicationPilgrim3::startGame] Not implemented");
}
#pragma endregion
@@ -52,7 +52,7 @@ class ApplicationPilgrim3 : public Application {
virtual void startMenu(bool savegame);
virtual void showMenu(ZoneId zone, MenuAction menuAction);
virtual void showCredits();
- virtual void loadPreferences();
+ virtual void startGame();
//////////////////////////////////////////////////////////////////////////
// Drawing
@@ -674,8 +674,8 @@ void ApplicationPompeii::showCredits() {
soundStop(90801, 1024);
}
-void ApplicationPompeii::loadPreferences() {
- error("[ApplicationPompeii::loadPreferences] Not implemented");
+void ApplicationPompeii::startGame() {
+ error("[ApplicationPompeii::startGame] Not implemented");
}
#pragma endregion
@@ -58,7 +58,7 @@ class ApplicationPompeii : public Application {
virtual void startMenu(bool savegame);
virtual void showMenu(ZoneId zone, MenuAction menuAction);
virtual void showCredits();
- virtual void loadPreferences();
+ virtual void startGame();
//////////////////////////////////////////////////////////////////////////
// Drawing
@@ -358,9 +358,9 @@ void ApplicationRing::showCredits() {
soundStop(51002, 1024);
}
-void ApplicationRing::loadPreferences() {
+void ApplicationRing::startGame() {
if (!_preferenceHandler)
- error("[] Preference handler not initialized properly");
+ error("[ApplicationRing::startGame] Preference handler not initialized properly");
_preferenceHandler->load();
@@ -502,8 +502,9 @@ void ApplicationRing::setupZone(ZoneId zone, SetupType type) {
} else {
// The original checks for the correct CD defined in cd.ini,
// instead we check that the zone archive has been copied properly
- if (!Common::File::exists(getZoneFolder(zone)))
- hasData = false;
+ Common::ArchiveMemberList list;
+ if (SearchMan.listMatchingMembers(list, Common::String::format("DATA/%s/*", getZoneFolder(zone).c_str())))
+ hasData = true;
}
}
@@ -521,7 +522,7 @@ void ApplicationRing::setupZone(ZoneId zone, SetupType type) {
setZone(zone, type);
} else {
_saveManager->setSetupType(type);
- messageFormat("InsertCD", Common::String::format("%d", getCdForZone(getCurrentZone())));
+ messageFormat("InsertCD", getCdForZone(getCurrentZone()));
messageInsertCd(zone);
}
}
@@ -826,7 +827,7 @@ bool ApplicationRing::handleLeftButtonUp(Accessibility *accessibility, Id id, co
if (object->getFieldC() & 1) {
onButtonUp(object->getId(), hotspot->getTarget(), id, 1, point);
- if (getState() == kStateShowMenu)
+ if (getState() == kStateShowMenu || getState() == kStateNone)
return true;
}
@@ -57,7 +57,7 @@ class ApplicationRing : public Application {
virtual void startMenu(bool savegame);
virtual void showMenu(ZoneId zone, MenuAction menuAction);
virtual void showCredits();
- virtual void loadPreferences();
+ virtual void startGame();
virtual void refreshPreferences();
//////////////////////////////////////////////////////////////////////////
@@ -491,7 +491,7 @@ void ZoneSystemRing::onButtonUp(ObjectId id, Id target, Id /*puzzleRotationId*/,
handleEvents();
_app->exitZone();
_app->initZones();
- _app->loadPreferences();
+ _app->startGame();
_app->messageHideQuestion(2);
break;
@@ -635,7 +635,7 @@ void ZoneSystemRing::onButtonUp(ObjectId id, Id target, Id /*puzzleRotationId*/,
if (!_app->getSaveManager()->loadSave(0, kLoadSaveRead)) {
_app->exitZone();
_app->initZones();
- _app->loadPreferences();
+ _app->startGame();
_app->messageGet("CanNotCountineGame"); // Typo is normal :S
_app->messageShowWarning(0);
}
@@ -674,7 +674,7 @@ void ZoneSystemRing::onButtonUp(ObjectId id, Id target, Id /*puzzleRotationId*/,
if (!_app->getSaveManager()->loadSave(0, kLoadSaveRead)) {
_app->exitZone();
_app->initZones();
- _app->loadPreferences();
+ _app->startGame();
}
_app->messageFormat("CanNotLoadGame", name);
@@ -704,7 +704,7 @@ void ZoneSystemRing::onButtonUp(ObjectId id, Id target, Id /*puzzleRotationId*/,
_app->exitZone();
_app->initZones();
- _app->loadPreferences();
+ _app->startGame();
_app->messageFormat("CanNotSaveGame", *_app->getSaveManager()->getName());
_app->messageShowWarning(0);
@@ -739,6 +739,9 @@ void ZoneSystemRing::onButtonUp(ObjectId id, Id target, Id /*puzzleRotationId*/,
// Check current Cd
if (target > 0 && target <=8) {
// Original checks the cd number in data/cd.ini
+ Common::ArchiveMemberList list;
+ if (!SearchMan.listMatchingMembers(list, Common::String::format("DATA/%s/*", _app->getZoneFolder((ZoneId)target).c_str())))
+ break;
_app->setZoneAndEnableBag((ZoneId)target);
_app->setZone((ZoneId)target, _app->getSaveManager()->getSetupType());

0 comments on commit 4a943f6

Please sign in to comment.