[New Feature] Patch for selective transparency (+catenary)
Moderator: OpenTTD Developers
[New Feature] Patch for selective transparency (+catenary)
i thought that a new "transparent" feature should be useful
make transparent things in different times is a good idea:
- when i want to see my new station (with newstations.grf) built in the middle of the city
- when i want to build junctions/signals and catenary doesn't allow me to see what i'm doing (not already done yet)
- now with magic bridges i want to see what i'm building below a bridge without making all other things transparent, but bridges only and maybe fully transparent (not already done the bridge invisibility)
the options are (selectable on the file menu like rollercoaster tycoon):
- make transparent trees
- make transparent houses
- make transparent industries
- make transparent player's buildings (now CATENARY!, stations, bridges etc)
keys:
X toggle transparency for all things
CTRL+X make player's buildings transparent (also catenary)
SHIFT+X cycle transparent selection (try it, it's hard to explain, but is only a bit shift)
i don't know well the code, so if it isn't optimized or placed uncorrectly don't blame me
in the post below you can find the diff and the executable (win32) with the english.lng (i hope that needs only that)
Credits:
peter1138 for suggestions on the code
Hackykid for suggestions on the code
the #OpenTTD chan for the help
make transparent things in different times is a good idea:
- when i want to see my new station (with newstations.grf) built in the middle of the city
- when i want to build junctions/signals and catenary doesn't allow me to see what i'm doing (not already done yet)
- now with magic bridges i want to see what i'm building below a bridge without making all other things transparent, but bridges only and maybe fully transparent (not already done the bridge invisibility)
the options are (selectable on the file menu like rollercoaster tycoon):
- make transparent trees
- make transparent houses
- make transparent industries
- make transparent player's buildings (now CATENARY!, stations, bridges etc)
keys:
X toggle transparency for all things
CTRL+X make player's buildings transparent (also catenary)
SHIFT+X cycle transparent selection (try it, it's hard to explain, but is only a bit shift)
i don't know well the code, so if it isn't optimized or placed uncorrectly don't blame me
in the post below you can find the diff and the executable (win32) with the english.lng (i hope that needs only that)
Credits:
peter1138 for suggestions on the code
Hackykid for suggestions on the code
the #OpenTTD chan for the help
- Attachments
-
- bin_w32.zip
- (685.03 KiB) Downloaded 218 times
-
- transparency_5348.diff
- 06-22-06 little bugfix
- (16.92 KiB) Downloaded 257 times
Last edited by Wolf01 on 24 Jun 2006 08:27, edited 8 times in total.
If just been trying your transparency patch.
Firstly I get a compile error with MSVC 2005
I changed:
To:
and it then compiles ok.
It seems to work well and I think it will be very useful. I've already cast my vote.
I have one suggestion, I think the menu item "Transparent buildings" should be "Transparent stations". "Transparent station buildings" would be better but is probably too long.
Edit: I also noticed you have a few problems with tabs in your patch, see screenshot. There are also a few tabs where they shouldn’t be in english.txt.
The program in the screenshot is Notepad2. It is a very useful alternative to Windows Notepad. It has built in colour coding support for diff and patch files (as well as many other file types). It will also optionally display tabs and spaces as shown. It is open source and available for download here.
Firstly I get a compile error with MSVC 2005
Code: Select all
c:\...\openttd\trunk\elrail.c(251) : error C2275: 'uint32' : illegal use of this type as an expression
Code: Select all
uint32 pylon;
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
for (k = 0; k < DIR_END; k++) {
...
Code: Select all
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
uint32 pylon;
for (k = 0; k < DIR_END; k++) {
...
It seems to work well and I think it will be very useful. I've already cast my vote.

I have one suggestion, I think the menu item "Transparent buildings" should be "Transparent stations". "Transparent station buildings" would be better but is probably too long.
Edit: I also noticed you have a few problems with tabs in your patch, see screenshot. There are also a few tabs where they shouldn’t be in english.txt.
The program in the screenshot is Notepad2. It is a very useful alternative to Windows Notepad. It has built in colour coding support for diff and patch files (as well as many other file types). It will also optionally display tabs and spaces as shown. It is open source and available for download here.
- Attachments
-
- Transparency.png (30.24 KiB) Viewed 5729 times
Thank you for the bugfixmart3p wrote:If just been trying your transparency patch.
Firstly I get a compile error with MSVC 2005[...]
and it then compiles ok.

Uhm, that menu item make transparent all the buildable things, not only stations, but bridges, waypoints, stations, catenary, depots... maybe "Trasparent buildable" or "Transparent constructions" may be betterIt seems to work well and I think it will be very useful. I've already cast my vote.
I have one suggestion, I think the menu item "Transparent buildings" should be "Transparent stations". "Transparent station buildings" would be better but is probably too long.
i know, i'm using devc++ which has some problems with tabs, i already thought to switch to notepad++Edit: I also noticed you have a few problems with tabs in your patch, see screenshot. There are also a few tabs where they shouldn’t be in english.txt.
The program in the screenshot is Notepad2. It is a very useful alternative to Windows Notepad. It has built in colour coding support for diff and patch files (as well as many other file types). It will also optionally display tabs and spaces as shown. It is open source and available for download here.
ok, i correct that bugs and then i upload the new version
- White Rabbit
- Tycoon
- Posts: 1734
- Joined: 22 Jun 2005 19:15
Code: Select all
case 'X': //toggle all transparent (as normal behaviour)
if (GB(_display_opt,7,4)==0) {
_display_opt ^= 1920; //11110000000
} else { //re sets the transparency to visible for all things
_display_opt &= 127;
_transp_opt &= 127; //reset also the temp variable for the shift
}
MarkWholeScreenDirty();
break;
it sets to 0 the 4 bits if at least one of them is 1 and sets all 4 to 1 if are all 0
i don't know why doesn't work, it must work!
i have some problems also here:
Code: Select all
case 'X' | WKC_SHIFT: //cycle transparency
_temp_bit=0;
if (_transp_opt&(1<<10)) _temp_bit=1;
_transp_opt=_transp_opt<<1;
if (!_temp_bit) _transp_opt+=128;
_transp_opt&=1920;
_display_opt ^= _transp_opt;
MarkWholeScreenDirty();
break;
0000xxxxxxx
0001xxxxxxx
0011xxxxxxx
0111xxxxxxx
1111xxxxxxx
1110xxxxxxx
1100xxxxxxx
1000xxxxxxx
0000xxxxxxx
and it mustn't touch bits marked as x
but also this doesn't work and i don't know why too (it does nothing at all)
thanks for any help

The first looks fine to me; a trace would be your friend there. But I would use hex (0x780/0x7F), since I think that's easier for a human reader than decimal.
As for the second, I might try:
static int lookup[16]={1,3,-1,7,-1,-1,-1,0xF,0,-1,-1,-1,8,-1,0xC,0xE}; // -1 indcates invalid entry.
...
SB(_display_opt,7,4,lookup[GB(_display_opt,7,4)]);
(This is assuming that SB works the way I think it does; I've got people waiting for this computer, so I shouldn't look that up right now.)
As for the second, I might try:
static int lookup[16]={1,3,-1,7,-1,-1,-1,0xF,0,-1,-1,-1,8,-1,0xC,0xE}; // -1 indcates invalid entry.
...
SB(_display_opt,7,4,lookup[GB(_display_opt,7,4)]);
(This is assuming that SB works the way I think it does; I've got people waiting for this computer, so I shouldn't look that up right now.)
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
i thought about the second code with a friend of mine
but i want to know why if i change more times the same piece of code, the code of the key shortcut this time, in the game it stops to work (for example if i copy the code to reset the transparency bits it doesn't work)
Code: Select all
case 'X' | WKC_SHIFT: //cycle transparency
_temp_bit=0;
_transp_opt&=1920; //reset the non used bits before shift
if (_transp_opt&(1<<10)) _temp_bit=1;
_transp_opt=_transp_opt<<1;
if (!_temp_bit) _transp_opt+=128;
_transp_opt&=1920;
_display_opt&=~1920; //reset the four transparency bits for the merge
_display_opt |= _transp_opt; //merge the 2 variables
MarkWholeScreenDirty();
break;
Have just posted an update for this patch in the MiniIN thread:
http://www.tt-forums.net/viewtopic.php?p=460382#460382
http://www.tt-forums.net/viewtopic.php?p=460382#460382
He's like, some kind of OpenTTD developer.
Who is online
Users browsing this forum: No registered users and 13 guests