summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-21 23:45:34 +0000
committerrubidium <rubidium@openttd.org>2009-03-21 23:45:34 +0000
commitd837fc4d03bc2cab4ffcae9c8fb81d4226e30913 (patch)
tree7735a9fe4858662401465187eed99bbd8c49f169
parent676bf31e82fb666feee5cde9ffc65bdc7a5070a7 (diff)
downloadopenttd-d837fc4d03bc2cab4ffcae9c8fb81d4226e30913.tar.xz
(svn r15797) -Codechange: make users of the old DrawStringMultiLine use the new one.
-rw-r--r--src/ai/ai_gui.cpp2
-rw-r--r--src/gfx.cpp7
-rw-r--r--src/gfx_func.h1
-rw-r--r--src/industry_gui.cpp6
-rw-r--r--src/misc_gui.cpp2
-rw-r--r--src/network/network_content_gui.cpp20
-rw-r--r--src/newgrf_gui.cpp22
-rw-r--r--src/station_gui.cpp2
-rw-r--r--src/town_gui.cpp2
-rw-r--r--src/vehicle_gui.cpp6
10 files changed, 32 insertions, 38 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 227396675..76340b4ce 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -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);
}
}
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 467434973..7398fa018 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -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
diff --git a/src/gfx_func.h b/src/gfx_func.h
index c208aaeb3..97ae75617 100644
--- a/src/gfx_func.h
+++ b/src/gfx_func.h
@@ -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.
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index b04a85736..73a391052 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -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();
}
}
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 009862c94..5ed8f2b62 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -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);
}
/**
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index d746fe93c..50cad09da 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -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);
}
}
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index e45f74501..7c14f2504 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -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);
}
}
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 460f4a947..a5d5360aa 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -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;
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 92829150e..98540d014 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -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);
}
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 0e16bf6dd..923899aad 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -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. */