AVALANCHE: callDialogDriver, displayText, unSkrimble, doTheBubble string cleanup
Unify callDialogDriver() and displayText(). Rework it, unSkrimble() and doTheBubble() to use Common::String instead of a private buffer. This fixes the bug regarding examining the money bag.
This commit is contained in:
parent
1c3fcf22a1
commit
38b842ba71
2 changed files with 36 additions and 44 deletions
|
@ -623,8 +623,10 @@ void Dialogs::solidify(byte n) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @remarks Originally called 'calldriver'
|
* @remarks Originally called 'calldriver'
|
||||||
|
* Display text by calling the dialog driver. It unifies the function of the original
|
||||||
|
* 'calldriver' and 'display' by using Common::String instead of a private buffer.
|
||||||
*/
|
*/
|
||||||
void Dialogs::callDialogDriver() {
|
void Dialogs::displayText(Common::String text) {
|
||||||
// bool was_virtual; // Was the mouse cursor virtual on entry to this proc?
|
// bool was_virtual; // Was the mouse cursor virtual on entry to this proc?
|
||||||
warning("STUB: Scrolls::calldrivers()");
|
warning("STUB: Scrolls::calldrivers()");
|
||||||
|
|
||||||
|
@ -635,30 +637,29 @@ void Dialogs::callDialogDriver() {
|
||||||
bool mouthnext = false;
|
bool mouthnext = false;
|
||||||
bool callSpriteRun = true; // Only call sprite_run the FIRST time.
|
bool callSpriteRun = true; // Only call sprite_run the FIRST time.
|
||||||
|
|
||||||
switch (_buffer[_bufSize - 1]) {
|
switch (text.lastChar()) {
|
||||||
case kControlToBuffer:
|
case kControlToBuffer:
|
||||||
_bufSize--;
|
text.deleteLastChar();
|
||||||
break; // ^D = (D)on't include pagebreak
|
break; // ^D = (D)on't include pagebreak
|
||||||
case kControlSpeechBubble:
|
case kControlSpeechBubble:
|
||||||
case kControlQuestion:
|
case kControlQuestion:
|
||||||
break; // ^B = speech (B)ubble, ^Q = (Q)uestion in dialogue box
|
break; // ^B = speech (B)ubble, ^Q = (Q)uestion in dialogue box
|
||||||
default:
|
default:
|
||||||
_buffer[_bufSize] = kControlParagraph;
|
text.insertChar(kControlParagraph, text.size());
|
||||||
_bufSize++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint16 i = 0; i < _bufSize; i++) {
|
for (uint16 i = 0; i < text.size(); i++) {
|
||||||
if (mouthnext) {
|
if (mouthnext) {
|
||||||
if (_buffer[i] == kControlRegister)
|
if (text[i] == kControlRegister)
|
||||||
_param = 0;
|
_param = 0;
|
||||||
else if (('0' <= _buffer[i]) && (_buffer[i] <= '9'))
|
else if (('0' <= text[i]) && (text[i] <= '9'))
|
||||||
_param = _buffer[i] - 48;
|
_param = text[i] - 48;
|
||||||
else if (('A' <= _buffer[i]) && (_buffer[i] <= 'Z'))
|
else if (('A' <= text[i]) && (text[i] <= 'Z'))
|
||||||
_param = _buffer[i] - 55;
|
_param = text[i] - 55;
|
||||||
|
|
||||||
mouthnext = false;
|
mouthnext = false;
|
||||||
} else {
|
} else {
|
||||||
switch (_buffer[i]) {
|
switch (text[i]) {
|
||||||
case kControlParagraph:
|
case kControlParagraph:
|
||||||
if ((_maxLineNum == 0) && (_scroll[0].empty()))
|
if ((_maxLineNum == 0) && (_scroll[0].empty()))
|
||||||
break;
|
break;
|
||||||
|
@ -796,7 +797,7 @@ void Dialogs::callDialogDriver() {
|
||||||
solidify(_maxLineNum);
|
solidify(_maxLineNum);
|
||||||
_maxLineNum++;
|
_maxLineNum++;
|
||||||
}
|
}
|
||||||
_scroll[_maxLineNum] += _buffer[i];
|
_scroll[_maxLineNum] += text[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -812,16 +813,6 @@ int16 Dialogs::getTalkPosX() {
|
||||||
return _talkX;
|
return _talkX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display text by calling the dialog driver
|
|
||||||
* @remarks Originally called 'display'
|
|
||||||
*/
|
|
||||||
void Dialogs::displayText(Common::String text) { // TODO: REPLACE BUFFER WITH A STRING!!!!!!!!!!
|
|
||||||
_bufSize = text.size();
|
|
||||||
memcpy(_buffer, text.c_str(), _bufSize);
|
|
||||||
callDialogDriver();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Dialogs::displayQuestion(Common::String question) {
|
bool Dialogs::displayQuestion(Common::String question) {
|
||||||
displayText(question + kControlNewLine + kControlQuestion);
|
displayText(question + kControlNewLine + kControlQuestion);
|
||||||
|
|
||||||
|
@ -879,15 +870,14 @@ void Dialogs::displayMusicalScroll() {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialogs::unSkrimble() {
|
void Dialogs::unSkrimble(Common::String &text) {
|
||||||
for (uint16 i = 0; i < _bufSize; i++)
|
for (uint16 i = 0; i < text.size(); i++)
|
||||||
_buffer[i] = (~(_buffer[i] - (i + 1))) % 256;
|
text.setChar((~(text[i] - (i + 1))) % 256, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialogs::doTheBubble() {
|
void Dialogs::doTheBubble(Common::String &text) {
|
||||||
_buffer[_bufSize] = 2;
|
text.insertChar(kControlSpeechBubble, text.size());
|
||||||
_bufSize++;
|
assert(text.size() < 2000);
|
||||||
assert(_bufSize < 2000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -928,16 +918,18 @@ void Dialogs::displayScrollChain(char block, byte point, bool report, bool bubbl
|
||||||
::error("AVALANCHE: Visa: File not found: avalot.sez");
|
::error("AVALANCHE: Visa: File not found: avalot.sez");
|
||||||
|
|
||||||
sezfile.seek(sez_offset);
|
sezfile.seek(sez_offset);
|
||||||
_bufSize = sezfile.readUint16LE();
|
uint16 _bufSize = sezfile.readUint16LE();
|
||||||
assert(_bufSize < 2000);
|
assert(_bufSize < 2000);
|
||||||
|
char *_buffer = new char[_bufSize];
|
||||||
sezfile.read(_buffer, _bufSize);
|
sezfile.read(_buffer, _bufSize);
|
||||||
sezfile.close();
|
sezfile.close();
|
||||||
unSkrimble();
|
Common::String text(_buffer, _bufSize);
|
||||||
|
delete[] _buffer;
|
||||||
|
|
||||||
|
unSkrimble(text);
|
||||||
if (bubbling)
|
if (bubbling)
|
||||||
doTheBubble();
|
doTheBubble(text);
|
||||||
|
displayText(text);
|
||||||
callDialogDriver();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -975,15 +967,18 @@ void Dialogs::speak(byte who, byte subject) {
|
||||||
error("AVALANCHE: Visa: File not found: avalot.sez");
|
error("AVALANCHE: Visa: File not found: avalot.sez");
|
||||||
|
|
||||||
sezfile.seek(sezOffset);
|
sezfile.seek(sezOffset);
|
||||||
_bufSize = sezfile.readUint16LE();
|
uint16 _bufSize = sezfile.readUint16LE();
|
||||||
assert(_bufSize < 2000);
|
assert(_bufSize < 2000);
|
||||||
|
char *_buffer = new char[_bufSize];
|
||||||
sezfile.read(_buffer, _bufSize);
|
sezfile.read(_buffer, _bufSize);
|
||||||
sezfile.close();
|
sezfile.close();
|
||||||
|
Common::String text(_buffer, _bufSize);
|
||||||
|
delete[] _buffer;
|
||||||
|
|
||||||
unSkrimble();
|
unSkrimble(text);
|
||||||
doTheBubble();
|
doTheBubble(text);
|
||||||
|
displayText(text);
|
||||||
|
|
||||||
callDialogDriver();
|
|
||||||
_noError = true;
|
_noError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,12 +82,9 @@ private:
|
||||||
byte _param; // For using arguments code
|
byte _param; // For using arguments code
|
||||||
byte _useIcon;
|
byte _useIcon;
|
||||||
byte _scrollBells; // no. of times to ring the bell
|
byte _scrollBells; // no. of times to ring the bell
|
||||||
byte _buffer[2000];
|
|
||||||
uint16 _bufSize;
|
|
||||||
int16 _underScroll; // Y-coord of just under the scroll text.
|
int16 _underScroll; // Y-coord of just under the scroll text.
|
||||||
int16 _shadowBoxX, _shadowBoxY;
|
int16 _shadowBoxX, _shadowBoxY;
|
||||||
|
|
||||||
void callDialogDriver();
|
|
||||||
void drawBubble(DialogFunctionType modeFunc);
|
void drawBubble(DialogFunctionType modeFunc);
|
||||||
void drawScroll(DialogFunctionType modeFunc);
|
void drawScroll(DialogFunctionType modeFunc);
|
||||||
void scrollModeNormal();
|
void scrollModeNormal();
|
||||||
|
@ -109,8 +106,8 @@ private:
|
||||||
void ringBell();
|
void ringBell();
|
||||||
void loadFont();
|
void loadFont();
|
||||||
|
|
||||||
void unSkrimble();
|
void unSkrimble(Common::String &text);
|
||||||
void doTheBubble();
|
void doTheBubble(Common::String &text);
|
||||||
void speak(byte who, byte subject);
|
void speak(byte who, byte subject);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue