mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-04 05:15:21 +00:00
(svn r6910) - Codechange: Supply width of area when drawing purchase info instead of using hardcoded values. (mart3p)
This commit is contained in:
parent
74850a7712
commit
59f78aa2b7
@ -208,7 +208,7 @@ static const StringID _aircraft_sort_listing[] = {
|
||||
* @param x,y location where to draw the info
|
||||
* @param engine_number the engine of which to draw the info of
|
||||
*/
|
||||
void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
void DrawAircraftPurchaseInfo(int x, int y, uint w, EngineID engine_number)
|
||||
{
|
||||
const AircraftVehicleInfo *avi = AircraftVehInfo(engine_number);
|
||||
const Engine *e = GetEngine(engine_number);
|
||||
@ -255,8 +255,7 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
y += 10;
|
||||
|
||||
/* Additional text from NewGRF */
|
||||
// XXX 227 will become a calculated width...
|
||||
y += ShowAdditionalText(x, y, 227, engine_number);
|
||||
y += ShowAdditionalText(x, y, w, engine_number);
|
||||
}
|
||||
|
||||
void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection)
|
||||
@ -427,7 +426,8 @@ static void DrawBuildAircraftWindow(Window *w)
|
||||
}
|
||||
|
||||
if (selected_id != INVALID_ENGINE) {
|
||||
DrawAircraftPurchaseInfo(x, w->widget[BUILD_VEHICLE_WIDGET_PANEL].top + 1, selected_id);
|
||||
const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
|
||||
DrawAircraftPurchaseInfo(x, wi->top + 1, wi->right - wi->left - 2, selected_id);
|
||||
}
|
||||
}
|
||||
DrawString(85, 15, _aircraft_sort_listing[WP(w,buildvehicle_d).sort_criteria], 0x10);
|
||||
|
@ -27,7 +27,7 @@
|
||||
* @param x,y location where to draw the info
|
||||
* @param engine_number the engine of which to draw the info of
|
||||
*/
|
||||
void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
void DrawRoadVehPurchaseInfo(int x, int y, uint w, EngineID engine_number)
|
||||
{
|
||||
const RoadVehicleInfo *rvi = RoadVehInfo(engine_number);
|
||||
const Engine *e = GetEngine(engine_number);
|
||||
@ -65,8 +65,7 @@ void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
y += 10;
|
||||
|
||||
/* Additional text from NewGRF */
|
||||
// XXX 227 will become a calculated width...
|
||||
y += ShowAdditionalText(x, y, 227, engine_number);
|
||||
y += ShowAdditionalText(x, y, w, engine_number);
|
||||
}
|
||||
|
||||
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection)
|
||||
@ -432,7 +431,8 @@ static void DrawNewRoadVehWindow(Window *w)
|
||||
|
||||
WP(w,buildvehicle_d).sel_engine = selected_id;
|
||||
if (selected_id != INVALID_ENGINE) {
|
||||
DrawRoadVehPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
||||
const Widget *wi = &w->widget[4];
|
||||
DrawRoadVehPurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, selected_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
* @param x,y location where to draw the info
|
||||
* @param engine_number the engine of which to draw the info of
|
||||
*/
|
||||
void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
void DrawShipPurchaseInfo(int x, int y, uint w, EngineID engine_number)
|
||||
{
|
||||
YearMonthDay ymd;
|
||||
const ShipVehicleInfo *svi = ShipVehInfo(engine_number);
|
||||
@ -65,8 +65,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
y += 10;
|
||||
|
||||
/* Additional text from NewGRF */
|
||||
// XXX 227 will become a calculated width...
|
||||
y += ShowAdditionalText(x, y, 227, engine_number);
|
||||
y += ShowAdditionalText(x, y, w, engine_number);
|
||||
}
|
||||
|
||||
void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
|
||||
@ -284,7 +283,8 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
|
||||
WP(w,buildvehicle_d).sel_engine = selected_id;
|
||||
|
||||
if (selected_id != INVALID_ENGINE) {
|
||||
DrawShipPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
||||
const Widget *wi = &w->widget[4];
|
||||
DrawShipPurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, selected_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
14
train_gui.c
14
train_gui.c
@ -235,7 +235,7 @@ static const StringID _engine_sort_listing[] = {
|
||||
* @param x,y location where to draw the info
|
||||
* @param engine_number the engine of which to draw the info of
|
||||
*/
|
||||
void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
|
||||
void DrawTrainEnginePurchaseInfo(int x, int y, uint w, EngineID engine_number)
|
||||
{
|
||||
const RailVehicleInfo *rvi = RailVehInfo(engine_number);
|
||||
const Engine *e = GetEngine(engine_number);
|
||||
@ -292,8 +292,7 @@ void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
|
||||
y += 10;
|
||||
|
||||
/* Additional text from NewGRF */
|
||||
// XXX 227 will become a calculated width...
|
||||
y += ShowAdditionalText(x, y, 227, engine_number);
|
||||
y += ShowAdditionalText(x, y, w, engine_number);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,7 +300,7 @@ void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
|
||||
* @param x,y location where to draw the info
|
||||
* @param engine_number the engine of which to draw the info of
|
||||
*/
|
||||
void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
void DrawTrainWagonPurchaseInfo(int x, int y, uint w, EngineID engine_number)
|
||||
{
|
||||
const RailVehicleInfo *rvi = RailVehInfo(engine_number);
|
||||
bool refittable = (EngInfo(engine_number)->refit_mask != 0);
|
||||
@ -337,7 +336,7 @@ void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
}
|
||||
|
||||
/* Additional text from NewGRF */
|
||||
y += ShowAdditionalText(x, y, 227, engine_number);
|
||||
y += ShowAdditionalText(x, y, w, engine_number);
|
||||
}
|
||||
|
||||
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
@ -519,11 +518,12 @@ static void DrawTrainBuildWindow(Window *w)
|
||||
|
||||
if (selected_id != INVALID_ENGINE) {
|
||||
const RailVehicleInfo *rvi = RailVehInfo(selected_id);
|
||||
const Widget *wi = &w->widget[BUILD_TRAIN_WIDGET_PANEL];
|
||||
|
||||
if (rvi->flags & RVI_WAGON) {
|
||||
DrawTrainWagonPurchaseInfo(2, w->widget[BUILD_TRAIN_WIDGET_PANEL].top + 1, selected_id);
|
||||
DrawTrainWagonPurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, selected_id);
|
||||
} else {
|
||||
DrawTrainEnginePurchaseInfo(2, w->widget[BUILD_TRAIN_WIDGET_PANEL].top + 1, selected_id);
|
||||
DrawTrainEnginePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, selected_id);
|
||||
}
|
||||
}
|
||||
DrawString(85, 15, _engine_sort_listing[WP(w,buildvehicle_d).sort_criteria], 0x10);
|
||||
|
@ -990,20 +990,20 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawVehiclePurchaseInfo(const int x, const int y, const EngineID engine_number)
|
||||
static void DrawVehiclePurchaseInfo(const int x, const int y, uint w, const EngineID engine_number)
|
||||
{
|
||||
switch (GetEngine(engine_number)->type) {
|
||||
case VEH_Train:
|
||||
if ((RailVehInfo(engine_number)->flags & RVI_WAGON) == 0) {
|
||||
DrawTrainEnginePurchaseInfo(x, y, engine_number);
|
||||
DrawTrainEnginePurchaseInfo(x, y, w, engine_number);
|
||||
} else {
|
||||
DrawTrainWagonPurchaseInfo(x, y, engine_number);
|
||||
DrawTrainWagonPurchaseInfo(x, y, w, engine_number);
|
||||
}
|
||||
break;
|
||||
|
||||
case VEH_Road: DrawRoadVehPurchaseInfo(x, y, engine_number); break;
|
||||
case VEH_Ship: DrawShipPurchaseInfo(x, y, engine_number); break;
|
||||
case VEH_Aircraft: DrawAircraftPurchaseInfo(x, y, engine_number); break;
|
||||
case VEH_Road: DrawRoadVehPurchaseInfo(x, y, w, engine_number); break;
|
||||
case VEH_Ship: DrawShipPurchaseInfo(x, y, w, engine_number); break;
|
||||
case VEH_Aircraft: DrawAircraftPurchaseInfo(x, y, w, engine_number); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
@ -1080,7 +1080,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
||||
SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED);
|
||||
}
|
||||
|
||||
DrawString(145, 87 + w->resize.step_height * w->vscroll.cap, STR_02BD, 0x10);
|
||||
DrawString(145, w->widget[5].top + 1, STR_02BD, 0x10);
|
||||
|
||||
/* now we draw the two arrays according to what we just counted */
|
||||
DrawEngineArrayInReplaceWindow(w, x, y, x2, y2, pos, pos2, sel[0], sel[1], selected_id[0], selected_id[1]);
|
||||
@ -1090,7 +1090,8 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
||||
/* now we draw the info about the vehicles we selected */
|
||||
for (i = 0 ; i < 2 ; i++) {
|
||||
if (selected_id[i] != INVALID_ENGINE) {
|
||||
DrawVehiclePurchaseInfo((i == 1) ? 230 : 2 , 15 + (w->resize.step_height * w->vscroll.cap), selected_id[i]);
|
||||
const Widget *wi = &w->widget[i == 0 ? 3 : 11];
|
||||
DrawVehiclePurchaseInfo(wi->left + 2 , wi->top + 1, wi->right - wi->left - 2, selected_id[i]);
|
||||
}
|
||||
}
|
||||
} break; // end of paint
|
||||
|
@ -32,11 +32,11 @@ static inline bool ValidVLWFlags(uint16 flags)
|
||||
|
||||
void PlayerVehWndProc(Window *w, WindowEvent *e);
|
||||
|
||||
void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number);
|
||||
void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number);
|
||||
void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number);
|
||||
void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number);
|
||||
void DrawShipPurchaseInfo(int x, int y, EngineID engine_number);
|
||||
void DrawTrainEnginePurchaseInfo(int x, int y, uint w, EngineID engine_number);
|
||||
void DrawTrainWagonPurchaseInfo(int x, int y, uint w, EngineID engine_number);
|
||||
void DrawRoadVehPurchaseInfo(int x, int y, uint w, EngineID engine_number);
|
||||
void DrawAircraftPurchaseInfo(int x, int y, uint w, EngineID engine_number);
|
||||
void DrawShipPurchaseInfo(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);
|
||||
|
Loading…
Reference in New Issue
Block a user