diff options
author | Paul Gilbert | 2012-02-13 09:07:48 +1100 |
---|---|---|
committer | Strangerke | 2012-04-06 08:21:22 +0200 |
commit | a764471c4cc32bf034d9491af26a6d01743efb84 (patch) | |
tree | bb687dc2ec9472ae43cd3c13551dae3a7d97bcfe /engines | |
parent | c3a63e04ee9a3cc5f70906638b41bf2fae7d13bc (diff) | |
download | scummvm-rg350-a764471c4cc32bf034d9491af26a6d01743efb84.tar.gz scummvm-rg350-a764471c4cc32bf034d9491af26a6d01743efb84.tar.bz2 scummvm-rg350-a764471c4cc32bf034d9491af26a6d01743efb84.zip |
MORTEVIELLE: Converted menu functions into it's own class
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mortevielle/actions.cpp | 12 | ||||
-rw-r--r-- | engines/mortevielle/menu.cpp | 166 | ||||
-rw-r--r-- | engines/mortevielle/menu.h | 16 | ||||
-rw-r--r-- | engines/mortevielle/mor.cpp | 28 | ||||
-rw-r--r-- | engines/mortevielle/mor2.cpp | 22 | ||||
-rw-r--r-- | engines/mortevielle/mortevielle.cpp | 2 | ||||
-rw-r--r-- | engines/mortevielle/ovd1.cpp | 54 | ||||
-rw-r--r-- | engines/mortevielle/ovd1.h | 1 | ||||
-rw-r--r-- | engines/mortevielle/var_mor.cpp | 11 | ||||
-rw-r--r-- | engines/mortevielle/var_mor.h | 19 |
10 files changed, 160 insertions, 171 deletions
diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp index b84857162c..dfd0811086 100644 --- a/engines/mortevielle/actions.cpp +++ b/engines/mortevielle/actions.cpp @@ -47,13 +47,13 @@ void taller() { //int mx, cx, cy; int cx; - if ((s.mlieu == 26) && (msg[4] == depl[6])) { + if ((s.mlieu == 26) && (msg[4] == g_vm->_menu._depl[6])) { s.mlieu = 15; caff = s.mlieu; afdes(0); repon(2, s.mlieu); } - if ((s.mlieu == 15) && (msg[4] == depl[6])) { + if ((s.mlieu == 15) && (msg[4] == g_vm->_menu._depl[6])) { if (!syn) ecr3(g_vm->getString(S_GO_TO)); tfleche(); @@ -78,7 +78,7 @@ void taller() { cx = 0; do { cx = cx + 1; - } while (!(depl[cx] == msg[4])); + } while (!(g_vm->_menu._depl[cx] == msg[4])); if (s.mlieu == 19) { if (cx == 1) t1deva(); if (cx == 2) t1neig(); @@ -236,7 +236,7 @@ void tsprendre() { cx = 0; do { cx = cx + 1; - } while (!(invt[cx] == msg[4])); + } while (!(g_vm->_menu._invt[cx] == msg[4])); cz = 0; cy = 0; do { @@ -870,7 +870,7 @@ void tentrer() { s.conf = s.conf + 1; s.mlieu = 15; msg[3] = discut; - msg[4] = disc[x]; + msg[4] = g_vm->_menu._disc[x]; syn = true; if (ment == 9) { col = true; @@ -1027,7 +1027,7 @@ void tparler() cx = 0; do { cx = cx + 1; - } while (!(disc[cx] == msg[4])); + } while (!(g_vm->_menu._disc[cx] == msg[4])); caff = 69 + cx; afdes(0); repon(2, caff); diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp index d6475c99d0..2fc558a7fb 100644 --- a/engines/mortevielle/menu.cpp +++ b/engines/mortevielle/menu.cpp @@ -2,14 +2,14 @@ * * 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. + * file _distributed with this source _distribution. * - * This program is free software; you can redistribute it and/or + * This program is free software; you can re_distribute 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, + * 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. @@ -32,6 +32,8 @@ #include "mortevielle/menu.h" #include "mortevielle/mortevielle.h" #include "mortevielle/mouse.h" +#include "mortevielle/outtext.h" +#include "mortevielle/ovd1.h" #include "mortevielle/var_mor.h" namespace Mortevielle { @@ -57,27 +59,27 @@ void Menu::menut(int no, Common::String nom) { switch (h) { case invent : if (l != 7) { - inv[l] = s; - inv[l].insertChar(' ', 0); + _inv[l] = s; + _inv[l].insertChar(' ', 0); } break; - case depla : - dep[l] = s; + case depla: + _dep[l] = s; break; - case action : - act[l] = s; + case action: + _act[l] = s; break; - case saction : - self_[l] = s; + case saction: + _self[l] = s; break; - case discut : - dis[l] = s; + case discut: + _dis[l] = s; break; } } /** - * Disable a menu item + * _disable a menu item * @param no Hi byte represents menu number, lo byte reprsents item index */ void Menu::disableMenuItem(int no) { @@ -88,23 +90,23 @@ void Menu::disableMenuItem(int no) { switch (h) { case invent : { if (l > 6) { - inv[l].setChar('<', 0); - inv[l].setChar('>', 21); + _inv[l].setChar('<', 0); + _inv[l].setChar('>', 21); } else - inv[l].setChar('*', 0); + _inv[l].setChar('*', 0); } break; - case depla : - dep[l].setChar('*', 0); + case depla: + _dep[l].setChar('*', 0); break; - case action : - act[l].setChar('*', 0); + case action: + _act[l].setChar('*', 0); break; - case saction : - self_[l].setChar('*', 0); + case saction: + _self[l].setChar('*', 0); break; - case discut : - dis[l].setChar('*', 0); + case discut: + _dis[l].setChar('*', 0); break; } } @@ -120,23 +122,23 @@ void Menu::enableMenuItem(int no) { l = lo(no); switch (h) { case invent : { - inv[l].setChar(' ', 0); - inv[l].setChar(' ', 21); + _inv[l].setChar(' ', 0); + _inv[l].setChar(' ', 21); } break; - case depla : - dep[l].setChar(' ', 0); + case depla: + _dep[l].setChar(' ', 0); break; - case action : - act[l].setChar(' ', 0); + case action: + _act[l].setChar(' ', 0); break; - case saction : { - self_[l].setChar(' ', 0); - self_[l].setChar(' ', 0); + case saction: { + _self[l].setChar(' ', 0); + _self[l].setChar(' ', 0); } break; - case discut : - dis[l].setChar(' ', 0); + case discut: + _dis[l].setChar(' ', 0); break; } } @@ -186,7 +188,7 @@ void Menu::menu_aff() { */ void Menu::drawMenu() { menu_aff(); - active_menu = true; + _menuActive = true; msg4 = no_choice; msg3 = no_choice; choisi = false; @@ -201,19 +203,19 @@ void Menu::invers(int ix) { g_vm->_screenSurface.putxy(don[msg3][1] << 3, succ(void, lo(msg4)) << 3); switch (msg3) { case 1 : - s = inv[lo(msg4)]; + s = _inv[lo(msg4)]; break; case 2 : - s = dep[lo(msg4)]; + s = _dep[lo(msg4)]; break; case 3 : - s = act[lo(msg4)]; + s = _act[lo(msg4)]; break; case 4 : - s = self_[lo(msg4)]; + s = _self[lo(msg4)]; break; case 5 : - s = dis[lo(msg4)]; + s = _dis[lo(msg4)]; break; case 6 : s = g_vm->getString(S_SAVE_LOAD + lo(msg4)); @@ -292,24 +294,24 @@ void Menu::menuDown(int ii) { cx = succ(int, cx); switch (ii) { case 1 : - if (inv[cx][0] != '*') - g_vm->_screenSurface.writeg(inv[cx], 4); + if (_inv[cx][0] != '*') + g_vm->_screenSurface.writeg(_inv[cx], 4); break; case 2 : - if (dep[cx][0] != '*') - g_vm->_screenSurface.writeg(dep[cx], 4); + if (_dep[cx][0] != '*') + g_vm->_screenSurface.writeg(_dep[cx], 4); break; case 3 : - if (act[cx][0] != '*') - g_vm->_screenSurface.writeg(act[cx], 4); + if (_act[cx][0] != '*') + g_vm->_screenSurface.writeg(_act[cx], 4); break; case 4 : - if (self_[cx][0] != '*') - g_vm->_screenSurface.writeg(self_[cx], 4); + if (_self[cx][0] != '*') + g_vm->_screenSurface.writeg(_self[cx], 4); break; case 5 : - if (dis[cx][0] != '*') - g_vm->_screenSurface.writeg(dis[cx], 4); + if (_dis[cx][0] != '*') + g_vm->_screenSurface.writeg(_dis[cx], 4); break; case 6 : g_vm->_screenSurface.writeg(g_vm->getString(S_SAVE_LOAD + cx), 4); @@ -366,7 +368,7 @@ void Menu::menuUp(int xx) { */ void Menu::eraseMenu() { /* debug('eraseMenu'); */ - active_menu = false; + _menuActive = false; g_vm->setMouseClick(false); menuUp(msg3); } @@ -380,7 +382,8 @@ void Menu::mdn() { bool tes; /* debug('mdn'); */ - if (! active_menu) return; + if (!_menuActive) + return; x = x_s; y = y_s; if (!g_vm->getMouseClick()) { @@ -415,7 +418,7 @@ void Menu::mdn() { } } else { /* There was a click */ if ((msg3 == fichier) && (msg4 != no_choice)) { - // Another menu to be displayed + // Another menu to be _displayed g_vm->setMouseClick(false); menuUp(msg3); if (lo(msg4) == 1) msg3 = 7; @@ -437,4 +440,57 @@ void Menu::mdn() { } } +void Menu::initMenu() { + int i, tai; + char st[1410]; + Common::File f; + + if (!f.open("menufr.mor")) + error("Missing file - menufr.mor"); + + f.read(lettres, 7 * 24); + f.close(); + + // Ask to swap floppy + dem2(); + + for (i = 1; i <= 8; i ++) + _inv[i] = "* "; + _inv[7] = "< -*-*-*-*-*-*-*-*-*- "; + for (i = 1; i <= 7; i ++) + _dep[i] = "* "; + i = 1; + do { + deline(i + c_action, st, tai); + _act[i] = delig; + while (_act[i].size() < 10) + _act[i] += ' '; + + if (i < 9) { + if (i < 6) { + deline(i + c_saction, st, tai); + _self[i] = delig; + while (_self[i].size() < 10) + _self[i] += ' '; + } + deline(i + c_dis, st, tai); + _dis[i] = delig + ' '; + } + i = succ(int, i); + } while (!(i == 22)); + for (i = 1; i <= 8; i ++) { + _disc[i] = 0x500 + i; + if (i < 8) + _depl[i] = 0x200 + i; + _invt[i] = 0x100 + i; + if (i > 6) + g_vm->_menu.disableMenuItem(_invt[i]); + } + msg3 = no_choice; + msg4 = no_choice; + msg[3] = no_choice; + msg[4] = no_choice; + g_vm->setMouseClick(false); +} + } // End of namespace Mortevielle diff --git a/engines/mortevielle/menu.h b/engines/mortevielle/menu.h index 6ab020dbd9..8779d51298 100644 --- a/engines/mortevielle/menu.h +++ b/engines/mortevielle/menu.h @@ -38,6 +38,16 @@ private: void invers(int ix); void menuDown(int ii); public: + bool _menuActive; + Common::String _inv[9]; + Common::String _dep[8]; + Common::String _act[22]; + Common::String _self[7]; + Common::String _dis[9]; + int _disc[9]; + int _invt[9]; + int _depl[8]; +public: void menut(int no, Common::String nom); void disableMenuItem(int no); void enableMenuItem(int no); @@ -46,6 +56,12 @@ public: void menuUp(int xx); void eraseMenu(); void mdn(); + void initMenu(); +}; + +enum { + invent = 1, depla = 2, action = 3, saction = 4, + discut = 5, fichier = 6, sauve = 7, charge = 8 }; } // End of namespace Mortevielle diff --git a/engines/mortevielle/mor.cpp b/engines/mortevielle/mor.cpp index d4461be3cd..013f69437d 100644 --- a/engines/mortevielle/mor.cpp +++ b/engines/mortevielle/mor.cpp @@ -324,8 +324,8 @@ void modobj(int m) { deline(m - 501 + c_st41, str_, tay); strp = delig; } - g_vm->_menu.menut(invt[8], strp); - g_vm->_menu.disableMenuItem(invt[8]); + g_vm->_menu.menut(g_vm->_menu._invt[8], strp); + g_vm->_menu.disableMenuItem(g_vm->_menu._invt[8]); } void modobj2(int m, bool t1, bool t2) { @@ -341,8 +341,8 @@ void modobj2(int m, bool t1, bool t2) { deline(m - 501 + c_st41, str_, tay); strp = delig; } - g_vm->_menu.menut(invt[8], strp); - g_vm->_menu.disableMenuItem(invt[8]); + g_vm->_menu.menut(g_vm->_menu._invt[8], strp); + g_vm->_menu.disableMenuItem(g_vm->_menu._invt[8]); } @@ -446,47 +446,47 @@ void affper(int per) { /* debug('affper'); */ for (cx = 1; cx <= 8; cx ++) - g_vm->_menu.disableMenuItem(disc[cx]); + g_vm->_menu.disableMenuItem(g_vm->_menu._disc[cx]); clsf10(); if ((per & 128) == 128) { g_vm->_screenSurface.putxy(560, 24); g_vm->_screenSurface.writeg("LEO", 4); - g_vm->_menu.enableMenuItem(disc[1]); + g_vm->_menu.enableMenuItem(g_vm->_menu._disc[1]); } if ((per & 64) == 64) { g_vm->_screenSurface.putxy(560, 32); g_vm->_screenSurface.writeg("PAT", 4); - g_vm->_menu.enableMenuItem(disc[2]); + g_vm->_menu.enableMenuItem(g_vm->_menu._disc[2]); } if ((per & 32) == 32) { g_vm->_screenSurface.putxy(560, 40); g_vm->_screenSurface.writeg("GUY", 4); - g_vm->_menu.enableMenuItem(disc[3]); + g_vm->_menu.enableMenuItem(g_vm->_menu._disc[3]); } if ((per & 16) == 16) { g_vm->_screenSurface.putxy(560, 48); g_vm->_screenSurface.writeg("EVA", 4); - g_vm->_menu.enableMenuItem(disc[4]); + g_vm->_menu.enableMenuItem(g_vm->_menu._disc[4]); } if ((per & 8) == 8) { g_vm->_screenSurface.putxy(560, 56); g_vm->_screenSurface.writeg("BOB", 4); - g_vm->_menu.enableMenuItem(disc[5]); + g_vm->_menu.enableMenuItem(g_vm->_menu._disc[5]); } if ((per & 4) == 4) { g_vm->_screenSurface.putxy(560, 64); g_vm->_screenSurface.writeg("LUC", 4); - g_vm->_menu.enableMenuItem(disc[6]); + g_vm->_menu.enableMenuItem(g_vm->_menu._disc[6]); } if ((per & 2) == 2) { g_vm->_screenSurface.putxy(560, 72); g_vm->_screenSurface.writeg("IDA", 4); - g_vm->_menu.enableMenuItem(disc[7]); + g_vm->_menu.enableMenuItem(g_vm->_menu._disc[7]); } if ((per & 1) == 1) { g_vm->_screenSurface.putxy(560, 80); g_vm->_screenSurface.writeg("MAX", 4); - g_vm->_menu.enableMenuItem(disc[8]); + g_vm->_menu.enableMenuItem(g_vm->_menu._disc[8]); } ipers = per; } @@ -579,7 +579,7 @@ void cpl6(int &p) { void person() { /* debug('person'); */ for (int cf = 1; cf <= 8; cf ++) - g_vm->_menu.disableMenuItem(disc[cf]); + g_vm->_menu.disableMenuItem(g_vm->_menu._disc[cf]); clsf10(); g_vm->_screenSurface.putxy(560, 30); diff --git a/engines/mortevielle/mor2.cpp b/engines/mortevielle/mor2.cpp index 557ca0679b..9a1d2712db 100644 --- a/engines/mortevielle/mor2.cpp +++ b/engines/mortevielle/mor2.cpp @@ -103,7 +103,7 @@ void tinke() { if (cf > 65) t = t - ((t / 3) * 2); nh = readclock(); if ((nh - mh) > t) { - am = active_menu; + am = g_vm->_menu._menuActive; g_vm->_menu.eraseMenu(); jh = jh + ((nh - mh) / t); mh = nh; @@ -234,12 +234,12 @@ void tmlieu(int mli) { deline(cx + c_tmlieu, st, tail); nomp = delig; while (nomp.size() < 20) nomp = nomp + ' '; - g_vm->_menu.menut(depl[i], nomp); + g_vm->_menu.menut(g_vm->_menu._depl[i], nomp); i = i + 1; } nomp = "* "; for (cx = 7; cx >= i; cx --) - g_vm->_menu.menut(depl[cx], nomp); + g_vm->_menu.menut(g_vm->_menu._depl[cx], nomp); } @@ -375,13 +375,13 @@ void modinv() { r = (ord(s.sjer[cx]) + 400); deline(r - 501 + c_st41, nom, tay); nomp = delig; - g_vm->_menu.menut(invt[cy], nomp); - g_vm->_menu.enableMenuItem(invt[cx]); + g_vm->_menu.menut(g_vm->_menu._invt[cy], nomp); + g_vm->_menu.enableMenuItem(g_vm->_menu._invt[cx]); } if (cy < 6) for (cx = cy + 1; cx <= 6; cx ++) { - g_vm->_menu.menut(invt[cx], " "); - g_vm->_menu.disableMenuItem(invt[cx]); + g_vm->_menu.menut(g_vm->_menu._invt[cx], " "); + g_vm->_menu.disableMenuItem(g_vm->_menu._invt[cx]); } } @@ -418,7 +418,7 @@ void mfoudi() { int cx; for (cx = 1; cx <= 7; cx ++) - g_vm->_menu.disableMenuItem(depl[cx]); + g_vm->_menu.disableMenuItem(g_vm->_menu._depl[cx]); for (cx = 1; cx <= 11; cx ++) g_vm->_menu.disableMenuItem(men[cx]); @@ -541,9 +541,7 @@ void tctrm() { } -void quelquun() - -{ +void quelquun() { int haz, cx; if (imen) @@ -566,7 +564,7 @@ L1: caff = 69 + cx; crep = caff; msg[3] = discut; - msg[4] = disc[cx]; + msg[4] = g_vm->_menu._disc[cx]; syn = true; col = true; } else { diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index 29a9d5bb46..6a7f84c18c 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -506,7 +506,7 @@ void MortevielleEngine::mainGame() { for (crep = 1; crep <= c_zzz; crep ++) zzuul(&adcfiec[161 * 16], ((822 * 128) - (161 * 16)) / 64); charge_bruit5(); - init_menu(); + _menu.initMenu(); theure(); dprog(); diff --git a/engines/mortevielle/ovd1.cpp b/engines/mortevielle/ovd1.cpp index 5bdb54f262..53237f7100 100644 --- a/engines/mortevielle/ovd1.cpp +++ b/engines/mortevielle/ovd1.cpp @@ -71,60 +71,6 @@ void aff50(bool c) { f3f8(); } -void init_menu() { - int i, tai; - char st[1410]; - Common::File f; - - if (!f.open("menufr.mor")) - error("Missing file - menufr.mor"); - - f.read(lettres, 7 * 24); - f.close(); - - // Ask to swap floppy - dem2(); - - - for (i = 1; i <= 8; i ++) - inv[i] = "* "; - inv[7] = "< -*-*-*-*-*-*-*-*-*- "; - for (i = 1; i <= 7; i ++) - dep[i] = "* "; - i = 1; - do { - deline(i + c_action, st, tai); - act[i] = delig; - while (act[i].size() < 10) - act[i] += ' '; - - if (i < 9) { - if (i < 6) { - deline(i + c_saction, st, tai); - self_[i] = delig; - while (self_[i].size() < 10) - self_[i] += ' '; - } - deline(i + c_dis, st, tai); - dis[i] = delig + ' '; - } - i = succ(int, i); - } while (!(i == 22)); - for (i = 1; i <= 8; i ++) { - disc[i] = 0x500 + i; - if (i < 8) depl[i] = 0x200 + i; - invt[i] = 0x100 + i; - if (i > 6) - g_vm->_menu.disableMenuItem(invt[i]); - } - msg3 = no_choice; - msg4 = no_choice; - msg[3] = no_choice; - msg[4] = no_choice; - g_vm->setMouseClick(false); -} - - void charpal() { Common::File f; // tabdb records Common::File ft; // tfxx diff --git a/engines/mortevielle/ovd1.h b/engines/mortevielle/ovd1.h index 96239ed3d5..6bb553a041 100644 --- a/engines/mortevielle/ovd1.h +++ b/engines/mortevielle/ovd1.h @@ -34,7 +34,6 @@ extern void dem2(); extern void ani50(); //extern void apzuul(); extern void aff50(bool c); -extern void init_menu(); extern void charpal(); extern void chartex(); extern void dialpre(); diff --git a/engines/mortevielle/var_mor.cpp b/engines/mortevielle/var_mor.cpp index 62b14575de..27eb5bb0b6 100644 --- a/engines/mortevielle/var_mor.cpp +++ b/engines/mortevielle/var_mor.cpp @@ -111,8 +111,7 @@ bool blo, anyone, brt, rect, - rech_cfiec, - active_menu; + rech_cfiec; int x, @@ -183,17 +182,9 @@ Common::String al_mess, ind_mess, al_mess2; -int invt[9]; int nbrep[9]; int nbrepm[9]; -int disc[9]; int msg[5]; -int depl[8]; -Common::String inv[9]; -Common::String dep[8]; -Common::String act[22]; -Common::String self_[7]; -Common::String dis[9]; char touv[8]; sav_chaine s, s1; byte bufcha[391]; diff --git a/engines/mortevielle/var_mor.h b/engines/mortevielle/var_mor.h index 3e496df9ff..b810033f0a 100644 --- a/engines/mortevielle/var_mor.h +++ b/engines/mortevielle/var_mor.h @@ -129,14 +129,6 @@ const int amzon = 1650; const int fleche = 1758; const int no_choice = 0; -const int invent = 1; -const int depla = 2; -const int action = 3; -const int saction = 4; -const int discut = 5; -const int fichier = 6; -const int sauve = 7; -const int charge = 8; const int attacher = 0x301; const int attendre = 0x302; @@ -284,8 +276,7 @@ extern bool blo, anyone, brt, rect, - rech_cfiec, - active_menu; + rech_cfiec; extern int x, @@ -356,17 +347,9 @@ extern Common::String al_mess, ind_mess, al_mess2; -extern int invt[9]; extern int nbrep[9]; extern int nbrepm[9]; -extern int disc[9]; extern int msg[5]; -extern int depl[8]; -extern Common::String inv[9]; -extern Common::String dep[8]; -extern Common::String act[22]; -extern Common::String self_[7]; -extern Common::String dis[9]; extern char touv[8]; extern sav_chaine s, s1; extern byte bufcha[391]; |