aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2018-04-22 14:49:44 +0200
committerJoseph-Eugene Winzer2019-02-06 09:42:11 +0100
commitbd298f3b3d9159c4d1be7d007994a69324c3c745 (patch)
tree75f877ce6c743d7b43b1fea55efc7e62be87396b
parent437b1c00036fbdf38688281a898133c3cb7a394f (diff)
downloadscummvm-rg350-bd298f3b3d9159c4d1be7d007994a69324c3c745.tar.gz
scummvm-rg350-bd298f3b3d9159c4d1be7d007994a69324c3c745.tar.bz2
scummvm-rg350-bd298f3b3d9159c4d1be7d007994a69324c3c745.zip
SUPERNOVA: Removes GameManager dependency for Screen
All calls from Screen member functions to the GameManager instance are relocated to the wrapper functions in SupernovaEngine.
-rw-r--r--engines/supernova/screen.cpp47
-rw-r--r--engines/supernova/screen.h8
-rw-r--r--engines/supernova/supernova.cpp15
3 files changed, 34 insertions, 36 deletions
diff --git a/engines/supernova/screen.cpp b/engines/supernova/screen.cpp
index 2c441acf7b..124bddd77b 100644
--- a/engines/supernova/screen.cpp
+++ b/engines/supernova/screen.cpp
@@ -168,9 +168,8 @@ void Marquee::renderCharacter() {
}
}
-Screen::Screen(SupernovaEngine *vm, GameManager *gm, ResourceManager *resMan)
+Screen::Screen(SupernovaEngine *vm, ResourceManager *resMan)
: _vm(vm)
- , _gm(gm)
, _resMan(resMan)
, _currentImage(nullptr)
, _viewportBrightness(255)
@@ -208,6 +207,10 @@ const MSNImage *Screen::getCurrentImage() const {
return _currentImage;
}
+const Screen::ImageInfo *Screen::getImageInfo(ImageId id) const {
+ return &imageInfo[(int)id];
+}
+
bool Screen::isMessageShown() const {
return _messageShown;
}
@@ -327,21 +330,16 @@ void Screen::renderText(StringId stringId, int x, int y, byte color) {
renderText(_vm->getGameString(stringId), x, y, color);
}
-void Screen::renderImageSection(const MSNImage *image, int section) {
+void Screen::renderImageSection(const MSNImage *image, int section, bool invert) {
// Note: inverting means we are removing the section. So we should get the rect for that
// section but draw the background (section 0) instead.
- bool invert = false;
- if (section > 128) {
- section -= 128;
- invert = true;
- }
if (section > image->_numSections - 1)
return;
Common::Rect sectionRect(image->_section[section].x1,
- image->_section[section].y1,
- image->_section[section].x2 + 1,
- image->_section[section].y2 + 1);
+ image->_section[section].y1,
+ image->_section[section].x2 + 1,
+ image->_section[section].y2 + 1);
if (image->_filenumber == 1 || image->_filenumber == 2) {
sectionRect.setWidth(640);
sectionRect.setHeight(480);
@@ -383,11 +381,7 @@ void Screen::renderImage(ImageId id, bool removeImage) {
}
do {
- if (removeImage)
- renderImageSection(image, info.section + 128);
- else
- renderImageSection(image, info.section);
-
+ renderImageSection(image, info.section, removeImage);
info.section = image->_section[info.section].next;
} while (info.section != 0);
}
@@ -396,20 +390,14 @@ void Screen::renderImage(int section) {
if (!_currentImage)
return;
- bool sectionVisible = true;
-
+ bool removeImage = false;
if (section > 128) {
- sectionVisible = false;
+ removeImage = true;
section -= 128;
}
- _gm->_currentRoom->setSectionVisible(section, sectionVisible);
-
do {
- if (sectionVisible)
- renderImageSection(_currentImage, section);
- else
- renderImageSection(_currentImage, section + 128);
+ renderImageSection(_currentImage, section, removeImage);
section = _currentImage->_section[section].next;
} while (section != 0);
}
@@ -443,7 +431,7 @@ void Screen::renderRoom(Room &room) {
int section = i;
if (room.isSectionVisible(section)) {
do {
- renderImageSection(_currentImage, section);
+ renderImageSection(_currentImage, section, false);
section = _currentImage->_section[section].next;
} while (section != 0);
}
@@ -554,7 +542,6 @@ void Screen::renderMessage(const char *text, MessagePosition position) {
}
_messageShown = true;
- _gm->_messageDuration = (Common::strnlen(text, 512) + 20) * _vm->_textSpeed / 10;
}
void Screen::removeMessage() {
@@ -613,9 +600,9 @@ void Screen::paletteFadeOut() {
_vm->_system->updateScreen();
}
-void Screen::paletteFadeIn() {
+void Screen::paletteFadeIn(int maxViewportBrightness) {
while (_guiBrightness < 245) {
- if (_viewportBrightness < _gm->_roomBrightness)
+ if (_viewportBrightness < maxViewportBrightness)
_viewportBrightness += 10;
_guiBrightness += 10;
paletteBrightness();
@@ -623,7 +610,7 @@ void Screen::paletteFadeIn() {
_vm->_system->delayMillis(_vm->_delay);
}
_guiBrightness = 255;
- _viewportBrightness = _gm->_roomBrightness;
+ _viewportBrightness = maxViewportBrightness;
paletteBrightness();
_vm->_system->updateScreen();
}
diff --git a/engines/supernova/screen.h b/engines/supernova/screen.h
index d57fb53ed2..bcffe61fc9 100644
--- a/engines/supernova/screen.h
+++ b/engines/supernova/screen.h
@@ -132,15 +132,16 @@ public:
static int textWidth(const Common::String &text);
public:
- Screen(SupernovaEngine *vm, GameManager *gm, ResourceManager *resMan);
+ Screen(SupernovaEngine *vm, ResourceManager *resMan);
int getViewportBrightness() const;
void setViewportBrightness(int brightness);
int getGuiBrightness() const;
void setGuiBrightness(int brightness);
const MSNImage *getCurrentImage() const;
+ const ImageInfo *getImageInfo(ImageId id) const;
bool isMessageShown() const;
- void paletteFadeIn();
+ void paletteFadeIn(int maxViewportBrightness);
void paletteFadeOut();
void paletteBrightness();
void renderImage(ImageId id, bool removeImage = false);
@@ -174,11 +175,10 @@ public:
void update();
private:
- void renderImageSection(const MSNImage *image, int section);
+ void renderImageSection(const MSNImage *image, int section, bool invert);
private:
SupernovaEngine *_vm;
- GameManager *_gm;
ResourceManager *_resMan;
const MSNImage *_currentImage;
ScreenBufferStack _screenBuffer;
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 833589c6c7..34d40640c7 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -136,7 +136,7 @@ void SupernovaEngine::init() {
_resMan = new ResourceManager();
_sound = new Sound(_mixer, _resMan);
_gm = new GameManager(this, _sound);
- _screen = new Screen(this, _gm, _resMan);
+ _screen = new Screen(this, _resMan);
_console = new Console(this, _gm);
setTotalPlayTime(0);
@@ -244,10 +244,16 @@ void SupernovaEngine::playSound(MusicId index) {
}
void SupernovaEngine::renderImage(int section) {
+ if (section > 128)
+ _gm->_currentRoom->setSectionVisible(section - 128, false);
+ else
+ _gm->_currentRoom->setSectionVisible(section, true);
+
_screen->renderImage(section);
}
void SupernovaEngine::renderImage(ImageId id, bool removeImage) {
+ _gm->_currentRoom->setSectionVisible(_screen->getImageInfo(id)->section, !removeImage);
_screen->renderImage(id, removeImage);
}
@@ -271,14 +277,17 @@ void SupernovaEngine::renderRoom(Room &room) {
}
void SupernovaEngine::renderMessage(const char *text, MessagePosition position) {
+ _gm->_messageDuration = (Common::strnlen(text, 512) + 20) * _textSpeed / 10;
_screen->renderMessage(text, position);
}
void SupernovaEngine::renderMessage(const Common::String &text, MessagePosition position) {
+ _gm->_messageDuration = (text.size() + 20) * _textSpeed / 10;
_screen->renderMessage(text, position);
}
void SupernovaEngine::renderMessage(StringId stringId, MessagePosition position, Common::String var1, Common::String var2) {
+ _gm->_messageDuration = (getGameString(stringId).size() + 20) * _textSpeed / 10;
_screen->renderMessage(stringId, position, var1, var2);
}
@@ -329,6 +338,7 @@ void SupernovaEngine::renderBox(int x, int y, int width, int height, byte color)
void SupernovaEngine::renderBox(const GuiElement &guiElement) {
_screen->renderBox(guiElement);
}
+
void SupernovaEngine::paletteBrightness() {
_screen->paletteBrightness();
}
@@ -338,7 +348,8 @@ void SupernovaEngine::paletteFadeOut() {
}
void SupernovaEngine::paletteFadeIn() {
- _screen->paletteFadeIn();
+ _gm->roomBrightness();
+ _screen->paletteFadeIn(_gm->_roomBrightness);
}
void SupernovaEngine::setColor63(byte value) {