[Scummvm-cvs-logs] SF.net SVN: scummvm: [28014] scummvm/trunk/engines/agi

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Tue Jul 10 20:08:35 CEST 2007


Revision: 28014
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28014&view=rev
Author:   buddha_
Date:     2007-07-10 11:08:35 -0700 (Tue, 10 Jul 2007)

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

Modified Paths:
--------------
    scummvm/trunk/engines/agi/agi.cpp
    scummvm/trunk/engines/agi/agi.h
    scummvm/trunk/engines/agi/graphics.cpp
    scummvm/trunk/engines/agi/graphics.h
    scummvm/trunk/engines/agi/predictive.cpp
    scummvm/trunk/engines/agi/saveload.cpp
    scummvm/trunk/engines/agi/text.cpp

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2007-07-10 17:41:40 UTC (rev 28013)
+++ scummvm/trunk/engines/agi/agi.cpp	2007-07-10 18:08:35 UTC (rev 28014)
@@ -697,6 +697,7 @@
 	}
 
 	_buttonStyle = AgiButtonStyle(_renderMode);
+	_defaultButtonStyle = AgiButtonStyle();
 	_console = new Console(this);
 	_gfx = new GfxMgr(this);
 	_sound = new SoundMgr(this, _mixer);

Modified: scummvm/trunk/engines/agi/agi.h
===================================================================
--- scummvm/trunk/engines/agi/agi.h	2007-07-10 17:41:40 UTC (rev 28013)
+++ scummvm/trunk/engines/agi/agi.h	2007-07-10 18:08:35 UTC (rev 28014)
@@ -81,6 +81,7 @@
 #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 @@
 
 	Menu* _menu;
 	AgiButtonStyle _buttonStyle;
+	AgiButtonStyle _defaultButtonStyle;
 
 	char _lastSentence[40];
 

Modified: scummvm/trunk/engines/agi/graphics.cpp
===================================================================
--- scummvm/trunk/engines/agi/graphics.cpp	2007-07-10 17:41:40 UTC (rev 28013)
+++ scummvm/trunk/engines/agi/graphics.cpp	2007-07-10 18:08:35 UTC (rev 28014)
@@ -554,13 +554,24 @@
 }
 
 /**
- * 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 @@
 	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;
 	}
 

Modified: scummvm/trunk/engines/agi/graphics.h
===================================================================
--- scummvm/trunk/engines/agi/graphics.h	2007-07-10 17:41:40 UTC (rev 28013)
+++ scummvm/trunk/engines/agi/graphics.h	2007-07-10 18:08:35 UTC (rev 28014)
@@ -50,6 +50,9 @@
 	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 @@
 	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 *);

Modified: scummvm/trunk/engines/agi/predictive.cpp
===================================================================
--- scummvm/trunk/engines/agi/predictive.cpp	2007-07-10 17:41:40 UTC (rev 28013)
+++ scummvm/trunk/engines/agi/predictive.cpp	2007-07-10 18:08:35 UTC (rev 28014)
@@ -200,9 +200,9 @@
 					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);
 				}
 			}
 

Modified: scummvm/trunk/engines/agi/saveload.cpp
===================================================================
--- scummvm/trunk/engines/agi/saveload.cpp	2007-07-10 17:41:40 UTC (rev 28013)
+++ scummvm/trunk/engines/agi/saveload.cpp	2007-07-10 18:08:35 UTC (rev 28014)
@@ -516,7 +516,7 @@
 	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;

Modified: scummvm/trunk/engines/agi/text.cpp
===================================================================
--- scummvm/trunk/engines/agi/text.cpp	2007-07-10 17:41:40 UTC (rev 28013)
+++ scummvm/trunk/engines/agi/text.cpp	2007-07-10 18:08:35 UTC (rev 28014)
@@ -364,7 +364,7 @@
 	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();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list