Skip to content

Commit

Permalink
(station) pamameter for road stops
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Sep 30, 2024
1 parent 6a9fec3 commit db4cf98
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
20 changes: 18 additions & 2 deletions roadstop/lib/roadstop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@


class ARoadStop(grf.SpriteGenerator):
def __init__(self, *, id, translation_name, graphics, callbacks=None, doc_layout=None, is_waypoint=False, **props):
def __init__(
self,
*,
id,
translation_name,
graphics,
callbacks=None,
doc_layout=None,
is_waypoint=False,
enable_if=None,
**props,
):
super().__init__()
self.id = id
self.translation_name = translation_name
Expand All @@ -14,6 +25,7 @@ def __init__(self, *, id, translation_name, graphics, callbacks=None, doc_layout
self.callbacks = grf.make_callback_manager(grf.ROAD_STOP, callbacks)
self.doc_layout = doc_layout
self.is_waypoint = is_waypoint
self.enable_if = enable_if
self._props = props

@property
Expand Down Expand Up @@ -47,6 +59,10 @@ def get_sprites(self, g, sprites=None):

if self.is_waypoint:
res.append(grf.If(is_static=True, variable=0xA1, condition=0x04, value=0x1F000000, skip=255, varsize=4))
if self.enable_if:
for cond in self.enable_if:
res.append(grf.If(is_static=False, variable=cond, condition=0x02, value=0x0, skip=255, varsize=4))

res.append(
definition := grf.Define(
feature=grf.ROAD_STOP,
Expand All @@ -60,7 +76,7 @@ def get_sprites(self, g, sprites=None):
)

res.extend(self.callbacks.make_map_action(definition))
if self.is_waypoint:
if self.is_waypoint or self.enable_if:
res.append(grf.Label(255, bytes()))

return res
Expand Down
5 changes: 5 additions & 0 deletions station/lang/chinese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ STR_PARAM_E88A9CA_ENABLE_MODULAR_DESC :选择是否启用现代芜湖站
STR_PARAM_E88A9CA_ENABLE_MODULAR_ENABLED :启用
STR_PARAM_E88A9CA_ENABLE_MODULAR_DISABLED :禁用

STR_PARAM_E88A9CA_ENABLE_ROADSTOP :芜湖站 - 启用配套的汽车站
STR_PARAM_E88A9CA_ENABLE_ROADSTOP_DESC :选择是否启用现代芜湖站配套的公交车站和路点{}{}注意:路点功能需要 OpenTTD 15.0 或以上版本。
STR_PARAM_E88A9CA_ENABLE_ROADSTOP_ENABLED :启用
STR_PARAM_E88A9CA_ENABLE_ROADSTOP_DISABLED :禁用

STR_PARAM_E88A9CA_INTRODUCTION_YEAR :芜湖站 - 可建造年份
STR_PARAM_E88A9CA_INTRODUCTION_YEAR_DESC :选择芜湖站从哪一年开始可以被建造。{}{}注意:本选项是否生效由“全局设置 - 限定可建造年份”所控制。

Expand Down
5 changes: 5 additions & 0 deletions station/lang/english-uk.lng
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ STR_PARAM_E88A9CA_ENABLE_MODULAR_DESC :Whether or not to enable modular st
STR_PARAM_E88A9CA_ENABLE_MODULAR_ENABLED :Enabled
STR_PARAM_E88A9CA_ENABLE_MODULAR_DISABLED :Disabled

STR_PARAM_E88A9CA_ENABLE_ROADSTOP :Wuhu Station - Enable Road Stops
STR_PARAM_E88A9CA_ENABLE_ROADSTOP_DESC :Whether or not to enable road stops and waypoints to use with Wuhu Station (Modern){}{}Note: the waypoints need OpenTTD 15.0 or above.
STR_PARAM_E88A9CA_ENABLE_ROADSTOP_ENABLED :Enabled
STR_PARAM_E88A9CA_ENABLE_ROADSTOP_DISABLED :Disabled

STR_PARAM_E88A9CA_INTRODUCTION_YEAR :Wuhu Station - Available Year
STR_PARAM_E88A9CA_INTRODUCTION_YEAR_DESC :Choose the year Wuhu Station (Modern) becomes available.{}{}Note: this setting is only effective if allowed by "Global - Station availability".

Expand Down
2 changes: 2 additions & 0 deletions station/lib/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
if s == "E88A9CA":
station_settings.append(Parameter(f"{s}_ENABLE_TEMPLATE", 1, booldict))
station_settings.append(Parameter(f"{s}_ENABLE_MODULAR", 1, booldict))
if s == "E88A9CA":
station_settings.append(Parameter(f"{s}_ENABLE_ROADSTOP", 1, booldict))
station_settings.append(Parameter(f"{s}_INTRODUCTION_YEAR", year, limits=(0, 9999)))
station_settings.append(Parameter("E88A9CP_ENABLE_MODULAR", 1, booldict))

Expand Down
3 changes: 3 additions & 0 deletions station/stations/dovemere_2018_lib/roadstops.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
AChildSprite,
ALayout,
)
from station.lib.parameters import parameter_list
from agrf.graphics.voxel import LazyVoxel
from agrf.graphics import SCALE_TO_ZOOM
from agrf.magic import Switch
Expand Down Expand Up @@ -88,6 +89,7 @@
graphics=Switch(ranges={4: cur, 5: cur.M}, default=cur, code="view"),
general_flags=0x8,
class_label=b"\xe8\x8a\x9cR",
enable_if=[parameter_list.index("E88A9CA_ENABLE_ROADSTOP")],
doc_layout=cur,
)
roadstops.append(cur_roadstop)
Expand All @@ -97,6 +99,7 @@
graphics=Switch(ranges={4: cur, 5: cur.M}, default=cur, code="view"),
general_flags=0x8,
class_label=b"\xe8\x8a\x9cR",
enable_if=[parameter_list.index("E88A9CA_ENABLE_ROADSTOP")],
doc_layout=cur,
is_waypoint=True,
)
Expand Down

0 comments on commit db4cf98

Please sign in to comment.