aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/riven_graphics.cpp82
-rw-r--r--engines/mohawk/riven_graphics.h16
-rw-r--r--engines/mohawk/riven_stacks/aspit.cpp55
3 files changed, 79 insertions, 74 deletions
diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp
index cc5105b15c..ac42b1207a 100644
--- a/engines/mohawk/riven_graphics.cpp
+++ b/engines/mohawk/riven_graphics.cpp
@@ -29,7 +29,12 @@
#include "mohawk/riven_video.h"
#include "common/system.h"
+
#include "engines/util.h"
+
+#include "graphics/fontman.h"
+#include "graphics/font.h"
+#include "graphics/fonts/ttf.h"
#include "graphics/colormasks.h"
namespace Mohawk {
@@ -317,6 +322,7 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) :
_transitionOffset(-1),
_waterEffect(nullptr),
_fliesEffect(nullptr),
+ _menuFont(nullptr),
_transitionFrames(0),
_transitionDuration(0) {
_bitmapDecoder = new MohawkBitmap();
@@ -332,6 +338,8 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) :
_effectScreen = new Graphics::Surface();
_effectScreen->create(608, 392, _pixelFormat);
+
+ loadMenuFont();
}
RivenGraphics::~RivenGraphics() {
@@ -342,6 +350,7 @@ RivenGraphics::~RivenGraphics() {
delete _bitmapDecoder;
clearFliesEffect();
clearWaterEffect();
+ delete _menuFont;
}
MohawkSurface *RivenGraphics::decodeImage(uint16 id) {
@@ -366,26 +375,6 @@ void RivenGraphics::copyImageToScreen(uint16 image, uint32 left, uint32 top, uin
applyScreenUpdate();
}
-void RivenGraphics::copySurfaceToScreen(Graphics::Surface *src, uint32 x, uint32 y) {
- beginScreenUpdate();
-
- int w = src->w;
- int h = src->h;
-
- // Clip the width to fit on the screen. Fixes some images.
- if (x + w > 608)
- w = 608 - x;
-
- if (y + h > 436)
- h = 346 - y;
-
- for (uint16 i = 0; i < h; i++)
- memcpy(_mainScreen->getBasePtr(x, i + y), src->getBasePtr(0, i), w * src->format.bytesPerPixel);
-
- _dirtyScreen = true;
- applyScreenUpdate();
-}
-
void RivenGraphics::updateScreen() {
if (_dirtyScreen) {
// Copy to screen if there's no transition. Otherwise transition.
@@ -782,6 +771,59 @@ void RivenGraphics::enableCardUpdateScript(bool enable) {
_enableCardUpdateScript = enable;
}
+void RivenGraphics::drawText(const Common::U32String &text, const Common::Rect &dest, uint8 greyLevel) {
+ _mainScreen->fillRect(dest, _pixelFormat.RGBToColor(0, 0, 0));
+
+ uint32 color = _pixelFormat.RGBToColor(greyLevel, greyLevel, greyLevel);
+
+ const Graphics::Font *font = getMenuFont();
+ font->drawString(_mainScreen, text, dest.left, dest.top, dest.width(), color);
+
+ _dirtyScreen = true;
+}
+
+void RivenGraphics::loadMenuFont() {
+ const char *fontName;
+
+ if (_vm->getLanguage() != Common::JA_JPN) {
+ fontName = "FreeSans.ttf";
+ } else {
+ fontName = "mplus-2c-regular.ttf";
+ }
+
+#if defined(USE_FREETYPE2)
+ int fontHeight;
+
+ if (_vm->getLanguage() != Common::JA_JPN) {
+ fontHeight = 12;
+ } else {
+ fontHeight = 11;
+ }
+
+ Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(fontName);
+ if (stream) {
+ _menuFont = Graphics::loadTTFFont(*stream, fontHeight);
+ delete stream;
+ }
+#endif
+
+ if (!_menuFont) {
+ warning("Cannot load font %s", fontName);
+ }
+}
+
+const Graphics::Font *RivenGraphics::getMenuFont() const {
+ const Graphics::Font *font;
+
+ if (_menuFont) {
+ font = _menuFont;
+ } else {
+ font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ }
+
+ return font;
+}
+
const FliesEffect::FliesEffectData FliesEffect::_firefliesParameters = {
true,
true,
diff --git a/engines/mohawk/riven_graphics.h b/engines/mohawk/riven_graphics.h
index 69a3182783..83d987d5e4 100644
--- a/engines/mohawk/riven_graphics.h
+++ b/engines/mohawk/riven_graphics.h
@@ -25,6 +25,12 @@
#include "mohawk/graphics.h"
+#include "common/ustr.h"
+
+namespace Graphics {
+struct Font;
+}
+
namespace Mohawk {
class MohawkEngine_Riven;
@@ -68,8 +74,6 @@ public:
void drawExtrasImage(uint16 id, const Common::Rect &dstRect);
void drawExtrasImageToScreen(uint16 id, const Common::Rect &rect);
- void copySurfaceToScreen(Graphics::Surface *src, uint32 x, uint32 y);
-
/** Copy a rect from the system screen to the game screen */
void copySystemRectToScreen(const Common::Rect &rect);
@@ -93,6 +97,9 @@ public:
void fadeToBlack();
void setTransitionMode(RivenTransitionMode mode);
+ // Main menu
+ void drawText(const Common::U32String &text, const Common::Rect &dest, uint8 greyLevel);
+
// Credits
void beginCredits();
void updateCredits();
@@ -130,6 +137,11 @@ private:
void updateScreen();
void clearMainScreen();
+ // Main menu
+ Graphics::Font *_menuFont;
+ void loadMenuFont();
+ const Graphics::Font *getMenuFont() const;
+
// Credits
uint _creditsImage, _creditsPos;
};
diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp
index 6f22786777..ba36dccdd7 100644
--- a/engines/mohawk/riven_stacks/aspit.cpp
+++ b/engines/mohawk/riven_stacks/aspit.cpp
@@ -93,42 +93,6 @@ void ASpit::xastartupbtnhide(const ArgumentArray &args) {
if (!(_vm->getFeatures() & GF_25TH))
return;
- Common::File file;
-
- const char *fontname;
- const Graphics::Font *font = nullptr;
-
- if (_vm->getLanguage() != Common::JA_JPN) {
- fontname = "FreeSans.ttf";
- } else {
- fontname = "mplus-2c-regular.ttf";
- }
-
-#if defined(USE_FREETYPE2)
- int fontHeight;
-
- if (_vm->getLanguage() != Common::JA_JPN) {
- fontHeight = 12;
- } else {
- fontHeight = 11;
- }
-
- if (file.open(fontname)) {
- font = Graphics::loadTTFFont(file, fontHeight);
- }
-#endif
-
- if (!font) {
- warning("Cannot load font %s directly", fontname);
- font = FontMan.getFontByName(fontname);
- }
-
- if (!font) {
- warning("Cannot load font %s", fontname);
-
- font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
- }
-
int lang = -1;
for (int i = 0; menuItems[i].language != -1; i++) {
if (menuItems[i].language == _vm->getLanguage()) {
@@ -168,24 +132,11 @@ void ASpit::xastartupbtnhide(const ArgumentArray &args) {
bool enabled = !items[i].requiresStartedGame || _vm->isGameStarted();
hotspot->enable(enabled);
- Common::Rect hotspotRect = hotspot->getRect();
-
- Graphics::Surface surface;
- surface.create(hotspotRect.width(), hotspotRect.height(), _vm->_gfx->getBackScreen()->format);
-
- uint32 textColor;
- if (enabled) {
- textColor = surface.format.RGBToColor(164, 164, 164);
- } else {
- textColor = surface.format.RGBToColor(96, 96, 96);
- }
-
Common::U32String str = Common::convertUtf8ToUtf32(menuItems[lang].items[i]);
+ Common::Rect hotspotRect = hotspot->getRect();
+ uint8 greyLevel = enabled ? 164 : 96;
- font->drawString(&surface, str, 0, 0, surface.w, textColor);
-
- _vm->_gfx->copySurfaceToScreen(&surface, hotspotRect.left, hotspotRect.top);
- surface.free();
+ _vm->_gfx->drawText(str, hotspotRect, greyLevel);
}
}