(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
authorDarkvater
Mon, 04 Sep 2006 15:44:28 +0000
changeset 4547 d37c2d172ad4
parent 4546 507b7d9bd834
child 4548 6165e12570bf
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
aircraft_gui.c
order_gui.c
rail_gui.c
roadveh_gui.c
ship_gui.c
train_gui.c
vehicle_gui.c
widget.c
window.h
--- a/aircraft_gui.c	Mon Sep 04 15:16:58 2006 +0000
+++ b/aircraft_gui.c	Mon Sep 04 15:44:28 2006 +0000
@@ -218,7 +218,7 @@
 
 	case WE_RESIZE:
 		w->vscroll.cap += e->sizing.diff.y / 24;
-		w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
+		w->widget[2].data = (w->vscroll.cap << 8) + 1;
 		break;
 	}
 }
@@ -252,7 +252,7 @@
 	w = AllocateWindowDesc(&_new_aircraft_desc);
 	w->window_number = tile;
 	w->vscroll.cap = 4;
-	w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
+	w->widget[2].data = (w->vscroll.cap << 8) + 1;
 
 	w->resize.step_height = 24;
 
@@ -903,7 +903,7 @@
 	case WE_RESIZE:
 		w->vscroll.cap += e->sizing.diff.y / 24;
 		w->hscroll.cap += e->sizing.diff.x / 74;
-		w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
+		w->widget[5].data = (w->vscroll.cap << 8) + w->hscroll.cap;
 		break;
 	}
 }
--- a/order_gui.c	Mon Sep 04 15:16:58 2006 +0000
+++ b/order_gui.c	Mon Sep 04 15:44:28 2006 +0000
@@ -73,9 +73,9 @@
 	if (v->type != VEH_Train) {
 		SETBIT(w->disabled_state, 6); // Disable non-stop for non-trains
 		switch (v->type) {
-			case VEH_Road:     w->widget[11].unkA = STR_LORRY; break;
-			case VEH_Ship:     w->widget[11].unkA = STR_SHIP;  break;
-			case VEH_Aircraft: w->widget[11].unkA = STR_PLANE; break;
+			case VEH_Road:     w->widget[11].data = STR_LORRY; break;
+			case VEH_Ship:     w->widget[11].data = STR_SHIP;  break;
+			case VEH_Aircraft: w->widget[11].data = STR_PLANE; break;
 			default: NOT_REACHED(); break;
 		}
 	}
--- a/rail_gui.c	Mon Sep 04 15:16:58 2006 +0000
+++ b/rail_gui.c	Mon Sep 04 15:44:28 2006 +0000
@@ -560,15 +560,15 @@
 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
 
 	assert(railtype < RAILTYPE_END);
-	w->widget[RTW_CAPTION].unkA = rti->strings.toolbar_caption;
-	w->widget[RTW_BUILD_NS].unkA = rti->gui_sprites.build_ns_rail;
-	w->widget[RTW_BUILD_X].unkA = rti->gui_sprites.build_x_rail;
-	w->widget[RTW_BUILD_EW].unkA = rti->gui_sprites.build_ew_rail;
-	w->widget[RTW_BUILD_Y].unkA = rti->gui_sprites.build_y_rail;
-	w->widget[RTW_AUTORAIL].unkA = rti->gui_sprites.auto_rail;
-	w->widget[RTW_BUILD_DEPOT].unkA = rti->gui_sprites.build_depot;
-	w->widget[RTW_CONVERT_RAIL].unkA = rti->gui_sprites.convert_rail;
-	w->widget[RTW_BUILD_TUNNEL].unkA = rti->gui_sprites.build_tunnel;
+	w->widget[RTW_CAPTION].data = rti->strings.toolbar_caption;
+	w->widget[RTW_BUILD_NS].data = rti->gui_sprites.build_ns_rail;
+	w->widget[RTW_BUILD_X].data = rti->gui_sprites.build_x_rail;
+	w->widget[RTW_BUILD_EW].data = rti->gui_sprites.build_ew_rail;
+	w->widget[RTW_BUILD_Y].data = rti->gui_sprites.build_y_rail;
+	w->widget[RTW_AUTORAIL].data = rti->gui_sprites.auto_rail;
+	w->widget[RTW_BUILD_DEPOT].data = rti->gui_sprites.build_depot;
+	w->widget[RTW_CONVERT_RAIL].data = rti->gui_sprites.convert_rail;
+	w->widget[RTW_BUILD_TUNNEL].data = rti->gui_sprites.build_tunnel;
 }
 
 void ShowBuildRailToolbar(RailType railtype, int button)
--- a/roadveh_gui.c	Mon Sep 04 15:16:58 2006 +0000
+++ b/roadveh_gui.c	Mon Sep 04 15:44:28 2006 +0000
@@ -567,7 +567,7 @@
 		if (e->sizing.diff.y == 0) break;
 
 		w->vscroll.cap += e->sizing.diff.y / 14;
-		w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
+		w->widget[2].data = (w->vscroll.cap << 8) + 1;
 	} break;
 
 	}
@@ -602,7 +602,7 @@
 	w = AllocateWindowDesc(&_new_road_veh_desc);
 	w->window_number = tile;
 	w->vscroll.cap = 8;
-	w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
+	w->widget[2].data = (w->vscroll.cap << 8) + 1;
 
 	w->resize.step_height = 14;
 	w->resize.height = w->height - 14 * 4; /* Minimum of 4 vehicles in the display */
@@ -854,7 +854,7 @@
 		/* Update the scroll + matrix */
 		w->vscroll.cap += e->sizing.diff.y / 14;
 		w->hscroll.cap += e->sizing.diff.x / 56;
-		w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
+		w->widget[5].data = (w->vscroll.cap << 8) + w->hscroll.cap;
 		break;
 
 	}
--- a/ship_gui.c	Mon Sep 04 15:16:58 2006 +0000
+++ b/ship_gui.c	Mon Sep 04 15:44:28 2006 +0000
@@ -398,7 +398,7 @@
 
 	case WE_RESIZE:
 		w->vscroll.cap += e->sizing.diff.y / 24;
-		w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
+		w->widget[2].data = (w->vscroll.cap << 8) + 1;
 		break;
 
 	}
@@ -434,7 +434,7 @@
 	w = AllocateWindowDesc(&_new_ship_desc);
 	w->window_number = tile;
 	w->vscroll.cap = 4;
-	w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
+	w->widget[2].data = (w->vscroll.cap << 8) + 1;
 
 	w->resize.step_height = 24;
 
@@ -843,7 +843,7 @@
 	case WE_RESIZE:
 		w->vscroll.cap += e->sizing.diff.y / 24;
 		w->hscroll.cap += e->sizing.diff.x / 90;
-		w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
+		w->widget[5].data = (w->vscroll.cap << 8) + w->hscroll.cap;
 		break;
 	}
 }
--- a/train_gui.c	Mon Sep 04 15:16:58 2006 +0000
+++ b/train_gui.c	Mon Sep 04 15:44:28 2006 +0000
@@ -296,7 +296,7 @@
 			break;
 
 		w->vscroll.cap += e->sizing.diff.y / 14;
-		w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
+		w->widget[2].data = (w->vscroll.cap << 8) + 1;
 	} break;
 	}
 }
@@ -330,7 +330,7 @@
 	w = AllocateWindowDesc(&_new_rail_vehicle_desc);
 	w->window_number = tile;
 	w->vscroll.cap = 8;
-	w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
+	w->widget[2].data = (w->vscroll.cap << 8) + 1;
 
 	w->resize.step_height = 14;
 	w->resize.height = w->height - 14 * 4; // Minimum of 4 vehicles in the display
@@ -765,7 +765,7 @@
 		/* Update the scroll + matrix */
 		w->vscroll.cap += e->sizing.diff.y / 14;
 		w->hscroll.cap += e->sizing.diff.x;
-		w->widget[6].unkA = (w->vscroll.cap << 8) + 1;
+		w->widget[6].data = (w->vscroll.cap << 8) + 1;
 	} break;
 	}
 }
@@ -1317,7 +1317,7 @@
 		if (e->sizing.diff.y == 0) break;
 
 		w->vscroll.cap += e->sizing.diff.y / 14;
-		w->widget[4].unkA = (w->vscroll.cap << 8) + 1;
+		w->widget[4].data = (w->vscroll.cap << 8) + 1;
 		break;
 	}
 }
@@ -1364,7 +1364,7 @@
 	w->window_number = veh;
 	w->caption_color = v->owner;
 	w->vscroll.cap = 6;
-	w->widget[4].unkA = (w->vscroll.cap << 8) + 1;
+	w->widget[4].data = (w->vscroll.cap << 8) + 1;
 
 	w->resize.step_height = 14;
 	w->resize.height = w->height - 14 * 2; /* Minimum of 4 wagons in the display */
--- a/vehicle_gui.c	Mon Sep 04 15:16:58 2006 +0000
+++ b/vehicle_gui.c	Mon Sep 04 15:44:28 2006 +0000
@@ -999,8 +999,8 @@
 			w->vscroll.cap  += e->sizing.diff.y / (int)w->resize.step_height;
 			w->vscroll2.cap += e->sizing.diff.y / (int)w->resize.step_height;
 
-			w->widget[7].unkA = (w->vscroll.cap  << 8) + 1;
-			w->widget[9].unkA = (w->vscroll2.cap << 8) + 1;
+			w->widget[7].data = (w->vscroll.cap  << 8) + 1;
+			w->widget[9].data = (w->vscroll2.cap << 8) + 1;
 			break;
 	}
 }
@@ -1188,16 +1188,16 @@
 			/* Set up the window widgets */
 			switch (window_type) {
 				case VLW_SHARED_ORDERS:
-					w->widget[1].unkA  = STR_VEH_WITH_SHARED_ORDERS_LIST;
+					w->widget[1].data  = STR_VEH_WITH_SHARED_ORDERS_LIST;
 					break;
 				case VLW_STANDARD: /* Company Name - standard widget setup */
 					break;
 				case VLW_STATION_LIST: /* Station Name */
 					switch (vl->vehicle_type) {
-						case VEH_Train:    w->widget[1].unkA = STR_SCHEDULED_TRAINS; break;
-						case VEH_Road:     w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES; break;
-						case VEH_Ship:     w->widget[1].unkA = STR_SCHEDULED_SHIPS; break;
-						case VEH_Aircraft: w->widget[1].unkA = STR_SCHEDULED_AIRCRAFT; break;
+						case VEH_Train:    w->widget[1].data = STR_SCHEDULED_TRAINS; break;
+						case VEH_Road:     w->widget[1].data = STR_SCHEDULED_ROAD_VEHICLES; break;
+						case VEH_Ship:     w->widget[1].data = STR_SCHEDULED_SHIPS; break;
+						case VEH_Aircraft: w->widget[1].data = STR_SCHEDULED_AIRCRAFT; break;
 						default: NOT_REACHED(); break;
 					}
 					break;
@@ -1222,7 +1222,7 @@
 				default: NOT_REACHED();
 			}
 
-			w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
+			w->widget[7].data = (w->vscroll.cap << 8) + 1;
 
 			/* Set up sorting. Make the window-specific _sorting variable
 			 * point to the correct global _sorting struct so we are freed
@@ -1430,7 +1430,7 @@
 		case WE_RESIZE: /* Update the scroll + matrix */
 			if (vl->vehicle_type == VEH_Train) w->hscroll.cap += e->sizing.diff.x;
 			w->vscroll.cap += e->sizing.diff.y / (int)w->resize.step_height;
-			w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
+			w->widget[7].data = (w->vscroll.cap << 8) + 1;
 			break;
 	}
 }
--- a/widget.c	Mon Sep 04 15:16:58 2006 +0000
+++ b/widget.c	Mon Sep 04 15:44:28 2006 +0000
@@ -209,11 +209,10 @@
 		switch (wi->type & WWT_MASK) {
 		case WWT_PANEL: /* WWT_IMGBTN */
 		case WWT_PANEL_2: {
-			int img;
+			int img = wi->data;
 
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
 
-			img = wi->unkA;
 			if (img != 0) { // has an image
 				// show diff image when clicked
 				if ((wi->type & WWT_MASK) == WWT_PANEL_2 && clicked) img++;
@@ -230,7 +229,7 @@
 		/* fall through */
 
 		case WWT_LABEL: {
-			StringID str = wi->unkA;
+			StringID str = wi->data;
 
 			if ((wi->type&WWT_MASK) == WWT_4 && clicked) str++;
 
@@ -240,11 +239,10 @@
 		}
 
 		case WWT_6: {
-			StringID str;
+			StringID str = wi->data;
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED);
 
-			str = wi->unkA;
-			if (str != 0) DrawStringTruncated(r.left + 2, r.top + 1, str, 0, r.right - r.left - 10);
+			if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 1, str, 0, r.right - r.left - 10);
 			goto draw_default;
 		}
 
@@ -255,10 +253,10 @@
 
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
 
-			c = GB(wi->unkA, 0, 8);
+			c = GB(wi->data, 0, 8);
 			amt1 = (wi->right - wi->left + 1) / c;
 
-			d = GB(wi->unkA, 8, 8);
+			d = GB(wi->data, 8, 8);
 			amt2 = (wi->bottom - wi->top + 1) / d;
 
 			color = _colour_gradient[wi->color & 0xF][6];
@@ -397,7 +395,7 @@
 			int c1,c2;
 			int x2 = r.left; // by default the left side is the left side of the widget
 
-			if (wi->unkA != 0) x2 = DrawString(r.left + 6, r.top, wi->unkA, 0);
+			if (wi->data != 0) x2 = DrawString(r.left + 6, r.top, wi->data, 0);
 
 			c1 = _colour_gradient[wi->color][3];
 			c2 = _colour_gradient[wi->color][7];
@@ -459,7 +457,7 @@
 				GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _colour_gradient[_player_colors[w->caption_color]][4]);
 			}
 
-			DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->unkA, 0x84);
+			DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->data, 0x84);
 draw_default:;
 			if (cur_disabled & 1) {
 				GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _colour_gradient[wi->color&0xF][2] | PALETTE_MODIFIER_GREYOUT);
--- a/window.h	Mon Sep 04 15:16:58 2006 +0000
+++ b/window.h	Mon Sep 04 15:44:28 2006 +0000
@@ -36,7 +36,7 @@
      w->resize.width or w->resize.height.
    That was all.. good luck, and enjoy :) -- TrueLight */
 
-enum {
+enum ResizeFlags {
 	RESIZE_NONE   = 0,
 
 	RESIZE_LEFT   = 1,
@@ -50,15 +50,15 @@
 	RESIZE_LRB    = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_BOTTOM,
 	RESIZE_LRTB   = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_TOP | RESIZE_BOTTOM,
 	RESIZE_RTB    = RESIZE_RIGHT | RESIZE_TOP    | RESIZE_BOTTOM,
-};
+} ResizeFlag;
 
 typedef struct Widget {
-	byte type;
-	byte resize_flag;
-	byte color;
-	uint16 left, right, top, bottom;
-	uint16 unkA;
-	StringID tooltips;
+	byte type;                        ///< Widget type, see @WindowWidgetTypes
+	byte resize_flag;                 ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags
+	byte color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
+	uint16 left, right, top, bottom;  ///< The position offsets inside the window
+	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
+	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
 } Widget;
 
 typedef enum FrameFlags {