aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2011-11-02 20:44:28 +1100
committerPaul Gilbert2011-11-02 20:44:28 +1100
commit5d08dbfa114fd03b9d811f2a961c13dbc4804d2c (patch)
tree2d42a8bd9e25a55ff5e389c23fb2d0c495db2cac /engines
parente9aebf0a210271cb2489332ad0c4ea13bea7542f (diff)
downloadscummvm-rg350-5d08dbfa114fd03b9d811f2a961c13dbc4804d2c.tar.gz
scummvm-rg350-5d08dbfa114fd03b9d811f2a961c13dbc4804d2c.tar.bz2
scummvm-rg350-5d08dbfa114fd03b9d811f2a961c13dbc4804d2c.zip
TSAGE: Implemented the character selection dialog logic in R2RW
Diffstat (limited to 'engines')
-rw-r--r--engines/tsage/globals.cpp8
-rw-r--r--engines/tsage/globals.h1
-rw-r--r--engines/tsage/ringworld2/ringworld2_dialogs.cpp117
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.cpp9
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.h1
5 files changed, 135 insertions, 1 deletions
diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp
index 623332e864..b82d4bce57 100644
--- a/engines/tsage/globals.cpp
+++ b/engines/tsage/globals.cpp
@@ -376,6 +376,12 @@ void Ringworld2Globals::reset() {
_v5657C = 0;
_v565F5 = 0;
_v57C2C = 0;
+ Common::set_to(&_v565F1[0], &_v565F1[MAX_CHARACTERS], 0);
+
+ _player._characterIndex = 1;
+ _player._characterScene[1] = 100;
+ _player._characterScene[2] = 300;
+ _player._characterScene[3] = 300;
}
void Ringworld2Globals::synchronize(Serializer &s) {
@@ -384,6 +390,8 @@ void Ringworld2Globals::synchronize(Serializer &s) {
s.syncAsSint16LE(_v5657C);
s.syncAsSint16LE(_v565F5);
s.syncAsSint16LE(_v57C2C);
+ for (int i = 0; i < MAX_CHARACTERS; ++i)
+ s.syncAsSint16LE(_v565F1[i]);
}
} // end of namespace Ringworld2
diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h
index 1dc8e28606..6d61ce6b69 100644
--- a/engines/tsage/globals.h
+++ b/engines/tsage/globals.h
@@ -247,6 +247,7 @@ public:
int _v565F5;
int _v5657C;
int _v57C2C;
+ int _v565F1[4];
virtual void reset();
virtual void synchronize(Serializer &s);
diff --git a/engines/tsage/ringworld2/ringworld2_dialogs.cpp b/engines/tsage/ringworld2/ringworld2_dialogs.cpp
index 7abf2c9a45..553a10a5a6 100644
--- a/engines/tsage/ringworld2/ringworld2_dialogs.cpp
+++ b/engines/tsage/ringworld2/ringworld2_dialogs.cpp
@@ -31,6 +31,7 @@
#include "tsage/staticres.h"
#include "tsage/globals.h"
#include "tsage/ringworld2/ringworld2_dialogs.h"
+#include "tsage/ringworld2/ringworld2_logic.h"
namespace TsAGE {
@@ -195,11 +196,125 @@ void CharacterDialog::show() {
CharacterDialog *dlg = new CharacterDialog();
dlg->draw();
- /*GfxButton *btn = */dlg->execute(&dlg->_btnCancel);
+ // Make the default button the currently active character
+ GfxButton *btn = NULL;
+ int oldCharacter = R2_GLOBALS._player._characterIndex;
+ switch (oldCharacter) {
+ case 1:
+ btn = &dlg->_btnQuinn;
+ break;
+ case 2:
+ btn = &dlg->_btnSeeker;
+ break;
+ case 3:
+ btn = &dlg->_btnMiranda;
+ break;
+ default:
+ break;
+ }
+
+ // Show the character selection dialog
+ btn = dlg->execute(btn);
+ // Figure out the new selected character
+ if (btn == &dlg->_btnQuinn)
+ R2_GLOBALS._player._characterIndex = 1;
+ else if (btn == &dlg->_btnSeeker)
+ R2_GLOBALS._player._characterIndex = 2;
+ else if (btn == &dlg->_btnMiranda)
+ R2_GLOBALS._player._characterIndex = 3;
+ // Remove the dialog
dlg->remove();
delete dlg;
+
+ // Only do transfer if a different character was selected
+ if (R2_GLOBALS._player._characterIndex != oldCharacter) {
+ // Save the details of the previously active character
+ SceneExt *scene = (SceneExt *)R2_GLOBALS._sceneManager._scene;
+ scene->saveCharacter(oldCharacter);
+
+ // Play a transition sound as the character is changed
+ if (R2_GLOBALS._player._characterScene[0] != 300) {
+ switch (R2_GLOBALS._v565F1[R2_GLOBALS._player._characterIndex]) {
+ case 0:
+ R2_GLOBALS._sound4.stop();
+ break;
+ case 1:
+ R2_GLOBALS._sound4.play(45);
+ break;
+ case 2:
+ R2_GLOBALS._sound4.play(4);
+ break;
+ case 3:
+ R2_GLOBALS._sound4.play(5);
+ break;
+ case 4:
+ R2_GLOBALS._sound4.play(6);
+ break;
+ default:
+ break;
+ }
+ } else if (R2_GLOBALS._v565F1[R2_GLOBALS._player._characterIndex] > 1) {
+ switch (R2_GLOBALS._v565F1[R2_GLOBALS._player._characterIndex]) {
+ case 2:
+ R2_GLOBALS._sound4.play(45);
+ break;
+ case 3:
+ R2_GLOBALS._sound4.play(4);
+ break;
+ case 4:
+ R2_GLOBALS._sound4.play(5);
+ break;
+ case 5:
+ R2_GLOBALS._sound4.play(6);
+ break;
+ default:
+ break;
+ }
+ } else if ((R2_GLOBALS._player._characterScene[1] == 300) && (R2_GLOBALS._v565F1[1] != 1)) {
+ switch (R2_GLOBALS._v565F1[1]) {
+ case 2:
+ R2_GLOBALS._sound4.play(45);
+ break;
+ case 3:
+ R2_GLOBALS._sound4.play(4);
+ break;
+ case 4:
+ R2_GLOBALS._sound4.play(5);
+ break;
+ case 5:
+ R2_GLOBALS._sound4.play(6);
+ break;
+ default:
+ break;
+ }
+ } else if (R2_GLOBALS._player._characterScene[2] != 300) {
+ R2_GLOBALS._sound4.stop();
+ } else if (R2_GLOBALS._v565F1[2] == 1) {
+ R2_GLOBALS._sound4.stop();
+ } else {
+ switch (R2_GLOBALS._v565F1[1]) {
+ case 2:
+ R2_GLOBALS._sound4.play(45);
+ break;
+ case 3:
+ R2_GLOBALS._sound4.play(4);
+ break;
+ case 4:
+ R2_GLOBALS._sound4.play(5);
+ break;
+ case 5:
+ R2_GLOBALS._sound4.play(6);
+ break;
+ default:
+ break;
+ }
+ }
+
+ // Change to whichever scene the newly selected character is in
+ R2_GLOBALS._sceneManager.changeScene(R2_GLOBALS._player._characterScene[R2_GLOBALS._player._characterIndex]);
+ }
}
CharacterDialog::CharacterDialog() {
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp
index 642d265e42..e9892c6880 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.cpp
+++ b/engines/tsage/ringworld2/ringworld2_logic.cpp
@@ -222,6 +222,15 @@ void SceneExt::refreshBackground(int xAmount, int yAmount) {
DEALLOCATE(dataP);
}
+/**
+ * Saves the current player position and view in the details for the specified character index
+ */
+void SceneExt::saveCharacter(int characterIndex) {
+ R2_GLOBALS._player._characterPos[characterIndex] = R2_GLOBALS._player._position;
+ R2_GLOBALS._player._characterStrip[characterIndex] = R2_GLOBALS._player._strip;
+ R2_GLOBALS._player._characterFrame[characterIndex] = R2_GLOBALS._player._frame;
+}
+
/*--------------------------------------------------------------------------*/
void SceneHandlerExt::postInit(SceneObjectList *OwnerList) {
diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h
index b0f388a2ae..4adfc9bc05 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.h
+++ b/engines/tsage/ringworld2/ringworld2_logic.h
@@ -67,6 +67,7 @@ public:
virtual void dispatch();
virtual void loadScene(int sceneNum);
virtual void refreshBackground(int xAmount, int yAmount);
+ virtual void saveCharacter(int characterIndex);
bool display(CursorType action);
void fadeOut();