- added ZScript property handling for names, sounds and colors.

This commit is contained in:
Christoph Oelckers 2017-02-14 23:28:49 +01:00
parent 2f1b5c375e
commit c01289e999
2 changed files with 28 additions and 1 deletions

View File

@ -840,6 +840,21 @@ static void DispatchScriptProperty(FScanner &sc, PProperty *prop, AActor *defaul
bool val = sc.CheckNumber() ? !!sc.Number : true; bool val = sc.CheckNumber() ? !!sc.Number : true;
static_cast<PBool*>(f->Type)->SetValue(addr, !!val); static_cast<PBool*>(f->Type)->SetValue(addr, !!val);
} }
else if (f->Type == TypeName)
{
sc.MustGetString();
*(FName*)addr = sc.String;
}
else if (f->Type == TypeSound)
{
sc.MustGetString();
*(FSoundID*)addr = sc.String;
}
else if (f->Type == TypeColor)
{
if (sc.CheckNumber()) *(int*)addr = sc.Number;
else *(PalEntry*)addr = V_GetColor(nullptr, sc);
}
else if (f->Type->IsKindOf(RUNTIME_CLASS(PInt))) else if (f->Type->IsKindOf(RUNTIME_CLASS(PInt)))
{ {
sc.MustGetNumber(); sc.MustGetNumber();

View File

@ -1720,7 +1720,19 @@ void ZCCCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt *prop
{ {
static_cast<PBool*>(f->Type)->SetValue(addr, !!GetIntConst(ex, ctx)); static_cast<PBool*>(f->Type)->SetValue(addr, !!GetIntConst(ex, ctx));
} }
if (f->Type->IsKindOf(RUNTIME_CLASS(PInt))) else if (f->Type == TypeName)
{
*(FName*)addr = GetStringConst(ex, ctx);
}
else if (f->Type == TypeSound)
{
*(FSoundID*)addr = GetStringConst(ex, ctx);
}
else if (f->Type == TypeColor && ex->ValueType == TypeString) // colors can also be specified as ints.
{
*(PalEntry*)addr = V_GetColor(nullptr, GetStringConst(ex, ctx).GetChars(), &ex->ScriptPosition);
}
else if (f->Type->IsKindOf(RUNTIME_CLASS(PInt)))
{ {
static_cast<PInt*>(f->Type)->SetValue(addr, GetIntConst(ex, ctx)); static_cast<PInt*>(f->Type)->SetValue(addr, GetIntConst(ex, ctx));
} }