From 9e21dc42eecf14c69af7c0e39428f24616c8cf23 Mon Sep 17 00:00:00 2001 From: Joseph-Eugene Winzer Date: Sat, 24 Jun 2017 14:45:23 +0200 Subject: SUPERNOVA: Implements rendering of newspaper articles The resolution will change dynamically depending what image is about to be rendered. As there are no other GUI elements shown that depend on the screen resolution when the artciles are rendered, there shouldn't be any problems. --- engines/supernova/supernova.cpp | 38 ++++++++++++++++++++++++++++++-------- engines/supernova/supernova.h | 2 ++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index 99cc867682..297365513c 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -98,6 +98,8 @@ SupernovaEngine::SupernovaEngine(OSystem *syst) , _sectionIndex(0) , _delay(33) , _gameRunning(true) + , _screenWidth(320) + , _screenHeight(200) { // const Common::FSNode gameDataDir(ConfMan.get("path")); // SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); @@ -119,8 +121,8 @@ SupernovaEngine::~SupernovaEngine() { } Common::Error SupernovaEngine::run() { - initGraphics(kScreenWidth, kScreenHeight); GameManager gm(this, &_event); + initGraphics(_screenWidth, _screenHeight); _console = new Console(this, &gm); initData(); @@ -253,17 +255,37 @@ void SupernovaEngine::renderImage(MSNImageDecoder &image, int section, bool full image.loadSection(section); _system->getPaletteManager()->setPalette(image.getPalette(), 16, 239); paletteBrightness(); + + Common::Rect sectionRect(image._section[section].x1, + image._section[section].y1, + image._section[section].x2 - image._section[section].x1, + image._section[section].y2 - image._section[section].y1); + if (image._filenumber == 1 || image._filenumber == 2) { + sectionRect.setWidth(640); + sectionRect.setHeight(480); + + if (_screenWidth != 640) { + _screenWidth = 640; + _screenHeight = 480; + initGraphics(_screenWidth, _screenHeight); + } + } else { + if (_screenWidth != 320) { + _screenWidth = 320; + _screenHeight = 200; + initGraphics(_screenWidth, _screenHeight); + } + } + if (fullscreen) { _system->copyRectToScreen(image.getSurface()->getPixels(), - image._pitch, 0, 0, kScreenWidth, kScreenHeight); + image._pitch, 0, 0, _screenWidth, _screenHeight); } else { - uint offset = image._section[section].y1 * 320 + image._section[section].x1; + uint offset = image._section[section].y1 * image._pitch + image._section[section].x1; _system->copyRectToScreen(static_cast(image.getSurface()->getPixels()) + offset, - 320, - image._section[section].x1, - image._section[section].y1, - image._section[section].x2 - image._section[section].x1, - image._section[section].y2 - image._section[section].y1); + image._pitch, + sectionRect.top, sectionRect.left, + sectionRect.width(), sectionRect.height()); } } diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index 16b9b4e130..db9919ecc4 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -88,6 +88,8 @@ public: } _soundSamples[kAudioNumSamples]; Common::Event _event; bool _gameRunning; + int _screenWidth; + int _screenHeight; byte _imageIndex; byte _sectionIndex; -- cgit v1.2.3