PRINCE: O_INITDIALOG() update

This commit is contained in:
lukaslw 2014-07-03 04:19:52 +02:00
parent 92f3d72f19
commit e853e44695
4 changed files with 44 additions and 43 deletions

View file

@ -780,11 +780,10 @@ void PrinceEngine::keyHandler(Common::Event event) {
debugEngine("RIGHT"); debugEngine("RIGHT");
break; break;
case Common::KEYCODE_1: case Common::KEYCODE_1:
//if(_mainHero->_state > 0) { if(_mainHero->_state > 0) {
// _mainHero->_state--; _mainHero->_state--;
//} }
//debugEngine("%d", _mainHero->_state); debugEngine("%d", _mainHero->_state);
testDialog();
break; break;
case Common::KEYCODE_2: case Common::KEYCODE_2:
_mainHero->_state++; _mainHero->_state++;
@ -2356,7 +2355,7 @@ void PrinceEngine::talkHero(int slot, const char *s) {
void PrinceEngine::doTalkAnim(int animNumber, int slot, AnimType animType) { void PrinceEngine::doTalkAnim(int animNumber, int slot, AnimType animType) {
Text &text = _textSlots[slot]; Text &text = _textSlots[slot];
int lines = calcText((const char *)_interpreter->getGlobalString()); int lines = calcText((const char *)_interpreter->getString());
int time = lines * 30; int time = lines * 30;
if (animType == kNormalAnimation) { if (animType == kNormalAnimation) {
Anim &normAnim = _normAnimList[animNumber]; Anim &normAnim = _normAnimList[animNumber];
@ -2387,41 +2386,10 @@ void PrinceEngine::doTalkAnim(int animNumber, int slot, AnimType animType) {
error("doTalkAnim() - wrong animType: %d", animType); error("doTalkAnim() - wrong animType: %d", animType);
} }
text._time = time; text._time = time;
text._str = (const char *)_interpreter->getGlobalString(); text._str = (const char *)_interpreter->getString();
_interpreter->increaseString(); _interpreter->increaseString();
} }
// Test
void PrinceEngine::testDialog() {
Common::Array<DialogLine> tempDialogBox;
DialogLine tempDialogLine;
int dialogBoxSize = 6;
// dialBox 0 create:
for (int i = 0; i < dialogBoxSize; i++) {
tempDialogLine._nr = i;
tempDialogLine._line = "";
tempDialogBox.push_back(tempDialogLine);
}
tempDialogBox[0]._line = "Co to za miejsce?";
tempDialogBox[1]._line = "Prosze, musi mi pan pomoc wydostac sie stad!";
tempDialogBox[2]._line = "Sam Adanor Wszobrody odmowil mi trzydziestego\n""siodmego kubeczka krasnoludzkiego spirytusu.";
tempDialogBox[3]._line = "A co do twoich czarodziejskich sztuczek, to\n""jak mowi stare przyslowie, nie chwal sie\n""dokonaniami dnia wczorajszego...";
tempDialogBox[4]._line = "Tu chyba nie jest zbyt bezpiecznie, prawda?";
tempDialogBox[5]._line = "Nie chce przeszkadzac.";
_dialogBoxList.push_back(tempDialogBox);
//dialogBox 0 draw:
createDialogBox(_dialogBoxList[0]);
if (_dialogBoxList[0].size() != 0) {
changeCursor(1);
runDialog(_dialogBoxList[0]);
changeCursor(0);
}
}
void PrinceEngine::freeNormAnim(int slot) { void PrinceEngine::freeNormAnim(int slot) {
_normAnimList[slot]._state = 1; _normAnimList[slot]._state = 1;
delete _normAnimList[slot]._animData; delete _normAnimList[slot]._animData;

View file

@ -410,7 +410,6 @@ public:
void runDialog(Common::Array<DialogLine> &dialogData); void runDialog(Common::Array<DialogLine> &dialogData);
void talkHero(int slot, const char *s); void talkHero(int slot, const char *s);
void doTalkAnim(int animNumber, int slot, AnimType animType); void doTalkAnim(int animNumber, int slot, AnimType animType);
void testDialog();
int testAnimNr; int testAnimNr;
int testAnimFrame; int testAnimFrame;

View file

@ -522,7 +522,7 @@ void Interpreter::setCurrentString(uint32 value) {
_currentString = value; _currentString = value;
} }
byte *Interpreter::getGlobalString() { byte *Interpreter::getString() {
return _string; return _string;
} }
@ -1370,7 +1370,6 @@ void Interpreter::O_INITDIALOG() {
stringESI += 2; stringESI += 2;
_string = stringEBP + adressOfFirstSequence; _string = stringEBP + adressOfFirstSequence;
// like this?
for (uint i = 0; i < _vm->_dialogBoxList.size(); i++) { for (uint i = 0; i < _vm->_dialogBoxList.size(); i++) {
_vm->_dialogBoxList[i].clear(); _vm->_dialogBoxList[i].clear();
} }
@ -1420,6 +1419,41 @@ void Interpreter::O_INITDIALOG() {
dialogOptAddr[edi] = eax; dialogOptAddr[edi] = eax;
edi++; edi++;
} }
int i = 0;
Common::Array<DialogLine> tempDialogBox;
while (dialogBoxAddr[i] != 0) {
tempDialogBox.clear();
byte *boxAddr = dialogBoxAddr[i];
byte *stream = boxAddr;
int streamSize = 0;
while (*stream != 0xFF) {
stream++;
streamSize++;
}
streamSize++;
//int dialogDataValueEDI = (int)READ_UINT32(dialogData);
byte c;
int sentenceNumber;
DialogLine tempDialogLine;
Common::MemoryReadStream dialogStream(boxAddr, streamSize);
while ((sentenceNumber = dialogStream.readSByte()) != -1) {
tempDialogLine._line.clear();
//bt edi, eax
//jc skip_zdanko
// skip_sentence - TODO
tempDialogLine._nr = sentenceNumber;
while ((c = dialogStream.readByte())) {
tempDialogLine._line += c;
}
tempDialogBox.push_back(tempDialogLine);
}
_vm->_dialogBoxList.push_back(tempDialogBox);
i++;
}
//opt_done //opt_done
int freeASlot = 0; int freeASlot = 0;
int freeBSlot = 0; int freeBSlot = 0;
@ -1430,7 +1464,7 @@ void Interpreter::O_INITDIALOG() {
//check //check
for (int i = 31; i >= 0; i--) { for (int i = 31; i >= 0; i--) {
if (dialogOptAddr[i] != 0) { if (dialogOptAddr[i] != 0) {
// or i++ before break here? i++;
debug("%s", (char *)dialogOptAddr[i]); debug("%s", (char *)dialogOptAddr[i]);
freeHSlot = i; freeHSlot = i;
_flags->setFlagValue(Flags::VOICE_H_LINE, i); _flags->setFlagValue(Flags::VOICE_H_LINE, i);

View file

@ -185,7 +185,7 @@ public:
uint32 getCurrentString(); uint32 getCurrentString();
void setCurrentString(uint32 value); void setCurrentString(uint32 value);
byte *getGlobalString(); byte *getString();
void increaseString(); void increaseString();