changeset 8320:06495654aee6 draft

(svn r11885) -Cleanup: Remove gotos from widget drawing code. A side affect is that it is now possible for any widget type to be shown disabled.
author peter1138 <peter1138@openttd.org>
date Thu, 17 Jan 2008 00:06:36 +0000
parents b2743d3ccecb
children c361d51b1bb8
files src/widget.cpp
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -210,13 +210,13 @@
 			/* show different image when clicked for WWT_IMGBTN_2 */
 			if ((wi->type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++;
 			DrawSprite(img, PAL_NONE, r.left + 1 + clicked, r.top + 1 + clicked);
-			goto draw_default;
+			break;
 		}
 
 		case WWT_PANEL: {
 			assert(wi->data == 0);
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
-			goto draw_default;
+			break;
 		}
 
 		case WWT_TEXTBTN:
@@ -231,7 +231,7 @@
 			if ((wi->type & WWT_MASK) == WWT_TEXTBTN_2 && clicked) str++;
 
 			DrawStringCentered(((r.left + r.right + 1) >> 1) + clicked, ((r.top + r.bottom + 1) >> 1) - 5 + clicked, str, TC_FROMSTRING);
-			goto draw_default;
+			break;
 		}
 
 		case WWT_TEXT: {
@@ -246,7 +246,7 @@
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED);
 
 			if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 1, str, TC_FROMSTRING, r.right - r.left - 10);
-			goto draw_default;
+			break;
 		}
 
 		case WWT_MATRIX: {
@@ -290,7 +290,7 @@
 				GfxFillRect(r.left + 1, x, r.right - 1, x, color);
 			}
 
-			goto draw_default;
+			break;
 		}
 
 		/* vertical scrollbar */
@@ -426,7 +426,7 @@
 			GfxFillRect(r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1, c1);
 			GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2);
 
-			goto draw_default;
+			break;
 		}
 
 		case WWT_STICKYBOX: {
@@ -470,11 +470,12 @@
 			}
 
 			DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top + 2, wi->data, 0x84);
-draw_default:;
-			if (w->IsWidgetDisabled(i)) {
-				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[wi->color & 0xF][2] | (1 << PALETTE_MODIFIER_GREYOUT));
-			}
+			break;
+		}
 		}
+
+		if (w->IsWidgetDisabled(i)) {
+			GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[wi->color & 0xF][2] | (1 << PALETTE_MODIFIER_GREYOUT));
 		}
 	}