[Scummvm-cvs-logs] CVS: scummvm gfx.cpp,1.86,1.87 gui.cpp,1.41,1.42 gui.h,1.19,1.20 guimaps.h,1.1,1.2 scummvm.cpp,1.143,1.144

Max Horn fingolfin at users.sourceforge.net
Tue May 7 17:28:02 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv15532

Modified Files:
	gfx.cpp gui.cpp gui.h guimaps.h scummvm.cpp 
Log Message:
made most stuff in gui class protected, as it should be; moved internal definitions from gui.h to gui.cpp; added up/down arrows to save dialog (ugly, but better than nothing IMO

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gfx.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- gfx.cpp	7 May 2002 18:44:34 -0000	1.86
+++ gfx.cpp	8 May 2002 00:27:09 -0000	1.87
@@ -153,7 +153,7 @@
 	}
 
 	/* Handle shaking */
-	if (_shakeEnabled &&  !_gui->_active) {
+	if (_shakeEnabled &&  !_gui->isActive()) {
 		_shakeFrame = (_shakeFrame + 1) & (NUM_SHAKE_POSITIONS - 1);
 		_system->set_shake_pos(shake_positions[_shakeFrame]);
 	}

Index: gui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- gui.cpp	5 May 2002 20:04:24 -0000	1.41
+++ gui.cpp	8 May 2002 00:27:09 -0000	1.42
@@ -43,6 +43,39 @@
 #endif
 
 enum {
+	GUI_NONE = 0,
+	GUI_RESTEXT = 1,
+	GUI_IMAGE = 2,
+	GUI_STAT = 3,
+	GUI_CUSTOMTEXT = 4,
+	GUI_VARTEXT = 5,
+	GUI_ACTIONTEXT = 6,
+	GUI_KEYTEXT = 7,
+	GUI_SCROLLTEXT = 8,
+	GUI_NEXTTEXT = 9,
+	GUI_UPDOWNARROW = 10
+};
+
+enum {
+	GWF_BORDER = 1,
+	GWF_CLEARBG = 2,
+	GWF_PARENT = 4,
+	GWF_DELAY = 8,
+	GWF_DEFAULT = GWF_BORDER|GWF_CLEARBG,
+	GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY
+};
+
+struct GuiWidget {
+	byte _type;
+	byte _page;
+	byte _flags;
+	int16 _x,_y;
+	uint16 _w,_h;
+	uint16 _id;
+	byte _string_number;
+};
+
+enum {
 	SAVELOAD_DIALOG,
 	PAUSE_DIALOG,
 	SOUND_DIALOG,
@@ -53,6 +86,33 @@
 };
 
 
+#define IMG_SIZE	8
+
+// Triangles pointing up-/downwards, used for save/load dialog
+static uint32 up_arrow[IMG_SIZE] = {
+	0x00011000,
+	0x00011000,
+	0x00100100,
+	0x00100100,
+	0x01000010,
+	0x01000010,
+	0x10000001,
+	0x10000001,
+};
+
+static uint32 down_arrow[IMG_SIZE] = {
+	0x10000001,
+	0x10000001,
+	0x01000010,
+	0x01000010,
+	0x00100100,
+	0x00100100,
+	0x00011000,
+	0x00011000,
+};
+
+
+
 void Gui::draw(int start, int end)
 {
 	int i;
@@ -111,6 +171,10 @@
 	tmp = &guifont[0];
 	tmp += 224 + (str + 1) * 8;
 
+	byte *ptr = getBasePtr(xx, yy);
+	if (ptr == NULL)
+	  return;
+	
 	for (y = 0; y < 8; y++) {
 		for (x = 0; x < 8; x++) {
 			unsigned char color;
@@ -120,8 +184,10 @@
 			}
 			color = ((buffer & mask) != 0);
 			if (color)
-				vline(xx + x, yy + y, yy + y);
+				ptr[x] = _color;
+//				vline(xx + x, yy + y, yy + y);
 		}
+		ptr += 320;
 	}
 	_color = tempc;
 
@@ -169,7 +235,8 @@
 	case GUI_KEYTEXT:
 	case GUI_ACTIONTEXT:
 	case GUI_RESTEXT:
-	case GUI_NEXTTEXT:{
+	case GUI_NEXTTEXT:
+		{
 			char text[500];
 			text[0] = '\0';
 
@@ -217,7 +284,40 @@
 			break;
 		}
 	case GUI_IMAGE:
-		;
+		break;
+	case GUI_UPDOWNARROW:
+		{
+			uint32 *data;
+			byte color = (_clickWidget && _clickWidget == w->_id) ? _textcolorhi : _textcolor;
+
+			if (w->_string_number == 0)
+				data = up_arrow;
+			else
+				data = down_arrow;
+
+			// Center the image
+			x += w->_w/2 - IMG_SIZE/2;
+			y += w->_h/2 - IMG_SIZE/2;
+			if (w->_flags & GWF_BORDER) {
+				x -= 4;
+				y -= 4;
+			}
+
+			byte *ptr = getBasePtr(x, y);
+			if (ptr == NULL)
+				return;
+	
+			for (int y2 = 0; y2 < IMG_SIZE; y2++) {
+				uint32 mask = 0xF0000000;
+				for (int x2 = 0; x2 < IMG_SIZE; x2++) {
+					if (data[y2] & mask)
+						ptr[x2] = color;
+					mask >>= 4;
+				}
+				ptr += 320;
+			}
+		}
+		break;
 	}
 }
 
@@ -313,10 +413,10 @@
 	_curY = y;
 
 	if (x2 < x)
-		x2 ^= x ^= x2 ^= x;
+		x2 ^= x ^= x2 ^= x;	// Swap x2 and x
 
 	if (y2 < y)
-		y2 ^= y ^= y2 ^= y;
+		y2 ^= y ^= y2 ^= y;	// Swap y2 and y
 
 	ptr = getBasePtr(x, y);
 
@@ -449,10 +549,10 @@
 	{GUI_RESTEXT, 0x04, 0, 40, 5, 128, 16, 0, 3},	/* Name your SAVE game */
 
 	{GUI_STAT, 0xFF, GWF_DEFAULT, 6, 16, 170, 96, 0, 0},
-	{GUI_RESTEXT, 0x01, GWF_DEFAULT, 180, 20, 16, 40, 0, 0},
-	{GUI_RESTEXT, 0x01, GWF_DEFAULT, 180, 66, 16, 40, 0, 0},
-	{GUI_RESTEXT, 0xFE, GWF_DEFAULT, 180, 20, 16, 40, 1, 0},
-	{GUI_RESTEXT, 0xFE, GWF_DEFAULT, 180, 66, 16, 40, 2, 0},
+	{GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 20, 16, 40, 0, 0}, /* Up (dummy) */
+	{GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 66, 16, 40, 0, 1}, /* Down (dummy) */
+	{GUI_UPDOWNARROW, 0xFE, GWF_BUTTON, 180, 20, 16, 40, 1, 0}, /* Up */
+	{GUI_UPDOWNARROW, 0xFE, GWF_BUTTON, 180, 66, 16, 40, 2, 1}, /* Down */
 
 	{GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 20, 160, 10, 20, 0},
 	{GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 30, 160, 10, 21, 0},
@@ -653,7 +753,7 @@
 		getSavegameNames(_slotIndex - 9);
 		draw(20, 28);
 		return;
-	case 2:
+	case 2:											/* down button */
 		if (_slotIndex > 80)
 			return;
 		getSavegameNames(_slotIndex + 9);

Index: gui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- gui.h	21 Apr 2002 21:54:08 -0000	1.19
+++ gui.h	8 May 2002 00:27:09 -0000	1.20
@@ -21,56 +21,37 @@
 #if !defined(gui_h)
 #define gui_h
 
-struct ResString {
-	int num;
-	char string[80];
-};
-
-enum {
-	GUI_NONE = 0,
-	GUI_RESTEXT = 1,
-	GUI_IMAGE = 2,
-	GUI_STAT = 3,
-	GUI_CUSTOMTEXT = 4,
-	GUI_VARTEXT = 5,
-	GUI_ACTIONTEXT = 6,
-	GUI_KEYTEXT = 7,
-	GUI_SCROLLTEXT = 8,
-	GUI_NEXTTEXT = 9
-};
-
-enum {
-	GWF_BORDER = 1,
-	GWF_CLEARBG = 2,
-	GWF_PARENT = 4,
-	GWF_DELAY = 8,
-	GWF_DEFAULT = GWF_BORDER|GWF_CLEARBG,
-	GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY
-};
-
-struct GuiWidget {
-	byte _type;
-	byte _page;
-	byte _flags;
-	int16 _x,_y;
-	uint16 _w,_h;
-	uint16 _id;
-	byte _string_number;
-};
+// Forward declaration for GuiWidget
+struct GuiWidget;
 
 #define SAVEGAME_NAME_LEN 32
 
 class Gui {
 public:
+	byte _color,_shadowcolor;
+	byte _bgcolor;
+	byte _textcolor;
+	byte _textcolorhi;
+
+	// Init
+	void init(Scumm *s);
+
+	// Dialogs
+	void saveLoadDialog();
+	void pause();
+	void options();
+	void launcher();
+
+	void loop();
+
+	bool isActive()	{ return _active; }
+
+protected:
 	Scumm *_s;
 	const GuiWidget *_widgets[4];
 	int _return_to;
 	int _curX, _curY;
 	VirtScreen *_vs;
-	byte _color,_shadowcolor;
-	byte _bgcolor;
-	byte _textcolor;
-	byte _textcolorhi;
 	bool _old_cursor_mode;
 	int _parentX, _parentY;
 	byte _active;
@@ -80,17 +61,17 @@
 	int _clickWidget;
 	char *_queryMess;
 
-	/* optiondialog specifics */
+	// optiondialog specifics
 	int _gui_variables[100];
 
-	/* savedialog specifics */	
+	// savedialog specifics	
 	int _slotIndex;
 	int _editString;
 	int _editLen;
 	bool valid_games[9];
 	char game_names[9][SAVEGAME_NAME_LEN];
-	void loop();
-	void init(Scumm *s);
+	
+	// Drawing
 	void draw(int start, int end);
 	void draw(int item) { draw(item,-1); }
 	void drawWidget(const GuiWidget *w);
@@ -104,6 +85,8 @@
 	void widgetBorder(const GuiWidget *w);
 	byte *getBasePtr(int x, int y);
 	const GuiWidget *widgetFromPos(int x, int y);
+	
+	// Actions
 	void leftMouseClick(int x, int y);
 	void handleCommand(int cmd);
 	void close();
@@ -116,12 +99,6 @@
 	byte getDefaultColor(int color);
 
 	char _gui_scroller[255];
-
-	// Dialogs
-	void saveLoadDialog();
-	void pause();
-	void options();
-	void launcher();
 
 	void handleSoundDialogCommand(int cmd);
 	void handleOptionsDialogCommand(int cmd);

Index: guimaps.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/guimaps.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- guimaps.h	13 Apr 2002 04:44:59 -0000	1.1
+++ guimaps.h	8 May 2002 00:27:09 -0000	1.2
@@ -21,6 +21,10 @@
 #if !defined(guimaps_h)
 #define guimaps_h
 
+struct ResString {
+	int num;
+	char string[80];
+};
 
 // String maps
 static const char* string_map_table_custom[] = { 

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.cpp,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- scummvm.cpp	7 May 2002 22:07:28 -0000	1.143
+++ scummvm.cpp	8 May 2002 00:27:09 -0000	1.144
@@ -1282,7 +1282,7 @@
 		new_time = _system->get_msecs();
 		waitForTimer(delta * 15 + last_time - new_time);
 		last_time = _system->get_msecs();
-		if (_gui->_active) {
+		if (_gui->isActive()) {
 			_gui->loop();
 			delta = 5;
 		} else {





More information about the Scummvm-git-logs mailing list