aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/supernova/rooms.cpp94
-rw-r--r--engines/supernova/state.cpp60
-rw-r--r--engines/supernova/state.h7
3 files changed, 96 insertions, 65 deletions
diff --git a/engines/supernova/rooms.cpp b/engines/supernova/rooms.cpp
index 41210d54bc..484a44fe5e 100644
--- a/engines/supernova/rooms.cpp
+++ b/engines/supernova/rooms.cpp
@@ -102,34 +102,35 @@ bool ShipSleepCabin::interact(Action verb, Object &obj1, Object &obj2) {
Room *r;
if (((verb == ACTION_LOOK) || (verb == ACTION_USE)) && (obj1._id == COMPUTER)) {
- setSectionVisible(kMaxSection - 1, true);
+ _gm->_guiEnabled = false;
setSectionVisible(4, false);
- _vm->renderBox(0,0,320,200,kColorDarkBlue);
+ g_system->fillScreen(kColorDarkBlue);
if (_gm->_state.time == 0) {
// Destination reached
_vm->renderText("Flugziel erreicht", 60, 95, kColorWhite99);
- _gm->mouseInput2();
+ _gm->getInput();
} else if (_gm->_state.powerOff) {
// Energy depleted
- _vm->renderText("Energie erschöpft",60,95,kColorWhite99);
+ _vm->renderText("Energie erschöpft", 60, 95, kColorWhite99);
// Artificial coma interrupted
- _vm->renderText("Tiefschlafprozess abgebrochen",60,115,kColorWhite99);
- _gm->mouseInput2();
+ _vm->renderText("Tiefschlafprozess abgebrochen", 60, 115, kColorWhite99);
+ _gm->getInput();
} else if (isSectionVisible(5)) {
// Sleep duration in days
- _vm->renderText("Schlafdauer in Tagen:",30,85,kColorWhite99);
+ _vm->renderText("Schlafdauer in Tagen:", 30, 85, kColorWhite99);
_vm->renderText(Common::String::format("%d",_gm->_state.timeSleep).c_str(),
- 150,85,kColorWhite99);
+ 150, 85, kColorWhite99);
_vm->renderText("Bitte legen Sie sich in die angezeigte Schlafkammer.",
- 30,105,kColorWhite99);
- _gm->mouseInput2();
+ 30, 105, kColorWhite99);
+ _gm->getInput();
} else {
- _vm->renderText("Bitte Passwort eingeben:",100,85,kColorWhite99);
+ _vm->renderText("Bitte Passwort eingeben:", 100, 85, kColorWhite99);
input[0] = 0;
do {
- _gm->edit(input,100,105,30);
- } while ((_gm->_key != Common::ASCII_RETURN) && (_gm->_key != Common::ASCII_ESCAPE));
- if (_gm->_key == Common::ASCII_ESCAPE) {
+ _gm->edit(input, 100, 105, 30);
+ } while ((_gm->_key.keycode != Common::KEYCODE_RETURN) &&
+ (_gm->_key.keycode != Common::KEYCODE_ESCAPE));
+ if (_gm->_key.keycode == Common::KEYCODE_ESCAPE) {
goto escape;
}
for (int i = 0; i < 30; ++i) {
@@ -138,20 +139,21 @@ bool ShipSleepCabin::interact(Action verb, Object &obj1, Object &obj2) {
}
}
if (strcmp(input,codeword_DE) != 0) {
- _vm->renderText("Falsches Passwort",100,125,kColorLightRed);
+ _vm->renderText("Falsches Passwort", 100, 125, kColorLightRed);
_gm->wait2(18);
goto escape;
}
_gm->great(6);
- _vm->renderBox(0,0,320,200,kColorDarkBlue);
- _vm->renderText("Schlafdauer in Tagen:",30,85,kColorWhite99);
+ _vm->renderBox(0, 0, 320, 200, kColorDarkBlue);
+ _vm->renderText("Schlafdauer in Tagen:", 30, 85, kColorWhite99);
do {
- _vm->renderBox(150,85,150,8,kColorDarkBlue);
+ _vm->renderBox(150, 85, 150, 8, kColorDarkBlue);
input[0] = 0;
do {
- _gm->edit(input,150,85,10);
- } while ((_gm->_key != Common::ASCII_RETURN) && (_gm->_key != Common::ASCII_ESCAPE));
- if (_gm->_key == Common::ASCII_ESCAPE) {
+ _gm->edit(input, 150, 85, 10);
+ } while ((_gm->_key.keycode != Common::KEYCODE_RETURN) &&
+ (_gm->_key.keycode != Common::KEYCODE_ESCAPE));
+ if (_gm->_key.keycode == Common::KEYCODE_ESCAPE) {
goto escape;
}
l = atol(input);
@@ -171,7 +173,7 @@ bool ShipSleepCabin::interact(Action verb, Object &obj1, Object &obj2) {
_gm->showMenu();
_gm->drawMapExits();
_gm->palette();
- setSectionVisible(kMaxSection - 1, false);
+ _gm->_guiEnabled = true;
} else if (((verb == ACTION_WALK) || (verb == ACTION_USE)) &&
((obj1._id == CABINS) || (obj1._id == CABIN))) {
r = _gm->_rooms[AIRLOCK];
@@ -315,33 +317,27 @@ bool ShipCockpit::interact(Action verb, Object &obj1, Object &obj2) {
if ((verb == ACTION_LOOK) && (obj1._id == MONITOR)) {
_gm->_guiEnabled = false;
- _vm->renderBox(0, 0, 320, 200, kColorBlack);
- _vm->renderText("Geschwindigkeit: ", 50, 50, kColorLightYellow);
- if (_gm->_state.time)
- _vm->renderText("8000 hpm");
- else
- _vm->renderText("0 hpm");
- _vm->renderText("Ziel: Arsano 3", 50, 70, kColorLightYellow);
- _vm->renderText("Entfernung: ", 50, 90, kColorLightYellow);
- _vm->renderText(Common::String::format("%d", _gm->_state.timeStarting / 7200000).c_str());
- _vm->renderText(",");
- c[0] = (_gm->_state.timeStarting / 720000) % 10 + '0';
- _vm->renderText(c);
- c[0] = (_gm->_state.timeStarting / 72000) % 10 + '0';
- _vm->renderText(c);
- _vm->renderText(" Lichtjahre");
- _vm->renderText("Dauer der Reise bei momentaner Geschwindigkeit:", 50, 110, kColorLightYellow);
- _vm->renderText(Common::String::format("%d", _gm->_state.timeStarting / 18000).c_str(), 50, 120, kColorLightYellow);
- _vm->renderText(" Tage");
-
- while (!_gm->_guiEnabled) {
- _vm->updateEvents();
- if (_gm->_key || _gm->_mouseClicked) {
- _gm->_guiEnabled = true;
- }
- g_system->updateScreen();
- g_system->delayMillis(_vm->_delay);
- }
+ _vm->renderBox(0, 0, 320, 200, kColorBlack);
+ _vm->renderText("Geschwindigkeit: ", 50, 50, kColorLightYellow);
+ if (_gm->_state.time)
+ _vm->renderText("8000 hpm");
+ else
+ _vm->renderText("0 hpm");
+ _vm->renderText("Ziel: Arsano 3", 50, 70, kColorLightYellow);
+ _vm->renderText("Entfernung: ", 50, 90, kColorLightYellow);
+ _vm->renderText(Common::String::format("%d", _gm->_state.timeStarting / 7200000).c_str());
+ _vm->renderText(",");
+ c[0] = (_gm->_state.timeStarting / 720000) % 10 + '0';
+ _vm->renderText(c);
+ c[0] = (_gm->_state.timeStarting / 72000) % 10 + '0';
+ _vm->renderText(c);
+ _vm->renderText(" Lichtjahre");
+ _vm->renderText("Dauer der Reise bei momentaner Geschwindigkeit:", 50, 110, kColorLightYellow);
+ _vm->renderText(Common::String::format("%d", _gm->_state.timeStarting / 18000).c_str(), 50, 120, kColorLightYellow);
+ _vm->renderText(" Tage");
+
+ _gm->getInput();
+ _gm->_guiEnabled = true;
} else if ((verb == ACTION_USE) && (obj1._id == INSTRUMENTS))
_vm->renderMessage("Vergiá nicht, du bist nur der|Schiffskoch und hast keine Ahnung,|wie man ein Raumschiff fliegt.");
else
diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp
index 9bfc4745b8..7548f920ac 100644
--- a/engines/supernova/state.cpp
+++ b/engines/supernova/state.cpp
@@ -259,6 +259,8 @@ void GameManager::initGui() {
void GameManager::processInput(Common::KeyState &state) {
+ _key = state;
+
switch (state.keycode) {
case Common::KEYCODE_F1:
// help
@@ -279,12 +281,10 @@ void GameManager::processInput(Common::KeyState &state) {
if (state.flags & Common::KBD_ALT) {
// quit game
_vm->_gameRunning = false;
- } else {
- _key = state.ascii;
}
break;
default:
- _key = state.ascii;
+ break;
}
}
@@ -294,8 +294,8 @@ void GameManager::resetInputState() {
_inputVerb = ACTION_WALK;
_processInput = false;
_mouseClicked = false;
- _key = 0;
_keyPressed = false;
+ _key.reset();
_mouseClickType = Common::EVENT_MOUSEMOVE;
processInput();
@@ -536,11 +536,44 @@ void GameManager::drawInventory() {
_vm->renderBox(272, 181, 7, 19, HGR_INV);
}
-void GameManager::mouseInput() {
- // STUB
+uint16 GameManager::getKeyInput(bool blockForPrintChar) {
+ while (true) {
+ _vm->updateEvents();
+ // TODO: Check for valid ascii
+ if (_keyPressed) {
+ if (blockForPrintChar) {
+ if (Common::isPrint(_key.keycode) ||
+ _key.keycode == Common::KEYCODE_BACKSPACE ||
+ _key.keycode == Common::KEYCODE_DELETE ||
+ _key.keycode == Common::KEYCODE_RETURN ||
+ _key.keycode == Common::KEYCODE_SPACE ||
+ _key.keycode == Common::KEYCODE_ESCAPE) {
+ if (_key.flags & Common::KBD_SHIFT)
+ return toupper(_key.ascii);
+ else
+ return tolower(_key.ascii);
+ }
+ } else {
+ return _key.ascii;
+ }
+ }
+ g_system->updateScreen();
+ g_system->delayMillis(_vm->_delay);
+ }
}
-void GameManager::mouseInput2() {
+Common::EventType GameManager::getMouseInput() {
+ while (true) {
+ _vm->updateEvents();
+ if (_mouseClicked) {
+ return _mouseClickType;
+ }
+ g_system->updateScreen();
+ g_system->delayMillis(_vm->_delay);
+ }
+}
+
+void GameManager::getInput() {
while (true) {
_vm->updateEvents();
// TODO: handle key input (e.g. alt+x, F-keys?)
@@ -552,10 +585,10 @@ void GameManager::mouseInput2() {
}
}
+// TODO: Unify mouseInput3 and mouseWait with getMouseInput
void GameManager::mouseInput3() {
// STUB
}
-
void GameManager::mouseWait(int delay) {
// STUB
}
@@ -629,7 +662,7 @@ void GameManager::showMenu() {
}
void GameManager::drawMapExits() {
- // TODO: Preload _exitList on room entry instead on every call
+// TODO: Preload _exitList on room entry instead on every call
_vm->renderBox(281, 161, 39, 39, HGR_AUSG);
for (int i = 0; i < 25; i++)
@@ -776,7 +809,7 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) {
// those cases seperately
_vm->renderImage(2, 0);
_vm->setColor63(40);
- mouseInput2();
+ getInput();
_vm->renderRoom(*_currentRoom);
roomBrightness();
palette();
@@ -806,7 +839,8 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) {
_vm->renderBox(91, 99, 138, 9, kColorDarkBlue);
do {
edit(t, 91, 100, 5);
- } while ((_key != Common::ASCII_RETURN) && (_key != Common::ASCII_ESCAPE));
+ } while ((_key.keycode != Common::KEYCODE_RETURN) &&
+ (_key.keycode != Common::KEYCODE_ESCAPE));
f = false;
if (t[0] == ':') {
t[0] = 0;
@@ -829,9 +863,9 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) {
minutes = atoi(min);
if ((hours > 23) || (minutes > 59)) f = true;
animationOn();
- } while (f && (_key != Common::ASCII_ESCAPE));
+ } while (f && (_key.keycode != Common::KEYCODE_ESCAPE));
_vm->restoreScreen();
- if (_key != Common::ASCII_ESCAPE) {
+ if (_key.keycode != Common::KEYCODE_ESCAPE) {
_state.timeAlarm = (hours * 60 + minutes) * 1092.3888 + 8;
_state.timeAlarmSystem = _state.timeAlarm + _state.timeStarting;
_state.alarmOn = (_state.timeAlarmSystem > _vm->getDOSTicks());
diff --git a/engines/supernova/state.h b/engines/supernova/state.h
index 2c61e153c6..a9741d77d7 100644
--- a/engines/supernova/state.h
+++ b/engines/supernova/state.h
@@ -103,7 +103,7 @@ public:
void executeRoom();
SupernovaEngine *_vm;
- uint16 _key;
+ Common::KeyState _key;
Common::EventType _mouseClickType;
bool _mouseClicked;
bool _keyPressed;
@@ -141,8 +141,9 @@ public:
void great(uint number);
bool airless();
void shock();
- void mouseInput();
- void mouseInput2();
+ Common::EventType getMouseInput();
+ uint16 getKeyInput(bool blockForAlNum = false);
+ void getInput();
void mouseInput3();
void mouseWait(int delay);
void wait2(int ticks);