diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp index 5b2f43786a2..b84857162c0 100644 --- a/engines/mortevielle/actions.cpp +++ b/engines/mortevielle/actions.cpp @@ -543,9 +543,12 @@ void tmettre() { show_mouse(); tinke(); pendule(); - if (ipers != 0) affper(ipers); - else person(); - menu_aff(); + if (ipers != 0) + affper(ipers); + else + person(); + + g_vm->_menu.menu_aff(); if (entre) { s.mlieu = 17; tmlieu(17); diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp index d8c1b6050b3..d6475c99d05 100644 --- a/engines/mortevielle/menu.cpp +++ b/engines/mortevielle/menu.cpp @@ -38,19 +38,22 @@ namespace Mortevielle { /* NIVEAU 14*/ -void menut(int no, Common::String nom) { +/** + * Setup a menu's contents + */ +void Menu::menut(int no, Common::String nom) { byte h, l; Common::String s; - - /* debug('menut'); */ h = hi(no); l = lo(no); s = nom; if (! tesok) { g_vm->quitGame(); } - while (s.size() < 20) s = s + ' '; + while (s.size() < 20) + s = s + ' '; + switch (h) { case invent : if (l != 7) { @@ -73,10 +76,13 @@ void menut(int no, Common::String nom) { } } -void menu_disable(int no) { +/** + * Disable a menu item + * @param no Hi byte represents menu number, lo byte reprsents item index + */ +void Menu::disableMenuItem(int no) { byte h, l; - /* debug('menu_disable'); */ h = hi(no); l = lo(no); switch (h) { @@ -84,7 +90,8 @@ void menu_disable(int no) { if (l > 6) { inv[l].setChar('<', 0); inv[l].setChar('>', 21); - } else inv[l].setChar('*', 0); + } else + inv[l].setChar('*', 0); } break; case depla : @@ -102,10 +109,13 @@ void menu_disable(int no) { } } -void menu_enable(int no) { +/** + * Enable a menu item + * @param no Hi byte represents menu number, lo byte reprsents item index + */ +void Menu::enableMenuItem(int no) { byte h, l; - /* debug('menu_disable'); */ h = hi(no); l = lo(no); switch (h) { @@ -131,19 +141,13 @@ void menu_enable(int no) { } } -void menu_aff() { +void Menu::menu_aff() { int ind_tabl, k, col; -// char c; - int pt, x, y, color, msk, - num_letr; - /* debug('menu_aff'); */ + int pt, x, y, color, msk, num_letr; + hide_mouse(); - /*if not tesok then - begin - clrscr; - halt; - end;*/ + g_vm->_screenSurface.fillRect(7, Common::Rect(0, 0, 639, 10)); col = 28 * res; if (gd == cga) color = 1; @@ -177,9 +181,10 @@ void menu_aff() { show_mouse(); } - -void draw_menu() { - /* debug('draw_menu'); */ +/** + * Show the menu + */ +void Menu::drawMenu() { menu_aff(); active_menu = true; msg4 = no_choice; @@ -189,10 +194,9 @@ void draw_menu() { test0 = false; } -void invers(int ix) { +void Menu::invers(int ix) { Common::String s; - /* debug('invers'); */ if (msg4 == no_choice) return; g_vm->_screenSurface.putxy(don[msg3][1] << 3, succ(void, lo(msg4)) << 3); switch (msg3) { @@ -235,7 +239,7 @@ void invers(int ix) { msg4 = no_choice; } -void util(int x, int y) { +void Menu::util(int x, int y) { int ymx, dxcar, xmn, xmx, ix; /* debug('util'); */ @@ -258,11 +262,14 @@ void util(int x, int y) { } } -void menu_down(int ii) { +/** + * Draw a menu + */ +void Menu::menuDown(int ii) { int cx, xcc; int xco, nb_lig; - /* debug('menu_down'); */ + /* debug('menuDown'); */ // Make a copy of the current screen surface for later restore g_vm->_backgroundSurface.copyFrom(g_vm->_screenSurface); @@ -331,8 +338,11 @@ void menu_down(int ii) { show_mouse(); } -void menu_up(int xx) { - /* debug('menu_up'); */ +/** + * Menu is being removed, so restore the previous background area. + */ +void Menu::menuUp(int xx) { + /* debug('menuUp'); */ if (test0) { charecr(10, succ(byte, don[xx][2]) << 1); @@ -351,14 +361,20 @@ void menu_up(int xx) { } } -void erase_menu() { - /* debug('erase_menu'); */ +/** + * Erase the menu + */ +void Menu::eraseMenu() { + /* debug('eraseMenu'); */ active_menu = false; g_vm->setMouseClick(false); - menu_up(msg3); + menuUp(msg3); } -void mdn() { +/** + * Handle updates to the menu + */ +void Menu::mdn() { //int x, y, c, a, ix; int x, y, ix; bool tes; @@ -389,28 +405,28 @@ void mdn() { else ix = fichier; if ((ix != msg3) || (! test0)) if (!((ix == fichier) && ((msg3 == sauve) || (msg3 == charge)))) { - menu_up(msg3); - menu_down(ix); + menuUp(msg3); + menuDown(ix); msg3 = ix; msg4 = no_choice; } } else { /* Not in the MenuTitle line */ if ((y > 11) && (test0)) util(x, y); } - } else /* There was a click */ + } else { /* There was a click */ if ((msg3 == fichier) && (msg4 != no_choice)) { // Another menu to be displayed g_vm->setMouseClick(false); - menu_up(msg3); + menuUp(msg3); if (lo(msg4) == 1) msg3 = 7; else msg3 = 8; - menu_down(msg3); + menuDown(msg3); g_vm->setMouseClick(false); } else { // A menu was clicked on choisi = (test0) && (msg4 != no_choice); - menu_up(msg3); + menuUp(msg3); msg[4] = msg4; msg[3] = msg3; msg3 = no_choice; @@ -418,6 +434,7 @@ void mdn() { g_vm->setMouseClick(false); } + } } } // End of namespace Mortevielle diff --git a/engines/mortevielle/menu.h b/engines/mortevielle/menu.h index 1ea6931c0ed..6ab020dbd95 100644 --- a/engines/mortevielle/menu.h +++ b/engines/mortevielle/menu.h @@ -32,18 +32,21 @@ namespace Mortevielle { -/* NIVEAU 14*/ -extern void menut(int no, Common::String nom); -extern void menu_disable(int no); -extern void menu_enable(int no); -extern void menu_aff(); -extern void draw_menu(); -extern void invers(int ix); -extern void util(int x, int y); -extern void menu_down(int ii); -extern void menu_up(int xx); -extern void erase_menu(); -extern void mdn(); +class Menu { +private: + void util(int x, int y); + void invers(int ix); + void menuDown(int ii); +public: + void menut(int no, Common::String nom); + void disableMenuItem(int no); + void enableMenuItem(int no); + void menu_aff(); + void drawMenu(); + void menuUp(int xx); + void eraseMenu(); + void mdn(); +}; } // End of namespace Mortevielle #endif diff --git a/engines/mortevielle/mor.cpp b/engines/mortevielle/mor.cpp index 895e18362d9..d4461be3cdd 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; } - menut(invt[8], strp); - menu_disable(invt[8]); + g_vm->_menu.menut(invt[8], strp); + g_vm->_menu.disableMenuItem(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; } - menut(invt[8], strp); - menu_disable(invt[8]); + g_vm->_menu.menut(invt[8], strp); + g_vm->_menu.disableMenuItem(invt[8]); } @@ -445,47 +445,48 @@ void affper(int per) { int cx; /* debug('affper'); */ - for (cx = 1; cx <= 8; cx ++) menu_disable(disc[cx]); + for (cx = 1; cx <= 8; cx ++) + g_vm->_menu.disableMenuItem(disc[cx]); clsf10(); if ((per & 128) == 128) { g_vm->_screenSurface.putxy(560, 24); g_vm->_screenSurface.writeg("LEO", 4); - menu_enable(disc[1]); + g_vm->_menu.enableMenuItem(disc[1]); } if ((per & 64) == 64) { g_vm->_screenSurface.putxy(560, 32); g_vm->_screenSurface.writeg("PAT", 4); - menu_enable(disc[2]); + g_vm->_menu.enableMenuItem(disc[2]); } if ((per & 32) == 32) { g_vm->_screenSurface.putxy(560, 40); g_vm->_screenSurface.writeg("GUY", 4); - menu_enable(disc[3]); + g_vm->_menu.enableMenuItem(disc[3]); } if ((per & 16) == 16) { g_vm->_screenSurface.putxy(560, 48); g_vm->_screenSurface.writeg("EVA", 4); - menu_enable(disc[4]); + g_vm->_menu.enableMenuItem(disc[4]); } if ((per & 8) == 8) { g_vm->_screenSurface.putxy(560, 56); g_vm->_screenSurface.writeg("BOB", 4); - menu_enable(disc[5]); + g_vm->_menu.enableMenuItem(disc[5]); } if ((per & 4) == 4) { g_vm->_screenSurface.putxy(560, 64); g_vm->_screenSurface.writeg("LUC", 4); - menu_enable(disc[6]); + g_vm->_menu.enableMenuItem(disc[6]); } if ((per & 2) == 2) { g_vm->_screenSurface.putxy(560, 72); g_vm->_screenSurface.writeg("IDA", 4); - menu_enable(disc[7]); + g_vm->_menu.enableMenuItem(disc[7]); } if ((per & 1) == 1) { g_vm->_screenSurface.putxy(560, 80); g_vm->_screenSurface.writeg("MAX", 4); - menu_enable(disc[8]); + g_vm->_menu.enableMenuItem(disc[8]); } ipers = per; } @@ -526,7 +527,7 @@ void cpl1(int &p) { if ((h > 17) && (h < 22)) p = 35; if ((h > 21) && (h < 24)) p = 50; if ((h >= 0) && (h < 8)) p = 70; - mdn(); + g_vm->_menu.mdn(); } void cpl2(int &p) { @@ -578,7 +579,7 @@ void cpl6(int &p) { void person() { /* debug('person'); */ for (int cf = 1; cf <= 8; cf ++) - menu_disable(disc[cf]); + g_vm->_menu.disableMenuItem(disc[cf]); clsf10(); g_vm->_screenSurface.putxy(560, 30); diff --git a/engines/mortevielle/mor2.cpp b/engines/mortevielle/mor2.cpp index 5d33175a604..557ca0679b9 100644 --- a/engines/mortevielle/mor2.cpp +++ b/engines/mortevielle/mor2.cpp @@ -104,7 +104,7 @@ void tinke() { nh = readclock(); if ((nh - mh) > t) { am = active_menu; - erase_menu(); + g_vm->_menu.eraseMenu(); jh = jh + ((nh - mh) / t); mh = nh; switch (li) { @@ -165,7 +165,8 @@ void tinke() { } } } - if (am) draw_menu(); + if (am) + g_vm->_menu.drawMenu(); } } hfb = readclock(); @@ -233,11 +234,12 @@ void tmlieu(int mli) { deline(cx + c_tmlieu, st, tail); nomp = delig; while (nomp.size() < 20) nomp = nomp + ' '; - menut(depl[i], nomp); + g_vm->_menu.menut(depl[i], nomp); i = i + 1; } nomp = "* "; - for (cx = 7; cx >= i; cx --) menut(depl[cx], nomp); + for (cx = 7; cx >= i; cx --) + g_vm->_menu.menut(depl[cx], nomp); } @@ -271,20 +273,11 @@ void mfouen() int cx; tmlieu(s.mlieu); - for (cx = 1; cx <= 11; cx ++) menu_enable(men[cx]); - /* menu_enable( scacher); - menu_enable(menup, attacher); - menu_enable(menup, defoncer); - menu_enable(menup, dormir); - menu_enable(menup, entrer); - menu_enable(menup, fermer); - menu_enable(menup, frapper); - menu_enable(menup, manger); - menu_enable(menup, mettre); - menu_enable(menup, ouvrir); - menu_enable(menup, sortir); */ - menut(sonder, g_vm->getString(S_PROBE)); - menut(soulever, g_vm->getString(S_RAISE)); + for (cx = 1; cx <= 11; cx ++) + g_vm->_menu.enableMenuItem(men[cx]); + + g_vm->_menu.menut(sonder, g_vm->getString(S_PROBE)); + g_vm->_menu.menut(soulever, g_vm->getString(S_RAISE)); } void atf3f8(int &key) { @@ -382,13 +375,13 @@ void modinv() { r = (ord(s.sjer[cx]) + 400); deline(r - 501 + c_st41, nom, tay); nomp = delig; - menut(invt[cy], nomp); - menu_enable(invt[cx]); + g_vm->_menu.menut(invt[cy], nomp); + g_vm->_menu.enableMenuItem(invt[cx]); } if (cy < 6) for (cx = cy + 1; cx <= 6; cx ++) { - menut(invt[cx], " "); - menu_disable(invt[cx]); + g_vm->_menu.menut(invt[cx], " "); + g_vm->_menu.disableMenuItem(invt[cx]); } } @@ -425,16 +418,16 @@ void mfoudi() { int cx; for (cx = 1; cx <= 7; cx ++) - menu_disable(depl[cx]); + g_vm->_menu.disableMenuItem(depl[cx]); for (cx = 1; cx <= 11; cx ++) - menu_disable(men[cx]); + g_vm->_menu.disableMenuItem(men[cx]); - menut(sonder, g_vm->getString(S_SUITE)); - menut(soulever, g_vm->getString(S_STOP)); + g_vm->_menu.menut(sonder, g_vm->getString(S_SUITE)); + g_vm->_menu.menut(soulever, g_vm->getString(S_STOP)); } void mennor() { - menu_up(msg[3]); + g_vm->_menu.menuUp(msg[3]); } void premtet() { @@ -553,7 +546,8 @@ void quelquun() { int haz, cx; - if (imen) erase_menu(); + if (imen) + g_vm->_menu.eraseMenu(); finfouil(); crep = 997; L1: @@ -591,7 +585,8 @@ L1: affrep(); } } - if (imen) draw_menu(); + if (imen) + g_vm->_menu.drawMenu(); } void tsuiv() { diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index 130449a2b71..29a9d5bb465 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -553,7 +553,7 @@ void MortevielleEngine::handleAction() { oo = false; ctrm = 0; if (! iesc) { - draw_menu(); + g_vm->_menu.drawMenu(); imen = true; temps = 0; key = 0; @@ -562,7 +562,7 @@ void MortevielleEngine::handleAction() { _inMainGameLoop = true; do { - mdn(); + g_vm->_menu.mdn(); tinke(); mov_mouse(funct, inkey); CHECK_QUIT; @@ -570,7 +570,7 @@ void MortevielleEngine::handleAction() { } while (!((choisi) || (temps > lim) || (funct) || (anyone))); _inMainGameLoop = false; - erase_menu(); + g_vm->_menu.eraseMenu(); imen = false; if ((inkey == '\1') || (inkey == '\3') || (inkey == '\5') || (inkey == '\7') || (inkey == '\11')) { change_gd((uint)pred(int, ord(inkey)) >> 1); diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index 94640ba8a9f..371dd40b384 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -33,6 +33,7 @@ #include "common/error.h" #include "graphics/surface.h" #include "mortevielle/graphics.h" +#include "mortevielle/menu.h" #include "mortevielle/saveload.h" #include "mortevielle/sound.h" @@ -100,6 +101,7 @@ public: Common::RandomSource _randomSource; SoundManager _soundManager; SavegameManager _savegameManager; + Menu _menu; bool _quitGame; // Quit game flag. Originally called 'arret' bool _endGame; // End game flag. Originally called 'solu' diff --git a/engines/mortevielle/ovd1.cpp b/engines/mortevielle/ovd1.cpp index 94f89c34015..5bdb54f262b 100644 --- a/engines/mortevielle/ovd1.cpp +++ b/engines/mortevielle/ovd1.cpp @@ -114,7 +114,8 @@ void init_menu() { disc[i] = 0x500 + i; if (i < 8) depl[i] = 0x200 + i; invt[i] = 0x100 + i; - if (i > 6) menu_disable(invt[i]); + if (i > 6) + g_vm->_menu.disableMenuItem(invt[i]); } msg3 = no_choice; msg4 = no_choice; diff --git a/engines/mortevielle/prog.cpp b/engines/mortevielle/prog.cpp index db8b2e9cbdd..7f61b791856 100644 --- a/engines/mortevielle/prog.cpp +++ b/engines/mortevielle/prog.cpp @@ -54,7 +54,7 @@ void change_gd(int ngd) { maff = 68; afdes(0); repon(2, crep); - menu_aff(); + g_vm->_menu.menu_aff(); } /** diff --git a/engines/mortevielle/var_mor.cpp b/engines/mortevielle/var_mor.cpp index 1b19d5ca115..62b14575de9 100644 --- a/engines/mortevielle/var_mor.cpp +++ b/engines/mortevielle/var_mor.cpp @@ -278,7 +278,7 @@ char get_ch() { */ void s_sauv(int Gd, int y, int dy) { // Note: May no longer be necessary, since the backgorund restore code - // is being handled slightly differently now in the menu_up() method + // is being handled slightly differently now in the menuUp() method } void palette(int v1) {