summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_gui.c6
-rw-r--r--order_gui.c6
-rw-r--r--rail_gui.c18
-rw-r--r--roadveh_gui.c6
-rw-r--r--ship_gui.c6
-rw-r--r--train_gui.c10
-rw-r--r--vehicle_gui.c18
-rw-r--r--widget.c18
-rw-r--r--window.h16
9 files changed, 51 insertions, 53 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index d3b5aa4fe..bca31d971 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -218,7 +218,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
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 @@ void ShowBuildAircraftWindow(TileIndex tile)
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 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e)
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;
}
}
diff --git a/order_gui.c b/order_gui.c
index 60d6af166..feb1e8179 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -73,9 +73,9 @@ static void DrawOrdersWindow(Window *w)
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;
}
}
diff --git a/rail_gui.c b/rail_gui.c
index 70db6a7d8..87bef2981 100644
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -560,15 +560,15 @@ static void SetupRailToolbar(RailType railtype, Window *w)
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)
diff --git a/roadveh_gui.c b/roadveh_gui.c
index b8600f7a9..47df5cdc4 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -567,7 +567,7 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e)
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 @@ void ShowBuildRoadVehWindow(TileIndex tile)
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 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
/* 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;
}
diff --git a/ship_gui.c b/ship_gui.c
index 6e209dfdb..0a0914e81 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -398,7 +398,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
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 @@ void ShowBuildShipWindow(TileIndex tile)
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 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e)
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;
}
}
diff --git a/train_gui.c b/train_gui.c
index 77a014b5d..3dfc86e84 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -296,7 +296,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
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 @@ void ShowBuildTrainWindow(TileIndex tile)
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 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
/* 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 @@ do_change_service_int:
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 @@ static void ShowTrainDetailsWindow(const Vehicle *v)
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 */
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 74d4955b6..625a2814d 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -999,8 +999,8 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
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 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
/* 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 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
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 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
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;
}
}
diff --git a/widget.c b/widget.c
index c93845dc0..a71182cee 100644
--- a/widget.c
+++ b/widget.c
@@ -209,11 +209,10 @@ void DrawWindowWidgets(const Window *w)
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 @@ void DrawWindowWidgets(const Window *w)
/* 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 @@ void DrawWindowWidgets(const Window *w)
}
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 @@ void DrawWindowWidgets(const Window *w)
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 @@ void DrawWindowWidgets(const Window *w)
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 @@ void DrawWindowWidgets(const Window *w)
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);
diff --git a/window.h b/window.h
index 865618c90..2ca55c84b 100644
--- a/window.h
+++ b/window.h
@@ -36,7 +36,7 @@ typedef void WindowProc(Window *w, WindowEvent *e);
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 @@ enum {
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 {