diff options
author | Paul Gilbert | 2016-04-25 20:38:23 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:12:02 -0400 |
commit | 1512545f28c805fd4083be746220f77b72463130 (patch) | |
tree | 9d9e6ea5e6499d0e90b5bebeba3d58e3731b3455 /engines | |
parent | 36faf0890fec6bab90531ade42c0eb924b31b64a (diff) | |
download | scummvm-rg350-1512545f28c805fd4083be746220f77b72463130.tar.gz scummvm-rg350-1512545f28c805fd4083be746220f77b72463130.tar.bz2 scummvm-rg350-1512545f28c805fd4083be746220f77b72463130.zip |
TITANIC: Resolve color handling code in CPetText
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/pet_control/pet_load_save.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_quit.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_real_life.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_sound.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_text.cpp | 42 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_text.h | 15 | ||||
-rw-r--r-- | engines/titanic/support/font.cpp | 10 | ||||
-rw-r--r-- | engines/titanic/support/font.h | 2 |
9 files changed, 45 insertions, 40 deletions
diff --git a/engines/titanic/pet_control/pet_load_save.cpp b/engines/titanic/pet_control/pet_load_save.cpp index 9d185a3742..5bfa1d635a 100644 --- a/engines/titanic/pet_control/pet_load_save.cpp +++ b/engines/titanic/pet_control/pet_load_save.cpp @@ -155,7 +155,7 @@ void CPetLoadSave::highlightChange() { // TODO: Unknown if check if (true) { col = section ? section->getColor(4) : 0; - _slotNames[_savegameSlotNum].setColor(0, col); + _slotNames[_savegameSlotNum].setLineColor(0, col); } } diff --git a/engines/titanic/pet_control/pet_quit.cpp b/engines/titanic/pet_control/pet_quit.cpp index 7dcaba895c..b92a362dd3 100644 --- a/engines/titanic/pet_control/pet_quit.cpp +++ b/engines/titanic/pet_control/pet_quit.cpp @@ -54,7 +54,7 @@ bool CPetQuit::reset() { uint col = getPetSection()->getColor(0); _text.setText("Are you sure you want to quit?"); - _text.setColor(0, col); + _text.setLineColor(0, col); _btnYes.reset("PetQuitOut", pet, MODE_UNSELECTED); _btnYes.reset("PetQuitIn", pet, MODE_SELECTED); diff --git a/engines/titanic/pet_control/pet_real_life.cpp b/engines/titanic/pet_control/pet_real_life.cpp index 27a5c22b01..9d469626aa 100644 --- a/engines/titanic/pet_control/pet_real_life.cpp +++ b/engines/titanic/pet_control/pet_real_life.cpp @@ -39,7 +39,7 @@ bool CPetRealLife::reset() { _glyphs.reset(); uint col = getColor(0); _text.setColor(col); - _text.setColor(0, col); + _text.setLineColor(0, col); return true; } diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp index 60ce398eb4..ee63f41ca6 100644 --- a/engines/titanic/pet_control/pet_rooms.cpp +++ b/engines/titanic/pet_control/pet_rooms.cpp @@ -47,7 +47,7 @@ bool CPetRooms::reset() { uint col = getColor(0); _text.setColor(col); - _text.setColor(0, col); + _text.setLineColor(0, col); } return true; diff --git a/engines/titanic/pet_control/pet_sound.cpp b/engines/titanic/pet_control/pet_sound.cpp index 72e991aa3d..9fb3a07322 100644 --- a/engines/titanic/pet_control/pet_sound.cpp +++ b/engines/titanic/pet_control/pet_sound.cpp @@ -100,10 +100,10 @@ bool CPetSound::reset() { CPetSection *section = getPetSection(); uint col = section->getColor(0); - _textMusicVolume.setColor(0, col); - _textMasterVolume.setColor(0, col); - _textParrotVolume.setColor(0, col); - _textSpeechVolume.setColor(0, col); + _textMusicVolume.setLineColor(0, col); + _textMasterVolume.setLineColor(0, col); + _textParrotVolume.setLineColor(0, col); + _textSpeechVolume.setLineColor(0, col); } return false; diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp index 35f5f8d8de..324a63389c 100644 --- a/engines/titanic/pet_control/pet_text.cpp +++ b/engines/titanic/pet_control/pet_text.cpp @@ -48,7 +48,7 @@ void CPetText::freeArrays() { void CPetText::setup() { for (int idx = 0; idx < (int)_array.size(); ++idx) { _array[idx]._string1.clear(); - setArrayStr2(idx, _textR, _textG, _textB); + setLineColor(idx, _textR, _textG, _textB); _array[idx]._string3.clear(); } @@ -56,22 +56,26 @@ void CPetText::setup() { _stringsMerged = false; } -void CPetText::setArrayStr2(uint idx, int val1, int val2, int val3) { +void CPetText::setLineColor(uint lineNum, uint col) { + setLineColor(lineNum, col & 0xff, (col >> 16) & 0xff, (col >> 8) & 0xff); +} + +void CPetText::setLineColor(uint lineNum, byte r, byte g, byte b) { char buffer[6]; - if (!val1) - val1 = 1; - if (!val2) - val2 = 1; - if (!val3) - val3 = 1; - - buffer[0] = 27; - buffer[1] = val1; - buffer[2] = val2; - buffer[3] = val3; - buffer[4] = 27; + if (!r) + r = 1; + if (!g) + g = 1; + if (!b) + b = 1; + + buffer[0] = TEXTCMD_SET_COLOR; + buffer[1] = r; + buffer[2] = g; + buffer[3] = b; + buffer[4] = TEXTCMD_SET_COLOR; buffer[5] = '\0'; - _array[idx]._string2 = buffer; + _array[lineNum]._rgb = buffer; } void CPetText::load(SimpleFile *file, int param) { @@ -99,7 +103,7 @@ void CPetText::load(SimpleFile *file, int param) { assert(_array.size() >= count); for (uint idx = 0; idx < count; ++idx) { _array[idx]._string1 = file->readString(); - _array[idx]._string2 = file->readString(); + _array[idx]._rgb = file->readString(); _array[idx]._string3 = file->readString(); } } @@ -147,7 +151,7 @@ void CPetText::mergeStrings() { _lines.clear(); for (int idx = 0; idx < _lineCount; ++idx) { - CString line = _array[idx]._string2 + _array[idx]._string3 + + CString line = _array[idx]._rgb + _array[idx]._string3 + _array[idx]._string1 + "\n"; _lines += line; @@ -188,10 +192,6 @@ void CPetText::changeText(const CString &str) { _stringsMerged = false; } -void CPetText::setColor(int val1, uint col) { - warning("CPetText::setColor"); -} - void CPetText::setColor(uint col) { _textR = col & 0xff; _textG = (col >> 8) & 0xff; diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h index 24c4e949b6..2213c631d6 100644 --- a/engines/titanic/pet_control/pet_text.h +++ b/engines/titanic/pet_control/pet_text.h @@ -31,7 +31,7 @@ namespace Titanic { class CPetText { struct ArrayEntry { CString _string1; - CString _string2; + CString _rgb; CString _string3; }; private: @@ -64,8 +64,6 @@ private: void freeArrays(); - void setArrayStr2(uint idx, int val1, int val2, int val3); - /** * Merges the strings in the strings array */ @@ -120,12 +118,17 @@ public: /** * Set text color */ - void setColor(int val1, uint col); + void setColor(uint col); /** - * Set text color + * Set the color for a line */ - void setColor(uint col); + void setLineColor(uint lineNum, byte r, byte g, byte b); + + /** + * Set the color for a line + */ + void setLineColor(uint lineNum, uint col); /** * Sets the maximum number of characters per line diff --git a/engines/titanic/support/font.cpp b/engines/titanic/support/font.cpp index e903abaf97..819eaadb33 100644 --- a/engines/titanic/support/font.cpp +++ b/engines/titanic/support/font.cpp @@ -84,9 +84,9 @@ int STFont::getTextBounds(const CString &str, int maxWidth, Point *sizeOut) cons // Loop through the characters of the string if (!str.empty()) { for (const char *strP = str.c_str(); *strP; ++strP) { - if (*strP == 26) { + if (*strP == TEXTCMD_26) { strP += 3; - } else if (*strP == 27) { + } else if (*strP == TEXTCMD_SET_COLOR) { strP += 4; } else { if (*strP == ' ') { @@ -116,7 +116,7 @@ int STFont::stringWidth(const CString &text) const { if (c == 26) { // Skip over command parameter bytes srcP += 3; - } else if (c == 27) { + } else if (c == TEXTCMD_SET_COLOR) { // Skip over command parameter bytes srcP += 4; } else if (c != '\n') { @@ -211,9 +211,9 @@ void STFont::checkLineWrap(Point &textSize, int maxWidth, const char *&str) cons if (*srcPtr == ' ' && flag) break; - if (*srcPtr == 26) + if (*srcPtr == TEXTCMD_26) srcPtr += 3; - else if (*srcPtr == 27) + else if (*srcPtr == TEXTCMD_SET_COLOR) srcPtr += 4; else totalWidth += _chars[*srcPtr]._width; diff --git a/engines/titanic/support/font.h b/engines/titanic/support/font.h index 4bb1b2e6d6..087680e933 100644 --- a/engines/titanic/support/font.h +++ b/engines/titanic/support/font.h @@ -30,6 +30,8 @@ namespace Titanic { +enum TextCommand { TEXTCMD_26 = 26, TEXTCMD_SET_COLOR = 27 }; + class CVideoSurface; class STFont { |