From 09aadafda1dfb08780fade5a52289a0742f84674 Mon Sep 17 00:00:00 2001 From: hackykid Date: Sun, 5 Jun 2005 23:01:10 +0000 Subject: (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later. - Add: In the purchase details for trains display "(refittable)" after the capacity if the vehicle is refittable. --- aircraft_gui.c | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) (limited to 'aircraft_gui.c') diff --git a/aircraft_gui.c b/aircraft_gui.c index f58184464..4c264fa55 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -15,25 +15,45 @@ #include "player.h" #include "depot.h" - -void Set_DPARAM_Aircraft_Build_Window(uint16 engine_number) +/** + * Draw the purchase info details of an aircraft at a given location. + * @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) { const AircraftVehicleInfo *avi = AircraftVehInfo(engine_number); - Engine *e; + Engine *e = &_engines[engine_number]; YearMonthDay ymd; + ConvertDayToYMD(&ymd, e->intro_date); + /* Purchase cost - Max speed */ SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5); SetDParam(1, avi->max_speed * 8); - SetDParam(2, avi->passenger_capacity); - SetDParam(3, avi->mail_capacity); - SetDParam(4, avi->running_cost * _price.aircraft_running >> 8); - - e = &_engines[engine_number]; - SetDParam(6, e->lifelength); - SetDParam(7, e->reliability * 100 >> 16); - ConvertDayToYMD(&ymd, e->intro_date); - SetDParam(5, ymd.year + 1920); - + DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); + y += 10; + + /* Cargo capacity */ + SetDParam(0, avi->passenger_capacity); + SetDParam(1, avi->mail_capacity); + DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, 0); + y += 10; + + /* Running cost */ + SetDParam(0, avi->running_cost * _price.aircraft_running >> 8); + DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); + y += 10; + + /* Design date - Life length */ + SetDParam(0, ymd.year + 1920); + SetDParam(1, e->lifelength); + DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); + y += 10; + + /* Reliability */ + SetDParam(0, e->reliability * 100 >> 16); + DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, 0); + y += 10; } static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection) @@ -110,9 +130,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e) WP(w,buildtrain_d).sel_engine = selected_id; if (selected_id != -1) { - Set_DPARAM_Aircraft_Build_Window(selected_id); - - DrawString(2, w->widget[4].top + 1, STR_A007_COST_SPEED_CAPACITY_PASSENGERS, 0); + DrawAircraftPurchaseInfo(2, w->widget[4].top + 1, selected_id); } } } break; -- cgit v1.2.3-54-g00ecf