diff options
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/events.cpp | 1 | ||||
-rw-r--r-- | engines/xeen/font.cpp | 10 | ||||
-rw-r--r-- | engines/xeen/menus.cpp | 35 | ||||
-rw-r--r-- | engines/xeen/menus.h | 14 | ||||
-rw-r--r-- | engines/xeen/screen.cpp | 16 | ||||
-rw-r--r-- | engines/xeen/screen.h | 10 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 1 | ||||
-rw-r--r-- | engines/xeen/xsurface.cpp | 21 | ||||
-rw-r--r-- | engines/xeen/xsurface.h | 4 |
9 files changed, 69 insertions, 43 deletions
diff --git a/engines/xeen/events.cpp b/engines/xeen/events.cpp index fd0871edbc..285005af98 100644 --- a/engines/xeen/events.cpp +++ b/engines/xeen/events.cpp @@ -55,6 +55,7 @@ void EventsManager::setCursor(int cursorId) { _sprites.draw(cursor, cursorId); CursorMan.replaceCursor(cursor.getPixels(), cursor.w, cursor.h, 0, 0, 0); + showCursor(); } /** diff --git a/engines/xeen/font.cpp b/engines/xeen/font.cpp index dd1b4dc321..018536b5bf 100644 --- a/engines/xeen/font.cpp +++ b/engines/xeen/font.cpp @@ -124,6 +124,7 @@ Common::String FontSurface::writeString(const Common::String &s, const Common::R _writePos.x += _fontReduced ? 3 : 4; } else if (c == '\r') { fillRect(bounds, _bgColor); + addDirtyRect(bounds); _writePos = Common::Point(bounds.left, bounds.top); } else if (c == 1) { // Turn off reduced font mode @@ -146,8 +147,9 @@ Common::String FontSurface::writeString(const Common::String &s, const Common::R Common::Point pt = _writePos; if (_fontJustify == JUSTIFY_RIGHT) pt.x -= w; - fillRect(Common::Rect(pt.x, pt.y, pt.x + w, pt.y + (_fontReduced ? 9 : 10)), - _bgColor); + + Common::Rect r(pt.x, pt.y, pt.x + w, pt.y + (_fontReduced ? 9 : 10)); + fillRect(r, _bgColor); } else if (c == 5) { continue; } else if (c == 6) { @@ -194,7 +196,7 @@ Common::String FontSurface::writeString(const Common::String &s, const Common::R break; } else if (c == 11) { // Skip y position - int yp = fontAtoi( ); + int yp = fontAtoi(); _writePos.y = MIN(bounds.top + yp, (int)bounds.bottom); } else if (c == 12) { // Set text colors @@ -330,6 +332,8 @@ void FontSurface::writeChar(char c) { } } + addDirtyRect(Common::Rect(_writePos.x, _writePos.y, _writePos.x + FONT_WIDTH, + _writePos.y + FONT_HEIGHT)); _writePos.x += _fontData[0x1000 + charIndex]; } diff --git a/engines/xeen/menus.cpp b/engines/xeen/menus.cpp index 0a7b0307c6..4e2226819a 100644 --- a/engines/xeen/menus.cpp +++ b/engines/xeen/menus.cpp @@ -43,8 +43,8 @@ void Dialog::restoreButtons() { _buttons = _savedButtons.pop(); } -void Dialog::addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool d) { - _buttons.push_back(DialogButton(bounds, c, sprites, d)); +void Dialog::addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw = true) { + _buttons.push_back(DialogButton(bounds, c, sprites, draw)); } void Dialog::checkEvents() { @@ -118,9 +118,9 @@ void OptionsMenu::execute() { startup(title1, title2); SpriteResource title1Sprites(title1), title2Sprites(title2); - bool firstTime = true; + bool firstTime = true, doFade = true; while (!_vm->shouldQuit()) { - setBackground(); + setBackground(doFade); events.setCursor(0); if (firstTime) { @@ -128,7 +128,7 @@ void OptionsMenu::execute() { warning("TODO: Read existing save file"); } - for (;;) { + while (!_vm->shouldQuit()) { showTitles1(title1Sprites); showTitles2(); @@ -199,17 +199,17 @@ void OptionsMenu::showTitles2() { } void OptionsMenu::setupButtons(SpriteResource *buttons) { - addButton(Common::Rect(124, 87, 124 + 53, 87 + 10), 'S', buttons, true); - addButton(Common::Rect(126, 98, 126 + 47, 98 + 10), 'L', buttons, true); - addButton(Common::Rect(91, 110, 91 + 118, 110 + 10), 'C', buttons, true); - addButton(Common::Rect(85, 121, 85 + 131, 121 + 10), 'O', buttons, true); + addButton(Common::Rect(124, 87, 124 + 53, 87 + 10), 'S', buttons, false); + addButton(Common::Rect(126, 98, 126 + 47, 98 + 10), 'L', buttons, false); + addButton(Common::Rect(91, 110, 91 + 118, 110 + 10), 'C', buttons, false); + addButton(Common::Rect(85, 121, 85 + 131, 121 + 10), 'O', buttons, false); } void WorldOptionsMenu::setupButtons(SpriteResource *buttons) { - addButton(Common::Rect(93, 53, 93 + 134, 53 + 20), 'S', buttons, false); - addButton(Common::Rect(93, 78, 93 + 134, 78 + 20), 'L', buttons, false); - addButton(Common::Rect(93, 103, 93 + 134, 103 + 20), 'C', buttons, false); - addButton(Common::Rect(93, 128, 93 + 134, 128 + 20), 'O', buttons, false); + addButton(Common::Rect(93, 53, 93 + 134, 53 + 20), 'S', buttons, true); + addButton(Common::Rect(93, 78, 93 + 134, 78 + 20), 'L', buttons, true); + addButton(Common::Rect(93, 103, 93 + 134, 103 + 20), 'C', buttons, true); + addButton(Common::Rect(93, 128, 93 + 134, 128 + 20), 'O', buttons, true); } /*------------------------------------------------------------------------*/ @@ -337,15 +337,16 @@ void WorldOptionsMenu::startup(Common::String &title1, Common::String &title2) { Screen &screen = *_vm->_screen; screen.fadeOut(4); screen.loadPalette("dark.pal"); - screen.fadeIn(0x81); _vm->_events->clearEvents(); } -void WorldOptionsMenu::setBackground() { +void WorldOptionsMenu::setBackground(bool doFade) { Screen &screen = *_vm->_screen; screen.loadBackground("world.raw"); screen.saveBackground(); - screen.fadeIn(4); + + if (doFade) + screen.fadeIn(4); } void WorldOptionsMenu::openWindow() { @@ -368,7 +369,7 @@ void WorldOptionsMenu::showContents(SpriteResource &title1, bool waitFlag) { for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) { DialogButton &btn = _buttons[btnIndex]; - if (btn._d) { + if (btn._draw) { btn._sprites->draw(screen._windows[0], btnIndex * 2, Common::Point(btn._bounds.left, btn._bounds.top)); } diff --git a/engines/xeen/menus.h b/engines/xeen/menus.h index 8cc004ac6f..65e3553110 100644 --- a/engines/xeen/menus.h +++ b/engines/xeen/menus.h @@ -35,12 +35,12 @@ public: Common::Rect _bounds; SpriteResource *_sprites; char _c; - bool _d; + bool _draw; - DialogButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool d) : - _bounds(bounds), _c(c), _sprites(sprites), _d(d) {} + DialogButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw) : + _bounds(bounds), _c(c), _sprites(sprites), _draw(draw) {} - DialogButton() : _c('\0'), _sprites(nullptr), _d(false) {} + DialogButton() : _c('\0'), _sprites(nullptr), _draw(false) {} }; class Dialog { @@ -63,7 +63,7 @@ public: void restoreButtons(); - void addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool d); + void addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw); }; class SettingsBaseDialog : public Dialog { @@ -80,7 +80,7 @@ protected: protected: virtual void startup(Common::String &title1, Common::String &title2) = 0; - virtual void setBackground() {} + virtual void setBackground(bool doFade) {} virtual void showTitles1(SpriteResource &sprites); @@ -115,7 +115,7 @@ private: protected: virtual void startup(Common::String &title1, Common::String &title2); - virtual void setBackground(); + virtual void setBackground(bool doFade); virtual void showTitles2() {} diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp index 757251ac2a..7b1dd1b724 100644 --- a/engines/xeen/screen.cpp +++ b/engines/xeen/screen.cpp @@ -29,7 +29,7 @@ namespace Xeen { -Window::Window() : _vm(nullptr), _enabled(false), _a(0), _border(0), +Window::Window() : _vm(nullptr), _enabled(false), _a(0), _border(0), _xLo(0), _xHi(0), _ycL(0), _ycH(0) { } @@ -38,6 +38,7 @@ Window::Window(XeenEngine *vm, const Common::Rect &bounds, int a, int border, _vm(vm), _enabled(false), _a(a), _border(border), _xLo(xLo), _ycL(ycL), _xHi(xHi), _ycH(ycH) { setBounds(bounds); + create(_vm->_screen, Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } void Window::setBounds(const Common::Rect &r) { @@ -48,6 +49,7 @@ void Window::setBounds(const Common::Rect &r) { void Window::open() { if (!_enabled) { + _enabled = true; _vm->_screen->_windowStack.push_back(this); open2(); } @@ -58,10 +60,9 @@ void Window::open() { } void Window::open2() { - create(_bounds.width(), _bounds.height()); - copyRectToSurface(*_vm->_screen, 0, 0, _bounds); _dirtyRects.push(_bounds); frame(); + fill(); } void Window::frame() { @@ -173,7 +174,8 @@ void Window::writeString(const Common::String &s) { Screen::Screen(XeenEngine *vm) : _vm(vm) { _fadeIn = false; create(SCREEN_WIDTH, SCREEN_HEIGHT); - setupWindows(); + Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); + Common::fill(&_mainPalette[0], &_mainPalette[PALETTE_SIZE], 0); // Load font data for the screen File f("fnt"); @@ -257,6 +259,7 @@ void Screen::update() { } void Screen::addDirtyRect(const Common::Rect &r) { + assert(r.isValidRect() && r.width() > 0 && r.height() > 0); _dirtyRects.push_back(r); } @@ -304,7 +307,7 @@ bool Screen::unionRectangle(Common::Rect &destRect, const Common::Rect &src1, co void Screen::loadPalette(const Common::String &name) { File f(name); for (int i = 0; i < PALETTE_SIZE; ++i) - _tempPaltte[i] = f.readByte() << 2; + _tempPalette[i] = f.readByte() << 2; } /** @@ -411,7 +414,7 @@ void Screen::fadeInner(int step) { } else { // Create a scaled palette from the temporary one for (int i = 0; i < PALETTE_SIZE; ++i) { - _mainPalette[i] = (_tempPaltte[i] * val * 2) >> 8; + _mainPalette[i] = (_tempPalette[i] * val * 2) >> 8; } updatePalette(); @@ -438,7 +441,6 @@ void Screen::restoreBackground(int slot) { assert(slot > 0 && slot < 10); _savedScreens[slot - 1].blitTo(*this); - _savedScreens[slot - 1].free(); } diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h index 4fd19d17eb..41b2821c29 100644 --- a/engines/xeen/screen.h +++ b/engines/xeen/screen.h @@ -81,13 +81,11 @@ private: XeenEngine *_vm; Common::List<Common::Rect> _dirtyRects; byte _mainPalette[PALETTE_SIZE]; - byte _tempPaltte[PALETTE_SIZE]; + byte _tempPalette[PALETTE_SIZE]; XSurface _pages[2]; XSurface _savedScreens[10]; bool _fadeIn; - void setupWindows(); - void mergeDirtyRects(); bool unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2); @@ -110,6 +108,8 @@ public: virtual ~Screen(); + void setupWindows(); + void closeWindows(); void update(); @@ -132,9 +132,9 @@ public: void fadeOut(int step); - void saveBackground(int slot = 0); + void saveBackground(int slot = 1); - void restoreBackground(int slot = 0); + void restoreBackground(int slot = 1); }; } // End of namespace Xeen diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index 372bbb1b46..1027572c67 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -62,6 +62,7 @@ void XeenEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); _screen = new Screen(this); + _screen->setupWindows(); _sound = new SoundManager(this); File f("029.obj"); diff --git a/engines/xeen/xsurface.cpp b/engines/xeen/xsurface.cpp index cd21a588ef..dc42a6fb24 100644 --- a/engines/xeen/xsurface.cpp +++ b/engines/xeen/xsurface.cpp @@ -27,21 +27,34 @@ namespace Xeen { -XSurface::XSurface() : Graphics::Surface() { +XSurface::XSurface() : Graphics::Surface(), _freeFlag(false) { } -XSurface::XSurface(int w, int h) : Graphics::Surface() { +XSurface::XSurface(int w, int h) : Graphics::Surface(), _freeFlag(false) { create(w, h); } XSurface::~XSurface() { - free(); + if (_freeFlag) + free(); } void XSurface::create(uint16 w, uint16 h) { Graphics::Surface::create(w, h, Graphics::PixelFormat::createFormatCLUT8()); + _freeFlag = true; } +void XSurface::create(XSurface *s, const Common::Rect &bounds) { + pixels = (byte *)s->getBasePtr(bounds.left, bounds.top); + format = Graphics::PixelFormat::createFormatCLUT8(); + pitch = s->pitch; + w = bounds.width(); + h = bounds.height(); + + _freeFlag = false; +} + + void XSurface::transBlitTo(XSurface &dest) const { transBlitTo(dest, Common::Point()); } @@ -78,7 +91,7 @@ void XSurface::blitTo(XSurface &dest, const Common::Point &destPos) const { Common::copy(srcP, srcP + w, destP); } - dest.addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + w, destPos.y)); + dest.addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + w, destPos.y + h)); } } // End of namespace Xeen diff --git a/engines/xeen/xsurface.h b/engines/xeen/xsurface.h index 64cdab0953..263ea5336f 100644 --- a/engines/xeen/xsurface.h +++ b/engines/xeen/xsurface.h @@ -31,6 +31,8 @@ namespace Xeen { class XSurface: public Graphics::Surface { +private: + bool _freeFlag; public: virtual void addDirtyRect(const Common::Rect &r) {} public: @@ -40,6 +42,8 @@ public: void create(uint16 w, uint16 h); + void create(XSurface *s, const Common::Rect &bounds); + void transBlitTo(XSurface &dest) const; void transBlitTo(XSurface &dest, const Common::Point &destPos) const; |