From 750e44219f246c404b44170001287b1ffb64ec89 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 19 Jan 2016 18:41:35 +0100 Subject: WAGE: Dialog loop --- engines/wage/dialog.cpp | 24 ++++++++++++++++++++++++ engines/wage/dialog.h | 10 ++++++++++ engines/wage/wage.cpp | 16 +++++++++++++++- engines/wage/wage.h | 4 ++++ 4 files changed, 53 insertions(+), 1 deletion(-) (limited to 'engines/wage') diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp index eb29f80cff..abd4d1b1c4 100644 --- a/engines/wage/dialog.cpp +++ b/engines/wage/dialog.cpp @@ -46,6 +46,7 @@ */ #include "common/system.h" +#include "common/events.h" #include "wage/wage.h" #include "wage/design.h" @@ -132,4 +133,27 @@ void Dialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) { 1, kColorBlack, _gui->_patterns, kPatternSolid); } +void Dialog::run() { + bool shouldQuit = false; + + paint(); + + while (!shouldQuit) { + Common::Event event; + + while (_gui->_engine->_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_QUIT: + shouldQuit = true; + break; + default: + break; + } + } + + g_system->updateScreen(); + g_system->delayMillis(50); + } +} + } // End of namespace Wage diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h index 747d9dea05..7983417b47 100644 --- a/engines/wage/dialog.h +++ b/engines/wage/dialog.h @@ -53,6 +53,14 @@ namespace Wage { struct DialogButton { Common::String text; Common::Rect bounds; + + DialogButton(const char *t, int x1, int y1, int x2, int y2) { + text = t; + bounds.left = x1; + bounds.top = y1; + bounds.right = x2; + bounds.bottom = y2; + } }; typedef Common::Array DialogButtonArray; @@ -62,6 +70,8 @@ public: Dialog(Gui *gui, const char *text, DialogButtonArray *buttons); ~Dialog(); + void run(); + private: Gui *_gui; Graphics::Surface _tempSurface; diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp index db7e364fab..b8d0977853 100644 --- a/engines/wage/wage.cpp +++ b/engines/wage/wage.cpp @@ -54,6 +54,7 @@ #include "wage/wage.h" #include "wage/entities.h" #include "wage/gui.h" +#include "wage/dialog.h" #include "wage/script.h" #include "wage/world.h" @@ -139,6 +140,7 @@ void WageEngine::processEvents() { while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_QUIT: + gameOver(); _shouldQuit = true; break; case Common::EVENT_MOUSEMOVE: @@ -217,7 +219,15 @@ void WageEngine::appendText(char *str) { } void WageEngine::gameOver() { - warning("STUB: WageEngine::gameOver()"); + DialogButtonArray buttons; + + buttons.push_back(new DialogButton("OK", 112, 67, 68, 28)); + + Dialog gameOver(_gui, _world->_gameOverMessage->c_str(), &buttons); + + gameOver.run(); + + doClose(); } void WageEngine::performInitialSetup() { @@ -278,6 +288,10 @@ void WageEngine::performInitialSetup() { } } +void WageEngine::doClose() { + warning("STUB: doClose()"); +} + Scene *WageEngine::getSceneByName(String &location) { Scene *scene; if (location.equals("random@")) { diff --git a/engines/wage/wage.h b/engines/wage/wage.h index 245fc9ba18..0d540d3c0b 100644 --- a/engines/wage/wage.h +++ b/engines/wage/wage.h @@ -63,6 +63,7 @@ namespace Wage { class Console; class Chr; class Designed; +class Dialog; class Gui; class Obj; class Scene; @@ -107,6 +108,7 @@ const char *getGenderSpecificPronoun(int gender, bool capitalize); typedef Common::Array Patterns; class WageEngine : public Engine { + friend class Dialog; public: WageEngine(OSystem *syst, const ADGameDescription *gameDesc); ~WageEngine(); @@ -135,6 +137,8 @@ private: void performOffer(Chr *attacker, Chr *victim); void performTake(Chr *npc, Obj *obj); + void doClose(); + public: Common::RandomSource *_rnd; -- cgit v1.2.3