Extended balloon manager to handle color constants and fixed color of text in balloons for BRA.
svn-id: r33940
This commit is contained in:
parent
b08a3885a8
commit
fbc9483ed2
4 changed files with 48 additions and 32 deletions
|
@ -246,6 +246,8 @@ class BalloonManager_ns : public BalloonManager {
|
||||||
|
|
||||||
static int16 _dialogueBalloonX[5];
|
static int16 _dialogueBalloonX[5];
|
||||||
|
|
||||||
|
byte _textColors[2];
|
||||||
|
|
||||||
struct Balloon {
|
struct Balloon {
|
||||||
Common::Rect outerBox;
|
Common::Rect outerBox;
|
||||||
Common::Rect innerBox;
|
Common::Rect innerBox;
|
||||||
|
@ -266,16 +268,18 @@ public:
|
||||||
|
|
||||||
void freeBalloons();
|
void freeBalloons();
|
||||||
int setLocationBalloon(char *text, bool endGame);
|
int setLocationBalloon(char *text, bool endGame);
|
||||||
int setDialogueBalloon(char *text, uint16 winding, byte textColor);
|
int setDialogueBalloon(char *text, uint16 winding, TextColor textColor);
|
||||||
int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor);
|
int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor);
|
||||||
void setBalloonText(uint id, char *text, byte textColor);
|
void setBalloonText(uint id, char *text, TextColor textColor);
|
||||||
int hitTestDialogueBalloon(int x, int y);
|
int hitTestDialogueBalloon(int x, int y);
|
||||||
};
|
};
|
||||||
|
|
||||||
int16 BalloonManager_ns::_dialogueBalloonX[5] = { 80, 120, 150, 150, 150 };
|
int16 BalloonManager_ns::_dialogueBalloonX[5] = { 80, 120, 150, 150, 150 };
|
||||||
|
|
||||||
BalloonManager_ns::BalloonManager_ns(Gfx *gfx) : _numBalloons(0), _gfx(gfx) {
|
BalloonManager_ns::BalloonManager_ns(Gfx *gfx) : _numBalloons(0), _gfx(gfx) {
|
||||||
|
_textColors[kSelectedColor] = 0;
|
||||||
|
_textColors[kUnselectedColor] = 3;
|
||||||
|
_textColors[kNormalColor] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BalloonManager_ns::~BalloonManager_ns() {
|
BalloonManager_ns::~BalloonManager_ns() {
|
||||||
|
@ -323,7 +327,7 @@ int BalloonManager_ns::createBalloon(int16 w, int16 h, int16 winding, uint16 bor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BalloonManager_ns::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor) {
|
int BalloonManager_ns::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor) {
|
||||||
|
|
||||||
int16 w, h;
|
int16 w, h;
|
||||||
|
|
||||||
|
@ -336,7 +340,7 @@ int BalloonManager_ns::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 w
|
||||||
Balloon *balloon = &_intBalloons[id];
|
Balloon *balloon = &_intBalloons[id];
|
||||||
|
|
||||||
StringWriter_NS sw(_vm->_dialogueFont);
|
StringWriter_NS sw(_vm->_dialogueFont);
|
||||||
sw.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
|
sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
|
||||||
|
|
||||||
// TODO: extract some text to make a name for obj
|
// TODO: extract some text to make a name for obj
|
||||||
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
||||||
|
@ -347,7 +351,7 @@ int BalloonManager_ns::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 w
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BalloonManager_ns::setDialogueBalloon(char *text, uint16 winding, byte textColor) {
|
int BalloonManager_ns::setDialogueBalloon(char *text, uint16 winding, TextColor textColor) {
|
||||||
|
|
||||||
int16 w, h;
|
int16 w, h;
|
||||||
|
|
||||||
|
@ -361,7 +365,7 @@ int BalloonManager_ns::setDialogueBalloon(char *text, uint16 winding, byte textC
|
||||||
Balloon *balloon = &_intBalloons[id];
|
Balloon *balloon = &_intBalloons[id];
|
||||||
|
|
||||||
StringWriter_NS sw(_vm->_dialogueFont);
|
StringWriter_NS sw(_vm->_dialogueFont);
|
||||||
sw.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
|
sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
|
||||||
|
|
||||||
// TODO: extract some text to make a name for obj
|
// TODO: extract some text to make a name for obj
|
||||||
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
||||||
|
@ -377,12 +381,12 @@ int BalloonManager_ns::setDialogueBalloon(char *text, uint16 winding, byte textC
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BalloonManager_ns::setBalloonText(uint id, char *text, byte textColor) {
|
void BalloonManager_ns::setBalloonText(uint id, char *text, TextColor textColor) {
|
||||||
Balloon *balloon = getBalloon(id);
|
Balloon *balloon = getBalloon(id);
|
||||||
balloon->surface->fillRect(balloon->innerBox, 1);
|
balloon->surface->fillRect(balloon->innerBox, 1);
|
||||||
|
|
||||||
StringWriter_NS sw(_vm->_dialogueFont);
|
StringWriter_NS sw(_vm->_dialogueFont);
|
||||||
sw.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
|
sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -398,7 +402,7 @@ int BalloonManager_ns::setLocationBalloon(char *text, bool endGame) {
|
||||||
int id = createBalloon(w+(endGame ? 5 : 10), h+5, -1, BALLOON_TRANSPARENT_COLOR_NS);
|
int id = createBalloon(w+(endGame ? 5 : 10), h+5, -1, BALLOON_TRANSPARENT_COLOR_NS);
|
||||||
Balloon *balloon = &_intBalloons[id];
|
Balloon *balloon = &_intBalloons[id];
|
||||||
StringWriter_NS sw(_vm->_dialogueFont);
|
StringWriter_NS sw(_vm->_dialogueFont);
|
||||||
sw.write(text, MAX_BALLOON_WIDTH, 0, balloon->surface);
|
sw.write(text, MAX_BALLOON_WIDTH, _textColors[kNormalColor], balloon->surface);
|
||||||
|
|
||||||
// TODO: extract some text to make a name for obj
|
// TODO: extract some text to make a name for obj
|
||||||
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
||||||
|
@ -534,6 +538,8 @@ public:
|
||||||
|
|
||||||
class BalloonManager_br : public BalloonManager {
|
class BalloonManager_br : public BalloonManager {
|
||||||
|
|
||||||
|
byte _textColors[2];
|
||||||
|
|
||||||
struct Balloon {
|
struct Balloon {
|
||||||
Common::Rect box;
|
Common::Rect box;
|
||||||
Graphics::Surface *surface;
|
Graphics::Surface *surface;
|
||||||
|
@ -562,9 +568,9 @@ public:
|
||||||
|
|
||||||
void freeBalloons();
|
void freeBalloons();
|
||||||
int setLocationBalloon(char *text, bool endGame);
|
int setLocationBalloon(char *text, bool endGame);
|
||||||
int setDialogueBalloon(char *text, uint16 winding, byte textColor);
|
int setDialogueBalloon(char *text, uint16 winding, TextColor textColor);
|
||||||
int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor);
|
int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor);
|
||||||
void setBalloonText(uint id, char *text, byte textColor);
|
void setBalloonText(uint id, char *text, TextColor textColor);
|
||||||
int hitTestDialogueBalloon(int x, int y);
|
int hitTestDialogueBalloon(int x, int y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -590,7 +596,7 @@ Graphics::Surface *BalloonManager_br::expandBalloon(Frames *data, int frameNum)
|
||||||
return surf;
|
return surf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BalloonManager_br::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor) {
|
int BalloonManager_br::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor) {
|
||||||
cacheAnims();
|
cacheAnims();
|
||||||
|
|
||||||
int id = _numBalloons;
|
int id = _numBalloons;
|
||||||
|
@ -613,7 +619,7 @@ int BalloonManager_br::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 w
|
||||||
balloon->surface = expandBalloon(src, srcFrame);
|
balloon->surface = expandBalloon(src, srcFrame);
|
||||||
src->getRect(srcFrame, balloon->box);
|
src->getRect(srcFrame, balloon->box);
|
||||||
|
|
||||||
_writer.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
|
_writer.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
|
||||||
|
|
||||||
// TODO: extract some text to make a name for obj
|
// TODO: extract some text to make a name for obj
|
||||||
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
||||||
|
@ -626,7 +632,7 @@ int BalloonManager_br::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 w
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BalloonManager_br::setDialogueBalloon(char *text, uint16 winding, byte textColor) {
|
int BalloonManager_br::setDialogueBalloon(char *text, uint16 winding, TextColor textColor) {
|
||||||
cacheAnims();
|
cacheAnims();
|
||||||
|
|
||||||
int id = _numBalloons;
|
int id = _numBalloons;
|
||||||
|
@ -649,7 +655,7 @@ int BalloonManager_br::setDialogueBalloon(char *text, uint16 winding, byte textC
|
||||||
balloon->surface = expandBalloon(src, srcFrame);
|
balloon->surface = expandBalloon(src, srcFrame);
|
||||||
src->getRect(srcFrame, balloon->box);
|
src->getRect(srcFrame, balloon->box);
|
||||||
|
|
||||||
_writer.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
|
_writer.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
|
||||||
|
|
||||||
// TODO: extract some text to make a name for obj
|
// TODO: extract some text to make a name for obj
|
||||||
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
|
||||||
|
@ -662,11 +668,11 @@ int BalloonManager_br::setDialogueBalloon(char *text, uint16 winding, byte textC
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BalloonManager_br::setBalloonText(uint id, char *text, byte textColor) {
|
void BalloonManager_br::setBalloonText(uint id, char *text, TextColor textColor) {
|
||||||
Balloon *balloon = getBalloon(id);
|
Balloon *balloon = getBalloon(id);
|
||||||
|
|
||||||
StringWriter_BR sw(_vm->_dialogueFont);
|
StringWriter_BR sw(_vm->_dialogueFont);
|
||||||
sw.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
|
sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BalloonManager_br::setLocationBalloon(char *text, bool endGame) {
|
int BalloonManager_br::setLocationBalloon(char *text, bool endGame) {
|
||||||
|
@ -722,6 +728,10 @@ void BalloonManager_br::cacheAnims() {
|
||||||
|
|
||||||
BalloonManager_br::BalloonManager_br(Disk *disk, Gfx *gfx) : _numBalloons(0), _disk(disk), _gfx(gfx),
|
BalloonManager_br::BalloonManager_br(Disk *disk, Gfx *gfx) : _numBalloons(0), _disk(disk), _gfx(gfx),
|
||||||
_leftBalloon(0), _rightBalloon(0), _writer(_vm->_dialogueFont) {
|
_leftBalloon(0), _rightBalloon(0), _writer(_vm->_dialogueFont) {
|
||||||
|
|
||||||
|
_textColors[kSelectedColor] = 12;
|
||||||
|
_textColors[kUnselectedColor] = 0;
|
||||||
|
_textColors[kNormalColor] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BalloonManager_br::~BalloonManager_br() {
|
BalloonManager_br::~BalloonManager_br() {
|
||||||
|
|
|
@ -173,7 +173,7 @@ bool DialogueManager::displayAnswer(uint16 i) {
|
||||||
// display suitable answers
|
// display suitable answers
|
||||||
if (((a->_yesFlags & flags) == a->_yesFlags) && ((a->_noFlags & ~flags) == a->_noFlags)) {
|
if (((a->_yesFlags & flags) == a->_yesFlags) && ((a->_noFlags & ~flags) == a->_noFlags)) {
|
||||||
|
|
||||||
int id = _vm->_balloonMan->setDialogueBalloon(a->_text, 1, 3);
|
int id = _vm->_balloonMan->setDialogueBalloon(a->_text, 1, BalloonManager::kUnselectedColor);
|
||||||
assert(id >= 0);
|
assert(id >= 0);
|
||||||
_visAnswers[id] = i;
|
_visAnswers[id] = i;
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ bool DialogueManager::displayAnswers() {
|
||||||
if (_numVisAnswers == 1) {
|
if (_numVisAnswers == 1) {
|
||||||
int id = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
|
int id = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
|
||||||
_vm->_gfx->setItemFrame(id, _q->_answers[0]->_mood & 0xF);
|
_vm->_gfx->setItemFrame(id, _q->_answers[0]->_mood & 0xF);
|
||||||
_vm->_balloonMan->setBalloonText(0, _q->_answers[_visAnswers[0]]->_text, 0);
|
_vm->_balloonMan->setBalloonText(0, _q->_answers[_visAnswers[0]]->_text, BalloonManager::kNormalColor);
|
||||||
} else
|
} else
|
||||||
if (_numVisAnswers > 1) {
|
if (_numVisAnswers > 1) {
|
||||||
int id = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
|
int id = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
|
||||||
|
@ -218,7 +218,7 @@ bool DialogueManager::displayAnswers() {
|
||||||
bool DialogueManager::displayQuestion() {
|
bool DialogueManager::displayQuestion() {
|
||||||
if (!scumm_stricmp(_q->_text, "NULL")) return false;
|
if (!scumm_stricmp(_q->_text, "NULL")) return false;
|
||||||
|
|
||||||
_vm->_balloonMan->setSingleBalloon(_q->_text, _ballonPos._questionBalloon.x, _ballonPos._questionBalloon.y, _q->_mood & 0x10, 0);
|
_vm->_balloonMan->setSingleBalloon(_q->_text, _ballonPos._questionBalloon.x, _ballonPos._questionBalloon.y, _q->_mood & 0x10, BalloonManager::kNormalColor);
|
||||||
int id = _vm->_gfx->setItem(_questioner, _ballonPos._questionChar.x, _ballonPos._questionChar.y);
|
int id = _vm->_gfx->setItem(_questioner, _ballonPos._questionChar.x, _ballonPos._questionChar.y);
|
||||||
_vm->_gfx->setItemFrame(id, _q->_mood & 0xF);
|
_vm->_gfx->setItemFrame(id, _q->_mood & 0xF);
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ int16 DialogueManager::askPassword() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_passwordChanged) {
|
if (_passwordChanged) {
|
||||||
_vm->_balloonMan->setBalloonText(0, _q->_answers[0]->_text, 3);
|
_vm->_balloonMan->setBalloonText(0, _q->_answers[0]->_text, BalloonManager::kNormalColor);
|
||||||
_passwordChanged = false;
|
_passwordChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,11 +286,11 @@ int16 DialogueManager::selectAnswerN() {
|
||||||
|
|
||||||
if (_selection != _oldSelection) {
|
if (_selection != _oldSelection) {
|
||||||
if (_oldSelection != -1) {
|
if (_oldSelection != -1) {
|
||||||
_vm->_balloonMan->setBalloonText(_oldSelection, _q->_answers[_visAnswers[_oldSelection]]->_text, 3);
|
_vm->_balloonMan->setBalloonText(_oldSelection, _q->_answers[_visAnswers[_oldSelection]]->_text, BalloonManager::kUnselectedColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_selection != -1) {
|
if (_selection != -1) {
|
||||||
_vm->_balloonMan->setBalloonText(_selection, _q->_answers[_visAnswers[_selection]]->_text, 0);
|
_vm->_balloonMan->setBalloonText(_selection, _q->_answers[_visAnswers[_selection]]->_text, BalloonManager::kSelectedColor);
|
||||||
_vm->_gfx->setItemFrame(0, _q->_answers[_visAnswers[_selection]]->_mood & 0xF);
|
_vm->_gfx->setItemFrame(0, _q->_answers[_visAnswers[_selection]]->_mood & 0xF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,7 +558,7 @@ void Parallaction::enterCommentMode(ZonePtr z) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_gfx->setHalfbriteMode(true);
|
_gfx->setHalfbriteMode(true);
|
||||||
_balloonMan->setSingleBalloon(data->_description, 0, 90, 0, 0);
|
_balloonMan->setSingleBalloon(data->_description, 0, 90, 0, BalloonManager::kNormalColor);
|
||||||
Common::Rect r;
|
Common::Rect r;
|
||||||
data->_cnv->getRect(0, r);
|
data->_cnv->getRect(0, r);
|
||||||
id = _gfx->setItem(data->_cnv, 140, (_screenHeight - r.height())/2);
|
id = _gfx->setItem(data->_cnv, 140, (_screenHeight - r.height())/2);
|
||||||
|
@ -566,13 +566,13 @@ void Parallaction::enterCommentMode(ZonePtr z) {
|
||||||
id = _gfx->setItem(_char._head, 100, 152);
|
id = _gfx->setItem(_char._head, 100, 152);
|
||||||
_gfx->setItemFrame(id, 0);
|
_gfx->setItemFrame(id, 0);
|
||||||
} else {
|
} else {
|
||||||
_balloonMan->setSingleBalloon(data->_description, 140, 10, 0, 0);
|
_balloonMan->setSingleBalloon(data->_description, 140, 10, 0, BalloonManager::kNormalColor);
|
||||||
id = _gfx->setItem(_char._talk, 190, 80);
|
id = _gfx->setItem(_char._talk, 190, 80);
|
||||||
_gfx->setItemFrame(id, 0);
|
_gfx->setItemFrame(id, 0);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (getGameType() == GType_BRA) {
|
if (getGameType() == GType_BRA) {
|
||||||
_balloonMan->setSingleBalloon(data->_description, 0, 0, 1, 0);
|
_balloonMan->setSingleBalloon(data->_description, 0, 0, 1, BalloonManager::kNormalColor);
|
||||||
int id = _gfx->setItem(_char._talk, 10, 80);
|
int id = _gfx->setItem(_char._talk, 10, 80);
|
||||||
_gfx->setItemFrame(id, 0);
|
_gfx->setItemFrame(id, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,13 +495,19 @@ enum {
|
||||||
|
|
||||||
class BalloonManager {
|
class BalloonManager {
|
||||||
public:
|
public:
|
||||||
|
enum TextColor {
|
||||||
|
kSelectedColor = 0,
|
||||||
|
kUnselectedColor = 1,
|
||||||
|
kNormalColor = 2
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~BalloonManager() { }
|
virtual ~BalloonManager() { }
|
||||||
|
|
||||||
virtual void freeBalloons() = 0;
|
virtual void freeBalloons() = 0;
|
||||||
virtual int setLocationBalloon(char *text, bool endGame) = 0;
|
virtual int setLocationBalloon(char *text, bool endGame) = 0;
|
||||||
virtual int setDialogueBalloon(char *text, uint16 winding, byte textColor) = 0;
|
virtual int setDialogueBalloon(char *text, uint16 winding, TextColor textColor) = 0;
|
||||||
virtual int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor) = 0;
|
virtual int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor) = 0;
|
||||||
virtual void setBalloonText(uint id, char *text, byte textColor) = 0;
|
virtual void setBalloonText(uint id, char *text, TextColor textColor) = 0;
|
||||||
virtual int hitTestDialogueBalloon(int x, int y) = 0;
|
virtual int hitTestDialogueBalloon(int x, int y) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue