[Scummvm-git-logs] scummvm master -> e32383574aa701ac7561a144252cdb22bf384439
sev-
sev at scummvm.org
Fri Apr 30 23:50:23 UTC 2021
This automated email contains information about 15 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
81252598e6 GRAPHICS: MACGUI: Optimize MacMenu rendering
cc0cdbbd22 GRAPHICS: MACGUI: Plug memory leak
537e654138 GRAPHICS: TTF: Support loading fixed size fonts
798a76ec56 DISTS: Added 2 MS-like fonts from wine to our fonts
d98473ba47 GRAPHICS: MACGUI: Use Win95 fonts for Win95 MacMenu
5fa661f1b0 PINK: Fix menu in Hebrew version.
ad50a1471a GUI: Initialize class variables
eda31b9498 GUI: Initialized more variables
12f107af67 GUI: Gracefully process broken images
c60009da68 GRAPHICS: MACGUI: Initialized class variables
364407a5c6 GRAPHICS: Properly initialize ManagedSurface copy constructor
7d4f064a2a GRAPHICS: MACGUI: Streamlined MacText initialization
738db125e3 GRAPHICS: MACGUI: Make MacText work with plain text
847208ade6 PINK: Switch action texts to Windows System font
e32383574a PINK: Create MacText once per action
Commit: 81252598e6675f841116016b2c68c6cf7b717609
https://github.com/scummvm/scummvm/commit/81252598e6675f841116016b2c68c6cf7b717609
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:37+02:00
Commit Message:
GRAPHICS: MACGUI: Optimize MacMenu rendering
Changed paths:
graphics/macgui/macmenu.cpp
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index f935e6f506..21a64d7519 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -957,8 +957,6 @@ void MacMenu::renderSubmenu(MacMenuSubMenu *menu, bool recursive) {
if (recursive && menu->highlight != -1 && menu->items[menu->highlight]->submenu != nullptr)
renderSubmenu(menu->items[menu->highlight]->submenu, false);
- _contentIsDirty = true;
-
if (_wm->_mode & kWMModalMenuMode)
g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 2, r->height() + 2);
}
@@ -1029,6 +1027,8 @@ bool MacMenu::mouseClick(int x, int y) {
}
_menustack.pop_back(); // Drop previous submenu
+ _contentIsDirty = true;
+ _wm->setFullRefresh(true);
}
}
@@ -1037,6 +1037,7 @@ bool MacMenu::mouseClick(int x, int y) {
if (_items[_activeItem]->submenu != nullptr) {
_menustack.push_back(_items[_activeItem]->submenu);
_items[_activeItem]->submenu->highlight = -1;
+ _contentIsDirty = true;
}
}
}
@@ -1046,9 +1047,6 @@ bool MacMenu::mouseClick(int x, int y) {
setActive(true);
- _contentIsDirty = true;
- _wm->setFullRefresh(true);
-
if (_wm->_mode & kWMModalMenuMode) {
draw(_wm->_screen);
eventLoop();
Commit: cc0cdbbd22584ff38562c1a691de6aa8d27b34c3
https://github.com/scummvm/scummvm/commit/cc0cdbbd22584ff38562c1a691de6aa8d27b34c3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:46+02:00
Commit Message:
GRAPHICS: MACGUI: Plug memory leak
Changed paths:
graphics/macgui/datafiles.cpp
graphics/macgui/macwindowmanager.cpp
graphics/macgui/macwindowmanager.h
diff --git a/graphics/macgui/datafiles.cpp b/graphics/macgui/datafiles.cpp
index 2add870a47..2cbcc0a706 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -82,6 +82,10 @@ void MacWindowManager::loadDataBundle() {
}
}
+void MacWindowManager::cleanupDataBundle() {
+ delete _dataBundle;
+}
+
BorderOffsets MacWindowManager::getBorderOffsets(byte windowType) {
int i = 0;
while (borders[i].type != 0xFF) {
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index d6566d0970..cd710838fb 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -236,6 +236,8 @@ MacWindowManager::~MacWindowManager() {
delete _desktopBmp;
delete _desktop;
+ cleanupDataBundle();
+
g_system->getTimerManager()->removeTimerProc(&menuTimerHandler);
}
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index acc23a802d..0ed4786b45 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -306,6 +306,7 @@ public:
void removeMarked();
void loadDataBundle();
+ void cleanupDataBundle();
BorderOffsets getBorderOffsets(byte windowType);
Common::SeekableReadStream *getBorderFile(byte windowType, uint32 flags);
Common::SeekableReadStream *getFile(const Common::String &filename);
Commit: 537e654138bae9fdec1ecc23c1d343523cd218fc
https://github.com/scummvm/scummvm/commit/537e654138bae9fdec1ecc23c1d343523cd218fc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:46+02:00
Commit Message:
GRAPHICS: TTF: Support loading fixed size fonts
Changed paths:
graphics/fonts/ttf.cpp
diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index 8d7636767d..cc6e212bd7 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -268,14 +268,27 @@ bool TTFFont::load(uint8 *ttfFile, uint32 sizeFile, int32 faceIndex, bool bold,
return false;
}
- // We only support scalable fonts.
+ // Check if the fixed font has the requested size
if (!FT_IS_SCALABLE(_face)) {
- g_ttf.closeFont(_face);
+ FT_Pos reqsize = computePointSize(size, sizeMode) * 64;
+ bool found = false;
- // Don't delete ttfFile as we return fail
- _ttfFile = 0;
+ for (int i = 0; i < _face->num_fixed_sizes; i++)
+ if (_face->available_sizes[i].size == reqsize) {
+ found = true;
+ break;
+ }
- return false;
+ if (!found) {
+ warning("The non-scalable font has no requested size: %ld", reqsize);
+
+ g_ttf.closeFont(_face);
+
+ // Don't delete ttfFile as we return fail
+ _ttfFile = 0;
+
+ return false;
+ }
}
if (stemDarkening) {
#if FREETYPE_MAJOR > 2 || ( FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 9)
@@ -770,7 +783,7 @@ bool TTFFont::cacheGlyph(Glyph &glyph, uint32 chr) const {
// That's 26.6 fixed-point units
if (FT_Bitmap_Embolden(_face->glyph->library, &_face->glyph->bitmap, 1 << 6, 0))
return false;
-
+
bitmap = &_face->glyph->bitmap;
#elif FAKE_BOLD >= 1
FT_Bitmap_New(&ownBitmap);
@@ -1069,4 +1082,3 @@ DECLARE_SINGLETON(Graphics::TTFLibrary);
} // End of namespace Common
#endif
-
Commit: 798a76ec56678d6633eaadea259bb36d32b0da4e
https://github.com/scummvm/scummvm/commit/798a76ec56678d6633eaadea259bb36d32b0da4e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:47+02:00
Commit Message:
DISTS: Added 2 MS-like fonts from wine to our fonts
Changed paths:
A gui/themes/fonts/ms_sans_serif.ttf
A gui/themes/fonts/system.ttf
dists/engine-data/fonts.dat
diff --git a/dists/engine-data/fonts.dat b/dists/engine-data/fonts.dat
index 2c3c050700..52755e012a 100644
Binary files a/dists/engine-data/fonts.dat and b/dists/engine-data/fonts.dat differ
diff --git a/gui/themes/fonts/ms_sans_serif.ttf b/gui/themes/fonts/ms_sans_serif.ttf
new file mode 100644
index 0000000000..fd20edb459
Binary files /dev/null and b/gui/themes/fonts/ms_sans_serif.ttf differ
diff --git a/gui/themes/fonts/system.ttf b/gui/themes/fonts/system.ttf
new file mode 100644
index 0000000000..0f629fc647
Binary files /dev/null and b/gui/themes/fonts/system.ttf differ
Commit: d98473ba47f76fb48501edd9515a2b7e4a1b85d0
https://github.com/scummvm/scummvm/commit/d98473ba47f76fb48501edd9515a2b7e4a1b85d0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:47+02:00
Commit Message:
GRAPHICS: MACGUI: Use Win95 fonts for Win95 MacMenu
Changed paths:
graphics/macgui/macmenu.cpp
graphics/macgui/macmenu.h
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index 21a64d7519..3a68ddd010 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -29,6 +29,7 @@
#include "graphics/primitives.h"
#include "graphics/font.h"
+#include "graphics/fonts/ttf.h"
#include "graphics/macgui/macfontmanager.h"
#include "graphics/macgui/macwindowmanager.h"
#include "graphics/macgui/macwindow.h"
@@ -109,6 +110,8 @@ MacMenuSubMenu::~MacMenuSubMenu() {
MacMenu::MacMenu(int id, const Common::Rect &bounds, MacWindowManager *wm)
: BaseMacWindow(id, false, wm) {
+ _loadedFont = NULL;
+
_font = getMenuFont();
_align = kTextAlignLeft;
@@ -150,6 +153,8 @@ MacMenu::MacMenu(int id, const Common::Rect &bounds, MacWindowManager *wm)
MacMenu::~MacMenu() {
for (uint i = 0; i < _items.size(); i++)
delete _items[i];
+
+ delete _loadedFont;
}
Common::StringArray *MacMenu::readMenuFromResource(Common::SeekableReadStream *res) {
@@ -580,6 +585,19 @@ void MacMenu::createSubMenuFromString(int id, const char *str, int commandId) {
}
const Font *MacMenu::getMenuFont(int slant) {
+ if (_wm->_mode & kWMModeWin95) {
+ if (!_loadedFont) {
+ _loadedFont = Graphics::loadTTFFontFromArchive("ms_sans_serif.ttf", 16);
+
+ if (_loadedFont)
+ return _loadedFont;
+ } else {
+ return _loadedFont;
+ }
+
+ // If font was not loaded, fallback
+ }
+
return _wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12, slant));
}
diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h
index 997c00dca4..36339f080b 100644
--- a/graphics/macgui/macmenu.h
+++ b/graphics/macgui/macmenu.h
@@ -131,6 +131,7 @@ private:
ItemArray _items;
const Font *_font;
+ Font *_loadedFont;
bool _isVisible;
Commit: 5fa661f1b0ff321a25b2ddec4eda125d56eba212
https://github.com/scummvm/scummvm/commit/5fa661f1b0ff321a25b2ddec4eda125d56eba212
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:47+02:00
Commit Message:
PINK: Fix menu in Hebrew version.
Unfortunately, we have no Hebrew glyphs in Win95 fonts.
Changed paths:
engines/pink/director.cpp
engines/pink/director.h
engines/pink/pink.cpp
diff --git a/engines/pink/director.cpp b/engines/pink/director.cpp
index 3fde192093..b99d57b326 100644
--- a/engines/pink/director.cpp
+++ b/engines/pink/director.cpp
@@ -24,6 +24,7 @@
#include "graphics/macgui/mactext.h"
#include "graphics/palette.h"
+#include "pink/pink.h"
#include "pink/cel_decoder.h"
#include "pink/director.h"
#include "pink/objects/actions/action_sound.h"
@@ -88,11 +89,16 @@ static void redrawCallback(void *ref) {
}
}
-Director::Director()
+Director::Director(PinkEngine *vm)
: _surface(640, 480), _textRendered(false) {
- _wm = new Graphics::MacWindowManager(Graphics::kWMModeNoDesktop | Graphics::kWMModeAutohideMenu
+ uint32 wmMode = Graphics::kWMModeNoDesktop | Graphics::kWMModeAutohideMenu
| Graphics::kWMModalMenuMode | Graphics::kWMModeForceBuiltinFonts
- | Graphics::kWMModeUnicode | Graphics::kWMModeWin95);
+ | Graphics::kWMModeUnicode;
+
+ if (vm->getLanguage() != Common::HE_ISR) // We do not have Hebrew font in MS fonts :(
+ wmMode |= Graphics::kWMModeWin95;
+
+ _wm = new Graphics::MacWindowManager(wmMode);
_wm->setScreen(&_surface);
_wm->setMenuHotzone(Common::Rect(0, 0, 640, 23));
diff --git a/engines/pink/director.h b/engines/pink/director.h
index a1652d2cc7..6e451c751f 100644
--- a/engines/pink/director.h
+++ b/engines/pink/director.h
@@ -40,10 +40,11 @@ class Actor;
class ActionCEL;
class ActionSound;
class ActionText;
+class PinkEngine;
class Director {
public:
- Director();
+ Director(PinkEngine *vm);
~Director();
void update();
diff --git a/engines/pink/pink.cpp b/engines/pink/pink.cpp
index 839ec85462..0d8108c0ae 100644
--- a/engines/pink/pink.cpp
+++ b/engines/pink/pink.cpp
@@ -80,7 +80,7 @@ Common::Error PinkEngine::init() {
}
setDebugger(new Console(this));
- _director = new Director();
+ _director = new Director(this);
initMenu();
Commit: ad50a1471a6ecb133a2951d3b8a96e839d7e7e21
https://github.com/scummvm/scummvm/commit/ad50a1471a6ecb133a2951d3b8a96e839d7e7e21
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:47+02:00
Commit Message:
GUI: Initialize class variables
Changed paths:
gui/ThemeEngine.cpp
gui/Tooltip.cpp
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 600379b14f..bfd84730bf 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -192,6 +192,9 @@ ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) :
_font(nullptr), _initOk(false), _themeOk(false), _enabled(false), _themeFiles(),
_cursor(nullptr), _scaleFactor(1.0f) {
+ _baseWidth = 640; // Default sane values
+ _baseHeight = 480;
+
_system = g_system;
_parser = new ThemeParser(this);
_themeEval = new GUI::ThemeEval();
@@ -227,9 +230,9 @@ ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) :
_cursorHotspotX = _cursorHotspotY = 0;
_cursorWidth = _cursorHeight = 0;
+ _cursorTransparent = 255;
#ifndef USE_RGB_COLOR
_cursorFormat = Graphics::PixelFormat::createFormatCLUT8();
- _cursorTransparent = 255;
_cursorPalSize = 0;
#endif
diff --git a/gui/Tooltip.cpp b/gui/Tooltip.cpp
index 20f74e1cd0..761257f82f 100644
--- a/gui/Tooltip.cpp
+++ b/gui/Tooltip.cpp
@@ -32,7 +32,7 @@ namespace GUI {
Tooltip::Tooltip() :
- Dialog(-1, -1, -1, -1), _maxWidth(-1), _parent(nullptr), _xdelta(0), _ydelta(0) {
+ Dialog(-1, -1, -1, -1), _maxWidth(-1), _parent(nullptr), _xdelta(0), _ydelta(0), _xpadding(0), _ypadding(0) {
_backgroundType = GUI::ThemeEngine::kDialogBackgroundTooltip;
}
Commit: eda31b9498f2986d70c26b4bca71a426506fef09
https://github.com/scummvm/scummvm/commit/eda31b9498f2986d70c26b4bca71a426506fef09
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:47+02:00
Commit Message:
GUI: Initialized more variables
Changed paths:
gui/about.cpp
gui/widgets/list.cpp
diff --git a/gui/about.cpp b/gui/about.cpp
index 009dcd5702..0f2ea51f64 100644
--- a/gui/about.cpp
+++ b/gui/about.cpp
@@ -456,6 +456,15 @@ bool EEHandler::handleKeyDown(Common::KeyState &state) {
EE::EE() {
init();
+
+ _scale = 1.0;
+ _windowW = 320;
+ _windowH = 200;
+ _windowX = _windowY = 0;
+
+ _format = g_system->getOverlayFormat();
+
+ _colorBlack = _colorBlue = _colorOrange = _colorKey = 0;
}
EE::~EE() {
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index 65523d75fa..e0c9820fdd 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -73,6 +73,7 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h, const U32String
: EditableWidget(boss, x, y, w, h, tooltip), _cmd(cmd) {
_entriesPerPage = 0;
+ _scrollBarWidth = 0;
_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth, 0, _scrollBarWidth, _h);
_scrollBar->setTarget(this);
Commit: 12f107af67520fb47d43c5c70eb0dceabcf34d5a
https://github.com/scummvm/scummvm/commit/12f107af67520fb47d43c5c70eb0dceabcf34d5a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:47+02:00
Commit Message:
GUI: Gracefully process broken images
Changed paths:
gui/ThemeEngine.cpp
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index bfd84730bf..e684eb6baa 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -680,6 +680,7 @@ bool ThemeEngine::addBitmap(const Common::String &filename, const Common::String
if (surf) {
surf->free();
delete surf;
+ surf = nullptr;
_bitmaps.erase(filename);
}
@@ -696,10 +697,14 @@ bool ThemeEngine::addBitmap(const Common::String &filename, const Common::String
}
}
- _bitmaps[filename] = new Graphics::ManagedSurface(width * _scaleFactor, height * _scaleFactor, *image->getPixelFormat());
- image->render(*_bitmaps[filename], width * _scaleFactor, height * _scaleFactor);
+ if (image) {
+ _bitmaps[filename] = new Graphics::ManagedSurface(width * _scaleFactor, height * _scaleFactor, *image->getPixelFormat());
+ image->render(*_bitmaps[filename], width * _scaleFactor, height * _scaleFactor);
- delete image;
+ delete image;
+ } else {
+ return false;
+ }
return true;
}
@@ -750,7 +755,7 @@ bool ThemeEngine::addBitmap(const Common::String &filename, const Common::String
surf = new Graphics::ManagedSurface(srcSurface->convertTo(_overlayFormat));
}
- if (_scaleFactor != 1.0) {
+ if (_scaleFactor != 1.0 && surf) {
Graphics::Surface *tmp2 = surf->rawSurface().scale(surf->w * _scaleFactor, surf->h * _scaleFactor, false);
surf->free();
Commit: c60009da680c021246aac35f160eaf5f9e65b083
https://github.com/scummvm/scummvm/commit/c60009da680c021246aac35f160eaf5f9e65b083
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:48+02:00
Commit Message:
GRAPHICS: MACGUI: Initialized class variables
Changed paths:
graphics/macgui/mactext.h
graphics/macgui/macwindow.cpp
graphics/macgui/macwindowborder.cpp
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 6097e0c167..566b980a2a 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -58,7 +58,8 @@ struct MacFontRun {
MacFontRun() {
wm = nullptr;
fontId = textSlant = fontSize = 0;
- palinfo1 = palinfo2 = palinfo3 = 0;
+ palinfo1 = palinfo2 = palinfo3 = 0;
+ fgcolor = 0;
font = nullptr;
wordContinuation = false;
}
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 5138353f0b..d721544221 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -527,6 +527,7 @@ void MacWindow::loadWin95Border(const Common::String &filename, uint32 flags) {
offsets.lowerScrollHeight = 15;
offsets.upperScrollHeight = 17;
offsets.titlePos = 0;
+ offsets.titleTop = 0;
loadBorder(*stream, flags, offsets);
delete stream;
}
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index d91b3099a4..dd00726bae 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -52,6 +52,11 @@ MacWindowBorder::MacWindowBorder() {
_borderOffsets.titleTop = -1;
_borderOffsets.titleBottom = -1;
_borderOffsets.dark = false;
+ _borderOffsets.titlePos = 0;
+ _borderOffsets.upperScrollHeight = 0;
+ _borderOffsets.lowerScrollHeight = 0;
+
+ _borderType = 0;
_scrollSize = -1;
_scrollPos = 0;
@@ -200,6 +205,9 @@ void MacWindowBorder::loadBorder(Common::SeekableReadStream &file, uint32 flags,
offsets.titleBottom = -1;
offsets.titlePos = 0;
offsets.dark = false;
+ offsets.upperScrollHeight = 0;
+ offsets.lowerScrollHeight = 0;
+
loadBorder(file, flags, offsets);
}
@@ -277,7 +285,7 @@ void MacWindowBorder::blitBorderInto(ManagedSurface &destination, uint32 flags,
warning("Attempt to draw %d x %d window", destination.w, destination.h);
return;
}
-
+
// we add a special check here, if we have title but the titleWidth is zero, then we try to recalc it
if ((flags & kWindowBorderTitle) && _border[flags]->getTitleWidth() == 0) {
setTitle(_title, destination.w, wm);
Commit: 364407a5c66f5b3b661d4e41e080f80fff0a7dfe
https://github.com/scummvm/scummvm/commit/364407a5c66f5b3b661d4e41e080f80fff0a7dfe
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:48+02:00
Commit Message:
GRAPHICS: Properly initialize ManagedSurface copy constructor
Changed paths:
graphics/managed_surface.cpp
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index dede913342..a02a68ad5f 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -77,6 +77,8 @@ ManagedSurface::ManagedSurface(Surface *surf, DisposeAfterUse::Flag disposeAfter
return;
}
+ _disposeAfterUse = disposeAfterUse;
+
if (disposeAfterUse == DisposeAfterUse::YES) {
_innerSurface.w = surf->w;
_innerSurface.h = surf->h;
Commit: 7d4f064a2ade2078f7d8994b14e8b0760c4bd71b
https://github.com/scummvm/scummvm/commit/7d4f064a2ade2078f7d8994b14e8b0760c4bd71b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:48+02:00
Commit Message:
GRAPHICS: MACGUI: Streamlined MacText initialization
Changed paths:
graphics/macgui/mactext.cpp
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 1c606f20e9..ec44a5c9c9 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -95,21 +95,16 @@ uint MacTextLine::getChunkNum(int *col) {
MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow) :
- MacWidget(parent, x, y, w + 2, h, wm, true, border, gutter, boxShadow) {
+ MacWidget(parent, x, y, w + 2, h, wm, true, border, gutter, boxShadow),
+ _macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
+
_str = s;
_fullRefresh = true;
_wm = wm;
- _macFont = macFont;
_fgcolor = fgcolor;
_bgcolor = bgcolor;
- _maxWidth = maxWidth;
- _textMaxWidth = 0;
- _textMaxHeight = 0;
- _surface = nullptr;
- _textAlignment = textAlignment;
- _interLinear = interlinear;
_textShadow = textShadow;
if (macFont) {
@@ -123,21 +118,14 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
}
MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow) :
- MacWidget(parent, x, y, w + 2, h, wm, true, border, gutter, boxShadow) {
+ MacWidget(parent, x, y, w + 2, h, wm, true, border, gutter, boxShadow),
+ _macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
_str = Common::U32String(s);
- _fullRefresh = true;
_wm = wm;
- _macFont = macFont;
_fgcolor = fgcolor;
_bgcolor = bgcolor;
- _maxWidth = maxWidth;
- _textMaxWidth = 0;
- _textMaxHeight = 0;
- _surface = nullptr;
- _textAlignment = textAlignment;
- _interLinear = interlinear;
_textShadow = textShadow;
if (macFont) {
@@ -152,21 +140,14 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
// NOTE: This constructor and the one afterward are for MacText engines that don't use widgets. This is the classic was MacText was constructed.
MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
- MacWidget(nullptr, 0, 0, 0, 0, wm, false, 0, 0, 0) {
+ MacWidget(nullptr, 0, 0, 0, 0, wm, false, 0, 0, 0),
+ _macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
_str = s;
- _fullRefresh = true;
_wm = wm;
- _macFont = macFont;
_fgcolor = fgcolor;
_bgcolor = bgcolor;
- _maxWidth = maxWidth;
- _textMaxWidth = 0;
- _textMaxHeight = 0;
- _surface = nullptr;
- _textAlignment = textAlignment;
- _interLinear = interlinear;
_textShadow = 0;
if (macFont) {
@@ -180,21 +161,14 @@ MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont
}
MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
- MacWidget(nullptr, 0, 0, 0, 0, wm, false, 0, 0, 0) {
+ MacWidget(nullptr, 0, 0, 0, 0, wm, false, 0, 0, 0),
+ _macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
_str = Common::U32String(s);
- _fullRefresh = true;
_wm = wm;
- _macFont = macFont;
_fgcolor = fgcolor;
_bgcolor = bgcolor;
- _maxWidth = maxWidth;
- _textMaxWidth = 0;
- _textMaxHeight = 0;
- _surface = nullptr;
- _textAlignment = textAlignment;
- _interLinear = interlinear;
_textShadow = 0;
if (macFont) {
@@ -208,6 +182,12 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m
}
void MacText::init() {
+ _fullRefresh = true;
+
+ _textMaxWidth = 0;
+ _textMaxHeight = 0;
+ _surface = nullptr;
+
_defaultFormatting.wm = _wm;
// try to set fgcolor as default color in chunks
if (_wm->_mode & kWMModeWin95) {
Commit: 738db125e39ba2b4ad6cfcf9727f9b90f1095fb6
https://github.com/scummvm/scummvm/commit/738db125e39ba2b4ad6cfcf9727f9b90f1095fb6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:48+02:00
Commit Message:
GRAPHICS: MACGUI: Make MacText work with plain text
Changed paths:
graphics/macgui/mactext.cpp
graphics/macgui/mactext.h
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index ec44a5c9c9..d0a0a4d11d 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -98,7 +98,6 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
MacWidget(parent, x, y, w + 2, h, wm, true, border, gutter, boxShadow),
_macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
-
_str = s;
_fullRefresh = true;
@@ -106,6 +105,7 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
_fgcolor = fgcolor;
_bgcolor = bgcolor;
_textShadow = textShadow;
+ _macFontMode = true;
if (macFont) {
_defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
@@ -127,6 +127,7 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
_fgcolor = fgcolor;
_bgcolor = bgcolor;
_textShadow = textShadow;
+ _macFontMode = true;
if (macFont) {
_defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
@@ -149,6 +150,7 @@ MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont
_fgcolor = fgcolor;
_bgcolor = bgcolor;
_textShadow = 0;
+ _macFontMode = true;
if (macFont) {
_defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
@@ -170,6 +172,7 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m
_fgcolor = fgcolor;
_bgcolor = bgcolor;
_textShadow = 0;
+ _macFontMode = true;
if (macFont) {
_defaultFormatting = MacFontRun(_wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
@@ -181,6 +184,29 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m
init();
}
+// Working with plain Font
+MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
+ MacWidget(nullptr, 0, 0, 0, 0, wm, false, 0, 0, 0),
+ _macFont(nullptr), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
+
+ _str = s;
+
+ _wm = wm;
+ _fgcolor = fgcolor;
+ _bgcolor = bgcolor;
+ _textShadow = 0;
+ _macFontMode = false;
+
+ if (font) {
+ _defaultFormatting = MacFontRun(_wm, font, 0, font->getFontHeight(), 0, 0, 0);
+ _defaultFormatting.font = font;
+ } else {
+ _defaultFormatting.font = NULL;
+ }
+
+ init();
+}
+
void MacText::init() {
_fullRefresh = true;
@@ -424,6 +450,9 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
current_format.setValues(_wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
+
+ if (!_macFontMode)
+ current_format.font = _defaultFormatting.font;
} else if (*s == '\016') { // human-readable format
s++;
@@ -440,6 +469,10 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
current_format.setValues(_wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
+
+ // So far, we enforce single font here, though in the future, font size could be altered
+ if (!_macFontMode)
+ current_format.font = _defaultFormatting.font;
}
while (*s && *s != ' ' && *s != '\001') {
@@ -674,7 +707,7 @@ int MacText::getLineWidth(int line, bool enforce, int col) {
bool hastext = false;
for (uint i = 0; i < _textLines[line].chunks.size(); i++) {
- if (enforce)
+ if (enforce && _macFontMode)
_textLines[line].chunks[i].font = nullptr;
if (col >= 0) {
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 566b980a2a..fbe2000f7e 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -70,6 +70,13 @@ struct MacFontRun {
wordContinuation = false;
}
+ MacFontRun(MacWindowManager *wm_, const Font *font_, byte textSlant_, uint16 fontSize_,
+ uint16 palinfo1_, uint16 palinfo2_, uint16 palinfo3_) {
+ setValues(wm_, 0, textSlant_, fontSize_, palinfo1_, palinfo2_, palinfo3_);
+ font = font_;
+ wordContinuation = false;
+ }
+
void setValues(MacWindowManager *wm_, uint16 fontId_, byte textSlant_, uint16 fontSize_,
uint16 palinfo1_, uint16 palinfo2_, uint16 palinfo3_) {
wm = wm_;
@@ -145,6 +152,8 @@ public:
MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0);
MacText(const Common::String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0);
+ MacText(const Common::U32String &s, MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0);
+
virtual ~MacText();
virtual void resize(int w, int h);
@@ -278,6 +287,8 @@ protected:
MacFontRun _defaultFormatting;
MacFontRun _currentFormatting;
+ bool _macFontMode;
+
private:
ManagedSurface *_cursorSurface;
ManagedSurface *_cursorSurface2;
Commit: 847208ade695e3cddd80a09b4654f89b4391151e
https://github.com/scummvm/scummvm/commit/847208ade695e3cddd80a09b4654f89b4391151e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:48+02:00
Commit Message:
PINK: Switch action texts to Windows System font
Changed paths:
engines/pink/director.cpp
engines/pink/director.h
engines/pink/objects/actions/action_text.cpp
diff --git a/engines/pink/director.cpp b/engines/pink/director.cpp
index b99d57b326..48a4758b9d 100644
--- a/engines/pink/director.cpp
+++ b/engines/pink/director.cpp
@@ -23,6 +23,7 @@
#include "graphics/macgui/macfontmanager.h"
#include "graphics/macgui/mactext.h"
#include "graphics/palette.h"
+#include "graphics/fonts/ttf.h"
#include "pink/pink.h"
#include "pink/cel_decoder.h"
@@ -104,10 +105,23 @@ Director::Director(PinkEngine *vm)
_wm->setMenuHotzone(Common::Rect(0, 0, 640, 23));
_wm->setMenuDelay(250000);
_wm->setEngineRedrawCallback(this, redrawCallback);
+
+ _textFont = Graphics::loadTTFFontFromArchive("system.ttf", 16);
+ _textFontCleanup = true;
+
+ if (!_textFont) {
+ _textFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ warning("Director: falling back to built-in font");
+
+ _textFontCleanup = false;
+ }
}
Director::~Director() {
delete _wm;
+
+ if (_textFontCleanup)
+ delete _textFont;
}
void Director::update() {
diff --git a/engines/pink/director.h b/engines/pink/director.h
index 6e451c751f..157988371a 100644
--- a/engines/pink/director.h
+++ b/engines/pink/director.h
@@ -80,6 +80,8 @@ public:
void draw(bool blit = true);
+ const Graphics::Font *getTextFont() { return _textFont; }
+
private:
void mergeDirtyRects();
void drawRect(const Common::Rect &rect);
@@ -94,6 +96,9 @@ private:
Common::Array<ActionText *> _textActions;
Common::Array<Graphics::MacTextWindow *> _textWindows;
bool _textRendered;
+
+ const Graphics::Font *_textFont;
+ bool _textFontCleanup;
};
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_text.cpp b/engines/pink/objects/actions/action_text.cpp
index f5bc9d5f6d..41c5449eff 100644
--- a/engines/pink/objects/actions/action_text.cpp
+++ b/engines/pink/objects/actions/action_text.cpp
@@ -151,14 +151,8 @@ void ActionText::draw(Graphics::ManagedSurface *surface) {
alignment = Graphics::kTextAlignRight;
}
int xOffset = 0, yOffset = 0;
- Graphics::MacFont *font = nullptr;
- if (_centered) {
- font = new Graphics::MacFont(Graphics::kMacFontChicago, 12, Graphics::kMacFontBold);
- } else {
- font = new Graphics::MacFont();
- }
Director *director = _actor->getPage()->getGame()->getDirector();
- Graphics::MacText text(_text, &director->getWndManager(), font, _textColorIndex, _backgroundColorIndex, _xRight - _xLeft, alignment);
+ Graphics::MacText text(_text, &director->getWndManager(), director->getTextFont(), _textColorIndex, _backgroundColorIndex, _xRight - _xLeft, alignment);
// we need to first fill this area with backgroundColor, in order to wash away the previous text
surface->fillRect(Common::Rect(_xLeft, _yTop, _xRight, _yBottom), _backgroundColorIndex);
Commit: e32383574aa701ac7561a144252cdb22bf384439
https://github.com/scummvm/scummvm/commit/e32383574aa701ac7561a144252cdb22bf384439
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-01T01:49:48+02:00
Commit Message:
PINK: Create MacText once per action
Changed paths:
engines/pink/objects/actions/action_text.cpp
engines/pink/objects/actions/action_text.h
diff --git a/engines/pink/objects/actions/action_text.cpp b/engines/pink/objects/actions/action_text.cpp
index 41c5449eff..f4d5d433e9 100644
--- a/engines/pink/objects/actions/action_text.cpp
+++ b/engines/pink/objects/actions/action_text.cpp
@@ -36,6 +36,7 @@ namespace Pink {
ActionText::ActionText() {
_txtWnd = nullptr;
+ _macText = nullptr;
_xLeft = _xRight = 0;
_yTop = _yBottom = 0;
@@ -126,6 +127,13 @@ void ActionText::start() {
} else {
director->addTextAction(this);
+
+ // alignment not working, thus we implement alignment for center manually
+ Graphics::TextAlign alignment = _centered ? Graphics::kTextAlignCenter : Graphics::kTextAlignLeft;
+ if (!_centered && _actor->getPage()->getGame()->getLanguage() == Common::HE_ISR) {
+ alignment = Graphics::kTextAlignRight;
+ }
+ _macText = new Graphics::MacText(_text, &director->getWndManager(), director->getTextFont(), _textColorIndex, _backgroundColorIndex, _xRight - _xLeft, alignment);
}
}
@@ -141,26 +149,20 @@ void ActionText::end() {
_txtWnd = nullptr;
} else {
director->removeTextAction(this);
+ delete _macText;
}
}
void ActionText::draw(Graphics::ManagedSurface *surface) {
- // alignment not working, thus we implement alignment for center manually
- Graphics::TextAlign alignment = _centered ? Graphics::kTextAlignCenter : Graphics::kTextAlignLeft;
- if (!_centered && _actor->getPage()->getGame()->getLanguage() == Common::HE_ISR) {
- alignment = Graphics::kTextAlignRight;
- }
int xOffset = 0, yOffset = 0;
- Director *director = _actor->getPage()->getGame()->getDirector();
- Graphics::MacText text(_text, &director->getWndManager(), director->getTextFont(), _textColorIndex, _backgroundColorIndex, _xRight - _xLeft, alignment);
// we need to first fill this area with backgroundColor, in order to wash away the previous text
surface->fillRect(Common::Rect(_xLeft, _yTop, _xRight, _yBottom), _backgroundColorIndex);
if (_centered) {
- xOffset = (_xRight - _xLeft) / 2 - text.getTextMaxWidth() / 2;
- yOffset = (_yBottom - _yTop) / 2 - text.getTextHeight() / 2;
+ xOffset = (_xRight - _xLeft) / 2 - _macText->getTextMaxWidth() / 2;
+ yOffset = (_yBottom - _yTop) / 2 - _macText->getTextHeight() / 2;
}
- text.drawToPoint(surface, Common::Rect(0, 0, _xRight - _xLeft, _yBottom - _yTop), Common::Point(_xLeft + xOffset, _yTop + yOffset));
+ _macText->drawToPoint(surface, Common::Rect(0, 0, _xRight - _xLeft, _yBottom - _yTop), Common::Point(_xLeft + xOffset, _yTop + yOffset));
}
#define BLUE(rgb) ((rgb) & 0xFF)
diff --git a/engines/pink/objects/actions/action_text.h b/engines/pink/objects/actions/action_text.h
index 0638bb01cd..b4d7be5cb3 100644
--- a/engines/pink/objects/actions/action_text.h
+++ b/engines/pink/objects/actions/action_text.h
@@ -57,6 +57,7 @@ private:
Common::String _fileName;
Common::U32String _text;
Graphics::MacTextWindow *_txtWnd;
+ Graphics::MacText *_macText;
uint32 _xLeft;
uint32 _yTop;
More information about the Scummvm-git-logs
mailing list