Changeset - r13721:3499c8d2d992
[Not reviewed]
master
0 2 0
rubidium - 15 years ago 2009-11-23 16:18:01
rubidium@openttd.org
(svn r18256) -Codechange: make the vehicle details window big font aware
2 files changed with 14 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/train_gui.cpp
Show inline comments
 
@@ -231,34 +231,35 @@ int GetTrainDetailsWndVScroll(VehicleID 
 
 * @param vscroll_pos Position of scrollbar
 
 * @param vscroll_cap Number of lines currently displayed
 
 * @param det_tab Selected details tab
 
 */
 
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
 
{
 
	/* draw the first 3 details tabs */
 
	if (det_tab != TDW_TAB_TOTALS) {
 
		bool rtl = _dynlang.text_dir == TD_RTL;
 
		Direction dir = rtl ? DIR_E : DIR_W;
 
		const Train *u = v;
 
		int x = rtl ? right : left;
 
		int sprite_y_offset = 4 + (FONT_HEIGHT_NORMAL - 10) / 2;
 
		for (;;) {
 
			if (--vscroll_pos < 0 && vscroll_pos >= -vscroll_cap) {
 
				int px = x;
 

	
 
				u = v;
 
				do {
 
					Point offset;
 
					int width = u->GetDisplayImageWidth(&offset);
 
					SpriteID pal = (u->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(u);
 
					DrawSprite(u->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), y + 4 + offset.y);
 
					DrawSprite(u->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), y + sprite_y_offset + offset.y);
 
					px += rtl ? -width : width;
 
					u = u->Next();
 
				} while (u != NULL && u->IsArticulatedPart() && u->cargo_cap == 0);
 

	
 
				px += rtl ? -2 : 2;
 
				int py = y;
 
				switch (det_tab) {
 
					default: NOT_REACHED();
 

	
 
					case TDW_TAB_CARGO:
 
						TrainDetailsCargoTab(v, rtl ? left : px, rtl ? px : right, py);
 
						break;
src/vehicle_gui.cpp
Show inline comments
 
@@ -1253,92 +1253,88 @@ void ShowVehicleListWindow(CompanyID com
 
/* Unified vehicle GUI - Vehicle Details Window */
 

	
 
/** Constants of vehicle details widget indices */
 
enum VehicleDetailsWindowWidgets {
 
	VLD_WIDGET_CLOSEBOX = 0,
 
	VLD_WIDGET_CAPTION,
 
	VLD_WIDGET_RENAME_VEHICLE,
 
	VLD_WIDGET_STICKY,
 
	VLD_WIDGET_TOP_DETAILS,
 
	VLD_WIDGET_INCREASE_SERVICING_INTERVAL,
 
	VLD_WIDGET_DECREASE_SERVICING_INTERVAL,
 
	VLD_WIDGET_SERVICING_INTERVAL,
 
	VLD_WIDGET_BOTTOM_RIGHT,
 
	VLD_WIDGET_MIDDLE_DETAILS,
 
	VLD_WIDGET_MATRIX,
 
	VLD_WIDGET_SCROLLBAR,
 
	VLD_WIDGET_DETAILS_CARGO_CARRIED,
 
	VLD_WIDGET_DETAILS_TRAIN_VEHICLES,
 
	VLD_WIDGET_DETAILS_CAPACITY_OF_EACH,
 
	VLD_WIDGET_DETAILS_TOTAL_CARGO,
 
	VLD_WIDGET_RESIZE,
 
};
 

	
 
assert_compile(VLD_WIDGET_DETAILS_CARGO_CARRIED    == VLD_WIDGET_DETAILS_CARGO_CARRIED + TDW_TAB_CARGO   );
 
assert_compile(VLD_WIDGET_DETAILS_TRAIN_VEHICLES   == VLD_WIDGET_DETAILS_CARGO_CARRIED + TDW_TAB_INFO    );
 
assert_compile(VLD_WIDGET_DETAILS_CAPACITY_OF_EACH == VLD_WIDGET_DETAILS_CARGO_CARRIED + TDW_TAB_CAPACITY);
 
assert_compile(VLD_WIDGET_DETAILS_TOTAL_CARGO      == VLD_WIDGET_DETAILS_CARGO_CARRIED + TDW_TAB_TOTALS  );
 

	
 
/** Vehicle details widgets (other than train). */
 
static const NWidgetPart _nested_nontrain_vehicle_details_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY, VLD_WIDGET_CLOSEBOX),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, VLD_WIDGET_CAPTION), SetDataTip(STR_VEHICLE_DETAILS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VLD_WIDGET_RENAME_VEHICLE), SetMinimalSize(40, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_VEHICLE_NAME_BUTTON, STR_NULL /* filled in later */),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY, VLD_WIDGET_STICKY),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_TOP_DETAILS), SetMinimalSize(405, 42), EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_MIDDLE_DETAILS), SetMinimalSize(405, 45), EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_BOTTOM_RIGHT),
 
	NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_TOP_DETAILS), SetMinimalSize(405, 42), SetResize(1, 0), EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_MIDDLE_DETAILS), SetMinimalSize(405, 45), SetResize(1, 0), EndContainer(),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, VLD_WIDGET_DECREASE_SERVICING_INTERVAL), SetFill(0, 1),
 
					SetDataTip(AWV_DECREASE, STR_VEHICLE_DETAILS_DECREASE_SERVICING_INTERVAL_TOOLTIP),
 
			NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, VLD_WIDGET_INCREASE_SERVICING_INTERVAL), SetFill(0, 1),
 
					SetDataTip(AWV_INCREASE, STR_VEHICLE_DETAILS_INCREASE_SERVICING_INTERVAL_TOOLTIP),
 
			NWidget(WWT_EMPTY, COLOUR_GREY, VLD_WIDGET_SERVICING_INTERVAL), SetFill(1, 1),
 
		EndContainer(),
 
		NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_SERVICING_INTERVAL), SetFill(1, 1), SetResize(1, 0), EndContainer(),
 
		NWidget(WWT_RESIZEBOX, COLOUR_GREY, VLD_WIDGET_RESIZE),
 
	EndContainer(),
 
};
 

	
 
/** Train details widgets. */
 
static const NWidgetPart _nested_train_vehicle_details_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY, VLD_WIDGET_CLOSEBOX),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, VLD_WIDGET_CAPTION), SetDataTip(STR_VEHICLE_DETAILS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VLD_WIDGET_RENAME_VEHICLE), SetMinimalSize(40, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_VEHICLE_NAME_BUTTON, STR_NULL /* filled in later */),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY, VLD_WIDGET_STICKY),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_TOP_DETAILS), SetResize(1, 0), SetMinimalSize(405, 42), EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_MATRIX, COLOUR_GREY, VLD_WIDGET_MATRIX), SetResize(1, 1), SetMinimalSize(393, 45), SetDataTip(0x701, STR_NULL), SetFill(1, 0),
 
		NWidget(WWT_SCROLLBAR, COLOUR_GREY, VLD_WIDGET_SCROLLBAR),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_BOTTOM_RIGHT),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, VLD_WIDGET_DECREASE_SERVICING_INTERVAL), SetFill(0, 1),
 
					SetDataTip(AWV_DECREASE, STR_VEHICLE_DETAILS_DECREASE_SERVICING_INTERVAL_TOOLTIP),
 
			NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, VLD_WIDGET_INCREASE_SERVICING_INTERVAL), SetFill(0, 1),
 
					SetDataTip(AWV_INCREASE, STR_VEHICLE_DETAILS_DECREASE_SERVICING_INTERVAL_TOOLTIP),
 
			NWidget(WWT_EMPTY, COLOUR_GREY, VLD_WIDGET_SERVICING_INTERVAL), SetFill(1, 1), SetResize(1, 0),
 
		EndContainer(),
 
		NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_SERVICING_INTERVAL), SetFill(1, 1), SetResize(1, 0), EndContainer(),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VLD_WIDGET_DETAILS_CARGO_CARRIED), SetMinimalSize(96, 12),
 
				SetDataTip(STR_VEHICLE_DETAIL_TAB_CARGO, STR_VEHICLE_DETAILS_TRAIN_CARGO_TOOLTIP), SetResize(1, 0),
 
				SetDataTip(STR_VEHICLE_DETAIL_TAB_CARGO, STR_VEHICLE_DETAILS_TRAIN_CARGO_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VLD_WIDGET_DETAILS_TRAIN_VEHICLES), SetMinimalSize(99, 12),
 
				SetDataTip(STR_VEHICLE_DETAIL_TAB_INFORMATION, STR_VEHICLE_DETAILS_TRAIN_INFORMATION_TOOLTIP), SetResize(1, 0),
 
				SetDataTip(STR_VEHICLE_DETAIL_TAB_INFORMATION, STR_VEHICLE_DETAILS_TRAIN_INFORMATION_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VLD_WIDGET_DETAILS_CAPACITY_OF_EACH), SetMinimalSize(99, 12),
 
				SetDataTip(STR_VEHICLE_DETAIL_TAB_CAPACITIES, STR_VEHICLE_DETAILS_TRAIN_CAPACITIES_TOOLTIP), SetResize(1, 0),
 
				SetDataTip(STR_VEHICLE_DETAIL_TAB_CAPACITIES, STR_VEHICLE_DETAILS_TRAIN_CAPACITIES_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VLD_WIDGET_DETAILS_TOTAL_CARGO), SetMinimalSize(99, 12),
 
				SetDataTip(STR_VEHICLE_DETAIL_TAB_TOTAL_CARGO, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CARGO_TOOLTIP), SetResize(1, 0),
 
				SetDataTip(STR_VEHICLE_DETAIL_TAB_TOTAL_CARGO, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CARGO_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
		NWidget(WWT_RESIZEBOX, COLOUR_GREY, VLD_WIDGET_RESIZE),
 
	EndContainer(),
 
};
 

	
 

	
 
extern int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab);
 
extern void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab);
 
extern void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y);
 
extern void DrawShipDetails(const Vehicle *v, int left, int right, int y);
 
extern void DrawAircraftDetails(const Aircraft *v, int left, int right, int y);
 

	
 
/** Class for managing the vehicle details window. */
 
@@ -1392,24 +1388,27 @@ struct VehicleDetailsWindow : Window {
 
					default:
 
						NOT_REACHED(); // Train uses VLD_WIDGET_MATRIX instead.
 
				}
 
				break;
 
			}
 

	
 
			case VLD_WIDGET_MATRIX:
 
				resize->height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
 
				size->height = 4 * resize->height;
 
				break;
 

	
 
			case VLD_WIDGET_SERVICING_INTERVAL:
 
				SetDParam(0, 9999); // Roughly the maximum interval
 
				SetDParam(1, MAX_YEAR * DAYS_IN_YEAR); // Roughly the maximum year
 
				size->width = max(GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT).width, GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS).width) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				size->height = WD_FRAMERECT_TOP + FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
 
				break;
 
		}
 
	}
 

	
 
	/** Checks whether service interval is enabled for the vehicle. */
 
	static bool IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type, CompanyID company_id)
 
	{
 
		const VehicleDefaultSettings *vds = &Company::Get(company_id)->settings.vehicle;
 
		switch (vehicle_type) {
 
			default: NOT_REACHED();
 
			case VEH_TRAIN:    return vds->servint_trains   != 0;
0 comments (0 inline, 0 general)