mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-02 08:19:19 +00:00
NANCY: Remove static members of GraphicsManager
Made GraphicsManager's static members non-static.
This commit is contained in:
parent
16c083d015
commit
1907b5f741
@ -33,8 +33,8 @@ namespace Nancy {
|
||||
namespace Action {
|
||||
|
||||
void LeverPuzzle::init() {
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), GraphicsManager::getInputPixelFormat());
|
||||
_drawSurface.clear(GraphicsManager::getTransColor());
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
_drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
|
||||
|
||||
setTransparent(true);
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace Action {
|
||||
void OrderingPuzzle::init() {
|
||||
// Screen position is initialized in readData and fits exactly the bounds of all elements on screen.
|
||||
// This is a hacky way to make this particular action record work with this implementation's graphics manager
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), GraphicsManager::getInputPixelFormat());
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
clearAllElements();
|
||||
|
||||
setTransparent(true);
|
||||
@ -223,12 +223,12 @@ void OrderingPuzzle::undrawElement(uint id) {
|
||||
Common::Rect bounds = _destRects[id];
|
||||
bounds.translate(-_screenPosition.left, -_screenPosition.top);
|
||||
|
||||
_drawSurface.fillRect(bounds, GraphicsManager::getTransColor());
|
||||
_drawSurface.fillRect(bounds, g_nancy->_graphicsManager->getTransColor());
|
||||
_needsRedraw = true;
|
||||
}
|
||||
|
||||
void OrderingPuzzle::clearAllElements() {
|
||||
_drawSurface.clear(GraphicsManager::getTransColor());
|
||||
_drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
|
||||
setVisible(false);
|
||||
_clickedSequence.clear();
|
||||
return;
|
||||
|
@ -35,8 +35,8 @@ namespace Nancy {
|
||||
namespace Action {
|
||||
|
||||
void PasswordPuzzle::init() {
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), GraphicsManager::getInputPixelFormat());
|
||||
_drawSurface.clear(GraphicsManager::getTransColor());
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
_drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
|
||||
|
||||
setTransparent(true);
|
||||
|
||||
@ -219,7 +219,7 @@ void PasswordPuzzle::onPause(bool pause) {
|
||||
}
|
||||
|
||||
void PasswordPuzzle::drawText() {
|
||||
_drawSurface.clear(GraphicsManager::getTransColor());
|
||||
_drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
|
||||
const Graphics::Font *font = g_nancy->_graphicsManager->getFont(_fontID);
|
||||
|
||||
Common::Rect bounds = _nameBounds;
|
||||
|
@ -35,8 +35,8 @@ namespace Nancy {
|
||||
namespace Action {
|
||||
|
||||
void RotatingLockPuzzle::init() {
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), GraphicsManager::getInputPixelFormat());
|
||||
_drawSurface.clear(GraphicsManager::getTransColor());
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
_drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
|
||||
|
||||
setTransparent(true);
|
||||
|
||||
|
@ -72,7 +72,7 @@ void PlaySecondaryMovie::init() {
|
||||
}
|
||||
|
||||
_decoder.loadFile(_videoName + ".avf");
|
||||
_drawSurface.create(_decoder.getWidth(), _decoder.getHeight(), GraphicsManager::getInputPixelFormat());
|
||||
_drawSurface.create(_decoder.getWidth(), _decoder.getHeight(), g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
_screenPosition = _drawSurface.getBounds();
|
||||
|
||||
RenderObject::init();
|
||||
|
@ -49,7 +49,7 @@ void PlaySecondaryVideo::init() {
|
||||
// Every secondary video frame (in nancy1) plays exactly 12ms slower than what its metadata says.
|
||||
// I'm still not sure how/why that happens so for now I'm using this hack to fix the timings
|
||||
_decoder.addFrameTime(12);
|
||||
_drawSurface.create(_decoder.getWidth(), _decoder.getHeight(), GraphicsManager::getInputPixelFormat());
|
||||
_drawSurface.create(_decoder.getWidth(), _decoder.getHeight(), g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
|
||||
if (_paletteFilename.size()) {
|
||||
GraphicsManager::loadSurfacePalette(_drawSurface, _paletteFilename);
|
||||
|
@ -35,8 +35,8 @@ namespace Nancy {
|
||||
namespace Action {
|
||||
|
||||
void SliderPuzzle::init() {
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), GraphicsManager::getInputPixelFormat());
|
||||
_drawSurface.clear(GraphicsManager::getTransColor());
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
_drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
|
||||
|
||||
setTransparent(true);
|
||||
|
||||
@ -310,7 +310,7 @@ void SliderPuzzle::drawTile(int tileID, uint posX, uint posY) {
|
||||
void SliderPuzzle::undrawTile(uint posX, uint posY) {
|
||||
Common::Rect bounds = _destRects[posY][posX];
|
||||
bounds.translate(-_screenPosition.left, -_screenPosition.top);
|
||||
_drawSurface.fillRect(bounds, GraphicsManager::getTransColor());
|
||||
_drawSurface.fillRect(bounds, g_nancy->_graphicsManager->getTransColor());
|
||||
|
||||
_needsRedraw = true;
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ namespace Nancy {
|
||||
namespace Action {
|
||||
|
||||
void Telephone::init() {
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), GraphicsManager::getInputPixelFormat());
|
||||
_drawSurface.clear(GraphicsManager::getTransColor());
|
||||
_drawSurface.create(_screenPosition.width(), _screenPosition.height(), g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
_drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
|
||||
|
||||
setTransparent(true);
|
||||
|
||||
@ -316,7 +316,7 @@ void Telephone::undrawButton(uint id) {
|
||||
Common::Rect bounds = _destRects[id];
|
||||
bounds.translate(-_screenPosition.left, -_screenPosition.top);
|
||||
|
||||
_drawSurface.fillRect(bounds, GraphicsManager::getTransColor());
|
||||
_drawSurface.fillRect(bounds, g_nancy->_graphicsManager->getTransColor());
|
||||
_needsRedraw = true;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ void CursorManager::setCursor(CursorType type, int16 itemID) {
|
||||
s.copyRectToSurface(*surf, 0, 0, bounds);
|
||||
|
||||
// TODO hotspots are terrible for arrow cursors, fix that??
|
||||
CursorMan.replaceCursor(s.getPixels(), s.w, s.h, hotspot.x, hotspot.y, GraphicsManager::getTransColor(), false, &GraphicsManager::getInputPixelFormat());
|
||||
CursorMan.replaceCursor(s.getPixels(), s.w, s.h, hotspot.x, hotspot.y, g_nancy->_graphicsManager->getTransColor(), false, &g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
|
||||
s.free();
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
namespace Nancy {
|
||||
|
||||
void Font::read(Common::SeekableReadStream &stream) {
|
||||
_transColor = GraphicsManager::getTransColor();
|
||||
_transColor = g_nancy->_graphicsManager->getTransColor();
|
||||
_maxCharWidth = 0;
|
||||
_fontHeight = 0;
|
||||
|
||||
@ -97,7 +97,7 @@ void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 col
|
||||
|
||||
for (uint curY = 0; curY < height; ++curY) {
|
||||
for (uint curX = 0; curX < width; ++curX) {
|
||||
switch (GraphicsManager::getInputPixelFormat().bytesPerPixel) {
|
||||
switch (g_nancy->_graphicsManager->getInputPixelFormat().bytesPerPixel) {
|
||||
case 1:
|
||||
// TODO
|
||||
break;
|
||||
|
@ -39,9 +39,11 @@
|
||||
|
||||
namespace Nancy {
|
||||
|
||||
const Graphics::PixelFormat GraphicsManager::_inputPixelFormat = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
|
||||
const Graphics::PixelFormat GraphicsManager::_screenPixelFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
|
||||
const Graphics::PixelFormat GraphicsManager::_clut8Format = Graphics::PixelFormat::createFormatCLUT8();
|
||||
GraphicsManager::GraphicsManager() :
|
||||
_objects(objectComparator),
|
||||
_inputPixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),
|
||||
_screenPixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0),
|
||||
_clut8Format(Graphics::PixelFormat::createFormatCLUT8()) {}
|
||||
|
||||
void GraphicsManager::init() {
|
||||
initGraphics(640, 480, &_screenPixelFormat);
|
||||
@ -232,6 +234,10 @@ const Graphics::PixelFormat &GraphicsManager::getInputPixelFormat() {
|
||||
}
|
||||
}
|
||||
|
||||
const Graphics::PixelFormat &GraphicsManager::getScreenPixelFormat() {
|
||||
return _screenPixelFormat;
|
||||
}
|
||||
|
||||
uint GraphicsManager::getTransColor() {
|
||||
if (g_nancy->getGameFlags() & NGF_8BITCOLOR) {
|
||||
return 1; // If this isn't correct, try picking the pixel at [0, 0] inside the palette bitmap
|
||||
|
@ -37,7 +37,7 @@ class NancyEngine;
|
||||
// Graphics class that handles multilayered surface rendering with minimal redraw
|
||||
class GraphicsManager {
|
||||
public:
|
||||
GraphicsManager() : _objects(objectComparator) {}
|
||||
GraphicsManager();
|
||||
|
||||
void init();
|
||||
void draw();
|
||||
@ -50,16 +50,17 @@ public:
|
||||
|
||||
const Font *getFont(uint id) const { return id < _fonts.size() ? &_fonts[id] : nullptr; }
|
||||
|
||||
const Graphics::PixelFormat &getInputPixelFormat();
|
||||
const Graphics::PixelFormat &getScreenPixelFormat();
|
||||
uint getTransColor();
|
||||
|
||||
static void loadSurfacePalette(Graphics::ManagedSurface &inSurf, const Common::String paletteFilename);
|
||||
static void copyToManaged(const Graphics::Surface &src, Graphics::ManagedSurface &dst, bool verticalFlip = false, bool doubleSize = false);
|
||||
static void copyToManaged(void *src, Graphics::ManagedSurface &dst, uint srcW, uint srcH, const Graphics::PixelFormat &format, bool verticalFlip = false, bool doubleSize = false);
|
||||
|
||||
static const Graphics::PixelFormat &getInputPixelFormat();
|
||||
static uint getTransColor();
|
||||
|
||||
Graphics::ManagedSurface _object0;
|
||||
|
||||
static const Graphics::PixelFormat _screenPixelFormat;
|
||||
Graphics::PixelFormat _screenPixelFormat;
|
||||
|
||||
private:
|
||||
void loadFonts();
|
||||
@ -69,8 +70,8 @@ private:
|
||||
|
||||
Common::SortedArray<RenderObject *> _objects;
|
||||
|
||||
static const Graphics::PixelFormat _inputPixelFormat;
|
||||
static const Graphics::PixelFormat _clut8Format;
|
||||
Graphics::PixelFormat _inputPixelFormat;
|
||||
Graphics::PixelFormat _clut8Format;
|
||||
|
||||
Graphics::Screen _screen;
|
||||
Common::Array<Font> _fonts;
|
||||
|
@ -60,7 +60,7 @@ void RenderObject::setVisible(bool visible) {
|
||||
|
||||
void RenderObject::setTransparent(bool isTransparent) {
|
||||
if (isTransparent) {
|
||||
_drawSurface.setTransparentColor(GraphicsManager::getTransColor());
|
||||
_drawSurface.setTransparentColor(g_nancy->_graphicsManager->getTransColor());
|
||||
} else {
|
||||
_drawSurface.clearTransparentColor();
|
||||
}
|
||||
|
@ -789,7 +789,7 @@ bool ResourceManager::loadImage(const Common::String &name, Graphics::Surface &s
|
||||
surf.h = info.height;
|
||||
surf.pitch = info.pitch;
|
||||
surf.setPixels(buf);
|
||||
surf.format = GraphicsManager::getInputPixelFormat();
|
||||
surf.format = g_nancy->_graphicsManager->getInputPixelFormat();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -830,7 +830,7 @@ bool ResourceManager::loadImage(const Common::String &name, Graphics::ManagedSur
|
||||
return false;
|
||||
}
|
||||
|
||||
GraphicsManager::copyToManaged(buf, surf, info.width, info.height, GraphicsManager::getInputPixelFormat());
|
||||
GraphicsManager::copyToManaged(buf, surf, info.width, info.height, g_nancy->_graphicsManager->getInputPixelFormat());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ void InventoryBox::init() {
|
||||
g_nancy->_resource->loadImage(inventoryBoxIconsImageName, _iconsSurface);
|
||||
|
||||
uint numItems = 11; // TODO
|
||||
_fullInventorySurface.create(_screenPosition.width(), _screenPosition.height() * ((numItems / 4) + 1), GraphicsManager::_screenPixelFormat);
|
||||
_fullInventorySurface.create(_screenPosition.width(), _screenPosition.height() * ((numItems / 4) + 1), g_nancy->_graphicsManager->getScreenPixelFormat());
|
||||
Common::Rect sourceRect = _screenPosition;
|
||||
sourceRect.moveTo(0, 0);
|
||||
_drawSurface.create(_fullInventorySurface, sourceRect);
|
||||
@ -223,7 +223,7 @@ void InventoryBox::InventoryScrollbar::init() {
|
||||
|
||||
void InventoryBox::Shades::init() {
|
||||
Common::Rect bounds = _parent->getBounds();
|
||||
_drawSurface.create(bounds.width(), bounds.height(), GraphicsManager::_screenPixelFormat);
|
||||
_drawSurface.create(bounds.width(), bounds.height(), g_nancy->_graphicsManager->getScreenPixelFormat());
|
||||
_screenPosition = _parent->getScreenPosition();
|
||||
_nextFrameTime = 0;
|
||||
setAnimationFrame(_curFrame);
|
||||
@ -274,7 +274,7 @@ void InventoryBox::Shades::setAnimationFrame(uint frame) {
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
_drawSurface.clear(GraphicsManager::getTransColor());
|
||||
_drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
|
||||
|
||||
// Draw left shade
|
||||
srcRect = _parent->_shadesSrc[frame * 2];
|
||||
|
@ -55,7 +55,7 @@ void Textbox::init() {
|
||||
chunk->seek(0x20);
|
||||
Common::Rect innerBoundingBox;
|
||||
readRect(*chunk, innerBoundingBox);
|
||||
_fullSurface.create(innerBoundingBox.width(), innerBoundingBox.height(), GraphicsManager::_screenPixelFormat);
|
||||
_fullSurface.create(innerBoundingBox.width(), innerBoundingBox.height(), g_nancy->_graphicsManager->getScreenPixelFormat());
|
||||
|
||||
_scrollbarDefaultDest.x = chunk->readUint16LE();
|
||||
_scrollbarDefaultDest.y = chunk->readUint16LE();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "engines/nancy/video.h"
|
||||
#include "engines/nancy/decompress.h"
|
||||
#include "engines/nancy/graphics.h"
|
||||
#include "engines/nancy/nancy.h"
|
||||
|
||||
#include "common/endian.h"
|
||||
#include "common/stream.h"
|
||||
@ -110,7 +111,7 @@ AVFDecoder::AVFVideoTrack::AVFVideoTrack(Common::SeekableReadStream *stream, uin
|
||||
error("Unknown compression type %d found in AVF", comp);
|
||||
|
||||
_surface = new Graphics::Surface();
|
||||
_pixelFormat = GraphicsManager::getInputPixelFormat();
|
||||
_pixelFormat = g_nancy->_graphicsManager->getInputPixelFormat();
|
||||
_surface->create(_width, _height, _pixelFormat);
|
||||
_frameSize = _width * _height * _pixelFormat.bytesPerPixel;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user