aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
authorPaul Gilbert2015-05-31 16:28:41 -0400
committerPaul Gilbert2015-05-31 16:28:41 -0400
commitc822e849de786f1b1be2dfbcdd3364d0b33c7297 (patch)
tree6b591c3c2c609168ba0c10e319aa850f2a7922cf /engines/sherlock
parentb01dee457a6adc2a9871e7a6007289fb7193903f (diff)
downloadscummvm-rg350-c822e849de786f1b1be2dfbcdd3364d0b33c7297.tar.gz
scummvm-rg350-c822e849de786f1b1be2dfbcdd3364d0b33c7297.tar.bz2
scummvm-rg350-c822e849de786f1b1be2dfbcdd3364d0b33c7297.zip
SHERLOCK: Move scroll variables from Screen to TattooUserInterface
Diffstat (limited to 'engines/sherlock')
-rw-r--r--engines/sherlock/scene.cpp2
-rw-r--r--engines/sherlock/screen.cpp23
-rw-r--r--engines/sherlock/screen.h14
-rw-r--r--engines/sherlock/tattoo/tattoo_scene.cpp72
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.cpp46
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.h8
-rw-r--r--engines/sherlock/user_interface.h5
7 files changed, 102 insertions, 68 deletions
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index 76fb7ae3a7..5b2cd9c1f4 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -336,7 +336,7 @@ bool Scene::loadScene(const Common::String &filename) {
screen.translatePalette(screen._cMap);
screen.setupBGArea(screen._cMap);
- screen.initScrollVars();
+ ui.initScrollVars();
// Read in background
if (_lzwMode) {
diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp
index a3af5559c7..708493cd30 100644
--- a/engines/sherlock/screen.cpp
+++ b/engines/sherlock/screen.cpp
@@ -44,10 +44,6 @@ Screen::Screen(SherlockEngine *vm) : Surface(g_system->getWidth(), g_system->get
// Rose Tattoo specific fields
_fadeBytesRead = _fadeBytesToRead = 0;
_oldFadePercent = 0;
- _scrollSize = 0;
- _scrollSpeed = 0;
- _currentScroll = 0;
- _targetScroll = 0;
_flushScreen = false;
}
@@ -310,6 +306,16 @@ void Screen::flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *
*height = newBounds.height();
}
+void Screen::blockMove(const Common::Rect &r, const Common::Point &scrollPos) {
+ Common::Rect bounds = r;
+ bounds.translate(scrollPos.x, scrollPos.y);
+ slamRect(bounds);
+}
+
+void Screen::blockMove(const Common::Point &scrollPos) {
+ blockMove(Common::Rect(0, 0, w(), h()), scrollPos);
+}
+
void Screen::print(const Common::Point &pt, byte color, const char *formatStr, ...) {
// Create the string to display
va_list args;
@@ -491,15 +497,6 @@ void Screen::setupBGArea(const byte cMap[PALETTE_SIZE]) {
warning("TODO");
}
-/**
- * Initializes scroll variables
- */
-void Screen::initScrollVars() {
- _scrollSize = 0;
- _currentScroll = 0;
- _targetScroll = 0;
-}
-
void Screen::translatePalette(byte palette[PALETTE_SIZE]) {
for (int idx = 0; idx < PALETTE_SIZE; ++idx)
palette[idx] = VGA_COLOR_TRANS(palette[idx]);
diff --git a/engines/sherlock/screen.h b/engines/sherlock/screen.h
index 8fda9cbb9c..27746731e8 100644
--- a/engines/sherlock/screen.h
+++ b/engines/sherlock/screen.h
@@ -99,8 +99,6 @@ public:
byte _cMap[PALETTE_SIZE];
byte _sMap[PALETTE_SIZE];
byte _tMap[PALETTE_SIZE];
- int _currentScroll, _targetScroll;
- int _scrollSize, _scrollSpeed;
bool _flushScreen;
public:
Screen(SherlockEngine *vm);
@@ -192,6 +190,16 @@ public:
int16 *width, int16 *height, int scaleVal);
/**
+ * Copies data from the back buffer to the screen, taking into account scrolling position
+ */
+ void blockMove(const Common::Rect &r, const Common::Point &scrollPos);
+
+ /**
+ * Copies the entire screen from the back buffer, taking into account scrolling position
+ */
+ void blockMove(const Common::Point &scorllPos);
+
+ /**
* Returns the width of a string in pixels
*/
int stringWidth(const Common::String &str);
@@ -257,8 +265,6 @@ public:
void setupBGArea(const byte cMap[PALETTE_SIZE]);
- void initScrollVars();
-
/**
* Translate a palette from 6-bit RGB values to full 8-bit values suitable for passing
* to the underlying palette manager
diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index 2a13b2a450..cd86a58d1a 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -99,8 +99,8 @@ void TattooScene::doBgAnimEraseBackground() {
if (_mask != nullptr) {
if (screen._backBuffer1.w() > screen.w())
- screen.blitFrom(screen._backBuffer1, Common::Point(0, 0), Common::Rect(screen._currentScroll, 0,
- screen._currentScroll + screen.w(), screen.h()));
+ screen.blitFrom(screen._backBuffer1, Common::Point(0, 0), Common::Rect(ui._currentScroll.x, 0,
+ ui._currentScroll.x + screen.w(), screen.h()));
else
screen.blitFrom(screen._backBuffer1);
@@ -175,22 +175,22 @@ void TattooScene::doBgAnimEraseBackground() {
}
// Adjust the Target Scroll if needed
- if ((people[people._walkControl]._position.x / FIXED_INT_MULTIPLIER - screen._currentScroll) <
+ if ((people[people._walkControl]._position.x / FIXED_INT_MULTIPLIER - ui._currentScroll.x) <
(SHERLOCK_SCREEN_WIDTH / 8) && people[people._walkControl]._delta.x < 0) {
- screen._targetScroll = (short)(people[people._walkControl]._position.x / FIXED_INT_MULTIPLIER -
+ ui._targetScroll.x = (short)(people[people._walkControl]._position.x / FIXED_INT_MULTIPLIER -
SHERLOCK_SCREEN_WIDTH / 8 - 250);
- if (screen._targetScroll < 0)
- screen._targetScroll = 0;
+ if (ui._targetScroll.x < 0)
+ ui._targetScroll.x = 0;
}
- if ((people[people._walkControl]._position.x / FIXED_INT_MULTIPLIER - screen._currentScroll) > (SHERLOCK_SCREEN_WIDTH / 4 * 3)
+ if ((people[people._walkControl]._position.x / FIXED_INT_MULTIPLIER - ui._currentScroll.x) > (SHERLOCK_SCREEN_WIDTH / 4 * 3)
&& people[people._walkControl]._delta.x > 0)
- screen._targetScroll = (short)(people[people._walkControl]._position.x / FIXED_INT_MULTIPLIER -
+ ui._targetScroll.x = (short)(people[people._walkControl]._position.x / FIXED_INT_MULTIPLIER -
SHERLOCK_SCREEN_WIDTH / 4 * 3 + 250);
- if (screen._targetScroll > screen._scrollSize)
- screen._targetScroll = screen._scrollSize;
+ if (ui._targetScroll.x > ui._scrollSize)
+ ui._targetScroll.x = ui._scrollSize;
ui.doScroll();
}
@@ -231,6 +231,7 @@ void TattooScene::doBgAnim() {
void TattooScene::doBgAnimUpdateBgObjectsAndAnim() {
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
+ TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &obj = _bgShapes[idx];
@@ -255,33 +256,33 @@ void TattooScene::doBgAnimUpdateBgObjectsAndAnim() {
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);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x);
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);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 180), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x);
if (!_vm->readFlags(880))
- screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300), screen._currentScroll);
+ screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300), ui._currentScroll.x);
break;
case 18:
- screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 203), screen._currentScroll);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 203), ui._currentScroll.x);
if (!_vm->readFlags(189))
- screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + _maskOffset.x, 239), screen._currentScroll);
+ screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + _maskOffset.x, 239), ui._currentScroll.x);
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);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x);
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);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 203), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + _maskOffset.x, 239), ui._currentScroll.x);
break;
}
}
@@ -291,38 +292,39 @@ void TattooScene::doBgAnimUpdateBgObjectsAndAnim() {
void TattooScene::updateBackground() {
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
+ TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Scene::updateBackground();
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);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x);
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);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 180), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x);
if (!_vm->readFlags(880))
- screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300), screen._currentScroll);
+ screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300), ui._currentScroll.x);
break;
case 18:
- screen._backBuffer1.maskArea((*_mask)[0], Common::Point(0, 203), screen._currentScroll);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(0, 203), ui._currentScroll.x);
if (!_vm->readFlags(189))
- screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124, 239), screen._currentScroll);
+ screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124, 239), ui._currentScroll.x);
break;
case 53:
- screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), screen._currentScroll);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), ui._currentScroll.x);
break;
case 68:
- screen._backBuffer1.maskArea((*_mask)[0], Common::Point(0, 203), screen._currentScroll);
- screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124, 239), screen._currentScroll);
+ screen._backBuffer1.maskArea((*_mask)[0], Common::Point(0, 203), ui._currentScroll.x);
+ screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124, 239), ui._currentScroll.x);
break;
default:
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index e76322833f..a97b6f78cf 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -33,6 +33,13 @@ TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm)
_invMenuBuffer = nullptr;
_tagBuffer = nullptr;
_invGraphic = nullptr;
+ _scrollSize = _scrollSpeed = 0;
+}
+
+void TattooUserInterface::initScrollVars() {
+ _scrollSize = 0;
+ _currentScroll.x = _currentScroll.y = 0;
+ _targetScroll.x = _targetScroll.y = 0;
}
void TattooUserInterface::handleInput() {
@@ -41,13 +48,14 @@ void TattooUserInterface::handleInput() {
}
void TattooUserInterface::drawInterface(int bufferNum) {
+ TattooScene &scene = *(TattooScene *)_vm->_scene;
Screen &screen = *_vm->_screen;
- TattooEngine &vm = *((TattooEngine *)_vm);
+ TattooEngine &vm = *(TattooEngine *)_vm;
if (_invMenuBuffer != nullptr) {
Common::Rect r = _invMenuBounds;
r.grow(-3);
- r.translate(-screen._currentScroll, 0);
+ r.translate(-_currentScroll.x, 0);
_grayAreas.clear();
_grayAreas.push_back(r);
@@ -58,7 +66,7 @@ void TattooUserInterface::drawInterface(int bufferNum) {
if (_menuBuffer != nullptr) {
Common::Rect r = _menuBounds;
r.grow(-3);
- r.translate(-screen._currentScroll, 0);
+ r.translate(-_currentScroll.x, 0);
_grayAreas.clear();
_grayAreas.push_back(r);
@@ -76,6 +84,14 @@ void TattooUserInterface::drawInterface(int bufferNum) {
if (vm._creditsActive)
vm.drawCredits();
+
+ // Bring the widgets to the screen
+ if (scene._mask != nullptr)
+ screen._flushScreen = true;
+
+ //if (screen._flushScreen)
+ // screen.blockMove(_currentScroll.x);
+
}
void TattooUserInterface::doBgAnimRestoreUI() {
@@ -118,27 +134,27 @@ void TattooUserInterface::doBgAnimRestoreUI() {
void TattooUserInterface::doScroll() {
Screen &screen = *_vm->_screen;
- int oldScroll = screen._currentScroll;
+ int oldScroll = _currentScroll.x;
// If we're already at the target scroll position, nothing needs to be done
- if (screen._targetScroll == screen._currentScroll)
+ if (_targetScroll.x == _currentScroll.x)
return;
screen._flushScreen = true;
- if (screen._targetScroll > screen._currentScroll) {
- screen._currentScroll += screen._scrollSpeed;
- if (screen._currentScroll > screen._targetScroll)
- screen._currentScroll = screen._targetScroll;
- } else if (screen._targetScroll < screen._currentScroll) {
- screen._currentScroll -= screen._scrollSpeed;
- if (screen._currentScroll < screen._targetScroll)
- screen._currentScroll = screen._targetScroll;
+ if (_targetScroll.x > _currentScroll.x) {
+ _currentScroll.x += _scrollSpeed;
+ if (_currentScroll.x > _targetScroll.x)
+ _currentScroll.x = _targetScroll.x;
+ } else if (_targetScroll.x < _currentScroll.x) {
+ _currentScroll.x -= _scrollSpeed;
+ if (_currentScroll.x < _targetScroll.x)
+ _currentScroll.x = _targetScroll.x;
}
if (_menuBuffer != nullptr)
- _menuBounds.translate(screen._currentScroll - oldScroll, 0);
+ _menuBounds.translate(_currentScroll.x - oldScroll, 0);
if (_invMenuBuffer != nullptr)
- _invMenuBounds.translate(screen._currentScroll - oldScroll, 0);
+ _invMenuBounds.translate(_currentScroll.x - oldScroll, 0);
}
void TattooUserInterface::drawGrayAreas() {
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index 2125f1ba07..fea9ca8442 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -51,6 +51,9 @@ private:
*/
void drawGrayAreas();
public:
+ Common::Point _currentScroll, _targetScroll;
+ int _scrollSize, _scrollSpeed;
+public:
TattooUserInterface(SherlockEngine *vm);
/**
@@ -74,6 +77,11 @@ public:
* Draw the user interface onto the screen's back buffers
*/
virtual void drawInterface(int bufferNum = 3);
+
+ /**
+ * Initializes scroll variables
+ */
+ virtual void initScrollVars();
};
} // End of namespace Tattoo
diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h
index 042997a3e2..c7a398741e 100644
--- a/engines/sherlock/user_interface.h
+++ b/engines/sherlock/user_interface.h
@@ -123,6 +123,11 @@ public:
* Print the previously selected object's decription
*/
virtual void printObjectDesc() {}
+
+ /**
+ * Initializes scroll variables
+ */
+ virtual void initScrollVars() {}
};
} // End of namespace Sherlock