Skip to content

Commit

Permalink
SHERLOCK: More RT doBgAnim code, interface draw
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed May 30, 2015
1 parent 074669a commit c9bfc5c
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 7 deletions.
4 changes: 4 additions & 0 deletions engines/sherlock/objects.cpp
Expand Up @@ -1151,6 +1151,10 @@ CAnimStream::CAnimStream() {
_zPlacement = 0;
}

void CAnimStream::getNextFrame() {
// TODO
}

/*----------------------------------------------------------------*/

SceneImage::SceneImage() {
Expand Down
2 changes: 2 additions & 0 deletions engines/sherlock/objects.h
Expand Up @@ -429,6 +429,8 @@ struct CAnimStream {
int _zPlacement; // Used by doBgAnim for determining Z order

CAnimStream();

void getNextFrame();
};

struct SceneImage {
Expand Down
10 changes: 5 additions & 5 deletions engines/sherlock/scene.h
Expand Up @@ -183,11 +183,6 @@ class Scene {
* will remain the same on future visits to the scene
*/
void saveSceneStatus();

/**
* Draw all the shapes, people and NPCs in the correct order
*/
void drawAllShapes();
protected:
SherlockEngine *_vm;

Expand All @@ -198,6 +193,11 @@ class Scene {
*/
virtual void checkBgShapes();

/**
* Draw all the shapes, people and NPCs in the correct order
*/
void drawAllShapes();

Scene(SherlockEngine *vm);
public:
int _currentScene;
Expand Down
6 changes: 6 additions & 0 deletions engines/sherlock/surface.cpp
Expand Up @@ -96,6 +96,12 @@ void Surface::transBlitFrom(const ImageFrame &src, const Common::Point &pt,
transBlitFrom(src._frame, pt + src._offset, flipped, overrideColor);
}

void Surface::transBlitFrom(const Surface &src, const Common::Point &pt,
bool flipped, int overrideColor) {
const Graphics::Surface &s = src._surface;
transBlitFrom(s, pt, flipped, overrideColor);
}

void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &pt,
bool flipped, int overrideColor) {
Common::Rect drawRect(0, 0, src.w, src.h);
Expand Down
4 changes: 4 additions & 0 deletions engines/sherlock/tattoo/tattoo.cpp
Expand Up @@ -68,6 +68,10 @@ void TattooEngine::loadInitialPalette() {
delete stream;
}

void TattooEngine::drawCredits() {
// TODO
}

void TattooEngine::eraseCredits() {
// TODO
}
Expand Down
5 changes: 5 additions & 0 deletions engines/sherlock/tattoo/tattoo.h
Expand Up @@ -53,6 +53,11 @@ class TattooEngine : public SherlockEngine {
TattooEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
virtual ~TattooEngine() {}

/**
* Draw credits on the screen
*/
void drawCredits();

/**
* Erase any area of the screen covered by credits
*/
Expand Down
69 changes: 68 additions & 1 deletion engines/sherlock/tattoo/tattoo_scene.cpp
Expand Up @@ -196,6 +196,8 @@ void TattooScene::doBgAnimEraseBackground() {
}

void TattooScene::doBgAnim() {
TattooUserInterface &ui = *((TattooUserInterface *)_vm->_ui);

doBgAnimCheckCursor();

// Events &events = *_vm->_events;
Expand All @@ -208,7 +210,7 @@ void TattooScene::doBgAnim() {
talk._talkToAbort = false;

// Check the characters and sprites for updates
for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
for (uint idx = 0; idx < MAX_CHARACTERS; ++idx) {
if (people[idx]._type == CHARACTER)
people[idx].checkSprite();
}
Expand All @@ -220,8 +222,73 @@ void TattooScene::doBgAnim() {

// Erase any affected background areas
doBgAnimEraseBackground();

doBgAnimUpdateBgObjectsAndAnim();

ui.drawInterface();
}

void TattooScene::doBgAnimUpdateBgObjectsAndAnim() {
TattooEngine &vm = *((TattooEngine *)_vm);
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;

for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &obj = _bgShapes[idx];
if (obj._type == ACTIVE_BG_SHAPE || obj._type == NO_SHAPE)
obj.adjustObject();
}

for (uint idx = 0; idx < MAX_CHARACTERS; ++idx) {
if (people[idx]._type == CHARACTER)
people[idx].adjustSprite();
}

if (_activeCAnim._images != nullptr != _activeCAnim._zPlacement != REMOVE) {
_activeCAnim.getNextFrame();
}

// Flag the bg shapes which need to be redrawn
checkBgShapes();
drawAllShapes();


if (_mask != nullptr) {
switch (_currentScene) {
case 7:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), screen._currentScroll);
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), screen._currentScroll);
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110), screen._currentScroll);
break;

case 8:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180), screen._currentScroll);
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 180), screen._currentScroll);
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180), screen._currentScroll);
if (!_vm->readFlags(880))
screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300), screen._currentScroll);
break;

case 18:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 203), screen._currentScroll);
if (!_vm->readFlags(189))
screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + _maskOffset.x, 239), screen._currentScroll);
break;

case 53:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), screen._currentScroll);
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), screen._currentScroll);
break;

case 68:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 203), screen._currentScroll);
screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + _maskOffset.x, 239), screen._currentScroll);
break;
}
}
}


void TattooScene::updateBackground() {
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
Expand Down
5 changes: 5 additions & 0 deletions engines/sherlock/tattoo/tattoo_scene.h
Expand Up @@ -39,6 +39,11 @@ class TattooScene : public Scene {
void doBgAnimCheckCursor();

void doBgAnimEraseBackground();

/**
* Update the background objects and canimations as part of doBgAnim
*/
void doBgAnimUpdateBgObjectsAndAnim();
protected:
/**
* Checks all the background shapes. If a background shape is animating,
Expand Down
46 changes: 45 additions & 1 deletion engines/sherlock/tattoo/tattoo_user_interface.cpp
Expand Up @@ -22,7 +22,7 @@

#include "sherlock/tattoo/tattoo_user_interface.h"
#include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/sherlock.h"
#include "sherlock/tattoo/tattoo.h"

namespace Sherlock {

Expand All @@ -31,13 +31,53 @@ namespace Tattoo {
TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm) {
_menuBuffer = nullptr;
_invMenuBuffer = nullptr;
_tagBuffer = nullptr;
_invGraphic = nullptr;
}

void TattooUserInterface::handleInput() {
// TODO
_vm->_events->pollEventsAndWait();
}

void TattooUserInterface::drawInterface(int bufferNum) {
Screen &screen = *_vm->_screen;
TattooEngine &vm = *((TattooEngine *)_vm);

if (_invMenuBuffer != nullptr) {
Common::Rect r = _invMenuBounds;
r.grow(-3);
r.translate(-screen._currentScroll, 0);
_grayAreas.clear();
_grayAreas.push_back(r);

drawGrayAreas();
screen._backBuffer1.transBlitFrom(*_invMenuBuffer, Common::Point(_invMenuBounds.left, _invMenuBounds.top));
}

if (_menuBuffer != nullptr) {
Common::Rect r = _menuBounds;
r.grow(-3);
r.translate(-screen._currentScroll, 0);
_grayAreas.clear();
_grayAreas.push_back(r);

drawGrayAreas();
screen._backBuffer1.transBlitFrom(*_menuBuffer, Common::Point(_invMenuBounds.left, _invMenuBounds.top));
}

// See if we need to draw a Text Tag floating with the cursor
if (_tagBuffer != nullptr)
screen._backBuffer1.transBlitFrom(*_tagBuffer, Common::Point(_tagBounds.left, _tagBounds.top));

// See if we need to draw an Inventory Item Graphic floating with the cursor
if (_invGraphic != nullptr)
screen._backBuffer1.transBlitFrom(*_invGraphic, Common::Point(_invGraphicBounds.left, _invGraphicBounds.top));

if (vm._creditsActive)
vm.drawCredits();
}

void TattooUserInterface::doBgAnimRestoreUI() {
TattooScene &scene = *((TattooScene *)_vm->_scene);
Screen &screen = *_vm->_screen;
Expand Down Expand Up @@ -101,6 +141,10 @@ void TattooUserInterface::doScroll() {
_invMenuBounds.translate(screen._currentScroll - oldScroll, 0);
}

void TattooUserInterface::drawGrayAreas() {
// TODO
}

} // End of namespace Tattoo

} // End of namespace Sherlock
15 changes: 15 additions & 0 deletions engines/sherlock/tattoo/tattoo_user_interface.h
Expand Up @@ -36,10 +36,20 @@ class TattooUserInterface : public UserInterface {
Common::Rect _oldMenuBounds;
Common::Rect _invMenuBounds;
Common::Rect _oldInvMenuBounds;
Common::Rect _tagBounds;
Common::Rect _oldTagBounds;
Common::Rect _invGraphicBounds;
Common::Rect _oldInvGraphicBounds;
Surface *_menuBuffer;
Surface *_invMenuBuffer;
Surface *_tagBuffer;
Surface *_invGraphic;
Common::Array<Common::Rect> _grayAreas;
private:
/**
* Draws designated areas of the screen that are meant to be grayed out using grayscale colors
*/
void drawGrayAreas();
public:
TattooUserInterface(SherlockEngine *vm);

Expand All @@ -59,6 +69,11 @@ class TattooUserInterface : public UserInterface {
* Main input handler for the user interface
*/
virtual void handleInput();

/**
* Draw the user interface onto the screen's back buffers
*/
virtual void drawInterface(int bufferNum = 3);
};

} // End of namespace Tattoo
Expand Down

0 comments on commit c9bfc5c

Please sign in to comment.