AVALANCHE: Use the Color enum, remove some magic values, identify some dead variables

This commit is contained in:
Strangerke 2013-09-27 21:57:24 +02:00
parent d7230fe856
commit 649fa6e5f0
11 changed files with 45 additions and 38 deletions

View File

@ -81,8 +81,8 @@ void AnimationType::init(byte spritenum, bool doCheck, Animation *anim) {
_info._yLength = inf.readByte();
_stat._seq = inf.readByte();
_info._size = inf.readUint16LE();
_stat._fgBubbleCol = inf.readByte();
_stat._bgBubbleCol = inf.readByte();
_stat._fgBubbleCol = (Color)inf.readByte();
_stat._bgBubbleCol = (Color)inf.readByte();
_stat._acciNum = inf.readByte();
_animCount = 0; // = 1;

View File

@ -50,7 +50,7 @@ struct StatType {
Common::String _comment; // Comment.
byte _frameNum; // Number of pictures.
byte _seq; // How many in one stride.
byte _fgBubbleCol, _bgBubbleCol; // Foreground & background bubble colors.
Color _fgBubbleCol, _bgBubbleCol; // Foreground & background bubble colors.
byte _acciNum; // The number according to Acci. (1=Avvy, etc.)
};

View File

@ -279,7 +279,7 @@ public:
byte _thinks;
bool _thinkThing;
int16 _talkX, _talkY;
byte _talkBackgroundColor, _talkFontColor;
Color _talkBackgroundColor, _talkFontColor;
byte _scrollBells; // no. of times to ring the bell
bool _onToolbar, _seeScroll; // TODO: maybe this means we're interacting with the toolbar / a scroll?
char _objectList[10];

View File

@ -201,7 +201,7 @@ void Clock::update() { // TODO: Move variables from Gyro to here (or at least so
_oldMinute = _minute;
}
void Clock::calcHand(uint16 angle, uint16 length, Common::Point &endPoint, byte color) {
void Clock::calcHand(uint16 angle, uint16 length, Common::Point &endPoint, Color color) {
if (angle > 900) {
endPoint.x = 177;
return;
@ -210,7 +210,7 @@ void Clock::calcHand(uint16 angle, uint16 length, Common::Point &endPoint, byte
endPoint = _vm->_graphics->drawArc(_vm->_graphics->_surface, kCenterX, kCenterY, 449 - angle, 450 - angle, length, color);
}
void Clock::drawHand(const Common::Point &endPoint, byte color) {
void Clock::drawHand(const Common::Point &endPoint, Color color) {
if (endPoint.x == 177)
return;
@ -522,7 +522,7 @@ void AvalancheEngine::loadAlso(byte num) {
curLine->_y1 = file.readSint16LE();
curLine->_x2 = file.readSint16LE();
curLine->_y2 = file.readSint16LE();
curLine->_color = file.readByte();
curLine->_color = (Color)file.readByte();
}
memset(_peds, 177, sizeof(_peds));
@ -1483,6 +1483,7 @@ void AvalancheEngine::spriteRun() {
_doingSpriteRun = false;
}
// CHECKME: Unused function
void AvalancheEngine::fixFlashers() {
_ledStatus = 177;
_animation->setOldDirection(kDirNone);

View File

@ -57,8 +57,8 @@ private:
uint16 _hour, _minute, _second, _hourAngle, _oldHour, _oldMinute, _oldHourAngle;
Common::Point _clockHandHour, _clockHandMinute;
void calcHand(uint16 angle, uint16 length, Common::Point &endPoint, byte color);
void drawHand(const Common::Point &endPoint, byte color);
void calcHand(uint16 angle, uint16 length, Common::Point &endPoint, Color color);
void drawHand(const Common::Point &endPoint, Color color);
void plotHands();
void chime();
};
@ -92,13 +92,16 @@ struct ByteField {
};
struct LineType : public FieldType {
byte _color;
Color _color;
};
typedef int8 TuneType[31];
struct QuasipedType {
byte _whichPed, _foregroundColor, _room, _backgroundColor;
byte _whichPed;
Color _foregroundColor;
Room _room;
Color _backgroundColor;
People _who;
};

View File

@ -51,7 +51,7 @@ void Dialogs::setReadyLight(byte state) { // Sets "Ready" light to whatever
if (_vm->_ledStatus == state)
return; // Already like that!
byte color = kColorBlack;
Color color = kColorBlack;
switch (state) {
case 0:
color = kColorBlack;
@ -621,8 +621,8 @@ void Dialogs::reset() {
void Dialogs::setBubbleStateNatural() {
_vm->_talkX = 320;
_vm->_talkY = 200;
_vm->_talkBackgroundColor = 8;
_vm->_talkFontColor = 15;
_vm->_talkBackgroundColor = kColorDarkgray;
_vm->_talkFontColor = kColorWhite;
}
Common::String Dialogs::displayMoney() {

View File

@ -30,10 +30,10 @@
namespace Avalanche {
enum Color {
kColorBlack, kColorBlue, kColorGreen, kColorCyan, kColorRed,
kColorMagenta, kColorBrown, kColorLightgray, kColorDarkgray, kColorLightblue,
kColorLightgreen, kColorLightcyan, kColorLightred, kColorLightmagenta, kColorYellow,
kColorWhite
kColorBlack = 0, kColorBlue, kColorGreen, kColorCyan, kColorRed,
kColorMagenta = 5, kColorBrown, kColorLightgray, kColorDarkgray, kColorLightblue,
kColorLightgreen = 10, kColorLightcyan, kColorLightred, kColorLightmagenta, kColorYellow,
kColorWhite = 15
};
// CHECKME: kRoomBossKey is a guess

View File

@ -76,7 +76,7 @@ void Graphics::fleshColors() {
g_system->getPaletteManager()->setPalette(_egaPalette[28], 5, 1);
}
Common::Point Graphics::drawArc(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color) {
Common::Point Graphics::drawArc(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color) {
Common::Point endPoint;
const double pi = 3.14;
const double convfac = pi / 180.0;
@ -162,12 +162,12 @@ Common::Point Graphics::drawArc(::Graphics::Surface &surface, int16 x, int16 y,
return endPoint;
}
void Graphics::drawPieSlice(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color) {
void Graphics::drawPieSlice(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color) {
while (radius > 0)
drawArc(surface, x, y, stAngle, endAngle, radius--, color);
}
void Graphics::drawTriangle(::Graphics::Surface &surface, Common::Point *p, byte color) {
void Graphics::drawTriangle(::Graphics::Surface &surface, Common::Point *p, Color color) {
// Draw the borders with a marking color.
_scrolls.drawLine(p[0].x, p[0].y, p[1].x, p[1].y, 255);
_scrolls.drawLine(p[1].x, p[1].y, p[2].x, p[2].y, 255);
@ -204,7 +204,7 @@ void Graphics::drawTriangle(::Graphics::Surface &surface, Common::Point *p, byte
_scrolls.drawLine(p[2].x, p[2].y, p[0].x, p[0].y, color);
}
void Graphics::drawText(::Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, byte color) {
void Graphics::drawText(::Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color) {
for (uint i = 0; i < text.size(); i++) {
for (int j = 0; j < fontHeight; j++) {
byte pixel = font[(byte)text[i]][j];

View File

@ -32,6 +32,7 @@
#include "common/rect.h"
#include "graphics/surface.h"
#include "avalanche/enums.h"
namespace Avalanche {
class AvalancheEngine;
@ -74,11 +75,11 @@ public:
// Taken from Free Pascal's Procedure InternalEllipseDefault. Used to replace Pascal's procedure arc.
// Returns the end point of the arc. (Needed in Lucerna::lucerna_clock().)
// TODO: Make it more accurate later.
Common::Point drawArc(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color);
Common::Point drawArc(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
void drawPieSlice(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color);
void drawTriangle(::Graphics::Surface &surface, Common::Point *p, byte color);
void drawText(::Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, byte color);
void drawPieSlice(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
void drawTriangle(::Graphics::Surface &surface, Common::Point *p, Color color);
void drawText(::Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
// The caller has to .free() the returned Surfaces!!!
// Further information about these two: http://www.shikadi.net/moddingwiki/Raw_EGA_data

View File

@ -103,11 +103,11 @@ void MenuItem::setupOption(Common::String title, char trigger, Common::String sh
}
void MenuItem::displayOption(byte y, bool highlit) {
byte backgroundColor;
Color backgroundColor;
if (highlit)
backgroundColor = 0;
backgroundColor = kColorBlack;
else
backgroundColor = 7;
backgroundColor = kColorLightgray;
_dr->_vm->_graphics->_surface.fillRect(Common::Rect((_flx1 + 1) * 8, 3 + (y + 1) * 10, (_flx2 + 1) * 8, 13 + (y + 1) * 10), backgroundColor);
Common::String text = _options[y]._title;
@ -290,8 +290,8 @@ void Menu::findWhatYouCanDoWithIt() {
}
void Menu::drawMenuText(int16 x, int16 y, char trigger, Common::String text, bool valid, bool highlighted) {
byte fontColor;
byte backgroundColor;
Color fontColor;
Color backgroundColor;
if (highlighted) {
fontColor = kColorWhite;
backgroundColor = kColorBlack;
@ -339,7 +339,7 @@ void Menu::drawMenuText(int16 x, int16 y, char trigger, Common::String text, boo
}
void Menu::bleep() {
warning("STUB: Dropdown::bleep()");
warning("STUB: Menu::bleep()");
}
void Menu::parseKey(char r, char re) {

View File

@ -131,12 +131,14 @@ private:
static const byte kIndent = 5;
static const byte kSpacing = 10;
static const byte kMenuBackgroundColor = kColorLightgray;
static const byte kMenuFontColor = kColorBlack;
static const byte kMenuBorderColor = kColorBlack;
static const byte kHighlightBackgroundColor = kColorBlack;
static const byte kHighlightFontColor = kColorWhite;
static const byte kDisabledColor = kColorDarkgray;
static const Color kMenuBackgroundColor = kColorLightgray;
static const Color kMenuBorderColor = kColorBlack;
// Checkme: Useless constants?
// static const Color kMenuFontColor = kColorBlack;
// static const Color kHighlightBackgroundColor = kColorBlack;
// static const Color kHighlightFontColor = kColorWhite;
// static const Color kDisabledColor = kColorDarkgray;
bool _menuActive; // Kludge so we don't have to keep referring to the menu.