diff options
author | Strangerke | 2013-06-26 08:29:09 +0200 |
---|---|---|
committer | Strangerke | 2013-06-26 08:29:09 +0200 |
commit | 7aceea722161038fa892f89d81479c06c5ab6a18 (patch) | |
tree | 3360e16517662356d46e9d3cde90aa1029af887f /engines/mortevielle | |
parent | cf26edf3854ec2441e9ce5e11fada17cfc530754 (diff) | |
download | scummvm-rg350-7aceea722161038fa892f89d81479c06c5ab6a18.tar.gz scummvm-rg350-7aceea722161038fa892f89d81479c06c5ab6a18.tar.bz2 scummvm-rg350-7aceea722161038fa892f89d81479c06c5ab6a18.zip |
MORTEVIELLE: Introduce DialogManager and get rid of static functions
Diffstat (limited to 'engines/mortevielle')
-rw-r--r-- | engines/mortevielle/actions.cpp | 20 | ||||
-rw-r--r-- | engines/mortevielle/dialogs.cpp | 27 | ||||
-rw-r--r-- | engines/mortevielle/dialogs.h | 34 | ||||
-rw-r--r-- | engines/mortevielle/mortevielle.cpp | 19 | ||||
-rw-r--r-- | engines/mortevielle/mortevielle.h | 3 |
5 files changed, 52 insertions, 51 deletions
diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp index 3a27c27069..9026df8470 100644 --- a/engines/mortevielle/actions.cpp +++ b/engines/mortevielle/actions.cpp @@ -701,12 +701,12 @@ void MortevielleEngine::fctPlace() { _speechManager.startSpeech(6, -9, 1); // Do you want to enter the hidden passage? - int answer = Alert::show(getEngineString(S_YES_NO), 1); + int answer = _dialogManager.show(getEngineString(S_YES_NO), 1); if (answer == 1) { Common::String alertTxt = getString(582); - Alert::show(alertTxt, 1); + _dialogManager.show(alertTxt, 1); - bool enterPassageFl = KnowledgeCheck::show(); + bool enterPassageFl = _dialogManager.showKnowledgeCheck(); _mouse.hideMouse(); hirs(); drawRightFrame(); @@ -731,7 +731,7 @@ void MortevielleEngine::fctPlace() { aniof(1, 2); aniof(1, 1); alertTxt = getString(577); - Alert::show(alertTxt, 1); + _dialogManager.show(alertTxt, 1); aniof(2, 1); _crep = 166; } @@ -800,7 +800,7 @@ void MortevielleEngine::fctTurn() { if ((_coreVar._currPlace == ATTIC) && (_coreVar._atticRodHoleObjectId == 159) && (_coreVar._atticBallHoleObjectId == 141)) { handleDescriptionText(2, 167); _speechManager.startSpeech(7, 9, 1); - int answer = Alert::show(getEngineString(S_YES_NO), 1); + int answer = _dialogManager.show(getEngineString(S_YES_NO), 1); if (answer == 1) _endGame = true; else @@ -810,7 +810,7 @@ void MortevielleEngine::fctTurn() { handleDescriptionText(2, 175); clearVerbBar(); _speechManager.startSpeech(6, -9, 1); - int answer = Alert::show(getEngineString(S_YES_NO), 1); + int answer = _dialogManager.show(getEngineString(S_YES_NO), 1); if (answer == 1) { _coreVar._currPlace = CRYPT; affrep(); @@ -915,7 +915,7 @@ void MortevielleEngine::fctKnock() { displayTextInVerbBar(getEngineString(S_HIT)); if (_coreVar._currPlace == LANDING) { - Alert::show(getEngineString(S_BEFORE_USE_DEP_MENU), 1); + _dialogManager.show(getEngineString(S_BEFORE_USE_DEP_MENU), 1); return; } @@ -1225,7 +1225,7 @@ void MortevielleEngine::fctSleep() { if (h > 23) h = 0; prepareRoom(); - answer = Alert::show(getEngineString(S_YES_NO), 1); + answer = _dialogManager.show(getEngineString(S_YES_NO), 1); _anyone = false; } while (answer != 1); _crep = 998; @@ -1315,7 +1315,7 @@ void MortevielleEngine::fctWait() { return; } handleDescriptionText(2, 102); - answer = Alert::show(getEngineString(S_YES_NO), 1); + answer = _dialogManager.show(getEngineString(S_YES_NO), 1); } while (answer != 2); _crep = 998; if (!_anyone) @@ -1632,7 +1632,7 @@ void MortevielleEngine::askRestart() { _day = 0; handleDescriptionText(2, 180); - int answer = Alert::show(getEngineString(S_YES_NO), 1); + int answer = _dialogManager.show(getEngineString(S_YES_NO), 1); _quitGame = (answer != 1); } diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp index 90c53d1648..4c7fddfccd 100644 --- a/engines/mortevielle/dialogs.cpp +++ b/engines/mortevielle/dialogs.cpp @@ -38,7 +38,7 @@ namespace Mortevielle { * Alert function - Show * @remarks Originally called 'do_alert' */ -int Alert::show(const Common::String &msg, int n) { +int DialogManager::show(const Common::String &msg, int n) { // Make a copy of the current screen surface for later restore g_vm->_backgroundSurface.copyFrom(g_vm->_screenSurface); @@ -188,7 +188,7 @@ int Alert::show(const Common::String &msg, int n) { * Alert function - Decode Alert Details * @remarks Originally called 'decod' */ -void Alert::decodeAlertDetails(Common::String inputStr, int &choiceNumb, int &lineNumb, int &col, Common::String &choiceStr, Common::String &choiceListStr) { +void DialogManager::decodeAlertDetails(Common::String inputStr, int &choiceNumb, int &lineNumb, int &col, Common::String &choiceStr, Common::String &choiceListStr) { // The second character of the string contains the number of choices choiceNumb = atoi(inputStr.c_str() + 1); @@ -228,7 +228,7 @@ void Alert::decodeAlertDetails(Common::String inputStr, int &choiceNumb, int &li col *= 10; } -void Alert::setPosition(int ji, int coldep, int esp) { +void DialogManager::setPosition(int ji, int coldep, int esp) { g_vm->_screenSurface.putxy(coldep + (40 + esp) * (ji - 1), 98); } @@ -236,7 +236,7 @@ void Alert::setPosition(int ji, int coldep, int esp) { * Alert function - Draw Alert Box * @remarks Originally called 'fait_boite' */ -void Alert::drawAlertBox(int lidep, int nli, int tx) { +void DialogManager::drawAlertBox(int lidep, int nli, int tx) { if (tx > 640) tx = 640; int x = 320 - ((uint)tx / 2); @@ -252,7 +252,7 @@ void Alert::drawAlertBox(int lidep, int nli, int tx) { * Alert function - Set Button Text * @remarks Originally called 'fait_choix' */ -void Alert::setButtonText(Common::String c, int coldep, int nbcase, Common::String *str, int esp) { +void DialogManager::setButtonText(Common::String c, int coldep, int nbcase, Common::String *str, int esp) { int i = 1; int x = coldep; for (int l = 1; l <= nbcase; ++l) { @@ -283,7 +283,7 @@ void Alert::setButtonText(Common::String c, int coldep, int nbcase, Common::Stri /** * Questions asked before entering the hidden passage */ -bool KnowledgeCheck::show() { +bool DialogManager::showKnowledgeCheck() { const int textIndexArr[10] = {511, 516, 524, 531, 545, 552, 559, 563, 570, 576}; const int correctAnswerArr[10] = {4, 7, 1, 6, 4, 4, 2, 5, 3, 1 }; @@ -402,7 +402,7 @@ bool KnowledgeCheck::show() { /** * Draw the F3/F8 dialog */ -void f3f8::draw() { +void DialogManager::drawF3F8() { Common::String f3 = g_vm->getEngineString(S_F3); Common::String f8 = g_vm->getEngineString(S_F8); @@ -425,7 +425,7 @@ void f3f8::draw() { * Graphical Device if modified * @remarks Originally called 'diver' */ -void f3f8::checkForF8(int SpeechNum, bool drawAni50Fl) { +void DialogManager::checkForF8(int SpeechNum, bool drawAni50Fl) { g_vm->testKeyboard(); do { g_vm->_speechManager.startSpeech(SpeechNum, 0, 0); @@ -445,7 +445,7 @@ void f3f8::checkForF8(int SpeechNum, bool drawAni50Fl) { * Alert function - Loop until F3 or F8 is pressed * @remarks Originally called 'atf3f8' */ -int f3f8::waitForF3F8() { +int DialogManager::waitForF3F8() { int key; do { @@ -457,7 +457,7 @@ int f3f8::waitForF3F8() { return key; } -void f3f8::aff50(bool drawAni50Fl) { +void DialogManager::aff50(bool drawAni50Fl) { g_vm->_caff = 50; g_vm->_maff = 0; g_vm->_text.taffich(); @@ -468,10 +468,10 @@ void f3f8::aff50(bool drawAni50Fl) { g_vm->handleDescriptionText(2, kDialogStringIndex + 142); // Draw the f3/f8 dialog - draw(); + drawF3F8(); } -void f3f8::ani50() { +void DialogManager::ani50() { g_vm->_crep = g_vm->animof(1, 1); g_vm->pictout(kAdrAni, g_vm->_crep, 63, 12); g_vm->_crep = g_vm->animof(2, 1); @@ -480,4 +480,7 @@ void f3f8::ani50() { g_vm->handleDescriptionText(2, kDialogStringIndex + 143); } +void DialogManager::setParent(MortevielleEngine *vm) { + _vm = vm; +} } // End of namespace Mortevielle diff --git a/engines/mortevielle/dialogs.h b/engines/mortevielle/dialogs.h index 9b980af379..35c3c34cac 100644 --- a/engines/mortevielle/dialogs.h +++ b/engines/mortevielle/dialogs.h @@ -32,6 +32,7 @@ #include "common/str.h" namespace Mortevielle { +class MortevielleEngine; static const int NUM_LINES = 7; const int kMaxHotspots = 14; @@ -41,28 +42,23 @@ struct Hotspot { bool _enabled; }; -class Alert { +class DialogManager { private: - static void decodeAlertDetails(Common::String inputStr, int &choiceNumb, int &lineNumb, int &col, Common::String &choiceStr, Common::String &choiceListStr); - static void setPosition(int ji, int coldep, int esp); - static void drawAlertBox(int lidep, int nli, int tx); - static void setButtonText(Common::String c, int coldep, int nbcase, Common::String *str, int esp); -public: - static int show(const Common::String &msg, int n); -}; - -class KnowledgeCheck { -public: - static bool show(); -}; + MortevielleEngine *_vm; -class f3f8 { + void decodeAlertDetails(Common::String inputStr, int &choiceNumb, int &lineNumb, int &col, Common::String &choiceStr, Common::String &choiceListStr); + void setPosition(int ji, int coldep, int esp); + void drawAlertBox(int lidep, int nli, int tx); + void setButtonText(Common::String c, int coldep, int nbcase, Common::String *str, int esp); public: - static void draw(); - static void checkForF8(int SpeechNum, bool drawAni50Fl); - static int waitForF3F8(); - static void aff50(bool drawAni50Fl); - static void ani50(); + void setParent(MortevielleEngine *vm); + int show(const Common::String &msg, int n); + void drawF3F8(); + void checkForF8(int SpeechNum, bool drawAni50Fl); + int waitForF3F8(); + void aff50(bool drawAni50Fl); + void ani50(); + bool showKnowledgeCheck(); }; } // End of namespace Mortevielle diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index c6cafac9d6..95750f5c4a 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -75,6 +75,7 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g _soundManager(_mixer) { g_vm = this; _debugger.setParent(this); + _dialogManager.setParent(this); _screenSurface.setParent(this); _mouse.setParent(this); _text.setParent(this); @@ -579,14 +580,14 @@ Common::Error MortevielleEngine::run() { * Show the game introduction */ void MortevielleEngine::showIntroduction() { - f3f8::aff50(false); + _dialogManager.aff50(false); _speechManager._mlec = 0; - f3f8::checkForF8(142, false); + _dialogManager.checkForF8(142, false); if (shouldQuit()) return; - f3f8::ani50(); - f3f8::checkForF8(143, true); + _dialogManager.ani50(); + _dialogManager.checkForF8(143, true); if (shouldQuit()) return; @@ -689,7 +690,7 @@ void MortevielleEngine::handleAction() { if (_menu._menuSelected && (_msg[3] == MENU_LOAD)) _savegameManager.loadGame((_msg[4] & 15) - 1); if (inkey == '\103') { /* F9 */ - temps = Alert::show(_hintPctMessage, 1); + temps = _dialogManager.show(_hintPctMessage, 1); return; } else if (inkey == '\77') { if ((_menuOpcode != OPCODE_NONE) && ((_msg[3] == MENU_ACTION) || (_msg[3] == MENU_SELF))) { @@ -1753,12 +1754,12 @@ void MortevielleEngine::startDialog(int16 rep) { _mouse.hideMouse(); Common::String dialogStr = getString(rep + kDialogStringIndex); _text.displayStr(dialogStr, 230, 4, 65, 24, 5); - f3f8::draw(); + _dialogManager.drawF3F8(); key = 0; do { _speechManager.startSpeech(rep, haut[_caff - 69], 0); - key = f3f8::waitForF3F8(); + key = _dialogManager.waitForF3F8(); if (shouldQuit()) return; } while (key != 66); @@ -2164,7 +2165,7 @@ int MortevielleEngine::getRandomNumber(int minval, int maxval) { * @remarks Originally called 'aldepl' */ void MortevielleEngine::showMoveMenuAlert() { - Alert::show(getEngineString(S_USE_DEP_MENU), 1); + _dialogManager.show(getEngineString(S_USE_DEP_MENU), 1); } /** @@ -3640,7 +3641,7 @@ void MortevielleEngine::tfleche() { } while (!(qust || inRect || _anyone)); if (qust && (touch == '\103')) - Alert::show(_hintPctMessage, 1); + _dialogManager.show(_hintPctMessage, 1); } while (!((touch == '\73') || ((touch == '\104') && (_x != 0) && (_y != 0)) || (_anyone) || (inRect))); if (touch == '\73') diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index bdf28e4514..9facc5ef86 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -38,6 +38,7 @@ #include "common/error.h" #include "graphics/surface.h" #include "mortevielle/debugger.h" +#include "mortevielle/dialogs.h" #include "mortevielle/graphics.h" #include "mortevielle/menu.h" #include "mortevielle/mouse.h" @@ -487,6 +488,7 @@ public: Menu _menu; MouseHandler _mouse; TextHandler _text; + DialogManager _dialogManager; MortevielleEngine(OSystem *system, const ADGameDescription *gameDesc); ~MortevielleEngine(); @@ -528,7 +530,6 @@ public: void pictout(int seg, int dep, int x, int y); void sauvecr(int y, int dy); void charecr(int y, int dy); - }; extern MortevielleEngine *g_vm; |