Author Topic: Roadsigns(Signals) Front- / BackImage Patch  (Read 558 times)

0 Members and 1 Guest are viewing this topic.

Offline THLeaderH

Roadsigns(Signals) Front- / BackImage Patch
« on: October 05, 2017, 01:50:36 AM »
This is the implementation of this topic.
http://forum.simutrans.com/index.php?topic=3725.0

This patch realizes front/back images of roadsigns and signals. I made this patch because of very strong requests by Japanese pak makers.
The patch is r8299 based and can be easily integrated to the nightly trunk. The patch file is attached. Also, the source can be seen on GitHub. https://github.com/teamhimeh/simutrans/tree/add_frontImage_to_roadsign

The new format of a roadsign dat file is as follows.
Code: [Select]
obj=roadsign
name=test_signal
intro_year=1915
intro_month=1
waytype=track
single_way=0
free_route=0
is_private=0
is_signal=1
is_presignal=0
is_longblocksignal=0
end_of_choose=0
cost=500
Icon=> foo.0.2
Cursor=foo.1.0
Image[0]=foo.6.1
Image[1]=foo.6.2
......
frontImage[0]=foo.5.1
frontImage[1]=foo.5.2
......
"Image[X]" represents back images and "frontImage[X]" represents front images.
To preserve the conventional behavior, a roadsign without frontImage behaves in the conventional way, that means the front/back is automatically set. If you want to set all images as back images, add
Code: [Select]
no_foreground=1to the dat file. Of course, roadsigns made with an old version makeobj are drawn in the conventional way.

This patch is so simple, but the benefit of this patch is so huge for pak makers I believe.

Offline Leartin

  • Devotee
  • *
  • Posts: 796
  • Total likes: 287
  • Helpful: 44
  • !!!!!This user was banned for double posting!!!!!
  • Languages: DE, EN
Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #1 on: October 05, 2017, 06:18:14 AM »
I know this is not what that patch is about, but what would you think about allowing more different images for signs and signals? Currently, you only have four "directions", pretty much for straight ways. I think it would be beneficial to allow additional graphics for diagonals - especially since with the current system, signals placed on the same diagonal road face different directions depending on which diagonal they are on. If additional graphics for slopes were added as well, one could use signals as markings on the ground - doing that with current signals looks derpy in curves or slopes. Seasons, at least winter, could be nice as well.

I'm not asking for too much, am I?  ??? :-X

Offline THLeaderH

Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #2 on: October 05, 2017, 09:07:07 AM »
Allowing additional graphics for seasons, diagonals and slopes would be not a small amount of work in the implementation, I think. Also, the pak can be so huge because a pre-signal have 6 status per each direction. If we support the full set, 2(front/back) x 6 (maximum status of a signal) x 4 (direction of a signal) x 4 (situation of a way. normal, gradual slope, steep slope, and diagonal) x 2 (seasonal image. normal and winter) = 384 images are needed.

So currently I'm not thinking about supporting these parameters.

Offline Ves

Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #3 on: October 05, 2017, 09:37:04 AM »
That is fantastic with back and front image! Thanks!

I would like to know, how difficult would it be to add animation frames to the signals? Lots of lots of signals have blinking lights that is part of their models, but which is simply not possible currently. Also flag men, like the ones in pak Britain, would wave their flag, not just hold it.
A small detail, but it would add much to the appearance!

Offline THLeaderH

Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #4 on: October 05, 2017, 10:11:36 AM »
I would like to know, how difficult would it be to add animation frames to the signals? Lots of lots of signals have blinking lights that is part of their models, but which is simply not possible currently. Also flag men, like the ones in pak Britain, would wave their flag, not just hold it.
A small detail, but it would add much to the appearance!
It's unknown, but I guess animation frames would be more difficult than supporting slopes and diagonals, and the latter would be a priority.
I'll consider implementing these parameters, but I cannot promise that. So, I want the great developers of this forum to do the code review and consider the integration.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4806
  • Total likes: 191
  • Helpful: 108
  • Languages: EN, NO
Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #5 on: October 05, 2017, 05:39:33 PM »
I would like to know, how difficult would it be to add animation frames to the signals?

It is not just adding animation frames to the signal that might be the problem, but Simutrans appears. to have some assumptions that most of the world is static. If too much is changing in the world, all the redrawing will bog down performance (not technically technically the redrawing, but close enough). That is probably why season changes happen gradually even horizontally.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15685
  • Total likes: 395
  • Helpful: 174
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #6 on: October 06, 2017, 12:10:27 PM »
This looks interesting. THLeaderH - would you be able to assist in integrating your patch into Extended at some point? The signal graphics code has been altered there, so I anticipate that it will not be a simple matter of copying and pasting your code into Extended to make it work; you might have a better idea of how it should work and therefore how to integrate it than I.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline THLeaderH

Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #7 on: October 06, 2017, 12:15:11 PM »
This looks interesting. THLeaderH - would you be able to assist in integrating your patch into Extended at some point? The signal graphics code has been altered there, so I anticipate that it will not be a simple matter of copying and pasting your code into Extended to make it work; you might have a better idea of how it should work and therefore how to integrate it than I.
Of course ;D

The most important point of this patch is that we have to draw 4 images since a bi-directional sign draws images of 2 directions. So, we have to override display() and display_after() so that a sign can draw 2 images in each layer.
In the perspective of a dat file, we have to distinguish a old style dat file from a new style one. In this patch, if there is no "frontImage[0]" in the dat file and "no_foreground" is not enabled, the roadsign is treated as a old style sign, that means we have to set back and front in a conventional method. Otherwise, the roadsign is treated as a new style sign, that means we have to set layer as is written in the dat file.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15685
  • Total likes: 395
  • Helpful: 174
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #8 on: October 06, 2017, 01:06:23 PM »
Splendid, thank you. Would you be able to produce an Extended compatible patch (either a conventional .patch or .diff file or a Github branch) once you have perfected the Standard version of this? That would be most helpful.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline THLeaderH

Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #9 on: October 06, 2017, 01:16:46 PM »
Amm... I'm considering supporting diagonals and slopes and I'd like to concentrate on it.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15685
  • Total likes: 395
  • Helpful: 174
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #10 on: October 06, 2017, 01:32:16 PM »
Amm... I'm considering supporting diagonals and slopes and I'd like to concentrate on it.

Ahh, I imagine that it would make more sense to integrate this into Extended after the diagonal and slope support has been completed in any event.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline THLeaderH

Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #11 on: October 09, 2017, 03:25:44 AM »
I'm implementing diagonal and slope images for a roadsign and I need a test pak of a roadsign and a signal. However, I do not have a technique to make images so I can't make a roadsign with slope and diagonal images!
Then, I write about how to write the dat file and hope someone makes the roadsign!

Private signs and traffic signals cannot have slope and diagonal images. Traffic signals can be placed only on a n intersection tile, so there is no meaning to have diagonal and slope images. Private signs have a different image direction pattern from others, so it's not supported. Of course traffic signals and private signs can be made with the conventional image definition.

Code: [Select]
obj=roadsign
name=SIS_signal
intro_year=1915
intro_month=1
waytype=track
single_way=0
free_route=0
is_private=0
is_signal=1
is_presignal=0
is_longblocksignal=0
end_of_choose=0
offset_left=0
cost=500
Icon=>
Cursor=
The first part has nothing different from the conventional definition.
However, the image definition is quite different.
Code: [Select]
#flat tile(not diagonal or slope)
#Image[state][direction][snow]
Image[0][N][0]=
Image[0][S][0]=
Image[0][W][0]=
Image[0][E][0]=
Image[1][N][0]=
Image[1][S][0]=
Image[1][W][0]=
Image[1][E][0]=
state is 0 only for signs. In the case of a railway signal, state 0 is red light and state 1 is green light. 2 and 3 is for non-electrified track. In the case of a railway pre-signal, state 0 is red light, state 1 is green light, state 2 is the situation that there is a train two blocks front of this train. 3, 4, and 5 is for non-electrified track.
The snow parameter should be 1 when the image is for winter. Otherwise, should be 0.
Direction [N] means the sign is heading to north.

Code: [Select]
#Diagonal
Diagonal[0][SW][0]=
Diagonal[0][WS][0]=
Diagonal[0][NW][0]=
Diagonal[0][WN][0]=
Diagonal[0][NE][0]=
Diagonal[0][EN][0]=
Diagonal[0][SE][0]=
Diagonal[0][ES][0]=

Diagonal[1][SW][0]=
Diagonal[1][WS][0]=
Diagonal[1][NW][0]=
Diagonal[1][WN][0]=
Diagonal[1][NE][0]=
Diagonal[1][EN][0]=
Diagonal[1][SE][0]=
Diagonal[1][ES][0]=
The state and snow parameter is same as a flat tile.
There are 8 directions. [SW] means the sign is heading to west and the way is connected to south and west. [EN] means the sign is heading to north and the way is connected to east and north.

Code: [Select]
#Slope
ImageUp[0][3][0]=
ImageUp[0][6][0]=
ImageUp[0][9][0]=
ImageUp[0][12][0]=
ImageUp[1][3][0]=
........(omitted)

ImageUp2[0][3][0]=
ImageUp2[0][6][0]=
ImageUp2[0][9][0]=
ImageUp2[0][12][0]=
ImageUp2[1][3][0]=
........(omitted)

ImageDown[0][3][0]=
ImageDown[0][6][0]=
ImageDown[0][9][0]=
ImageDown[0][12][0]=
ImageDown[1][3][0]=
........(omitted)

ImageDown2[0][3][0]=
ImageDown2[0][6][0]=
ImageDown2[0][9][0]=
ImageDown2[0][12][0]=
ImageDown2[1][3][0]=
........(omitted)
I omitted definitions for state 1. Slope has 4 directions, 3,6,9, and 12. It's same as a way and a wayobj.
If the sign is heading to the direction that the way climbs up, it's ImageUp or ImageUp2. If the sign is heading to the direction that the way goes down, it's ImageDown or ImageDown2. Half slope is considered.

When you use front images, Image, Diagonal, and ImageDown become frontImage, frontDiagonal, frontImageDown.

I hope someone makes  a test roadsign pak that has winter images and diagonal and slope images!

Offline Leartin

  • Devotee
  • *
  • Posts: 796
  • Total likes: 287
  • Helpful: 44
  • !!!!!This user was banned for double posting!!!!!
  • Languages: DE, EN
Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #12 on: October 09, 2017, 05:39:30 AM »
Is it fine if it's done in the 192-size I'm accustomed to, or do you need it in 128? Is it fine if different signs/signals use different things, or is one sign that does all required?



And by the way, since you do both two-lane roads and signals: Would it make sense to you if a two-lane monodirectional road would show each sign on both sides of the road, making use of the code used for signals on left?

Offline THLeaderH

Re: Roadsigns(Signals) Front- / BackImage Patch
« Reply #13 on: October 09, 2017, 08:48:48 AM »
If it's made in the 192-size, I'd appreciate and use it. It's OK if different signs/signals use different things.
I do not think that it makes sense to show each sign on both sides of the road on oneway mode road, since the example of that in the real world is not so many, as far as I know.