aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2015-12-31 18:50:34 +0100
committerEugene Sandulenko2015-12-31 18:50:34 +0100
commitdad200e50eb1096db39a282d5110225da92dbade (patch)
tree2320e76c006dd9a67682fac9dd52576abd126f8b /engines
parenta3cc6cdddcd49d95fc377f282a70e4894e1e0d59 (diff)
downloadscummvm-rg350-dad200e50eb1096db39a282d5110225da92dbade.tar.gz
scummvm-rg350-dad200e50eb1096db39a282d5110225da92dbade.tar.bz2
scummvm-rg350-dad200e50eb1096db39a282d5110225da92dbade.zip
WAGE: Load fonts from wage.dat
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/gui.cpp46
-rw-r--r--engines/wage/gui.h3
2 files changed, 49 insertions, 0 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index e4c7a455cf..cbaba94446 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -46,8 +46,10 @@
*/
#include "common/system.h"
+#include "common/unzip.h"
#include "graphics/fontman.h"
#include "graphics/font.h"
+#include "graphics/fonts/bdf.h"
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
@@ -74,8 +76,11 @@ Gui::Gui() {
Common::Rect r(0, 0, _screen.w, _screen.h);
_scrollPos = 0;
+ _builtInFonts = false;
Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
+
+ loadFonts();
}
Gui::~Gui() {
@@ -308,5 +313,46 @@ void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int heigh
g->copyRectToSurface(_console, x - kConOverscan, y - kConOverscan, boundsR);
}
+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;
+ }
+
+ 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;
+}
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 7be81baa54..91acfb3635 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -73,6 +73,7 @@ private:
void renderConsole(Graphics::Surface *g, int x, int y, int width, int height);
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
+ void loadFonts();
private:
Graphics::Surface _screen;
@@ -83,6 +84,8 @@ private:
Common::StringArray _out;
Common::StringArray _lines;
uint _scrollPos;
+
+ bool _builtInFonts;
};
} // End of namespace Wage