aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2009-04-28 15:00:56 +0000
committerNicola Mettifogo2009-04-28 15:00:56 +0000
commit01fceec37c83ba855ed60b284d47c7e6a84d2f1d (patch)
tree3123e1fef6061f0b1aa1f6a86bc067f3d9adc2d3 /engines/parallaction
parenta4cb413d7038be2780271fedb39f2505177fdc6f (diff)
downloadscummvm-rg350-01fceec37c83ba855ed60b284d47c7e6a84d2f1d.tar.gz
scummvm-rg350-01fceec37c83ba855ed60b284d47c7e6a84d2f1d.tar.bz2
scummvm-rg350-01fceec37c83ba855ed60b284d47c7e6a84d2f1d.zip
Implemented quit dialog box in BRA.
svn-id: r40181
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/gui_br.cpp84
1 files changed, 83 insertions, 1 deletions
diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp
index 760a5b0d04..fd882d4b93 100644
--- a/engines/parallaction/gui_br.cpp
+++ b/engines/parallaction/gui_br.cpp
@@ -366,6 +366,12 @@ public:
_cellH = _menuRect.height() / 2;
}
+ ~IngameMenuInputState_BR() {
+ delete _menuObj;
+ delete _mscMenuObj;
+ delete _sfxMenuObj;
+ }
+
MenuInputState *run() {
if (_vm->_input->getLastButtonEvent() != kMouseLeftUp) {
return this;
@@ -412,7 +418,7 @@ public:
break;
case 5: // quit
- _vm->quitGame();
+ return _helper->getState("quitdialog");
}
return 0;
@@ -433,10 +439,86 @@ public:
}
};
+class QuitDialogInputState_BR : public MenuInputState {
+ Parallaction_br *_vm;
+ Font *_font;
+ int _x, _y;
+ GfxObj *_obj;
+
+public:
+ QuitDialogInputState_BR(Parallaction_br *vm, MenuInputHelper *helper) : MenuInputState("quitdialog", helper), _vm(vm) {
+ _font = _vm->_dialogueFont;
+
+ const char *question = "Do you really want to quit ?";
+ const char *option = "Yes No";
+
+ int questionW = _font->getStringWidth(question);
+ int optionW = _font->getStringWidth(option);
+ int w = MAX(questionW, optionW) + 30;
+
+ _x = (640 - w) / 2;
+ _y = 90;
+
+ Graphics::Surface *surf = new Graphics::Surface;
+ surf->create(w, 110, 1);
+ surf->fillRect(Common::Rect(0, 0, w, 110), 12);
+ surf->fillRect(Common::Rect(10, 10, w-10, 100), 15);
+
+ _font->setColor(0);
+ int x = (w - questionW)/2;
+ int y = 13;
+ _font->drawString((byte*)surf->getBasePtr(x, y), surf->pitch, question);
+ x = (w - optionW)/2;
+ y = 13 + _font->height()*2;
+ _font->drawString((byte*)surf->getBasePtr(x,y), surf->pitch, option);
+
+ _obj = new GfxObj(kGfxObjTypeMenu, new SurfaceToFrames(surf), "quitdialog");
+ assert(_obj);
+ }
+
+ ~QuitDialogInputState_BR() {
+ delete _obj;
+ }
+
+ MenuInputState *run() {
+ uint16 key;
+ bool e = _vm->_input->getLastKeyDown(key);
+ if (!e) {
+ return this;
+ }
+
+ if (key == 'y' || key == 'Y') {
+ _vm->quitGame();
+ return 0;
+ } else
+ if (key == 'n' || key == 'N') {
+ // NOTE: when the quit dialog is hidden, the in-game menu is
+ // deleted for a frame, and then redrawn. This is because the
+ // current implementation of graphic 'items' doesn't allow
+ // deletion of a single 'item'.
+ _vm->_gfx->freeDialogueObjects();
+ return _helper->getState("ingamemenu");
+ }
+
+ return this;
+ }
+
+
+ void enter() {
+ // setPaletteEntry(1, 0, 0, 0); // text color
+ // setPaletteEntry(15, 255, 255, 255); // background color
+ int id = _vm->_gfx->setItem(_obj, _x, _y, 0);
+ _vm->_gfx->setItemFrame(id, 0);
+ }
+};
+
+
void Parallaction_br::startIngameMenu() {
_menuHelper = new MenuInputHelper;
new IngameMenuInputState_BR(this, _menuHelper);
+ new QuitDialogInputState_BR(this, _menuHelper);
+
_menuHelper->setState("ingamemenu");
_input->_inputMode = Input::kInputModeMenu;