Enum fixes
This commit is contained in:
parent
1dcfa63f3c
commit
8470923e45
|
@ -59,9 +59,10 @@ CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplat
|
|||
break;
|
||||
}
|
||||
case eEnumProperty: {
|
||||
CEnumTemplate *pTemp = static_cast<CEnumTemplate*>(pPropTmp);
|
||||
long ID = SCLY.ReadLong();
|
||||
long index = pTemp->EnumeratorIndex(ID);
|
||||
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pPropTmp);
|
||||
u32 ID = SCLY.ReadLong();
|
||||
u32 index = pEnumTemp->EnumeratorIndex(ID);
|
||||
if (index == -1) Log::FileError(SCLY.GetSourceString(), SCLY.Tell() - 4, "Enum property \"" + pEnumTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has invalid enumerator value: " + StringUtil::ToHexString(ID, true, true, 8));
|
||||
pProp = new CEnumProperty(index);
|
||||
break;
|
||||
}
|
||||
|
@ -274,9 +275,10 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
|
|||
|
||||
case eEnumProperty: {
|
||||
CEnumProperty *pEnumCast = static_cast<CEnumProperty*>(pProp);
|
||||
CEnumTemplate *pTemp = static_cast<CEnumTemplate*>(pPropTemp);
|
||||
long ID = SCLY.ReadLong();
|
||||
long index = pTemp->EnumeratorIndex(ID);
|
||||
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pPropTemp);
|
||||
u32 ID = SCLY.ReadLong();
|
||||
u32 index = pEnumTemp->EnumeratorIndex(ID);
|
||||
if (index == -1) Log::FileError(SCLY.GetSourceString(), SCLY.Tell() - 4, "Enum property \"" + pEnumTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has invalid enumerator value: " + StringUtil::ToHexString(ID, true, true, 8));
|
||||
pEnumCast->Set(index);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -154,9 +154,16 @@ EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
|
|||
break;
|
||||
|
||||
case eLongProperty:
|
||||
case eEnumProperty:
|
||||
v = (int) static_cast<CLongProperty*>(pProp)->Get();
|
||||
break;
|
||||
|
||||
case eEnumProperty: {
|
||||
CEnumProperty *pEnumCast = static_cast<CEnumProperty*>(pProp);
|
||||
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pEnumCast->Template());
|
||||
int index = static_cast<CEnumProperty*>(pProp)->Get();
|
||||
v = pEnumTemp->EnumeratorID(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Test and check whether any of the conditions are true
|
||||
|
|
|
@ -148,7 +148,8 @@ void WPropertyEditor::CreateEditor()
|
|||
pComboBox->addItem(QString::fromStdString(name));
|
||||
}
|
||||
|
||||
pComboBox->setCurrentIndex(pEnumCast->Get());
|
||||
u32 index = pEnumCast->Get();
|
||||
if (index < pTemplate->NumEnumerators()) pComboBox->setCurrentIndex(index);
|
||||
pComboBox->setFocusPolicy(Qt::StrongFocus);
|
||||
pComboBox->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
|
||||
|
|
Loading…
Reference in New Issue