Skip to content

Commit

Permalink
(Rv) Migrate to parameter list
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Nov 22, 2023
1 parent 265da3b commit 68355ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
24 changes: 6 additions & 18 deletions road_vehicle/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,17 @@ def gen(fast):
preferred_blitter=grf.NewGRF.BLITTER_BPP_32,
)

from road_vehicle.lib.parameters import parameter_list

parameter_list.add(g, s)

# Parameter 0
g.add_int_parameter(
name=s["STR_PARAM_VANILLA_RV"],
description=s["STR_PARAM_VANILLA_RV_DESC"],
default=0,
limits=(0, 1),
enum={0: s["STR_PARAM_VANILLA_RV_DISABLED"], 1: s["STR_PARAM_VANILLA_RV_ENABLED"]},
g.add(
grf.If(is_static=True, variable=parameter_list.index("VANILLA_RV"), condition=0x02, value=1, skip=1, varsize=4)
)
g.add(grf.If(is_static=True, variable=0, condition=0x02, value=1, skip=1, varsize=4))
g.add(grf.DisableDefault(grf.RV, range(88)))

# Parameter 1
g.add_int_parameter(
name=s["STR_PARAM_NIGHT_MODE"],
description=s["STR_PARAM_NIGHT_MODE_DESC"],
default=0,
limits=(0, 2),
enum={
0: s["STR_PARAM_NIGHT_MODE_AUTO_DETECT"],
1: s["STR_PARAM_NIGHT_MODE_ENABLED"],
2: s["STR_PARAM_NIGHT_MODE_DISABLED"],
},
)
nightgfx_id = struct.unpack("<I", b"\xffOTN")[0]
g.add(grf.ComputeParameters(target=0x41, operation=0x00, if_undefined=False, source1=0xFF, source2=0xFF, value=1))
g.add(grf.If(is_static=False, variable=0x88, condition=0x06, value=nightgfx_id, skip=1, varsize=4))
Expand Down
16 changes: 16 additions & 0 deletions road_vehicle/lib/parameters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from agrf.parameters import Parameter, ParameterList, SearchSpace


parameter_list = ParameterList(
[
Parameter(
"VANILLA_RV",
0,
{
0: "DISABLED",
1: "ENABLED",
},
),
Parameter("NIGHT_MODE", 0, {0: "AUTO_DETECT", 1: "ENABLED", 2: "DISABLED"}),
]
)

0 comments on commit 68355ff

Please sign in to comment.