mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-01 00:12:59 +00:00
ULTIMA1: Beginnings of VGA status display
This commit is contained in:
parent
74fb21e767
commit
75bf34d7da
@ -70,6 +70,7 @@ void Game::setEGAPalette() {
|
||||
_highlightColor = 12;
|
||||
_textColor = 11;
|
||||
_color1 = 7;
|
||||
_bgColor = 0;
|
||||
}
|
||||
|
||||
void Game::loadU6Palette() {
|
||||
@ -88,8 +89,9 @@ void Game::loadU6Palette() {
|
||||
_edgeColor = 15;
|
||||
_borderColor = 1;
|
||||
_highlightColor = 12;
|
||||
_textColor = 11;
|
||||
_textColor = 72;
|
||||
_color1 = 7;
|
||||
_bgColor = 49;
|
||||
}
|
||||
|
||||
} // End of namespace Shared
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
byte _highlightColor;
|
||||
byte _textColor;
|
||||
byte _color1;
|
||||
byte _bgColor;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
|
@ -101,6 +101,11 @@ public:
|
||||
* Called when the game starts
|
||||
*/
|
||||
virtual void starting();
|
||||
|
||||
/**
|
||||
* Returns true if the current video mode is VGA
|
||||
*/
|
||||
virtual bool isVGA() const { return false; }
|
||||
|
||||
/**
|
||||
* Called once every frame to update the game and render the view
|
||||
|
@ -30,17 +30,19 @@ namespace Gfx {
|
||||
Font::Font(const byte *data, size_t startingChar, size_t charCount) :
|
||||
_data(data), _startingChar(startingChar), _endingChar(startingChar + charCount - 1) {}
|
||||
|
||||
int Font::writeString(Graphics::ManagedSurface &surface, const Common::String &msg, const Point &pt, byte color) {
|
||||
int Font::writeString(Graphics::ManagedSurface &surface, const Common::String &msg, const Point &pt,
|
||||
byte color, byte bgColor) {
|
||||
Point textPos = pt;
|
||||
int total = 0;
|
||||
|
||||
for (const char *msgP = msg.c_str(); *msgP; ++msgP, textPos.x += 8, total += 8)
|
||||
writeChar(surface, (unsigned char)*msgP, textPos, color);
|
||||
writeChar(surface, (unsigned char)*msgP, textPos, color, bgColor);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
void Font::writeChar(Graphics::ManagedSurface &surface, unsigned char c, const Point &pt, byte color) {
|
||||
void Font::writeChar(Graphics::ManagedSurface &surface, unsigned char c, const Point &pt,
|
||||
byte color, byte bgColor) {
|
||||
assert(c >= _startingChar && c <= _endingChar);
|
||||
const byte *charP = _data + (c - _startingChar) * 8;
|
||||
Graphics::Surface s = surface.getSubArea(Common::Rect(pt.x, pt.y, pt.x + 8, pt.y + 8));
|
||||
@ -50,7 +52,7 @@ void Font::writeChar(Graphics::ManagedSurface &surface, unsigned char c, const P
|
||||
byte lineData = charP[y];
|
||||
|
||||
for (int x = 0; x < 8; ++x, lineData <<= 1, ++lineP) {
|
||||
*lineP = (lineData & 0x80) ? color : 0;
|
||||
*lineP = (lineData & 0x80) ? color : bgColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,12 +42,14 @@ public:
|
||||
/**
|
||||
* Write out a string
|
||||
*/
|
||||
int writeString(Graphics::ManagedSurface &surface, const Common::String &msg, const Point &pt, byte color);
|
||||
int writeString(Graphics::ManagedSurface &surface, const Common::String &msg,
|
||||
const Point &pt, byte color, byte bgColor = 0);
|
||||
|
||||
/**
|
||||
* Draw a character
|
||||
*/
|
||||
void writeChar(Graphics::ManagedSurface &surface, unsigned char c, const Point &pt, byte color);
|
||||
void writeChar(Graphics::ManagedSurface &surface, unsigned char c, const Point &pt,
|
||||
byte color, byte bgColor = 0);
|
||||
|
||||
/**
|
||||
* Return the width of a character
|
||||
|
@ -37,24 +37,24 @@ void VisualSurface::drawPoint(const Point &pt, byte color) {
|
||||
fillRect(Rect(pt.x, pt.y, pt.x + 1, pt.y + 1), color);
|
||||
}
|
||||
|
||||
void VisualSurface::writeString(const Common::String &msg, const Point &pt, byte color) {
|
||||
void VisualSurface::writeString(const Common::String &msg, const Point &pt, byte color, byte bgColor) {
|
||||
_textPos = pt;
|
||||
writeString(msg, color);
|
||||
writeString(msg, color, bgColor);
|
||||
}
|
||||
|
||||
void VisualSurface::writeString(const Common::String &msg, byte color) {
|
||||
void VisualSurface::writeString(const Common::String &msg, byte color, byte bgColor) {
|
||||
Gfx::Font *font = g_vm->_game->getFont();
|
||||
_textPos.x += font->writeString(*this, msg, _textPos, color);
|
||||
_textPos.x += font->writeString(*this, msg, _textPos, color, bgColor);
|
||||
}
|
||||
|
||||
void VisualSurface::writeChar(unsigned char c, const Point &pt, byte color) {
|
||||
void VisualSurface::writeChar(unsigned char c, const Point &pt, byte color, byte bgColor) {
|
||||
_textPos = pt;
|
||||
writeChar(c, color);
|
||||
writeChar(c, color, bgColor);
|
||||
}
|
||||
|
||||
void VisualSurface::writeChar(unsigned char c, byte color) {
|
||||
void VisualSurface::writeChar(unsigned char c, byte color, byte bgColor) {
|
||||
Gfx::Font *font = g_vm->_game->getFont();
|
||||
font->writeChar(*this, c, _textPos, color);
|
||||
font->writeChar(*this, c, _textPos, color, bgColor);
|
||||
_textPos.x += font->charWidth(c);
|
||||
}
|
||||
|
||||
|
@ -54,22 +54,22 @@ public:
|
||||
/**
|
||||
* Write out a string
|
||||
*/
|
||||
void writeString(const Common::String &msg, const Point &pt, byte color);
|
||||
void writeString(const Common::String &msg, const Point &pt, byte color, byte bgColor = 0);
|
||||
|
||||
/**
|
||||
* Write out a string
|
||||
*/
|
||||
void writeString(const Common::String &msg, byte color);
|
||||
void writeString(const Common::String &msg, byte color, byte bgColor = 0);
|
||||
|
||||
/**
|
||||
* Draw a character
|
||||
*/
|
||||
void writeChar(unsigned char c, const Point &pt, byte color);
|
||||
void writeChar(unsigned char c, const Point &pt, byte color, byte bgColor = 0);
|
||||
|
||||
/**
|
||||
* Draw a character
|
||||
*/
|
||||
void writeChar(unsigned char c, byte color);
|
||||
void writeChar(unsigned char c, byte color, byte bgColor = 0);
|
||||
};
|
||||
|
||||
} // End of namespace Gfx
|
||||
|
@ -49,6 +49,11 @@ public:
|
||||
Ultima1Game();
|
||||
virtual ~Ultima1Game();
|
||||
|
||||
/**
|
||||
* Returns true if the current video mode is VGA
|
||||
*/
|
||||
virtual bool isVGA() const { return _videoMode == VIDEOMODE_VGA; }
|
||||
|
||||
/**
|
||||
* Called when the game starts
|
||||
*/
|
||||
|
@ -37,16 +37,17 @@ void Status::draw() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
s.clear();
|
||||
|
||||
// Iterate through displaying the four values
|
||||
// Iterate through displaying the values
|
||||
Shared::Character &c = gameState->_characters.front();
|
||||
const uint *vals[4] = { &c._hitPoints, &c._food, &c._experience, &c._coins };
|
||||
int count = game->isVGA() ? 3 : 4;
|
||||
|
||||
for (int idx = 0; idx < 4; ++idx) {
|
||||
for (int idx = 0; idx < count; ++idx) {
|
||||
// Write header
|
||||
s.writeString(game->_res->STATUS_TEXT[idx], TextPoint(0, idx), game->_textColor);
|
||||
s.writeString(game->_res->STATUS_TEXT[idx], TextPoint(0, idx), game->_textColor, game->_bgColor);
|
||||
|
||||
uint value = MIN(*vals[idx], (uint)9999);
|
||||
s.writeString(Common::String::format("%4u", value), TextPoint(5, idx), game->_textColor);
|
||||
s.writeString(Common::String::format("%4u", value), TextPoint(5, idx), game->_textColor, game->_bgColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ END_MESSAGE_MAP()
|
||||
|
||||
GameView::GameView(TreeItem *parent) : Shared::Gfx::VisualContainer("GameView", Rect(0, 0, 320, 200), parent) {
|
||||
_info = nullptr;
|
||||
_status = new U1Gfx::Status(this);
|
||||
_actions[0] = new Actions::Move(this);
|
||||
_actions[1] = new Actions::Climb(this);
|
||||
_actions[2] = new Actions::Enter(this);
|
||||
@ -53,6 +54,7 @@ GameView::GameView(TreeItem *parent) : Shared::Gfx::VisualContainer("GameView",
|
||||
|
||||
GameView::~GameView() {
|
||||
delete _info;
|
||||
delete _status;
|
||||
for (int idx = 0; idx < 3; ++idx)
|
||||
delete _actions[idx];
|
||||
}
|
||||
@ -91,6 +93,8 @@ void GameView::loadBackground() {
|
||||
void GameView::draw() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
s.blitFrom(_background);
|
||||
|
||||
_status->draw();
|
||||
}
|
||||
|
||||
bool GameView::KeypressMsg(CKeypressMsg &msg) {
|
||||
|
@ -36,6 +36,9 @@ namespace Ultima1 {
|
||||
namespace Actions {
|
||||
class Action;
|
||||
}
|
||||
namespace U1Gfx {
|
||||
class Status;
|
||||
}
|
||||
|
||||
namespace U6Gfx {
|
||||
|
||||
@ -66,6 +69,7 @@ class GameView : public Shared::Gfx::VisualContainer {
|
||||
bool KeypressMsg(CKeypressMsg &msg);
|
||||
private:
|
||||
Shared::Info *_info;
|
||||
U1Gfx::Status *_status;
|
||||
Shared::ViewportDungeon *_viewportDungeon;
|
||||
Actions::Action *_actions[3];
|
||||
Graphics::ManagedSurface _background;
|
||||
|
Loading…
x
Reference in New Issue
Block a user