Make AGI's button drawing use AgiButtonStyle. Doesn't use Amiga-style yet. It's next.

svn-id: r28014
This commit is contained in:
Kari Salminen 2007-07-10 18:08:35 +00:00
parent 83e038de19
commit 969df42d01
7 changed files with 29 additions and 8 deletions

View file

@ -697,6 +697,7 @@ void AgiEngine::initialize() {
}
_buttonStyle = AgiButtonStyle(_renderMode);
_defaultButtonStyle = AgiButtonStyle();
_console = new Console(this);
_gfx = new GfxMgr(this);
_sound = new SoundMgr(this, _mixer);

View file

@ -81,6 +81,7 @@ typedef signed int Err;
#define MSG_BOX_COLOUR 0x0f /* White */
#define MSG_BOX_TEXT 0x00 /* Black */
#define MSG_BOX_LINE 0x04 /* Red */
#define BUTTON_BORDER 0x00 /* Black */
#define STATUS_FG 0x00 /* Black */
#define STATUS_BG 0x0f /* White */
@ -708,6 +709,7 @@ public:
Menu* _menu;
AgiButtonStyle _buttonStyle;
AgiButtonStyle _defaultButtonStyle;
char _lastSentence[40];

View file

@ -554,13 +554,24 @@ void GfxMgr::printCharacter(int x, int y, char c, int fg, int bg) {
}
/**
* Draw button
* Draw a default style button.
* Swaps background and foreground color if button is in focus or being pressed.
* @param x x coordinate of the button
* @param y y coordinate of the button
* @param a set if the button has focus
* @param p set if the button is pressed
* @param fgcolor foreground color of the button when it is neither in focus nor being pressed
* @param bgcolor background color of the button when it is neither in focus nor being pressed
*/
void GfxMgr::drawButton(int x, int y, const char *s, int a, int p, int fgcolor, int bgcolor) {
void GfxMgr::drawDefaultStyleButton(int x, int y, const char *s, int a, int p, int fgcolor, int bgcolor) {
int textOffset = _vm->_defaultButtonStyle.getTextOffset(a > 0, p > 0);
AgiTextColor color = _vm->_defaultButtonStyle.getColor (a > 0, p > 0, fgcolor, bgcolor);
bool border = _vm->_defaultButtonStyle.getBorder (a > 0, p > 0);
rawDrawButton(x, y, s, color.fg, color.bg, border, textOffset);
}
void GfxMgr::rawDrawButton(int x, int y, const char *s, int fgcolor, int bgcolor, bool border, int textOffset) {
int len = strlen(s);
int x1, y1, x2, y2;
@ -569,8 +580,12 @@ void GfxMgr::drawButton(int x, int y, const char *s, int a, int p, int fgcolor,
x2 = x + CHAR_COLS * len + 2;
y2 = y + CHAR_LINES + 2;
// Draw a filled rectangle that's larger than the button. Used for drawing
// a border around the button as the button itself is drawn after this.
drawRectangle(x1, y1, x2, y2, border ? BUTTON_BORDER : MSG_BOX_COLOUR);
while (*s) {
putTextCharacter(0, x + (!!p), y + (!!p), *s++, a ? bgcolor : fgcolor, a ? fgcolor : bgcolor);
putTextCharacter(0, x + textOffset, y + textOffset, *s++, fgcolor, bgcolor);
x += CHAR_COLS;
}

View file

@ -50,6 +50,9 @@ private:
uint8 _agipalPalette[16 * 3];
int _agipalFileNum;
private:
void rawDrawButton(int x, int y, const char *s, int fgcolor, int bgcolor, bool border, int textOffset);
public:
GfxMgr(AgiEngine *vm);
@ -74,7 +77,7 @@ public:
void clearScreen(int);
void clearConsoleScreen(int);
void drawBox(int, int, int, int, int, int, int);
void drawButton(int, int, const char *, int, int, int fgcolor = 0, int bgcolor = 0);
void drawDefaultStyleButton(int, int, const char *, int, int, int fgcolor = 0, int bgcolor = 0);
int testButton(int, int, const char *);
void drawRectangle(int, int, int, int, int);
void saveBlock(int, int, int, int, uint8 *);

View file

@ -200,9 +200,9 @@ bool AgiEngine::predictiveDialog(void) {
color2 = 7;
}
if (i == 14) {
_gfx->drawButton(bx[i], by[i], modes[mode], i == active, 0, color1, color2);
_gfx->drawDefaultStyleButton(bx[i], by[i], modes[mode], i == active, 0, color1, color2);
} else {
_gfx->drawButton(bx[i], by[i], buttons[i], i == active, 0, color1, color2);
_gfx->drawDefaultStyleButton(bx[i], by[i], buttons[i], i == active, 0, color1, color2);
}
}

View file

@ -516,7 +516,7 @@ int AgiEngine::selectSlot() {
buttonY = (vm + 17) * CHAR_LINES;
for (i = 0; i < 2; i++)
_gfx->drawButton(buttonX[i], buttonY, buttonText[i], 0, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR);
_gfx->drawDefaultStyleButton(buttonX[i], buttonY, buttonText[i], 0, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR);
AllowSyntheticEvents on(this);
int oldFirstSlot = _firstSlot + 1;

View file

@ -364,7 +364,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
debugC(4, kDebugLevelText, "waiting...");
for (;;) {
for (i = 0; b[i]; i++)
_gfx->drawButton(bx[i], by[i], b[i], i == active, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR);
_gfx->drawDefaultStyleButton(bx[i], by[i], b[i], i == active, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR);
_gfx->pollTimer(); /* msdos driver -> does nothing */
key = doPollKeyboard();