Page 1 of 1

{COMPANY_COLOUR} string control code patch

Posted: 12 Feb 2018 16:56
by xarick
Created this control code thing so that game scripts could get a way to retrieve company colours with StringID's.
Image

Re: {COMPANY_COLOUR} string control code patch

Posted: 11 Apr 2018 22:18
by KeldorKatarn
Can I suggest you rename that to COMPANY_COLOR_NAME or something? COMPANY_COLOR should possibly reserved for using the actual color to color the text.

Re: {COMPANY_COLOUR} string control code patch

Posted: 11 Apr 2018 22:21
by peter1138
Yeah, when he was discussing this I thought that was what he was doing as well :-)

I've done a git branch that adds this. I've not tested the either control code myself.
https://github.com/PeterN/OpenTTD/commi ... ontrolcode

Re: {COMPANY_COLOUR} string control code patch

Posted: 11 Apr 2018 22:44
by KeldorKatarn
Neat, I might cherry pick those :)

Btw, I noticed that {PREVIOUS_COLOR} is for some reason not active, at least not in my fork, I didn't check vanilla yet. But since it's missing in JGR's fork also, I'd almost assume it's in vanilla too:

https://github.com/KeldorKatarn/OpenTTD ... c18a751c54

The logic for it is in place, so there's no reason why it shouldn't be in that table. I'm using it in my fork for something and it works fine. (The name of that code is the reason why I think COMPANY_COLOUR should indeed be a color, otherwise devs will get confused.)

Re: {COMPANY_COLOUR} string control code patch

Posted: 12 Apr 2018 06:05
by peter1138
Interesting catch. PREVIOUS_COLOUR is used internally when making negative cash show as red, but never external. It could be potentially be useful though.

By the way, you used spaces instead of tab so I can't cherry-pick that.

Re: {COMPANY_COLOUR} string control code patch

Posted: 17 Apr 2018 19:37
by peter1138
Ok, I dropped the COMPANY_COLOUR stuff, after I realised the text colours don't align with company colours at all. (And my revision to the company colour name stuff doesn't work either.)

Re: {COMPANY_COLOUR} string control code patch

Posted: 18 Apr 2018 06:10
by KeldorKatarn
I'll take a look at some point. Maybe I can figure it out. I have some other work on my plate right now though.
Regarding the spaces.. well spaces are kinda the standard, at least on whatever code I worked. But switching to tabs should be a simple "reformat code section" call in any IDE of your choosing, so reformatting that shouldn't be an issue.