ZVISION: Implement functions for system messaging.

This commit is contained in:
Marisa-Chan 2014-07-12 19:09:08 +00:00
parent bbaebdf680
commit b9103b8d19
4 changed files with 85 additions and 0 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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();