mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 07:29:44 +00:00
(svn r15797) -Codechange: make users of the old DrawStringMultiLine use the new one.
This commit is contained in:
parent
676bf31e82
commit
d837fc4d03
@ -104,7 +104,7 @@ struct AIListWindow : public Window {
|
||||
DrawString(x + 5, this->widget[AIL_WIDGET_LIST].right - 4, y, buf, TC_BLACK);
|
||||
y += 13;
|
||||
SetDParamStr(0, selected_info->GetDescription());
|
||||
DrawStringMultiLine(4, y, STR_JUST_RAW_STRING, this->width - 8, this->widget[AIL_WIDGET_INFO_BG].bottom - y);
|
||||
DrawStringMultiLine(4, this->width - 8, y, this->widget[AIL_WIDGET_INFO_BG].bottom, STR_JUST_RAW_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str,
|
||||
|
||||
if (maxh != -1 && (int)total_height > maxh) {
|
||||
/* Check there's room enough for at least one line. */
|
||||
if (maxh < mt) return 0;
|
||||
if (maxh < mt) return top;
|
||||
|
||||
num = maxh / mt - 1;
|
||||
total_height = (num + 1) * mt;
|
||||
@ -674,11 +674,6 @@ void DrawStringMultiCenter(int x, int y, StringID str, int maxw)
|
||||
DrawStringMultiLine(x - maxw / 2, x + maxw / 2, y, INT32_MAX, str, SA_CENTER);
|
||||
}
|
||||
|
||||
uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh)
|
||||
{
|
||||
return DrawStringMultiLine(x, x + maxw, y, y + maxh, str, SA_LEFT) - y;
|
||||
}
|
||||
|
||||
/** Return the string dimension in pixels. The height and width are returned
|
||||
* in a single Dimension value. TINYFONT, BIGFONT modifiers are only
|
||||
* supported as the first character of the string. The returned dimensions
|
||||
|
@ -109,7 +109,6 @@ uint32 FormatStringLinebreaks(char *str, int maxw);
|
||||
int GetStringHeight(StringID str, int maxw);
|
||||
void LoadStringWidthTable();
|
||||
void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
|
||||
uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1);
|
||||
|
||||
/**
|
||||
* Let the dirty blocks repainting by the video driver.
|
||||
|
@ -226,7 +226,7 @@ public:
|
||||
}
|
||||
|
||||
if (this->selected_type == INVALID_INDUSTRYTYPE) {
|
||||
DrawStringMultiLine(x_str, y_str, STR_RANDOM_INDUSTRIES_TIP, max_width, wi->bottom - wi->top - 40);
|
||||
DrawStringMultiLine(x_str, x_str + max_width, y_str, wi->bottom, STR_RANDOM_INDUSTRIES_TIP);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ public:
|
||||
str = this->text[this->selected_index];
|
||||
if (str != STR_NULL && str != STR_UNDEFINED) {
|
||||
SetDParam(0, str);
|
||||
DrawStringMultiLine(x_str, y_str, STR_JUST_STRING, max_width, wi->bottom - wi->top - 40);
|
||||
DrawStringMultiLine(x_str, x_str + max_width, y_str, wi->bottom, STR_JUST_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,7 +551,7 @@ public:
|
||||
|
||||
PrepareTextRefStackUsage(6);
|
||||
/* Use all the available space left from where we stand up to the end of the window */
|
||||
y += DrawStringMultiLine(2, y, message, wi->right - wi->left - 4, -1);
|
||||
y = DrawStringMultiLine(wi->left + 2, wi->right -2, y, wi->bottom, message);
|
||||
StopTextRefStackUsage();
|
||||
}
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ static int DrawStationCoverageText(const AcceptedCargo cargo,
|
||||
assert(b < endof(string));
|
||||
|
||||
SetDParamStr(0, string);
|
||||
return DrawStringMultiLine(str_x, str_y, STR_JUST_RAW_STRING, 144);
|
||||
return DrawStringMultiLine(str_x, str_x + 144, str_y, INT32_MAX, STR_JUST_RAW_STRING);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -443,34 +443,34 @@ public:
|
||||
|
||||
if (this->selected->upgrade) {
|
||||
SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_UPDATE, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_UPDATE);
|
||||
y += 11;
|
||||
}
|
||||
|
||||
SetDParamStr(0, this->selected->name);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_NAME, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_NAME);
|
||||
|
||||
if (!StrEmpty(this->selected->version)) {
|
||||
SetDParamStr(0, this->selected->version);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_VERSION, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_VERSION);
|
||||
}
|
||||
|
||||
if (!StrEmpty(this->selected->description)) {
|
||||
SetDParamStr(0, this->selected->description);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_DESCRIPTION, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_DESCRIPTION);
|
||||
}
|
||||
|
||||
if (!StrEmpty(this->selected->url)) {
|
||||
SetDParamStr(0, this->selected->url);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_URL, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_URL);
|
||||
}
|
||||
|
||||
SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_TYPE, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_TYPE);
|
||||
|
||||
y += 11;
|
||||
SetDParam(0, this->selected->filesize);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_FILESIZE, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_FILESIZE);
|
||||
|
||||
if (this->selected->dependency_count != 0) {
|
||||
/* List dependencies */
|
||||
@ -490,7 +490,7 @@ public:
|
||||
}
|
||||
}
|
||||
SetDParamStr(0, buf);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_DEPENDENCIES, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_DEPENDENCIES);
|
||||
}
|
||||
|
||||
if (this->selected->tag_count != 0) {
|
||||
@ -501,7 +501,7 @@ public:
|
||||
p += seprintf(p, lastof(buf), i == 0 ? "%s" : ", %s", this->selected->tags[i]);
|
||||
}
|
||||
SetDParamStr(0, buf);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_TAGS, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_TAGS);
|
||||
}
|
||||
|
||||
if (this->selected->IsSelected()) {
|
||||
@ -519,7 +519,7 @@ public:
|
||||
}
|
||||
if (p != buf) {
|
||||
SetDParamStr(0, buf);
|
||||
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
|
||||
y = DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, y, max_y, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,24 +67,24 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, uint bott
|
||||
GetString(message, c->error->custom_message == NULL ? c->error->message : STR_JUST_RAW_STRING, lastof(message));
|
||||
|
||||
SetDParamStr(0, message);
|
||||
y += DrawStringMultiLine(x, y, c->error->severity, w, bottom - y);
|
||||
y = DrawStringMultiLine(x, x + w, y, bottom, c->error->severity);
|
||||
}
|
||||
|
||||
/* Draw filename or not if it is not known (GRF sent over internet) */
|
||||
if (c->filename != NULL) {
|
||||
SetDParamStr(0, c->filename);
|
||||
y += DrawStringMultiLine(x, y, STR_NEWGRF_FILENAME, w, bottom - y);
|
||||
y = DrawStringMultiLine(x, x + w, y, bottom, STR_NEWGRF_FILENAME);
|
||||
}
|
||||
|
||||
/* Prepare and draw GRF ID */
|
||||
snprintf(buff, lengthof(buff), "%08X", BSWAP32(c->grfid));
|
||||
SetDParamStr(0, buff);
|
||||
y += DrawStringMultiLine(x, y, STR_NEWGRF_GRF_ID, w, bottom - y);
|
||||
y = DrawStringMultiLine(x, x + w, y, bottom, STR_NEWGRF_GRF_ID);
|
||||
|
||||
/* Prepare and draw MD5 sum */
|
||||
md5sumToString(buff, lastof(buff), c->md5sum);
|
||||
SetDParamStr(0, buff);
|
||||
y += DrawStringMultiLine(x, y, STR_NEWGRF_MD5SUM, w, bottom - y);
|
||||
y = DrawStringMultiLine(x, x + w, y, bottom, STR_NEWGRF_MD5SUM);
|
||||
|
||||
/* Show GRF parameter list */
|
||||
if (show_params) {
|
||||
@ -95,25 +95,25 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, uint bott
|
||||
} else {
|
||||
SetDParam(0, STR_01A9_NONE);
|
||||
}
|
||||
y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w, bottom - y);
|
||||
y = DrawStringMultiLine(x, x + w, y, bottom, STR_NEWGRF_PARAMETER);
|
||||
|
||||
/* Draw the palette of the NewGRF */
|
||||
SetDParamStr(0, c->windows_paletted ? "Windows" : "DOS");
|
||||
y += DrawStringMultiLine(x, y, STR_NEWGRF_PALETTE, w, bottom - y);
|
||||
y = DrawStringMultiLine(x, x + w, y, bottom, STR_NEWGRF_PALETTE);
|
||||
}
|
||||
|
||||
/* Show flags */
|
||||
if (c->status == GCS_NOT_FOUND) y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w, bottom - y);
|
||||
if (c->status == GCS_DISABLED) y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w, bottom - y);
|
||||
if (HasBit(c->flags, GCF_COMPATIBLE)) y += DrawStringMultiLine(x, y, STR_NEWGRF_COMPATIBLE_LOADED, w, bottom - y);
|
||||
if (c->status == GCS_NOT_FOUND) y = DrawStringMultiLine(x, x + w, y, bottom, STR_NEWGRF_NOT_FOUND);
|
||||
if (c->status == GCS_DISABLED) y = DrawStringMultiLine(x, x + w, y, bottom, STR_NEWGRF_DISABLED);
|
||||
if (HasBit(c->flags, GCF_COMPATIBLE)) y = DrawStringMultiLine(x, x + w, y, bottom, STR_NEWGRF_COMPATIBLE_LOADED);
|
||||
|
||||
/* Draw GRF info if it exists */
|
||||
if (c->info != NULL && !StrEmpty(c->info)) {
|
||||
SetDParam(0, STR_JUST_RAW_STRING);
|
||||
SetDParamStr(1, c->info);
|
||||
y += DrawStringMultiLine(x, y, STR_02BD, w, bottom - y);
|
||||
y = DrawStringMultiLine(x, x + w, y, bottom, STR_02BD);
|
||||
} else {
|
||||
y += DrawStringMultiLine(x, y, STR_NEWGRF_NO_INFO, w, bottom - y);
|
||||
y = DrawStringMultiLine(x, x + w, y, bottom, STR_NEWGRF_NO_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -863,7 +863,7 @@ struct StationViewWindow : public Window {
|
||||
assert(b < endof(string));
|
||||
|
||||
SetDParamStr(0, string);
|
||||
DrawStringMultiLine(2, this->widget[SVW_ACCEPTLIST].top + 1, STR_JUST_RAW_STRING, this->widget[SVW_ACCEPTLIST].right - this->widget[SVW_ACCEPTLIST].left);
|
||||
DrawStringMultiLine(this->widget[SVW_ACCEPTLIST].left + 2, this->widget[SVW_ACCEPTLIST].right - 2, this->widget[SVW_ACCEPTLIST].bottom - 1, this->widget[SVW_ACCEPTLIST].top + 1, STR_JUST_RAW_STRING);
|
||||
} else { // extended window with list of cargo ratings
|
||||
y = this->widget[SVW_RATINGLIST].top + 1;
|
||||
|
||||
|
@ -169,7 +169,7 @@ public:
|
||||
if (this->sel_index != -1) {
|
||||
SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[this->sel_index]);
|
||||
SetDParam(0, STR_2046_SMALL_ADVERTISING_CAMPAIGN + this->sel_index);
|
||||
DrawStringMultiLine(2, this->widget[TWA_ACTION_INFO].top + 1, STR_204D_INITIATE_A_SMALL_LOCAL + this->sel_index, 313);
|
||||
DrawStringMultiLine(this->widget[TWA_ACTION_INFO].left + 2, this->widget[TWA_ACTION_INFO].right - 2, this->widget[TWA_ACTION_INFO].top + 1, this->widget[TWA_ACTION_INFO].bottom - 1, STR_204D_INITIATE_A_SMALL_LOCAL + this->sel_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,9 +439,9 @@ uint ShowAdditionalText(int x, int y, uint w, EngineID engine)
|
||||
/* STR_02BD is used to start the string with {BLACK} */
|
||||
SetDParam(0, GetGRFStringID(GetEngineGRFID(engine), 0xD000 + callback));
|
||||
PrepareTextRefStackUsage(0);
|
||||
uint result = DrawStringMultiLine(x, y, STR_02BD, w);
|
||||
uint result = DrawStringMultiLine(x, x + w, y, INT32_MAX, STR_02BD);
|
||||
StopTextRefStackUsage();
|
||||
return result;
|
||||
return result - y;
|
||||
}
|
||||
|
||||
/** Display list of cargo types of the engine, for the purchase information window */
|
||||
@ -492,7 +492,7 @@ uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine)
|
||||
assert(b < endof(string));
|
||||
|
||||
SetDParamStr(0, string);
|
||||
return DrawStringMultiLine(x, y, STR_JUST_RAW_STRING, w);
|
||||
return DrawStringMultiLine(x, x + w, y, INT32_MAX, STR_JUST_RAW_STRING);
|
||||
}
|
||||
|
||||
/** Get the cargo subtype text from NewGRF for the vehicle details window. */
|
||||
|
Loading…
Reference in New Issue
Block a user