Skip to content

Commit

Permalink
WAGE: Dialog loop
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Feb 14, 2016
1 parent 8760362 commit 750e442
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
24 changes: 24 additions & 0 deletions engines/wage/dialog.cpp
Expand Up @@ -46,6 +46,7 @@
*/

#include "common/system.h"
#include "common/events.h"

#include "wage/wage.h"
#include "wage/design.h"
Expand Down Expand Up @@ -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
10 changes: 10 additions & 0 deletions engines/wage/dialog.h
Expand Up @@ -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<DialogButton *> DialogButtonArray;
Expand All @@ -62,6 +70,8 @@ class Dialog {
Dialog(Gui *gui, const char *text, DialogButtonArray *buttons);
~Dialog();

void run();

private:
Gui *_gui;
Graphics::Surface _tempSurface;
Expand Down
16 changes: 15 additions & 1 deletion engines/wage/wage.cpp
Expand Up @@ -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"

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -278,6 +288,10 @@ void WageEngine::performInitialSetup() {
}
}

void WageEngine::doClose() {
warning("STUB: doClose()");
}

Scene *WageEngine::getSceneByName(String &location) {
Scene *scene;
if (location.equals("random@")) {
Expand Down
4 changes: 4 additions & 0 deletions engines/wage/wage.h
Expand Up @@ -63,6 +63,7 @@ namespace Wage {
class Console;
class Chr;
class Designed;
class Dialog;
class Gui;
class Obj;
class Scene;
Expand Down Expand Up @@ -107,6 +108,7 @@ const char *getGenderSpecificPronoun(int gender, bool capitalize);
typedef Common::Array<byte *> Patterns;

class WageEngine : public Engine {
friend class Dialog;
public:
WageEngine(OSystem *syst, const ADGameDescription *gameDesc);
~WageEngine();
Expand Down Expand Up @@ -135,6 +137,8 @@ class WageEngine : public Engine {
void performOffer(Chr *attacker, Chr *victim);
void performTake(Chr *npc, Obj *obj);

void doClose();

public:
Common::RandomSource *_rnd;

Expand Down

0 comments on commit 750e442

Please sign in to comment.