diff options
-rw-r--r-- | doc/de/Neues | 2 | ||||
-rw-r--r-- | engines/drascula/graphics.cpp | 31 | ||||
-rw-r--r-- | engines/wage/macwindow.cpp | 11 | ||||
-rw-r--r-- | engines/wage/macwindow.h | 11 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.cpp | 46 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.h | 17 |
6 files changed, 101 insertions, 17 deletions
diff --git a/doc/de/Neues b/doc/de/Neues index 6ab66015a7..106dc6ea88 100644 --- a/doc/de/Neues +++ b/doc/de/Neues @@ -38,7 +38,7 @@ Programmcodes finden Sie auf Englisch unter: SAGA: - Fehlerhafte Farben der Bedienelemente in der französischen und deutschen - Version von "I Have No Mouth and I Must Screm" korrigiert. + Version von "I Have No Mouth and I Must Scream" korrigiert. SCI: - Cursor-Hilfsroutinen funktionieren nun korrekt auf OpenPandora und anderen diff --git a/engines/drascula/graphics.cpp b/engines/drascula/graphics.cpp index 4ed949cc99..01bd267158 100644 --- a/engines/drascula/graphics.cpp +++ b/engines/drascula/graphics.cpp @@ -319,12 +319,27 @@ int DrasculaEngine::print_abc_opc(const char *said, int screenY, int game) { } bool DrasculaEngine::textFitsCentered(char *text, int x) { - int halfLen = (strlen(text) / 2) * CHAR_WIDTH; + int textLen = strlen(text); + int halfLen = (textLen / 2) * CHAR_WIDTH; - // See comment in centerText() + //if (x > 160) + // x = 315 - x; + //return (halfLen <= x); + + // The commented out code above is what the original engine is doing. Instead of testing the + // upper bound if x is greater than 160 it takes the complement to 315 and test only the lower + // bounds. + // Also note that since it does an integer division to compute the half length of the string, + // in the case where the string has an odd number of characters there is one more character to + // the right than to the left. If the string center is beyond 160, this is taken care of by + // taking the complement to 315 instead of 320. But if the string center is close to the screen + // center, but not greater than 160, this can lead to the string being accepted despite having + // one character beyond the right edge of the screen. + // In ScummVM we therefore also test the right edge, which leads to differences + // with the original engine, but for the better. if (x > 160) - x = 315 - x; - return (halfLen <= x); + return (315 - x - halfLen >= 0); + return (x - halfLen >= 0 && x + halfLen + (textLen % 2) * CHAR_WIDTH <= 320); } void DrasculaEngine::centerText(const char *message, int textX, int textY) { @@ -337,13 +352,7 @@ void DrasculaEngine::centerText(const char *message, int textX, int textY) { // return (x - halfLen >= 0 && x + halfLen <= 319); // The engines does things differently though. It tries to clips text at 315 instead of 319. - // And instead of testing the upper bound if x is greater than 160 it takes the complement to 315 - // and test only the lower bounds. However since 160 is not the middle of 315, we end up having - // text that can go beyond 315 (up to 320) if x is in [159, 160]. - // Also note that if the numbers of characters is odd, there is one more character to the right - // than to the left as it computes the half length with an integer division by two BEFORE multiplying - // by CHAR_WIDTH. Thus in theory we may end up with one character out of the screen! - // Be faithfull to the original and do the same though. + // See also the comment in textFitsCentered(). textX = CLIP<int>(textX, 60, 255); diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index a745755c07..99d0ad061c 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -49,7 +49,7 @@ namespace Wage { -MacWindow::MacWindow(WindowType type) : _type(type) { +MacWindow::MacWindow(bool scrollable, int id) : _scrollable(scrollable), _id(id) { _active = false; _borderIsDirty = true; } @@ -69,9 +69,16 @@ void MacWindow::resize(int w, int h) { _surface.free(); _surface.create(w, h, Graphics::PixelFormat::createFormatCLUT8()); + + _dims.setWidth(w); + _dims.setHeight(h); +} + +void MacWindow::move(int x, int y) { + _dims.moveTo(x, y); } -void MacWindow::draw(Graphics::Surface *g, int x, int y) { +void MacWindow::draw(Graphics::Surface *g) { if (_borderIsDirty) drawBorder(); } diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index 4efdbd0a0f..44f25b6101 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -58,10 +58,12 @@ enum WindowType { }; class MacWindow { - MacWindow(WindowType type); +public: + MacWindow(bool scrollable, int id); ~MacWindow(); + void move(int x, int y); void resize(int w, int h); - void draw(Graphics::Surface *g, int x, int y); + void draw(Graphics::Surface *g); void setActive(bool active); Graphics::ManagedSurface *getSurface() { return &_surface; } @@ -71,9 +73,12 @@ private: private: Graphics::ManagedSurface _surface; Graphics::ManagedSurface _borderSurface; - WindowType _type; + bool _scrollable; + int _id; bool _active; bool _borderIsDirty; + + Common::Rect _dims; }; } // End of namespace Wage diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index 02e47a148e..5717361527 100644 --- a/engines/wage/macwindowmanager.cpp +++ b/engines/wage/macwindowmanager.cpp @@ -45,14 +45,60 @@ * */ +#include "common/list.h" +#include "common/array.h" + +#include "graphics/surface.h" +#include "wage/macwindow.h" #include "wage/macwindowmanager.h" namespace Wage { MacWindowManager::MacWindowManager() { + _lastId = 0; + _activeWindow = -1; } MacWindowManager::~MacWindowManager() { + for (uint i = 0; i < _lastId; i++) + delete _windows[i]; +} + +int MacWindowManager::add(bool scrollable) { + MacWindow *w = new MacWindow(scrollable, _lastId); + + _windows.push_back(w); + _windowStack.push_back(w); + + _activeWindow = _lastId; + + _lastId++; + + return _activeWindow; +} + +void MacWindowManager::setActive(int id) { + if (_activeWindow == id) + return; + + if (_activeWindow != -1) + _windows[_activeWindow]->setActive(false); + + _windows[id]->setActive(true); + + _windowStack.remove(_windows[id]); + _windowStack.push_back(_windows[id]); + + _fullRefresh = true; +} + +void MacWindowManager::draw(Graphics::Surface *g) { + if (_fullRefresh) { + for (Common::List<MacWindow *>::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++) + (*it)->draw(g); + } else { + _windowStack.back()->draw(g); + } } } // End of namespace Wage diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index eaec462d5d..0c35356863 100644 --- a/engines/wage/macwindowmanager.h +++ b/engines/wage/macwindowmanager.h @@ -50,9 +50,26 @@ namespace Wage { +class MacWindow; + class MacWindowManager { +public: MacWindowManager(); ~MacWindowManager(); + + int add(bool scrollable); + void setActive(int id); + + void draw(Graphics::Surface *g); + +private: + Common::List<MacWindow *> _windowStack; + Common::Array<MacWindow *> _windows; + + int _lastId; + int _activeWindow; + + bool _fullRefresh; }; } // End of namespace Wage |