Skip to content

Instantly share code, notes, and snippets.

@Rainyan
Last active May 3, 2018 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rainyan/cf1eac8ec69c1ba1218442fddd16837e to your computer and use it in GitHub Desktop.
Save Rainyan/cf1eac8ec69c1ba1218442fddd16837e to your computer and use it in GitHub Desktop.
@ECHO off
REM Purpose: Toggle custom assets for a Source engine map on/off by renaming their
REM paths with a "_disabled" suffix. Disabling all custom assets can help making
REM sure all custom assets are properly BSPZIP'd in the map file before distribution.
REM ########################
REM Set project paths below.
REM ########################
REM Name of the map without .bsp. Used for locating the related soundscript file.
SET MapVersion=nt_snowfall_ctg_a42
REM This is the asset subfolder folder name. (ie: materials\CUSTOM\%AssetId%\)
SET AssetId=snowfall
REM NeotokyoSource folder location.
SET NeoRoot=C:\Program Files\Steam\steamapps\common\NEOTOKYO\NeotokyoSource
SET DisabledSuffix=_disabled
SET MaterialPath=materials\CUSTOM\
SET ModelPath=models\custom\
SET SoundPath=sound\CUSTOM\
SET ScriptPath=scripts\
REM ########################
REM Logic start below.
REM ########################
ECHO ** Asset renaming utility for %MapVersion%
ECHO.
IF exist %NeoRoot%\%MaterialPath%\%AssetId%\ (
ECHO Material path exists.
REM If material path exists, model and sound paths should also exist.
IF not exist %NeoRoot%\%ModelPath%\%AssetId%\ ( GOTO fail_Inconsistent )
ECHO * Models path OK
IF not exist %NeoRoot%\%SoundPath%\%AssetId%\ ( GOTO fail_Inconsistent )
ECHO * Sound path OK
IF not exist %NeoRoot%\%ScriptPath%\soundscapes_%MapVersion%.txt ( GOTO fail_Inconsistent )
ECHO * Script path OK.
ECHO ** All asset paths OK.
ECHO * Renaming paths to disable assets...
REN "%NeoRoot%\%MaterialPath%\%AssetId%" "%AssetId%%DisabledSuffix%"
REN "%NeoRoot%\%ModelPath%\%AssetId%" "%AssetId%%DisabledSuffix%"
REN "%NeoRoot%\%SoundPath%\%AssetId%" "%AssetId%%DisabledSuffix%"
REN "%NeoRoot%\%ScriptPath%\soundscapes_%MapVersion%.txt" "soundscapes_%MapVersion%%DisabledSuffix%.txt"
GOTO success
) ELSE (
ECHO Material path doesn't exist.
REM Material path didn't exist - check if a disabled path exists.
IF not exist %NeoRoot%\%MaterialPath%\%AssetId%%DisabledSuffix%\ ( GOTO fail_NeitherExists )
REM If disabled material path exists, disabled model and sound paths should also exist.
IF not exist %NeoRoot%\%ModelPath%\%AssetId%%DisabledSuffix%\ ( GOTO fail_NegInconsistent )
ECHO * Disabled models path OK
IF not exist %NeoRoot%\%SoundPath%\%AssetId%%DisabledSuffix%\ ( GOTO fail_NegInconsistent )
ECHO * Disabled sound path OK
IF not exist %NeoRoot%\%ScriptPath%\soundscapes_%MapVersion%%DisabledSuffix%.txt ( GOTO fail_NegInconsistent )
ECHO * Disabled script path OK
ECHO ** All disabled asset paths OK.
ECHO * Renaming paths to enable assets...
REN "%NeoRoot%\%MaterialPath%\%AssetId%%DisabledSuffix%" "%AssetId%"
REN "%NeoRoot%\%ModelPath%\%AssetId%%DisabledSuffix%" "%AssetId%"
REN "%NeoRoot%\%SoundPath%\%AssetId%%DisabledSuffix%" "%AssetId%"
REN "%NeoRoot%\%ScriptPath%\soundscapes_%MapVersion%%DisabledSuffix%.txt" "soundscapes_%MapVersion%.txt"
GOTO success
)
:fail_FellThrough
REM Should never reach this line.
ECHO Fell through the conditions! This should never happen.
GOTO doPromptExit
:fail_Inconsistent
ECHO Material path exists while model/sound/script path(s) don't! Are the paths correct?
GOTO doPromptExit
:fail_NegInconsistent
ECHO The disabled material path exists while model/sound/script path(s) don't! Are the paths correct?
GOTO doPromptExit
:fail_NeitherExists
ECHO Neither the original nor disabled asset paths exist! Are the paths correct?
GOTO doPromptExit
:success
ECHO ** All OK.
GOTO doPromptExit
:doPromptExit
ECHO.
ECHO Press any key to exit...
PAUSE > NUL
EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment