diff options
author | Paul Gilbert | 2016-04-30 19:47:49 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:37:51 -0400 |
commit | 2fb692321165ec5831877fcb60408dd45610f7bb (patch) | |
tree | 44672f24a09f83083d33de1a8b571f07bfaa5e7e /engines/titanic/pet_control | |
parent | 65dbc2a26505e79c51351eda10195e8425460a87 (diff) | |
download | scummvm-rg350-2fb692321165ec5831877fcb60408dd45610f7bb.tar.gz scummvm-rg350-2fb692321165ec5831877fcb60408dd45610f7bb.tar.bz2 scummvm-rg350-2fb692321165ec5831877fcb60408dd45610f7bb.zip |
TITANIC: Implement PET Text color remapping
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r-- | engines/titanic/pet_control/pet_conversations.cpp | 11 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_conversations.h | 5 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_text.cpp | 25 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_text.h | 10 |
4 files changed, 50 insertions, 1 deletions
diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp index 090952dbe2..76d293208b 100644 --- a/engines/titanic/pet_control/pet_conversations.cpp +++ b/engines/titanic/pet_control/pet_conversations.cpp @@ -88,7 +88,11 @@ bool CPetConversations::reset() { _textInput.setColor(col); _textInput.setLineColor(0, col); - warning("TODO: Setup log shaded palette?"); + // Replace the log colors with new 1st class ones + uint colors1[5], colors2[5]; + copyColors(2, colors1); + copyColors(1, colors2); + _log.remapColors(5, colors1, colors2); _log.setColor(getColor(2)); } @@ -479,4 +483,9 @@ CString CPetConversations::getActiveNPCName() const { return CString(); } +void CPetConversations::copyColors(uint tableNum, uint colors[5]) { + const uint *src = getColorTable(tableNum); + Common::copy(src, src + 5, colors); +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h index 1bc59419f1..57c7fbd9b2 100644 --- a/engines/titanic/pet_control/pet_conversations.h +++ b/engines/titanic/pet_control/pet_conversations.h @@ -126,6 +126,11 @@ private: * Returns the name of the currently active NPC, if any */ CString getActiveNPCName() const; + + /** + * Create a color table + */ + void copyColors(uint tableNum, uint colors[5]); public: CPetConversations(); virtual ~CPetConversations() {} diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp index a1cc75cb42..1065e6f825 100644 --- a/engines/titanic/pet_control/pet_text.cpp +++ b/engines/titanic/pet_control/pet_text.cpp @@ -234,6 +234,31 @@ void CPetText::setColor(byte r, byte g, byte b) { _textB = b; } +void CPetText::remapColors(uint count, uint *srcColors, uint *destColors) { + if (_lineCount >= 0) { + int lineNum = 0; + int index1 = 0; + + for (int lineNum = 0; lineNum <= _lineCount; ++lineNum) { + // Get the rgb values + uint r = _array[lineNum]._rgb[1]; + uint g = _array[lineNum]._rgb[2]; + uint b = _array[lineNum]._rgb[3]; + uint color = r | (g << 8) | (b << 16); + + for (uint index = 0; index < count; ++index) { + if (color == srcColors[index]) { + // Found a match, so replace the color + setLineColor(lineNum, destColors[lineNum]); + break; + } + } + } + } + + _stringsMerged = false; +} + void CPetText::setMaxCharsPerLine(int maxChars) { if (maxChars >= -1 && maxChars < 257) _maxCharsPerLine = maxChars; diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h index adbd1401ea..930bf3da8b 100644 --- a/engines/titanic/pet_control/pet_text.h +++ b/engines/titanic/pet_control/pet_text.h @@ -242,7 +242,17 @@ public: */ void hideCursor(); + /** + * Get an NPC Number embedded within on-screen text. + * Used by the PET log to encode which NPC spoke + */ int getNPCNum(uint npcId, uint startIndex); + + /** + * Replaces any occurances of line colors that appear in the + * first list with the entry at the same index in the dest list + */ + void remapColors(uint count, uint *srcColors, uint *destColors); }; } // End of namespace Titanic |