Changeset - r6385:7a6435f64b55
[Not reviewed]
master
0 2 0
maedhros - 17 years ago 2007-03-26 11:41:14
maedhros@openttd.org
(svn r9475) -Codechange: Allow the purchase details widget to expand dynamically if there's still not enough room for the text.
2 files changed with 26 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -41,6 +41,7 @@ enum BuildVehicleWidgets {
 
	BUILD_VEHICLE_WIDGET_BUILD,
 
	BUILD_VEHICLE_WIDGET_RENAME,
 
	BUILD_VEHICLE_WIDGET_RESIZE,
 
	BUILD_VEHICLE_WIDGET_END
 
};
 

	
 
static const Widget _build_vehicle_widgets[] = {
 
@@ -527,8 +528,9 @@ static int DrawAircraftPurchaseInfo(int 
 
 * @param x,y location where to draw the info
 
 * @param w how wide are the text allowed to be (size of widget/window to Draw in)
 
 * @param engine_number the engine of which to draw the info of
 
 * @return y after drawing all the text
 
 */
 
void DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
 
int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
 
{
 
	const Engine *e = GetEngine(engine_number);
 
	YearMonthDay ymd;
 
@@ -594,6 +596,8 @@ void DrawVehiclePurchaseInfo(int x, int 
 
	/* Additional text from NewGRF */
 
	y += ShowAdditionalText(x, y, w, engine_number);
 
	if (refitable) y += ShowRefitOptionsList(x, y, w, engine_number);
 

	
 
	return y;
 
}
 

	
 
/* Figure out what train EngineIDs to put in the list */
 
@@ -793,6 +797,23 @@ void DrawEngineList(byte type, int x, in
 
	}
 
}
 

	
 
static void ExpandPurchaseInfoWidget(Window *w, int expand_by)
 
{
 
	Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
 

	
 
	SetWindowDirty(w);
 
	wi->bottom += expand_by;
 

	
 
	for (uint i = BUILD_VEHICLE_WIDGET_BUILD; i < BUILD_VEHICLE_WIDGET_END; i++) {
 
		wi = &w->widget[i];
 
		wi->top += expand_by;
 
		wi->bottom += expand_by;
 
	}
 

	
 
	w->height += expand_by;
 
	SetWindowDirty(w);
 
}
 

	
 
static void DrawBuildVehicleWindow(Window *w)
 
{
 
	const buildvehicle_d *bv = &WP(w, buildvehicle_d);
 
@@ -808,7 +829,9 @@ static void DrawBuildVehicleWindow(Windo
 

	
 
	if (bv->sel_engine != INVALID_ENGINE) {
 
		const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
 
		DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine);
 
		int text_end = DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine);
 

	
 
		if (text_end > wi->bottom) ExpandPurchaseInfoWidget(w, text_end - wi->bottom);
 
	}
 

	
 
	DrawString(85, 15, _sort_listing[bv->vehicle_type][bv->sort_criteria], 0x10);
src/vehicle_gui.h
Show inline comments
 
@@ -32,7 +32,7 @@ static inline bool ValidVLWFlags(uint16 
 

	
 
void PlayerVehWndProc(Window *w, WindowEvent *e);
 

	
 
void DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number);
 
int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number);
 

	
 
void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection);
 
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection);
0 comments (0 inline, 0 general)