Skip to content

Commit ee2e53b

Browse files
committed
fgdlib: Add boolean, scrip, script list FGD types support from TF2/CS:GO
1 parent d8b39ac commit ee2e53b

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

fgdlib/gdvar.cpp

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ static constexpr TypeMap_t TypeMap[] =
5252
{ ivVecLine, "vecline", STRING },
5353
{ ivPointEntityClass, "pointentityclass", STRING },
5454
{ ivNodeDest, "node_dest", INTEGER },
55+
// dimhotepus: CS:GO backport.
56+
{ ivBoolean, "boolean", STRING },
57+
// dimhotepus: TF2 backport.
58+
{ ivScript, "script", STRING },
59+
{ ivScriptList, "scriptlist", STRING },
5560
{ ivInstanceFile, "instance_file", STRING },
5661
{ ivAngleNegativePitch, "angle_negative_pitch", STRING },
5762
{ ivInstanceVariable, "instance_variable", STRING },
@@ -231,7 +236,8 @@ BOOL GDinputvariable::InitFromTokens(TokenReader& tr)
231236
return FALSE;
232237
}
233238

234-
// check for "reportable" marker
239+
// check for "reportable" marker.
240+
// NOTE: This has been deprecated in favor of the "report" keyword below.
235241
trtoken_t ttype = tr.NextToken(szToken);
236242
if (ttype == OPERATOR)
237243
{
@@ -286,6 +292,21 @@ BOOL GDinputvariable::InitFromTokens(TokenReader& tr)
286292
ttype = tr.PeekTokenType(szToken);
287293
}
288294

295+
//
296+
// Check for the "report" specifier.
297+
//
298+
// dimhotepus: TF2 backport.
299+
if ((ttype == IDENT) && IsToken(szToken, "report"))
300+
{
301+
(void)tr.NextToken(szToken);
302+
m_bReportable = true;
303+
304+
//
305+
// Look ahead at the next token.
306+
//
307+
ttype = tr.PeekTokenType(szToken);
308+
}
309+
289310
//
290311
// Check for the ':' indicating a long name.
291312
//
@@ -420,6 +441,44 @@ BOOL GDinputvariable::InitFromTokens(TokenReader& tr)
420441
GDError(tr, "no %s specified", m_eType == ivFlags ? "flags" : "choices");
421442
return(FALSE);
422443
}
444+
445+
// dimhotepus: TF2 backport.
446+
// For boolean values, we construct it as if it were a choices dialog
447+
if ( m_eType == ivBoolean )
448+
{
449+
m_eType = ivChoices;
450+
451+
GDIVITEM ivi;
452+
BitwiseClear( ivi );
453+
454+
// Yes
455+
V_strcpy_safe( ivi.szValue, "1" );
456+
V_strcpy_safe( ivi.szCaption, "Yes" );
457+
m_Items.AddToTail(ivi);
458+
459+
// No
460+
V_strcpy_safe( ivi.szValue, "0" );
461+
V_strcpy_safe( ivi.szCaption, "No" );
462+
m_Items.AddToTail(ivi);
463+
464+
// Clean up string usages!
465+
if ( stricmp( m_szDefault, "no" ) == 0 )
466+
{
467+
V_strcpy_safe( m_szDefault, "0" );
468+
}
469+
else if ( stricmp( m_szDefault, "yes" ) == 0 )
470+
{
471+
V_strcpy_safe( m_szDefault, "1" );
472+
}
473+
474+
// Sanity check it!
475+
if ( strcmp( m_szDefault, "0" ) && strcmp( m_szDefault, "1" ) )
476+
{
477+
GDError(tr, "boolean type specified with nonsensical default value: %s", m_szDefault );
478+
return(FALSE);
479+
}
480+
}
481+
423482
return(TRUE);
424483
}
425484

fgdlib/inputoutput.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static constexpr TypeMap_t TypeMap[] =
3636
{ iotEHandle, "target_destination" },
3737
{ iotColor, "color255" },
3838
{ iotEHandle, "ehandle" }, // for backwards compatibility
39+
{ iotScript, "script" }
3940
};
4041

4142

public/fgdlib/gdvar.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ enum GDIV_TYPE
5050
ivAngleNegativePitch, // used for instance rotating when just a pitch value is present
5151
ivInstanceVariable, // used for instance variables for easy hammer editing
5252
ivInstanceParm, // used for instance parameter declaration
53+
// dimhotepus: TF2 backport.
54+
ivScript,
55+
ivScriptList,
56+
ivBoolean,
5357

5458
ivMax // count of types
5559
};

public/fgdlib/inputoutput.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ enum InputOutputType_t
2424
iotVector,
2525
iotEHandle,
2626
iotColor,
27+
// dimhotepus: TF2 backport.
28+
iotScript
2729
};
2830

2931

0 commit comments

Comments
 (0)