(svn r15808) -Codechange: use the new DrawString API in a number of GUIs

This commit is contained in:
rubidium 2009-03-22 12:01:21 +00:00
parent dfe5dad5f6
commit 57174a9301
11 changed files with 51 additions and 52 deletions

View File

@ -243,7 +243,7 @@ public:
if (_settings_game.economy.station_noise_level) {
/* show the noise of the selected airport */
SetDParam(0, airport->noise_level);
DrawString(2, 206, STR_STATION_NOISE, TC_FROMSTRING);
DrawString(2, this->width - 2, 206, STR_STATION_NOISE, TC_FROMSTRING);
y_noise_offset = 10;
}

View File

@ -170,7 +170,7 @@ public:
SetDParam(0, b->material);
DrawSprite(b->sprite, b->pal, 3, y);
DrawString(44, y, STR_500D, TC_FROMSTRING);
DrawString(44, this->width, y, STR_500D, TC_FROMSTRING);
y += this->resize.step_height;
}

View File

@ -144,7 +144,7 @@ struct CheatWindow : Window {
virtual void OnPaint()
{
this->DrawWidgets();
DrawStringMultiLine(20, this->width - 40, 15, 45, STR_CHEATS_WARNING, SA_CENTER);
DrawStringMultiLine(20, this->width - 20, 15, 45, STR_CHEATS_WARNING, SA_CENTER);
for (int i = 0, x = 0, y = 45; i != lengthof(_cheats_ui); i++) {
const CheatEntry *ce = &_cheats_ui[i];
@ -186,7 +186,7 @@ struct CheatWindow : Window {
} break;
}
DrawString(50, y + 1, ce->str, TC_FROMSTRING);
DrawString(50, this->width, y + 1, ce->str, TC_FROMSTRING);
y += 12;
}

View File

@ -99,10 +99,10 @@ static void DrawCompanyEconomyStats(const Company *c, bool small)
ExpensesType et = _expenses_list_types[type].et[i];
if (et == INVALID_EXPENSES) {
y += 2;
DrawString(0, 111, y, STR_7020_TOTAL, TC_FROMSTRING, SA_RIGHT);
DrawString(2, 111, y, STR_7020_TOTAL, TC_FROMSTRING, SA_RIGHT);
y += 20;
} else {
DrawString(2, y, STR_7011_CONSTRUCTION + et, TC_FROMSTRING);
DrawString(2, 111, y, STR_7011_CONSTRUCTION + et, TC_FROMSTRING);
y += 10;
}
}
@ -165,18 +165,18 @@ static void DrawCompanyEconomyStats(const Company *c, bool small)
/* draw max loan aligned to loan below (y += 10) */
SetDParam(0, _economy.max_loan);
DrawString(202, y + 10, STR_MAX_LOAN, TC_FROMSTRING);
DrawString(202, 406, y + 10, STR_MAX_LOAN, TC_FROMSTRING);
} else {
y = 15;
}
DrawString(2, y, STR_7026_BANK_BALANCE, TC_FROMSTRING);
DrawString(2, 182, y, STR_7026_BANK_BALANCE, TC_FROMSTRING);
SetDParam(0, c->money);
DrawString(182 - 75, 182, y, STR_7028, TC_FROMSTRING, SA_RIGHT);
y += 10;
DrawString(2, y, STR_7027_LOAN, TC_FROMSTRING);
DrawString(2, 182, y, STR_7027_LOAN, TC_FROMSTRING);
SetDParam(0, c->current_loan);
DrawString(182 - 75, 182, y, STR_7028, TC_FROMSTRING, SA_RIGHT);
@ -201,8 +201,8 @@ static const Widget _company_finances_widgets[] = {
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_GREY, 380, 394, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
{ WWT_STICKYBOX, RESIZE_NONE, COLOUR_GREY, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 406, 14, 13 + 10, 0x0, STR_NULL},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 406, 14 + 10, 47 + 10, 0x0, STR_NULL},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 406, 14, 13 + 10, 0x0, STR_NULL},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 406, 14 + 10, 47 + 10, 0x0, STR_NULL},
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 202, 48 + 10, 59 + 10, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN},
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 203, 406, 48 + 10, 59 + 10, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN},
{ WIDGETS_END},
@ -496,14 +496,14 @@ public:
DrawSprite(c->livery[scheme].in_use ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, 2, y);
}
DrawString(15, y, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
DrawString(15, 165, y, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(c->livery[scheme].colour1), 152, y);
DrawString(165, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD);
DrawString(165, 290, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour1, sel ? TC_WHITE : TC_GOLD);
if (!this->IsWidgetHidden(SCLW_WIDGET_SEC_COL_DROPDOWN)) {
DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(c->livery[scheme].colour2), 277, y);
DrawString(290, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD);
DrawString(290, this->width, y, STR_00D1_DARK_BLUE + c->livery[scheme].colour2, sel ? TC_WHITE : TC_GOLD);
}
y += 14;
@ -1164,7 +1164,7 @@ static const Widget _company_widgets[] = {
* Draws text "Vehicles:" and number of all vehicle types, or "(none)"
* @param company ID of company to print statistics of
*/
static void DrawCompanyVehiclesAmount(CompanyID company)
static void DrawCompanyVehiclesAmount(CompanyID company, int right)
{
const int x = 110;
int y = 63;
@ -1174,7 +1174,7 @@ static void DrawCompanyVehiclesAmount(CompanyID company)
uint air = 0;
uint ship = 0;
DrawString(x, y, STR_7039_VEHICLES, TC_FROMSTRING);
DrawString(x, right, y, STR_7039_VEHICLES, TC_FROMSTRING);
FOR_ALL_VEHICLES(v) {
if (v->owner == company) {
@ -1189,29 +1189,29 @@ static void DrawCompanyVehiclesAmount(CompanyID company)
}
if (train + road + air + ship == 0) {
DrawString(x + 70, y, STR_7042_NONE, TC_FROMSTRING);
DrawString(x + 70, right, y, STR_7042_NONE, TC_FROMSTRING);
} else {
if (train != 0) {
SetDParam(0, train);
DrawString(x + 70, y, STR_TRAINS, TC_FROMSTRING);
DrawString(x + 70, right, y, STR_TRAINS, TC_FROMSTRING);
y += 10;
}
if (road != 0) {
SetDParam(0, road);
DrawString(x + 70, y, STR_ROAD_VEHICLES, TC_FROMSTRING);
DrawString(x + 70, right, y, STR_ROAD_VEHICLES, TC_FROMSTRING);
y += 10;
}
if (air != 0) {
SetDParam(0, air);
DrawString(x + 70, y, STR_AIRCRAFT, TC_FROMSTRING);
DrawString(x + 70, right, y, STR_AIRCRAFT, TC_FROMSTRING);
y += 10;
}
if (ship != 0) {
SetDParam(0, ship);
DrawString(x + 70, y, STR_SHIPS, TC_FROMSTRING);
DrawString(x + 70, right, y, STR_SHIPS, TC_FROMSTRING);
}
}
}
@ -1240,7 +1240,7 @@ static void DrawCompanyOwnerText(const Company *c)
SetDParam(0, amt * 25);
SetDParam(1, c2->index);
DrawString(120, (num++) * height + 116, STR_707D_OWNED_BY, TC_FROMSTRING);
DrawString(120, 359, (num++) * height + 116, STR_707D_OWNED_BY, TC_FROMSTRING);
}
}
}
@ -1316,19 +1316,19 @@ struct CompanyWindow : Window
/* "Inaugurated:" */
SetDParam(0, c->inaugurated_year);
DrawString(110, 23, STR_7038_INAUGURATED, TC_FROMSTRING);
DrawString(110, this->width, 23, STR_7038_INAUGURATED, TC_FROMSTRING);
/* "Colour scheme:" */
DrawString(110, 43, STR_7006_COLOUR_SCHEME, TC_FROMSTRING);
DrawString(110, this->width, 43, STR_7006_COLOUR_SCHEME, TC_FROMSTRING);
/* Draw company-colour bus */
DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->index), 215, 44);
/* "Vehicles:" */
DrawCompanyVehiclesAmount((CompanyID)this->window_number);
DrawCompanyVehiclesAmount((CompanyID)this->window_number, this->width);
/* "Company value:" */
SetDParam(0, CalculateCompanyValue(c));
DrawString(110, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING);
DrawString(110, this->width, 106, STR_7076_COMPANY_VALUE, TC_FROMSTRING);
/* Shares list */
DrawCompanyOwnerText(c);

View File

@ -297,7 +297,7 @@ struct DepotWindow : Window {
DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, x + diff_x, y + diff_y);
SetDParam(0, v->unitnumber);
DrawString(x, y + 2, (uint16)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? STR_00E2 : STR_00E3, TC_FROMSTRING);
DrawString(x, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 2, (uint16)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? STR_00E2 : STR_00E3, TC_FROMSTRING);
}
void DrawDepotWindow(Window *w)
@ -369,7 +369,7 @@ struct DepotWindow : Window {
const Vehicle *u;
DrawTrainImage(v, x + 50, y, this->sel, this->hscroll.cap - 29, 0);
DrawString(x, y + 2, STR_8816, TC_FROMSTRING);
DrawString(x, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 2, STR_8816, TC_FROMSTRING);
/* Draw the train counter */
i = 0;

View File

@ -397,7 +397,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
}
int right = DrawString(0, 326, 91, STR_HEIGHTMAP_SIZE, TC_BLACK, SA_RIGHT);
DrawString( 12, 91, STR_HEIGHTMAP_NAME, TC_BLACK);
DrawString( 12, 114, 91, STR_HEIGHTMAP_NAME, TC_BLACK);
SetDParamStr(0, this->name);
DrawString(114, right - 5, 91, STR_JUST_RAW_STRING, TC_ORANGE);
}

View File

@ -1422,7 +1422,7 @@ static void DrawFiosTexts(uint maxw)
}
if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
DrawString(2, 37, str, TC_FROMSTRING);
DrawString(2, 2 + maxw, 37, str, TC_FROMSTRING);
DrawString(2, 2 + maxw, 27, path, TC_BLACK);
}

View File

@ -239,7 +239,7 @@ public:
SetDParam(0, i);
SetDParam(2, i);
SetDParam(1, SPECSTR_SONGNAME);
DrawString(4, 23 + (i - 1) * 6, (i < 10) ? STR_01EC_0 : STR_01ED, TC_FROMSTRING);
DrawString(this->widget[MTSW_LIST_RIGHT].left + 2, this->widget[MTSW_LIST_RIGHT].right - 2, 23 + (i - 1) * 6, (i < 10) ? STR_01EC_0 : STR_01ED, TC_FROMSTRING);
}
for (i = 0; i != 6; i++) {
@ -256,7 +256,7 @@ public:
SetDParam(0, i);
SetDParam(1, SPECSTR_SONGNAME);
SetDParam(2, i);
DrawString(252, y, (i < 10) ? STR_01EC_0 : STR_01ED, TC_FROMSTRING);
DrawString(this->widget[MTSW_LIST_LEFT].left + 2, this->widget[MTSW_LIST_LEFT].right - 2, y, (i < 10) ? STR_01EC_0 : STR_01ED, TC_FROMSTRING);
y += 6;
}
}
@ -416,7 +416,7 @@ public:
SetDParam(0, _music_wnd_cursong);
str = (_music_wnd_cursong < 10) ? STR_01E4_0 : STR_01E5;
}
DrawString(62, 46, str, TC_FROMSTRING);
DrawString(this->widget[MW_INFO].left + 3, this->widget[MW_INFO].right - 3, 46, str, TC_FROMSTRING);
str = STR_01E6;
if (_song_is_active != 0 && _music_wnd_cursong != 0) {
@ -426,8 +426,7 @@ public:
}
DrawString(this->widget[MW_INFO].left, this->widget[MW_INFO].right, 46, str, TC_FROMSTRING, SA_CENTER);
DrawString(60, 38, STR_01E8_TRACK_XTITLE, TC_FROMSTRING);
DrawString(this->widget[MW_INFO].left + 1, this->widget[MW_INFO].right, 38, STR_01E8_TRACK_XTITLE, TC_FROMSTRING);
for (i = 0; i != 6; i++) {
DrawString(this->widget[i + MW_ALL].left, this->widget[i + MW_ALL].right, 59, STR_01D5_ALL + i, msf.playlist == i ? TC_WHITE : TC_BLACK, SA_CENTER);

View File

@ -525,7 +525,7 @@ public:
/* Draw the total download size */
SetDParam(0, filesize);
DrawString(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].bottom - 12, STR_CONTENT_TOTAL_DOWNLOAD_SIZE, TC_BLACK);
DrawString(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, this->widget[NCLWW_DETAILS].bottom - 12, STR_CONTENT_TOTAL_DOWNLOAD_SIZE, TC_BLACK);
}
virtual void OnDoubleClick(Point pt, int widget)

View File

@ -833,7 +833,7 @@ public:
if (i - this->vscroll.pos < this->vscroll.cap) {
str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
DrawString(2, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
DrawString(this->widget[ORDER_WIDGET_ORDER_LIST].left + 2, this->widget[ORDER_WIDGET_ORDER_LIST].right - 2, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
}
}

View File

@ -109,7 +109,7 @@ public:
int y = this->widget[TWA_RATING_INFO].top + 1;
DrawString(2, y, STR_2023_TRANSPORT_COMPANY_RATINGS, TC_FROMSTRING);
DrawString(this->widget[TWA_RATING_INFO].left + 2, this->widget[TWA_RATING_INFO].right - 2, y, STR_2023_TRANSPORT_COMPANY_RATINGS, TC_FROMSTRING);
y += 10;
/* Draw list of companies */
@ -137,7 +137,7 @@ public:
DrawSprite(SPR_BLOT, PALETTE_TO_RED, 18, y);
}
DrawString(28, y, STR_2024, TC_FROMSTRING);
DrawString(this->widget[TWA_RATING_INFO].left + 28, this->widget[TWA_RATING_INFO].right - 2, y, STR_2024, TC_FROMSTRING);
y += 10;
}
}
@ -153,7 +153,7 @@ public:
int pos = this->vscroll.pos;
if (--pos < 0) {
DrawString(2, y, STR_2045_ACTIONS_AVAILABLE, TC_FROMSTRING);
DrawString(this->widget[TWA_COMMAND_LIST].left + 2, this->widget[TWA_COMMAND_LIST].right - 2, y, STR_2045_ACTIONS_AVAILABLE, TC_FROMSTRING);
y += 10;
}
@ -161,7 +161,7 @@ public:
if (pos <= -5) break; ///< Draw only the 5 fitting lines
if ((buttons & 1) && --pos < 0) {
DrawString(3, y, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i, TC_ORANGE);
DrawString(this->widget[TWA_COMMAND_LIST].left + 3, this->widget[TWA_COMMAND_LIST].right - 2, y, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i, TC_ORANGE);
y += 10;
}
}
@ -277,15 +277,15 @@ public:
SetDParam(0, this->town->population);
SetDParam(1, this->town->num_houses);
DrawString(2, y, STR_2006_POPULATION, TC_FROMSTRING);
DrawString(2, this->width - 2, y, STR_2006_POPULATION, TC_FROMSTRING);
SetDParam(0, this->town->act_pass);
SetDParam(1, this->town->max_pass);
DrawString(2, y += 10, STR_200D_PASSENGERS_LAST_MONTH_MAX, TC_FROMSTRING);
DrawString(2, this->width - 2, y += 10, STR_200D_PASSENGERS_LAST_MONTH_MAX, TC_FROMSTRING);
SetDParam(0, this->town->act_mail);
SetDParam(1, this->town->max_mail);
DrawString(2, y += 10, STR_200E_MAIL_LAST_MONTH_MAX, TC_FROMSTRING);
DrawString(2, this->width - 2, y += 10, STR_200E_MAIL_LAST_MONTH_MAX, TC_FROMSTRING);
uint cargo_needed_for_growth = 0;
switch (_settings_game.game_creation.landscape) {
@ -301,7 +301,7 @@ public:
}
if (cargo_needed_for_growth > 0) {
DrawString(2, y += 10, STR_CARGO_FOR_TOWNGROWTH, TC_FROMSTRING);
DrawString(2, this->width - 2, y += 10, STR_CARGO_FOR_TOWNGROWTH, TC_FROMSTRING);
CargoID first_food_cargo = CT_INVALID;
StringID food_name = STR_001E_FOOD;
@ -322,20 +322,20 @@ public:
if (first_food_cargo != CT_INVALID && this->town->act_food > 0) {
SetDParam(0, first_food_cargo);
SetDParam(1, this->town->act_food);
DrawString(2, y += 10, STR_CARGO_FOR_TOWNGROWTH_LAST_MONTH, TC_FROMSTRING);
DrawString(2, this->width - 2, y += 10, STR_CARGO_FOR_TOWNGROWTH_LAST_MONTH, TC_FROMSTRING);
} else {
SetDParam(0, food_name);
DrawString(2, y += 10, STR_CARGO_FOR_TOWNGROWTH_REQUIRED, TC_FROMSTRING);
DrawString(2, this->width - 2, y += 10, STR_CARGO_FOR_TOWNGROWTH_REQUIRED, TC_FROMSTRING);
}
if (cargo_needed_for_growth > 1) {
if (first_water_cargo != CT_INVALID && this->town->act_water > 0) {
SetDParam(0, first_water_cargo);
SetDParam(1, this->town->act_water);
DrawString(2, y += 10, STR_CARGO_FOR_TOWNGROWTH_LAST_MONTH, TC_FROMSTRING);
DrawString(2, this->width - 2, y += 10, STR_CARGO_FOR_TOWNGROWTH_LAST_MONTH, TC_FROMSTRING);
} else {
SetDParam(0, water_name);
DrawString(2, y += 10, STR_CARGO_FOR_TOWNGROWTH_REQUIRED, TC_FROMSTRING);
DrawString(2, this->width - 2, y += 10, STR_CARGO_FOR_TOWNGROWTH_REQUIRED, TC_FROMSTRING);
}
}
}
@ -346,7 +346,7 @@ public:
if (_settings_game.economy.station_noise_level) {
SetDParam(0, this->town->noise_reached);
SetDParam(1, this->town->MaxTownNoise());
DrawString(2, y += 10, STR_NOISE_IN_TOWN, TC_FROMSTRING);
DrawString(2, this->width - 2, y += 10, STR_NOISE_IN_TOWN, TC_FROMSTRING);
}
}
@ -566,7 +566,7 @@ public:
SetDParam(0, t->index);
SetDParam(1, t->population);
DrawString(2, y, STR_2057, TC_FROMSTRING);
DrawString(2, this->width - 2, y, STR_2057, TC_FROMSTRING);
y += 10;
i++;
@ -574,7 +574,7 @@ public:
}
SetDParam(0, GetWorldPopulation());
DrawString(3, this->height - 12 + 2, STR_TOWN_POPULATION, TC_FROMSTRING);
DrawString(3, this->width - 3, this->height - 12 + 2, STR_TOWN_POPULATION, TC_FROMSTRING);
}
}