Skip to content

Commit

Permalink
Merge pull request #277 from lordhoto/cine-amiga-menu
Browse files Browse the repository at this point in the history
Improvements for Cine's selection menu.
  • Loading branch information
David Turner committed Sep 7, 2012
2 parents 74d5214 + 855a0d3 commit 8f9b811
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
60 changes: 52 additions & 8 deletions engines/cine/gfx.cpp
Expand Up @@ -471,6 +471,41 @@ int FWRenderer::drawChar(char character, int x, int y) {
return x;
}

/**
* Clears the character glyph to black
* This function is called "undrawChar", because the original only applies
* this drawing after the original glyph has been drawn.
* Possible TODO: Find a better name.
* @param character Character to undraw
* @param x Character coordinate
* @param y Character coordinate
*/
int FWRenderer::undrawChar(char character, int x, int y) {
int width, idx;

if (character == ' ') {
x += 5;
} else if ((width = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterWidth)) {
idx = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterIdx;
const byte *sprite = g_cine->_textHandler.textTable[idx][FONT_DATA];
for (uint i = 0; i < FONT_HEIGHT; ++i) {
byte *dst = _backBuffer + (y + i) * 320 + x;
for (uint j = 0; j < FONT_WIDTH; ++j, ++dst) {
// The original does this based on whether bit 1 of the pixel
// is set. Since that's the only bit ever set in (FW) this
// check should be fine.
// TODO: Check how Operation Stealth Amiga works
if (*sprite++) {
*dst = 0;
}
}
}
x += width + 1;
}

return x;
}

int FWRenderer::getStringWidth(const char *str) {
const char *p = str;
int width = 0;
Expand Down Expand Up @@ -969,20 +1004,29 @@ void SelectionMenu::drawMenu(FWRenderer &r, bool top) {
charX = x + 4;

if (i == _selection) {
int color;

if (isAmiga) {
// The original Amiga version is using a different highlight color here,
// but with our current code it is not possible to change the text color,
// thus we can not use the Amiga's color, since otherwise the text
// wouldn't be visible anymore.
r.drawPlainBox(charX, lineY, _width - 8, FONT_HEIGHT, top ? r._messageBg/*2*/ : 18);
if (top) {
color = 2;
} else {
color = 18;
}
} else {
r.drawPlainBox(charX, lineY, _width - 8, 9, 0);
color = 0;
}

r.drawPlainBox(x + 2, lineY - 1, _width - 3, 9, color);
}

const int size = _elements[i].size();
for (int j = 0; j < size; ++j)
charX = r.drawChar(_elements[i][j], charX, lineY);
for (int j = 0; j < size; ++j) {
if (isAmiga && i == _selection) {
charX = r.undrawChar(_elements[i][j], charX, lineY);
} else {
charX = r.drawChar(_elements[i][j], charX, lineY);
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions engines/cine/gfx.h
Expand Up @@ -152,6 +152,7 @@ class FWRenderer : public Common::NonCopyable {
void drawBorder(int x, int y, int width, int height, byte color);
void drawDoubleBorder(int x, int y, int width, int height, byte color);
virtual int drawChar(char character, int x, int y);
virtual int undrawChar(char character, int x, int y);
void drawLine(int x, int y, int width, int height, byte color);
void remaskSprite(byte *mask, Common::List<overlay>::iterator it);
virtual void drawBackground();
Expand Down

0 comments on commit 8f9b811

Please sign in to comment.