Conditionals "support"
PazerOP opened this issue · comments
Valve KeyValues files can have conditionals that determine if a key or attribute should be ignored or not.
"ChalkboardText"
{
"1"
{
"name" "TF2 Professor"
"tall" "14" [!$OSX]
"tall" "15" [$OSX]
"tall_lodef" "32"
"tall_hidef" "32"
"antialias" "1"
"custom" "1" [$OSX]
"weight" "500"
}
}
or
"countImage2" [$WIN32]
{
"ControlName" "CTFImagePanel"
"fieldName" "countImage2"
"xpos" "9999"
"ypos" "9999"
"zpos" "9"
"wide" "30"
"tall" "60"
"visible" "0"
"enabled" "0"
"image" ""
"scaleImage" "1"
}
I'm not sure it's necessary/worthwhile to support actually parsing and obeying these attributes in your library, but it would be nice if your library could silently ignore them so they don't cause parsing to fail.
Silently skipping over them is relatively simple, I added it on my fork (not sure why I called them attributes, that doesn't make any sense): PazerOP@0d96221
Hi,
I added a first version.
It just probably misses some conditional strings and maybe more test cases.
you don't have a list of all the supported conditional strings?
Sorry, I was distracted when I created this issue and neglected to include that information. These are all the conditional strings I'm aware of: https://github.com/TheAlePower/TeamFortress2/blob/master/tf2_src/tier1/KeyValues.cpp#L2186
It's worth noting that valve's KeyValues class also supports disabling conditional evaluation: https://github.com/TheAlePower/TeamFortress2/blob/master/tf2_src/public/tier1/KeyValues.h#L331
Thanks, this is really helpful and I will add them.
Not sure how I will put the option into the current interface, since there is not option for anything atm.