Page 1 of 4

Patch: Rating in Town Label [v13-r18684]

Posted: 30 Mar 2009 21:53
by Terkhen
The idea around this patch is based on Progman's Town rating indicator patch, taking users and devs comments into account. Without knowing it, the patch does this in a similar way than Vikthor's Local authority rating in town label patch. I have adopted some fixes and improvements from the Russian OpenTTD Community patchpack.

Essentialy, the patch uses a colour code in the population part of the town label to show the current rating. If the window is zoomed out, the complete town label will have a changed colour. When the rating at a town changes, the colour is updated accordingly.

Currently the colour scheme is:

Red: Appalling and Very poor ratings.
Orange: Poor and mediocre ratings.
Yellow: Good rating.
White: Very Good rating (standard).
Green: Excellent and outstanding ratings.

Here's a screenshot showing all ratings:
colour.png
colour.png (81.46 KiB) Viewed 23752 times
Version history
  • v13-r17745: Update to current trunk. Version format changed to fit the used at the rest of my patches. Some code cleanup and simplifications.
  • v12-r17558: Update to current trunk. Fixed an incorrect string.
  • v11: Patch renamed, and almost completely remade. The patch uses only standard colours, and because of that now the code is way more simple. Added comments and fixed a situation in which the correct ratings weren't shown.
  • v10: Update to current trunk. Critical parts of the patch have been remade to be both faster and easier to read. This version is the last one with a colour for each rating. You can download this version here.
  • v09: Update to current trunk. Coding style corrected, including trailing whitespaces (I hope they are out now). Statements to check current rating changed to a better solution that is already used in other parts of OpenTTD code. TownRatingColour implemented as a member of the Town class. Unified some duplicated code. Thanks, Hirundo!
  • v08: (Minor) update to trunk.
  • v07: Update to trunk. Added version for stable 0.7.0 (which is essentially identical to v0.6).
  • v06: Symbol version removed: you still can find the v0.5 version here. Now only the population is coloured. Setting option merged with "show population". Fixed a bug where the colour won't update after town growth. Made sure that the patch can be applied to 0.7.
  • v05: I finally found why _current_company != _local_company. Because of this bug, when the game just commenced the town names were white. A more exact colour scheme is introduced. The code have been almost completely remade to be more efficient (no longer it needs to calculate the colour each time the sign is drawn, only when the rating changes).
  • v04: Colour scheme changed again. Ratings are now shown with 4x and 8x zoom-out. Symbol-only version released.
  • v03: Colour scheme changed for better readability. Code changed to work only with colours instead of completely different string IDs. Use always the white colour while playing as spectator. Fixed some indentation errors.
  • v02: Added patch option to activate / deactivate this option. Now everytime that a town rating is changed, that town's sign is updated.
  • v01: Initial release

Re: Patch: Town sign color shows ratings

Posted: 30 Mar 2009 22:45
by Timmaexx
Very nice idea Terkhen!
This will be my favourite patch ;)
Oh and I bet, in 6 hours the first demands for the KGATPP are coming in :D

Re: Patch: Town sign color shows ratings

Posted: 31 Mar 2009 00:45
by Eddi
what's a must-of?

Re: Patch: Town sign color shows ratings

Posted: 31 Mar 2009 21:47
by Terkhen
New version posted: see first post for details.

@Eddi: I suppose he means a "must-have". Thank you Timmaexx!

Re: Patch: Town sign color shows ratings

Posted: 31 Mar 2009 23:52
by 2007Alain2007
I had a look at this patch and it looks nice but not all the coulours work all the time it be nice to see what the rateings for each palyer not just one get a setting to show yours and everones who run in that town

Re: Patch: Town sign color shows ratings

Posted: 01 Apr 2009 09:15
by Vikthor
It's interesting how some ideas emerge again and again. I made similar patch over a year ago. I wish you luck and I hope you will be more successful in getting it commited.

Re: Patch: Town sign color shows ratings

Posted: 01 Apr 2009 09:34
by Terkhen
@2007Alain2007: I'm not sure I understood what you meant, but the aim of this patch is to provide info about ratings while building near a city. That way, you don't have to open the ratings window and have it occupying screen space. If you need to check ratings for other companies, the best solution is just to look at the ratings window.

@Vikthor: It's incredible: I hadn't seen your patch but after reading it, I see that we reached almost the same solution. I added a link to your work in the first post. Thanks for your support!.

Re: Patch: Town sign color shows ratings

Posted: 01 Apr 2009 09:47
by FooBar
Maybe instead of colours (which make the sign quite unreadable sometimes), you could do something with plusses and minusses.

For instance, add a double plus (++) at the end of the town label in case of Excellent or Outstanding rating, and along those lines outher ratings could be indicated as follows:

Appalling and Very Poor: --
Poor: -
Mediocre: (no indication)
Good and Very Good ratings: +
Excellent and Outstanding: ++

Otherwise I think it's a very nice addition to the game. Keeps me from opening two windows in every town.

Re: Patch: Town sign color shows ratings

Posted: 01 Apr 2009 15:30
by Hirundo
Some random comments on the code:

_current_company != _local_company.
Also, both current and local company may not be a valid company. e.g. t->ratings[COMPANY_SPECTATOR] will overflow badly.

Isn't it possible to specify a colour when drawing a string? I think this would be preferable to using many different strings in english.txt.

In some places the code isn't aligned properly w.r.t. tabs/indentation. Read the .diff thoroughly to see what I mean.

Re: Patch: Town sign color shows ratings

Posted: 01 Apr 2009 15:56
by Terkhen
I like Foobar's idea: is more readable than using colors. What do other people think?

Swallow: Thanks for your comments. I'll look into the company problem and the indentation errors tonight. I don't know how to use strings that aren't defined at english.txt, but I'll give it a try.

Re: Patch: Town sign color shows ratings

Posted: 01 Apr 2009 17:07
by Zuu
About choosing what color to draw with. The sign list window uses the following code to draw sign names in yellow. Notice the last argument to DrawString is the colour.

Code: Select all

			SetDParam(0, si->index);
			DrawString(this->widget[SLW_LIST].left + 22, this->widget[SLW_LIST].right, y, STR_SIGN_NAME, TC_YELLOW);
I've checked your patch and see that the town names are drawn using another function "AddStringToDraw", but looking up that function it has two optional parameters. The first optional parameter is named colour. If it works the same as the colour parameter to DrawString, it will override the colour information in the string with the supplied colour.

Re: Patch: Town sign color shows ratings

Posted: 04 Apr 2009 15:19
by Terkhen
I have posted a new version of the patch in the first post. See the changelog for details.

What is your opinion about the new colors?

Zuu: Thanks for your help: I think the code is cleaner now that it works just with colors.

Swallow: I think I fixed everything, except the _current_company and _local_company issue. All functions related to the town sign drawing used _current_company, so I wasn't sure if I had to change it or not.

Re: Patch: Town sign color shows ratings

Posted: 04 Apr 2009 17:50
by FooBar
Terkhen wrote:What is your opinion about the new colors?
Much better. That blue was just terribly unreadable.

Maybe change the red for orange? That red is a bit 'screamish' compared to the other colours.

Re: Patch: Town sign color shows ratings

Posted: 04 Apr 2009 18:17
by Terkhen
This screenshot shows how it looks after changing red with orange:
orange.png
orange.png (92.22 KiB) Viewed 26104 times
I prefer orange too. It's not as striking as red, but still shows a bad rating nicely.

Re: Patch: Town sign color shows ratings

Posted: 11 Apr 2009 09:28
by ChillCore
I like this patch.
I is much easier to see which towns needs that little extra attention.
Also it prevents me bulldozing and terraforming then to find out i am not allowed to build whatever i was preparing the terrain for.

The only thing that confuses me a little bit is the townname colourchange.

Would it be possible to leave the townname white and only have the townpopulation change colour?
That way we still see the townratings and I am no longer searching for the townname between my station/busstop signs (and other player/ai stations/busstops).

Anyway nice patch.
I hope it hits trunk.

Re: Patch: Town sign color shows ratings

Posted: 11 Apr 2009 12:17
by Auge
Hello
ChillCore wrote: The only thing that confuses me a little bit is the townname colourchange.

Would it be possible to leave the townname white and only have the townpopulation change colour?
That could cause a problem. You can disable the displaying of the townpopulation. Wich element want you to be coloured in this case?
ChillCore wrote: I hope it hits trunk.
Me too. :-)

Tschö, Auge

Re: Patch: Town sign color shows ratings

Posted: 11 Apr 2009 12:25
by ChillCore
That could cause a problem. You can disable the displaying of the townpopulation. Wich element want you to be coloured in this case?
None?

I have the grass on tracks in my patchpack and if i disable all details the grass is gone and so is my extra system load.(hint)

Re: Patch: Town sign color shows ratings

Posted: 11 Apr 2009 13:56
by Auge
ChillCore wrote:
That could cause a problem. You can disable the displaying of the townpopulation. Wich element want you to be coloured in this case?
None?
Oh, sorry. I thought, the patch make it into trunk and should be available for everyone (including those, who disabled the displaying of town population).

Tschö, Auge

Re: Patch: Town sign color shows ratings

Posted: 11 Apr 2009 15:43
by ChillCore
Maybe like FooBar suggested adding :

++ + N - --

to/before the townstring.

Its just an idea.
The way it is now it is fine too.
I just have to search a bit longer after the townname sometimes,
because in some of my games i dont let towns build roads so the towname is not always in the center. No biggy

Re: Patch: Town sign color shows ratings

Posted: 11 Apr 2009 21:33
by Terkhen
Both approachs (different color only in town population and adding something at the end of the string) would need a new string in english.txt for each color / symbol to be added. Since that makes the patch more messy, I'd prefer not to add more strings. I think there's a way to pass a string parameter to a string, I'll give it a look soon.