aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruruk2013-09-07 18:00:00 +0200
committeruruk2013-09-07 18:00:00 +0200
commit467a7b1cce55680bddbae18fe655b386a4f3d051 (patch)
tree5def8e0d10c860b93d7ec1f7a7527941e9fea363
parent2bed64b447516f1f702fd70952a9886fac454b0d (diff)
downloadscummvm-rg350-467a7b1cce55680bddbae18fe655b386a4f3d051.tar.gz
scummvm-rg350-467a7b1cce55680bddbae18fe655b386a4f3d051.tar.bz2
scummvm-rg350-467a7b1cce55680bddbae18fe655b386a4f3d051.zip
AVALANCHE: Introduce a new class: Clock.
-rw-r--r--engines/avalanche/avalanche.cpp4
-rw-r--r--engines/avalanche/avalot.cpp2
-rw-r--r--engines/avalanche/dropdown2.cpp16
-rw-r--r--engines/avalanche/gyro2.cpp2
-rw-r--r--engines/avalanche/gyro2.h1
-rw-r--r--engines/avalanche/lucerna2.cpp136
-rw-r--r--engines/avalanche/lucerna2.h39
-rw-r--r--engines/avalanche/scrolls2.cpp2
8 files changed, 107 insertions, 95 deletions
diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp
index fbdeb2583b..27cfdd1178 100644
--- a/engines/avalanche/avalanche.cpp
+++ b/engines/avalanche/avalanche.cpp
@@ -525,10 +525,10 @@ void AvalancheEngine::updateEvents() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_LBUTTONDOWN:
- _lucerna->holdLeftMouse = true; // Used in Lucerna::checkclick() and Dropdown::menu_link().
+ _lucerna->_holdLeftMouse = true; // Used in Lucerna::checkclick() and Dropdown::menu_link().
break;
case Common::EVENT_LBUTTONUP:
- _lucerna->holdLeftMouse = false; // Same as above.
+ _lucerna->_holdLeftMouse = false; // Same as above.
break;
case Common::EVENT_KEYDOWN:
_avalot->handleKeyDown(event);
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index ff8a5aa8bf..814de6368a 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -198,7 +198,7 @@ void Avalot::run(Common::String arg) {
- _vm->_lucerna->updateClock();
+ _vm->_lucerna->_clock.update();
_vm->_dropdown->updateMenu();
_vm->_gyro->forceNumlock();
_vm->_trip->get_back_loretta();
diff --git a/engines/avalanche/dropdown2.cpp b/engines/avalanche/dropdown2.cpp
index b0b3b2fd51..9894769d41 100644
--- a/engines/avalanche/dropdown2.cpp
+++ b/engines/avalanche/dropdown2.cpp
@@ -728,11 +728,11 @@ void Dropdown::updateMenu() { // TODO: Optimize it ASAP!!! It really needs it...
::Graphics::Surface backup;
backup.copyFrom(_vm->_graphics->_surface);
- while (!_activeMenuItem._activeNow && (cursorPos.y <= 21) && _vm->_lucerna->holdLeftMouse) {
+ while (!_activeMenuItem._activeNow && (cursorPos.y <= 21) && _vm->_lucerna->_holdLeftMouse) {
_menuBar.chooseMenuItem(cursorPos.x);
do
_vm->updateEvents();
- while (_vm->_lucerna->holdLeftMouse);
+ while (_vm->_lucerna->_holdLeftMouse);
while (!_vm->shouldQuit()) {
@@ -755,16 +755,16 @@ void Dropdown::updateMenu() { // TODO: Optimize it ASAP!!! It really needs it...
_activeMenuItem.lightUp(cursorPos);
_vm->_graphics->refreshScreen();
- } while (!_vm->_lucerna->holdLeftMouse);
+ } while (!_vm->_lucerna->_holdLeftMouse);
- if (_vm->_lucerna->holdLeftMouse) {
+ if (_vm->_lucerna->_holdLeftMouse) {
if (cursorPos.y > 21) {
if (!((_activeMenuItem._firstlix) && ((cursorPos.x >= _activeMenuItem._flx1 * 8) && (cursorPos.x <= _activeMenuItem._flx2 * 8)
&& (cursorPos.y >= 24) && (cursorPos.y <= (_activeMenuItem.fly * 2 + 1))))) {
// Clicked OUTSIDE the menu.
if (_activeMenuItem._activeNow) {
_activeMenuItem.wipe();
- _vm->_lucerna->holdLeftMouse = false;
+ _vm->_lucerna->_holdLeftMouse = false;
backup.free();
return;
} // No "else"- clicking on menu has no effect (only releasing).
@@ -778,11 +778,11 @@ void Dropdown::updateMenu() { // TODO: Optimize it ASAP!!! It really needs it...
if (((_activeMenuItem._left * 8) <= cursorPos.x) && (cursorPos.x <= (_activeMenuItem._left * 8 + 80))) { // 80: the width of one menu item on the bar in pixels.
// If we clicked on the same menu item (the one that is already active) on the bar...
- _vm->_lucerna->holdLeftMouse = false;
+ _vm->_lucerna->_holdLeftMouse = false;
backup.free();
return;
} else {
- _vm->_lucerna->holdLeftMouse = true;
+ _vm->_lucerna->_holdLeftMouse = true;
break;
}
}
@@ -799,7 +799,7 @@ void Dropdown::updateMenu() { // TODO: Optimize it ASAP!!! It really needs it...
_vm->_graphics->refreshScreen();
_vm->updateEvents();
- if (!_vm->_lucerna->holdLeftMouse)
+ if (!_vm->_lucerna->_holdLeftMouse)
break;
}
diff --git a/engines/avalanche/gyro2.cpp b/engines/avalanche/gyro2.cpp
index cc624172d1..fd36aded84 100644
--- a/engines/avalanche/gyro2.cpp
+++ b/engines/avalanche/gyro2.cpp
@@ -279,7 +279,7 @@ void Gyro::newGame() {
_vm->_trip->new_game_for_trippancy();
_vm->_lucerna->drawScore();
_vm->_dropdown->setupMenu();
- _vm->_lucerna->updateClock();
+ _vm->_lucerna->_clock.update();
_vm->_lucerna->spriteRun();
}
diff --git a/engines/avalanche/gyro2.h b/engines/avalanche/gyro2.h
index e1ce464f56..21ea9da8e5 100644
--- a/engines/avalanche/gyro2.h
+++ b/engines/avalanche/gyro2.h
@@ -356,7 +356,6 @@ public:
byte _fieldNum;
Common::String _flags;
Common::String _listen;
- uint16 _oh, _onh, _om, _hours, _minutes, _seconds; // For Timeout. TODO: Move them into it.
Common::String _atKey; // For XTs, set to "alt-". For ATs, set to "f1".
byte _cp, _ledStatus, _defaultLed;
FontType _font;
diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp
index 76b2836c0f..5ecd00925e 100644
--- a/engines/avalanche/lucerna2.cpp
+++ b/engines/avalanche/lucerna2.cpp
@@ -49,7 +49,71 @@
namespace Avalanche {
-Lucerna::Lucerna(AvalancheEngine *vm) : _fxHidden(false) {
+const Common::Point Clock::kCenter(510,183);
+
+Clock::Clock(AvalancheEngine *vm) {
+ _vm = vm;
+ _oldHour = _oldHourAngle = _oldMinute = 17717;
+}
+
+void Clock::update() { // TODO: Move variables from Gyro to here (or at least somewhere nearby), rename them.
+ TimeDate t;
+ _vm->_system->getTimeAndDate(t);
+ _hour = t.tm_hour;
+ _minute = t.tm_min;
+ _second = t.tm_sec;
+
+ _hourAngle = (_hour % 12) * 30 + _minute / 2;
+
+ if (_oldHour != _hour) {
+ plotHands();
+ chime();
+ }
+
+ if (_oldMinute != _minute)
+ plotHands();
+
+ if ((_hour == 0) && (_oldHour != 0) && (_oldHour != 17717))
+ _vm->_scrolls->display(Common::String("Good morning!\n\nYes, it's just past midnight. Are you having an all-night Avvy session? Glad you like the game that much!"));
+
+ _oldHour = _hour;
+ _oldHourAngle = _hourAngle;
+ _oldMinute = _minute;
+}
+
+void Clock::calcHand(uint16 angle, uint16 length, Common::Point &endPoint, byte color) {
+ if (angle > 900) {
+ endPoint.x = 177;
+ return;
+ }
+
+ endPoint = _vm->_graphics->drawArc(_vm->_graphics->_surface, kCenter.x, kCenter.y, 449 - angle, 450 - angle, length, color);
+}
+
+void Clock::drawHand(const Common::Point &endPoint, byte color) {
+ if (endPoint.x == 177)
+ return;
+
+ _vm->_graphics->_surface.drawLine(kCenter.x, kCenter.y, endPoint.x, endPoint.y, color);
+}
+
+void Clock::plotHands() {
+ calcHand(_oldHourAngle, 14, _clockHandHour, kColorYellow);
+ calcHand(_oldMinute * 6, 17, _clockHandMinute, kColorYellow);
+ drawHand(_clockHandHour, kColorBrown);
+ drawHand(_clockHandMinute, kColorBrown);
+
+ calcHand(_hourAngle, 14, _clockHandHour, kColorBrown);
+ calcHand(_minute * 6, 17, _clockHandMinute, kColorBrown);
+ drawHand(_clockHandHour, kColorYellow);
+ drawHand(_clockHandMinute, kColorYellow);
+}
+
+void Clock::chime() {
+ warning("STUB: Lucerna::chime()");
+}
+
+Lucerna::Lucerna(AvalancheEngine *vm) : _fxHidden(false), _clock(vm) {
_vm = vm;
}
@@ -63,8 +127,6 @@ Lucerna::~Lucerna() {
}
void Lucerna::init() {
- _vm->_gyro->_oh = _vm->_gyro->_onh = _vm->_gyro->_om = 17717;
-
for (byte i = 0; i < 31; i++)
for (byte j = 0; j < 2; j++)
_vm->_gyro->_also[i][j] = 0;
@@ -111,9 +173,7 @@ void Lucerna::drawAlsoLines() {
CursorMan.showMouse(true);
}
-
-
-// nextstring, scram1 and unscrable are only used in load_also
+// readAlsoStringFromFile, scram and unScramble are only used in loadAlso
Common::String Lucerna::readAlsoStringFromFile() {
Common::String str;
@@ -1025,14 +1085,14 @@ void Lucerna::checkClick() {
else if ((340 <= cursorPos.y) && (cursorPos.y <= 399))
_vm->_gyro->newMouse(2); // screwdriver
else if (!_vm->_gyro->_dropdownActive) { // Dropdown can handle its own pointers.
- if (holdLeftMouse) {
+ if (_holdLeftMouse) {
_vm->_gyro->newMouse(7); // Mark's crosshairs
guideAvvy(cursorPos); // Normally, if you click on the picture, you're guiding Avvy around.
} else
_vm->_gyro->newMouse(4); // fletch
}
- if (holdLeftMouse) {
+ if (_holdLeftMouse) {
if ((0 <= cursorPos.y) && (cursorPos.y <= 21)) { // Click on the dropdown menu.
if (_vm->_gyro->_dropsOk)
_vm->_dropdown->updateMenu();
@@ -1051,7 +1111,7 @@ void Lucerna::checkClick() {
} else if ((208 <= cursorPos.x) && (cursorPos.x <= 260)) { // Examine the _thing.
do {
_vm->updateEvents();
- } while (holdLeftMouse);
+ } while (_holdLeftMouse);
if (_vm->_gyro->_thinkThing) {
_vm->_acci->_thing = _vm->_gyro->_thinks;
@@ -1065,7 +1125,7 @@ void Lucerna::checkClick() {
} else if ((261 <= cursorPos.x) && (cursorPos.x <= 319)) { // Display the score.
do {
_vm->updateEvents();
- } while (holdLeftMouse);
+ } while (_holdLeftMouse);
callVerb(_vm->_acci->kVerbCodeScore);
} else if ((320 <= cursorPos.x) && (cursorPos.x <= 357)) { // Change speed.
@@ -1121,62 +1181,6 @@ void Lucerna::drawDirection() { // It's data is loaded in load_digits().
CursorMan.showMouse(true);
}
-void Lucerna::calcHand(uint16 angle, uint16 length, Common::Point &endPoint, byte color) {
- if (angle > 900) {
- endPoint.x = 177;
- return;
- }
-
- endPoint = _vm->_graphics->drawArc(_vm->_graphics->_surface, _clockCenterX, _clockCenterY, 449 - angle, 450 - angle, length, color);
-}
-
-void Lucerna::drawHand(const Common::Point &endPoint, byte color) {
- if (endPoint.x == 177)
- return;
-
- _vm->_graphics->_surface.drawLine(_clockCenterX, _clockCenterY, endPoint.x, endPoint.y, color);
-}
-
-void Lucerna::plotHands() {
- calcHand(_vm->_gyro->_onh, 14, _clockHandHour, kColorYellow);
- calcHand(_vm->_gyro->_om * 6, 17, _clockHandMinute, kColorYellow);
- drawHand(_clockHandHour, kColorBrown);
- drawHand(_clockHandMinute, kColorBrown);
-
- calcHand(_hourAngle, 14, _clockHandHour, kColorBrown);
- calcHand(_vm->_gyro->_minutes * 6, 17, _clockHandMinute, kColorBrown);
- drawHand(_clockHandHour, kColorYellow);
- drawHand(_clockHandMinute, kColorYellow);
-}
-
-void Lucerna::chime() {
- warning("STUB: Lucerna::chime()");
-}
-
-void Lucerna::updateClock() { // TODO: Move variables from Gyro to here (or at least somewhere nearby), rename them.
- TimeDate t;
- _vm->_system->getTimeAndDate(t);
- _vm->_gyro->_hours = t.tm_hour;
- _vm->_gyro->_minutes = t.tm_min;
- _vm->_gyro->_seconds = t.tm_sec;
-
- _hourAngle = (_vm->_gyro->_hours % 12) * 30 + _vm->_gyro->_minutes / 2;
-
- if (_vm->_gyro->_oh != _vm->_gyro->_hours) {
- plotHands();
- chime();
- }
-
- if (_vm->_gyro->_om != _vm->_gyro->_minutes)
- plotHands();
-
- if ((_vm->_gyro->_hours == 0) && (_vm->_gyro->_oh != 0) && (_vm->_gyro->_oh != 17717))
- _vm->_scrolls->display(Common::String("Good morning!\n\nYes, it's just past midnight. Are you having an all-night Avvy session? Glad you like the game that much!"));
-
- _vm->_gyro->_oh = _vm->_gyro->_hours;
- _vm->_gyro->_onh = _hourAngle;
- _vm->_gyro->_om = _vm->_gyro->_minutes;
-}
void Lucerna::gameOver() {
_vm->_gyro->_dna._userMovesAvvy = false;
diff --git a/engines/avalanche/lucerna2.h b/engines/avalanche/lucerna2.h
index 6835fe01c1..2260c46373 100644
--- a/engines/avalanche/lucerna2.h
+++ b/engines/avalanche/lucerna2.h
@@ -36,10 +36,32 @@
namespace Avalanche {
class AvalancheEngine;
-class Lucerna {
+class Clock {
public:
- bool holdLeftMouse;
+ Clock(AvalancheEngine *vm);
+
+ void update();
+
+private:
+ static const Common::Point kCenter;
+
+ AvalancheEngine *_vm;
+
+ uint16 _hour, _minute, _second, _hourAngle, _oldHour, _oldMinute, _oldHourAngle; // hourAngle = nh in the original.
+ Common::Point _clockHandHour, _clockHandMinute; // ah and am in the original.
+
+ void calcHand(uint16 angle, uint16 length, Common::Point &endPoint, byte color);
+ void drawHand(const Common::Point &endPoint, byte color);
+ void plotHands();
+ void chime();
+};
+
+class Lucerna {
+public:
+ bool _holdLeftMouse;
+ Clock _clock;
+
Lucerna(AvalancheEngine *vm);
~Lucerna();
@@ -62,7 +84,6 @@ public:
void dusk();
void dawn();
void drawDirection(); // Draws the little icon at the left end of the text input field.
- void updateClock();
void gameOver();
uint16 bearing(byte whichPed); // Returns the bearing from ped 'whichped' to Avvy, in degrees.
void fixFlashers();
@@ -79,12 +100,6 @@ public:
private:
AvalancheEngine *_vm;
- //Clock
- static const int16 _clockCenterX = 510;
- static const int16 _clockCenterY = 183;
- Common::Point _clockHandHour, _clockHandMinute; // ah and am in the original.
- uint16 _hourAngle; // nh in the original.
-
bool _fxHidden; // Will de used in dust() and dawn().
Common::File file;
@@ -104,12 +119,6 @@ private:
void fadeOut(byte n);
void fadeIn(byte n);
- // Clock
- void calcHand(uint16 angle, uint16 length, Common::Point &endPoint, byte color);
- void drawHand(const Common::Point &endPoint, byte color);
- void plotHands();
- void chime();
-
};
} // End of namespace Avalanche
diff --git a/engines/avalanche/scrolls2.cpp b/engines/avalanche/scrolls2.cpp
index 16e0fb11ad..56f605a9d4 100644
--- a/engines/avalanche/scrolls2.cpp
+++ b/engines/avalanche/scrolls2.cpp
@@ -185,7 +185,7 @@ void Scrolls::normscroll() {
state(0);
_vm->_gyro->_seeScroll = false;
CursorMan.showMouse(false);
- _vm->_lucerna->holdLeftMouse = false; // Used in Lucerna::checkclick().
+ _vm->_lucerna->_holdLeftMouse = false; // Used in Lucerna::checkclick().
warning("STUB: Scrolls::normscroll()");
}