Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number of vehicles in depots not fully displayed #6102

Closed
DorpsGek opened this issue Aug 31, 2014 · 2 comments
Closed

Number of vehicles in depots not fully displayed #6102

DorpsGek opened this issue Aug 31, 2014 · 2 comments
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

juanjo opened the ticket and wrote:

When there are thousands of vehicles, the number is not properly displayed in the depot window if the language has a digits separator (see image).

Currently, the space for the number is calculated as 4 digits, but doesn't take into account the separator:

# depot_gui.cpp
-Dimension unumber = { GetDigitWidth() * 4, FONT_HEIGHT_NORMAL };
+SetDParamMaxDigits(0, 4);
+Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/6102
@DorpsGek
Copy link
Member Author

juanjo wrote:

Moreover, I think it doesn't look right to leave so much space.

The same problem in vehicle lists (see image).
Just to give some context about how vehicle lists deal with it:

# vehicle_gui.cpp
109 uint unitnumber = 0;
for (const Vehicle **v = this->vehicles.Begin(); v != this->vehicles.End(); v++) {
unitnumber = max(unitnumber, (*v)->unitnumber);
}

114 /* Because 111 is much less wide than e.g. 999 we use the
* wider numbers to determine the width instead of just
* the random number that it seems to be. */
if (unitnumber >= 1000) {
this->unitnumber_digits = 4;
} else if (unitnumber >= 100) {
this->unitnumber_digits = 3;
} else {
this->unitnumber_digits = 2;
}
...
1357 int text_offset = GetDigitWidth() * this->unitnumber_digits + WD_FRAMERECT_RIGHT;

I think a possible solution would be something like:

  1. After building the list (depot, vehicle list,...), calculate the max unitnumber of the vehicles and store the number of digits (always at least 2).
  2. Later on (probably on UpdateWidgetSize or similar), use that value with SetDParamMaxDigits and use GetStringBoundingBox. Keep that value for drawing the list later.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6102#comment13494

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Fixed

In r27014


This comment was imported from FlySpray: https://bugs.openttd.org/task/6102

@DorpsGek DorpsGek added component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant