From d738576f1c966d4e515c3a3ee64bd0972b3efdca Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 13 Feb 2012 20:51:36 +1100 Subject: MORTEVIELLE: Convert f3/f8 dialog, alert dialog, and ques dialogs into classes --- engines/mortevielle/actions.cpp | 23 +- engines/mortevielle/alert.cpp | 270 ---------------------- engines/mortevielle/alert.h | 39 ---- engines/mortevielle/dialogs.cpp | 447 ++++++++++++++++++++++++++++++++++++ engines/mortevielle/dialogs.h | 60 +++++ engines/mortevielle/module.mk | 3 +- engines/mortevielle/mor.cpp | 22 +- engines/mortevielle/mor.h | 1 - engines/mortevielle/mor2.cpp | 17 +- engines/mortevielle/mor2.h | 1 - engines/mortevielle/mortevielle.cpp | 27 +-- engines/mortevielle/mortevielle.h | 1 - engines/mortevielle/ovd1.cpp | 21 +- engines/mortevielle/ovd1.h | 2 - engines/mortevielle/prog.cpp | 2 +- engines/mortevielle/ques.cpp | 144 ------------ engines/mortevielle/ques.h | 38 --- engines/mortevielle/saveload.cpp | 2 +- 18 files changed, 535 insertions(+), 585 deletions(-) delete mode 100644 engines/mortevielle/alert.cpp delete mode 100644 engines/mortevielle/alert.h create mode 100644 engines/mortevielle/dialogs.cpp create mode 100644 engines/mortevielle/dialogs.h delete mode 100644 engines/mortevielle/ques.cpp delete mode 100644 engines/mortevielle/ques.h diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp index dfd0811086..02c7b6a90f 100644 --- a/engines/mortevielle/actions.cpp +++ b/engines/mortevielle/actions.cpp @@ -27,7 +27,7 @@ #include "common/scummsys.h" #include "mortevielle/actions.h" -#include "mortevielle/alert.h" +#include "mortevielle/dialogs.h" #include "mortevielle/level15.h" #include "mortevielle/menu.h" #include "mortevielle/mor.h" @@ -35,7 +35,6 @@ #include "mortevielle/mortevielle.h" #include "mortevielle/mouse.h" #include "mortevielle/outtext.h" -#include "mortevielle/ques.h" #include "mortevielle/parole2.h" #include "mortevielle/taffich.h" #include "mortevielle/var_mor.h" @@ -529,12 +528,12 @@ void tmettre() { repon(2, 165); maivid(); parole(6, -9, 1); - quel = do_alert(g_vm->getString(S_YES_NO), 1); + quel = Alert::show(g_vm->getString(S_YES_NO), 1); if (quel == 1) { deline(582, st, tay); - i = do_alert(delig, 1); + i = Alert::show(delig, 1); tesok = false; - entre = ques(); + entre = Ques::show(); hide_mouse(); hirs(); dessine_rouleau(); @@ -559,7 +558,7 @@ void tmettre() { aniof(1, 2); aniof(1, 1); deline(577, st, tay); - i = do_alert(delig, 1); + i = Alert::show(delig, 1); aniof(2, 1); crep = 166; } @@ -611,7 +610,7 @@ void ttourner() { if ((s.mlieu == 13) && (s.ibag == 159) && (s.iboul == 141)) { repon(2, 167); parole(7, 9, 1); - quel = do_alert(g_vm->getString(S_YES_NO), 1); + quel = Alert::show(g_vm->getString(S_YES_NO), 1); if (quel == 1) g_vm->_endGame = true; else crep = 168; @@ -620,7 +619,7 @@ void ttourner() { repon(2, 175); clsf3(); parole(6, -9, 1); - quel = do_alert(g_vm->getString(S_YES_NO), 1); + quel = Alert::show(g_vm->getString(S_YES_NO), 1); if (quel == 1) { s.mlieu = 16; affrep(); @@ -700,7 +699,7 @@ void tfrapper() { if (!syn) ecr3(g_vm->getString(S_HIT)); if (s.mlieu == 15) { - l = do_alert(g_vm->getString(S_BEFORE_USE_DEP_MENU), 1); + l = Alert::show(g_vm->getString(S_BEFORE_USE_DEP_MENU), 1); return; } if (s.mlieu < 25) { @@ -930,7 +929,7 @@ void tdormir() { h = h + 1; if (h > 23) h = 0; tinke(); - quel = do_alert(g_vm->getString(S_YES_NO), 1); + quel = Alert::show(g_vm->getString(S_YES_NO), 1); anyone = false; } while (!(quel == 1)); crep = 998; @@ -992,7 +991,7 @@ void tattendre() { return; } repon(2, 102); - quel = do_alert(g_vm->getString(S_YES_NO), 1); + quel = Alert::show(g_vm->getString(S_YES_NO), 1); } while (!(quel == 2)); crep = 998; if (! anyone) tinke(); @@ -1259,7 +1258,7 @@ void MortevielleEngine::loseGame() { heu = 10; jou = 0; repon(2, 180); - quel = do_alert(g_vm->getString(S_YES_NO), 1); + quel = Alert::show(g_vm->getString(S_YES_NO), 1); _quitGame = (quel != 1); } diff --git a/engines/mortevielle/alert.cpp b/engines/mortevielle/alert.cpp deleted file mode 100644 index a3787a09b3..0000000000 --- a/engines/mortevielle/alert.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Mortville Manor DOS source code - * Copyright (c) 1988-1989 Lankhor - */ - -#include "common/str.h" -#include "mortevielle/alert.h" -#include "mortevielle/level15.h" -#include "mortevielle/mortevielle.h" -#include "mortevielle/mouse.h" - -namespace Mortevielle { - -int do_alert(Common::String str_, int n); - - -const int nligne = 7; - -const int coord[3][4] = { - {0, 0, 0, 0}, - {0, 150, 72, 103}, - {0, 143, 107, 183} -}; - - -static void decod(Common::String s, int &nbc, int &nbl, int &col, Common::String &c, Common::String &cs) { - int i, k; - bool v; - - //val(s[2], nbc, i); - nbc = atoi(s.c_str() + 1); - i = 0; - - c = ""; - nbl = 0; - i = 5; - k = 0; - v = true; - col = 0; - - while (s[i] != ']') { - c = c + s[i]; - if ((s[i] == '|') || (s[i + 1] == ']')) { - if (k > col) col = k; - k = 0; - nbl = nbl + 1; - } else if (s[i] != ' ') v = false; - i = i + 1; - k = k + 1; - } - if (v) { - c = ""; - col = 20; - } else { - c = c + ']'; - col = col + 6; - } - i = i + 1; - cs = copy(s, i, 30); - if (res == 2) col = col * 6; - else col = col * 10; -} - - - -static void posit(int ji, int &coldep, int &esp) { - g_vm->_screenSurface.putxy(coldep + (40 + esp) *pred(int, ji), 98); -} - - - -static void fait_boite(int lidep, int nli, int tx) { - int x, y, xx, yy; - - if (tx > 640) tx = 640; - x = 320 - ((uint)tx >> 1); - y = pred(int, lidep) << 3; - xx = x + tx; - yy = y + (nli << 3); - g_vm->_screenSurface.fillRect(15, Common::Rect(x, y, xx, yy)); - g_vm->_screenSurface.fillRect(0, Common::Rect(x, y + 2, xx, y + 4)); - g_vm->_screenSurface.fillRect(0, Common::Rect(x, yy - 4, xx, yy - 2)); -} - - - -static void fait_choix(Common::String c, int &coldep, int &nbcase, Common::String *str, int &esp) { - int i, l, x; - char ch; - - i = 1; - x = coldep; - for (l = 1; l <= nbcase; l ++) { - str[l] = ""; - do { - i = i + 1; - ch = c[i]; - str[l] = str[l] + ch; - } while (!(c[i + 1] == ']')); - i = i + 2; - while (str[l].size() < 3) str[l] = str[l] + ' '; - g_vm->_screenSurface.putxy(x, 98); - - Common::String tmp(" "); - tmp += str[l]; - tmp += " "; - - g_vm->_screenSurface.writeg(tmp, 0); - x = x + esp + 40; - } -} - -int do_alert(Common::String str_, int n) { - int coldep, esp, i, nbcase, quoi, ix; - Common::String st, chaine; - int limit[3][3]; - char dumi; - Common::String s[3]; - int cx, cy, nbcol, nblig; - bool newaff, test, test1, test2, test3, dum; - Common::String cas; - - // Make a copy of the current screen surface for later restore - g_vm->_backgroundSurface.copyFrom(g_vm->_screenSurface); - - /*debug('** do_alert **');*/ - memset(&limit[0][0], 0, sizeof(int) * 3 * 3); - int do_alert_result; - hide_mouse(); - while (keypressed()) - dumi = get_ch(); // input >> kbd >> dumi; - - g_vm->setMouseClick(false); - decod(str_, nbcase, nblig, nbcol, chaine, cas); - sauvecr(50, succ(int, nligne) << 4); - - i = 0; - if (chaine == "") { - fait_boite(10, 5, nbcol); - } else { - fait_boite(8, 7, nbcol); - i = 0; - g_vm->_screenSurface._textPos.y = 70; - do { - cx = 320; - st = ""; - while ((chaine[i + 1] != '\174') && (chaine[i + 1] != '\135')) { - i = i + 1; - st = st + chaine[i]; - if (res == 2) cx = cx - 3; - else cx = cx - 5; - } - g_vm->_screenSurface.putxy(cx, g_vm->_screenSurface._textPos.y); - g_vm->_screenSurface._textPos.y += 6; - g_vm->_screenSurface.writeg(st, 4); - i = i + 1; - } while (!(chaine[i] == ']')); - } - if (nbcase == 1) esp = nbcol - 40; - else esp = (uint)(nbcol - nbcase * 40) >> 1; - coldep = 320 - ((uint)nbcol >> 1) + ((uint)esp >> 1); - fait_choix(cas, coldep, nbcase, &s[0], esp); - limit[1][1] = ((uint)(coldep) >> 1) * res; - limit[1][2] = limit[1][1] + 40; - if (nbcase == 1) { - limit[2][1] = limit[2][2]; - } else { - limit[2][1] = ((uint)(320 + ((uint)esp >> 1)) >> 1) * res; - limit[2][2] = (limit[2][1]) + 40; - } - show_mouse(); - quoi = 0; - dum = false; - do { - dumi = '\377'; - mov_mouse(dum, dumi); - CHECK_QUIT0; - - cx = x_s; - cy = y_s; - test = (cy > 95) && (cy < 105); - newaff = false; - if (test) { - test1 = (cx > limit[1][1]) && (cx < limit[1][2]); - test2 = test1; - if (nbcase > 1) test2 = test1 || ((cx > limit[2][1]) && (cx < limit[2][2])); - if (test2) { - newaff = true; - if (test1) ix = 1; - else ix = 2; - if (ix != quoi) { - hide_mouse(); - if (quoi != 0) { - posit(quoi, coldep, esp); - - Common::String tmp(" "); - tmp += s[quoi]; - tmp += " "; - g_vm->_screenSurface.writeg(tmp, 0); - } - posit(ix, coldep, esp); - - Common::String tmp2 = " "; - tmp2 += s[ix]; - tmp2 += " "; - g_vm->_screenSurface.writeg(tmp2, 1); - - quoi = ix; - show_mouse(); - } - } - } - if ((quoi != 0) && ! newaff) { - hide_mouse(); - posit(quoi, coldep, esp); - - Common::String tmp3(" "); - tmp3 += s[quoi]; - tmp3 += " "; - g_vm->_screenSurface.writeg(tmp3, 0); - - quoi = 0; - show_mouse(); - } - test3 = (cy > 95) && (cy < 105) && (((cx > limit[1][1]) && (cx < limit[1][2])) - || ((cx > limit[2][1]) && (cx < limit[2][2]))); - } while (!g_vm->getMouseClick()); - g_vm->setMouseClick(false); - hide_mouse(); - if (! test3) { - quoi = n; - posit(n, coldep, esp); - Common::String tmp4(" "); - tmp4 += s[n]; - tmp4 += " "; - g_vm->_screenSurface.writeg(tmp4, 1); - } - charecr(50, succ(int, nligne) << 4); - show_mouse(); - - /* Restore the background area */ - g_vm->_screenSurface.copyFrom(g_vm->_backgroundSurface, 0, 0); - - do_alert_result = quoi; - return do_alert_result; -} - -} // End of namespace Mortevielle diff --git a/engines/mortevielle/alert.h b/engines/mortevielle/alert.h deleted file mode 100644 index f7a9e7d1c1..0000000000 --- a/engines/mortevielle/alert.h +++ /dev/null @@ -1,39 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Mortville Manor DOS source code - * Copyright (c) 1988-1989 Lankhor - */ - -#ifndef MORTEVIELLE_ALERT_H -#define MORTEVIELLE_ALERT_H - -#include "common/str.h" - -namespace Mortevielle { - -extern int do_alert(Common::String str_, int n); -extern int do_alert(Common::String str_, int n); - -} // End of namespace Mortevielle -#endif diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp new file mode 100644 index 0000000000..3efa80efdd --- /dev/null +++ b/engines/mortevielle/dialogs.cpp @@ -0,0 +1,447 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Mortville Manor DOS source code + * Copyright (c) 1988-1989 Lankhor + */ + +#include "common/str.h" +#include "mortevielle/dialogs.h" +#include "mortevielle/keyboard.h" +#include "mortevielle/level15.h" +#include "mortevielle/mortevielle.h" +#include "mortevielle/mor.h" +#include "mortevielle/mouse.h" +#include "mortevielle/outtext.h" +#include "mortevielle/parole2.h" +#include "mortevielle/taffich.h" + +namespace Mortevielle { + +static const int nligne = 7; + +/* +static const int coord[3][4] = { + {0, 0, 0, 0}, + {0, 150, 72, 103}, + {0, 143, 107, 183} +}; +*/ + +int Alert::show(const Common::String &msg, int n) { + int coldep, esp, i, nbcase, quoi, ix; + Common::String st, chaine; + int limit[3][3]; + char dumi; + Common::String s[3]; + int cx, cy, nbcol, nblig; + bool newaff, test, test1, test2, test3, dum; + Common::String cas; + + // Make a copy of the current screen surface for later restore + g_vm->_backgroundSurface.copyFrom(g_vm->_screenSurface); + + /*debug('** do_alert **');*/ + memset(&limit[0][0], 0, sizeof(int) * 3 * 3); + int do_alert_result; + hide_mouse(); + while (keypressed()) + dumi = get_ch(); // input >> kbd >> dumi; + + g_vm->setMouseClick(false); + decod(msg, nbcase, nblig, nbcol, chaine, cas); + sauvecr(50, succ(int, nligne) << 4); + + i = 0; + if (chaine == "") { + fait_boite(10, 5, nbcol); + } else { + fait_boite(8, 7, nbcol); + i = 0; + g_vm->_screenSurface._textPos.y = 70; + do { + cx = 320; + st = ""; + while ((chaine[i + 1] != '\174') && (chaine[i + 1] != '\135')) { + i = i + 1; + st = st + chaine[i]; + if (res == 2) cx = cx - 3; + else cx = cx - 5; + } + g_vm->_screenSurface.putxy(cx, g_vm->_screenSurface._textPos.y); + g_vm->_screenSurface._textPos.y += 6; + g_vm->_screenSurface.writeg(st, 4); + i = i + 1; + } while (!(chaine[i] == ']')); + } + if (nbcase == 1) esp = nbcol - 40; + else esp = (uint)(nbcol - nbcase * 40) >> 1; + coldep = 320 - ((uint)nbcol >> 1) + ((uint)esp >> 1); + fait_choix(cas, coldep, nbcase, &s[0], esp); + limit[1][1] = ((uint)(coldep) >> 1) * res; + limit[1][2] = limit[1][1] + 40; + if (nbcase == 1) { + limit[2][1] = limit[2][2]; + } else { + limit[2][1] = ((uint)(320 + ((uint)esp >> 1)) >> 1) * res; + limit[2][2] = (limit[2][1]) + 40; + } + show_mouse(); + quoi = 0; + dum = false; + do { + dumi = '\377'; + mov_mouse(dum, dumi); + CHECK_QUIT0; + + cx = x_s; + cy = y_s; + test = (cy > 95) && (cy < 105); + newaff = false; + if (test) { + test1 = (cx > limit[1][1]) && (cx < limit[1][2]); + test2 = test1; + if (nbcase > 1) test2 = test1 || ((cx > limit[2][1]) && (cx < limit[2][2])); + if (test2) { + newaff = true; + if (test1) ix = 1; + else ix = 2; + if (ix != quoi) { + hide_mouse(); + if (quoi != 0) { + setPosition(quoi, coldep, esp); + + Common::String tmp(" "); + tmp += s[quoi]; + tmp += " "; + g_vm->_screenSurface.writeg(tmp, 0); + } + setPosition(ix, coldep, esp); + + Common::String tmp2 = " "; + tmp2 += s[ix]; + tmp2 += " "; + g_vm->_screenSurface.writeg(tmp2, 1); + + quoi = ix; + show_mouse(); + } + } + } + if ((quoi != 0) && ! newaff) { + hide_mouse(); + setPosition(quoi, coldep, esp); + + Common::String tmp3(" "); + tmp3 += s[quoi]; + tmp3 += " "; + g_vm->_screenSurface.writeg(tmp3, 0); + + quoi = 0; + show_mouse(); + } + test3 = (cy > 95) && (cy < 105) && (((cx > limit[1][1]) && (cx < limit[1][2])) + || ((cx > limit[2][1]) && (cx < limit[2][2]))); + } while (!g_vm->getMouseClick()); + g_vm->setMouseClick(false); + hide_mouse(); + if (! test3) { + quoi = n; + setPosition(n, coldep, esp); + Common::String tmp4(" "); + tmp4 += s[n]; + tmp4 += " "; + g_vm->_screenSurface.writeg(tmp4, 1); + } + charecr(50, succ(int, nligne) << 4); + show_mouse(); + + /* Restore the background area */ + g_vm->_screenSurface.copyFrom(g_vm->_backgroundSurface, 0, 0); + + do_alert_result = quoi; + return do_alert_result; +} + +void Alert::decod(Common::String s, int &nbc, int &nbl, int &col, Common::String &c, Common::String &cs) { + int i, k; + bool v; + + //val(s[2], nbc, i); + nbc = atoi(s.c_str() + 1); + i = 0; + + c = ""; + nbl = 0; + i = 5; + k = 0; + v = true; + col = 0; + + while (s[i] != ']') { + c = c + s[i]; + if ((s[i] == '|') || (s[i + 1] == ']')) { + if (k > col) col = k; + k = 0; + nbl = nbl + 1; + } else if (s[i] != ' ') v = false; + i = i + 1; + k = k + 1; + } + if (v) { + c = ""; + col = 20; + } else { + c = c + ']'; + col = col + 6; + } + i = i + 1; + cs = copy(s, i, 30); + if (res == 2) col = col * 6; + else col = col * 10; +} + +void Alert::setPosition(int ji, int coldep, int esp) { + g_vm->_screenSurface.putxy(coldep + (40 + esp) *pred(int, ji), 98); +} + +void Alert::fait_boite(int lidep, int nli, int tx) { + int x, y, xx, yy; + + if (tx > 640) tx = 640; + x = 320 - ((uint)tx >> 1); + y = pred(int, lidep) << 3; + xx = x + tx; + yy = y + (nli << 3); + g_vm->_screenSurface.fillRect(15, Common::Rect(x, y, xx, yy)); + g_vm->_screenSurface.fillRect(0, Common::Rect(x, y + 2, xx, y + 4)); + g_vm->_screenSurface.fillRect(0, Common::Rect(x, yy - 4, xx, yy - 2)); +} + + + +void Alert::fait_choix(Common::String c, int coldep, int nbcase, Common::String *str, int esp) { + int i, l, x; + char ch; + + i = 1; + x = coldep; + for (l = 1; l <= nbcase; l ++) { + str[l] = ""; + do { + i = i + 1; + ch = c[i]; + str[l] = str[l] + ch; + } while (!(c[i + 1] == ']')); + i = i + 2; + while (str[l].size() < 3) str[l] = str[l] + ' '; + g_vm->_screenSurface.putxy(x, 98); + + Common::String tmp(" "); + tmp += str[l]; + tmp += " "; + + g_vm->_screenSurface.writeg(tmp, 0); + x = x + esp + 40; + } +} + +/*------------------------------------------------------------------------*/ + +bool Ques::show() { + const int ta[11] = {0, 511, 516, 524, 531, 545, 552, 559, 563, 570, 576}; + const int ok[11] = {0, 4, 7, 1, 6, 4, 4, 2, 5, 3, 1 }; + + bool q, func, test; + int i, j, k, y, memk; + int tay , tmax; + int rep, prem, der; + char st[1410]; + char key; + rectangle coor[max_rect]; + Common::String chaines[15]; + int compte; + + + bool ques_result; + test = false; + i = 0; + compte = 0; + + do { + hide_mouse(); + hirs(); + show_mouse(); + i = i + 1; + deline(ta[i], st, tay); + if (res == 1) y = 29; + else y = 23; + g_vm->_screenSurface.fillRect(15, Common::Rect(0, 14, 630, y)); + afftex(st, 20, 15, 100, 2, 0); + if (i != 10) { + prem = ta[i] + 1; + der = ta[i + 1] - 1; + } else { + prem = 503; + der = 510; + } + y = 35; + tmax = 0; + memk = 1; + for (j = prem; j <= der; j ++) { + deline(j, st, tay); + if (tay > tmax) tmax = tay; + afftex(st, 100, y, 100, 1, 0); + chaines[memk] = delig; + memk = memk + 1; + y = y + 8; + } + for (j = 1; j <= succ(int, der - prem); j ++) { + { + rectangle &with = coor[j]; + + with.x1 = 45 * res; + with.x2 = (tmax * 3 + 55) * res; + with.y1 = 27 + j * 8; + with.y2 = 34 + j * 8; + with.etat = true; + } + while ((int)chaines[j].size() < tmax) { + chaines[j] = chaines[j] + ' '; + } + } + coor[j + 1].etat = false; + if (res == 1) rep = 10; + else rep = 6; + g_vm->_screenSurface.drawBox(80, 33, 40 + tmax * rep, (der - prem) * 8 + 16, 15); + rep = 0; + j = 0; + memk = 0; + do { + g_vm->setMouseClick(false); + tesok = false; + mov_mouse(func, key); + CHECK_QUIT0; + + k = 1; + while (coor[k].etat && ! dans_rect(coor[k])) k = k + 1; + if (coor[k].etat) { + if ((memk != 0) && (memk != k)) { + for (j = 1; j <= tmax; j ++) st[j] = chaines[memk][j]; + st[1 + tmax] = '$'; + afftex(st, 100, 27 + memk * 8, 100, 1, 0); + } + if (memk != k) { + for (j = 1; j <= tmax; j ++) st[j] = chaines[k][j]; + st[1 + tmax] = '$'; + afftex(st, 100, 27 + k * 8, 100, 1, 1); + memk = k; + } + } else if (memk != 0) { + for (j = 1; j <= tmax; j ++) st[j] = chaines[memk][j]; + st[1 + tmax] = '$'; + afftex(st, 100, 27 + memk * 8, 100, 1, 0); + memk = 0; + } + } while (!((memk != 0) && g_vm->getMouseClick())); + if (memk == ok[i]) compte = compte + 1; + else { + if (i == 5) i = i + 1; + if ((i == 7) || (i == 8)) i = 10; + } + if (i == 10) q = /*testprot*/ true; + } while (!(i == 10)); + ques_result = (compte == 10) && q; + return ques_result; +} + +/*------------------------------------------------------------------------*/ + +/** + * Draw the F3/F8 dialog + */ +void f3f8::draw() { + Common::String f3 = g_vm->getString(S_F3); + Common::String f8 = g_vm->getString(S_F8); + + // Write the F3 and F8 text strings + g_vm->_screenSurface.putxy(3, 44); + g_vm->_screenSurface.writeg(f3, 5); + g_vm->_screenSurface._textPos.y = 51; + g_vm->_screenSurface.writeg(f8, 5); + + // Get the width of the written text strings + int f3Width = g_vm->_screenSurface.getStringWidth(f3); + int f8Width = g_vm->_screenSurface.getStringWidth(f8); + + // Write out the bounding box + g_vm->_screenSurface.drawBox(0, 42, MAX(f3Width, f8Width) + 6, 16, 7); +} + +void f3f8::divers(int np, bool b) { + teskbd(); + do { + parole(np, 0, 0); + atf3f8(key); + CHECK_QUIT; + + if (newgd != gd) { + gd = newgd; + hirs(); + aff50(b); + } + } while (!(key == 66)); +} + +void f3f8::atf3f8(int &key) { + do { + key = testou(); + CHECK_QUIT; + } while (!((key == 61) || (key == 66))); +} + +void f3f8::aff50(bool c) { + caff = 50; + maff = 0; + taffich(); + dessine(ades, 63, 12); + if (c) + ani50(); + else + repon(2, c_paroles + 142); + + // Draw the f3/f8 dialog + draw(); +} + +void f3f8::ani50() { + crep = animof(1, 1); + pictout(adani, crep, 63, 12); + crep = animof(2, 1); + pictout(adani, crep, 63, 12); + f2_all = (res == 1); + repon(2, c_paroles + 143); +} + + +} // End of namespace Mortevielle diff --git a/engines/mortevielle/dialogs.h b/engines/mortevielle/dialogs.h new file mode 100644 index 0000000000..260f355e8f --- /dev/null +++ b/engines/mortevielle/dialogs.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on original Mortville Manor DOS source code + * Copyright (c) 1988-1989 Lankhor + */ + +#ifndef MORTEVIELLE_ALERT_H +#define MORTEVIELLE_ALERT_H + +#include "common/str.h" + +namespace Mortevielle { + +class Alert { +private: + static void decod(Common::String s, int &nbc, int &nbl, int &col, Common::String &c, Common::String &cs); + static void setPosition(int ji, int coldep, int esp); + static void fait_boite(int lidep, int nli, int tx); + static void fait_choix(Common::String c, int coldep, int nbcase, Common::String *str, int esp); +public: + static int show(const Common::String &s, int n); +}; + +class Ques { +public: + static bool show(); +}; + +class f3f8 { +public: + static void draw(); + static void divers(int np, bool b); + static void atf3f8(int &key); + static void aff50(bool c); + static void ani50(); +}; + +} // End of namespace Mortevielle +#endif diff --git a/engines/mortevielle/module.mk b/engines/mortevielle/module.mk index 67ca57dbb4..16f56bc5b0 100644 --- a/engines/mortevielle/module.mk +++ b/engines/mortevielle/module.mk @@ -2,9 +2,9 @@ MODULE := engines/mortevielle MODULE_OBJS := \ actions.o \ - alert.o \ asm.o \ detection.o \ + dialogs.o \ graphics.o \ keyboard.o \ level15.o \ @@ -18,7 +18,6 @@ MODULE_OBJS := \ parole.o \ parole2.o \ prog.o \ - ques.o \ saveload.o \ sound.o \ taffich.o \ diff --git a/engines/mortevielle/mor.cpp b/engines/mortevielle/mor.cpp index 013f69437d..eb900d1515 100644 --- a/engines/mortevielle/mor.cpp +++ b/engines/mortevielle/mor.cpp @@ -29,7 +29,7 @@ #include "common/str.h" #include "common/system.h" #include "common/textconsole.h" -#include "mortevielle/alert.h" +#include "mortevielle/dialogs.h" #include "mortevielle/graphics.h" #include "mortevielle/level15.h" #include "mortevielle/menu.h" @@ -47,7 +47,7 @@ const int ioresult = 0; void testfi() { if (ioresult != 0) { - caff = do_alert(err_mess, 1); + caff = Alert::show(err_mess, 1); g_vm->quitGame(); } } @@ -403,24 +403,6 @@ void repon(int f, int m) { } } -void f3f8() { - Common::String f3 = g_vm->getString(S_F3); - Common::String f8 = g_vm->getString(S_F8); - - // Write the F3 and F8 text strings - g_vm->_screenSurface.putxy(3, 44); - g_vm->_screenSurface.writeg(f3, 5); - g_vm->_screenSurface._textPos.y = 51; - g_vm->_screenSurface.writeg(f8, 5); - - // Get the width of the written text strings - int f3Width = g_vm->_screenSurface.getStringWidth(f3); - int f8Width = g_vm->_screenSurface.getStringWidth(f8); - - // Write out the bounding box - g_vm->_screenSurface.drawBox(0, 42, MAX(f3Width, f8Width) + 6, 16, 7); -} - void t5(int cx) { /* debug('t5'); */ if (cx == 10) blo = false; diff --git a/engines/mortevielle/mor.h b/engines/mortevielle/mor.h index cabc3c4e92..22879246f6 100644 --- a/engines/mortevielle/mor.h +++ b/engines/mortevielle/mor.h @@ -62,7 +62,6 @@ extern void okpas(); extern void modobj(int m); extern void modobj2(int m, bool t1, bool t2); extern void repon(int f, int m); -extern void f3f8(); extern void t5(int cx); extern void affper(int per); extern void choix(int min, int max, int &per); diff --git a/engines/mortevielle/mor2.cpp b/engines/mortevielle/mor2.cpp index 9a1d2712db..c388c4a937 100644 --- a/engines/mortevielle/mor2.cpp +++ b/engines/mortevielle/mor2.cpp @@ -26,7 +26,7 @@ */ #include "mortevielle/mor2.h" -#include "mortevielle/alert.h" +#include "mortevielle/dialogs.h" #include "mortevielle/keyboard.h" #include "mortevielle/menu.h" #include "mortevielle/mor.h" @@ -280,13 +280,6 @@ void mfouen() g_vm->_menu.menut(soulever, g_vm->getString(S_RAISE)); } -void atf3f8(int &key) { - do { - key = testou(); - CHECK_QUIT; - } while (!((key == 61) || (key == 66))); -} - /* NIVEAU 6 */ void tperd() { @@ -394,12 +387,12 @@ void sparl(float adr, float rep) { hide_mouse(); deline(repint + c_paroles, st, tay); afftex(st, 230, 4, 65, 24, 5); - f3f8(); + f3f8::draw(); key = 0; do { parole(repint, haut[caff - 69], 0); - atf3f8(key); + f3f8::atf3f8(key); CHECK_QUIT; } while (!(key == 66)); hirs(); @@ -631,7 +624,7 @@ void tfleche() { tinke(); } while (!(qust || rect || anyone)); - if (qust && (touch == '\103')) dummy = do_alert(stpou, 1); + if (qust && (touch == '\103')) dummy = Alert::show(stpou, 1); } while (!((touch == '\73') || ((touch == '\104') && (x != 0) && (y != 0)) || (anyone) || (rect))); if (touch == '\73') iesc = true; @@ -767,7 +760,7 @@ void st13(int ob) { void aldepl() { int dummy; - dummy = do_alert(g_vm->getString(S_USE_DEP_MENU), 1); + dummy = Alert::show(g_vm->getString(S_USE_DEP_MENU), 1); } } // End of namespace Mortevielle diff --git a/engines/mortevielle/mor2.h b/engines/mortevielle/mor2.h index 6668d54113..1d66548ffa 100644 --- a/engines/mortevielle/mor2.h +++ b/engines/mortevielle/mor2.h @@ -41,7 +41,6 @@ extern void tlu(int af, int ob); extern void delin(int n); extern void affrep(); extern void mfouen(); -extern void atf3f8(int &key); /* NIVEAU 6 */ extern void tperd(); extern void tsort(); diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index 6a7f84c18c..b35e98611c 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -30,7 +30,7 @@ #include "graphics/pixelformat.h" #include "mortevielle/mortevielle.h" #include "mortevielle/actions.h" -#include "mortevielle/alert.h" +#include "mortevielle/dialogs.h" #include "mortevielle/asm.h" #include "mortevielle/keyboard.h" #include "mortevielle/level15.h" @@ -467,13 +467,13 @@ Common::Error MortevielleEngine::run() { * Show the game introduction */ void MortevielleEngine::showIntroduction() { - aff50(false); + f3f8::aff50(false); mlec = 0; - divers(142, false); + f3f8::divers(142, false); CHECK_QUIT; - ani50(); - divers(143, true); + f3f8::ani50(); + f3f8::divers(143, true); CHECK_QUIT; // TODO: Once music is implemented, only use the below delay if music is turned off @@ -482,21 +482,6 @@ void MortevielleEngine::showIntroduction() { music(); } -void MortevielleEngine::divers(int np, bool b) { - teskbd(); - do { - parole(np, 0, 0); - atf3f8(key); - CHECK_QUIT; - - if (newgd != gd) { - gd = newgd; - hirs(); - aff50(b); - } - } while (!(key == 66)); -} - /** * Main game loop. Handles potentially playing the game multiple times, such as if the player * loses, and chooses to start playing the game again. @@ -583,7 +568,7 @@ void MortevielleEngine::handleAction() { if (choisi && (msg[3] == charge)) g_vm->_savegameManager.loadGame((msg[4] & 7) - 1); if (inkey == '\103') { /* F9 */ - temps = do_alert(stpou, 1); + temps = Alert::show(stpou, 1); return; } else if (inkey == '\77') { if ((mnumo != no_choice) && ((msg[3] == action) || (msg[3] == saction))) { diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index 371dd40b38..b0f1c4cffe 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -93,7 +93,6 @@ private: void mainGame(); void playGame(); void handleAction(); - void divers(int np, bool b); public: ScreenSurface _screenSurface; PaletteManager _paletteManager; diff --git a/engines/mortevielle/ovd1.cpp b/engines/mortevielle/ovd1.cpp index 53237f7100..33f879d61b 100644 --- a/engines/mortevielle/ovd1.cpp +++ b/engines/mortevielle/ovd1.cpp @@ -26,7 +26,7 @@ */ #include "common/file.h" -#include "mortevielle/alert.h" +#include "mortevielle/dialogs.h" #include "mortevielle/keyboard.h" #include "mortevielle/level15.h" #include "mortevielle/menu.h" @@ -52,25 +52,6 @@ void dem2() { // Deprecated under ScummVM } -void ani50() { - crep = animof(1, 1); - pictout(adani, crep, 63, 12); - crep = animof(2, 1); - pictout(adani, crep, 63, 12); - f2_all = (res == 1); - repon(2, c_paroles + 143); -} - -void aff50(bool c) { - caff = 50; - maff = 0; - taffich(); - dessine(ades, 63, 12); - if (c) ani50(); - else repon(2, c_paroles + 142); - f3f8(); -} - void charpal() { Common::File f; // tabdb records Common::File ft; // tfxx diff --git a/engines/mortevielle/ovd1.h b/engines/mortevielle/ovd1.h index 6bb553a041..13a8f5db2e 100644 --- a/engines/mortevielle/ovd1.h +++ b/engines/mortevielle/ovd1.h @@ -31,9 +31,7 @@ namespace Mortevielle { extern void dem2(); -extern void ani50(); //extern void apzuul(); -extern void aff50(bool c); extern void charpal(); extern void chartex(); extern void dialpre(); diff --git a/engines/mortevielle/prog.cpp b/engines/mortevielle/prog.cpp index 7f61b79185..8d905af326 100644 --- a/engines/mortevielle/prog.cpp +++ b/engines/mortevielle/prog.cpp @@ -26,7 +26,7 @@ */ #include "mortevielle/actions.h" -#include "mortevielle/alert.h" +#include "mortevielle/dialogs.h" #include "mortevielle/menu.h" #include "mortevielle/mor.h" #include "mortevielle/mor2.h" diff --git a/engines/mortevielle/ques.cpp b/engines/mortevielle/ques.cpp deleted file mode 100644 index e8c568d398..0000000000 --- a/engines/mortevielle/ques.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Mortville Manor DOS source code - * Copyright (c) 1988-1989 Lankhor - */ - -#include "common/str.h" -#include "mortevielle/level15.h" -#include "mortevielle/mortevielle.h" -#include "mortevielle/mouse.h" -#include "mortevielle/outtext.h" -#include "mortevielle/ques.h" - -namespace Mortevielle { - -bool ques() { - const int ta[11] = {0, 511, 516, 524, 531, 545, 552, 559, 563, 570, 576}; - const int ok[11] = {0, 4, 7, 1, 6, 4, 4, 2, 5, 3, 1 }; - - bool q, func, test; - int i, j, k, y, memk; - int tay , tmax; - int rep, prem, der; - char st[1410]; - char key; - rectangle coor[max_rect]; - Common::String chaines[15]; - int compte; - - - bool ques_result; - test = false; - i = 0; - compte = 0; - - do { - hide_mouse(); - hirs(); - show_mouse(); - i = i + 1; - deline(ta[i], st, tay); - if (res == 1) y = 29; - else y = 23; - g_vm->_screenSurface.fillRect(15, Common::Rect(0, 14, 630, y)); - afftex(st, 20, 15, 100, 2, 0); - if (i != 10) { - prem = ta[i] + 1; - der = ta[i + 1] - 1; - } else { - prem = 503; - der = 510; - } - y = 35; - tmax = 0; - memk = 1; - for (j = prem; j <= der; j ++) { - deline(j, st, tay); - if (tay > tmax) tmax = tay; - afftex(st, 100, y, 100, 1, 0); - chaines[memk] = delig; - memk = memk + 1; - y = y + 8; - } - for (j = 1; j <= succ(int, der - prem); j ++) { - { - rectangle &with = coor[j]; - - with.x1 = 45 * res; - with.x2 = (tmax * 3 + 55) * res; - with.y1 = 27 + j * 8; - with.y2 = 34 + j * 8; - with.etat = true; - } - while ((int)chaines[j].size() < tmax) { - chaines[j] = chaines[j] + ' '; - } - } - coor[j + 1].etat = false; - if (res == 1) rep = 10; - else rep = 6; - g_vm->_screenSurface.drawBox(80, 33, 40 + tmax * rep, (der - prem) * 8 + 16, 15); - rep = 0; - j = 0; - memk = 0; - do { - g_vm->setMouseClick(false); - tesok = false; - mov_mouse(func, key); - CHECK_QUIT0; - - k = 1; - while (coor[k].etat && ! dans_rect(coor[k])) k = k + 1; - if (coor[k].etat) { - if ((memk != 0) && (memk != k)) { - for (j = 1; j <= tmax; j ++) st[j] = chaines[memk][j]; - st[1 + tmax] = '$'; - afftex(st, 100, 27 + memk * 8, 100, 1, 0); - } - if (memk != k) { - for (j = 1; j <= tmax; j ++) st[j] = chaines[k][j]; - st[1 + tmax] = '$'; - afftex(st, 100, 27 + k * 8, 100, 1, 1); - memk = k; - } - } else if (memk != 0) { - for (j = 1; j <= tmax; j ++) st[j] = chaines[memk][j]; - st[1 + tmax] = '$'; - afftex(st, 100, 27 + memk * 8, 100, 1, 0); - memk = 0; - } - } while (!((memk != 0) && g_vm->getMouseClick())); - if (memk == ok[i]) compte = compte + 1; - else { - if (i == 5) i = i + 1; - if ((i == 7) || (i == 8)) i = 10; - } - if (i == 10) q = /*testprot*/ true; - } while (!(i == 10)); - ques_result = (compte == 10) && q; - return ques_result; -} - -} // End of namespace Mortevielle diff --git a/engines/mortevielle/ques.h b/engines/mortevielle/ques.h deleted file mode 100644 index 7260bfa6a2..0000000000 --- a/engines/mortevielle/ques.h +++ /dev/null @@ -1,38 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This code is based on original Mortville Manor DOS source code - * Copyright (c) 1988-1989 Lankhor - */ - -#ifndef MORTEVIELLE_QUES_H -#define MORTEVIELLE_QUES_H - -#include "common/str.h" - -namespace Mortevielle { - -extern bool ques(); - -} // End of namespace Mortevielle -#endif diff --git a/engines/mortevielle/saveload.cpp b/engines/mortevielle/saveload.cpp index 4f37c2839b..0b3946af0b 100644 --- a/engines/mortevielle/saveload.cpp +++ b/engines/mortevielle/saveload.cpp @@ -27,7 +27,7 @@ #include "common/file.h" #include "common/system.h" -#include "mortevielle/alert.h" +#include "mortevielle/dialogs.h" #include "mortevielle/mor.h" #include "mortevielle/mor2.h" #include "mortevielle/mortevielle.h" -- cgit v1.2.3