mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r21047) [1.0] -Backport from trunk:
- Fix: Chat/console messages got sometimes messed up due to LTR names in RTL translations and vice-versa [FS#3746] (r21006, r21004) - Fix: Size of sort buttons for order and vehicle list gui could be too small (r20997) - Fix: [NewGRF] The X and Y offsets in the parameter for industry vars 60, 61, 62, 63 are unsigned instead of signed (r20996) [1.0] -Add: Knowledge about the existence of XZ/LZMA compressed savegames so loading those gives a proper error message (Yexo)
This commit is contained in:
parent
d48a03cb14
commit
c377b3f57a
@ -168,7 +168,7 @@ public:
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case BBSW_DROPDOWN_ORDER: {
|
case BBSW_DROPDOWN_ORDER: {
|
||||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||||
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the word is centered, also looks nice.
|
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
|
||||||
d.height += padding.height;
|
d.height += padding.height;
|
||||||
*size = maxdim(*size, d);
|
*size = maxdim(*size, d);
|
||||||
break;
|
break;
|
||||||
|
@ -281,7 +281,10 @@ struct IConsoleWindow : Window
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WKC_RETURN: case WKC_NUM_ENTER: {
|
case WKC_RETURN: case WKC_NUM_ENTER: {
|
||||||
IConsolePrintF(CC_COMMAND, "] %s", _iconsole_cmdline.buf);
|
/* We always want the ] at the left side; we always force these strings to be left
|
||||||
|
* aligned anyway. So enforce this in all cases by addding a left-to-right marker,
|
||||||
|
* otherwise it will be drawn at the wrong side with right-to-left texts. */
|
||||||
|
IConsolePrintF(CC_COMMAND, LRM "] %s", _iconsole_cmdline.buf);
|
||||||
const char *cmd = IConsoleHistoryAdd(_iconsole_cmdline.buf);
|
const char *cmd = IConsoleHistoryAdd(_iconsole_cmdline.buf);
|
||||||
IConsoleClearCommand();
|
IConsoleClearCommand();
|
||||||
|
|
||||||
|
12
src/gfx.cpp
12
src/gfx.cpp
@ -345,7 +345,7 @@ static int TruncateString(char *str, int maxw, bool ignore_setxy)
|
|||||||
ddd_w = ddd = GetCharacterWidth(size, '.') * 3;
|
ddd_w = ddd = GetCharacterWidth(size, '.') * 3;
|
||||||
|
|
||||||
for (ddd_pos = str; (c = Utf8Consume(const_cast<const char **>(&str))) != '\0'; ) {
|
for (ddd_pos = str; (c = Utf8Consume(const_cast<const char **>(&str))) != '\0'; ) {
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||||
w += GetCharacterWidth(size, c);
|
w += GetCharacterWidth(size, c);
|
||||||
|
|
||||||
if (w > maxw) {
|
if (w > maxw) {
|
||||||
@ -401,7 +401,7 @@ static int GetStringWidth(const UChar *str)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
c = *str++;
|
c = *str++;
|
||||||
if (c == 0) break;
|
if (c == 0) break;
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||||
width += GetCharacterWidth(size, c);
|
width += GetCharacterWidth(size, c);
|
||||||
} else {
|
} else {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -654,7 +654,7 @@ uint32 FormatStringLinebreaks(char *str, const char *last, int maxw)
|
|||||||
/* whitespace is where we will insert the line-break */
|
/* whitespace is where we will insert the line-break */
|
||||||
if (IsWhitespace(c)) last_space = str;
|
if (IsWhitespace(c)) last_space = str;
|
||||||
|
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||||
int char_w = GetCharacterWidth(size, c);
|
int char_w = GetCharacterWidth(size, c);
|
||||||
w += char_w;
|
w += char_w;
|
||||||
if (w > maxw) {
|
if (w > maxw) {
|
||||||
@ -869,7 +869,7 @@ Dimension GetStringBoundingBox(const char *str)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
c = Utf8Consume(&str);
|
c = Utf8Consume(&str);
|
||||||
if (c == 0) break;
|
if (c == 0) break;
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||||
br.width += GetCharacterWidth(size, c);
|
br.width += GetCharacterWidth(size, c);
|
||||||
} else {
|
} else {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -974,7 +974,7 @@ skip_cont:;
|
|||||||
_last_fontsize = size;
|
_last_fontsize = size;
|
||||||
return x; // Nothing more to draw, get out. And here is the new x position
|
return x; // Nothing more to draw, get out. And here is the new x position
|
||||||
}
|
}
|
||||||
if (IsPrintable(c)) {
|
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||||
if (x >= dpi->left + dpi->width) goto skip_char;
|
if (x >= dpi->left + dpi->width) goto skip_char;
|
||||||
if (x + _max_char_width >= dpi->left) {
|
if (x + _max_char_width >= dpi->left) {
|
||||||
GfxMainBlitter(GetGlyph(size, c), x, y, BM_COLOUR_REMAP);
|
GfxMainBlitter(GetGlyph(size, c), x, y, BM_COLOUR_REMAP);
|
||||||
@ -998,7 +998,7 @@ skip_cont:;
|
|||||||
size = FS_SMALL;
|
size = FS_SMALL;
|
||||||
} else if (c == SCC_BIGFONT) { // {BIGFONT}
|
} else if (c == SCC_BIGFONT) { // {BIGFONT}
|
||||||
size = FS_LARGE;
|
size = FS_LARGE;
|
||||||
} else {
|
} else if (!IsTextDirectionChar(c)) {
|
||||||
DEBUG(misc, 0, "[utf8] unknown string command character %d", c);
|
DEBUG(misc, 0, "[utf8] unknown string command character %d", c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,14 @@ public:
|
|||||||
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + 8 + 8;
|
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + 8 + 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GRP_WIDGET_SORT_BY_ORDER: {
|
||||||
|
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||||
|
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
|
||||||
|
d.height += padding.height;
|
||||||
|
*size = maxdim(*size, d);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case GRP_WIDGET_LIST_VEHICLE:
|
case GRP_WIDGET_LIST_VEHICLE:
|
||||||
resize->height = GetVehicleListHeight(this->vehicle_type, FONT_HEIGHT_NORMAL + WD_MATRIX_TOP);
|
resize->height = GetVehicleListHeight(this->vehicle_type, FONT_HEIGHT_NORMAL + WD_MATRIX_TOP);
|
||||||
size->height = 4 * resize->height;
|
size->height = 4 * resize->height;
|
||||||
|
@ -1066,7 +1066,7 @@ public:
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case IDW_DROPDOWN_ORDER: {
|
case IDW_DROPDOWN_ORDER: {
|
||||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||||
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the word is centered, also looks nice.
|
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
|
||||||
d.height += padding.height;
|
d.height += padding.height;
|
||||||
*size = maxdim(*size, d);
|
*size = maxdim(*size, d);
|
||||||
break;
|
break;
|
||||||
|
@ -250,7 +250,13 @@ void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_se
|
|||||||
SetDParamStr(0, name);
|
SetDParamStr(0, name);
|
||||||
SetDParamStr(1, str);
|
SetDParamStr(1, str);
|
||||||
SetDParam(2, data);
|
SetDParam(2, data);
|
||||||
GetString(message, strid, lastof(message));
|
|
||||||
|
/* All of these strings start with "***". These characters are interpreted as both left-to-right and
|
||||||
|
* right-to-left characters depending on the context. As the next text might be an user's name, the
|
||||||
|
* user name's characters will influence the direction of the "***" instead of the language setting
|
||||||
|
* of the game. Manually set the direction of the "***" by inserting a text-direction marker. */
|
||||||
|
char *msg_ptr = message + Utf8Encode(message, _dynlang.text_dir == TD_LTR ? CHAR_TD_LRM : CHAR_TD_RLM);
|
||||||
|
GetString(msg_ptr, strid, lastof(message));
|
||||||
|
|
||||||
DEBUG(desync, 1, "msg: %08x; %02x; %s", _date, _date_fract, message);
|
DEBUG(desync, 1, "msg: %08x; %02x; %s", _date, _date_fract, message);
|
||||||
IConsolePrintF(colour, "%s", message);
|
IConsolePrintF(colour, "%s", message);
|
||||||
|
@ -351,13 +351,13 @@ uint32 GetTerrainType(TileIndex tile, TileContext context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TileIndex GetNearbyTile(byte parameter, TileIndex tile)
|
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets)
|
||||||
{
|
{
|
||||||
int8 x = GB(parameter, 0, 4);
|
int8 x = GB(parameter, 0, 4);
|
||||||
int8 y = GB(parameter, 4, 4);
|
int8 y = GB(parameter, 4, 4);
|
||||||
|
|
||||||
if (x >= 8) x -= 16;
|
if (signed_offsets && x >= 8) x -= 16;
|
||||||
if (y >= 8) y -= 16;
|
if (signed_offsets && y >= 8) y -= 16;
|
||||||
|
|
||||||
/* Swap width and height depending on axis for railway stations */
|
/* Swap width and height depending on axis for railway stations */
|
||||||
if (HasStationTileRail(tile) && GetRailStationAxis(tile) == AXIS_Y) Swap(x, y);
|
if (HasStationTileRail(tile) && GetRailStationAxis(tile) == AXIS_Y) Swap(x, y);
|
||||||
|
@ -109,7 +109,7 @@ extern IndustryOverrideManager _industry_mngr;
|
|||||||
extern IndustryTileOverrideManager _industile_mngr;
|
extern IndustryTileOverrideManager _industile_mngr;
|
||||||
|
|
||||||
uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL);
|
uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL);
|
||||||
TileIndex GetNearbyTile(byte parameter, TileIndex tile);
|
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets = true);
|
||||||
uint32 GetNearbyTileInformation(TileIndex tile);
|
uint32 GetNearbyTileInformation(TileIndex tile);
|
||||||
|
|
||||||
#endif /* NEWGRF_COMMONS_H */
|
#endif /* NEWGRF_COMMONS_H */
|
||||||
|
@ -233,19 +233,19 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
|
|||||||
case 0x46: return industry->construction_date; // Date when built - long format - (in days)
|
case 0x46: return industry->construction_date; // Date when built - long format - (in days)
|
||||||
|
|
||||||
/* Get industry ID at offset param */
|
/* Get industry ID at offset param */
|
||||||
case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->location.tile), industry, object->grffile->grfid);
|
case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->location.tile, false), industry, object->grffile->grfid);
|
||||||
|
|
||||||
/* Get random tile bits at offset param */
|
/* Get random tile bits at offset param */
|
||||||
case 0x61:
|
case 0x61:
|
||||||
tile = GetNearbyTile(parameter, tile);
|
tile = GetNearbyTile(parameter, tile, false);
|
||||||
return (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0;
|
return (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0;
|
||||||
|
|
||||||
/* Land info of nearby tiles */
|
/* Land info of nearby tiles */
|
||||||
case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY);
|
case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY, false);
|
||||||
|
|
||||||
/* Animation stage of nearby tiles */
|
/* Animation stage of nearby tiles */
|
||||||
case 0x63:
|
case 0x63:
|
||||||
tile = GetNearbyTile(parameter, tile);
|
tile = GetNearbyTile(parameter, tile, false);
|
||||||
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
|
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
|
||||||
return GetIndustryAnimationState(tile);
|
return GetIndustryAnimationState(tile);
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,6 @@ bool CheckIfCallBackAllowsAvailability(IndustryType type, IndustryAvailabilityCa
|
|||||||
IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id);
|
IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id);
|
||||||
|
|
||||||
/* in newgrf_industrytiles.cpp*/
|
/* in newgrf_industrytiles.cpp*/
|
||||||
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index);
|
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets = true);
|
||||||
|
|
||||||
#endif /* NEWGRF_INDUSTRIES_H */
|
#endif /* NEWGRF_INDUSTRIES_H */
|
||||||
|
@ -35,11 +35,12 @@
|
|||||||
* @param parameter from callback. It's in fact a pair of coordinates
|
* @param parameter from callback. It's in fact a pair of coordinates
|
||||||
* @param tile TileIndex from which the callback was initiated
|
* @param tile TileIndex from which the callback was initiated
|
||||||
* @param index of the industry been queried for
|
* @param index of the industry been queried for
|
||||||
|
* @param signed_offsets Are the x and y offset encoded in parameter signed?
|
||||||
* @return a construction of bits obeying the newgrf format
|
* @return a construction of bits obeying the newgrf format
|
||||||
*/
|
*/
|
||||||
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index)
|
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets)
|
||||||
{
|
{
|
||||||
if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
|
if (parameter != 0) tile = GetNearbyTile(parameter, tile, signed_offsets); // only perform if it is required
|
||||||
bool is_same_industry = (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == index);
|
bool is_same_industry = (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == index);
|
||||||
|
|
||||||
return GetNearbyTileInformation(tile) | (is_same_industry ? 1 : 0) << 8;
|
return GetNearbyTileInformation(tile) | (is_same_industry ? 1 : 0) << 8;
|
||||||
|
@ -1643,6 +1643,7 @@ static const SaveLoadFormat _saveload_formats[] = {
|
|||||||
#else
|
#else
|
||||||
{"zlib", TO_BE32X('OTTZ'), NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0},
|
{"zlib", TO_BE32X('OTTZ'), NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0},
|
||||||
#endif
|
#endif
|
||||||
|
{"lzma", TO_BE32X('OTTX'), NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -378,7 +378,7 @@ public:
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case SLW_SORTBY: {
|
case SLW_SORTBY: {
|
||||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||||
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the word is centered, also looks nice.
|
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
|
||||||
d.height += padding.height;
|
d.height += padding.height;
|
||||||
*size = maxdim(*size, d);
|
*size = maxdim(*size, d);
|
||||||
break;
|
break;
|
||||||
|
@ -222,6 +222,28 @@ static inline char *Utf8PrevChar(char *s)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the given character a text direction character.
|
||||||
|
* @param c The character to test.
|
||||||
|
* @return true iff the character is used to influence
|
||||||
|
* the text direction.
|
||||||
|
*/
|
||||||
|
static inline bool IsTextDirectionChar(WChar c)
|
||||||
|
{
|
||||||
|
switch (c) {
|
||||||
|
case CHAR_TD_LRM:
|
||||||
|
case CHAR_TD_RLM:
|
||||||
|
case CHAR_TD_LRE:
|
||||||
|
case CHAR_TD_RLE:
|
||||||
|
case CHAR_TD_LRO:
|
||||||
|
case CHAR_TD_RLO:
|
||||||
|
case CHAR_TD_PDF:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool IsPrintable(WChar c)
|
static inline bool IsPrintable(WChar c)
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
/** A non-breaking space. */
|
/** A non-breaking space. */
|
||||||
#define NBSP "\xC2\xA0"
|
#define NBSP "\xC2\xA0"
|
||||||
|
|
||||||
|
/** A left-to-right marker, marks the next character as left-to-right. */
|
||||||
|
#define LRM "\xE2\x80\x8E"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Valid filter types for IsValidChar.
|
* Valid filter types for IsValidChar.
|
||||||
*/
|
*/
|
||||||
@ -27,4 +30,14 @@ enum CharSetFilter {
|
|||||||
|
|
||||||
typedef uint32 WChar;
|
typedef uint32 WChar;
|
||||||
|
|
||||||
|
/* The following are directional formatting codes used to get the LTR and RTL strings right:
|
||||||
|
* http://www.unicode.org/unicode/reports/tr9/#Directional_Formatting_Codes */
|
||||||
|
static const WChar CHAR_TD_LRM = 0x200E; ///< The next character acts like a left-to-right character.
|
||||||
|
static const WChar CHAR_TD_RLM = 0x200F; ///< The next character acts like a right-to-left character.
|
||||||
|
static const WChar CHAR_TD_LRE = 0x202A; ///< The following text is embedded left-to-right.
|
||||||
|
static const WChar CHAR_TD_RLE = 0x202B; ///< The following text is embedded right-to-left.
|
||||||
|
static const WChar CHAR_TD_LRO = 0x202D; ///< Force the following characters to be treated as left-to-right characters.
|
||||||
|
static const WChar CHAR_TD_RLO = 0x202E; ///< Force the following characters to be treated as right-to-left characters.
|
||||||
|
static const WChar CHAR_TD_PDF = 0x202C; ///< Restore the text-direction state to before the last LRE, RLE, LRO or RLO.
|
||||||
|
|
||||||
#endif /* STRING_TYPE_H */
|
#endif /* STRING_TYPE_H */
|
||||||
|
@ -134,13 +134,13 @@ static const CmdStruct _cmd_structs[] = {
|
|||||||
|
|
||||||
/* The following are directional formatting codes used to get the RTL strings right:
|
/* The following are directional formatting codes used to get the RTL strings right:
|
||||||
* http://www.unicode.org/unicode/reports/tr9/#Directional_Formatting_Codes */
|
* http://www.unicode.org/unicode/reports/tr9/#Directional_Formatting_Codes */
|
||||||
{"LRM", EmitSingleChar, 0x200E, 0, C_DONTCOUNT},
|
{"LRM", EmitSingleChar, CHAR_TD_LRM, 0, C_DONTCOUNT},
|
||||||
{"RLM", EmitSingleChar, 0x200F, 0, C_DONTCOUNT},
|
{"RLM", EmitSingleChar, CHAR_TD_RLM, 0, C_DONTCOUNT},
|
||||||
{"LRE", EmitSingleChar, 0x202A, 0, C_DONTCOUNT},
|
{"LRE", EmitSingleChar, CHAR_TD_LRE, 0, C_DONTCOUNT},
|
||||||
{"RLE", EmitSingleChar, 0x202B, 0, C_DONTCOUNT},
|
{"RLE", EmitSingleChar, CHAR_TD_RLE, 0, C_DONTCOUNT},
|
||||||
{"LRO", EmitSingleChar, 0x202D, 0, C_DONTCOUNT},
|
{"LRO", EmitSingleChar, CHAR_TD_LRO, 0, C_DONTCOUNT},
|
||||||
{"RLO", EmitSingleChar, 0x202E, 0, C_DONTCOUNT},
|
{"RLO", EmitSingleChar, CHAR_TD_RLO, 0, C_DONTCOUNT},
|
||||||
{"PDF", EmitSingleChar, 0x202C, 0, C_DONTCOUNT},
|
{"PDF", EmitSingleChar, CHAR_TD_PDF, 0, C_DONTCOUNT},
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Description of a plural form */
|
/** Description of a plural form */
|
||||||
|
@ -817,7 +817,7 @@ public:
|
|||||||
case TDW_SORTNAME:
|
case TDW_SORTNAME:
|
||||||
case TDW_SORTPOPULATION: {
|
case TDW_SORTPOPULATION: {
|
||||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||||
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the word is centered, also looks nice.
|
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
|
||||||
d.height += padding.height;
|
d.height += padding.height;
|
||||||
*size = maxdim(*size, d);
|
*size = maxdim(*size, d);
|
||||||
break;
|
break;
|
||||||
|
@ -999,20 +999,30 @@ public:
|
|||||||
|
|
||||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||||
{
|
{
|
||||||
if (widget != VLW_WIDGET_LIST) return;
|
switch (widget) {
|
||||||
|
case VLW_WIDGET_LIST:
|
||||||
|
resize->height = GetVehicleListHeight(this->vehicle_type, 1);
|
||||||
|
switch (this->vehicle_type) {
|
||||||
|
case VEH_TRAIN:
|
||||||
|
case VEH_ROAD:
|
||||||
|
size->height = 6 * resize->height;
|
||||||
|
|
||||||
resize->height = GetVehicleListHeight(this->vehicle_type, 1);
|
break;
|
||||||
|
case VEH_SHIP:
|
||||||
|
case VEH_AIRCRAFT:
|
||||||
|
size->height = 4 * resize->height;
|
||||||
|
break;
|
||||||
|
default: NOT_REACHED();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
switch (this->vehicle_type) {
|
case VLW_WIDGET_SORT_ORDER: {
|
||||||
case VEH_TRAIN:
|
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||||
case VEH_ROAD:
|
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
|
||||||
size->height = 6 * resize->height;
|
d.height += padding.height;
|
||||||
|
*size = maxdim(*size, d);
|
||||||
break;
|
break;
|
||||||
case VEH_SHIP:
|
}
|
||||||
case VEH_AIRCRAFT:
|
|
||||||
size->height = 4 * resize->height;
|
|
||||||
break;
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user