HOPKINS: More refactoring in TalkManager

This commit is contained in:
Strangerke 2013-01-16 23:38:03 +01:00
parent ae93d1f6ee
commit 4d16fb1bbd

View file

@ -245,17 +245,20 @@ int TalkManager::DIALOGUE() {
dialogWait(); dialogWait();
} }
int v19 = VERIF_BOITE(PLIGNE1, _questionsFilename, 65); int sentence1LineNumb = VERIF_BOITE(PLIGNE1, _questionsFilename, 65);
int v2 = VERIF_BOITE(PLIGNE2, _questionsFilename, 65); int sentence2LineNumb = VERIF_BOITE(PLIGNE2, _questionsFilename, 65);
int v3 = VERIF_BOITE(PLIGNE3, _questionsFilename, 65); int sentence3LineNumb = VERIF_BOITE(PLIGNE3, _questionsFilename, 65);
int v20 = 420 - 20 * VERIF_BOITE(PLIGNE4, _questionsFilename, 65); int sentence4LineNumb = VERIF_BOITE(PLIGNE4, _questionsFilename, 65);
int v21 = v20 - 20 * v3;
int v18 = v21 - 1; int sentence4PosY = 420 - 20 * sentence4LineNumb;
int v4 = v21 - 20 * v2; int sentence3PosY = sentence4PosY - 20 * sentence3LineNumb;
_vm->_fontManager.initTextBuffers(5, PLIGNE1, _questionsFilename, 5, v4 - 20 * v19, 0, 65, 255); int sentence2PosY = sentence3PosY - 20 * sentence2LineNumb;
_vm->_fontManager.initTextBuffers(6, PLIGNE2, _questionsFilename, 5, v4, 0, 65, 255); int sentence1PosY = sentence2PosY - 20 * sentence1LineNumb;
_vm->_fontManager.initTextBuffers(7, PLIGNE3, _questionsFilename, 5, v21, 0, 65, 255);
_vm->_fontManager.initTextBuffers(8, PLIGNE4, _questionsFilename, 5, v20, 0, 65, 255); _vm->_fontManager.initTextBuffers(5, PLIGNE1, _questionsFilename, 5, sentence1PosY, 0, 65, 255);
_vm->_fontManager.initTextBuffers(6, PLIGNE2, _questionsFilename, 5, sentence2PosY, 0, 65, 255);
_vm->_fontManager.initTextBuffers(7, PLIGNE3, _questionsFilename, 5, sentence3PosY, 0, 65, 255);
_vm->_fontManager.initTextBuffers(8, PLIGNE4, _questionsFilename, 5, sentence4PosY, 0, 65, 255);
_vm->_fontManager.showText(5); _vm->_fontManager.showText(5);
_vm->_fontManager.showText(6); _vm->_fontManager.showText(6);
_vm->_fontManager.showText(7); _vm->_fontManager.showText(7);
@ -265,19 +268,19 @@ int TalkManager::DIALOGUE() {
bool v6 = false; bool v6 = false;
do { do {
int mousePosY = _vm->_eventsManager.getMouseY(); int mousePosY = _vm->_eventsManager.getMouseY();
if ((v4 - 20 * v19) < mousePosY && (v4 - 1) > mousePosY) { if (sentence1PosY < mousePosY && mousePosY < (sentence2PosY - 1)) {
_vm->_fontManager.setOptimalColor(6, 7, 8, 5); _vm->_fontManager.setOptimalColor(6, 7, 8, 5);
retVal = PLIGNE1; retVal = PLIGNE1;
} }
if (mousePosY > v4 && v18 > mousePosY) { if (sentence2PosY < mousePosY && mousePosY < (sentence3PosY - 1)) {
_vm->_fontManager.setOptimalColor(5, 7, 8, 6); _vm->_fontManager.setOptimalColor(5, 7, 8, 6);
retVal = PLIGNE2; retVal = PLIGNE2;
} }
if (v21 < mousePosY && (v20 - 1) > mousePosY) { if (sentence3PosY < mousePosY && mousePosY < (sentence4PosY - 1)) {
_vm->_fontManager.setOptimalColor(5, 6, 8, 7); _vm->_fontManager.setOptimalColor(5, 6, 8, 7);
retVal = PLIGNE3; retVal = PLIGNE3;
} }
if (v20 < mousePosY && mousePosY < 419) { if (sentence4PosY < mousePosY && mousePosY < 419) {
_vm->_fontManager.setOptimalColor(5, 6, 7, 8); _vm->_fontManager.setOptimalColor(5, 6, 7, 8);
retVal = PLIGNE4; retVal = PLIGNE4;
} }
@ -510,16 +513,13 @@ void TalkManager::dialogEndTalk() {
} }
int TalkManager::VERIF_BOITE(int idx, const Common::String &file, int a3) { int TalkManager::VERIF_BOITE(int idx, const Common::String &file, int a3) {
char v8;
int v9; int v9;
int v10; int v10;
char v11; char v11;
char v13; char v13;
char v14;
int v15; int v15;
byte *ptr; byte *ptr;
int v17; int v17;
int v18;
byte *v19; byte *v19;
uint32 indexData[4047]; uint32 indexData[4047];
Common::String filename; Common::String filename;
@ -527,7 +527,6 @@ int TalkManager::VERIF_BOITE(int idx, const Common::String &file, int a3) {
Common::File f; Common::File f;
int filesize; int filesize;
v18 = 0;
_vm->_globals.police_l = 11; _vm->_globals.police_l = 11;
// Build up the filename // Build up the filename
@ -569,47 +568,42 @@ int TalkManager::VERIF_BOITE(int idx, const Common::String &file, int a3) {
v13 = *v19 + 111; v13 = *v19 + 111;
} }
*v19 = v13; *v19 = v13;
v19 = v19 + 1; v19++;
} }
for (int i = 0; i < 2048; i++) { for (int i = 0; i < 2048; i++) {
v8 = ptr[i]; if ( ptr[i] == 10 || ptr[i] == 13 )
if ( v8 == 10 || v8 == 13 )
ptr[i] = 0; ptr[i] = 0;
} }
v9 = 0; v9 = 0;
v15 = (11 * a3) - 4; v15 = (11 * a3) - 4;
int lineCount = 0;
do { do {
v10 = 0; v10 = 0;
for (;;) { for (;;) {
v17 = v10; v17 = v10;
do { do {
v11 = ptr[v9 + v10]; v11 = ptr[v9 + v10];
v14 = v11;
++v10; ++v10;
} while (v11 != ' ' && v11 != '%'); } while (v11 != ' ' && v11 != '%');
if (v10 >= v15 / _vm->_globals.police_l) if (v10 >= v15 / _vm->_globals.police_l) {
if (v11 == '%')
v11 = ' ';
break; break;
}
if (v11 == '%') { if (v11 == '%') {
if (v10 < v15 / _vm->_globals.police_l) v17 = v10;
goto LABEL_31;
break; break;
} }
} }
if (v11 != '%') ++lineCount;
goto LABEL_33;
v14 = ' ';
LABEL_31:
if (v14 == '%')
v17 = v10;
LABEL_33:
++v18;
v9 += v17; v9 += v17;
} while (v14 != 37); } while (v11 != '%');
free(ptr); free(ptr);
return v18; return lineCount;
} }
void TalkManager::VISU_PARLE() { void TalkManager::VISU_PARLE() {
@ -676,51 +670,47 @@ void TalkManager::startCharacterAnim0(int startIdx, bool readOnlyFl) {
* Initialize character animation * Initialize character animation
*/ */
void TalkManager::initCharacterAnim() { void TalkManager::initCharacterAnim() {
byte *v0; uint16 *bufPtr = (uint16 *)_characterBuffer + 43;
byte *v1; byte *animPtr = _characterBuffer + 110;
int v2; int curVal = (int16)READ_LE_UINT16(bufPtr);
int v4; if (curVal)
int v5; searchCharacterAnim(21, animPtr, curVal, _characterSize);
int v6;
int v7;
int v8;
int v9;
int v10;
int v11;
int v12;
v0 = _characterBuffer; curVal = (int16)READ_LE_UINT16(bufPtr + 1);
v1 = _characterBuffer + 110; if (curVal)
v2 = (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 43); searchCharacterAnim(22, animPtr, curVal, _characterSize);
if (v2)
searchCharacterAnim(21, (_characterBuffer + 110), v2, _characterSize); curVal = (int16)READ_LE_UINT16(bufPtr + 2);
v4 = (int16)READ_LE_UINT16((uint16 *)v0 + 44); if (curVal)
if (v4) searchCharacterAnim(23, animPtr, curVal, _characterSize);
searchCharacterAnim(22, v1, v4, _characterSize);
v5 = (int16)READ_LE_UINT16((uint16 *)v0 + 45); curVal = (int16)READ_LE_UINT16(bufPtr + 3);
if (v5) if (curVal)
searchCharacterAnim(23, v1, v5, _characterSize); searchCharacterAnim(24, animPtr, curVal, _characterSize);
v6 = (int16)READ_LE_UINT16((uint16 *)v0 + 46);
if (v6) curVal = (int16)READ_LE_UINT16(bufPtr + 4);
searchCharacterAnim(24, v1, v6, _characterSize); if (curVal)
v7 = (int16)READ_LE_UINT16((uint16 *)v0 + 47); searchCharacterAnim(25, animPtr, curVal, _characterSize);
if (v7)
searchCharacterAnim(25, v1, v7, _characterSize); curVal = (int16)READ_LE_UINT16(bufPtr + 5);
v8 = (int16)READ_LE_UINT16((uint16 *)v0 + 48); if (curVal)
if (v8) searchCharacterAnim(26, animPtr, curVal, _characterSize);
searchCharacterAnim(26, v1, v8, _characterSize);
v9 = (int16)READ_LE_UINT16((uint16 *)v0 + 49); curVal = (int16)READ_LE_UINT16(bufPtr + 6);
if (v9) if (curVal)
searchCharacterAnim(27, v1, v9, _characterSize); searchCharacterAnim(27, animPtr, curVal, _characterSize);
v10 = (int16)READ_LE_UINT16((uint16 *)v0 + 50);
if (v10) curVal = (int16)READ_LE_UINT16(bufPtr + 7);
searchCharacterAnim(28, v1, v10, _characterSize); if (curVal)
v11 = (int16)READ_LE_UINT16((uint16 *)v0 + 51); searchCharacterAnim(28, animPtr, curVal, _characterSize);
if (v11)
searchCharacterAnim(29, v1, v11, _characterSize); curVal = (int16)READ_LE_UINT16(bufPtr + 8);
v12 = (int16)READ_LE_UINT16((uint16 *)v0 + 52); if (curVal)
if (v12) searchCharacterAnim(29, animPtr, curVal, _characterSize);
searchCharacterAnim(30, v1, v12, _characterSize);
curVal = (int16)READ_LE_UINT16(bufPtr + 9);
if (curVal)
searchCharacterAnim(30, animPtr, curVal, _characterSize);
} }
void TalkManager::clearCharacterAnim() { void TalkManager::clearCharacterAnim() {