-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#277: Enforce lua_run casing via postcompiler
- Loading branch information
1 parent
e42fc80
commit bf1aa35
Showing
3 changed files
with
28 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Some keyvalues are case-sensitive, force the required casing.""" | ||
from srctools import VMF, logger | ||
|
||
from hammeraddons.bsp_transform import Context, trans | ||
from hammeraddons.bsp_transform.common import ent_description | ||
|
||
LOGGER = logger.get_logger(__name__) | ||
|
||
|
||
@trans('FGD - Fix key casing') | ||
def force_case_sensitivity(ctx: Context) -> None: | ||
"""Force case-sensitivity on some keyvalues that require it.""" | ||
fix_casing(ctx.vmf, 'light_environment', 'SunSpreadAngle') | ||
fix_casing(ctx.vmf, 'light_directional', 'SunSpreadAngle') | ||
fix_casing(ctx.vmf, 'lua_run', 'Code') | ||
|
||
|
||
def fix_casing(vmf: VMF, classname: str, *keys: str) -> None: | ||
"""Fix the casing for one entity.""" | ||
for ent in vmf.by_class[classname]: | ||
for key in keys: | ||
if value := ent.pop(key): | ||
LOGGER.warning( | ||
'Correcting case of "{}" for {}', | ||
key, ent_description(ent), | ||
) | ||
ent[key] = value |
This file was deleted.
Oops, something went wrong.