aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/spinner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/bladerunner/spinner.cpp')
-rw-r--r--engines/bladerunner/spinner.cpp144
1 files changed, 86 insertions, 58 deletions
diff --git a/engines/bladerunner/spinner.cpp b/engines/bladerunner/spinner.cpp
index 40650cbc22..acee0cb262 100644
--- a/engines/bladerunner/spinner.cpp
+++ b/engines/bladerunner/spinner.cpp
@@ -38,12 +38,19 @@ namespace BladeRunner {
Spinner::Spinner(BladeRunnerEngine *vm) : _vm(vm) {
reset();
- _imagePicker = new UIImagePicker(vm, SPINNER_DESTINATIONS);
+ _imagePicker = new UIImagePicker(vm, kSpinnerDestinations);
+ _vqaPlayer = nullptr;
}
Spinner::~Spinner() {
delete _imagePicker;
+
reset();
+
+ if (_vqaPlayer != nullptr) {
+ _vqaPlayer->close();
+ delete _vqaPlayer;
+ }
}
void Spinner::setSelectableDestinationFlag(int destination, bool selectable) {
@@ -55,38 +62,39 @@ bool Spinner::querySelectableDestinationFlag(int destination) const {
}
SpinnerDestination SpinnerDestinationsNear[] = {
- { 0, 0x0D2, 0x107, 0x107, 0x14C },
- { 1, 0x133, 0x14A, 0x169, 0x17D },
- { 2, 0x152, 0x089, 0x16A, 0x0A9 },
- { 3, 0x0F8, 0x087, 0x121, 0x0A8 },
- { 4, 0x160, 0x0DE, 0x17B, 0x0EE },
- { -1, -1, -1, -1, -1 }
+ { 0, { 210, 263, 263, 332 } },
+ { 1, { 307, 330, 361, 381 } },
+ { 2, { 338, 137, 362, 169 } },
+ { 3, { 248, 135, 289, 168 } },
+ { 4, { 352, 222, 379, 238 } },
+ { -1, { -1,-1,-1,-1 } }
+
};
SpinnerDestination SpinnerDestinationsMedium[] = {
- { 0, 0x0FC, 0x0F2, 0x117, 0x11B },
- { 1, 0x12D, 0x111, 0x148, 0x130 },
- { 2, 0x13F, 0x0B6, 0x150, 0x0C8 },
- { 3, 0x10D, 0x0B5, 0x125, 0x0C8 },
- { 4, 0x145, 0x0E3, 0x159, 0x0F0 },
- { 5, 0x103, 0x04A, 0x17C, 0x077 },
- { 6, 0x0CB, 0x07C, 0x0E0, 0x088 },
- { 7, 0x0C8, 0x093, 0x0DE, 0x0AA },
- { -1, -1, -1, -1, -1 }
+ { 0, { 252, 242, 279, 283 } },
+ { 1, { 301, 273, 328, 304 } },
+ { 2, { 319, 182, 336, 200 } },
+ { 3, { 269, 181, 293, 200 } },
+ { 4, { 325, 227, 345, 240 } },
+ { 5, { 259, 74, 380, 119 } },
+ { 6, { 203, 124, 224, 136 } },
+ { 7, { 200, 147, 222, 170 } },
+ { -1, { -1,-1,-1,-1 } }
};
SpinnerDestination SpinnerDestinationsFar[] = {
- { 0, 0x0DC, 0x0E3, 0x0F6, 0x106 },
- { 1, 0x104, 0x0FC, 0x11E, 0x117 },
- { 2, 0x11E, 0x0B2, 0x12E, 0x0C4 },
- { 3, 0x0F4, 0x0B2, 0x107, 0x0C3 },
- { 4, 0x120, 0x0D8, 0x132, 0x0E4 },
- { 5, 0x0F9, 0x04D, 0x161, 0x07C },
- { 6, 0x0BE, 0x07F, 0x0D0, 0x08A },
- { 7, 0x0B9, 0x095, 0x0CE, 0x0AA },
- { 8, 0x18E, 0x0F9, 0x1A3, 0x10C },
- { 9, 0x186, 0x0DA, 0x1A3, 0x0EC },
- { -1, -1, -1, -1, -1 }
+ { 0, { 220, 227, 246, 262 } },
+ { 1, { 260, 252, 286, 279 } },
+ { 2, { 286, 178, 302, 196 } },
+ { 3, { 244, 178, 263, 195 } },
+ { 4, { 288, 216, 306, 228 } },
+ { 5, { 249, 77, 353, 124 } },
+ { 6, { 190, 127, 208, 138 } },
+ { 7, { 185, 149, 206, 170 } },
+ { 8, { 398, 249, 419, 268 } },
+ { 9, { 390, 218, 419, 236 } },
+ { -1, { -1, -1, -1, -1 } }
};
static void spinner_mouseInCallback(int, void*);
@@ -94,16 +102,17 @@ static void spinner_mouseOutCallback(int, void*);
static void spinner_mouseDownCallback(int, void*);
static void spinner_mouseUpCallback(int, void*);
-int Spinner::interfaceChooseDest(int loopId, int loopFlag) {
+int Spinner::chooseDestination(int loopId, bool immediately) {
_selectedDestination = 0;
- if (!_vm->openArchive("MODE.MIX"))
+ if (!_vm->openArchive("MODE.MIX")) {
return 0;
+ }
if (loopId < 0) {
_isOpen = true;
} else {
_vm->playerLosesControl();
- _vm->_scene->loopStartSpecial(3, loopId, loopFlag);
+ _vm->_scene->loopStartSpecial(kSceneLoopModeSpinner, loopId, immediately);
while (!_isOpen) {
_vm->gameTick();
}
@@ -119,10 +128,11 @@ int Spinner::interfaceChooseDest(int loopId, int loopFlag) {
// Determine which map we need to show to include the active destinations
uint8 mapmask = 0;
- uint8 mapmaskv[SPINNER_DESTINATIONS] = { 1, 1, 1, 1, 1, 3, 3, 3, 7, 7 };
- for (int i = 0; i != SPINNER_DESTINATIONS; ++i) {
- if (_isDestinationSelectable[i])
+ uint8 mapmaskv[kSpinnerDestinations] = { 1, 1, 1, 1, 1, 3, 3, 3, 7, 7 };
+ for (int i = 0; i != kSpinnerDestinations; ++i) {
+ if (_isDestinationSelectable[i]) {
mapmask |= mapmaskv[i];
+ }
}
_destinations = nullptr;
@@ -151,8 +161,8 @@ int Spinner::interfaceChooseDest(int loopId, int loopFlag) {
return -1;
}
- _vqaPlayer->setLoop(spinnerLoopId, -1, 2, nullptr, nullptr);
- _vqaPlayer->setLoop(spinnerLoopId + 1, -1, 0, nullptr, nullptr);
+ _vqaPlayer->setLoop(spinnerLoopId, -1, kLoopSetModeImmediate, nullptr, nullptr);
+ _vqaPlayer->setLoop(spinnerLoopId + 1, -1, kLoopSetModeJustStart, nullptr, nullptr);
for (int j = 0; j != shapeCount; ++j) {
_shapes.push_back(new Shape(_vm));
@@ -162,17 +172,15 @@ int Spinner::interfaceChooseDest(int loopId, int loopFlag) {
_imagePicker->resetImages();
for (SpinnerDestination *dest = _destinations; dest->id != -1; ++dest) {
- if (!_isDestinationSelectable[dest->id])
+ if (!_isDestinationSelectable[dest->id]) {
continue;
+ }
const char *tooltip = _vm->_textSpinnerDestinations->getText(dest->id);
_imagePicker->defineImage(
dest->id,
- dest->left,
- dest->top,
- dest->right,
- dest->bottom,
+ dest->rect,
_shapes[dest->id],
_shapes[dest->id + _shapes.size() / 2],
_shapes[dest->id + _shapes.size() / 2],
@@ -180,7 +188,7 @@ int Spinner::interfaceChooseDest(int loopId, int loopFlag) {
);
}
- _imagePicker->setCallbacks(
+ _imagePicker->activate(
spinner_mouseInCallback,
spinner_mouseOutCallback,
spinner_mouseDownCallback,
@@ -194,14 +202,26 @@ int Spinner::interfaceChooseDest(int loopId, int loopFlag) {
_vm->gameTick();
} while (_selectedDestination == -1);
- // TODO: Unfreeze game time
- _isOpen = false;
- // TODO: _vm->_scene->resume();
+ _imagePicker->deactivate();
- for (int i = 0; i != (int)_shapes.size(); ++i)
+ for (int i = 0; i != (int)_shapes.size(); ++i) {
delete _shapes[i];
+ }
_shapes.clear();
+ if (_vqaPlayer != nullptr) {
+ _vqaPlayer->close();
+ delete _vqaPlayer;
+ _vqaPlayer = nullptr;
+ }
+
+ _vm->closeArchive("MODE.MIX");
+
+ _isOpen = false;
+
+ // TODO: Unfreeze game time
+ // TODO: _vm->_scene->resume();
+
return _selectedDestination;
}
@@ -214,14 +234,13 @@ static void spinner_mouseOutCallback(int, void*) {
static void spinner_mouseDownCallback(int, void*) {
}
-static void spinner_mouseUpCallback(int image, void *data) {
+static void spinner_mouseUpCallback(int image, void *self) {
if (image >= 0 && image < 10) {
- Spinner *spinner = (Spinner *)data;
- spinner->setSelectedDestination(image);
+ ((Spinner *)self)->setSelectedDestination(image);
}
}
-void Spinner::setIsOpen() {
+void Spinner::open() {
_isOpen = true;
}
@@ -230,18 +249,19 @@ bool Spinner::isOpen() const {
}
int Spinner::handleMouseUp(int x, int y) {
- _imagePicker->handleMouseAction(x, y, false, true, 0);
+ _imagePicker->handleMouseAction(x, y, false, true, false);
return false;
}
int Spinner::handleMouseDown(int x, int y) {
- _imagePicker->handleMouseAction(x, y, true, false, 0);
+ _imagePicker->handleMouseAction(x, y, true, false, false);
return false;
}
void Spinner::tick() {
- if (!_vm->_gameIsRunning)
+ if (!_vm->_gameIsRunning) {
return;
+ }
int frame = _vqaPlayer->update();
assert(frame >= -1);
@@ -249,8 +269,6 @@ void Spinner::tick() {
// vqaPlayer renders to _surfaceInterface
blit(_vm->_surfaceInterface, _vm->_surfaceGame);
- _imagePicker->draw(_vm->_surfaceGame);
-
Common::Point p = _vm->getMousePos();
_imagePicker->handleMouseAction(p.x, p.y, false, false, false);
if (_imagePicker->hasHoveredImage()) {
@@ -258,7 +276,9 @@ void Spinner::tick() {
} else {
_vm->_mouse->setCursor(0);
}
+ _imagePicker->draw(_vm->_surfaceGame);
_vm->_mouse->draw(_vm->_surfaceGame, p.x, p.y);
+ _imagePicker->drawTooltip(_vm->_surfaceGame, p.x, p.y);
_vm->blitToScreen(_vm->_surfaceGame);
_vm->_system->delayMillis(10);
@@ -269,8 +289,8 @@ void Spinner::setSelectedDestination(int destination) {
}
void Spinner::reset() {
- for (int i = 0; i != SPINNER_DESTINATIONS; ++i) {
- _isDestinationSelectable[i] = 0;
+ for (int i = 0; i != kSpinnerDestinations; ++i) {
+ _isDestinationSelectable[i] = false;
}
_isOpen = false;
@@ -278,13 +298,21 @@ void Spinner::reset() {
_selectedDestination = -1;
_imagePicker = nullptr;
- for (int i = 0; i != (int)_shapes.size(); ++i)
+ for (int i = 0; i != (int)_shapes.size(); ++i) {
delete _shapes[i];
+ }
_shapes.clear();
}
void Spinner::resume() {
- // TODO
+ if(_vqaPlayer == nullptr) {
+ return;
+ }
+
+ //_vqa->clear();
+ _vqaPlayer->setLoop(0, -1, kLoopSetModeImmediate, nullptr, nullptr);
+ tick();
+ _vqaPlayer->setLoop(1, -1, kLoopSetModeJustStart, nullptr, nullptr);
}
} // End of namespace BladeRunner