From b2dcd1bb1ef920e7723501c9500a8ef0348be03a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 6 Oct 2016 23:48:50 +0200 Subject: GRAPHICS: Move font-related MacGUI code to MacFontManager --- engines/wage/dialog.cpp | 3 ++- engines/wage/entities.cpp | 17 ++++------------- engines/wage/entities.h | 6 +++--- engines/wage/gui-console.cpp | 3 ++- engines/wage/world.cpp | 6 ++++-- 5 files changed, 15 insertions(+), 20 deletions(-) (limited to 'engines/wage') diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp index ffb4f9c93d..a8500a7ebe 100644 --- a/engines/wage/dialog.cpp +++ b/engines/wage/dialog.cpp @@ -48,6 +48,7 @@ #include "common/system.h" #include "common/events.h" +#include "graphics/macgui/macfontmanager.h" #include "graphics/macgui/macwindowmanager.h" #include "wage/wage.h" @@ -92,7 +93,7 @@ Dialog::~Dialog() { } const Graphics::Font *Dialog::getDialogFont() { - return _gui->_wm.getFont(_gui->_wm.getFontName(0, 12), Graphics::FontManager::kBigGUIFont); // Default is Chicago + return _gui->_wm._fontMan->getFont(Graphics::MacFont(Graphics::kMacFontChicago, 12)); } void Dialog::paint() { diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp index 5ec54493a7..90247a5b21 100644 --- a/engines/wage/entities.cpp +++ b/engines/wage/entities.cpp @@ -54,6 +54,7 @@ #include "common/memstream.h" #include "graphics/managed_surface.h" +#include "graphics/macgui/macfontmanager.h" namespace Wage { @@ -86,8 +87,7 @@ Scene::Scene() { _script = NULL; _design = NULL; _textBounds = NULL; - _fontSize = 0; - _fontType = 0; + _font = NULL; for (int i = 0; i < 4; i++) _blocked[i] = false; @@ -111,8 +111,7 @@ Scene::Scene(Common::String name, Common::SeekableReadStream *data) { _script = NULL; _textBounds = NULL; - _fontSize = 0; - _fontType = 0; + _font = NULL; setDesignBounds(readRect(data)); _worldY = data->readSint16BE(); @@ -138,6 +137,7 @@ Scene::Scene(Common::String name, Common::SeekableReadStream *data) { Scene::~Scene() { delete _script; delete _textBounds; + delete _font; } void Scene::paint(Graphics::ManagedSurface *surface, int x, int y) { @@ -157,15 +157,6 @@ void Scene::paint(Graphics::ManagedSurface *surface, int x, int y) { } } -const char *Scene::getFontName() { - const char *name = ((WageEngine *)g_engine)->_gui->_wm.getFontName(_fontType, _fontSize); - - if (!name) - return "Unknown"; - - return name; -} - Designed *Scene::lookUpEntity(int x, int y) { for (ObjList::const_iterator it = _objs.end(); it != _objs.begin(); ) { it--; diff --git a/engines/wage/entities.h b/engines/wage/entities.h index b7cafb2294..a755af5360 100644 --- a/engines/wage/entities.h +++ b/engines/wage/entities.h @@ -50,6 +50,7 @@ namespace Graphics { class ManagedSurface; + class MacFont; } namespace Wage { @@ -308,8 +309,7 @@ public: Script *_script; Common::String _text; Common::Rect *_textBounds; - int _fontSize; - int _fontType; // 3 => Geneva, 22 => Courier, param to TextFont() function + Graphics::MacFont *_font; bool _blocked[4]; Common::String _messages[4]; int _soundFrequency; // times a minute, max 3600 @@ -334,7 +334,7 @@ public: void paint(Graphics::ManagedSurface *screen, int x, int y); - const char *getFontName(); + const Graphics::MacFont *getFont() { return _font; } }; } // End of namespace Wage diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp index a5e71463f7..37031f0dd9 100644 --- a/engines/wage/gui-console.cpp +++ b/engines/wage/gui-console.cpp @@ -51,6 +51,7 @@ #include "graphics/cursorman.h" #include "graphics/fonts/bdf.h" #include "graphics/palette.h" +#include "graphics/macgui/macfontmanager.h" #include "graphics/macgui/macwindow.h" #include "graphics/macgui/macmenu.h" @@ -65,7 +66,7 @@ namespace Wage { const Graphics::Font *Gui::getConsoleFont() { Scene *scene = _engine->_world->_player->_currentScene; - return _wm.getFont(scene->getFontName(), Graphics::FontManager::kConsoleFont); + return _wm._fontMan->getFont(*scene->getFont()); } void Gui::clearOutput() { diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp index 3e56c0daa7..100517b836 100644 --- a/engines/wage/world.cpp +++ b/engines/wage/world.cpp @@ -46,6 +46,7 @@ */ #include "common/file.h" +#include "graphics/macgui/macfontmanager.h" #include "wage/wage.h" #include "wage/entities.h" @@ -203,8 +204,9 @@ bool World::loadWorld(Common::MacResManager *resMan) { res = resMan->getResource(MKTAG('A','T','X','T'), *iter); if (res != NULL) { scene->_textBounds = readRect(res); - scene->_fontType = res->readUint16BE(); - scene->_fontSize = res->readUint16BE(); + int fontType = res->readUint16BE(); + int fontSize = res->readUint16BE(); + scene->_font = new Graphics::MacFont(fontType, fontSize, Graphics::FontManager::kConsoleFont); Common::String text; while (res->pos() < res->size()) { -- cgit v1.2.3