aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorFilippos Karapetis2014-06-28 21:57:11 +0300
committerFilippos Karapetis2014-06-28 21:57:46 +0300
commitb356f7f923c265697cb5147b13e623b66ba14421 (patch)
tree68c2c7874862af46c0c1b551d8130838a487806e /engines/mads
parenta1b80bb536801568ed43089cf3cc284383283bc4 (diff)
downloadscummvm-rg350-b356f7f923c265697cb5147b13e623b66ba14421.tar.gz
scummvm-rg350-b356f7f923c265697cb5147b13e623b66ba14421.tar.bz2
scummvm-rg350-b356f7f923c265697cb5147b13e623b66ba14421.zip
MADS: Started implementing the Rex in-game and option menus
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp230
-rw-r--r--engines/mads/nebular/dialogs_nebular.h36
2 files changed, 248 insertions, 18 deletions
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 6f75c21fd4..a1459d5a8d 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -23,6 +23,10 @@
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/util.h"
+#include "common/translation.h"
+
+#include "gui/saveload.h"
+
#include "mads/mads.h"
#include "mads/screen.h"
#include "mads/msurface.h"
@@ -266,20 +270,73 @@ bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr,
void DialogsNebular::showDialog() {
switch (_pendingDialog) {
- case DIALOG_GAME_MENU:
- //GameMenuDialog::show();
- break;
case DIALOG_DIFFICULTY: {
DifficultyDialog *dlg = new DifficultyDialog(_vm);
dlg->show();
delete dlg;
break;
}
+ case DIALOG_GAME_MENU: {
+ GameMenuDialog *dlg = new GameMenuDialog(_vm);
+ dlg->show();
+ delete dlg;
+ break;
+ }
+ case DIALOG_SAVE: {
+ showScummVMSaveDialog();
+ break;
+ }
+ case DIALOG_RESTORE: {
+ showScummVMRestoreDialog();
+ break;
+ }
+ case DIALOG_OPTIONS: {
+ OptionsDialog *dlg = new OptionsDialog(_vm);
+ dlg->show();
+ delete dlg;
+ break;
+ }
default:
break;
}
}
+void DialogsNebular::showScummVMSaveDialog() {
+ Nebular::GameNebular &game = *(Nebular::GameNebular *)_vm->_game;
+ Scene *scene = &(game._scene);
+ GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+
+ int slot = dialog->runModalWithCurrentTarget();
+ if (slot >= 0) {
+ Common::String desc = dialog->getResultString();
+
+ if (desc.empty()) {
+ // create our own description for the saved game, the user didn't enter it
+ desc = dialog->createDefaultSaveDescription(slot);
+ }
+
+ scene->_spriteSlots.reset();
+ _vm->_screen._offset.y = 0;
+ scene->loadScene(scene->_currentSceneId, game._aaName, true);
+ scene->_userInterface.noInventoryAnim();
+ game._scene.drawElements(kTransitionFadeIn, false);
+
+ game.saveGame(slot, desc);
+ }
+}
+
+void DialogsNebular::showScummVMRestoreDialog() {
+ Nebular::GameNebular &game = *(Nebular::GameNebular *)_vm->_game;
+ GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+
+ int slot = dialog->runModalWithCurrentTarget();
+ if (slot >= 0) {
+ game._loadGameSlot = slot;
+ game._scene._currentSceneId = -1;
+ game._currentSectionNumber = -1;
+ }
+}
+
/*------------------------------------------------------------------------*/
CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong) :
@@ -514,7 +571,7 @@ ScreenDialog::ScreenDialog(MADSEngine *vm) : _vm(vm) {
int currentSceneId = scene._currentSceneId;
int priorSceneId = scene._priorSceneId;
- if (_vm->_dialogs->_pendingDialog == DIALOG_DIFFICULTY) {
+ if (_vm->_dialogs->_pendingDialog) {
palFlag = true;
} else {
_vm->_palette->initPalette();
@@ -593,12 +650,10 @@ void ScreenDialog::setClickableLines() {
void ScreenDialog::addQuote(int id1, int id2, DialogTextAlign align,
const Common::Point &pt, Font *font) {
- Common::String msg = _vm->_game->getQuote(id1);
+ Common::String msg = _vm->_game->getQuote(id1).c_str(); // c_str() because we need a copy
- if (id2 > 0) {
- msg += " ";
+ if (id2 > 0)
msg += _vm->_game->getQuote(id2);
- }
addLine(msg, align, pt, font);
}
@@ -646,6 +701,10 @@ void ScreenDialog::addLine(const Common::String &msg, DialogTextAlign align,
int xOffset;
switch (align) {
+ case ALIGN_NONE:
+ // No adjustment
+ break;
+
case ALIGN_CENTER:
xOffset = (MADS_SCREEN_WIDTH / 2) - font->getWidth(msg, -1) / 2;
line->_pos.x += xOffset;
@@ -658,6 +717,10 @@ void ScreenDialog::addLine(const Common::String &msg, DialogTextAlign align,
xOffset = (MADS_SCREEN_WIDTH / 2) - font->getWidth(
Common::String(msgP, ch), line->_widthAdjust);
line->_pos.x += xOffset;
+
+ Common::String newMsg = msg.c_str();
+ newMsg.deleteChar(ch - msgP);
+ line->_msg = newMsg;
}
break;
}
@@ -771,7 +834,7 @@ void ScreenDialog::handleEvents() {
}
int line = -1;
- if (objIndex > 0 || events._mouseButtons) {
+ if (objIndex > 0 /*|| events._mouseButtons*/) {
line = screenObjects[objIndex]._descId;
if (dialogs._pendingDialog == DIALOG_SAVE || dialogs._pendingDialog == DIALOG_RESTORE) {
if (line > 7 && line <= 14) {
@@ -887,14 +950,153 @@ void DifficultyDialog::show() {
GameMenuDialog::GameMenuDialog(MADSEngine *vm) : ScreenDialog(vm) {
setFrame(1, 2);
+ setLines();
+ setClickableLines();
}
-void GameMenuDialog::addLines() {
- initVars();
+void GameMenuDialog::setLines() {
Font *font = _vm->_font->getFont(FONT_CONVERSATION);
- int top = 78 - (font->getHeight() + 2) * 12;
- addQuote(10, 0, ALIGN_CENTER, Common::Point(0, top), font);
- // TODO
+
+ int yp = 64 - ((font->getHeight() + 1) * 4 + 6) / 2;
+
+ addQuote(10, 0, ALIGN_CENTER, Common::Point(0, yp), font);
+ yp += 6;
+
+ for (int id = 11; id <= 15; ++id) {
+ yp += font->getHeight();
+ addQuote(id, 0, ALIGN_CENTER, Common::Point(0, yp));
+ }
+}
+
+void GameMenuDialog::show() {
+ ScreenDialog::show();
+
+ switch (_selectedLine) {
+ case 1:
+ _vm->_dialogs->_pendingDialog = DIALOG_SAVE;
+ _vm->_dialogs->showDialog();
+ break;
+ case 2:
+ _vm->_dialogs->_pendingDialog = DIALOG_RESTORE;
+ _vm->_dialogs->showDialog();
+ break;
+ case 3:
+ _vm->_dialogs->_pendingDialog = DIALOG_OPTIONS;
+ _vm->_dialogs->showDialog();
+ break;
+ case 4:
+ // Resume game
+ break;
+ case 5:
+ default:
+ _vm->quitGame();
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+OptionsDialog::OptionsDialog(MADSEngine *vm) : ScreenDialog(vm) {
+ setFrame(2, 2);
+ setLines();
+ setClickableLines();
+}
+
+int OptionsDialog::getOptionQuote(int option) {
+ Nebular::GameNebular &game = *(Nebular::GameNebular *)_vm->_game;
+
+ // TODO: Hook the rest of the options to the current config
+ switch (option) {
+ case 17: // Music
+ return 24; // 24: ON, 25: OFF
+ case 18: // Sound
+ return 26; // 26: ON, 27: OFF
+ case 19: // Interface
+ return !_vm->_easyMouse ? 28 : 29; // 28: Standard, 29: Easy
+ case 20: // Inventory
+ return _vm->_invObjectsAnimated ? 30 : 31; // 30: Spinning, 31: Still
+ case 21: // Text window
+ return !_vm->_textWindowStill ? 32 : 33; // 32: Animated, 33: Still
+ case 22: // Screen fade
+ return 34 + _vm->_screenFade; // 34: Smooth, 35: Medium, 36: Fast
+ case 23: // Storyline
+ return (game._storyMode == STORYMODE_NAUGHTY) ? 37 : 38; // 37: Naughty, 38: Nice
+ default:
+ error("getOptionQuote: Unknown option");
+ }
+}
+
+void OptionsDialog::setLines() {
+ Font *font = _vm->_font->getFont(FONT_CONVERSATION);
+
+ int yp = 40 - ((font->getHeight() + 1) * 4 + 6) / 2;
+
+ addQuote(16, 0, ALIGN_CENTER, Common::Point(0, yp), font);
+ yp += 6;
+
+ for (int id = 17; id <= 23; ++id) {
+ yp += font->getHeight();
+ addQuote(id, getOptionQuote(id), ALIGN_AT_CENTER, Common::Point(0, yp));
+ }
+
+ yp += 28;
+ addQuote(1, 0, ALIGN_NONE, Common::Point(90, yp));
+ addQuote(2, 0, ALIGN_NONE, Common::Point(190, yp));
+}
+
+void OptionsDialog::show() {
+ Nebular::GameNebular &game = *(Nebular::GameNebular *)_vm->_game;
+ do {
+ _selectedLine = 0;
+ ScreenDialog::show();
+
+ switch (_selectedLine) {
+ case 1: // Music
+ warning("STUB: Music toggle");
+ break;
+ case 2: // Sound
+ warning("STUB: Sound toggle");
+ break;
+ case 3: // Interface
+ _vm->_easyMouse = !_vm->_easyMouse;
+ break;
+ case 4: // Inventory
+ _vm->_invObjectsAnimated = !_vm->_invObjectsAnimated;
+ break;
+ case 5: // Text window
+ _vm->_textWindowStill = !_vm->_textWindowStill;
+ break;
+ case 6: // Screen fade
+ if (_vm->_screenFade == SCREEN_FADE_FAST)
+ _vm->_screenFade = SCREEN_FADE_MEDIUM;
+ else if (_vm->_screenFade == SCREEN_FADE_MEDIUM)
+ _vm->_screenFade = SCREEN_FADE_SMOOTH;
+ else
+ _vm->_screenFade = SCREEN_FADE_FAST;
+ break;
+ case 7: // Storyline
+ game._storyMode = (game._storyMode == STORYMODE_NAUGHTY) ? STORYMODE_NICE : STORYMODE_NAUGHTY;
+ break;
+ default:
+ break;
+ }
+
+ // Reload menu
+ _lineIndex = -1;
+ clearLines();
+ setLines();
+ setClickableLines();
+ } while (_selectedLine <= 7);
+
+ switch (_selectedLine) {
+ case 8: // Done
+ // TODO: Copy from temporary config
+ break;
+ case 9: // Cancel
+ // TODO: Ignore all changes to temporary config
+ break;
+ default:
+ break;
+ }
}
} // End of namespace Nebular
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 39d0a31670..504359b6b8 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -46,6 +46,10 @@ private:
bool textNoun(Common::String &dest, int nounId, const Common::String &source);
bool commandCheck(const char *idStr, Common::String &valStr, const Common::String &command);
+
+ void showScummVMSaveDialog();
+ void showScummVMRestoreDialog();
+
public:
virtual void showDialog();
@@ -99,7 +103,7 @@ public:
virtual ~PictureDialog();
};
-enum DialogTextAlign { ALIGN_CENTER = -1, ALIGN_AT_CENTER = -2, ALIGN_RIGHT = -3 };
+enum DialogTextAlign { ALIGN_NONE = 0, ALIGN_CENTER = -1, ALIGN_AT_CENTER = -2, ALIGN_RIGHT = -3 };
enum DialogState { DLGSTATE_UNSELECTED = 0, DLGSTATE_SELECTED = 1, DLGSTATE_FOCUSED = 2 };
@@ -193,7 +197,7 @@ public:
class DifficultyDialog : public ScreenDialog {
private:
/**
- * Set the lines for the dialog
+ * Set the lines for the dialog
*/
void setLines();
public:
@@ -208,12 +212,36 @@ public:
class GameMenuDialog : public ScreenDialog {
private:
/**
- * Add the lines for the Game Menu dialog
+ * Set the lines for the dialog
*/
- void addLines();
+ void setLines();
public:
GameMenuDialog(MADSEngine *vm);
+ /**
+ * Show the dialog
+ */
+ virtual void show();
+};
+
+class OptionsDialog : public ScreenDialog {
+private:
+ /**
+ * Set the lines for the dialog
+ */
+ void setLines();
+
+ /**
+ * Gets the quote to be shown for an option
+ */
+ int getOptionQuote(int option);
+public:
+ OptionsDialog(MADSEngine *vm);
+
+ /**
+ * Show the dialog
+ */
+ virtual void show();
};
} // End of namespace Nebular