MOHAWK: RIVEN: Draw menu with TTF fonts

This commit is contained in:
Eugene Sandulenko 2018-06-15 00:48:00 +02:00 committed by Bastien Bouclet
parent 1e9b58ab4b
commit 0ca52f62a4
3 changed files with 69 additions and 0 deletions

View File

@ -366,6 +366,26 @@ 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.

View File

@ -68,6 +68,8 @@ 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);

View File

@ -31,6 +31,10 @@
#include "common/translation.h"
#include "graphics/fonts/ttf.h"
#include "graphics/font.h"
#include "graphics/fontman.h"
#include "gui/message.h"
namespace Mohawk {
@ -62,9 +66,52 @@ ASpit::ASpit(MohawkEngine_Riven *vm) :
REGISTER_COMMAND(ASpit, xaexittomain);
}
static const char *menuItems[] = {
"SETUP",
"START NEW GAME",
"START SAVED GAME",
0
};
void ASpit::xastartupbtnhide(const ArgumentArray &args) {
// The original game hides the start/setup buttons depending on an ini entry.
// It's safe to ignore this command.
warning("xastartupbtnhide");
Graphics::Surface surface;
surface.create(115, 200, _vm->_gfx->getBackScreen()->format);
surface.fillRect(Common::Rect(0, 0, 115, 200), 0);
Common::File file;
const char *fontname = "FreeSans.ttf";
int fontHeight = 11;
const Graphics::Font *font = nullptr;
if (file.open(fontname)) {
font = Graphics::loadTTFFont(file, fontHeight);
}
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 y = 70;
for (const char **item = menuItems; *item; item++) {
font->drawString(&surface, *item, 0, y, surface.w, 0xffffff);
y += fontHeight * 2.5;
}
_vm->_gfx->copySurfaceToScreen(&surface, 485, 160);
}
void ASpit::xasetupcomplete(const ArgumentArray &args) {