aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/lab/eventman.cpp10
-rw-r--r--engines/lab/lab.h2
-rw-r--r--engines/lab/special.cpp33
-rw-r--r--engines/mads/nebular/game_nebular.cpp76
-rw-r--r--engines/mads/phantom/game_phantom.cpp2
-rw-r--r--engines/mads/player.cpp82
-rw-r--r--engines/mads/player.h24
7 files changed, 139 insertions, 90 deletions
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index a94ddbf16b..b1348371b1 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -30,6 +30,8 @@
#include "common/events.h"
+#include "graphics/cursorman.h"
+
#include "lab/lab.h"
#include "lab/dispman.h"
@@ -125,18 +127,18 @@ void EventManager::updateMouse() {
}
void EventManager::initMouse() {
- _vm->_system->setMouseCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
- _vm->_system->showMouse(false);
+ CursorMan.pushCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
+ CursorMan.showMouse(false);
setMousePos(Common::Point(_vm->_graphics->_screenWidth / 2, _vm->_graphics->_screenHeight / 2));
}
void EventManager::mouseShow() {
- _vm->_system->showMouse(true);
+ CursorMan.showMouse(true);
}
void EventManager::mouseHide() {
- _vm->_system->showMouse(false);
+ CursorMan.showMouse(false);
}
void EventManager::setMousePos(Common::Point pos) {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 2c3a723f3e..0e9cdd36b1 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -461,7 +461,7 @@ private:
/**
* Processes user input.
*/
- void processMonitor(const char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect);
+ void processMonitor(const Common::String &ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect);
/**
* Figures out what a room's coordinates should be.
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 43d6056125..48e32cb1dc 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -288,8 +288,6 @@ void LabEngine::doJournal() {
void LabEngine::drawMonText(const char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive) {
uint16 drawingToPage = 0, yspacing = 0;
- int charsDrawn = 0;
- const char *curText = text;
_event->mouseHide();
@@ -319,10 +317,10 @@ void LabEngine::drawMonText(const char *text, TextFont *monitorFont, Common::Rec
_graphics->rectFill(textRect, 0);
}
+ const char *curText = text;
while (drawingToPage < _monitorPage) {
updateEvents();
- curText = text + charsDrawn;
- charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText);
+ curText += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText);
_lastPage = (*curText == 0);
if (_lastPage)
@@ -331,16 +329,16 @@ void LabEngine::drawMonText(const char *text, TextFont *monitorFont, Common::Rec
drawingToPage++;
}
- curText = text + charsDrawn;
+ curText += _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, textRect, curText);
_lastPage = (*curText == 0);
- _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, textRect, curText);
_event->mouseShow();
}
-void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) {
+void LabEngine::processMonitor(const Common::String &ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) {
Common::String startFileName = _monitorTextFilename;
const CloseData *startClosePtr = _closeDataPtr, *lastClosePtr[10];
uint16 depth = 0;
+ Common::String text = ntext;
lastClosePtr[0] = _closeDataPtr;
@@ -359,7 +357,7 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is
_monitorPage = 0;
_monitorTextFilename = filename;
- Common::String text = _resource->getText(_monitorTextFilename);
+ text = _resource->getText(_monitorTextFilename);
_graphics->fade(false);
drawMonText(text.c_str(), monitorFont, textRect, isInteractive);
_graphics->fade(true);
@@ -387,11 +385,15 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is
int16 mouseX = msg->_mouse.x;
int16 mouseY = msg->_mouse.y;
+ // Check if mouse was in button bar
if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) {
- if (mouseX <= _utils->vgaScaleX(31))
+ if (mouseX <= _utils->vgaScaleX(31)) {
+ // Exit button
return;
+ }
if (mouseX <= _utils->vgaScaleX(59)) {
+ // Back button
if (isInteractive) {
_monitorPage = 0;
@@ -401,19 +403,20 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is
}
} else if (_monitorPage > 0) {
_monitorPage = 0;
- drawMonText(ntext, monitorFont, textRect, isInteractive);
+ drawMonText(text.c_str(), monitorFont, textRect, isInteractive);
}
} else if (mouseX < _utils->vgaScaleX(259)) {
- return;
+ // empty region; ignore
} else if (mouseX <= _utils->vgaScaleX(289)) {
+ // Page down button
if (!_lastPage) {
_monitorPage += 1;
- drawMonText(ntext, monitorFont, textRect, isInteractive);
+ drawMonText(text.c_str(), monitorFont, textRect, isInteractive);
}
} else if (_monitorPage >= 1) {
- // mouseX is greater than 290 (scaled)
+ // Page up button
_monitorPage -= 1;
- drawMonText(ntext, monitorFont, textRect, isInteractive);
+ drawMonText(text.c_str(), monitorFont, textRect, isInteractive);
}
} else if (isInteractive) {
const CloseData *tmpClosePtr = _closeDataPtr;
@@ -456,7 +459,7 @@ void LabEngine::doMonitor(const Common::String background, const Common::String
drawMonText(ntext.c_str(), monitorFont, scaledRect, isinteractive);
_event->mouseShow();
_graphics->fade(true);
- processMonitor(ntext.c_str(), monitorFont, isinteractive, scaledRect);
+ processMonitor(ntext, monitorFont, isinteractive, scaledRect);
_graphics->fade(false);
_event->mouseHide();
_graphics->freeFont(&monitorFont);
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index c4b7f57281..9c0acf1a47 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -827,51 +827,49 @@ void GameNebular::step() {
if (_player._visible && _player._stepEnabled && !_player._moving &&
(_player._facing == _player._turnToFacing)) {
if (_scene._frameStartTime >= (uint32)_globals[kWalkerTiming]) {
- if (!_player._stopWalkerIndex) {
- int randomVal = _vm->getRandomNumber(29999);
- if (_globals[kSexOfRex] == REX_MALE) {
- switch (_player._facing) {
- case FACING_SOUTHWEST:
- case FACING_SOUTHEAST:
- case FACING_NORTHWEST:
- case FACING_NORTHEAST:
- if (randomVal < 200) {
- _player.addWalker(-1, 0);
+ int randomVal = _vm->getRandomNumber(29999);
+ if (_globals[kSexOfRex] == REX_MALE) {
+ switch (_player._facing) {
+ case FACING_SOUTHWEST:
+ case FACING_SOUTHEAST:
+ case FACING_NORTHWEST:
+ case FACING_NORTHEAST:
+ if (randomVal < 200) {
+ _player.addWalker(-1, 0);
+ _player.addWalker(1, 0);
+ }
+ break;
+
+ case FACING_WEST:
+ case FACING_EAST:
+ if (randomVal < 500) {
+ for (int count = 0; count < 10; ++count) {
_player.addWalker(1, 0);
}
- break;
-
- case FACING_WEST:
- case FACING_EAST:
- if (randomVal < 500) {
- for (int count = 0; count < 10; ++count) {
- _player.addWalker(1, 0);
- }
+ }
+ break;
+
+ case FACING_SOUTH:
+ if (randomVal < 500) {
+ for (int count = 0; count < 10; ++count) {
+ _player.addWalker((randomVal < 250) ? 1 : 2, 0);
}
- break;
-
- case FACING_SOUTH:
- if (randomVal < 500) {
- for (int count = 0; count < 10; ++count) {
- _player.addWalker((randomVal < 250) ? 1 : 2, 0);
- }
- } else if (randomVal < 750) {
- for (int count = 0; count < 5; ++count) {
- _player.addWalker(1, 0);
- }
-
- _player.addWalker(0, 0);
- _player.addWalker(0, 0);
-
- for (int count = 0; count < 5; ++count) {
- _player.addWalker(2, 0);
- }
+ } else if (randomVal < 750) {
+ for (int count = 0; count < 5; ++count) {
+ _player.addWalker(1, 0);
}
- break;
- default:
- break;
+ _player.addWalker(0, 0);
+ _player.addWalker(0, 0);
+
+ for (int count = 0; count < 5; ++count) {
+ _player.addWalker(2, 0);
+ }
}
+ break;
+
+ default:
+ break;
}
}
diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp
index 27849cce1e..3ec3052ad5 100644
--- a/engines/mads/phantom/game_phantom.cpp
+++ b/engines/mads/phantom/game_phantom.cpp
@@ -747,7 +747,7 @@ void GamePhantom::step() {
&& (_player._stepEnabled || (_vm->_gameConv->_running >= 0))
&& !_player._moving && (_player._facing == _player._turnToFacing)
&& (_scene._frameStartTime >= (uint32)_globals[kWalkerTiming])) {
- if (!_player._stopWalkerIndex)
+ if (_player._stopWalkers.empty())
stopWalker();
_globals[kWalkerTiming] += 6;
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 09a961825e..7d9a4fd8df 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -32,6 +32,34 @@ const int Player::_directionListIndexes[32] = {
0, 7, 4, 3, 6, 0, 2, 5, 0, 1, 9, 4, 1, 2, 7, 9, 3, 8, 9, 6, 7, 2, 3, 6, 1, 7, 9, 4, 7, 8, 0, 0
};
+/*------------------------------------------------------------------------*/
+
+void StopWalkerEntry::synchronize(Common::Serializer &s) {
+ s.syncAsSint16LE(_stack);
+ s.syncAsSint16LE(_trigger);
+}
+
+/*------------------------------------------------------------------------*/
+
+void StopWalkers::synchronize(Common::Serializer &s) {
+ StopWalkerEntry rec;
+ int count = size();
+ s.syncAsUint16LE(count);
+
+ if (s.isLoading()) {
+ clear();
+ for (int idx = 0; idx < count; ++idx) {
+ rec.synchronize(s);
+ push(rec);
+ }
+ } else {
+ for (int idx = 0; idx < count; ++idx)
+ (*this)[idx].synchronize(s);
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
Player::Player(MADSEngine *vm)
: _vm(vm) {
_action = nullptr;
@@ -69,7 +97,6 @@ Player::Player(MADSEngine *vm)
_upcomingTrigger = 0;
_trigger = 0;
_frameListIndex = 0;
- _stopWalkerIndex = 0;
_totalDistance = 0;
_distAccum = 0;
_pixelAccum = 0;
@@ -84,8 +111,6 @@ Player::Player(MADSEngine *vm)
_enableAtTarget = false;
_walkTrigger = 0;
- Common::fill(&_stopWalkerList[0], &_stopWalkerList[12], 0);
- Common::fill(&_stopWalkerTrigger[0], &_stopWalkerTrigger[12], 0);
Common::fill(&_spriteSetsPresent[0], &_spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT], false);
}
@@ -256,15 +281,16 @@ void Player::updateFrame() {
if (!spriteSet._charInfo->_numEntries) {
_frameNumber = 1;
} else {
- _frameListIndex = _stopWalkerList[_stopWalkerIndex];
+ _frameListIndex = _stopWalkers.empty() ? 0 : _stopWalkers.top()._stack;
if (!_visible) {
_upcomingTrigger = 0;
} else {
- _upcomingTrigger = _stopWalkerTrigger[_stopWalkerIndex];
-
- if (_stopWalkerIndex > 0)
- --_stopWalkerIndex;
+ if (_stopWalkers.empty()) {
+ _upcomingTrigger = 0;
+ } else {
+ _upcomingTrigger = _stopWalkers.pop()._trigger;
+ }
}
// Set the player frame number
@@ -284,11 +310,20 @@ void Player::updateFrame() {
}
void Player::activateTrigger() {
- // TODO: Finish this!
- // TODO: Also sync _walkTrigger, if necessary
+ Game &game = *_vm->_game;
+ MADSAction &action = game._scene._action;
+ _commandsAllowed |= _enableAtTarget;
+ _enableAtTarget = false;
+
if (_walkTrigger) {
- _vm->_game->_trigger = _walkTrigger;
+ game._trigger = _walkTrigger;
+ game._triggerMode = SEQUENCE_TRIGGER_DAEMON;
+
+ if (game._triggerMode != SEQUENCE_TRIGGER_DAEMON) {
+ action._activeAction = _walkTriggerAction;
+ }
+
_walkTrigger = 0;
}
}
@@ -376,9 +411,7 @@ void Player::update() {
}
void Player::clearStopList() {
- _stopWalkerList[0] = 0;
- _stopWalkerTrigger[0] = 0;
- _stopWalkerIndex = 0;
+ _stopWalkers.clear();
_upcomingTrigger = 0;
_trigger = 0;
}
@@ -701,14 +734,10 @@ void Player::addWalker(int walker, int trigger) {
SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
assert(spriteSet._charInfo);
- if (walker < spriteSet._charInfo->_numEntries && _stopWalkerIndex < 11) {
- ++_stopWalkerIndex;
- _stopWalkerList[_stopWalkerIndex] = walker;
- _stopWalkerTrigger[_stopWalkerIndex] = trigger;
- }
+ if (walker < spriteSet._charInfo->_numEntries)
+ _stopWalkers.push(StopWalkerEntry(walker, trigger));
}
-
/**
* Releases any sprites used by the player
*/
@@ -770,13 +799,10 @@ void Player::synchronize(Common::Serializer &s) {
s.syncAsSint16LE(_currentDepth);
s.syncAsSint16LE(_currentScale);
s.syncAsSint16LE(_frameListIndex);
+ _stopWalkers.synchronize(s);
+ _walkTriggerAction.synchronize(s);
+ s.syncAsUint16LE(_walkTriggerDest);
- for (int i = 0; i < 12; ++i) {
- s.syncAsSint16LE(_stopWalkerList[i]);
- s.syncAsSint16LE(_stopWalkerTrigger[i]);
- }
-
- s.syncAsSint16LE(_stopWalkerIndex);
s.syncAsSint16LE(_upcomingTrigger);
s.syncAsSint16LE(_trigger);
s.syncAsSint16LE(_scalingVelocity);
@@ -826,8 +852,10 @@ void Player::firstWalk(Common::Point fromPos, Facing fromFacing, Common::Point d
}
void Player::setWalkTrigger(int val) {
+ Scene &scene = _vm->_game->_scene;
_walkTrigger = val;
- warning("TODO: Player::setWalkTrigger");
+ _walkTriggerDest = _vm->_game->_triggerSetupMode;
+ _walkTriggerAction = scene._action._activeAction;
}
void Player::resetFacing(Facing facing) {
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 55000047fb..04b86b76b4 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -45,6 +45,23 @@ enum Facing {
FACING_NONE = 5, FACING_DUMMY = 0
};
+struct StopWalkerEntry {
+ int _stack;
+ int _trigger;
+
+ StopWalkerEntry() : _stack(0), _trigger(0) {}
+ StopWalkerEntry(int stack, int trigger) : _stack(stack), _trigger(trigger) {}
+
+ void synchronize(Common::Serializer &s);
+};
+
+class StopWalkers : public Common::FixedStack<StopWalkerEntry, 12> {
+public:
+ StopWalkers() : Common::FixedStack<StopWalkerEntry, 12>() {}
+
+ void synchronize(Common::Serializer &s);
+};
+
class Player {
private:
static const int _directionListIndexes[32];
@@ -58,8 +75,6 @@ private:
int _distAccum;
int _pixelAccum;
int _deltaDistance;
- int _stopWalkerList[12];
- int _stopWalkerTrigger[12];
int _totalDistance;
void clearStopList();
@@ -138,12 +153,15 @@ public:
bool _readyToWalk;
bool _commandsAllowed;
bool _enableAtTarget;
- int _stopWalkerIndex;
int _centerOfGravity;
int _currentDepth;
int _currentScale;
Common::String _spritesPrefix;
+
int _walkTrigger;
+ TriggerMode _walkTriggerDest;
+ ActionDetails _walkTriggerAction;
+ StopWalkers _stopWalkers;
public:
Player(MADSEngine *vm);