Skip to content

Commit

Permalink
WAGE: Moved global patterns to Gui class
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Jan 13, 2016
1 parent 3646555 commit 4c8b9bb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
12 changes: 8 additions & 4 deletions engines/wage/gui.cpp
Expand Up @@ -67,7 +67,9 @@ static const byte palette[] = {
0x00, 0xff, 0x00 // Green
};

static byte checkersPattern[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static byte fillPatternStripes[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa };
static byte fillPatternCheckers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };

static const byte macCursorArrow[] = {
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
Expand Down Expand Up @@ -158,6 +160,10 @@ Gui::Gui(WageEngine *engine) {
_cursorIsArrow = true;
CursorMan.showMouse(true);

_patterns.push_back(fillPattern);
_patterns.push_back(fillPatternStripes);
_patterns.push_back(fillPatternCheckers);

loadFonts();

g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 200000, this, "wageCursor");
Expand Down Expand Up @@ -240,10 +246,8 @@ void Gui::draw() {
_scene = _engine->_world->_player->_currentScene;

// Draw desktop
Patterns p;
p.push_back(checkersPattern);
Common::Rect r(0, 0, _screen.w - 1, _screen.h - 1);
Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, p, 1);
Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, _patterns, kPatternCheckers);
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);

_sceneDirty = true;
Expand Down
8 changes: 8 additions & 0 deletions engines/wage/gui.h
Expand Up @@ -77,6 +77,12 @@ enum {
kCursorHeight = 12
};

enum {
kPatternSolid = 1,
kPatternStripes = 2,
kPatternCheckers = 3
};

class Gui {
public:
Gui(WageEngine *engine);
Expand Down Expand Up @@ -112,6 +118,8 @@ class Gui {
bool _builtInFonts;
WageEngine *_engine;

Patterns _patterns;

private:
Graphics::Surface _console;
Menu *_menu;
Expand Down
36 changes: 11 additions & 25 deletions engines/wage/menu.cpp
Expand Up @@ -78,16 +78,6 @@ struct MenuItem {
MenuItem(const char *n) : name(n) {}
};

static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static byte fillPatternStripes[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa };
static byte fillPatternCheckers[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };

enum {
kPatternSolid = 1,
kPatternStripes = 2,
kPatternCheckers = 3
};

enum {
kMenuActionAbout,
kMenuActionNew,
Expand Down Expand Up @@ -131,10 +121,6 @@ struct MenuData {
};

Menu::Menu(Gui *gui) : _gui(gui) {
_patterns.push_back(fillPattern);
_patterns.push_back(fillPatternStripes);
_patterns.push_back(fillPatternCheckers);

MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
Expand Down Expand Up @@ -254,18 +240,18 @@ void Menu::calcMenuBounds(MenuItem *menu) {
void Menu::render() {
Common::Rect r(_bbox);

Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _patterns, kPatternSolid);
Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid);
r.top = 7;
Design::drawFilledRect(&_gui->_screen, r, kColorWhite, _patterns, kPatternSolid);
Design::drawFilledRect(&_gui->_screen, r, kColorWhite, _gui->_patterns, kPatternSolid);
r.top = kMenuHeight - 1;
Design::drawFilledRect(&_gui->_screen, r, kColorBlack, _patterns, kPatternSolid);
Design::drawFilledRect(&_gui->_screen, r, kColorBlack, _gui->_patterns, kPatternSolid);

for (int i = 0; i < _items.size(); i++) {
int color = kColorBlack;
MenuItem *it = _items[i];

if (_activeItem == i) {
Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, _patterns, kPatternSolid);
Design::drawFilledRect(&_gui->_screen, it->bbox, kColorBlack, _gui->_patterns, kPatternSolid);
color = kColorWhite;

if (it->subitems.size())
Expand All @@ -284,10 +270,10 @@ void Menu::renderSubmenu(MenuItem *menu) {
if (r->width() == 0 || r->height() == 0)
return;

Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, kPatternSolid);
Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, kPatternSolid);
Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _patterns, kPatternSolid);
Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _patterns, kPatternSolid);
Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _gui->_patterns, kPatternSolid);
Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _gui->_patterns, kPatternSolid);
Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);
Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);

int x = r->left + kMenuDropdownPadding;
int y = r->top + 1;
Expand All @@ -303,7 +289,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
color = kColorWhite;
Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());

Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _patterns, kPatternSolid);
Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
}
if (text.size()) {
if (menu->subitems[i]->enabled) {
Expand All @@ -317,7 +303,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
for (int ii = 0; ii < _tempSurface.h; ii++) {
const byte *src = (const byte *)_tempSurface.getBasePtr(0, ii);
byte *dst = (byte *)_gui->_screen.getBasePtr(x, y+ii);
byte pat = _patterns[kPatternCheckers - 1][(y + ii) % 8];
byte pat = _gui->_patterns[kPatternCheckers - 1][(y + ii) % 8];
for (int j = 0; j < r->width(); j++) {
if (*src != kColorGreen && (pat & (1 << (7 - (x + j) % 8))))
*dst = *src;
Expand All @@ -327,7 +313,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
}
}
} else { // Delimiter
Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _patterns, kPatternStripes);
Design::drawHLine(&_gui->_screen, r->left, r->right, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes);
}

y += kMenuDropdownItemHeight;
Expand Down
1 change: 0 additions & 1 deletion engines/wage/menu.h
Expand Up @@ -68,7 +68,6 @@ class Menu {

private:
Gui *_gui;
Patterns _patterns;
Graphics::Surface _screenCopy;
Graphics::Surface _tempSurface;

Expand Down

0 comments on commit 4c8b9bb

Please sign in to comment.