TSAGE: Implemented R2R card game options dialog

This commit is contained in:
Paul Gilbert 2013-12-15 10:22:40 -05:00
parent 7cd0da64f5
commit aaa88e7f8a
4 changed files with 123 additions and 4 deletions

View File

@ -4490,6 +4490,7 @@ void Scene1337::remove() {
}
R2_GLOBALS._uiElements._active = true;
R2_GLOBALS._uiElements._visible = true;
SceneExt::remove();
}
@ -5418,9 +5419,10 @@ void Scene1337::dealCards() {
// Deal cards
_item1.setAction(&_action3);
}
void Scene1337::subCD193() {
void Scene1337::showOptionsDialog() {
// Display menu with "Auto Play", "New Game", "Quit" and "Continue"
warning("STUBBED: subCD193()");
OptionsDialog::show();
}
void Scene1337::handleClick(int arg1, Common::Point pt) {
@ -5674,7 +5676,7 @@ void Scene1337::handleClick(int arg1, Common::Point pt) {
return;
if (_helpIcon._bounds.contains(pt)) {
subCD193();
showOptionsDialog();
return;
}
@ -6764,6 +6766,94 @@ void Scene1337::subD1975(int arg1, int arg2) {
warning("STUBBED lvl2 Scene1337::subD1975()");
}
void Scene1337::OptionsDialog::show() {
OptionsDialog *dlg = new OptionsDialog();
dlg->draw();
// Show the dialog
GfxButton *btn = dlg->execute(NULL);
// Figure out the new selected character
if (btn == &dlg->_quitGame)
R2_GLOBALS._sceneManager.changeScene(125);
else if (btn == &dlg->_restartGame)
R2_GLOBALS._sceneManager.changeScene(1330);
// Remove the dialog
dlg->remove();
delete dlg;
}
Scene1337::OptionsDialog::OptionsDialog() {
// Set the elements text
Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
_autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
_restartGame.setText(START_NEW_CARD_GAME);
_quitGame.setText(QUIT_CARD_GAME);
_continueGame.setText(CONTINUE_CARD_GAME);
// Set position of the elements
_autoplay._bounds.moveTo(5, 2);
_restartGame._bounds.moveTo(5, _autoplay._bounds.bottom + 2);
_quitGame._bounds.moveTo(5, _restartGame._bounds.bottom + 2);
_continueGame._bounds.moveTo(5, _quitGame._bounds.bottom + 2);
// Add the items to the dialog
addElements(&_autoplay, &_restartGame, &_quitGame, &_continueGame, NULL);
// Set the dialog size and position
frame();
_bounds.collapse(-6, -6);
setCenter(160, 100);
}
GfxButton *Scene1337::OptionsDialog::execute(GfxButton *defaultButton) {
_gfxManager.activate();
// Event loop
GfxButton *selectedButton = NULL;
bool breakFlag = false;
while (!g_vm->shouldQuit() && !breakFlag) {
Event event;
while (g_globals->_events.getEvent(event) && !breakFlag) {
// Adjust mouse positions to be relative within the dialog
event.mousePos.x -= _gfxManager._bounds.left;
event.mousePos.y -= _gfxManager._bounds.top;
for (GfxElementList::iterator i = _elements.begin(); i != _elements.end(); ++i) {
if ((*i)->process(event))
selectedButton = static_cast<GfxButton *>(*i);
}
if (selectedButton == &_autoplay) {
// Toggle Autoplay
selectedButton = NULL;
Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
scene->_autoplay = !scene->_autoplay;
_autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
_autoplay.draw();
} else if (selectedButton) {
breakFlag = true;
break;
} else if (!event.handled) {
if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) {
selectedButton = NULL;
breakFlag = true;
break;
}
}
}
g_system->delayMillis(10);
GLOBALS._screenSurface.updateScreen();
}
_gfxManager.deactivate();
return selectedButton;
}
/*--------------------------------------------------------------------------
* Scene 1500 - Cutscene: Ship landing
*

View File

@ -183,6 +183,20 @@ public:
};
class Scene1337 : public SceneExt {
class OptionsDialog: public GfxDialog {
private:
GfxButton _autoplay;
GfxButton _restartGame;
GfxButton _quitGame;
GfxButton _continueGame;
OptionsDialog();
virtual ~OptionsDialog() {}
virtual GfxButton *OptionsDialog::execute(GfxButton *defaultButton);
public:
static void show();
};
class Card: public SceneHotspot {
public:
SceneObject _card;
@ -364,7 +378,7 @@ public:
void suggestInstructions();
void shuffleCards();
void dealCards();
void subCD193();
void showOptionsDialog();
void handleClick(int arg1, Common::Point pt);
void handlePlayer0();
void handlePlayer1();

View File

@ -213,6 +213,14 @@ char const *const ACCESS_CODE_REQUIRED = "access code required";
char const *const INVALID_ACCESS_CODE = "invalid access code";
char const *const FOREIGN_OBJECT_EXTRACTED = "foreign object extracted";
// Scene 1330/7 Options dialog messages
char const *const AUTO_PLAY_ON = "Auto-Play is On";
char const *const AUTO_PLAY_OFF = "Auto-Play is Off";
char const *const START_NEW_CARD_GAME = "Start a new game";
char const *const QUIT_CARD_GAME = "Quit Outpost Alpha";
char const *const CONTINUE_CARD_GAME = "Continue Outpost Alpha";
//
char const *const HELP_MSG = "\x1\rRETURN TO\r RINGWORLD\x14";
char const *const CHAR_TITLE = "\x01Select Character:";
char const *const CHAR_QUINN_MSG = " Quinn ";

View File

@ -165,6 +165,13 @@ extern char const *const ACCESS_CODE_REQUIRED;
extern char const *const INVALID_ACCESS_CODE;
extern char const *const FOREIGN_OBJECT_EXTRACTED;
// Scene 1330/7 Options dialog messages
extern char const *const AUTO_PLAY_ON;
extern char const *const AUTO_PLAY_OFF;
extern char const *const START_NEW_CARD_GAME;
extern char const *const QUIT_CARD_GAME;
extern char const *const CONTINUE_CARD_GAME;
// Dialog messages
extern char const *const HELP_MSG;
extern char const *const CHAR_TITLE;