Skip to content

Commit

Permalink
(Aegis) a more readable string-based pseudoswitch
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Oct 27, 2023
1 parent db1a09a commit 19565e9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
5 changes: 5 additions & 0 deletions agrf/parameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ def add(self, g, s):
enum={k: s[f"STR_PARAM_{self.name}_{v}"] for k, v in self.enum.items()},
)

def set_index(self, index):
self.index = index


class ParameterList:
def __init__(self, parameters):
self.parameters = parameters
for i, p in enumerate(parameters):
p.set_index(i)

def add(self, g, s):
for p in self.parameters:
Expand Down
18 changes: 9 additions & 9 deletions industry/industries/forest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
name="Forest",
override_type=0x03,
layouts=SplitDefinition(
9,
"INDUSTRY_SIZE",
{
0: transcribe(enormous_set, tile_map),
1: transcribe(huge_set, tile_map),
2: transcribe(large_set, tile_map),
3: transcribe(medium_set, tile_map),
4: transcribe(small_set, tile_map),
5: transcribe(tiny_set, tile_map),
6: transcribe(one_grid_set, tile_map),
7: transcribe(one_grid_set, tile_map),
"ENORMOUS": transcribe(enormous_set, tile_map),
"HUGE": transcribe(huge_set, tile_map),
"LARGE": transcribe(large_set, tile_map),
"MEDIUM": transcribe(medium_set, tile_map),
"SMALL": transcribe(small_set, tile_map),
"TINY": transcribe(tiny_set, tile_map),
"ONE_TILE": transcribe(one_grid_set, tile_map),
"ONE_TILE_FLAT": transcribe(one_grid_set, tile_map),
},
),
mapgen_probability=10,
Expand Down
2 changes: 1 addition & 1 deletion industry/lang/chinese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ STR_PARAM_INDUSTRY_SIZE_DESC :选择工业的占地大小
STR_PARAM_INDUSTRY_SIZE_ENORMOUS:大得离谱
STR_PARAM_INDUSTRY_SIZE_HUGE :巨大
STR_PARAM_INDUSTRY_SIZE_LARGE :大
STR_PARAM_INDUSTRY_SIZE_REGULAR :中
STR_PARAM_INDUSTRY_SIZE_MEDIUM :中
STR_PARAM_INDUSTRY_SIZE_SMALL :小
STR_PARAM_INDUSTRY_SIZE_TINY :特小
STR_PARAM_INDUSTRY_SIZE_ONE_TILE:一格
Expand Down
2 changes: 1 addition & 1 deletion industry/lang/english-uk.lng
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ STR_PARAM_INDUSTRY_SIZE_DESC :Choose the visual size of the industries
STR_PARAM_INDUSTRY_SIZE_ENORMOUS:Enormous
STR_PARAM_INDUSTRY_SIZE_HUGE :Huge
STR_PARAM_INDUSTRY_SIZE_LARGE :Large
STR_PARAM_INDUSTRY_SIZE_REGULAR :Regular
STR_PARAM_INDUSTRY_SIZE_MEDIUM :Medium
STR_PARAM_INDUSTRY_SIZE_SMALL :Small
STR_PARAM_INDUSTRY_SIZE_TINY :Tiny
STR_PARAM_INDUSTRY_SIZE_ONE_TILE:One Tile
Expand Down
6 changes: 6 additions & 0 deletions industry/lib/industry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import grf
from industry.lib.parameters import parameter_list
from .transcriber import transcribe
from .symmetrizer import symmetrize

Expand All @@ -9,6 +10,11 @@ def __init__(self, variables, branches):
# Legacy format
variables = (variables,)
branches = {(i,): b for i, b in branches.items()}
if isinstance(variables, str):
idx = parameter_list.index(variables)
p = parameter_list.parameters[idx]
variables = (idx,)
branches = {(next(k for k, v in p.enum.items() if v == i),): b for i, b in branches.items()}
self.variables = variables
self.branches = branches

Expand Down
2 changes: 1 addition & 1 deletion industry/lib/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
0: "ENORMOUS",
1: "HUGE",
2: "LARGE",
3: "REGULAR",
3: "MEDIUM",
4: "SMALL",
5: "TINY",
6: "ONE_TILE",
Expand Down

0 comments on commit 19565e9

Please sign in to comment.