-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change unlock mandatory stylevar to be a widget config instead
- Loading branch information
1 parent
2d6953e
commit 4bcd920
Showing
6 changed files
with
80 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,21 @@ | ||
from typing import Dict | ||
import copy | ||
"""Export stylevar selections.""" | ||
from srctools import Keyvalues, bool_as_int | ||
|
||
import srctools | ||
from srctools import Keyvalues | ||
|
||
import editoritems | ||
from consts import DefaultItems | ||
from . import ExportData, STEPS, StepResource | ||
from packages import StyleVar | ||
|
||
|
||
UNLOCK_ITEMS = { | ||
DefaultItems.door_sp_entry.id, | ||
DefaultItems.door_coop_entry.id, | ||
DefaultItems.door_sp_entry.id, | ||
DefaultItems.door_sp_exit.id, | ||
DefaultItems.obs_room_large.id, | ||
} | ||
|
||
|
||
@STEPS.add_step(prereq=[], results=[StepResource.VCONF_DATA]) | ||
async def step_add_stylevars(exp_data: ExportData) -> None: | ||
"""Export style var selections into the config. | ||
The .selected attribute is a dict mapping ids to the boolean value. | ||
""" | ||
style_vars: Dict[str, bool] = exp_data.selected[StyleVar] | ||
style_vars: dict[str, bool] = exp_data.selected[StyleVar] | ||
# Add the StyleVars block, containing each style_var. | ||
exp_data.vbsp_conf.append(Keyvalues('StyleVars', [ | ||
Keyvalues(key, srctools.bool_as_int(val)) | ||
Keyvalues(key, bool_as_int(val)) | ||
for key, val in | ||
style_vars.items() | ||
])) | ||
|
||
|
||
@STEPS.add_step(prereq=[StepResource.EI_ITEMS], results=[StepResource.EI_DATA]) | ||
async def step_unlock_defaults(exp_data: ExportData) -> None: | ||
"""If the unlock defaults stylevar is set, unlock the default items.""" | ||
if not exp_data.selected[StyleVar]['UnlockDefault']: | ||
return | ||
|
||
for i, item in enumerate(exp_data.all_items): | ||
# If the Unlock Default Items stylevar is enabled, we | ||
# want to force the corridors and obs room to be | ||
# deletable and copyable. | ||
# Also add DESIRES_UP, so they place in the correct orientation. | ||
# That would have already been done for vertical-enabled corridors, but that's | ||
# fine. | ||
if item.id in UNLOCK_ITEMS: | ||
exp_data.all_items[i] = item = copy.copy(item) | ||
item.deletable = item.copiable = True | ||
item.facing = editoritems.DesiredFacing.UP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters