mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-07-08 22:25:54 +00:00
Added support for numerical property suffixes
This commit is contained in:
parent
c14e48bea5
commit
55b2c053ab
@ -469,6 +469,19 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
|||||||
pElem->LinkEndChild(pRange);
|
pElem->LinkEndChild(pRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Suffix
|
||||||
|
if (pProp->IsNumerical())
|
||||||
|
{
|
||||||
|
TString Suffix = pProp->Suffix();
|
||||||
|
|
||||||
|
if (!Suffix.IsEmpty())
|
||||||
|
{
|
||||||
|
XMLElement *pSuffix = pDoc->NewElement("suffix");
|
||||||
|
pSuffix->SetText(*Suffix);
|
||||||
|
pElem->LinkEndChild(pSuffix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Cook Pref
|
// Cook Pref
|
||||||
ECookPreference CookPref = pProp->CookPreference();
|
ECookPreference CookPref = pProp->CookPreference();
|
||||||
|
|
||||||
|
@ -58,9 +58,10 @@ public:
|
|||||||
virtual bool CanHaveDefault() const = 0;
|
virtual bool CanHaveDefault() const = 0;
|
||||||
virtual bool IsNumerical() const = 0;
|
virtual bool IsNumerical() const = 0;
|
||||||
|
|
||||||
virtual bool HasValidRange() const { return false; }
|
virtual bool HasValidRange() const { return false; }
|
||||||
virtual TString DefaultToString() { return ""; }
|
virtual TString DefaultToString() const { return ""; }
|
||||||
virtual TString RangeToString() { return ""; }
|
virtual TString RangeToString() const { return ""; }
|
||||||
|
virtual TString Suffix() const { return ""; }
|
||||||
|
|
||||||
virtual void SetParam(const TString& rkParamName, const TString& rkValue)
|
virtual void SetParam(const TString& rkParamName, const TString& rkValue)
|
||||||
{
|
{
|
||||||
@ -144,7 +145,7 @@ public:
|
|||||||
virtual bool CanHaveDefault() const { return true; }
|
virtual bool CanHaveDefault() const { return true; }
|
||||||
virtual bool IsNumerical() const { return false; }
|
virtual bool IsNumerical() const { return false; }
|
||||||
|
|
||||||
virtual TString DefaultToString()
|
virtual TString DefaultToString() const
|
||||||
{
|
{
|
||||||
return mDefaultValue.ToString();
|
return mDefaultValue.ToString();
|
||||||
}
|
}
|
||||||
@ -178,7 +179,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TNumericalPropertyTemplate - Subclass of TTypedPropertyTemplate for numerical
|
// TNumericalPropertyTemplate - Subclass of TTypedPropertyTemplate for numerical
|
||||||
// property types, and allows a min/max value to be tracked.
|
// property types, and allows a min/max value and a suffix to be tracked.
|
||||||
template<typename PropType, EPropertyType PropTypeEnum, class ValueClass>
|
template<typename PropType, EPropertyType PropTypeEnum, class ValueClass>
|
||||||
class TNumericalPropertyTemplate : public TTypedPropertyTemplate<PropType,PropTypeEnum,ValueClass>
|
class TNumericalPropertyTemplate : public TTypedPropertyTemplate<PropType,PropTypeEnum,ValueClass>
|
||||||
{
|
{
|
||||||
@ -187,6 +188,7 @@ class TNumericalPropertyTemplate : public TTypedPropertyTemplate<PropType,PropTy
|
|||||||
|
|
||||||
ValueClass mMin;
|
ValueClass mMin;
|
||||||
ValueClass mMax;
|
ValueClass mMax;
|
||||||
|
TString mSuffix;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TNumericalPropertyTemplate(u32 ID, CStructTemplate *pParent = 0)
|
TNumericalPropertyTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||||
@ -225,14 +227,24 @@ public:
|
|||||||
mMax.FromString(Components.back());
|
mMax.FromString(Components.back());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (rkParamName == "suffix")
|
||||||
|
{
|
||||||
|
mSuffix = rkValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PropType GetMin()
|
virtual TString Suffix() const
|
||||||
|
{
|
||||||
|
return mSuffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline PropType GetMin() const
|
||||||
{
|
{
|
||||||
return mMin.Get();
|
return mMin.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PropType GetMax()
|
inline PropType GetMax() const
|
||||||
{
|
{
|
||||||
return mMax.Get();
|
return mMax.Get();
|
||||||
}
|
}
|
||||||
@ -242,6 +254,11 @@ public:
|
|||||||
mMin.Set(rkMin);
|
mMin.Set(rkMin);
|
||||||
mMax.Set(rkMax);
|
mMax.Set(rkMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void SetSuffix(const TString& rkSuffix)
|
||||||
|
{
|
||||||
|
mSuffix = rkSuffix;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Typedefs for all property types that don't need further functionality.
|
// Typedefs for all property types that don't need further functionality.
|
||||||
|
@ -67,6 +67,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||||||
WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent);
|
WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent);
|
||||||
pSpinBox->setMinimum(INT16_MIN);
|
pSpinBox->setMinimum(INT16_MIN);
|
||||||
pSpinBox->setMaximum(INT16_MAX);
|
pSpinBox->setMaximum(INT16_MAX);
|
||||||
|
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
||||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int));
|
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int));
|
||||||
pOut = pSpinBox;
|
pOut = pSpinBox;
|
||||||
break;
|
break;
|
||||||
@ -77,6 +78,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||||||
WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent);
|
WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent);
|
||||||
pSpinBox->setMinimum(INT32_MIN);
|
pSpinBox->setMinimum(INT32_MIN);
|
||||||
pSpinBox->setMaximum(INT32_MAX);
|
pSpinBox->setMaximum(INT32_MAX);
|
||||||
|
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
||||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int));
|
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int));
|
||||||
pOut = pSpinBox;
|
pOut = pSpinBox;
|
||||||
break;
|
break;
|
||||||
@ -86,6 +88,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
|
|||||||
{
|
{
|
||||||
WDraggableSpinBox *pSpinBox = new WDraggableSpinBox(pParent);
|
WDraggableSpinBox *pSpinBox = new WDraggableSpinBox(pParent);
|
||||||
pSpinBox->setSingleStep(0.1);
|
pSpinBox->setSingleStep(0.1);
|
||||||
|
pSpinBox->setSuffix(TO_QSTRING(pProp->Template()->Suffix()));
|
||||||
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double));
|
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(double));
|
||||||
pOut = pSpinBox;
|
pOut = pSpinBox;
|
||||||
break;
|
break;
|
||||||
|
@ -316,7 +316,7 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
// fall through
|
// fall through
|
||||||
// Display property value to string for everything else
|
// Display property value to string for everything else
|
||||||
default:
|
default:
|
||||||
return TO_QSTRING(pProp->ToString());
|
return TO_QSTRING(pProp->ToString() + pProp->Template()->Suffix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property ID="0x852D3871" type="float">
|
<property ID="0x852D3871" type="float">
|
||||||
<default>100.0</default>
|
<default>100.0</default>
|
||||||
|
<suffix>%</suffix>
|
||||||
</property>
|
</property>
|
||||||
<property ID="0x68ACBD86" type="long">
|
<property ID="0x68ACBD86" type="long">
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property ID="0x852D3871" type="float">
|
<property ID="0x852D3871" type="float">
|
||||||
<default>100.0</default>
|
<default>100.0</default>
|
||||||
|
<suffix>%</suffix>
|
||||||
</property>
|
</property>
|
||||||
<property ID="0x68ACBD86" type="long">
|
<property ID="0x68ACBD86" type="long">
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property ID="0x852D3871" type="float">
|
<property ID="0x852D3871" type="float">
|
||||||
<default>100.0</default>
|
<default>100.0</default>
|
||||||
|
<suffix>%</suffix>
|
||||||
</property>
|
</property>
|
||||||
<property ID="0x68ACBD86" type="long">
|
<property ID="0x68ACBD86" type="long">
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property ID="0x852D3871" type="float">
|
<property ID="0x852D3871" type="float">
|
||||||
<default>100.0</default>
|
<default>100.0</default>
|
||||||
|
<suffix>%</suffix>
|
||||||
</property>
|
</property>
|
||||||
<property ID="0x68ACBD86" type="long">
|
<property ID="0x68ACBD86" type="long">
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user