diff --git a/src/exporting/stylevar.py b/src/exporting/stylevar.py index df806707..6d0f5f19 100644 --- a/src/exporting/stylevar.py +++ b/src/exporting/stylevar.py @@ -1,9 +1,11 @@ """Export stylevar selections.""" from srctools import Keyvalues, bool_as_int -from . import ExportData, STEPS, StepResource -from packages import StyleVar +from config.widgets import WidgetConfig +from packages import ConfigGroup, StyleVar +import config +from . import ExportData, STEPS, StepResource @STEPS.add_step(prereq=[], results=[StepResource.VCONF_DATA]) @@ -14,8 +16,17 @@ async def step_add_stylevars(exp_data: ExportData) -> None: """ style_vars: dict[str, bool] = exp_data.selected[StyleVar] # Add the StyleVars block, containing each style_var. - exp_data.vbsp_conf.append(Keyvalues('StyleVars', [ + block = Keyvalues('StyleVars', [ Keyvalues(key, bool_as_int(val)) for key, val in style_vars.items() - ])) + ]) + # Also add all widgets that were stylevars, so previous packages still function. + for group in exp_data.packset.all_obj(ConfigGroup): + for widget in group.widgets: + if widget.stylevar_id: + value = config.APP.get_cur_conf(WidgetConfig, widget.conf_id()).values + if isinstance(value, str): + block[widget.stylevar_id] = value + + exp_data.vbsp_conf.append(block)