aboutsummaryrefslogtreecommitdiff
path: root/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2005-12-13 15:10:20 +0000
committerJohannes Schickel2005-12-13 15:10:20 +0000
commit1f727e00189d347e23e24fe7e2fbd7ed68378793 (patch)
tree498d2177a670ba0400d59a6a1035a875645a29cf /kyra
parent67d640b214d099761ced51aff67c8c55a8f395ae (diff)
downloadscummvm-rg350-1f727e00189d347e23e24fe7e2fbd7ed68378793.tar.gz
scummvm-rg350-1f727e00189d347e23e24fe7e2fbd7ed68378793.tar.bz2
scummvm-rg350-1f727e00189d347e23e24fe7e2fbd7ed68378793.zip
Improved user controlled input handling.
Disabled use of _mouseLockCount in screen.cpp for now. (that should fix a bug with not displayed cursor after using the debugger) svn-id: r19794
Diffstat (limited to 'kyra')
-rw-r--r--kyra/kyra.cpp37
-rw-r--r--kyra/kyra.h4
-rw-r--r--kyra/screen.cpp6
3 files changed, 37 insertions, 10 deletions
diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp
index 61a393d608..244f1c47fb 100644
--- a/kyra/kyra.cpp
+++ b/kyra/kyra.cpp
@@ -325,6 +325,8 @@ int KyraEngine::init(GameDetector &detector) {
memset(_flagsTable, 0, sizeof(_flagsTable));
_fastMode = false;
+ _abortWalkFlag = false;
+ _abortWalkFlag2 = false;
_talkCoords.y = 0x88;
_talkCoords.x = 0;
_talkCoords.w = 0;
@@ -548,6 +550,11 @@ void KyraEngine::delay(uint32 amount) {
quitGame();
break;
case OSystem::EVENT_LBUTTONDOWN:
+ if (_abortWalkFlag2) {
+ _abortWalkFlag = true;
+ _mouseX = event.mouse.x;
+ _mouseY = event.mouse.y;
+ }
if (_handleInput) {
_mouseX = event.mouse.x;
_mouseY = event.mouse.y;
@@ -1163,6 +1170,7 @@ void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int
debug(9, "enterNewScene(%d, %d, %d, %d, %d)", sceneId, facing, unk1, unk2, brandonAlive);
int unkVar1 = 1;
_screen->hideMouse();
+ _abortWalkFlag2 = false;
if (_currentCharacter->sceneId == 7 && sceneId == 24) {
_newMusicTheme = 2;
} else if (_currentCharacter->sceneId == 25 && sceneId == 109) {
@@ -1321,7 +1329,8 @@ void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int
_screen->showMouse();
if (!brandonAlive) {
// XXX seq_poisionDeathNow
- }
+ }
+ updateMousePointer(true);
}
void KyraEngine::transcendScenes(int roomIndex, int roomName) {
@@ -4275,8 +4284,16 @@ int KyraEngine::processSceneChange(int *table, int unk1, int frameReset) {
bool running = true;
int returnValue = 0;
uint32 nextFrame = 0;
+ _abortWalkFlag = false;
while (running) {
- // XXX
+ if (_abortWalkFlag) {
+ *table = 8;
+ _currentCharacter->currentAnimFrame = 7;
+ animRefreshNPC(0);
+ updateAllObjectShapes();
+ processInput(_mouseX, _mouseY);
+ return 0;
+ }
bool forceContinue = false;
switch (*table) {
case 0: case 1: case 2:
@@ -4708,6 +4725,8 @@ void KyraEngine::drawAmulet() {
void KyraEngine::processInput(int xpos, int ypos) {
debug(9, "processInput(%d, %d)", xpos, ypos);
+ _abortWalkFlag2 = false;
+
if (processInputHelper(xpos, ypos)) {
return;
}
@@ -4731,7 +4750,9 @@ void KyraEngine::processInput(int xpos, int ypos) {
}
if (exit != 0xFFFF) {
+ _abortWalkFlag2 = true;
handleSceneChange(xpos, ypos, 1, 1);
+ _abortWalkFlag2 = false;
return;
} else {
int script = checkForNPCScriptRun(xpos, ypos);
@@ -4742,14 +4763,18 @@ void KyraEngine::processInput(int xpos, int ypos) {
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;
handleSceneChange(xpos, ypos, 1, 1);
+ _abortWalkFlag2 = false;
}
}
}
@@ -4797,7 +4822,7 @@ int KyraEngine::clickEventHandler(int xpos, int ypos) {
return _scriptClick->variables[3];
}
-void KyraEngine::updateMousePointer() {
+void KyraEngine::updateMousePointer(bool forceUpdate) {
int shape = 0;
int newMouseState = 0;
@@ -4886,7 +4911,7 @@ void KyraEngine::updateMousePointer() {
newY = 4;
}
- if (newMouseState && _mouseState != newMouseState) {
+ if ((newMouseState && _mouseState != newMouseState) || (newMouseState && forceUpdate)) {
_mouseState = newMouseState;
_screen->hideMouse();
_screen->setMouseCursor(newX, newY, _shapes[4+shape]);
@@ -4894,8 +4919,8 @@ void KyraEngine::updateMousePointer() {
}
if (!newMouseState) {
- if (_mouseState != _itemInHand) {
- if (_mouseY > 158 || (_mouseX >= 12 && _mouseX < 308 && _mouseY < 136 && _mouseY >= 12)) {
+ if (_mouseState != _itemInHand || forceUpdate) {
+ if (_mouseY > 158 || (_mouseX >= 12 && _mouseX < 308 && _mouseY < 136 && _mouseY >= 12) || forceUpdate) {
_mouseState = _itemInHand;
_screen->hideMouse();
if (_itemInHand == -1) {
diff --git a/kyra/kyra.h b/kyra/kyra.h
index d58e0a9b77..f2054dc396 100644
--- a/kyra/kyra.h
+++ b/kyra/kyra.h
@@ -476,7 +476,7 @@ protected:
int processInputHelper(int xpos, int ypos);
int clickEventHandler(int xpos, int ypos);
void clickEventHandler2();
- void updateMousePointer();
+ void updateMousePointer(bool forceUpdate = false);
bool hasClickedOnExit(int xpos, int ypos);
int checkForNPCScriptRun(int xpos, int ypos);
void runNpcScript(int func);
@@ -560,6 +560,8 @@ protected:
bool _quitFlag;
bool _skipIntroFlag;
bool _abortIntroFlag;
+ bool _abortWalkFlag;
+ bool _abortWalkFlag2;
char _talkBuffer[300];
char _talkSubstrings[TALK_SUBSTRING_LEN * TALK_SUBSTRING_NUM];
TalkCoords _talkCoords;
diff --git a/kyra/screen.cpp b/kyra/screen.cpp
index 91ba5bda36..6a32bc8c29 100644
--- a/kyra/screen.cpp
+++ b/kyra/screen.cpp
@@ -1584,15 +1584,15 @@ int Screen::getRectSize(int x, int y) {
void Screen::hideMouse() {
debug(9, "hideMouse()");
- ++_mouseLockCount;
+ //++_mouseLockCount;
_system->showMouse(false);
}
void Screen::showMouse() {
debug(9, "showMouse()");
- if (--_mouseLockCount == 0) {
+ //if (--_mouseLockCount == 0) {
_system->showMouse(true);
- }
+ //}
}
void Screen::setShapePages(int page1, int page2) {