aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/kyra/gui.cpp48
-rw-r--r--engines/kyra/gui.h4
-rw-r--r--engines/kyra/gui_lok.cpp95
-rw-r--r--engines/kyra/gui_lok.h6
-rw-r--r--engines/kyra/gui_v2.cpp61
-rw-r--r--engines/kyra/gui_v2.h4
-rw-r--r--engines/kyra/kyra_hof.h2
-rw-r--r--engines/kyra/kyra_lok.cpp171
-rw-r--r--engines/kyra/kyra_lok.h16
-rw-r--r--engines/kyra/kyra_mr.h2
-rw-r--r--engines/kyra/kyra_v1.cpp142
-rw-r--r--engines/kyra/kyra_v1.h28
-rw-r--r--engines/kyra/kyra_v2.cpp135
-rw-r--r--engines/kyra/kyra_v2.h22
-rw-r--r--engines/kyra/saveload_lok.cpp3
-rw-r--r--engines/kyra/scene_lok.cpp20
-rw-r--r--engines/kyra/script_lok.cpp59
-rw-r--r--engines/kyra/sequences_lok.cpp9
-rw-r--r--engines/kyra/sound_lok.cpp2
-rw-r--r--engines/kyra/text_lok.cpp28
20 files changed, 365 insertions, 492 deletions
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
index 06d7f1783a..b316d727bd 100644
--- a/engines/kyra/gui.cpp
+++ b/engines/kyra/gui.cpp
@@ -335,6 +335,54 @@ int GUI::getNextSavegameSlot() {
return 0;
}
+void GUI::checkTextfieldInput() {
+ Common::Event event;
+
+ uint32 now = _vm->_system->getMillis();
+
+ bool running = true;
+ int keys = 0;
+ while (_vm->_eventMan->pollEvent(event) && running) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == 'q' && event.kbd.flags == Common::KBD_CTRL)
+ _vm->quitGame();
+ else
+ _keyPressed = event.kbd;
+ running = false;
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP: {
+ Common::Point pos = _vm->getMousePos();
+ _vm->_mouseX = pos.x;
+ _vm->_mouseY = pos.y;
+ keys = event.type == Common::EVENT_LBUTTONDOWN ? 199 : (200 | 0x800);
+ running = false;
+ } break;
+
+ case Common::EVENT_MOUSEMOVE: {
+ Common::Point pos = _vm->getMousePos();
+ _vm->_mouseX = pos.x;
+ _vm->_mouseY = pos.y;
+ _screen->updateScreen();
+ _lastScreenUpdate = now;
+ } break;
+
+ default:
+ break;
+ }
+ }
+
+ if (now - _lastScreenUpdate > 50) {
+ _vm->_system->updateScreen();
+ _lastScreenUpdate = now;
+ }
+
+ processButtonList(_menuButtonList, keys | 0x8000, 0);
+ _vm->_system->delayMillis(3);
+}
+
#pragma mark -
MainMenu::MainMenu(KyraEngine_v1 *vm) : _vm(vm), _screen(0) {
diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h
index 7db8f52f16..8115d91e7a 100644
--- a/engines/kyra/gui.h
+++ b/engines/kyra/gui.h
@@ -194,6 +194,10 @@ protected:
Common::Array<int> _saveSlots;
void updateSaveList();
int getNextSavegameSlot();
+
+ uint32 _lastScreenUpdate;
+ Common::KeyState _keyPressed;
+ void checkTextfieldInput();
};
class Movie;
diff --git a/engines/kyra/gui_lok.cpp b/engines/kyra/gui_lok.cpp
index a778f98ed6..5ba805044f 100644
--- a/engines/kyra/gui_lok.cpp
+++ b/engines/kyra/gui_lok.cpp
@@ -191,6 +191,7 @@ int KyraEngine_LoK::buttonAmuletCallback(Button *caller) {
GUI_LoK::GUI_LoK(KyraEngine_LoK *vm, Screen_LoK *screen) : GUI(vm), _vm(vm), _screen(screen) {
_lastScreenUpdate = 0;
_menu = 0;
+ _pressFlag = false;
initStaticResource();
_scrollUpFunctor = BUTTON_FUNCTOR(GUI_LoK, this, &GUI_LoK::scrollUp);
_scrollDownFunctor = BUTTON_FUNCTOR(GUI_LoK, this, &GUI_LoK::scrollDown);
@@ -213,6 +214,12 @@ void GUI_LoK::createScreenThumbnail(Graphics::Surface &dst) {
}
int GUI_LoK::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel) {
+ if ((inputFlag & 0xFF) == 199)
+ _pressFlag = true;
+ else if ((inputFlag & 0xFF) == 200)
+ _pressFlag = false;
+
+ int returnValue = 0;
while (list) {
if (list->flags & 8) {
list = list->nextButton;
@@ -220,51 +227,47 @@ int GUI_LoK::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel)
}
if (mouseWheel && list->mouseWheel == mouseWheel && list->buttonCallback) {
- if ((*list->buttonCallback.get())(list)) {
+ if ((*list->buttonCallback.get())(list))
break;
- }
}
int x = list->x;
int y = list->y;
assert(_screen->getScreenDim(list->dimTableIndex) != 0);
- if (x < 0) {
+
+ if (x < 0)
x += _screen->getScreenDim(list->dimTableIndex)->w << 3;
- }
x += _screen->getScreenDim(list->dimTableIndex)->sx << 3;
- if (y < 0) {
+ if (y < 0)
y += _screen->getScreenDim(list->dimTableIndex)->h;
- }
y += _screen->getScreenDim(list->dimTableIndex)->sy;
- Common::Point mouse = _vm->getMousePos();
- if (mouse.x >= x && mouse.y >= y && x + list->width >= mouse.x && y + list->height >= mouse.y) {
+ if (_vm->_mouseX >= x && _vm->_mouseY >= y && x + list->width >= _vm->_mouseX && y + list->height >= _vm->_mouseY) {
int processMouseClick = 0;
if (list->flags & 0x400) {
- if (_vm->_mousePressFlag) {
+ if ((inputFlag & 0xFF) == 199 || _pressFlag) {
if (!(list->flags2 & 1)) {
list->flags2 |= 1;
list->flags2 |= 4;
processButton(list);
_screen->updateScreen();
+ inputFlag = 0;
}
- } else {
+ } else if ((inputFlag & 0xFF) == 200) {
if (list->flags2 & 1) {
list->flags2 &= 0xFFFE;
processButton(list);
processMouseClick = 1;
+ inputFlag = 0;
}
}
- } else if (_vm->_mousePressFlag) {
- processMouseClick = 1;
}
if (processMouseClick) {
if (list->buttonCallback) {
- if ((*list->buttonCallback.get())(list)) {
+ if ((*list->buttonCallback.get())(list))
break;
- }
}
}
} else {
@@ -272,18 +275,21 @@ int GUI_LoK::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel)
list->flags2 &= 0xFFFE;
processButton(list);
}
+
if (list->flags2 & 4) {
list->flags2 &= 0xFFFB;
processButton(list);
_screen->updateScreen();
}
- list = list->nextButton;
- continue;
}
list = list->nextButton;
}
- return 0;
+
+ if (!returnValue)
+ returnValue = inputFlag & 0xFF;
+
+ return returnValue;
}
void GUI_LoK::processButton(Button *button) {
@@ -460,7 +466,6 @@ int GUI_LoK::buttonMenuCallback(Button *caller) {
_menuRestoreScreen = true;
_keyPressed.reset();
- _vm->_mousePressFlag = false;
_toplevelMenu = 0;
if (_vm->_menuDirectlyToLoad) {
@@ -474,9 +479,7 @@ int GUI_LoK::buttonMenuCallback(Button *caller) {
}
while (_displayMenu && !_vm->shouldQuit()) {
- Common::Point mouse = _vm->getMousePos();
- processHighlights(_menu[_toplevelMenu], mouse.x, mouse.y);
- processButtonList(_menuButtonList, 0, 0);
+ processHighlights(_menu[_toplevelMenu], _vm->_mouseX, _vm->_mouseY);
getInput();
}
@@ -495,32 +498,8 @@ void GUI_LoK::getInput() {
Common::Event event;
uint32 now = _vm->_system->getMillis();
- _mouseWheel = 0;
- while (_vm->_eventMan->pollEvent(event)) {
- switch (event.type) {
- case Common::EVENT_LBUTTONDOWN:
- _vm->_mousePressFlag = true;
- break;
- case Common::EVENT_LBUTTONUP:
- _vm->_mousePressFlag = false;
- break;
- case Common::EVENT_MOUSEMOVE:
- _vm->_system->updateScreen();
- _lastScreenUpdate = now;
- break;
- case Common::EVENT_WHEELUP:
- _mouseWheel = -1;
- break;
- case Common::EVENT_WHEELDOWN:
- _mouseWheel = 1;
- break;
- case Common::EVENT_KEYDOWN:
- _keyPressed = event.kbd;
- break;
- default:
- break;
- }
- }
+ _vm->checkInput(_menuButtonList);
+ _vm->removeInputTop();
if (now - _lastScreenUpdate > 50) {
_vm->_system->updateScreen();
@@ -594,10 +573,8 @@ int GUI_LoK::saveGameMenu(Button *button) {
_cancelSubMenu = false;
while (_displaySubMenu && !_vm->shouldQuit()) {
+ processHighlights(_menu[2], _vm->_mouseX, _vm->_mouseY);
getInput();
- Common::Point mouse = _vm->getMousePos();
- processHighlights(_menu[2], mouse.x, mouse.y);
- processButtonList(_menuButtonList, 0, _mouseWheel);
}
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@@ -643,10 +620,8 @@ int GUI_LoK::loadGameMenu(Button *button) {
_vm->_gameToLoad = -1;
while (_displaySubMenu && !_vm->shouldQuit()) {
+ processHighlights(_menu[2], _vm->_mouseX, _vm->_mouseY);
getInput();
- Common::Point mouse = _vm->getMousePos();
- processHighlights(_menu[2], mouse.x, mouse.y);
- processButtonList(_menuButtonList, 0, _mouseWheel);
}
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@@ -731,11 +706,9 @@ int GUI_LoK::saveGame(Button *button) {
redrawTextfield();
while (_displaySubMenu && !_vm->shouldQuit()) {
- getInput();
+ checkTextfieldInput();
updateSavegameString();
- Common::Point mouse = _vm->getMousePos();
- processHighlights(_menu[3], mouse.x, mouse.y);
- processButtonList(_menuButtonList, 0, 0);
+ processHighlights(_menu[3], _vm->_mouseX, _vm->_mouseY);
}
if (_cancelSubMenu) {
@@ -811,10 +784,8 @@ bool GUI_LoK::quitConfirm(const char *str) {
_cancelSubMenu = true;
while (_displaySubMenu && !_vm->shouldQuit()) {
+ processHighlights(_menu[1], _vm->_mouseX, _vm->_mouseY);
getInput();
- Common::Point mouse = _vm->getMousePos();
- processHighlights(_menu[1], mouse.x, mouse.y);
- processButtonList(_menuButtonList, 0, 0);
}
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@@ -877,10 +848,8 @@ int GUI_LoK::gameControlsMenu(Button *button) {
_cancelSubMenu = false;
while (_displaySubMenu && !_vm->shouldQuit()) {
+ processHighlights(_menu[5], _vm->_mouseX, _vm->_mouseY);
getInput();
- Common::Point mouse = _vm->getMousePos();
- processHighlights(_menu[5], mouse.x, mouse.y);
- processButtonList(_menuButtonList, 0, 0);
}
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
diff --git a/engines/kyra/gui_lok.h b/engines/kyra/gui_lok.h
index 0ce718d7a7..9eb433bf44 100644
--- a/engines/kyra/gui_lok.h
+++ b/engines/kyra/gui_lok.h
@@ -117,6 +117,8 @@ private:
Menu *_menu;
+ bool _pressFlag;
+
void setGUILabels();
void setupSavegames(Menu &menu, int num);
@@ -159,15 +161,11 @@ private:
KyraEngine_LoK *_vm;
Screen_LoK *_screen;
- uint32 _lastScreenUpdate;
-
bool _menuRestoreScreen;
uint8 _toplevelMenu;
int _savegameOffset;
char _savegameName[35];
const char *_specialSavegameString;
- Common::KeyState _keyPressed;
- int8 _mouseWheel;
Button::Callback _scrollUpFunctor;
Button::Callback _scrollDownFunctor;
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp
index 4859b813e7..500d816cb9 100644
--- a/engines/kyra/gui_v2.cpp
+++ b/engines/kyra/gui_v2.cpp
@@ -36,6 +36,7 @@ GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) {
_backUpButtonList = _unknownButtonList = 0;
_buttonListChanged = false;
_lastScreenUpdate = 0;
+ _flagsModifier = 0;
_currentMenu = 0;
_isDeathMenu = false;
@@ -142,8 +143,6 @@ void GUI_v2::processButton(Button *button) {
}
int GUI_v2::processButtonList(Button *buttonList, uint16 inputFlag, int8 mouseWheel) {
- static uint16 flagsModifier = 0;
-
if (!buttonList)
return inputFlag & 0x7FFF;
@@ -179,10 +178,10 @@ int GUI_v2::processButtonList(Button *buttonList, uint16 inputFlag, int8 mouseWh
flags |= temp;
- flagsModifier &= ~((temp & 0x4400) >> 1);
- flagsModifier |= (temp & 0x1100) * 2;
- flags |= flagsModifier;
- flags |= (flagsModifier << 2) ^ 0x8800;
+ _flagsModifier &= ~((temp & 0x4400) >> 1);
+ _flagsModifier |= (temp & 0x1100) * 2;
+ flags |= _flagsModifier;
+ flags |= (_flagsModifier << 2) ^ 0x8800;
}
buttonList = _backUpButtonList;
@@ -750,8 +749,8 @@ const char *GUI_v2::nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8
_keyPressed.reset();
_cancelNameInput = _finishNameInput = false;
while (running && !_vm->shouldQuit()) {
- processHighlights(_savenameMenu, _vm->_mouseX, _vm->_mouseY);
checkTextfieldInput();
+ processHighlights(_savenameMenu, _vm->_mouseX, _vm->_mouseY);
if (_keyPressed.keycode == Common::KEYCODE_RETURN || _keyPressed.keycode == Common::KEYCODE_KP_ENTER || _finishNameInput) {
if (checkSavegameDescription(buffer, curPos)) {
buffer[curPos] = 0;
@@ -823,54 +822,6 @@ int GUI_v2::getCharWidth(uint8 c) {
return width;
}
-void GUI_v2::checkTextfieldInput() {
- Common::Event event;
-
- uint32 now = _vm->_system->getMillis();
-
- bool running = true;
- int keys = 0;
- while (_vm->_eventMan->pollEvent(event) && running) {
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode == 'q' && event.kbd.flags == Common::KBD_CTRL)
- _vm->quitGame();
- else
- _keyPressed = event.kbd;
- running = false;
- break;
-
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_LBUTTONUP: {
- Common::Point pos = _vm->getMousePos();
- _vm->_mouseX = pos.x;
- _vm->_mouseY = pos.y;
- keys = event.type == Common::EVENT_LBUTTONDOWN ? 199 : (200 | 0x800);
- running = false;
- } break;
-
- case Common::EVENT_MOUSEMOVE: {
- Common::Point pos = _vm->getMousePos();
- _vm->_mouseX = pos.x;
- _vm->_mouseY = pos.y;
- _screen->updateScreen();
- _lastScreenUpdate = now;
- } break;
-
- default:
- break;
- }
- }
-
- if (now - _lastScreenUpdate > 50) {
- _vm->_system->updateScreen();
- _lastScreenUpdate = now;
- }
-
- processButtonList(_menuButtonList, keys | 0x8000, 0);
- _vm->_system->delayMillis(3);
-}
-
void GUI_v2::drawTextfieldBlock(int x, int y, uint8 c) {
_screen->fillRect(x+1, y+1, x+7, y+8, c);
}
diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h
index 88861ff905..a8e14d8831 100644
--- a/engines/kyra/gui_v2.h
+++ b/engines/kyra/gui_v2.h
@@ -121,6 +121,7 @@ protected:
bool _buttonListChanged;
Button *_backUpButtonList;
Button *_unknownButtonList;
+ uint16 _flagsModifier;
protected:
virtual void setupPalette() {}
@@ -212,8 +213,6 @@ protected:
// savename menu
bool _finishNameInput, _cancelNameInput;
- Common::KeyState _keyPressed;
- uint32 _lastScreenUpdate;
const char *nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8 c2, uint8 c3, int bufferSize);
int finishSavename(Button *caller);
@@ -221,7 +220,6 @@ protected:
bool checkSavegameDescription(const char *buffer, int size);
int getCharWidth(uint8 c);
- void checkTextfieldInput();
void drawTextfieldBlock(int x, int y, uint8 c);
// choice menu
diff --git a/engines/kyra/kyra_hof.h b/engines/kyra/kyra_hof.h
index 8db7a28387..a3f78b8465 100644
--- a/engines/kyra/kyra_hof.h
+++ b/engines/kyra/kyra_hof.h
@@ -200,7 +200,7 @@ public:
Screen *screen() { return _screen; }
Screen_v2 *screen_v2() const { return _screen; }
- GUI_v2 *gui_v2() const { return _gui; }
+ GUI *gui() const { return _gui; }
virtual TextDisplayer *text() { return _text; }
int language() const { return _lang; }
protected:
diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp
index e7e0ff25e0..5829aeb10a 100644
--- a/engines/kyra/kyra_lok.cpp
+++ b/engines/kyra/kyra_lok.cpp
@@ -48,7 +48,6 @@ namespace Kyra {
KyraEngine_LoK::KyraEngine_LoK(OSystem *system, const GameFlags &flags)
: KyraEngine_v1(system, flags) {
- _skipFlag = false;
_seq_Forest = _seq_KallakWriting = _seq_KyrandiaLogo = _seq_KallakMalcolm =
_seq_MalcolmTree = _seq_WestwoodLogo = _seq_Demo1 = _seq_Demo2 = _seq_Demo3 =
@@ -220,8 +219,6 @@ Common::Error KyraEngine_LoK::init() {
memset(_flagsTable, 0, sizeof(_flagsTable));
- _abortWalkFlag = false;
- _abortWalkFlag2 = false;
_talkingCharNum = -1;
_charSayUnk3 = -1;
memset(_currSentenceColor, 0, 3);
@@ -247,12 +244,9 @@ Common::Error KyraEngine_LoK::init() {
assert(_movFacingTable);
_movFacingTable[0] = 8;
- _skipFlag = false;
-
_marbleVaseItem = -1;
memset(_foyerItemTable, -1, sizeof(_foyerItemTable));
_itemInHand = -1;
- _handleInput = false;
_currentRoom = 0xFFFF;
_scenePhasingFlag = 0;
@@ -279,8 +273,6 @@ Common::Error KyraEngine_LoK::init() {
_kyragemFadingState.gOffset = 0x13;
_kyragemFadingState.bOffset = 0x13;
- _mousePressFlag = false;
-
_menuDirectlyToLoad = false;
_lastMusicCommand = 0;
@@ -297,18 +289,23 @@ Common::Error KyraEngine_LoK::go() {
_abortIntroFlag = false;
if (_flags.isDemo) {
+ _seqPlayerFlag = true;
seq_demo();
+ _seqPlayerFlag = false;
} else {
setGameFlag(0xF3);
setGameFlag(0xFD);
if (_gameToLoad == -1) {
setGameFlag(0xEF);
+ _seqPlayerFlag = true;
seq_intro();
if (shouldQuit())
return Common::kNoError;
if (_skipIntroFlag && _abortIntroFlag)
resetGameFlag(0xEF);
+ _seqPlayerFlag = false;
}
+ _eventList.clear();
startup();
resetGameFlag(0xEF);
mainLoop();
@@ -403,9 +400,10 @@ void KyraEngine_LoK::startup() {
void KyraEngine_LoK::mainLoop() {
debugC(9, kDebugLevelMain, "KyraEngine_LoK::mainLoop()");
+ _eventList.clear();
+
while (!shouldQuit()) {
int32 frameTime = (int32)_system->getMillis();
- _skipFlag = false;
checkAutosave();
@@ -434,18 +432,24 @@ void KyraEngine_LoK::mainLoop() {
_brandonStatusBit0x20Flag = 0;
}
+ // FIXME: Why is this here?
_screen->showMouse();
- _gui->processButtonList(_buttonList, 0, 0);
+ int inputFlag = checkInput(_buttonList, true);
+ removeInputTop();
+
updateMousePointer();
_timer->update();
+ _sound->process();
updateTextFade();
- _handleInput = true;
- delay((frameTime + _gameSpeed) - _system->getMillis(), true, true);
- _handleInput = false;
+ if (inputFlag == 198 || inputFlag == 199)
+ processInput(_mouseX, _mouseY);
- _sound->process();
+ if (skipFlag())
+ resetSkipFlag();
+
+ delay((frameTime + _gameSpeed) - _system->getMillis(), true, true);
}
}
@@ -464,69 +468,9 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) {
uint32 start = _system->getMillis();
do {
- if (isMainLoop)
- _isSaveAllowed = true;
-
- while (_eventMan->pollEvent(event)) {
- _isSaveAllowed = false;
-
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' &&
- (event.kbd.flags == Common::KBD_CTRL || event.kbd.flags == Common::KBD_ALT) && isMainLoop) {
- int saveLoadSlot = 9 - (event.kbd.keycode - '0') + 990;
-
- if (event.kbd.flags == Common::KBD_CTRL)
- loadGameStateCheck(saveLoadSlot);
- else {
- char savegameName[14];
- sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0');
- saveGameState(saveLoadSlot, savegameName, 0);
- }
- } else if (event.kbd.flags == Common::KBD_CTRL) {
- if (event.kbd.keycode == 'd')
- _debugger->attach();
- else if (event.kbd.keycode == 'q')
- quitGame();
- } else if (event.kbd.keycode == '.') {
- _skipFlag = true;
+ /*} else if (event.kbd.keycode == '.') {
} else if (event.kbd.keycode == Common::KEYCODE_RETURN || event.kbd.keycode == Common::KEYCODE_SPACE || event.kbd.keycode == Common::KEYCODE_ESCAPE) {
- _abortIntroFlag = true;
- _skipFlag = true;
- }
-
- break;
- case Common::EVENT_MOUSEMOVE:
- _animator->_updateScreen = true;
- break;
- case Common::EVENT_LBUTTONDOWN:
- _mousePressFlag = true;
- break;
- case Common::EVENT_LBUTTONUP:
- _mousePressFlag = false;
-
- if (_abortWalkFlag2)
- _abortWalkFlag = true;
-
- if (_handleInput) {
- _handleInput = false;
- processInput();
- _handleInput = true;
- } else
- _skipFlag = true;
-
- break;
- default:
- break;
- }
-
- if (isMainLoop)
- _isSaveAllowed = true;
- }
-
- if (_debugger->isAttached())
- _debugger->onFrame();
-
+ _abortIntroFlag = true;*/
if (update) {
_sprites->updateSceneAnims();
_animator->updateAllObjectShapes();
@@ -534,44 +478,33 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) {
updateMousePointer();
}
+ updateInput();
+
if (_currentCharacter && _currentCharacter->sceneId == 210 && update)
updateKyragemFading();
- if (_skipFlag && !_abortIntroFlag && !queryGameFlag(0xFE))
- _skipFlag = false;
-
- if (amount > 0 && !_skipFlag && !shouldQuit())
+ if (amount > 0 && !skipFlag() && !shouldQuit())
_system->delayMillis(10);
- if (_skipFlag)
- _sound->voiceStop();
- } while (!_skipFlag && _system->getMillis() < start + amount && !shouldQuit());
-}
-
-void KyraEngine_LoK::waitForEvent() {
- bool finished = false;
- Common::Event event;
-
- while (!finished && !shouldQuit()) {
- while (_eventMan->pollEvent(event)) {
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- finished = true;
- break;
- case Common::EVENT_LBUTTONDOWN:
- finished = true;
- _skipFlag = true;
- break;
- default:
- break;
+ // FIXME: Major hackery to allow skipping the intro
+ if (_seqPlayerFlag) {
+ for (Common::List<Event>::iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
+ if (i->causedSkip) {
+ if (i->event.type == Common::EVENT_KEYDOWN && i->event.kbd.keycode == Common::KEYCODE_ESCAPE)
+ _abortIntroFlag = true;
+ else
+ i->causedSkip = false;
+ }
}
}
- if (_debugger->isAttached())
- _debugger->onFrame();
+ if (skipFlag())
+ _sound->voiceStop();
+ } while (!skipFlag() && _system->getMillis() < start + amount && !shouldQuit());
+}
- _system->delayMillis(10);
- }
+bool KyraEngine_LoK::skipFlag() const {
+ return KyraEngine_v1::skipFlag() || shouldQuit();
}
void KyraEngine_LoK::delayWithTicks(int ticks) {
@@ -586,7 +519,7 @@ void KyraEngine_LoK::delayWithTicks(int ticks) {
seq_playEnd();
}
- if (_skipFlag)
+ if (skipFlag())
break;
if (nextTime - _system->getMillis() >= 10)
@@ -676,13 +609,8 @@ void KyraEngine_LoK::resetBrandonPoisonFlags() {
#pragma mark - Input
#pragma mark -
-void KyraEngine_LoK::processInput() {
- Common::Point mouse = getMousePos();
- int xpos = mouse.x;
- int ypos = mouse.y;
-
+void KyraEngine_LoK::processInput(int xpos, int ypos) {
debugC(9, kDebugLevelMain, "KyraEngine_LoK::processInput(%d, %d)", xpos, ypos);
- _abortWalkFlag2 = false;
if (processInputHelper(xpos, ypos))
return;
@@ -698,20 +626,18 @@ void KyraEngine_LoK::processInput() {
// XXX _deathHandler specific
if (ypos <= 158) {
uint16 exit = 0xFFFF;
- if (xpos < 12) {
+
+ if (xpos < 12)
exit = _walkBlockWest;
- } else if (xpos >= 308) {
+ else if (xpos >= 308)
exit = _walkBlockEast;
- } else if (ypos >= 136) {
+ else if (ypos >= 136)
exit = _walkBlockSouth;
- } else if (ypos < 12) {
+ else if (ypos < 12)
exit = _walkBlockNorth;
- }
if (exit != 0xFFFF) {
- _abortWalkFlag2 = true;
handleSceneChange(xpos, ypos, 1, 1);
- _abortWalkFlag2 = false;
return;
} else {
int script = checkForNPCScriptRun(xpos, ypos);
@@ -722,19 +648,14 @@ void KyraEngine_LoK::processInput() {
if (_itemInHand != -1) {
if (ypos < 155) {
if (hasClickedOnExit(xpos, ypos)) {
- _abortWalkFlag2 = true;
handleSceneChange(xpos, ypos, 1, 1);
- _abortWalkFlag2 = false;
return;
}
dropItem(0, _itemInHand, xpos, ypos, 1);
}
} else {
- if (ypos <= 155) {
- _abortWalkFlag2 = true;
+ if (ypos <= 155)
handleSceneChange(xpos, ypos, 1, 1);
- _abortWalkFlag2 = false;
- }
}
}
}
diff --git a/engines/kyra/kyra_lok.h b/engines/kyra/kyra_lok.h
index d294e29fad..ebe110981e 100644
--- a/engines/kyra/kyra_lok.h
+++ b/engines/kyra/kyra_lok.h
@@ -119,6 +119,7 @@ public:
Screen *screen() { return _screen; }
Animator_LoK *animator() { return _animator; }
+ GUI *gui() const { return _gui; }
virtual Movie *createWSAMovie();
uint8 **shapes() { return _shapes; }
@@ -198,7 +199,8 @@ public:
void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false);
void delay(uint32 millis, bool update = false, bool isMainLoop = false);
void delayWithTicks(int ticks);
- void waitForEvent();
+
+ bool skipFlag() const;
// TODO
void registerDefaultSettings();
@@ -218,17 +220,13 @@ protected:
Common::Error loadGameState(int slot);
protected:
// input
- void processInput();
+ void processInput(int xpos, int ypos);
int processInputHelper(int xpos, int ypos);
int clickEventHandler(int xpos, int ypos);
void clickEventHandler2();
void updateMousePointer(bool forceUpdate = false);
bool hasClickedOnExit(int xpos, int ypos);
- bool _skipFlag;
- bool skipFlag() const { return _skipFlag; }
- void resetSkipFlag(bool removeEvent = true) { _skipFlag = false; }
-
// scene
// -> init
void loadSceneMsc();
@@ -389,16 +387,14 @@ protected:
int buttonInventoryCallback(Button *caller);
int buttonAmuletCallback(Button *caller);
+ bool _seqPlayerFlag;
bool _skipIntroFlag;
bool _abortIntroFlag;
+
bool _menuDirectlyToLoad;
- bool _abortWalkFlag;
- bool _abortWalkFlag2;
- bool _mousePressFlag;
uint8 *_itemBkgBackUp[2];
uint8 *_shapes[373];
int8 _itemInHand;
- bool _handleInput;
bool _changedScene;
int _unkScreenVar1, _unkScreenVar2, _unkScreenVar3;
int _beadStateVar;
diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h
index 73886b9d11..a0e0af93b0 100644
--- a/engines/kyra/kyra_mr.h
+++ b/engines/kyra/kyra_mr.h
@@ -57,7 +57,7 @@ public:
Screen *screen() { return _screen; }
Screen_v2 *screen_v2() const { return _screen; }
- GUI_v2 *gui_v2() const { return _gui; }
+ GUI *gui() const { return _gui; }
SoundDigital *soundDigital() { return _soundDigital; }
int language() const { return _lang; }
bool heliumMode() const { return _configHelium; }
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index 0e981a50d0..b2682fb385 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -222,6 +222,148 @@ void KyraEngine_v1::setMousePos(int x, int y) {
_system->warpMouse(x, y);
}
+int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v1::checkInput(%p, %d)", (const void*)buttonList, mainLoop);
+ if (mainLoop)
+ _isSaveAllowed = true;
+
+ updateInput();
+
+ _isSaveAllowed = false;
+
+ int keys = 0;
+ int8 mouseWheel = 0;
+
+ while (_eventList.size()) {
+ Common::Event event = *_eventList.begin();
+ bool breakLoop = false;
+
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' &&
+ (event.kbd.flags == Common::KBD_CTRL || event.kbd.flags == Common::KBD_ALT) && mainLoop) {
+ int saveLoadSlot = 9 - (event.kbd.keycode - '0') + 990;
+
+ if (event.kbd.flags == Common::KBD_CTRL) {
+ loadGameStateCheck(saveLoadSlot);
+ _eventList.clear();
+ breakLoop = true;
+ } else {
+ char savegameName[14];
+ sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0');
+ saveGameState(saveLoadSlot, savegameName, 0);
+ }
+ } else if (event.kbd.flags == Common::KBD_CTRL) {
+ if (event.kbd.keycode == 'd')
+ _debugger->attach();
+ else if (event.kbd.keycode == 'q')
+ quitGame();
+ }
+ break;
+
+ case Common::EVENT_MOUSEMOVE: {
+ Common::Point pos = getMousePos();
+ _mouseX = pos.x;
+ _mouseY = pos.y;
+ } break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP: {
+ Common::Point pos = getMousePos();
+ _mouseX = pos.x;
+ _mouseY = pos.y;
+ keys = (event.type == Common::EVENT_LBUTTONDOWN ? 199 : (200 | 0x800));
+ breakLoop = true;
+ } break;
+
+ case Common::EVENT_WHEELUP:
+ mouseWheel = -1;
+ break;
+
+ case Common::EVENT_WHEELDOWN:
+ mouseWheel = 1;
+ break;
+
+ default:
+ break;
+ }
+
+ if (_debugger->isAttached())
+ _debugger->onFrame();
+
+ if (breakLoop)
+ break;
+
+ _eventList.erase(_eventList.begin());
+ }
+
+ GUI *guiInstance = gui();
+ if (guiInstance)
+ return guiInstance->processButtonList(buttonList, keys | 0x8000, mouseWheel);
+ else
+ return keys;
+}
+
+void KyraEngine_v1::updateInput() {
+ Common::Event event;
+
+ while (_eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == '.' || event.kbd.keycode == Common::KEYCODE_ESCAPE)
+ _eventList.push_back(Event(event, true));
+ else if (event.kbd.keycode == 'q' && event.kbd.flags == Common::KBD_CTRL)
+ quitGame();
+ else
+ _eventList.push_back(event);
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ _eventList.push_back(Event(event, true));
+ break;
+
+ case Common::EVENT_MOUSEMOVE:
+ screen()->updateScreen();
+ // fall through
+
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_WHEELUP:
+ case Common::EVENT_WHEELDOWN:
+ _eventList.push_back(event);
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+void KyraEngine_v1::removeInputTop() {
+ if (!_eventList.empty())
+ _eventList.erase(_eventList.begin());
+}
+
+bool KyraEngine_v1::skipFlag() const {
+ for (Common::List<Event>::const_iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
+ if (i->causedSkip)
+ return true;
+ }
+ return false;
+}
+
+void KyraEngine_v1::resetSkipFlag(bool removeEvent) {
+ for (Common::List<Event>::iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
+ if (i->causedSkip) {
+ if (removeEvent)
+ _eventList.erase(i);
+ else
+ i->causedSkip = false;
+ return;
+ }
+ }
+}
+
+
int KyraEngine_v1::setGameFlag(int flag) {
_flagsTable[flag >> 3] |= (1 << (flag & 7));
return 1;
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index e1dde72b8d..13b6397e44 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -105,6 +105,9 @@ class TextDisplayer;
class StaticResource;
class TimerManager;
class Debugger;
+class GUI;
+
+struct Button;
class KyraEngine_v1 : public Engine {
friend class Debugger;
@@ -115,7 +118,6 @@ public:
KyraEngine_v1(OSystem *system, const GameFlags &flags);
virtual ~KyraEngine_v1();
-
uint8 game() const { return _flags.gameID; }
const GameFlags &gameFlags() const { return _flags; }
@@ -123,6 +125,7 @@ public:
Resource *resource() { return _res; }
virtual Screen *screen() = 0;
virtual TextDisplayer *text() { return _text; }
+ virtual GUI *gui() const { return 0; }
Sound *sound() { return _sound; }
StaticResource *staticres() { return _staticres; }
TimerManager *timer() { return _timer; }
@@ -185,6 +188,25 @@ protected:
EMCInterpreter *_emc;
Debugger *_debugger;
+ // input
+ void updateInput();
+ int checkInput(Button *buttonList, bool mainLoop = false);
+ void removeInputTop();
+
+ int _mouseX, _mouseY;
+
+ struct Event {
+ Common::Event event;
+ bool causedSkip;
+
+ Event() : event(), causedSkip(false) {}
+ Event(Common::Event e) : event(e), causedSkip(false) {}
+ Event(Common::Event e, bool skip) : event(e), causedSkip(skip) {}
+
+ operator Common::Event() const { return event; }
+ };
+ Common::List<Event> _eventList;
+
// config specific
virtual void registerDefaultSettings();
virtual void readSettings();
@@ -197,8 +219,8 @@ protected:
uint8 _configVoice;
// game speed
- virtual bool skipFlag() const = 0;
- virtual void resetSkipFlag(bool removeEvent = true) = 0;
+ virtual bool skipFlag() const;
+ virtual void resetSkipFlag(bool removeEvent = true);
uint16 _tickLength;
uint16 _gameSpeed;
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 3099652af3..158206f73f 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -162,141 +162,6 @@ void KyraEngine_v2::delay(uint32 amount, bool updateGame, bool isMainLoop) {
} while (!skipFlag() && _system->getMillis() < start + amount && !shouldQuit());
}
-int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) {
- debugC(9, kDebugLevelMain, "KyraEngine_v2::checkInput(%p, %d)", (const void*)buttonList, mainLoop);
- if (mainLoop)
- _isSaveAllowed = true;
-
- updateInput();
-
- _isSaveAllowed = false;
-
- int keys = 0;
- int8 mouseWheel = 0;
-
- while (_eventList.size()) {
- Common::Event event = *_eventList.begin();
- bool breakLoop = false;
-
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' &&
- (event.kbd.flags == Common::KBD_CTRL || event.kbd.flags == Common::KBD_ALT) && mainLoop) {
- int saveLoadSlot = 9 - (event.kbd.keycode - '0') + 990;
-
- if (event.kbd.flags == Common::KBD_CTRL) {
- loadGameStateCheck(saveLoadSlot);
- _eventList.clear();
- breakLoop = true;
- } else {
- char savegameName[14];
- sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0');
- saveGameState(saveLoadSlot, savegameName, 0);
- }
- } else if (event.kbd.flags == Common::KBD_CTRL) {
- if (event.kbd.keycode == 'd')
- _debugger->attach();
- }
- break;
-
- case Common::EVENT_MOUSEMOVE: {
- Common::Point pos = getMousePos();
- _mouseX = pos.x;
- _mouseY = pos.y;
- } break;
-
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_LBUTTONUP: {
- Common::Point pos = getMousePos();
- _mouseX = pos.x;
- _mouseY = pos.y;
- keys = (event.type == Common::EVENT_LBUTTONDOWN ? 199 : (200 | 0x800));
- breakLoop = true;
- } break;
-
- case Common::EVENT_WHEELUP:
- mouseWheel = -1;
- break;
-
- case Common::EVENT_WHEELDOWN:
- mouseWheel = 1;
- break;
-
- default:
- break;
- }
-
- if (_debugger->isAttached())
- _debugger->onFrame();
-
- if (breakLoop)
- break;
-
- _eventList.erase(_eventList.begin());
- }
-
- return gui_v2()->processButtonList(buttonList, keys | 0x8000, mouseWheel);
-}
-
-void KyraEngine_v2::updateInput() {
- Common::Event event;
-
- while (_eventMan->pollEvent(event)) {
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode == '.' || event.kbd.keycode == Common::KEYCODE_ESCAPE)
- _eventList.push_back(Event(event, true));
- else if (event.kbd.keycode == 'q' && event.kbd.flags == Common::KBD_CTRL)
- quitGame();
- else
- _eventList.push_back(event);
- break;
-
- case Common::EVENT_LBUTTONDOWN:
- _eventList.push_back(Event(event, true));
- break;
-
- case Common::EVENT_MOUSEMOVE:
- screen_v2()->updateScreen();
- // fall through
-
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_WHEELUP:
- case Common::EVENT_WHEELDOWN:
- _eventList.push_back(event);
- break;
-
- default:
- break;
- }
- }
-}
-
-void KyraEngine_v2::removeInputTop() {
- if (!_eventList.empty())
- _eventList.erase(_eventList.begin());
-}
-
-bool KyraEngine_v2::skipFlag() const {
- for (Common::List<Event>::const_iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
- if (i->causedSkip)
- return true;
- }
- return false;
-}
-
-void KyraEngine_v2::resetSkipFlag(bool removeEvent) {
- for (Common::List<Event>::iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
- if (i->causedSkip) {
- if (removeEvent)
- _eventList.erase(i);
- else
- i->causedSkip = false;
- return;
- }
- }
-}
-
bool KyraEngine_v2::checkSpecialSceneExit(int num, int x, int y) {
if (_specialExitTable[0+num] > x || _specialExitTable[5+num] > y ||
_specialExitTable[10+num] < x || _specialExitTable[15+num] < y)
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index e606bdfc15..2d261d8c7b 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -78,7 +78,6 @@ public:
virtual void pauseEngineIntern(bool pause);
virtual Screen_v2 *screen_v2() const = 0;
- virtual GUI *gui_v2() const = 0;
void delay(uint32 time, bool update = false, bool isMainLoop = false);
@@ -103,27 +102,6 @@ protected:
// Input
virtual int inputSceneChange(int x, int y, int unk1, int unk2) = 0;
- void updateInput();
- int checkInput(Button *buttonList, bool mainLoop = false);
- void removeInputTop();
-
- int _mouseX, _mouseY;
-
- struct Event {
- Common::Event event;
- bool causedSkip;
-
- Event() : event(), causedSkip(false) {}
- Event(Common::Event e) : event(e), causedSkip(false) {}
- Event(Common::Event e, bool skip) : event(e), causedSkip(skip) {}
-
- operator Common::Event() const { return event; }
- };
- Common::List<Event> _eventList;
-
- virtual bool skipFlag() const;
- virtual void resetSkipFlag(bool removeEvent = true);
-
// Animator
struct AnimObj {
uint16 index;
diff --git a/engines/kyra/saveload_lok.cpp b/engines/kyra/saveload_lok.cpp
index 8cad0eeb75..c437960907 100644
--- a/engines/kyra/saveload_lok.cpp
+++ b/engines/kyra/saveload_lok.cpp
@@ -202,9 +202,6 @@ Common::Error KyraEngine_LoK::loadGameState(int slot) {
_screen->_disableScreen = false;
_screen->updateScreen();
- _abortWalkFlag = true;
- _abortWalkFlag2 = false;
- _mousePressFlag = false;
setMousePos(brandonX, brandonY);
if (in->err() || in->eos()) {
diff --git a/engines/kyra/scene_lok.cpp b/engines/kyra/scene_lok.cpp
index b3b830faed..8d6309855f 100644
--- a/engines/kyra/scene_lok.cpp
+++ b/engines/kyra/scene_lok.cpp
@@ -44,9 +44,6 @@ void KyraEngine_LoK::enterNewScene(int sceneId, int facing, int unk1, int unk2,
debugC(9, kDebugLevelMain, "KyraEngine_LoK::enterNewScene(%d, %d, %d, %d, %d)", sceneId, facing, unk1, unk2, brandonAlive);
int unkVar1 = 1;
_screen->hideMouse();
- _handleInput = false;
- _abortWalkFlag = false;
- _abortWalkFlag2 = false;
// TODO: Check how the original handled sfx still playing
_sound->stopAllSoundEffects();
@@ -923,18 +920,8 @@ int KyraEngine_LoK::processSceneChange(int *table, int unk1, int frameReset) {
bool running = true;
int returnValue = 0;
uint32 nextFrame = 0;
- _abortWalkFlag = false;
- _mousePressFlag = false;
while (running) {
- if (_abortWalkFlag) {
- *table = 8;
- _currentCharacter->currentAnimFrame = 7;
- _animator->animRefreshNPC(0);
- _animator->updateAllObjectShapes();
- processInput();
- return 0;
- }
bool forceContinue = false;
switch (*table) {
case 0: case 1: case 2:
@@ -955,13 +942,12 @@ int KyraEngine_LoK::processSceneChange(int *table, int unk1, int frameReset) {
}
returnValue = changeScene(_currentCharacter->facing);
- if (returnValue) {
+ if (returnValue)
running = false;
- _abortWalkFlag = false;
- }
if (unk1) {
- if (_mousePressFlag) {
+ if (skipFlag()) {
+ resetSkipFlag(false);
running = false;
_sceneChangeState = 1;
}
diff --git a/engines/kyra/script_lok.cpp b/engines/kyra/script_lok.cpp
index b0fc4b860c..afdb4d2dab 100644
--- a/engines/kyra/script_lok.cpp
+++ b/engines/kyra/script_lok.cpp
@@ -44,7 +44,7 @@ int KyraEngine_LoK::o1_magicInMouseItem(EMCState *script) {
}
int KyraEngine_LoK::o1_characterSays(EMCState *script) {
- _skipFlag = false;
+ resetSkipFlag();
if (_flags.isTalkie) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_LoK::o1_characterSays(%p) (%d, '%s', %d, %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3));
characterSays(stackPos(0), stackPosString(1), stackPos(2), stackPos(3));
@@ -330,11 +330,11 @@ int KyraEngine_LoK::o1_delaySecs(EMCState *script) {
}
} else {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_LoK::o1_delaySecs(%p) (%d)", (const void *)script, stackPos(0));
- if (stackPos(0) >= 0 && !_skipFlag)
+ if (stackPos(0) >= 0 && !skipFlag())
delay(stackPos(0)*1000, true);
}
- _skipFlag = false;
+ resetSkipFlag();
return 0;
}
@@ -470,7 +470,7 @@ int KyraEngine_LoK::o1_displayWSAFrame(EMCState *script) {
while (_system->getMillis() < continueTime) {
_sprites->updateSceneAnims();
_animator->updateAllObjectShapes();
- if (_skipFlag)
+ if (skipFlag())
break;
if (continueTime - _system->getMillis() >= 10)
@@ -607,12 +607,12 @@ int KyraEngine_LoK::o1_customPrintTalkString(EMCState *script) {
snd_playVoiceFile(stackPos(0));
}
- _skipFlag = false;
+ resetSkipFlag();
if (textEnabled())
_text->printTalkTextMessage(stackPosString(1), stackPos(2), stackPos(3), stackPos(4) & 0xFF, 0, 2);
} else {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_LoK::o1_customPrintTalkString(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3) & 0xFF);
- _skipFlag = false;
+ resetSkipFlag();
_text->printTalkTextMessage(stackPosString(0), stackPos(1), stackPos(2), stackPos(3) & 0xFF, 0, 2);
}
_screen->updateScreen();
@@ -699,7 +699,7 @@ int KyraEngine_LoK::o1_displayWSAFrameOnHidPage(EMCState *script) {
while (_system->getMillis() < continueTime) {
_sprites->updateSceneAnims();
_animator->updateAllObjectShapes();
- if (_skipFlag)
+ if (skipFlag())
break;
if (continueTime - _system->getMillis() >= 10)
@@ -787,7 +787,7 @@ int KyraEngine_LoK::o1_displayWSASequentialFrames(EMCState *script) {
while (_system->getMillis() < continueTime) {
_sprites->updateSceneAnims();
_animator->updateAllObjectShapes();
- if (_skipFlag)
+ if (skipFlag())
break;
if (continueTime - _system->getMillis() >= 10)
@@ -805,7 +805,7 @@ int KyraEngine_LoK::o1_displayWSASequentialFrames(EMCState *script) {
while (_system->getMillis() < continueTime) {
_sprites->updateSceneAnims();
_animator->updateAllObjectShapes();
- if (_skipFlag)
+ if (skipFlag())
break;
if (continueTime - _system->getMillis() >= 10)
@@ -815,7 +815,7 @@ int KyraEngine_LoK::o1_displayWSASequentialFrames(EMCState *script) {
}
}
- if (_skipFlag)
+ if (skipFlag())
break;
else
++curTime;
@@ -927,7 +927,17 @@ int KyraEngine_LoK::o1_placeCharacterInOtherScene(EMCState *script) {
int KyraEngine_LoK::o1_getKey(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_LoK::o1_getKey(%p) ()", (const void *)script);
- waitForEvent();
+
+ // TODO: Check this implementation
+
+ while (true) {
+ delay(10);
+
+ if (skipFlag())
+ break;
+ }
+
+ resetSkipFlag();
return 0;
}
@@ -1338,26 +1348,25 @@ int KyraEngine_LoK::o1_setCharacterCurrentFrame(EMCState *script) {
int KyraEngine_LoK::o1_waitForConfirmationMouseClick(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_LoK::o1_waitForConfirmationMouseClick(%p) ()", (const void *)script);
- // if (mouseEnabled) {
- while (!_mousePressFlag) {
- updateMousePointer();
- _sprites->updateSceneAnims();
- _animator->updateAllObjectShapes();
- delay(10);
- }
- while (_mousePressFlag) {
+ while (true) {
updateMousePointer();
_sprites->updateSceneAnims();
_animator->updateAllObjectShapes();
+
+ updateInput();
+
+ int input = checkInput(_buttonList, false) & 0xFF;
+ removeInputTop();
+ if (input == 200)
+ break;
+
delay(10);
}
- // }
- _gui->processButtonList(_buttonList, 0, 0);
- _skipFlag = false;
- Common::Point mouse = getMousePos();
- script->regs[1] = mouse.x;
- script->regs[2] = mouse.y;
+
+ script->regs[1] = _mouseX;
+ script->regs[2] = _mouseY;
+
return 0;
}
diff --git a/engines/kyra/sequences_lok.cpp b/engines/kyra/sequences_lok.cpp
index c9c1a05842..e072b84876 100644
--- a/engines/kyra/sequences_lok.cpp
+++ b/engines/kyra/sequences_lok.cpp
@@ -107,8 +107,9 @@ void KyraEngine_LoK::seq_intro() {
if ((in = _saveFileMan->openForLoading(getSavegameFilename(0)))) {
delete in;
_skipIntroFlag = true;
- } else
+ } else {
_skipIntroFlag = false;
+ }
_seq->setCopyViewOffs(true);
_screen->setFont(Screen::FID_8_FNT);
@@ -163,7 +164,7 @@ void KyraEngine_LoK::seq_introLogos() {
_screen->updateScreen();
_screen->fadeFromBlack();
- if (_seq->playSequence(_seq_WestwoodLogo, _skipFlag) || shouldQuit()) {
+ if (_seq->playSequence(_seq_WestwoodLogo, skipFlag()) || shouldQuit()) {
_screen->fadeToBlack();
_screen->clearPage(0);
return;
@@ -175,7 +176,7 @@ void KyraEngine_LoK::seq_introLogos() {
_screen->setScreenPalette(_screen->_currentPalette);
}
- if ((_seq->playSequence(_seq_KyrandiaLogo, _skipFlag) && !seq_skipSequence()) || shouldQuit()) {
+ if ((_seq->playSequence(_seq_KyrandiaLogo, skipFlag()) && !seq_skipSequence()) || shouldQuit()) {
_screen->fadeToBlack();
_screen->clearPage(0);
return;
@@ -274,7 +275,7 @@ void KyraEngine_LoK::seq_introStory() {
}
_screen->updateScreen();
- //debugC(0, kDebugLevelMain, "skipFlag %i, %i", _skipFlag, _tickLength);
+ //debugC(0, kDebugLevelMain, "skipFlag %i, %i", skipFlag(), _tickLength);
delay(360 * _tickLength);
}
diff --git a/engines/kyra/sound_lok.cpp b/engines/kyra/sound_lok.cpp
index b43d72ebce..415181b985 100644
--- a/engines/kyra/sound_lok.cpp
+++ b/engines/kyra/sound_lok.cpp
@@ -82,7 +82,7 @@ void KyraEngine_LoK::snd_playVoiceFile(int id) {
void KyraEngine_LoK::snd_voiceWaitForFinish(bool ingame) {
debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_LoK::snd_voiceWaitForFinish(%d)", ingame);
- while (_sound->voiceIsPlaying() && !_skipFlag) {
+ while (_sound->voiceIsPlaying() && !skipFlag()) {
if (ingame)
delay(10, true);
else
diff --git a/engines/kyra/text_lok.cpp b/engines/kyra/text_lok.cpp
index 150ec59a23..8c0980005b 100644
--- a/engines/kyra/text_lok.cpp
+++ b/engines/kyra/text_lok.cpp
@@ -114,22 +114,11 @@ void KyraEngine_LoK::waitForChatToFinish(int vocFile, int16 chatDuration, const
uint32 nextTime = loopStart + _tickLength;
while (_system->getMillis() < nextTime) {
- while (_eventMan->pollEvent(event)) {
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode == '.')
- _skipFlag = true;
- break;
- case Common::EVENT_RTL:
- case Common::EVENT_QUIT:
- runLoop = false;
- break;
- case Common::EVENT_LBUTTONDOWN:
- runLoop = false;
- break;
- default:
- break;
- }
+ updateInput();
+
+ if (skipFlag()) {
+ runLoop = false;
+ break;
}
if (nextTime - _system->getMillis() >= 10) {
@@ -137,13 +126,12 @@ void KyraEngine_LoK::waitForChatToFinish(int vocFile, int16 chatDuration, const
_system->updateScreen();
}
}
-
- if (_skipFlag)
- runLoop = false;
}
- if (_skipFlag)
+ if (skipFlag()) {
+ resetSkipFlag();
snd_stopVoice();
+ }
_timer->enable(14);
_timer->enable(15);