Skip to content

Commit

Permalink
Add: trackless platforms && cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
WenSimEHRP committed May 19, 2024
1 parent 1eebd5b commit 51cac30
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 101 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ root = true
# default style settings
[*]
charset = utf-8
end_of_line = crlf
indent_size = 4
indent_style = space
insert_final_newline = true
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ sprites/
*.png
custom_tags.txt
cns.nml
!palette.png
!palette.png
18 changes: 11 additions & 7 deletions lang/english.lng
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ STR_OPENTTD :OpenTTD
# NPLAT = nothern platform
# SPLAT = southern platform
# SHELTER = shelter
STR_PLATFORMS :CNS: Platforms
STR_PLATFORMS :{PUSH_COLOUR}{WHITE}CNS:{POP_COLOUR} Platforms
STR_TRACKLESS_PLATFORMS :{PUSH_COLOUR}{WHITE}|>{POP_COLOUR} Trackless Platforms
STR_ADDI_PLAT :{PUSH_COLOUR}{WHITE}|>{POP_COLOUR} Extra platforms
STR_FULL_PLAT :{PUSH_COLOUR}{WHITE}|>{POP_COLOUR} Full platforms
STR_BUILDINGS :{PUSH_COLOUR}{WHITE}|>{POP_COLOUR} Buildings

STR_NPLAT_0 :{PUSH_COLOUR}{GREEN}N{POP_COLOUR}
STR_NPLAT_1 :{PUSH_COLOUR}{RED}N{POP_COLOUR}
STR_SPLAT_0 :{PUSH_COLOUR}{GREEN}S{POP_COLOUR}
STR_SPLAT_1 :{PUSH_COLOUR}{RED}S{POP_COLOUR}
STR_SHELTER_0 :{PUSH_COLOUR}{GREEN}S{POP_COLOUR}
STR_SHELTER_1 :{PUSH_COLOUR}{RED}S{POP_COLOUR}
STR_NPLAT_0 :{PUSH_COLOUR}{GREEN}N{POP_COLOUR}
STR_NPLAT_1 :{PUSH_COLOUR}{RED}N{POP_COLOUR}
STR_SPLAT_0 :{PUSH_COLOUR}{GREEN}S{POP_COLOUR}
STR_SPLAT_1 :{PUSH_COLOUR}{RED}S{POP_COLOUR}
STR_SHELTER_0 :{PUSH_COLOUR}{GREEN}S{POP_COLOUR}
STR_SHELTER_1 :{PUSH_COLOUR}{RED}S{POP_COLOUR}

STR_STATION_WRAPPER :Platform ({STRING}{STRING}{STRING})
18 changes: 11 additions & 7 deletions lang/simplified_chinese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ STR_OPENTTD :OpenTTD
# NPLAT = nothern platform
# SPLAT = southern platform
# SHELTER = shelter
STR_PLATFORMS :CNS:站台
STR_PLATFORMS :{PUSH_COLOUR}{WHITE}CNS:{POP_COLOUR}站台
STR_TRACKLESS_PLATFORMS :{PUSH_COLOUR}{WHITE}|>{POP_COLOUR} 无轨站台
STR_ADDI_PLAT :{PUSH_COLOUR}{WHITE}|>{POP_COLOUR} 额外站台
STR_FULL_PLAT :{PUSH_COLOUR}{WHITE}|>{POP_COLOUR} 全格站台
STR_BUILDINGS :{PUSH_COLOUR}{WHITE}|>{POP_COLOUR} 车站建筑

STR_NPLAT_0 :{PUSH_COLOUR}{GREEN}北{POP_COLOUR}
STR_NPLAT_1 :{PUSH_COLOUR}{RED}北{POP_COLOUR}
STR_SPLAT_0 :{PUSH_COLOUR}{GREEN}南{POP_COLOUR}
STR_SPLAT_1 :{PUSH_COLOUR}{RED}南{POP_COLOUR}
STR_SHELTER_0 :{PUSH_COLOUR}{GREEN}雨{POP_COLOUR}
STR_SHELTER_1 :{PUSH_COLOUR}{RED}雨{POP_COLOUR}
STR_NPLAT_0 :{PUSH_COLOUR}{GREEN}北{POP_COLOUR}
STR_NPLAT_1 :{PUSH_COLOUR}{RED}北{POP_COLOUR}
STR_SPLAT_0 :{PUSH_COLOUR}{GREEN}南{POP_COLOUR}
STR_SPLAT_1 :{PUSH_COLOUR}{RED}南{POP_COLOUR}
STR_SHELTER_0 :{PUSH_COLOUR}{GREEN}雨{POP_COLOUR}
STR_SHELTER_1 :{PUSH_COLOUR}{RED}雨{POP_COLOUR}

STR_STATION_WRAPPER :站台({1:STRING}{0:STRING}{2:STRING})
3 changes: 2 additions & 1 deletion src/defines.pnml
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@

#define STANDARD_PLATFORM_BITS 3 << 14

#define NPLAT_BIT 7 // 0 only
#define NPLAT_BIT 0 // 0 only
#define SPLAT_BIT 1 // 1 only
#define SHELTER_BIT 2 // 2 only
#define PLATFORM_SPRITESET_BITS 3 // 3 and 4
#define SHELTER_SPRITESET_BITS 5 // 5 and 6
#define GROUND_TYPE_BITS 7 // 7 and 8
4 changes: 2 additions & 2 deletions src/templates.pnml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define PATH "vox/"+a+"_32bpp.png"

// empty templates and sprites will be removed after the release of NML 0.7.5
// empty templates and sprites will be removed after the release of NML 0.7.5
// currently for maximum compatibility we need to keep them

template template_platform_NW (a) {[POSITION_X * 0, POSITION_Y, SIZE_X, SIZE_Y, -127, -182, PATH]}
Expand All @@ -28,4 +28,4 @@ template template_fence_SE (a) {[POSITION_X * 2, POSITION_Y, SIZE_X, SIZE_Y, -25
template template_fence_SW (a) {[POSITION_X * 3, POSITION_Y, SIZE_X, SIZE_Y, 0, -245, PATH]}


template template_platform_zero (pos, a) {[POSITION_X * pos, POSITION_Y, SIZE_X, SIZE_Y, 0, 0, PATH]}
template template_platform_zero (pos, a) {[POSITION_X * pos, POSITION_Y, SIZE_X, SIZE_Y, 0, 0, PATH]}
178 changes: 96 additions & 82 deletions src/testing.pnml
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,37 @@
#define TEMP_NEARBY_TILE_PERPENDICULAR 11
#define TEMP_NEARBY_TILE_GRF 12

spriteset (s_platform_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {
template_platform_NW("platforms/platform_concrete")
template_platform_NE("platforms/platform_concrete")
template_platform_SE("platforms/platform_concrete")
template_platform_SW("platforms/platform_concrete")
// asym platforms, soooooo strange
template_platform_NW("asym_platforms/platform_concrete_slope")
template_asymplat_NE("asym_platforms/platform_concrete_slope")
template_asymplat_SE("asym_platforms/platform_concrete_slope")
template_platform_SW("asym_platforms/platform_concrete_slope")
template_asymplat_NW("asym_platforms/platform_concrete_slope")
template_platform_NE("asym_platforms/platform_concrete_slope")
template_platform_SE("asym_platforms/platform_concrete_slope")
template_asymplat_SW("asym_platforms/platform_concrete_slope")
#define NORMAL_PLATFORM_SPRITESET(num, name)\
spriteset (s_platform_##num, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {\
template_platform_NW("platforms/" + name)\
template_platform_NE("platforms/" + name)\
template_platform_SE("platforms/" + name)\
template_platform_SW("platforms/" + name)\
\
template_platform_NW("asym_platforms/" + name + "_slope")\
template_asymplat_NE("asym_platforms/" + name + "_slope")\
template_asymplat_SE("asym_platforms/" + name + "_slope")\
template_platform_SW("asym_platforms/" + name + "_slope")\
\
template_asymplat_NW("asym_platforms/" + name + "_slope")\
template_platform_NE("asym_platforms/" + name + "_slope")\
template_platform_SE("asym_platforms/" + name + "_slope")\
template_asymplat_SW("asym_platforms/" + name + "_slope")\
}

spriteset (s_platform_1, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {
template_platform_NW("platforms/platform_brick")
template_platform_NE("platforms/platform_brick")
template_platform_SE("platforms/platform_brick")
template_platform_SW("platforms/platform_brick")
// asym platforms, soooooo strange
template_platform_NW("asym_platforms/platform_brick_slope")
template_asymplat_NE("asym_platforms/platform_brick_slope")
template_asymplat_SE("asym_platforms/platform_brick_slope")
template_platform_SW("asym_platforms/platform_brick_slope")
template_asymplat_NW("asym_platforms/platform_brick_slope")
template_platform_NE("asym_platforms/platform_brick_slope")
template_platform_SE("asym_platforms/platform_brick_slope")
template_asymplat_SW("asym_platforms/platform_brick_slope")
#define SHELTER_SPRITESET(num, name)\
spriteset (s_shelter_##num, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {\
NW: template_platform_zero(0, "shelters/" + name)\
NE: template_platform_zero(1, "shelters/" + name)\
SE: template_platform_zero(2, "shelters/" + name)\
SW: template_platform_zero(3, "shelters/" + name)\
}

spriteset (s_shelter_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {
NW: template_platform_zero(0, "shelters/shelter1")
NE: template_platform_zero(1, "shelters/shelter1")
SE: template_platform_zero(2, "shelters/shelter1")
SW: template_platform_zero(3, "shelters/shelter1")
}
NORMAL_PLATFORM_SPRITESET(0, "platform_concrete")
NORMAL_PLATFORM_SPRITESET(1, "platform_brick")

spriteset (s_shelter_1, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {
NW: template_platform_zero(0, "shelters/shelter2")
NE: template_platform_zero(1, "shelters/shelter2")
SE: template_platform_zero(2, "shelters/shelter2")
SW: template_platform_zero(3, "shelters/shelter2")
}
SHELTER_SPRITESET(0, "shelter1")
SHELTER_SPRITESET(1, "shelter2")

spriteset (s_test_bufferstop, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {
NW: template_bufferstop_NW("extras/bufferstop")
Expand All @@ -93,28 +79,18 @@ spriteset (s_test_fence, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {
((!getbits(LOAD_TEMP(TEMP_NEARBY_TILE_STATION), TILE_X_SW, 1) | getbits(LOAD_TEMP(TILE_X_SW), SPLAT_BIT, 1) & getbits(LOAD_TEMP(TEMP_NEARBY_TILE_GRF), TILE_X_SW, 1)) << 0|\
(!getbits(LOAD_TEMP(TEMP_NEARBY_TILE_STATION), TILE_X_NE, 1) | getbits(LOAD_TEMP(TILE_X_NE), SPLAT_BIT, 1) & getbits(LOAD_TEMP(TEMP_NEARBY_TILE_GRF), TILE_X_NE, 1)) << 1)

spritelayout sp_test_x(hide_platform_nw, hide_platform_se, hide_shelter) {
ground {sprite: GROUNDSPRITE_RAIL_X;}
spritelayout sp_test_x(hide_platform_nw, hide_platform_se, hide_shelter, ground_type) {
ground {sprite: ground_type == 1? GROUNDSPRITE_NORMAL: ground_type == 2? GROUNDSPRITE_CONCRETE: GROUNDSPRITE_RAIL_X;}
building { // bufferstop
sprite: s_test_bufferstop(NE);
BUFFERSTOP_BBOX_NE // macro
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_NE, 1);
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_NE, 1) || ground_type;
}
building { // bufferstop
sprite: s_test_bufferstop(SW);
BUFFERSTOP_BBOX_SW // macro
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_SW, 1);
}/*
building { // fence
sprite: s_test_fence(NW);
FENCE_BBOX_NW
hide_sprite: getbits(LOAD_TEMP(10), 2 ,1);
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_SW, 1) || ground_type;
}
building { // fence
sprite: s_test_fence(SE);
FENCE_BBOX_SE
hide_sprite: getbits(LOAD_TEMP(10), 3, 1);
}*/
building { // station platform, macro is used to define the bounding box.
sprite: CUSTOM(0, 0 + GET_NPLAT_FORMATION % 3 * 4);
PLATFORM_BBOX_NW // macro
Expand All @@ -135,28 +111,18 @@ spritelayout sp_test_x(hide_platform_nw, hide_platform_se, hide_shelter) {
}
}

spritelayout sp_test_y(hide_platform_ne, hide_platform_sw, hide_shelter) {
ground {sprite: GROUNDSPRITE_RAIL_Y;}
spritelayout sp_test_y(hide_platform_ne, hide_platform_sw, hide_shelter, ground_type) {
ground {sprite: ground_type == 1? GROUNDSPRITE_NORMAL: ground_type == 2? GROUNDSPRITE_CONCRETE: GROUNDSPRITE_RAIL_Y;}
building {
sprite: s_test_bufferstop(NW);
BUFFERSTOP_BBOX_NW // macro
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_NE, 1);
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_NE, 1) || ground_type;
}
building {
sprite: s_test_bufferstop(SE);
BUFFERSTOP_BBOX_SE // macro
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_SW, 1);
}/*
building {
sprite: s_test_fence(NE);
FENCE_BBOX_NE
hide_sprite: getbits(LOAD_TEMP(10), 2, 1);
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_SW, 1) || ground_type;
}
building {
sprite: s_test_fence(SW);
FENCE_BBOX_SW
hide_sprite: getbits(LOAD_TEMP(10), 3, 1);
}*/
building { // station platform, macros are still used
sprite: CUSTOM(0, 1 + GET_NPLAT_FORMATION % 3 * 4);
PLATFORM_BBOX_NE // macro
Expand Down Expand Up @@ -195,14 +161,16 @@ switch (FEAT_STATIONS, SELF, sw_check_nearby_tile_station,
nearby_tile_is_station(-1, 1) << TILE_X_E) {return;}

switch (FEAT_STATIONS, SELF, sw_check_nearby_tile_perpendicular,
(nearby_tile_perpendicular(-1, 0) == 1) << TILE_X_NE|
(nearby_tile_perpendicular( 1, 0) == 1) << TILE_X_SW|
(nearby_tile_perpendicular( 0,-1) == 1) << TILE_X_NW|
(nearby_tile_perpendicular( 0, 1) == 1) << TILE_X_SE|
(nearby_tile_perpendicular(-1,-1) == 1) << TILE_X_N|
(nearby_tile_perpendicular( 1, 1) == 1) << TILE_X_S|
(nearby_tile_perpendicular( 1,-1) == 1) << TILE_X_W|
(nearby_tile_perpendicular(-1, 1) == 1) << TILE_X_E) {return;}
nearby_tile_perpendicular(-1, 0) == 1 << TILE_X_NE|
nearby_tile_perpendicular( 1, 0) == 1 << TILE_X_SW|
nearby_tile_perpendicular( 0,-1) == 1 << TILE_X_NW|
nearby_tile_perpendicular( 0, 1) == 1 << TILE_X_SE|
nearby_tile_perpendicular(-1,-1) == 1 << TILE_X_N|
nearby_tile_perpendicular( 1, 1) == 1 << TILE_X_S|
nearby_tile_perpendicular( 1,-1) == 1 << TILE_X_W|
nearby_tile_perpendicular(-1, 1) == 1 << TILE_X_E) {return;}

//TODO: if openttd/nml #330 is merged, change "other" to "same"

switch (FEAT_STATIONS, SELF, sw_check_nearby_tile_grf,
nearby_tile_other_grf(-1, 0) << TILE_X_NE|
Expand All @@ -214,6 +182,16 @@ switch (FEAT_STATIONS, SELF, sw_check_nearby_tile_grf,
nearby_tile_other_grf( 1,-1) << TILE_X_W|
nearby_tile_other_grf(-1, 1) << TILE_X_E) {return;}

//switch (FEAT_STATIONS, SELF, sw_check_nearby_tile_grf,
// nearby_tile_same_grf(-1, 0) << TILE_X_NE|
// nearby_tile_same_grf( 1, 0) << TILE_X_SW|
// nearby_tile_same_grf( 0,-1) << TILE_X_NW|
// nearby_tile_same_grf( 0, 1) << TILE_X_SE|
// nearby_tile_same_grf(-1,-1) << TILE_X_N|
// nearby_tile_same_grf( 1, 1) << TILE_X_S|
// nearby_tile_same_grf( 1,-1) << TILE_X_W|
// nearby_tile_same_grf(-1, 1) << TILE_X_E) {return;}

switch (FEAT_STATIONS, SELF, sw_test, [
STORE_TEMP(sw_check_rail_continuation(), TEMP_RAIL_CONTINUATION),
STORE_TEMP(nearby_tile_station_id(-1, 0), TILE_X_NE),
Expand All @@ -234,34 +212,70 @@ switch (FEAT_STATIONS, SELF, sw_test, [
#define STANDARD_STATION(hide_nplat, hide_splat, hide_shelter, platform_spriteset, shelter_spriteset) \
item (FEAT_STATIONS, i_station_##hide_nplat##hide_splat##hide_shelter##platform_spriteset##shelter_spriteset, \
hide_nplat << NPLAT_BIT | hide_splat << SPLAT_BIT | hide_shelter << SHELTER_BIT |\
platform_spriteset << PLATFORM_SPRITESET_BITS | shelter_spriteset << SHELTER_SPRITESET_BITS|\
platform_spriteset << PLATFORM_SPRITESET_BITS | shelter_spriteset << SHELTER_SPRITESET_BITS |\
STANDARD_PLATFORM_BITS) {\
property {\
class: "CNS1";\
classname: string(STR_PLATFORMS);\
name: string(STR_STATION_WRAPPER,string(STR_NPLAT_##hide_nplat),string(STR_SPLAT_##hide_splat),string(STR_SHELTER_##hide_shelter));\
}\
graphics {\
sprite_layouts: [sp_test_x(hide_nplat, hide_splat, hide_shelter), sp_test_y(hide_nplat, hide_splat, hide_shelter)];\
sprite_layouts: [sp_test_x(hide_nplat, hide_splat, hide_shelter, 0), sp_test_y(hide_nplat, hide_splat, hide_shelter, 0)];\
custom_spritesets: [s_platform_##platform_spriteset, s_shelter_##shelter_spriteset];\
prepare_layout: sw_test();\
}\
}

#define TRACKLESS_STATION(hide_nplat, hide_splat, hide_shelter, platform_spriteset, shelter_spriteset, ground_type) \
item (FEAT_STATIONS, i_station_##hide_nplat##hide_splat##hide_shelter##platform_spriteset##shelter_spriteset##ground_type, \
hide_nplat << NPLAT_BIT | hide_splat << SPLAT_BIT | hide_shelter << SHELTER_BIT |\
platform_spriteset << PLATFORM_SPRITESET_BITS | shelter_spriteset << SHELTER_SPRITESET_BITS |\
STANDARD_PLATFORM_BITS | ground_type << GROUND_TYPE_BITS) {\
property {\
class: "CNS2";\
classname: string(STR_TRACKLESS_PLATFORMS);\
name: string(STR_STATION_WRAPPER,string(STR_NPLAT_##hide_nplat),string(STR_SPLAT_##hide_splat),string(STR_SHELTER_##hide_shelter));\
non_traversable_tiles: STAT_ALL_TILES;\
}\
graphics {\
sprite_layouts: [sp_test_x(hide_nplat, hide_splat, hide_shelter, ground_type), sp_test_y(hide_nplat, hide_splat, hide_shelter, ground_type)];\
custom_spritesets: [s_platform_##platform_spriteset, s_shelter_##shelter_spriteset];\
prepare_layout: sw_test();\
}\
}

#define GRASS 1
#define CEMENT 2

#define TRACKLESS_STATION_DEFINES(a,b,ground_type) \
TRACKLESS_STATION(0,0,0,a,b,ground_type)\
TRACKLESS_STATION(0,1,0,a,b,ground_type)\
TRACKLESS_STATION(1,0,0,a,b,ground_type)

#define STANDARD_STATION_DEFINES(a,b) \
STANDARD_STATION(0,0,0,a,b)\
STANDARD_STATION(0,1,0,a,b)\
STANDARD_STATION(1,0,0,a,b)\
STANDARD_STATION(1,0,0,a,b)

STANDARD_STATION_DEFINES(0,0)
STANDARD_STATION_DEFINES(0,1)
STANDARD_STATION(0,0,1,0,1)\
STANDARD_STATION(0,1,1,0,1)\
STANDARD_STATION(1,0,1,0,1)\
STANDARD_STATION_DEFINES(1,0)
STANDARD_STATION_DEFINES(1,1)
STANDARD_STATION(0,0,1,0,1)
STANDARD_STATION(0,1,1,0,1)
STANDARD_STATION(1,0,1,0,1)

STANDARD_STATION(1,1,1,0,0)

TRACKLESS_STATION_DEFINES(0,0,GRASS)
TRACKLESS_STATION_DEFINES(0,1,GRASS)
TRACKLESS_STATION_DEFINES(1,0,GRASS)
TRACKLESS_STATION_DEFINES(1,1,GRASS)
TRACKLESS_STATION_DEFINES(0,0,CEMENT)
TRACKLESS_STATION_DEFINES(0,1,CEMENT)
TRACKLESS_STATION_DEFINES(1,0,CEMENT)
TRACKLESS_STATION_DEFINES(1,1,CEMENT)

#undef STANDARD_STATION
#undef STANDARD_STATION_DEFINES

Expand Down

0 comments on commit 51cac30

Please sign in to comment.