Skip to content

Commit

Permalink
WAGE: Simplified border drawing API
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Dec 31, 2015
1 parent f256636 commit 849220b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
27 changes: 22 additions & 5 deletions engines/wage/gui.cpp
Expand Up @@ -115,7 +115,7 @@ void Gui::draw() {
if (_scene != NULL && _sceneDirty) {
_scene->paint(&_screen, 0, kMenuHeight);
paintBorder(&_screen, 0, kMenuHeight, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
false, false, false, false);
kWindowScene);

_sceneDirty = false;
}
Expand All @@ -127,7 +127,7 @@ void Gui::draw() {

renderConsole(&_screen, sceneW + kBorderWidth, kMenuHeight + kBorderWidth, consoleW, consoleH);
paintBorder(&_screen, sceneW, kMenuHeight, _screen.w - sceneW, _scene->_design->getBounds()->height(),
true, true, true, false);
kWindowConsole);

// Blit to screen
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
Expand Down Expand Up @@ -157,8 +157,24 @@ const int arrowPixels[ARROW_H][ARROW_W] = {
{1,1,1,1,1,1,1,1,1,1,1,1}};


void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
bool active, bool scrollable, bool closeable, bool closeBoxPressed) {
void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType) {
bool active, scrollable, closeable, closeBoxPressed;

switch (windowType) {
case kWindowScene:
active = false;
scrollable = false;
closeable = false;
closeBoxPressed = false;
break;
case kWindowConsole:
active = true;
scrollable = true;
closeable = true;
closeBoxPressed = false;
break;
}

const int size = kBorderWidth;
drawBox(g, x, y, size, size);
drawBox(g, x+width-size-1, y, size, size);
Expand Down Expand Up @@ -242,7 +258,8 @@ void Gui::renderConsole(Graphics::Surface *g, int x, int y, int width, int heigh
int surfW = width + kConWOverlap * 2;
int surfH = height + kConHOverlap * 2;

Common::Rect boundsR(kConWOverlap - kConOverscan, kConHOverlap - kConOverscan, width + kConWOverlap + kConOverscan, height + kConHOverlap + kConOverscan);
Common::Rect boundsR(kConWOverlap - kConOverscan, kConHOverlap - kConOverscan,
width + kConWOverlap + kConOverscan, height + kConHOverlap + kConOverscan);
Common::Rect fullR(0, 0, surfW, surfH);

if (_console.w != surfW || _console.h != surfH) {
Expand Down
9 changes: 6 additions & 3 deletions engines/wage/gui.h
Expand Up @@ -54,6 +54,11 @@

namespace Wage {

enum WindowType {
kWindowScene,
kWindowConsole
};

class Gui {
public:
Gui();
Expand All @@ -64,9 +69,7 @@ class Gui {
void appendText(Common::String &str);

private:
void paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
bool active, bool scrollable, bool closeable, bool closeBoxPressed);

void paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType);
void renderConsole(Graphics::Surface *g, int x, int y, int width, int height);
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
Expand Down

0 comments on commit 849220b

Please sign in to comment.