Skip to content

Commit

Permalink
MOHAWK: Use ScummVM GUI fonts for the cstime demo
Browse files Browse the repository at this point in the history
The demo is now playable without using fonts from the full game
  • Loading branch information
Matthew Hoops committed Mar 31, 2011
1 parent e705759 commit 84c45ea
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
40 changes: 34 additions & 6 deletions engines/mohawk/cstime_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "mohawk/resource.h"
#include "common/algorithm.h" // find
#include "common/events.h"
#include "graphics/fontman.h"

namespace Mohawk {

Expand Down Expand Up @@ -64,12 +65,15 @@ CSTimeInterface::CSTimeInterface(MohawkEngine_CSTime *vm) : _vm(vm) {
_note = new CSTimeCarmenNote(_vm);
_options = new CSTimeOptions(_vm);

if (!_normalFont.loadFromFON("EvP14.fon"))
error("failed to load normal font");
if (!_dialogFont.loadFromFON("Int1212.fon"))
error("failed to load dialog font");
if (!_rolloverFont.loadFromFON("Int1818.fon"))
error("failed to load rollover font");
// The demo uses hardcoded system fonts
if (!(_vm->getFeatures() & GF_DEMO)) {
if (!_normalFont.loadFromFON("EvP14.fon"))
error("failed to load normal font");
if (!_dialogFont.loadFromFON("Int1212.fon"))
error("failed to load dialog font");
if (!_rolloverFont.loadFromFON("Int1818.fon"))
error("failed to load rollover font");
}

_uiFeature = NULL;
_dialogTextFeature = NULL;
Expand All @@ -91,6 +95,30 @@ CSTimeInterface::~CSTimeInterface() {
delete _options;
}

const Graphics::Font &CSTimeInterface::getNormalFont() const {
// HACK: Use a ScummVM GUI font in place of a system one for the demo
if (_vm->getFeatures() & GF_DEMO)
return *FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);

return _normalFont;
}

const Graphics::Font &CSTimeInterface::getDialogFont() const {
// HACK: Use a ScummVM GUI font in place of a system one for the demo
if (_vm->getFeatures() & GF_DEMO)
return *FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);

return _dialogFont;
}

const Graphics::Font &CSTimeInterface::getRolloverFont() const {
// HACK: Use a ScummVM GUI font in place of a system one for the demo
if (_vm->getFeatures() & GF_DEMO)
return *FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);

return _rolloverFont;
}

void CSTimeInterface::cursorInstall() {
_vm->getView()->loadBitmapCursors(200);
}
Expand Down
6 changes: 3 additions & 3 deletions engines/mohawk/cstime_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ class CSTimeInterface {
const Common::Array<Common::String> &getDialogLines() { return _dialogLines; }
const Common::Array<byte> &getDialogLineColors() { return _dialogLineColors; }

const Graphics::WinFont &getNormalFont() { return _normalFont; }
const Graphics::WinFont &getDialogFont() { return _dialogFont; }
const Graphics::WinFont &getRolloverFont() { return _rolloverFont; }
const Graphics::Font &getNormalFont() const;
const Graphics::Font &getDialogFont() const;
const Graphics::Font &getRolloverFont() const;

Common::Rect _sceneRect, _uiRect;
Common::Rect _dialogTextRect, _bookRect, _noteRect;
Expand Down
4 changes: 2 additions & 2 deletions engines/mohawk/cstime_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void CSTimeModule::dialogTextDrawProc(Feature *feature) {
const Common::Array<Common::String> &lines = _vm->getInterface()->getDialogLines();
const Common::Array<byte> &colors = _vm->getInterface()->getDialogLineColors();
const Common::Rect &bounds = feature->_data.bounds;
const Graphics::WinFont &font = _vm->getInterface()->getDialogFont();
const Graphics::Font &font = _vm->getInterface()->getDialogFont();

Graphics::Surface *screen = _vm->_system->lockScreen();
for (uint i = 0; i < lines.size(); i++)
Expand All @@ -553,7 +553,7 @@ void CSTimeModule::bubbleTextMoveProc(Feature *feature) {
void CSTimeModule::bubbleTextDrawProc(Feature *feature) {
Common::Rect bounds = feature->_data.bounds;
bounds.grow(-5);
const Graphics::WinFont &font = _vm->getInterface()->getDialogFont();
const Graphics::Font &font = _vm->getInterface()->getDialogFont();
uint height = font.getFontHeight();

Common::Array<Common::String> lines;
Expand Down

0 comments on commit 84c45ea

Please sign in to comment.