diff options
author | craigsc | 2020-01-11 12:08:21 -0800 |
---|---|---|
committer | craigsc | 2020-01-11 12:08:21 -0800 |
commit | 3dd4fb16f017a8eab5c6c11fd119a397b457866e (patch) | |
tree | 5b80b5c5038d8577c2d674a5a4742b335deca515 /graphics/macgui | |
parent | f9f81ea9baecb714f26cf1c17a1b0ae58431467b (diff) | |
parent | 5893672b80f00fced33c42e63471d68ba47d7dd4 (diff) | |
download | scummvm-rg350-3dd4fb16f017a8eab5c6c11fd119a397b457866e.tar.gz scummvm-rg350-3dd4fb16f017a8eab5c6c11fd119a397b457866e.tar.bz2 scummvm-rg350-3dd4fb16f017a8eab5c6c11fd119a397b457866e.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'graphics/macgui')
-rw-r--r-- | graphics/macgui/macfontmanager.cpp | 51 | ||||
-rw-r--r-- | graphics/macgui/macmenu.cpp | 5 | ||||
-rw-r--r-- | graphics/macgui/macmenu.h | 4 | ||||
-rw-r--r-- | graphics/macgui/mactext.cpp | 16 | ||||
-rw-r--r-- | graphics/macgui/macwindowmanager.cpp | 6 | ||||
-rw-r--r-- | graphics/macgui/macwindowmanager.h | 6 |
6 files changed, 56 insertions, 32 deletions
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp index e8e3d4314b..ff940384c4 100644 --- a/graphics/macgui/macfontmanager.cpp +++ b/graphics/macgui/macfontmanager.cpp @@ -405,42 +405,67 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) { // No simple substitute was found. Looking for neighborhood fonts // First we gather all font sizes for this font - Common::Array<int> sizes; + Common::Array<MacFont *> sizes; for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) { if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == macFont.getSlant() && !i->_value->isGenerated()) - sizes.push_back(i->_value->getSize()); + sizes.push_back(i->_value); } if (sizes.empty()) { - debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str()); - return; + if (macFont.getSlant() == kMacFontRegular) { + debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str()); + return; + } + + // Now let's try to find a regular font + for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) { + if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == kMacFontRegular && !i->_value->isGenerated()) + sizes.push_back(i->_value); + } + + if (sizes.empty()) { + debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str()); + return; + } } - // Now looking next larger font, and store the largest one for next check - int candidate = 1000; - int maxSize = sizes[0]; + // Now looking for the next larger font, and store the largest one for next check + MacFont *candidate = nullptr; + MacFont *maxSize = sizes[0]; for (uint i = 0; i < sizes.size(); i++) { - if (sizes[i] > macFont.getSize() && sizes[i] < candidate) + if (sizes[i]->getSize() == macFont.getSize()) { // Same size but regular slant + candidate = sizes[i]; + break; + } + + if (sizes[i]->getSize() > macFont.getSize() && candidate && sizes[i]->getSize() < candidate->getSize()) candidate = sizes[i]; - if (sizes[i] > maxSize) + if (sizes[i]->getSize() > maxSize->getSize()) maxSize = sizes[i]; } - if (candidate != 1000) { - generateFont(macFont, *_fontRegistry[getFontName(macFont.getId(), candidate, macFont.getSlant())]); + if (candidate) { + generateFont(macFont, *candidate); return; } // Now next smaller font, which is the biggest we have - generateFont(macFont, *_fontRegistry[getFontName(macFont.getId(), maxSize, macFont.getSlant())]); + generateFont(macFont, *maxSize); } void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) { debugN("Found font substitute for font '%s' ", getFontName(toFont).c_str()); debug("as '%s'", getFontName(fromFont).c_str()); - MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize()); + bool bold = false, italic = false; + + if (fromFont.getSlant() == kMacFontRegular) { + bold = toFont.getSlant() == kMacFontBold; + italic = toFont.getSlant() == kMacFontItalic; + } + + MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize(), bold, italic); if (!font) { warning("Failed to generate font '%s'", getFontName(toFont).c_str()); diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp index 2c9b3f0902..b79ba8cfbc 100644 --- a/graphics/macgui/macmenu.cpp +++ b/graphics/macgui/macmenu.cpp @@ -24,6 +24,7 @@ #include "common/stack.h" #include "common/keyboard.h" #include "common/macresman.h" +#include "common/winexe_pe.h" #include "graphics/primitives.h" #include "graphics/font.h" @@ -200,8 +201,8 @@ static Common::U32String readUnicodeString(Common::SeekableReadStream *stream) { } -MacMenu *MacMenu::createMenuFromPEexe(Common::PEResources &exe, MacWindowManager *wm) { - Common::SeekableReadStream *menuData = exe.getResource(Common::kWinMenu, 128); +MacMenu *MacMenu::createMenuFromPEexe(Common::PEResources *exe, MacWindowManager *wm) { + Common::SeekableReadStream *menuData = exe->getResource(Common::kWinMenu, 128); if (!menuData) return nullptr; diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h index c8633c0cc7..13d374d084 100644 --- a/graphics/macgui/macmenu.h +++ b/graphics/macgui/macmenu.h @@ -24,11 +24,11 @@ #define GRAPHICS_MACGUI_MACMENU_H #include "common/str-array.h" -#include "common/winexe_pe.h" namespace Common { class U32String; class MacResManager; +class PEResources; } namespace Graphics { @@ -51,7 +51,7 @@ public: ~MacMenu(); static Common::StringArray *readMenuFromResource(Common::SeekableReadStream *res); - static MacMenu *createMenuFromPEexe(Common::PEResources &exe, MacWindowManager *wm); + static MacMenu *createMenuFromPEexe(Common::PEResources *exe, MacWindowManager *wm); void setCommandsCallback(void (*callback)(int, Common::String &, void *), void *data) { _ccallback = callback; _cdata = data; } void setCommandsCallback(void (*callback)(int, Common::U32String &, void *), void *data) { _unicodeccallback = callback; _cdata = data; } diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 0df403ac8c..2fc9b8dd33 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -69,8 +69,7 @@ MacText::MacText(Common::U32String s, MacWindowManager *wm, const MacFont *macFo _currentFormatting = _defaultFormatting; - if (!_str.empty()) - splitString(_str); + splitString(_str); recalcDims(); @@ -101,8 +100,7 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m _currentFormatting = _defaultFormatting; - if (!_str.empty()) - splitString(_str); + splitString(_str); recalcDims(); @@ -114,13 +112,11 @@ void MacText::setMaxWidth(int maxWidth) { _textLines.clear(); - if (!_str.empty()) { - splitString(_str); + splitString(_str); - recalcDims(); + recalcDims(); - _fullRefresh = true; - } + _fullRefresh = true; } static const Common::U32String::value_type *readHex(uint16 *res, const Common::U32String::value_type *s, int len) { @@ -395,7 +391,7 @@ int MacText::getLineWidth(int line, bool enforce) { height = MAX(height, _textLines[line].chunks[i].getFont()->getFontHeight()); } - if (!hastext) + if (!hastext && _textLines.size() > 1) height = height > 3 ? height - 3 : 0; _textLines[line].width = width; diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp index 12cd391f92..19448053a3 100644 --- a/graphics/macgui/macwindowmanager.cpp +++ b/graphics/macgui/macwindowmanager.cpp @@ -295,7 +295,7 @@ void macDrawPixel(int x, int y, int color, void *data) { uint yu = (uint)y; *((byte *)p->surface->getBasePtr(xu, yu)) = - (pat[yu % 8] & (1 << (7 - xu % 8))) ? + (pat[(yu - p->fillOriginY) % 8] & (1 << (7 - (xu - p->fillOriginX) % 8))) ? color : p->bgColor; } } else { @@ -310,7 +310,7 @@ void macDrawPixel(int x, int y, int color, void *data) { uint xu = (uint)x; // for letting compiler optimize it uint yu = (uint)y; *((byte *)p->surface->getBasePtr(xu, yu)) = - (pat[yu % 8] & (1 << (7 - xu % 8))) ? + (pat[(yu - p->fillOriginY) % 8] & (1 << (7 - (xu - p->fillOriginX) % 8))) ? color : p->bgColor; } } @@ -319,7 +319,7 @@ void macDrawPixel(int x, int y, int color, void *data) { void MacWindowManager::drawDesktop() { Common::Rect r(_screen->getBounds()); - MacPlotData pd(_screen, &_patterns, kPatternCheckers, 1, _colorWhite); + MacPlotData pd(_screen, &_patterns, kPatternCheckers, 0, 0, 1, _colorWhite); Graphics::drawRoundRect(r, kDesktopArc, _colorBlack, true, macDrawPixel, &pd); diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h index c412e64f0a..5846bcba07 100644 --- a/graphics/macgui/macwindowmanager.h +++ b/graphics/macgui/macwindowmanager.h @@ -83,11 +83,13 @@ struct MacPlotData { Graphics::ManagedSurface *surface; MacPatterns *patterns; uint fillType; + int fillOriginX; + int fillOriginY; int thickness; uint bgColor; - MacPlotData(Graphics::ManagedSurface *s, MacPatterns *p, int f, int t, uint bg) : - surface(s), patterns(p), fillType(f), thickness(t), bgColor(bg) { + MacPlotData(Graphics::ManagedSurface *s, MacPatterns *p, uint f, int fx, int fy, int t, uint bg) : + surface(s), patterns(p), fillType(f), fillOriginX(fx), fillOriginY(fy), thickness(t), bgColor(bg) { } }; |