ACCESS: Split the bubble box code from Room into it's own file
This commit is contained in:
parent
3e61eb9cc3
commit
404c7cd5d3
8 changed files with 229 additions and 146 deletions
|
@ -33,6 +33,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
|
||||||
_gameDescription(gameDesc), Engine(syst), _randomSource("Access"),
|
_gameDescription(gameDesc), Engine(syst), _randomSource("Access"),
|
||||||
_useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
|
_useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
|
||||||
_animation = nullptr;
|
_animation = nullptr;
|
||||||
|
_bubbleBox = nullptr;
|
||||||
_debugger = nullptr;
|
_debugger = nullptr;
|
||||||
_events = nullptr;
|
_events = nullptr;
|
||||||
_files = nullptr;
|
_files = nullptr;
|
||||||
|
@ -102,6 +103,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
|
||||||
|
|
||||||
AccessEngine::~AccessEngine() {
|
AccessEngine::~AccessEngine() {
|
||||||
delete _animation;
|
delete _animation;
|
||||||
|
delete _bubbleBox;
|
||||||
delete _debugger;
|
delete _debugger;
|
||||||
delete _events;
|
delete _events;
|
||||||
delete _files;
|
delete _files;
|
||||||
|
@ -142,6 +144,7 @@ void AccessEngine::initialize() {
|
||||||
// Create sub-objects of the engine
|
// Create sub-objects of the engine
|
||||||
ASurface::init();
|
ASurface::init();
|
||||||
_animation = new AnimationManager(this);
|
_animation = new AnimationManager(this);
|
||||||
|
_bubbleBox = new BubbleBox(this);
|
||||||
_debugger = new Debugger(this);
|
_debugger = new Debugger(this);
|
||||||
_events = new EventsManager(this);
|
_events = new EventsManager(this);
|
||||||
_files = new FileManager(this);
|
_files = new FileManager(this);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
#include "access/animation.h"
|
#include "access/animation.h"
|
||||||
|
#include "access/bubble_box.h"
|
||||||
#include "access/data.h"
|
#include "access/data.h"
|
||||||
#include "access/debugger.h"
|
#include "access/debugger.h"
|
||||||
#include "access/events.h"
|
#include "access/events.h"
|
||||||
|
@ -104,6 +105,7 @@ protected:
|
||||||
virtual void playGame() = 0;
|
virtual void playGame() = 0;
|
||||||
public:
|
public:
|
||||||
AnimationManager *_animation;
|
AnimationManager *_animation;
|
||||||
|
BubbleBox *_bubbleBox;
|
||||||
Debugger *_debugger;
|
Debugger *_debugger;
|
||||||
EventsManager *_events;
|
EventsManager *_events;
|
||||||
FileManager *_files;
|
FileManager *_files;
|
||||||
|
|
144
engines/access/bubble_box.cpp
Normal file
144
engines/access/bubble_box.cpp
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common/algorithm.h"
|
||||||
|
#include "access/bubble_box.h"
|
||||||
|
#include "access/access.h"
|
||||||
|
|
||||||
|
namespace Access {
|
||||||
|
|
||||||
|
Box::Box(AccessEngine *vm) : Manager(vm) {
|
||||||
|
_edgeSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box::doBox(int item, int box) {
|
||||||
|
error("TODO: doBox");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
BubbleBox::BubbleBox(AccessEngine *vm) : Box(vm) {
|
||||||
|
_bubblePtr = nullptr;
|
||||||
|
_maxChars = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BubbleBox::load(Common::SeekableReadStream *stream) {
|
||||||
|
_bubbleTitle.clear();
|
||||||
|
|
||||||
|
byte v;
|
||||||
|
while ((v = stream->readByte()) != 0)
|
||||||
|
_bubbleTitle += (char)v;
|
||||||
|
|
||||||
|
_bubblePtr = _bubbleTitle.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BubbleBox::clearBubbles() {
|
||||||
|
_bubbles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BubbleBox::placeBubble() {
|
||||||
|
BubbleBox::_maxChars = 27;
|
||||||
|
placeBubble1();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BubbleBox::placeBubble1() {
|
||||||
|
BubbleBox::clearBubbles();
|
||||||
|
_vm->_fonts._charSet._lo = 1;
|
||||||
|
_vm->_fonts._charSet._hi = 8;
|
||||||
|
_vm->_fonts._charFor._lo = 29;
|
||||||
|
_vm->_fonts._charFor._hi = 32;
|
||||||
|
|
||||||
|
calcBubble();
|
||||||
|
|
||||||
|
Common::Rect r = BubbleBox::_bubbles[0];
|
||||||
|
r.translate(-2, 0);
|
||||||
|
_vm->_screen->saveBlock(r);
|
||||||
|
printBubble();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BubbleBox::calcBubble() {
|
||||||
|
// Save points
|
||||||
|
Common::Point printOrg = _vm->_fonts._printOrg;
|
||||||
|
Common::Point printStart = _vm->_fonts._printStart;
|
||||||
|
|
||||||
|
// Figure out maximum width allowed
|
||||||
|
if (_edgeSize == 4) {
|
||||||
|
_vm->_fonts._printMaxX = 110;
|
||||||
|
} else {
|
||||||
|
_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(BubbleBox::_bubblePtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start of with a rect with the given starting x and y
|
||||||
|
Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y);
|
||||||
|
|
||||||
|
// Loop through getting lines
|
||||||
|
Common::String msg(BubbleBox::_bubblePtr);
|
||||||
|
Common::String line;
|
||||||
|
int width = 0;
|
||||||
|
bool lastLine;
|
||||||
|
do {
|
||||||
|
lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width);
|
||||||
|
width = MIN(width, _vm->_fonts._printMaxX);
|
||||||
|
|
||||||
|
_vm->_fonts._printOrg.y += 6;
|
||||||
|
_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
|
||||||
|
} while (!lastLine);
|
||||||
|
|
||||||
|
if (_edgeSize == 4)
|
||||||
|
++_vm->_fonts._printOrg.y += 6;
|
||||||
|
|
||||||
|
// Determine the width for the area
|
||||||
|
width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5;
|
||||||
|
if (width >= 24)
|
||||||
|
width += 20 - ((width - 24) % 20);
|
||||||
|
bounds.setWidth(width);
|
||||||
|
|
||||||
|
// Determine the height for area
|
||||||
|
int y = _vm->_fonts._printOrg.y + 6;
|
||||||
|
if (_edgeSize == 4)
|
||||||
|
y += 6;
|
||||||
|
int height = y - bounds.top;
|
||||||
|
bounds.setHeight(height);
|
||||||
|
|
||||||
|
height -= (_edgeSize == 4) ? 30 : 24;
|
||||||
|
if (height >= 0)
|
||||||
|
bounds.setHeight(bounds.height() + 13 - (height % 13));
|
||||||
|
|
||||||
|
// Add the new bounds to the bubbles list
|
||||||
|
BubbleBox::_bubbles.push_back(bounds);
|
||||||
|
|
||||||
|
// Restore points
|
||||||
|
_vm->_fonts._printOrg = printOrg;
|
||||||
|
_vm->_fonts._printStart = printStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BubbleBox::printBubble() {
|
||||||
|
//drawBubble(BubbleBox::_bubbles.size() - 1);
|
||||||
|
error("TODO: printBubble");
|
||||||
|
}
|
||||||
|
|
||||||
|
void BubbleBox::drawBubble(int index) {
|
||||||
|
_bounds = BubbleBox::_bubbles[index];
|
||||||
|
doBox(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End of namespace Access
|
75
engines/access/bubble_box.h
Normal file
75
engines/access/bubble_box.h
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ACCESS_BUBBLE_BOX_H
|
||||||
|
#define ACCESS_BUBBLE_BOX_H
|
||||||
|
|
||||||
|
#include "common/scummsys.h"
|
||||||
|
#include "common/array.h"
|
||||||
|
#include "common/rect.h"
|
||||||
|
#include "common/stream.h"
|
||||||
|
#include "common/types.h"
|
||||||
|
#include "graphics/surface.h"
|
||||||
|
#include "access/data.h"
|
||||||
|
|
||||||
|
namespace Access {
|
||||||
|
|
||||||
|
class AccessEngine;
|
||||||
|
|
||||||
|
class Box: public Manager {
|
||||||
|
public:
|
||||||
|
int _edgeSize;
|
||||||
|
Common::Rect _bounds;
|
||||||
|
public:
|
||||||
|
Box(AccessEngine *vm);
|
||||||
|
|
||||||
|
void doBox(int item, int box);
|
||||||
|
};
|
||||||
|
|
||||||
|
class BubbleBox: public Box {
|
||||||
|
public:
|
||||||
|
Common::String _bubbleTitle;
|
||||||
|
const char *_bubblePtr;
|
||||||
|
int _maxChars;
|
||||||
|
Common::Array<Common::Rect> _bubbles;
|
||||||
|
public:
|
||||||
|
BubbleBox(AccessEngine *vm);
|
||||||
|
|
||||||
|
void load(Common::SeekableReadStream *stream);
|
||||||
|
|
||||||
|
void clearBubbles();
|
||||||
|
|
||||||
|
void placeBubble();
|
||||||
|
void placeBubble1();
|
||||||
|
|
||||||
|
void calcBubble();
|
||||||
|
|
||||||
|
void printBubble();
|
||||||
|
|
||||||
|
void drawBubble(int index);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // End of namespace Access
|
||||||
|
|
||||||
|
#endif /* ACCESS_BUBBLE_BOX_H */
|
|
@ -4,6 +4,7 @@ MODULE_OBJS := \
|
||||||
animation.o \
|
animation.o \
|
||||||
asurface.o \
|
asurface.o \
|
||||||
access.o \
|
access.o \
|
||||||
|
bubble_box.o \
|
||||||
data.o \
|
data.o \
|
||||||
debugger.o \
|
debugger.o \
|
||||||
decompress.o \
|
decompress.o \
|
||||||
|
|
|
@ -584,96 +584,6 @@ int Room::validateBox(int boxId) {
|
||||||
return _vm->_scripts->executeScript();
|
return _vm->_scripts->executeScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::placeBubble() {
|
|
||||||
_bubbleBox._maxChars = 27;
|
|
||||||
placeBubble1();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::placeBubble1() {
|
|
||||||
_bubbleBox.clearBubbles();
|
|
||||||
_vm->_fonts._charSet._lo = 1;
|
|
||||||
_vm->_fonts._charSet._hi = 8;
|
|
||||||
_vm->_fonts._charFor._lo = 29;
|
|
||||||
_vm->_fonts._charFor._hi = 32;
|
|
||||||
|
|
||||||
calcBubble();
|
|
||||||
|
|
||||||
Common::Rect r = _bubbleBox._bubbles[0];
|
|
||||||
r.translate(-2, 0);
|
|
||||||
_vm->_screen->saveBlock(r);
|
|
||||||
printBubble();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::calcBubble() {
|
|
||||||
// Save points
|
|
||||||
Common::Point printOrg = _vm->_fonts._printOrg;
|
|
||||||
Common::Point printStart = _vm->_fonts._printStart;
|
|
||||||
|
|
||||||
// Figure out maximum width allowed
|
|
||||||
if (_bubbleBox._type == 4) {
|
|
||||||
_vm->_fonts._printMaxX = 110;
|
|
||||||
} else {
|
|
||||||
_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleBox._bubblePtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start of with a rect with the given starting x and y
|
|
||||||
Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y);
|
|
||||||
|
|
||||||
// Loop through getting lines
|
|
||||||
Common::String msg(_bubbleBox._bubblePtr);
|
|
||||||
Common::String line;
|
|
||||||
int width = 0;
|
|
||||||
bool lastLine;
|
|
||||||
do {
|
|
||||||
lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width);
|
|
||||||
width = MIN(width, _vm->_fonts._printMaxX);
|
|
||||||
|
|
||||||
_vm->_fonts._printOrg.y += 6;
|
|
||||||
_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
|
|
||||||
} while (!lastLine);
|
|
||||||
|
|
||||||
if (_bubbleBox._type == 4)
|
|
||||||
++_vm->_fonts._printOrg.y += 6;
|
|
||||||
|
|
||||||
// Determine the width for the area
|
|
||||||
width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5;
|
|
||||||
if (width >= 24)
|
|
||||||
width += 20 - ((width - 24) % 20);
|
|
||||||
bounds.setWidth(width);
|
|
||||||
|
|
||||||
// Determine the height for area
|
|
||||||
int y = _vm->_fonts._printOrg.y + 6;
|
|
||||||
if (_bubbleBox._type == 4)
|
|
||||||
y += 6;
|
|
||||||
int height = y - bounds.top;
|
|
||||||
bounds.setHeight(height);
|
|
||||||
|
|
||||||
height -= (_bubbleBox._type == 4) ? 30 : 24;
|
|
||||||
if (height >= 0)
|
|
||||||
bounds.setHeight(bounds.height() + 13 - (height % 13));
|
|
||||||
|
|
||||||
// Add the new bounds to the bubbles list
|
|
||||||
_bubbleBox._bubbles.push_back(bounds);
|
|
||||||
|
|
||||||
// Restore points
|
|
||||||
_vm->_fonts._printOrg = printOrg;
|
|
||||||
_vm->_fonts._printStart = printStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::printBubble() {
|
|
||||||
//drawBubble(_bubbleBox._bubbles.size() - 1);
|
|
||||||
error("TODO: printBubble");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::drawBubble(int index) {
|
|
||||||
_bubbleBox._bounds = _bubbleBox._bubbles[index];
|
|
||||||
doBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::doBox() {
|
|
||||||
error("TODO: doBox");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
RoomInfo::RoomInfo(const byte *data) {
|
RoomInfo::RoomInfo(const byte *data) {
|
||||||
|
@ -732,28 +642,4 @@ RoomInfo::RoomInfo(const byte *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
BubbleBox::BubbleBox() {
|
|
||||||
_type = 2;
|
|
||||||
_bounds = Common::Rect(64, 32, 130, 122);
|
|
||||||
_bubblePtr = nullptr;
|
|
||||||
_maxChars = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BubbleBox::load(Common::SeekableReadStream *stream) {
|
|
||||||
_bubbleTitle.clear();
|
|
||||||
|
|
||||||
byte v;
|
|
||||||
while ((v = stream->readByte()) != 0)
|
|
||||||
_bubbleTitle += (char)v;
|
|
||||||
|
|
||||||
_bubblePtr = _bubbleTitle.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BubbleBox::clearBubbles() {
|
|
||||||
_bubbles.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // End of namespace Access
|
} // End of namespace Access
|
||||||
|
|
|
@ -58,22 +58,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class BubbleBox {
|
|
||||||
public:
|
|
||||||
int _type;
|
|
||||||
Common::Rect _bounds;
|
|
||||||
Common::String _bubbleTitle;
|
|
||||||
const char *_bubblePtr;
|
|
||||||
int _maxChars;
|
|
||||||
Common::Array<Common::Rect> _bubbles;
|
|
||||||
public:
|
|
||||||
BubbleBox();
|
|
||||||
|
|
||||||
void load(Common::SeekableReadStream *stream);
|
|
||||||
|
|
||||||
void clearBubbles();
|
|
||||||
};
|
|
||||||
|
|
||||||
class Room: public Manager {
|
class Room: public Manager {
|
||||||
private:
|
private:
|
||||||
void roomLoop();
|
void roomLoop();
|
||||||
|
@ -125,10 +109,11 @@ protected:
|
||||||
virtual void roomMenu() = 0;
|
virtual void roomMenu() = 0;
|
||||||
|
|
||||||
virtual void mainAreaClick() = 0;
|
virtual void mainAreaClick() = 0;
|
||||||
|
public:
|
||||||
|
virtual void setIconPalette() {}
|
||||||
public:
|
public:
|
||||||
Plotter _plotter;
|
Plotter _plotter;
|
||||||
Common::Array<JetFrame> _jetFrame;
|
Common::Array<JetFrame> _jetFrame;
|
||||||
BubbleBox _bubbleBox;
|
|
||||||
int _function;
|
int _function;
|
||||||
int _roomFlag;
|
int _roomFlag;
|
||||||
byte *_playField;
|
byte *_playField;
|
||||||
|
@ -156,21 +141,8 @@ public:
|
||||||
void buildRow(int playY, int screenY);
|
void buildRow(int playY, int screenY);
|
||||||
|
|
||||||
void init4Quads();
|
void init4Quads();
|
||||||
|
|
||||||
virtual void setIconPalette() {}
|
|
||||||
void placeBubble();
|
|
||||||
void placeBubble1();
|
|
||||||
|
|
||||||
void calcBubble();
|
|
||||||
|
|
||||||
void printBubble();
|
|
||||||
|
|
||||||
void drawBubble(int index);
|
|
||||||
|
|
||||||
void doBox();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class RoomInfo {
|
class RoomInfo {
|
||||||
public:
|
public:
|
||||||
struct FileIdent {
|
struct FileIdent {
|
||||||
|
|
|
@ -117,7 +117,7 @@ void Scripts::executeCommand(int commandIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scripts::CMDOBJECT() {
|
void Scripts::CMDOBJECT() {
|
||||||
_vm->_room->_bubbleBox.load(_data);
|
_vm->_bubbleBox->load(_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); }
|
void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); }
|
||||||
|
@ -176,7 +176,7 @@ void Scripts::cmdPrint() {
|
||||||
_vm->_timers[PRINT_TIMER]._initTm = 50;
|
_vm->_timers[PRINT_TIMER]._initTm = 50;
|
||||||
_vm->_timers[PRINT_TIMER]._flag = true;
|
_vm->_timers[PRINT_TIMER]._flag = true;
|
||||||
|
|
||||||
_vm->_room->placeBubble();
|
_vm->_bubbleBox->placeBubble();
|
||||||
_vm->_events->waitKeyMouse();
|
_vm->_events->waitKeyMouse();
|
||||||
|
|
||||||
while (_vm->_timers[PRINT_TIMER]._flag) {
|
while (_vm->_timers[PRINT_TIMER]._flag) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue