Skip to content

Commit

Permalink
Add: Support for roadtype direction markings (OpenTTD#274)
Browse files Browse the repository at this point in the history
OTTD #10282
Trivial NML change and add them to the example.
  • Loading branch information
FLHerne authored Jun 28, 2023
1 parent a9a1a3e commit 0a6dcdb
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 144 deletions.
34 changes: 34 additions & 0 deletions examples/roadtype_and_tramtype/example_roadtype_and_tramtype.nml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,37 @@ spriteset(roadstop_underlay_yellow, "gfx/roads_yellow.png") {
tmpl_underlay_roadstop()
}

/**********************************************
* Direction overlay sprites:
**********************************************/

spriteset(st_direction_markings, "gfx/direction_markings.png") {
/* Flat ground */
[ 34, 8, 24, 16, -10, -9 ]
[ 66, 8, 24, 16, -13, -7 ]
[ 98, 8, 24, 16, -12, -8 ]
[ 130, 8, 24, 16, -15, -10 ]
[ 162, 8, 24, 16, -12, -9 ]
[ 194, 8, 24, 16, -11, -8 ]

/* Slopes with N corner raised */
[ 34, 40, 24, 16, -13, -10 ]
[ 66, 40, 24, 16, -12, -8 ]
[ 98, 40, 24, 16, -12, -9 ]
[ 130, 40, 24, 16, -11, -8 ]
[ 162, 40, 24, 16, -9, -10 ]
[ 194, 40, 24, 16, -10, -9 ]

/* Slopes with S corner raised */
[ 34, 72, 24, 16, -8, -11 ]
[ 66, 72, 24, 16, -11, -5 ]
[ 98, 72, 24, 16, -12, -8 ]
[ 130, 72, 24, 16, -12, -5 ]
[ 162, 72, 24, 16, -14, -10 ]
[ 194, 72, 24, 16, -12, -8 ]
}


/**********************************************
* Roadtype definitions:
**********************************************/
Expand Down Expand Up @@ -245,6 +276,7 @@ item(FEAT_ROADTYPES, red_road, 5) {
roadstops: roadstop_underlay_red;
// gui: gui_normal;
/* Catenary is not not implemented here, use the default */
direction_markings: st_direction_markings;
}
}

Expand All @@ -271,6 +303,7 @@ item(FEAT_ROADTYPES, blue_road, 6) {
roadstops: roadstop_underlay_blue;
// gui: gui_normal;
/* Catenary is not not implemented here, use the default */
direction_markings: st_direction_markings;
}
}

Expand All @@ -297,6 +330,7 @@ item(FEAT_ROADTYPES, yellow_road, 7) {
roadstops: roadstop_underlay_yellow;
// gui: gui_normal;
/* Catenary is not not implemented here, use the default */
direction_markings: st_direction_markings;
}
}
/**********************************************
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions nml/actions/action3_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,16 @@ def vehicle_length(value):
# Roadtypes
callbacks[0x12] = {
# No default here, it makes no sense
'gui' : {'type': 'cargo', 'num': 0x00},
'track_overlay' : {'type': 'cargo', 'num': 0x01},
'underlay' : {'type': 'cargo', 'num': 0x02},
'tunnels' : {'type': 'cargo', 'num': 0x03},
'catenary_front' : {'type': 'cargo', 'num': 0x04},
'catenary_back' : {'type': 'cargo', 'num': 0x05},
'bridge_surfaces' : {'type': 'cargo', 'num': 0x06},
'depots' : {'type': 'cargo', 'num': 0x08},
'roadstops' : {'type': 'cargo', 'num': 0x0A},
'gui' : {'type': 'cargo', 'num': 0x00},
'track_overlay' : {'type': 'cargo', 'num': 0x01},
'underlay' : {'type': 'cargo', 'num': 0x02},
'tunnels' : {'type': 'cargo', 'num': 0x03},
'catenary_front' : {'type': 'cargo', 'num': 0x04},
'catenary_back' : {'type': 'cargo', 'num': 0x05},
'bridge_surfaces' : {'type': 'cargo', 'num': 0x06},
'depots' : {'type': 'cargo', 'num': 0x08},
'roadstops' : {'type': 'cargo', 'num': 0x0A},
'direction_markings' : {'type': 'cargo', 'num': 0x0B},
}

# Tramtypes
Expand Down
2 changes: 1 addition & 1 deletion nml/actions/action5.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Action5BlockType:
"TTDP_GUI_25": (0x07, 73, Action5BlockType.FIXED),
"TTDP_GUI": (0x07, 93, Action5BlockType.FIXED),
"CANALS": (0x08, 65, Action5BlockType.OFFSET),
"ONE_WAY_ROAD": (0x09, 6, Action5BlockType.OFFSET),
"ONE_WAY_ROAD": (0x09, 18, Action5BlockType.OFFSET),
"COLOURMAP_2CC": (0x0A, 256, Action5BlockType.OFFSET),
"TRAMWAY": (0x0B, 119, Action5BlockType.OFFSET),
"SNOWY_TEMPERATE_TREES": (0x0C, 133, Action5BlockType.FIXED),
Expand Down
Binary file modified regression/expected/009_replace.grf
Binary file not shown.
2 changes: 1 addition & 1 deletion regression/expected/009_replace.nfo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
4 opengfx_generic_trams1.pcx 8bpp 48 56 8 18 -3 -10 normal
5 opengfx_generic_trams1.pcx 8bpp 48 56 8 18 -3 4 normal

6 * 5 05 09 FF \w6
6 * 8 05 89 FF \w6 FF \w0

7 oneway.png 8bpp 18 8 24 16 -12 -8 normal
8 oneway.png 8bpp 50 8 24 16 -12 -8 normal
Expand Down
Binary file modified regression/expected/example_roadtype_and_tramtype.grf
Binary file not shown.
Loading

0 comments on commit 0a6dcdb

Please sign in to comment.