Removed public data variables of Game concerning dialogues and added getters/setters.

svn-id: r43492
This commit is contained in:
Denis Kasak 2009-08-17 19:37:55 +00:00
parent 85bf130a50
commit be0cfa50f2
3 changed files with 88 additions and 27 deletions

View File

@ -805,10 +805,10 @@ void Game::dialogueMenu(int dialogueID) {
debugC(7, kDraciLogicDebugLevel,
"hit: %d, _lines[hit]: %d, lastblock: %d, dialogueLines: %d, dialogueExit: %d",
hit, _lines[hit], _lastBlock, _dialogueLines, _dialogueExit);
hit, _lines[hit], _lastBlock, _dialogueLinesNum, _dialogueExit);
if ((!_dialogueExit) && (hit != -1) && (_lines[hit] != -1)) {
if ((oldLines == 1) && (_dialogueLines == 1) && (_lines[hit] == _lastBlock)) {
if ((oldLines == 1) && (_dialogueLinesNum == 1) && (_lines[hit] == _lastBlock)) {
break;
}
_currentBlock = _lines[hit];
@ -819,7 +819,7 @@ void Game::dialogueMenu(int dialogueID) {
_lastBlock = _lines[hit];
_dialogueVars[_dialogueOffsets[dialogueID] + _lastBlock] += 1;
_dialogueBegin = false;
oldLines = _dialogueLines;
oldLines = _dialogueLinesNum;
} while(!_dialogueExit);
@ -828,32 +828,32 @@ void Game::dialogueMenu(int dialogueID) {
}
int Game::dialogueDraw() {
_dialogueLines = 0;
_dialogueLinesNum = 0;
int i = 0;
int ret = 0;
Animation *anim;
Text *dialogueLine;
while ((_dialogueLines < 4) && (i < _blockNum)) {
while ((_dialogueLinesNum < 4) && (i < _blockNum)) {
GPL2Program blockTest;
blockTest._bytecode = _dialogueBlocks[i]._canBlock;
blockTest._length = _dialogueBlocks[i]._canLen;
debugC(3, kDraciLogicDebugLevel, "Testing dialogue block %d", i);
if (_vm->_script->testExpression(blockTest, 1)) {
anim = _dialogueAnims[_dialogueLines];
anim = _dialogueAnims[_dialogueLinesNum];
dialogueLine = reinterpret_cast<Text *>(anim->getFrame());
dialogueLine->setText(_dialogueBlocks[i]._title);
dialogueLine->setColour(kLineInactiveColour);
_lines[_dialogueLines] = i;
_dialogueLines++;
_lines[_dialogueLinesNum] = i;
_dialogueLinesNum++;
}
++i;
}
for (i = _dialogueLines; i < kDialogueLines; ++i) {
for (i = _dialogueLinesNum; i < kDialogueLines; ++i) {
_lines[i] = -1;
anim = _dialogueAnims[i];
dialogueLine = reinterpret_cast<Text *>(anim->getFrame());
@ -862,7 +862,7 @@ int Game::dialogueDraw() {
_oldObjUnderCursor = kObjectNotFound;
if (_dialogueLines > 1) {
if (_dialogueLinesNum > 1) {
_vm->_mouse->cursorOn();
_shouldExitLoop = false;
loop();
@ -882,7 +882,7 @@ int Game::dialogueDraw() {
ret = _dialogueAnims[0]->getID() - _animUnderCursor;
}
} else {
ret = _dialogueLines - 1;
ret = _dialogueLinesNum - 1;
}
for (i = 0; i < kDialogueLines; ++i) {
@ -970,6 +970,50 @@ void Game::runDialogueProg(GPL2Program prog, int offset) {
_vm->_anims->deleteAfterIndex(lastAnimIndex);
}
bool Game::isDialogueBegin() {
return _dialogueBegin;
}
bool Game::shouldExitDialogue() {
return _dialogueExit;
}
void Game::setDialogueExit(bool exit) {
_dialogueExit = exit;
}
int Game::getDialogueBlockNum() {
return _blockNum;
}
int Game::getDialogueVar(int dialogueID) {
return _dialogueVars[dialogueID];
}
void Game::setDialogueVar(int dialogueID, int value) {
_dialogueVars[dialogueID] = value;
}
int Game::getCurrentDialogue() {
return _currentDialogue;
}
int Game::getDialogueLastBlock() {
return _lastBlock;
}
int Game::getDialogueLinesNum() {
return _dialogueLinesNum;
}
int Game::getDialogueCurrentBlock() {
return _currentBlock;
}
int Game::getCurrentDialogueOffset() {
return _dialogueOffsets[_currentDialogue];
}
void Game::walkHero(int x, int y) {
Surface *surface = _vm->_screen->getSurface();

View File

@ -324,6 +324,18 @@ public:
void dialogueDone();
void runDialogueProg(GPL2Program, int offset);
bool isDialogueBegin();
bool shouldExitDialogue();
void setDialogueExit(bool exit);
int getDialogueBlockNum();
int getDialogueVar(int dialogueID);
void setDialogueVar(int dialogueID, int value);
int getCurrentDialogue();
int getDialogueCurrentBlock();
int getDialogueLastBlock();
int getDialogueLinesNum();
int getCurrentDialogueOffset();
void schedulePalette(int paletteID);
int getScheduledPalette();
@ -344,14 +356,11 @@ private:
int _inventory[kInventorySlots];
bool _inventoryExit;
Room _currentRoom;
int _currentGate;
int _newRoom;
int _newGate;
// HACK: remove public when tested and add getters instead
public:
uint *_dialogueOffsets;
int _currentDialogue;
int *_dialogueVars;
@ -361,7 +370,7 @@ public:
bool _dialogueExit;
int _currentBlock;
int _lastBlock;
int _dialogueLines;
int _dialogueLinesNum;
int _blockNum;
int _lines[kDialogueLines];
Animation *_dialogueAnims[kDialogueLines];

View File

@ -219,29 +219,31 @@ int Script::funcRandom(int n) {
}
int Script::funcAtBegin(int yesno) {
return _vm->_game->_dialogueBegin == yesno;
return _vm->_game->isDialogueBegin() == yesno;
}
int Script::funcLastBlock(int blockID) {
blockID -= 1;
return _vm->_game->_lastBlock == blockID;
return _vm->_game->getDialogueLastBlock() == blockID;
}
int Script::funcBlockVar(int blockID) {
blockID -= 1;
return _vm->_game->_dialogueVars[_vm->_game->_dialogueOffsets[_vm->_game->_currentDialogue] + blockID];
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
return _vm->_game->getDialogueVar(currentOffset + blockID);
}
int Script::funcHasBeen(int blockID) {
blockID -= 1;
return _vm->_game->_dialogueVars[_vm->_game->_dialogueOffsets[_vm->_game->_currentDialogue] + blockID] > 0;
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
return _vm->_game->getDialogueVar(currentOffset + blockID) > 0;
}
int Script::funcMaxLine(int lines) {
return _vm->_game->_dialogueLines < lines;
return _vm->_game->getDialogueLinesNum() < lines;
}
int Script::funcNot(int n) {
@ -731,27 +733,33 @@ void Script::loadMap(Common::Queue<int> &params) {
}
void Script::resetDialogue(Common::Queue<int> &params) {
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
for (int i = 0; i < _vm->_game->_blockNum; ++i) {
_vm->_game->_dialogueVars[_vm->_game->_dialogueOffsets[_vm->_game->_currentDialogue]+i] = 0;
for (int i = 0; i < _vm->_game->getDialogueBlockNum(); ++i) {
_vm->_game->setDialogueVar(currentOffset + i, 0);
}
}
void Script::resetDialogueFrom(Common::Queue<int> &params) {
for (int i = _vm->_game->_currentBlock; i < _vm->_game->_blockNum; ++i) {
_vm->_game->_dialogueVars[_vm->_game->_dialogueOffsets[_vm->_game->_currentDialogue]+i] = 0;
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
for (int i = _vm->_game->getDialogueCurrentBlock(); i < _vm->_game->getDialogueBlockNum(); ++i) {
_vm->_game->setDialogueVar(currentOffset + i, 0);
}
}
void Script::resetBlock(Common::Queue<int> &params) {
int blockID = params.pop() - 1;
_vm->_game->_dialogueVars[_vm->_game->_dialogueOffsets[_vm->_game->_currentDialogue]+blockID] = 0;
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
_vm->_game->setDialogueVar(currentOffset + blockID, 0);
}
void Script::exitDialogue(Common::Queue<int> &params) {
_vm->_game->_dialogueExit = true;
_vm->_game->setDialogueExit(true);
}
void Script::roomMap(Common::Queue<int> &params) {