1
0
Fork 0

(svn r15806) -Codechange: pass both left and right to the vehicle details drawing functions instead of only the left.

release/1.0
rubidium 2009-03-22 10:37:51 +00:00
parent 8324f65b4b
commit ead0a6a6e5
6 changed files with 101 additions and 58 deletions

View File

@ -95,10 +95,10 @@ struct AIListWindow : public Window {
/* Some info about the currently selected AI. */ /* Some info about the currently selected AI. */
if (selected_info != NULL) { if (selected_info != NULL) {
int y = this->widget[AIL_WIDGET_INFO_BG].top + 6; int y = this->widget[AIL_WIDGET_INFO_BG].top + 6;
int x = DrawString(4, y, STR_AI_AUTHOR, TC_BLACK); int x = DrawString(this->widget[AIL_WIDGET_LIST].left + 4, this->widget[AIL_WIDGET_LIST].right - 4, y, STR_AI_AUTHOR, TC_BLACK);
DrawString(x + 5, this->widget[AIL_WIDGET_LIST].right - 4, y, selected_info->GetAuthor(), TC_BLACK); DrawString(x + 5, this->widget[AIL_WIDGET_LIST].right - 4, y, selected_info->GetAuthor(), TC_BLACK);
y += 13; y += 13;
x = DrawString(4, y, STR_AI_VERSION, TC_BLACK); x = DrawString(this->widget[AIL_WIDGET_LIST].left + 4, this->widget[AIL_WIDGET_LIST].right - 4, y, STR_AI_VERSION, TC_BLACK);
static char buf[8]; static char buf[8];
sprintf(buf, "%d", selected_info->GetVersion()); sprintf(buf, "%d", selected_info->GetVersion());
DrawString(x + 5, this->widget[AIL_WIDGET_LIST].right - 4, y, buf, TC_BLACK); DrawString(x + 5, this->widget[AIL_WIDGET_LIST].right - 4, y, buf, TC_BLACK);
@ -461,7 +461,7 @@ struct AIConfigWindow : public Window {
byte max_competitors = _settings_newgame.difficulty.max_no_competitors; byte max_competitors = _settings_newgame.difficulty.max_no_competitors;
DrawArrowButtons(10, 18, COLOUR_YELLOW, this->clicked_button ? 1 + !!this->clicked_increase : 0, max_competitors > 0, max_competitors < MAX_COMPANIES - 1); DrawArrowButtons(10, 18, COLOUR_YELLOW, this->clicked_button ? 1 + !!this->clicked_increase : 0, max_competitors > 0, max_competitors < MAX_COMPANIES - 1);
SetDParam(0, _settings_newgame.difficulty.max_no_competitors); SetDParam(0, _settings_newgame.difficulty.max_no_competitors);
DrawString(36, 18, STR_6805_MAXIMUM_NO_COMPETITORS, TC_FROMSTRING); DrawString(36, this->widget[AIC_WIDGET_BACKGROUND].right, 18, STR_6805_MAXIMUM_NO_COMPETITORS, TC_FROMSTRING);
int y = this->widget[AIC_WIDGET_LIST].top; int y = this->widget[AIC_WIDGET_LIST].top;
for (int i = this->vscroll.pos; i < this->vscroll.pos + this->vscroll.cap && i < MAX_COMPANIES; i++) { for (int i = this->vscroll.pos; i < this->vscroll.pos + this->vscroll.cap && i < MAX_COMPANIES; i++) {

View File

@ -15,13 +15,14 @@
#include "table/strings.h" #include "table/strings.h"
/** /**
* Draw the details for the given vehicle at the position (x, y) * Draw the details for the given vehicle at the given position
* *
* @param v current vehicle * @param v current vehicle
* @param x The x coordinate * @param left The left most coordinate to draw
* @param y The y coordinate * @param right The right most coordinate to draw
* @param y The y coordinate
*/ */
void DrawAircraftDetails(const Vehicle *v, int x, int y) void DrawAircraftDetails(const Vehicle *v, int left, int right, int y)
{ {
int y_offset = (v->Next()->cargo_cap != 0) ? -11 : 0; int y_offset = (v->Next()->cargo_cap != 0) ? -11 : 0;
Money feeder_share = 0; Money feeder_share = 0;
@ -31,14 +32,14 @@ void DrawAircraftDetails(const Vehicle *v, int x, int y)
SetDParam(0, u->engine_type); SetDParam(0, u->engine_type);
SetDParam(1, u->build_year); SetDParam(1, u->build_year);
SetDParam(2, u->value); SetDParam(2, u->value);
DrawString(x, y, STR_A011_BUILT_VALUE, TC_FROMSTRING); DrawString(left, right, y, STR_A011_BUILT_VALUE, TC_FROMSTRING);
SetDParam(0, u->cargo_type); SetDParam(0, u->cargo_type);
SetDParam(1, u->cargo_cap); SetDParam(1, u->cargo_cap);
SetDParam(2, u->Next()->cargo_type); SetDParam(2, u->Next()->cargo_type);
SetDParam(3, u->Next()->cargo_cap); SetDParam(3, u->Next()->cargo_cap);
SetDParam(4, GetCargoSubtypeText(u)); SetDParam(4, GetCargoSubtypeText(u));
DrawString(x, y + 10, (u->Next()->cargo_cap != 0) ? STR_A019_CAPACITY : STR_A01A_CAPACITY, TC_FROMSTRING); DrawString(left, right, y + 10, (u->Next()->cargo_cap != 0) ? STR_A019_CAPACITY : STR_A01A_CAPACITY, TC_FROMSTRING);
} }
if (u->cargo_cap != 0) { if (u->cargo_cap != 0) {
@ -50,14 +51,14 @@ void DrawAircraftDetails(const Vehicle *v, int x, int y)
SetDParam(0, u->cargo_type); SetDParam(0, u->cargo_type);
SetDParam(1, cargo_count); SetDParam(1, cargo_count);
SetDParam(2, u->cargo.Source()); SetDParam(2, u->cargo.Source());
DrawString(x, y + 21 + y_offset, STR_8813_FROM, TC_FROMSTRING); DrawString(left, right, y + 21 + y_offset, STR_8813_FROM, TC_FROMSTRING);
feeder_share += u->cargo.FeederShare(); feeder_share += u->cargo.FeederShare();
} }
} }
} }
SetDParam(0, feeder_share); SetDParam(0, feeder_share);
DrawString(x, y + 33 + y_offset, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING); DrawString(left, right, y + 33 + y_offset, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
} }

View File

@ -14,7 +14,15 @@
#include "table/sprites.h" #include "table/sprites.h"
#include "table/strings.h" #include "table/strings.h"
void DrawRoadVehDetails(const Vehicle *v, int x, int y) /**
* Draw the details for the given vehicle at the given position
*
* @param v current vehicle
* @param left The left most coordinate to draw
* @param right The right most coordinate to draw
* @param y The y coordinate
*/
void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
{ {
uint y_offset = RoadVehHasArticPart(v) ? 15 : 0; uint y_offset = RoadVehHasArticPart(v) ? 15 : 0;
StringID str; StringID str;
@ -23,7 +31,7 @@ void DrawRoadVehDetails(const Vehicle *v, int x, int y)
SetDParam(0, v->engine_type); SetDParam(0, v->engine_type);
SetDParam(1, v->build_year); SetDParam(1, v->build_year);
SetDParam(2, v->value); SetDParam(2, v->value);
DrawString(x, y + y_offset, STR_9011_BUILT_VALUE, TC_FROMSTRING); DrawString(left, right, y + y_offset, STR_9011_BUILT_VALUE, TC_FROMSTRING);
if (RoadVehHasArticPart(v)) { if (RoadVehHasArticPart(v)) {
AcceptedCargo max_cargo; AcceptedCargo max_cargo;
@ -65,7 +73,7 @@ void DrawRoadVehDetails(const Vehicle *v, int x, int y)
} }
SetDParamStr(0, capacity); SetDParamStr(0, capacity);
DrawString(x, 300, y + 10 + y_offset, STR_JUST_RAW_STRING, TC_BLUE); DrawString(left, right, y + 10 + y_offset, STR_JUST_RAW_STRING, TC_BLUE);
for (const Vehicle *u = v; u != NULL; u = u->Next()) { for (const Vehicle *u = v; u != NULL; u = u->Next()) {
if (u->cargo_cap == 0) continue; if (u->cargo_cap == 0) continue;
@ -78,7 +86,7 @@ void DrawRoadVehDetails(const Vehicle *v, int x, int y)
str = STR_8813_FROM; str = STR_8813_FROM;
feeder_share += u->cargo.FeederShare(); feeder_share += u->cargo.FeederShare();
} }
DrawString(x, y + 21 + y_offset, str, TC_FROMSTRING); DrawString(left, right, y + 21 + y_offset, str, TC_FROMSTRING);
y_offset += 11; y_offset += 11;
} }
@ -88,7 +96,7 @@ void DrawRoadVehDetails(const Vehicle *v, int x, int y)
SetDParam(0, v->cargo_type); SetDParam(0, v->cargo_type);
SetDParam(1, v->cargo_cap); SetDParam(1, v->cargo_cap);
SetDParam(2, GetCargoSubtypeText(v)); SetDParam(2, GetCargoSubtypeText(v));
DrawString(x, y + 10 + y_offset, STR_9012_CAPACITY, TC_FROMSTRING); DrawString(left, right, y + 10 + y_offset, STR_9012_CAPACITY, TC_FROMSTRING);
str = STR_8812_EMPTY; str = STR_8812_EMPTY;
if (!v->cargo.Empty()) { if (!v->cargo.Empty()) {
@ -98,12 +106,12 @@ void DrawRoadVehDetails(const Vehicle *v, int x, int y)
str = STR_8813_FROM; str = STR_8813_FROM;
feeder_share += v->cargo.FeederShare(); feeder_share += v->cargo.FeederShare();
} }
DrawString(x, y + 21 + y_offset, str, TC_FROMSTRING); DrawString(left, right, y + 21 + y_offset, str, TC_FROMSTRING);
} }
/* Draw Transfer credits text */ /* Draw Transfer credits text */
SetDParam(0, feeder_share); SetDParam(0, feeder_share);
DrawString(x, y + 33 + y_offset, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING); DrawString(left, right, y + 33 + y_offset, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
} }

View File

@ -35,23 +35,24 @@ void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
} }
/** /**
* Draw the details for the given vehicle at the position (x, y) * Draw the details for the given vehicle at the given position
* *
* @param v current vehicle * @param v current vehicle
* @param x The x coordinate * @param left The left most coordinate to draw
* @param y The y coordinate * @param right The right most coordinate to draw
* @param y The y coordinate
*/ */
void DrawShipDetails(const Vehicle *v, int x, int y) void DrawShipDetails(const Vehicle *v, int left, int right, int y)
{ {
SetDParam(0, v->engine_type); SetDParam(0, v->engine_type);
SetDParam(1, v->build_year); SetDParam(1, v->build_year);
SetDParam(2, v->value); SetDParam(2, v->value);
DrawString(x, y, STR_9816_BUILT_VALUE, TC_FROMSTRING); DrawString(left, right, y, STR_9816_BUILT_VALUE, TC_FROMSTRING);
SetDParam(0, v->cargo_type); SetDParam(0, v->cargo_type);
SetDParam(1, v->cargo_cap); SetDParam(1, v->cargo_cap);
SetDParam(2, GetCargoSubtypeText(v)); SetDParam(2, GetCargoSubtypeText(v));
DrawString(x, y + 10, STR_9817_CAPACITY, TC_FROMSTRING); DrawString(left, right, y + 10, STR_9817_CAPACITY, TC_FROMSTRING);
StringID str = STR_8812_EMPTY; StringID str = STR_8812_EMPTY;
if (!v->cargo.Empty()) { if (!v->cargo.Empty()) {
@ -60,9 +61,9 @@ void DrawShipDetails(const Vehicle *v, int x, int y)
SetDParam(2, v->cargo.Source()); SetDParam(2, v->cargo.Source());
str = STR_8813_FROM; str = STR_8813_FROM;
} }
DrawString(x, y + 21, str, TC_FROMSTRING); DrawString(left, right, y + 21, str, TC_FROMSTRING);
/* Draw Transfer credits text */ /* Draw Transfer credits text */
SetDParam(0, v->cargo.FeederShare()); SetDParam(0, v->cargo.FeederShare());
DrawString(x, y + 33, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING); DrawString(left, right, y + 33, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
} }

View File

@ -110,7 +110,15 @@ void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int cou
_cur_dpi = old_dpi; _cur_dpi = old_dpi;
} }
static void TrainDetailsCargoTab(const Vehicle *v, int x, int y) /**
* Draw the details cargo tab for the given vehicle at the given position
*
* @param v current vehicle
* @param left The left most coordinate to draw
* @param right The right most coordinate to draw
* @param y The y coordinate
*/
static void TrainDetailsCargoTab(const Vehicle *v, int left, int right, int y)
{ {
if (v->cargo_cap != 0) { if (v->cargo_cap != 0) {
StringID str = STR_8812_EMPTY; StringID str = STR_8812_EMPTY;
@ -122,32 +130,48 @@ static void TrainDetailsCargoTab(const Vehicle *v, int x, int y)
SetDParam(3, _settings_game.vehicle.freight_trains); SetDParam(3, _settings_game.vehicle.freight_trains);
str = FreightWagonMult(v->cargo_type) > 1 ? STR_FROM_MULT : STR_8813_FROM; str = FreightWagonMult(v->cargo_type) > 1 ? STR_FROM_MULT : STR_8813_FROM;
} }
DrawString(x, y, str, TC_FROMSTRING); DrawString(left, right, y, str, TC_FROMSTRING);
} }
} }
static void TrainDetailsInfoTab(const Vehicle *v, int x, int y) /**
* Draw the details info tab for the given vehicle at the given position
*
* @param v current vehicle
* @param left The left most coordinate to draw
* @param right The right most coordinate to draw
* @param y The y coordinate
*/
static void TrainDetailsInfoTab(const Vehicle *v, int left, int right, int y)
{ {
if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) { if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
SetDParam(0, v->engine_type); SetDParam(0, v->engine_type);
SetDParam(1, v->value); SetDParam(1, v->value);
DrawString(x, y, STR_882D_VALUE, TC_BLACK); DrawString(left, right, y, STR_882D_VALUE, TC_BLACK);
} else { } else {
SetDParam(0, v->engine_type); SetDParam(0, v->engine_type);
SetDParam(1, v->build_year); SetDParam(1, v->build_year);
SetDParam(2, v->value); SetDParam(2, v->value);
DrawString(x, y, STR_882C_BUILT_VALUE, TC_BLACK); DrawString(left, right, y, STR_882C_BUILT_VALUE, TC_BLACK);
} }
} }
static void TrainDetailsCapacityTab(const Vehicle *v, int x, int y) /**
* Draw the details capacity tab for the given vehicle at the given position
*
* @param v current vehicle
* @param left The left most coordinate to draw
* @param right The right most coordinate to draw
* @param y The y coordinate
*/
static void TrainDetailsCapacityTab(const Vehicle *v, int left, int right, int y)
{ {
if (v->cargo_cap != 0) { if (v->cargo_cap != 0) {
SetDParam(0, v->cargo_type); SetDParam(0, v->cargo_type);
SetDParam(1, v->cargo_cap); SetDParam(1, v->cargo_cap);
SetDParam(2, GetCargoSubtypeText(v)); SetDParam(2, GetCargoSubtypeText(v));
SetDParam(3, _settings_game.vehicle.freight_trains); SetDParam(3, _settings_game.vehicle.freight_trains);
DrawString(x, y, FreightWagonMult(v->cargo_type) > 1 ? STR_CAPACITY_MULT : STR_013F_CAPACITY, TC_FROMSTRING); DrawString(left, right, y, FreightWagonMult(v->cargo_type) > 1 ? STR_CAPACITY_MULT : STR_013F_CAPACITY, TC_FROMSTRING);
} }
} }
@ -182,12 +206,20 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab)
return num; return num;
} }
void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab) /**
* Draw the details for the given vehicle at the given position
*
* @param v current vehicle
* @param left The left most coordinate to draw
* @param right The right most coordinate to draw
* @param y The y coordinate
*/
void DrawTrainDetails(const Vehicle *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab)
{ {
/* draw the first 3 details tabs */ /* draw the first 3 details tabs */
if (det_tab != 3) { if (det_tab != 3) {
const Vehicle *u = v; const Vehicle *u = v;
x = 1; int x = 1;
for (;;) { for (;;) {
if (--vscroll_pos < 0 && vscroll_pos >= -vscroll_cap) { if (--vscroll_pos < 0 && vscroll_pos >= -vscroll_cap) {
int dx = 0; int dx = 0;
@ -204,14 +236,14 @@ void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vs
int py = y + 2; int py = y + 2;
switch (det_tab) { switch (det_tab) {
default: NOT_REACHED(); default: NOT_REACHED();
case 0: TrainDetailsCargoTab( v, px, py); break; case 0: TrainDetailsCargoTab( v, px, right, py); break;
case 1: case 1:
/* Only show name and value for the 'real' part */ /* Only show name and value for the 'real' part */
if (!IsArticulatedPart(v)) { if (!IsArticulatedPart(v)) {
TrainDetailsInfoTab(v, px, py); TrainDetailsInfoTab(v, px, right, py);
} }
break; break;
case 2: TrainDetailsCapacityTab(v, px, py); break; case 2: TrainDetailsCapacityTab(v, px, right, py); break;
} }
y += 14; y += 14;
@ -239,7 +271,7 @@ void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vs
} }
/* draw total cargo tab */ /* draw total cargo tab */
DrawString(x, y + 2, STR_TOTAL_CAPACITY_TEXT, TC_FROMSTRING); DrawString(left, right, y + 2, STR_TOTAL_CAPACITY_TEXT, TC_FROMSTRING);
for (CargoID i = 0; i < NUM_CARGO; i++) { for (CargoID i = 0; i < NUM_CARGO; i++) {
if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) { if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
y += 14; y += 14;
@ -248,10 +280,10 @@ void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vs
SetDParam(2, i); // {SHORTCARGO} #1 SetDParam(2, i); // {SHORTCARGO} #1
SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2 SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
SetDParam(4, _settings_game.vehicle.freight_trains); SetDParam(4, _settings_game.vehicle.freight_trains);
DrawString(x, y + 2, FreightWagonMult(i) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_TOTAL_CAPACITY, TC_FROMSTRING); DrawString(left, right, y + 2, FreightWagonMult(i) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_TOTAL_CAPACITY, TC_FROMSTRING);
} }
} }
SetDParam(0, feeder_share); SetDParam(0, feeder_share);
DrawString(x, y + 15, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING); DrawString(left, right, y + 15, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
} }
} }

View File

@ -1275,10 +1275,10 @@ static const StringID _vehicle_translation_table[][4] = {
extern int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab); extern int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab);
extern void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab); extern void DrawTrainDetails(const Vehicle *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab);
extern void DrawRoadVehDetails(const Vehicle *v, int x, int y); extern void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y);
extern void DrawShipDetails(const Vehicle *v, int x, int y); extern void DrawShipDetails(const Vehicle *v, int left, int right, int y);
extern void DrawAircraftDetails(const Vehicle *v, int x, int y); extern void DrawAircraftDetails(const Vehicle *v, int left, int right, int y);
struct VehicleDetailsWindow : Window { struct VehicleDetailsWindow : Window {
int tab; int tab;
@ -1359,22 +1359,23 @@ struct VehicleDetailsWindow : Window {
} }
/** /**
* Draw the details for the given vehicle at the position (x, y) of the Details windows * Draw the details for the given vehicle at the position of the Details windows
* *
* @param v current vehicle * @param v current vehicle
* @param x The x coordinate * @param left The left most coordinate to draw
* @param y The y coordinate * @param right The right most coordinate to draw
* @param y The y coordinate
* @param vscroll_pos (train only) * @param vscroll_pos (train only)
* @param vscroll_cap (train only) * @param vscroll_cap (train only)
* @param det_tab (train only) * @param det_tab (train only)
*/ */
static void DrawVehicleDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint vscroll_cap, byte det_tab) static void DrawVehicleDetails(const Vehicle *v, int left, int right, int y, int vscroll_pos, uint vscroll_cap, byte det_tab)
{ {
switch (v->type) { switch (v->type) {
case VEH_TRAIN: DrawTrainDetails(v, x, y, vscroll_pos, vscroll_cap, det_tab); break; case VEH_TRAIN: DrawTrainDetails(v, left, right, y, vscroll_pos, vscroll_cap, det_tab); break;
case VEH_ROAD: DrawRoadVehDetails(v, x, y); break; case VEH_ROAD: DrawRoadVehDetails(v, left, right, y); break;
case VEH_SHIP: DrawShipDetails(v, x, y); break; case VEH_SHIP: DrawShipDetails(v, left, right, y); break;
case VEH_AIRCRAFT: DrawAircraftDetails(v, x, y); break; case VEH_AIRCRAFT: DrawAircraftDetails(v, left, right, y); break;
default: NOT_REACHED(); default: NOT_REACHED();
} }
} }
@ -1457,14 +1458,14 @@ struct VehicleDetailsWindow : Window {
switch (v->type) { switch (v->type) {
case VEH_TRAIN: case VEH_TRAIN:
DrawVehicleDetails(v, 2, 57, this->vscroll.pos, this->vscroll.cap, det_tab); DrawVehicleDetails(v, 2, this->width - 2, 57, this->vscroll.pos, this->vscroll.cap, det_tab);
break; break;
case VEH_ROAD: case VEH_ROAD:
case VEH_SHIP: case VEH_SHIP:
case VEH_AIRCRAFT: case VEH_AIRCRAFT:
DrawVehicleImage(v, 3, 57, INVALID_VEHICLE, 0, 0); DrawVehicleImage(v, 3, 57, INVALID_VEHICLE, 0, 0);
DrawVehicleDetails(v, 75, 57, this->vscroll.pos, this->vscroll.cap, det_tab); DrawVehicleDetails(v, 75, this->width - 2, 57, this->vscroll.pos, this->vscroll.cap, det_tab);
break; break;
default: NOT_REACHED(); default: NOT_REACHED();