diff options
author | Marisa-Chan | 2014-07-12 19:09:08 +0000 |
---|---|---|
committer | Marisa-Chan | 2014-07-12 19:09:08 +0000 |
commit | b9103b8d19a5da396d217e8d9bcc5c1502b89837 (patch) | |
tree | 016f1a0c90e7809445b6889f483deb495ced7209 | |
parent | bbaebdf680179dca103b0ed635e791aa602d610d (diff) | |
download | scummvm-rg350-b9103b8d19a5da396d217e8d9bcc5c1502b89837.tar.gz scummvm-rg350-b9103b8d19a5da396d217e8d9bcc5c1502b89837.tar.bz2 scummvm-rg350-b9103b8d19a5da396d217e8d9bcc5c1502b89837.zip |
ZVISION: Implement functions for system messaging.
-rw-r--r-- | engines/zvision/graphics/render_manager.cpp | 15 | ||||
-rw-r--r-- | engines/zvision/graphics/render_manager.h | 1 | ||||
-rw-r--r-- | engines/zvision/zvision.cpp | 65 | ||||
-rw-r--r-- | engines/zvision/zvision.h | 4 |
4 files changed, 85 insertions, 0 deletions
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index f3b01b7e30..c89444df13 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -729,6 +729,21 @@ uint16 RenderManager::createSubArea(const Common::Rect &area) { return _subid; } +uint16 RenderManager::createSubArea() { + _subid++; + + oneSub sub; + sub.redraw = false; + sub.timer = -1; + sub.todelete = false; + sub._r = Common::Rect(_subWndRect.left, _subWndRect.top, _subWndRect.right, _subWndRect.bottom); + sub._r.translate(-_workingWindow.left, -_workingWindow.top); + + _subsList[_subid] = sub; + + return _subid; +} + void RenderManager::deleteSubArea(uint16 id) { if (_subsList.contains(id)) _subsList[id].todelete = true; diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index ca2e715e8a..b4c6c76a6e 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -233,6 +233,7 @@ public: void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey); uint16 createSubArea(const Common::Rect &area); + uint16 createSubArea(); void deleteSubArea(uint16 id); void deleteSubArea(uint16 id, int16 delay); void updateSubArea(uint16 id, const Common::String &txt); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 0eb14257f2..24e15e0c86 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -212,6 +212,71 @@ Common::Error ZVision::run() { return Common::kNoError; } +bool ZVision::askQuestion(const Common::String &str) { + uint16 msgid = _renderManager->createSubArea(); + _renderManager->updateSubArea(msgid, str); + _renderManager->processSubs(0); + _renderManager->renderBackbufferToScreen(); + _clock.stop(); + + int result = 0; + + while (result == 0) { + Common::Event evnt; + while (_eventMan->pollEvent(evnt)) { + if (evnt.type == Common::EVENT_KEYDOWN) { + switch (evnt.kbd.keycode) { + case Common::KEYCODE_y: + result = 2; + break; + case Common::KEYCODE_n: + result = 1; + break; + default: + break; + } + } + } + _system->updateScreen(); + _system->delayMillis(66); + } + _renderManager->deleteSubArea(msgid); + _clock.start(); + return result == 2; +} + +void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) { + uint16 msgid = _renderManager->createSubArea(); + _renderManager->updateSubArea(msgid, str); + _renderManager->processSubs(0); + _renderManager->renderBackbufferToScreen(); + _clock.stop(); + + uint32 stop_time = _system->getMillis() + milsecs; + while (_system->getMillis() < stop_time) { + Common::Event evnt; + while (_eventMan->pollEvent(evnt)) { + if (evnt.type == Common::EVENT_KEYDOWN && + (evnt.kbd.keycode == Common::KEYCODE_SPACE || + evnt.kbd.keycode == Common::KEYCODE_RETURN || + evnt.kbd.keycode == Common::KEYCODE_ESCAPE)) + break; + } + _system->updateScreen(); + _system->delayMillis(66); + } + _renderManager->deleteSubArea(msgid); + _clock.start(); +} + +void ZVision::timedMessage(const Common::String &str, uint16 milsecs) { + uint16 msgid = _renderManager->createSubArea(); + _renderManager->updateSubArea(msgid, str); + _renderManager->processSubs(0); + _renderManager->renderBackbufferToScreen(); + _renderManager->deleteSubArea(msgid, milsecs); +} + void ZVision::pauseEngineIntern(bool pause) { _mixer->pauseAll(pause); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 57e7339da6..e5d32bf678 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -167,6 +167,10 @@ public: Common::String generateSaveFileName(uint slot); Common::String generateAutoSaveFileName(); + bool askQuestion(const Common::String &str); + void delayedMessage(const Common::String &str, uint16 milsecs); + void timedMessage(const Common::String &str, uint16 milsecs); + void setRenderDelay(uint); bool canRender(); |