Skip to content

Commit

Permalink
WAGE: Redraw Gui parts on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Jan 2, 2016
1 parent 31e4f81 commit 8d6e811
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
29 changes: 19 additions & 10 deletions engines/wage/gui.cpp
Expand Up @@ -121,7 +121,9 @@ Gui::Gui(WageEngine *engine) {
_engine = engine;
_scene = NULL;
_sceneDirty = true;
_consoleDirty = true;
_bordersDirty = true;
_menuDirty = true;
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());

Patterns p;
Expand Down Expand Up @@ -153,6 +155,8 @@ void Gui::clearOutput() {
}

void Gui::appendText(String &str) {
_consoleDirty = true;

if (!str.contains('\n')) {
_out.push_back(str);
return;
Expand All @@ -178,36 +182,41 @@ void Gui::appendText(String &str) {
void Gui::draw() {
if (_scene != _engine->_world->_player->_currentScene || _sceneDirty) {
_scene = _engine->_world->_player->_currentScene;
_sceneDirty = true;

_scene->paint(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding);

_sceneArea.left = 0 + kComponentsPadding + kBorderWidth;
_sceneArea.top = kMenuHeight + kComponentsPadding + kBorderWidth;
_sceneArea.setWidth(_scene->_design->getBounds()->width() - 2 * kBorderWidth);
_sceneArea.setHeight(_scene->_design->getBounds()->height() - 2 * kBorderWidth);

_sceneDirty = false;
}

if (_scene && (_bordersDirty || _sceneDirty))
paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
kWindowScene);


// Render console
int sceneW = _scene->_design->getBounds()->width();
int consoleW = _screen.w - sceneW - 2 * kComponentsPadding;
int consoleH = _scene->_design->getBounds()->height();
int consoleX = sceneW + kComponentsPadding;
int consoleY = kMenuHeight + kComponentsPadding;

renderConsole(&_screen, consoleX + kBorderWidth , consoleY + kBorderWidth, consoleW - 2 * kBorderWidth, consoleH - 2 * kBorderWidth);
if (_consoleDirty)
renderConsole(&_screen, consoleX + kBorderWidth , consoleY + kBorderWidth, consoleW - 2 * kBorderWidth, consoleH - 2 * kBorderWidth);

if (_bordersDirty) {
if (_scene)
paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
kWindowScene);
if (_bordersDirty || _consoleDirty)
paintBorder(&_screen, consoleX, consoleY, consoleW, consoleH, kWindowConsole);

_bordersDirty = false;
}
if (_menuDirty)
renderMenu();

renderMenu();
_sceneDirty = false;
_consoleDirty = false;
_bordersDirty = false;
_menuDirty = false;

// Blit to screen
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
Expand Down
2 changes: 2 additions & 0 deletions engines/wage/gui.h
Expand Up @@ -84,7 +84,9 @@ class Gui {
Graphics::Surface _console;
Scene *_scene;
bool _sceneDirty;
bool _consoleDirty;
bool _bordersDirty;
bool _menuDirty;

Common::StringArray _out;
Common::StringArray _lines;
Expand Down

0 comments on commit 8d6e811

Please sign in to comment.