TSAGE: Implemented the character selection dialog logic in R2RW

This commit is contained in:
Paul Gilbert 2011-11-02 20:44:28 +11:00
parent e9aebf0a21
commit 5d08dbfa11
5 changed files with 135 additions and 1 deletions

View File

@ -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

View File

@ -247,6 +247,7 @@ public:
int _v565F5;
int _v5657C;
int _v57C2C;
int _v565F1[4];
virtual void reset();
virtual void synchronize(Serializer &s);

View File

@ -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() {

View File

@ -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) {

View File

@ -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();