(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
This commit is contained in:
		
							
								
								
									
										33
									
								
								gfx.c
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								gfx.c
									
									
									
									
									
								
							@@ -557,39 +557,6 @@ int GetStringWidth(const char *str)
 | 
				
			|||||||
	return w;
 | 
						return w;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DrawFrameRect(int left, int top, int right, int bottom, int ctab, int flags)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	byte color_2 = _color_list[ctab].window_color_1a;
 | 
					 | 
				
			||||||
	byte color_interior = _color_list[ctab].window_color_bga;
 | 
					 | 
				
			||||||
	byte color_3 = _color_list[ctab].window_color_bgb;
 | 
					 | 
				
			||||||
	byte color = _color_list[ctab].window_color_2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!(flags & 0x8)) {
 | 
					 | 
				
			||||||
		if (!(flags & 0x20)) {
 | 
					 | 
				
			||||||
			GfxFillRect(left, top, left, bottom - 1, color);
 | 
					 | 
				
			||||||
			GfxFillRect(left + 1, top, right - 1, top, color);
 | 
					 | 
				
			||||||
			GfxFillRect(right, top, right, bottom - 1, color_2);
 | 
					 | 
				
			||||||
			GfxFillRect(left, bottom, right, bottom, color_2);
 | 
					 | 
				
			||||||
			if (!(flags & 0x10)) {
 | 
					 | 
				
			||||||
				GfxFillRect(left + 1, top + 1, right - 1, bottom - 1, color_interior);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			GfxFillRect(left, top, left, bottom, color_2);
 | 
					 | 
				
			||||||
			GfxFillRect(left + 1, top, right, top, color_2);
 | 
					 | 
				
			||||||
			GfxFillRect(right, top + 1, right, bottom - 1, color);
 | 
					 | 
				
			||||||
			GfxFillRect(left + 1, bottom, right, bottom, color);
 | 
					 | 
				
			||||||
			if (!(flags & 0x10)) {
 | 
					 | 
				
			||||||
				GfxFillRect(left + 1, top + 1, right - 1, bottom - 1,
 | 
					 | 
				
			||||||
					flags & 0x40 ? color_interior : color_3);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else if (flags & 0x1) {
 | 
					 | 
				
			||||||
		// transparency
 | 
					 | 
				
			||||||
		GfxFillRect(left, top, right, bottom, 0x322 | USE_COLORTABLE);
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		GfxFillRect(left, top, right, bottom, color_interior);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int DoDrawString(const char *string, int x, int y, uint16 real_color)
 | 
					int DoDrawString(const char *string, int x, int y, uint16 real_color)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								gfx.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								gfx.h
									
									
									
									
									
								
							@@ -73,7 +73,6 @@ void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void GfxFillRect(int left, int top, int right, int bottom, int color);
 | 
					void GfxFillRect(int left, int top, int right, int bottom, int color);
 | 
				
			||||||
void GfxDrawLine(int left, int top, int right, int bottom, int color);
 | 
					void GfxDrawLine(int left, int top, int right, int bottom, int color);
 | 
				
			||||||
void DrawFrameRect(int left, int top, int right, int bottom, int color, int flags);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int GetStringWidth(const char *str);
 | 
					int GetStringWidth(const char *str);
 | 
				
			||||||
void LoadStringWidthTable(void);
 | 
					void LoadStringWidthTable(void);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -410,8 +410,8 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		y = GAMEDIFF_WND_TOP_OFFSET;
 | 
							y = GAMEDIFF_WND_TOP_OFFSET;
 | 
				
			||||||
		for (i = 0; i != GAME_DIFFICULTY_NUM; i++) {
 | 
							for (i = 0; i != GAME_DIFFICULTY_NUM; i++) {
 | 
				
			||||||
			DrawFrameRect( 5, y,  5 + 8, y + 8, 3, GetBitAndShift(&click_a) ? (1 << 5) : 0);
 | 
								DrawFrameRect( 5, y,  5 + 8, y + 8, 3, GetBitAndShift(&click_a) ? FR_LOWERED : 0);
 | 
				
			||||||
			DrawFrameRect(15, y, 15 + 8, y + 8, 3, GetBitAndShift(&click_b) ? (1 << 5) : 0);
 | 
								DrawFrameRect(15, y, 15 + 8, y + 8, 3, GetBitAndShift(&click_b) ? FR_LOWERED : 0);
 | 
				
			||||||
			if (GetBitAndShift(&disabled) || (_networking && !_network_server)) {
 | 
								if (GetBitAndShift(&disabled) || (_networking && !_network_server)) {
 | 
				
			||||||
				int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
 | 
									int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
 | 
				
			||||||
				GfxFillRect( 6, y + 1,  6 + 8, y + 8, color);
 | 
									GfxFillRect( 6, y + 1,  6 + 8, y + 8, color);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										36
									
								
								widget.c
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								widget.c
									
									
									
									
									
								
							@@ -150,6 +150,42 @@ int GetWidgetFromPos(const Window *w, int x, int y)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DrawFrameRect(int left, int top, int right, int bottom, int ctab, FrameFlags flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						uint dark         = _color_list[ctab].window_color_1a;
 | 
				
			||||||
 | 
						uint medium_dark  = _color_list[ctab].window_color_bga;
 | 
				
			||||||
 | 
						uint medium_light = _color_list[ctab].window_color_bgb;
 | 
				
			||||||
 | 
						uint light        = _color_list[ctab].window_color_2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (flags & FR_NOBORDER) {
 | 
				
			||||||
 | 
							if (flags & FR_TRANSPARENT) {
 | 
				
			||||||
 | 
								GfxFillRect(left, top, right, bottom, 0x322 | USE_COLORTABLE);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								GfxFillRect(left, top, right, bottom, medium_dark);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							uint interior;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (flags & FR_LOWERED) {
 | 
				
			||||||
 | 
								GfxFillRect(left,     top,     left,  bottom,     dark);
 | 
				
			||||||
 | 
								GfxFillRect(left + 1, top,     right, top,        dark);
 | 
				
			||||||
 | 
								GfxFillRect(right,    top + 1, right, bottom - 1, light);
 | 
				
			||||||
 | 
								GfxFillRect(left + 1, bottom,  right, bottom,     light);
 | 
				
			||||||
 | 
								interior = (flags & FR_DARKENED ? medium_dark : medium_light);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								GfxFillRect(left,     top,    left,      bottom - 1, light);
 | 
				
			||||||
 | 
								GfxFillRect(left + 1, top,    right - 1, top,        light);
 | 
				
			||||||
 | 
								GfxFillRect(right,    top,    right,     bottom - 1, dark);
 | 
				
			||||||
 | 
								GfxFillRect(left,     bottom, right,     bottom,     dark);
 | 
				
			||||||
 | 
								interior = medium_dark;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (!(flags & FR_BORDERONLY)) {
 | 
				
			||||||
 | 
								GfxFillRect(left + 1, top + 1, right - 1, bottom - 1, interior);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DrawWindowWidgets(const Window *w)
 | 
					void DrawWindowWidgets(const Window *w)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const Widget *wi;
 | 
						const Widget *wi;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								window.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								window.h
									
									
									
									
									
								
							@@ -61,13 +61,15 @@ typedef struct Widget {
 | 
				
			|||||||
	StringID tooltips;
 | 
						StringID tooltips;
 | 
				
			||||||
} Widget;
 | 
					} Widget;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum FrameFlags {
 | 
					typedef enum FrameFlags {
 | 
				
			||||||
	FR_TRANSPARENT  = 0x01,  ///< Makes the background transparent if set
 | 
						FR_TRANSPARENT  = 0x01,  ///< Makes the background transparent if set
 | 
				
			||||||
	FR_NOBORDER     = 0x08,  ///< Hide border (draws just a solid box)
 | 
						FR_NOBORDER     = 0x08,  ///< Hide border (draws just a solid box)
 | 
				
			||||||
	FR_BORDERONLY   = 0x10,  ///< Draw border only, no background
 | 
						FR_BORDERONLY   = 0x10,  ///< Draw border only, no background
 | 
				
			||||||
	FR_LOWERED      = 0x20,  ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
 | 
						FR_LOWERED      = 0x20,  ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
 | 
				
			||||||
	FR_DARKENED     = 0x40,  ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes)
 | 
						FR_DARKENED     = 0x40,  ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes)
 | 
				
			||||||
};
 | 
					} FrameFlags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* XXX - outside "byte event" so you can set event directly without going into
 | 
					/* XXX - outside "byte event" so you can set event directly without going into
 | 
				
			||||||
 * the union elements at first. Because of this every first element of the union
 | 
					 * the union elements at first. Because of this every first element of the union
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user