Skip to content

Commit

Permalink
fix enable disable menus from after the menu class reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
EphDoering committed Oct 21, 2024
1 parent 67ccf06 commit 4e37200
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions map_gen_setting_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def val_to_string(self, *args):
def save_val(self, val, *args):
l_args = list(args)
item = self.obj
for key in self.path[:-1]:
for key in self.path:
if key == "_arg":
key = l_args.pop(0)
prev_item = item
Expand Down Expand Up @@ -58,9 +58,9 @@ def got_toggled(self, *args):

def remake_submenu(self):
if self.enabler.val:
self.submenu = self.full_submenu
self.items = self.full_submenu
else:
self.submenu = self.submenu[:2]
self.items = self.items[:2]

def __call__(self, *args):
self.remake_submenu()
Expand All @@ -80,11 +80,15 @@ def __init__(

def __call__(self, *args):
super().__call__(*args)
self.parent().got_toggled(*args)
self.parent().remake_submenu()
return 0


class autoplace_enable_disable_menu(enable_disable_menu):
"""This is used because when on autoplace control is disabled
the subitems are just set to zero."""

def got_toggled(self, *args):
if not self.enabler.val:
for sub in self.full_submenu[2:]:
Expand Down Expand Up @@ -525,7 +529,7 @@ def launch_new_preset(preset, *args):
return launch_new_game_from_params(["--preset", p])


def launch_new(*args):
def launch_new_custom(*args):
mgs_path = fa_paths.SCRIPT_OUTPUT.joinpath("map_gen.json")
ms_path = fa_paths.SCRIPT_OUTPUT.joinpath("map.json")
files = {"basic_settings": mgs_path, "advanced_settings": ms_path}
Expand All @@ -546,18 +550,21 @@ def launch_new(*args):
("gui-map-generator.terrain-tab-title",): {
"map_type": mgs_json["property_expression_names"]["elevation"],
"Water": autoplace_enable_disable_menu(
("gui-map-generator.water",),
{"Scale": mgs_json["terrain_segmentation"], "Coverage": mgs_json["water"]},
("size.only-starting-area",),
name=("gui-map-generator.water",),
submenu={
"Scale": mgs_json["terrain_segmentation"],
"Coverage": mgs_json["water"],
},
desc=("size.only-starting-area",),
),
},
("gui-map-generator.enemy-tab-title",): {},
("gui-map-generator.advanced-tab-title",): {
"Record replay information": fa_menu.setting_menu_bool(
("gui-map-generator.enable-replay",),
("gui-map-generator.enable-replay-description",),
False,
False,
title=("gui-map-generator.enable-replay",),
desc=("gui-map-generator.enable-replay-description",),
default=False,
val=False,
),
("gui-map-generator.map-size-group-tile",): {
"Width": mgs_json["width"],
Expand Down Expand Up @@ -589,12 +596,12 @@ def launch_new(*args):
},
),
},
("gui-map-generator.play",): launch_new,
("gui-map-generator.play",): launch_new_custom,
}

msj["pollution"]["enabled"] = menu[("gui-map-generator.advanced-tab-title",)][
("gui-map-generator.pollution",)
].submenu[1]
].items[1]


for name, control in data["autoplace-control"].items():
Expand Down Expand Up @@ -719,10 +726,10 @@ def launch_new(*args):

msj["enemy_expansion"]["enabled"] = menu[("gui-map-generator.enemy-tab-title",)][
"Enemy Expansion"
].submenu[1]
].items[1]
msj["enemy_evolution"]["enabled"] = menu[("gui-map-generator.enemy-tab-title",)][
"Evolution"
].submenu[1]
].items[1]


sub_preset = {
Expand Down

0 comments on commit 4e37200

Please sign in to comment.