Skip to content

Commit

Permalink
MORTEVIELLE: Merge the _mouseButtons and clic variables
Browse files Browse the repository at this point in the history
The original separate implementation was causing problems with the mouse click variable remaining set too long.
  • Loading branch information
dreammaster authored and Strangerke committed Apr 6, 2012
1 parent 27ff523 commit d0de28c
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 36 deletions.
5 changes: 3 additions & 2 deletions engines/mortevielle/actions.cpp
Expand Up @@ -32,6 +32,7 @@
#include "mortevielle/menu.h"
#include "mortevielle/mor.h"
#include "mortevielle/mor2.h"
#include "mortevielle/mortevielle.h"
#include "mortevielle/mouse.h"
#include "mortevielle/outtext.h"
#include "mortevielle/ques.h"
Expand Down Expand Up @@ -1094,8 +1095,8 @@ void taller() {
} else choi = 0;
}
}
} while (!((tou == '\15') || (((c != 0) || clic) && (choi != 0))));
clic = false;
} while (!((tou == '\15') || (((c != 0) || g_vm->getMouseClick()) && (choi != 0))));
g_vm->setMouseClick(false);
if (choi != 46) {
ix = choi - 1;
if (col) {
Expand Down
7 changes: 4 additions & 3 deletions engines/mortevielle/alert.cpp
Expand Up @@ -28,6 +28,7 @@
#include "common/str.h"
#include "mortevielle/alert.h"
#include "mortevielle/level15.h"
#include "mortevielle/mortevielle.h"
#include "mortevielle/mouse.h"
#include "mortevielle/sprint.h"

Expand Down Expand Up @@ -150,7 +151,7 @@ int do_alert(Common::String str_, int n) {
while (keypressed())
dumi = get_ch(); // input >> kbd >> dumi;

clic = false;
g_vm->setMouseClick(false);
decod(str_, nbcase, nblig, nbcol, chaine, cas);
sauvecr(50, succ(int, nligne) << 4);

Expand Down Expand Up @@ -242,8 +243,8 @@ int do_alert(Common::String str_, int n) {
}
test3 = (cy > 95) && (cy < 105) && (((cx > limit[1][1]) && (cx < limit[1][2]))
|| ((cx > limit[2][1]) && (cx < limit[2][2])));
} while (!clic);
clic = false;
} while (!g_vm->getMouseClick());
g_vm->setMouseClick(false);
hide_mouse();
if (! test3) {
quoi = n;
Expand Down
2 changes: 1 addition & 1 deletion engines/mortevielle/graphics.cpp
Expand Up @@ -79,7 +79,7 @@ void PaletteManager::setDefaultPalette() {

#define INCR_TAIX { if (_xSize & 1) ++_xSize; }
#define DEFAULT_WIDTH (SCREEN_WIDTH / 2)
#define BUFFER_SIZE 8192
#define BUFFER_SIZE 40000

void GfxSurface::decode(const byte *pSrc) {
_width = _height = 0;
Expand Down
19 changes: 12 additions & 7 deletions engines/mortevielle/menu.cpp
Expand Up @@ -187,7 +187,7 @@ void draw_menu() {
msg4 = no_choice;
msg3 = no_choice;
choisi = false;
clic = false;
g_vm->setMouseClick(false);
test0 = false;
}

Expand Down Expand Up @@ -342,7 +342,7 @@ void menu_up(int xx) {
void erase_menu() {
/* debug('erase_menu'); */
active_menu = false;
clic = false;
g_vm->setMouseClick(false);
menu_up(msg3);
}

Expand All @@ -355,7 +355,7 @@ void mdn() {
if (! active_menu) return;
x = x_s;
y = y_s;
if (! clic) {
if (!g_vm->getMouseClick()) {
if ((x == xprec) &&
(y == yprec)) return;
else {
Expand Down Expand Up @@ -385,21 +385,26 @@ void mdn() {
} else { /* Not in the MenuTitle line */
if ((y > 11) && (test0)) util(x, y);
}
} else /* il y a eu 'clic' */
} else /* There was a click */
if ((msg3 == fichier) && (msg4 != no_choice)) {
clic = false;
// Another menu to be displayed
g_vm->setMouseClick(false);
menu_up(msg3);
if (lo(msg4) == 1) msg3 = 7;
else msg3 = 8;
menu_down(msg3);
} else { /* il y a eu clic sur un autre menu */

g_vm->setMouseClick(false);
} else {
// A menu was clicked on
choisi = (test0) && (msg4 != no_choice);
menu_up(msg3);
msg[4] = msg4;
msg[3] = msg3;
msg3 = no_choice;
msg4 = no_choice;
clic = false;

g_vm->setMouseClick(false);
}
}

Expand Down
5 changes: 3 additions & 2 deletions engines/mortevielle/mor2.cpp
Expand Up @@ -202,7 +202,7 @@ void tkey1(bool d) {
read_pos_mouse(x, y, c);
} while (!(quest || (c != 0) || (d && anyone)));
if (quest) key = testou();
clic = false;
g_vm->setMouseClick(false);
show_mouse();
}

Expand Down Expand Up @@ -628,7 +628,8 @@ void tfleche() {

do {
mov_mouse(qust, touch);
if (clic) rect = (x_s < 256 * res) && (y_s < 176) && (y_s > 12);
if (g_vm->getMouseClick())
rect = (x_s < 256 * res) && (y_s < 176) && (y_s > 12);
tinke();
} while (!(qust || rect || anyone));

Expand Down
12 changes: 3 additions & 9 deletions engines/mortevielle/mortevielle.cpp
Expand Up @@ -40,7 +40,7 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g
Engine(system), _gameDescription(gameDesc), _randomSource("mortevielle") {
g_vm = this;
_lastGameFrame = 0;
_mouseButtons = 0;
_mouseClick = false;
}

MortevielleEngine::~MortevielleEngine() {
Expand Down Expand Up @@ -168,21 +168,15 @@ bool MortevielleEngine::handleEvents() {
switch (event.type) {
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_RBUTTONUP:
case Common::EVENT_MOUSEMOVE:
_mousePos = Common::Point(event.mouse.x, event.mouse.y / 2);
x_s = event.mouse.x;
y_s = event.mouse.y / 2;

if (event.type == Common::EVENT_LBUTTONDOWN)
_mouseButtons |= 1;
_mouseClick = true;
else if (event.type == Common::EVENT_LBUTTONUP)
_mouseButtons &= ~1;
else if (event.type == Common::EVENT_RBUTTONDOWN)
_mouseButtons |= 2;
else if (event.type == Common::EVENT_RBUTTONUP)
_mouseButtons &= ~2;
_mouseClick = false;
break;

case Common::EVENT_KEYDOWN:
Expand Down
5 changes: 3 additions & 2 deletions engines/mortevielle/mortevielle.h
Expand Up @@ -53,7 +53,7 @@ class MortevielleEngine : public Engine {
const ADGameDescription *_gameDescription;
Common::Stack<int> _keypresses;
uint32 _lastGameFrame;
int _mouseButtons;
bool _mouseClick;
Common::Point _mousePos;

Common::ErrorCode initialise();
Expand All @@ -78,7 +78,8 @@ class MortevielleEngine : public Engine {
int getChar();
Common::Point getMousePos() const { return _mousePos; }
void setMousePos(const Common::Point &pt);
int getMouseButtons() const { return _mouseButtons; }
bool getMouseClick() const { return _mouseClick; }
void setMouseClick(bool v) { _mouseClick = v; }
};

extern MortevielleEngine *g_vm;
Expand Down
10 changes: 4 additions & 6 deletions engines/mortevielle/mouse.cpp
Expand Up @@ -57,7 +57,7 @@ void init_mouse() {
y_s = 0;
p_o_s = 0;
/*int_m:= False;*/
clic = false;
g_vm->setMouseClick(false);
m_show = m_arrow;
if ((READ_LE_UINT16(&mem[0xcc]) == 0) && (READ_LE_UINT16(&mem[0xce]) == 0)) int_m = false;
if (int_m) {
Expand Down Expand Up @@ -278,7 +278,7 @@ void pos_mouse(int x, int y) {
void read_pos_mouse(int &x, int &y, int &c) {
x = g_vm->getMousePos().x;
y = g_vm->getMousePos().y;
c = g_vm->getMouseButtons();
c = g_vm->getMouseClick() ? 1 : 0;
}

void mov_mouse(bool &funct, char &key) {
Expand All @@ -292,10 +292,8 @@ void mov_mouse(bool &funct, char &key) {
p_key = keypressed();

// If mouse button clicked, return it
if (g_vm->getMouseButtons() != 0) {
clic = true;
if (g_vm->getMouseClick())
return;
}

// Handle any pending keypresses
while (p_key) {
Expand Down Expand Up @@ -343,7 +341,7 @@ void mov_mouse(bool &funct, char &key) {
break;
case ' ':
case '\15' : {
clic = true;
g_vm->setMouseClick(true);
return;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion engines/mortevielle/mouse.h
Expand Up @@ -30,7 +30,7 @@

namespace Mortevielle {

extern bool clic, int_m;
extern bool int_m;

extern int m_show,
x_s,
Expand Down
3 changes: 2 additions & 1 deletion engines/mortevielle/ovd1.cpp
Expand Up @@ -31,6 +31,7 @@
#include "mortevielle/level15.h"
#include "mortevielle/menu.h"
#include "mortevielle/mor.h"
#include "mortevielle/mortevielle.h"
#include "mortevielle/mouse.h"
#include "mortevielle/outtext.h"
#include "mortevielle/ovd1.h"
Expand Down Expand Up @@ -142,7 +143,7 @@ void ani50() {
msg4 = no_choice;
msg[3] = no_choice;
msg[4] = no_choice;
clic = false;
g_vm->setMouseClick(false);
}


Expand Down
5 changes: 3 additions & 2 deletions engines/mortevielle/ques.cpp
Expand Up @@ -28,6 +28,7 @@
#include "common/str.h"
#include "mortevielle/boite.h"
#include "mortevielle/level15.h"
#include "mortevielle/mortevielle.h"
#include "mortevielle/mouse.h"
#include "mortevielle/outtext.h"
#include "mortevielle/ques.h"
Expand Down Expand Up @@ -105,7 +106,7 @@ namespace Mortevielle {
j = 0;
memk = 0;
do {
clic = false;
g_vm->setMouseClick(false);
tesok = false;
mov_mouse(func, key);
k = 1;
Expand All @@ -130,7 +131,7 @@ namespace Mortevielle {
afftex(st, 100, 27 + memk * 8, 100, 1, 0);
memk = 0;
}
} while (!((memk != 0) && clic));
} while (!((memk != 0) && g_vm->getMouseClick()));
if (memk == ok[i]) compte = compte + 1;
else {
if (i == 5) i = i + 1;
Expand Down

0 comments on commit d0de28c

Please sign in to comment.