aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorKari Salminen2007-07-10 18:08:35 +0000
committerKari Salminen2007-07-10 18:08:35 +0000
commit969df42d016ae1fcc528c4c96ba02f1297712816 (patch)
treec5f64d2dbf9d9612819d9fe7a17ed18a58cb3442 /engines
parent83e038de191888758fdc2e2d741b12f1c28f7e2b (diff)
downloadscummvm-rg350-969df42d016ae1fcc528c4c96ba02f1297712816.tar.gz
scummvm-rg350-969df42d016ae1fcc528c4c96ba02f1297712816.tar.bz2
scummvm-rg350-969df42d016ae1fcc528c4c96ba02f1297712816.zip
Make AGI's button drawing use AgiButtonStyle. Doesn't use Amiga-style yet. It's next.
svn-id: r28014
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp1
-rw-r--r--engines/agi/agi.h2
-rw-r--r--engines/agi/graphics.cpp21
-rw-r--r--engines/agi/graphics.h5
-rw-r--r--engines/agi/predictive.cpp4
-rw-r--r--engines/agi/saveload.cpp2
-rw-r--r--engines/agi/text.cpp2
7 files changed, 29 insertions, 8 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 7abeaf3f05..ccacb3fe01 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -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);
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index e99e8c2b57..c732121e11 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -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];
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index 54f1783d83..c7b62ee11f 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -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;
}
diff --git a/engines/agi/graphics.h b/engines/agi/graphics.h
index b1f9c0e1d7..e9f16a63ef 100644
--- a/engines/agi/graphics.h
+++ b/engines/agi/graphics.h
@@ -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 *);
diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp
index 67ebed5f05..2db4b49396 100644
--- a/engines/agi/predictive.cpp
+++ b/engines/agi/predictive.cpp
@@ -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);
}
}
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 9144dae96c..0f475ab644 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -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;
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 565e94fa26..7ba7aa71fc 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -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();