From bd4f0aa570b795afaf8c5a5b3837082b995b797f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 5 Jan 2020 10:59:11 +0100 Subject: GRAPHICS: MACGUI: Fix text height for one line texts --- graphics/macgui/mactext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/macgui') diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 0df403ac8c..916219fe73 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -395,7 +395,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; -- cgit v1.2.3 From 5a06fcecddd0fec6336a24b8f84ca73b055f8bdd Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 5 Jan 2020 11:34:17 +0100 Subject: GRAPHICS: MACGUI: Generate MacText surface for empty texts --- graphics/macgui/mactext.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'graphics/macgui') diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 916219fe73..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) { -- cgit v1.2.3 From bfd796fec2e723bb3a43e672fcddf2dfd5108ccf Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 7 Jan 2020 15:45:32 +0100 Subject: GRAPHICS: MACGUI: Use regular slant as font substitutes --- graphics/macgui/macfontmanager.cpp | 42 +++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'graphics/macgui') diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp index e8e3d4314b..151a3d9ee8 100644 --- a/graphics/macgui/macfontmanager.cpp +++ b/graphics/macgui/macfontmanager.cpp @@ -405,35 +405,53 @@ 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 sizes; + Common::Array sizes; for (Common::HashMap::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::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) { -- cgit v1.2.3 From 8c8a710d80394a7c60456cfdfded46d222c5ee21 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 7 Jan 2020 21:55:06 +0100 Subject: GRAPHICS: MACGUI: Generate bold font substitutes in MacFontManager --- graphics/macgui/macfontmanager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'graphics/macgui') diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp index 151a3d9ee8..ff940384c4 100644 --- a/graphics/macgui/macfontmanager.cpp +++ b/graphics/macgui/macfontmanager.cpp @@ -458,7 +458,14 @@ 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()); -- cgit v1.2.3 From b31d5ac2b9efe04fa717f6c39b4ce1526b55fd19 Mon Sep 17 00:00:00 2001 From: Scott Percival Date: Sat, 11 Jan 2020 11:27:21 +0800 Subject: DIRECTOR: Align fill patterns to global origin --- graphics/macgui/macwindowmanager.cpp | 6 +++--- graphics/macgui/macwindowmanager.h | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'graphics/macgui') 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) { } }; -- cgit v1.2.3 From 948c555ea616821ed7c2678ad406ed5bea392339 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Tue, 31 Dec 2019 19:19:42 +0000 Subject: ALL: Create all instances of NEResources and PEResources using new instead of on the stack Also adapted WinCursorGroup and MacMenu to reflect this. --- graphics/macgui/macmenu.cpp | 5 +++-- graphics/macgui/macmenu.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'graphics/macgui') 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; } -- cgit v1.2.3