aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/dialog.cpp2
-rw-r--r--engines/wage/gui-console.cpp2
-rw-r--r--engines/wage/gui.cpp71
-rw-r--r--engines/wage/gui.h5
-rw-r--r--engines/wage/macwindow.cpp8
-rw-r--r--engines/wage/macwindowmanager.cpp67
-rw-r--r--engines/wage/macwindowmanager.h3
-rw-r--r--engines/wage/menu.cpp2
8 files changed, 77 insertions, 83 deletions
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index 263570bddc..5495409934 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -88,7 +88,7 @@ Dialog::~Dialog() {
}
const Graphics::Font *Dialog::getDialogFont() {
- return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+ return _gui->_wm.getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
void Dialog::paint() {
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index e0373687bf..0609b4f35c 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -68,7 +68,7 @@ const Graphics::Font *Gui::getConsoleFont() {
snprintf(fontName, 128, "%s-%d", scene->getFontName(), scene->_fontSize);
- return getFont(fontName, Graphics::FontManager::kConsoleFont);
+ return _wm.getFont(fontName, Graphics::FontManager::kConsoleFont);
}
void Gui::clearOutput() {
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 92b936f3e5..7752f2d7c3 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -46,9 +46,8 @@
*/
#include "common/timer.h"
-#include "common/unzip.h"
+#include "common/system.h"
#include "graphics/cursorman.h"
-#include "graphics/fonts/bdf.h"
#include "graphics/palette.h"
#include "graphics/primitives.h"
@@ -159,7 +158,6 @@ Gui::Gui(WageEngine *engine) {
_scrollPos = 0;
_consoleLineHeight = 8; // Dummy value which makes sense
_consoleNumLines = 24; // Dummy value
- _builtInFonts = false;
_cursorX = 0;
_cursorY = 0;
@@ -182,9 +180,6 @@ Gui::Gui(WageEngine *engine) {
for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
_patterns.push_back(fillPatterns[i]);
- loadFonts();
- _wm.setBuiltInFonts(_builtInFonts);
-
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
_menu = _wm.addMenu(this);
@@ -209,26 +204,6 @@ void Gui::undrawCursor() {
_cursorOff = false;
}
-const Graphics::Font *Gui::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
- const Graphics::Font *font = 0;
-
- if (!_builtInFonts) {
- font = FontMan.getFontByName(name);
-
- if (!font)
- warning("Cannot load font %s", name);
- }
-
- if (_builtInFonts || !font)
- font = FontMan.getFontByUsage(fallback);
-
- return font;
-}
-
-const Graphics::Font *Gui::getTitleFont() {
- return getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
-}
-
void Gui::draw() {
if (_engine->_isGameOver) {
_wm.draw();
@@ -419,50 +394,6 @@ bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
return false;
}
-void Gui::loadFonts() {
- Common::Archive *dat;
-
- dat = Common::makeZipArchive("wage.dat");
-
- if (!dat) {
- warning("Could not find wage.dat. Falling back to built-in fonts");
- _builtInFonts = true;
-
- return;
- }
-
- Common::ArchiveMemberList list;
- dat->listMembers(list);
-
- for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
- Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName());
-
- Graphics::BdfFont *font = Graphics::BdfFont::loadFont(*stream);
-
- delete stream;
-
- Common::String fontName = (*it)->getName();
-
- // Trim the .bdf extension
- for (int i = fontName.size() - 1; i >= 0; --i) {
- if (fontName[i] == '.') {
- while ((uint)i < fontName.size()) {
- fontName.deleteLastChar();
- }
- break;
- }
- }
-
- FontMan.assignFontToName(fontName, font);
-
- debug(2, " %s", fontName.c_str());
- }
-
- _builtInFonts = false;
-
- delete dat;
-}
-
void Gui::regenCommandsMenu() {
_menu->regenCommandsMenu();
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index d0af24c08b..9b1995c3f8 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -93,7 +93,6 @@ public:
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
- const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
void regenCommandsMenu();
void regenWeaponsMenu();
void pushArrowCursor();
@@ -108,8 +107,6 @@ public:
void disableAllMenus();
void enableNewGameMenus();
- bool builtInFonts() { return _builtInFonts; }
-
bool processSceneEvents(WindowClick click, Common::Event &event);
bool processConsoleEvents(WindowClick click, Common::Event &event);
@@ -120,7 +117,6 @@ private:
void drawConsole();
void undrawCursor();
void renderConsole(Graphics::ManagedSurface *g, const Common::Rect &r);
- void loadFonts();
void flowText(Common::String &str);
const Graphics::Font *getConsoleFont();
const Graphics::Font *getTitleFont();
@@ -134,7 +130,6 @@ public:
int _cursorX, _cursorY;
bool _cursorState;
- bool _builtInFonts;
WageEngine *_engine;
Patterns _patterns;
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index 199bbdc25d..c46def61b8 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -81,6 +81,10 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, MacWindowManager *
MacWindow::~MacWindow() {
}
+const Graphics::Font *MacWindow::getTitleFont() {
+ return _wm->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+}
+
void MacWindow::setActive(bool active) {
if (active == _active)
return;
@@ -145,10 +149,6 @@ bool MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
return true;
}
-const Graphics::Font *MacWindow::getTitleFont() {
- return ((WageEngine *)g_engine)->_gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
-}
-
#define ARROW_W 12
#define ARROW_H 6
const int arrowPixels[ARROW_H][ARROW_W] = {
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index b3cd15e448..402350d2fa 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -48,8 +48,10 @@
#include "common/array.h"
#include "common/events.h"
#include "common/list.h"
+#include "common/unzip.h"
#include "common/system.h"
+#include "graphics/fonts/bdf.h"
#include "graphics/managed_surface.h"
#include "wage/wage.h"
@@ -82,6 +84,8 @@ MacWindowManager::MacWindowManager() {
for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
_patterns.push_back(fillPatterns[i]);
+
+ loadFonts();
}
MacWindowManager::~MacWindowManager() {
@@ -185,4 +189,67 @@ bool MacWindowManager::processEvent(Common::Event &event) {
return false;
}
+//////////////////////
+// Font stuff
+//////////////////////
+void MacWindowManager::loadFonts() {
+ Common::Archive *dat;
+
+ dat = Common::makeZipArchive("classicmacfonts.dat");
+
+ if (!dat) {
+ warning("Could not find classicmacfonts.dat. Falling back to built-in fonts");
+ _builtInFonts = true;
+
+ return;
+ }
+
+ Common::ArchiveMemberList list;
+ dat->listMembers(list);
+
+ for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
+ Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName());
+
+ Graphics::BdfFont *font = Graphics::BdfFont::loadFont(*stream);
+
+ delete stream;
+
+ Common::String fontName = (*it)->getName();
+
+ // Trim the .bdf extension
+ for (int i = fontName.size() - 1; i >= 0; --i) {
+ if (fontName[i] == '.') {
+ while ((uint)i < fontName.size()) {
+ fontName.deleteLastChar();
+ }
+ break;
+ }
+ }
+
+ FontMan.assignFontToName(fontName, font);
+
+ debug(2, " %s", fontName.c_str());
+ }
+
+ _builtInFonts = false;
+
+ delete dat;
+}
+
+const Graphics::Font *MacWindowManager::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
+ const Graphics::Font *font = 0;
+
+ if (!_builtInFonts) {
+ font = FontMan.getFontByName(name);
+
+ if (!font)
+ warning("Cannot load font %s", name);
+ }
+
+ if (_builtInFonts || !font)
+ font = FontMan.getFontByUsage(fallback);
+
+ return font;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index c99120f00b..1c0b5c0aea 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -59,8 +59,8 @@ public:
~MacWindowManager();
void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; }
- void setBuiltInFonts(bool builtInFonts) { _builtInFonts = builtInFonts; }
bool hasBuiltInFonts() { return _builtInFonts; }
+ const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
MacWindow *addWindow(bool scrollable, bool resizable);
Menu *addMenu(Gui *gui);
@@ -76,6 +76,7 @@ public:
private:
void drawDesktop();
+ void loadFonts();
private:
Graphics::ManagedSurface *_screen;
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index e21adaed20..6a677fda5c 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -291,7 +291,7 @@ void Menu::createWeaponsMenu(MenuItem *menu) {
}
const Graphics::Font *Menu::getMenuFont() {
- return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+ return _wm->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) {