mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-18 09:25:31 +00:00
Support for undoing property changes + tons of tweaks and fixes
This commit is contained in:
@@ -33,6 +33,18 @@ public:
|
||||
void SetResource(CResource *pRes);
|
||||
void SetNodeIndex(u32 Index);
|
||||
void SetUnknown(u32 Index, u32 Value);
|
||||
|
||||
// Operators
|
||||
inline bool operator==(const CAnimationParameters& rkOther) const
|
||||
{
|
||||
return ( (mGame == rkOther.mGame) &&
|
||||
(mpCharSet == rkOther.mpCharSet) &&
|
||||
(mNodeIndex == rkOther.mNodeIndex) &&
|
||||
(mUnknown1 == rkOther.mUnknown1) &&
|
||||
(mUnknown2 == rkOther.mUnknown2) &&
|
||||
(mUnknown3 == rkOther.mUnknown3) &&
|
||||
(mUnknown4 == rkOther.mUnknown4) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CANIMATIONPARAMETERS_H
|
||||
|
||||
@@ -196,6 +196,7 @@ CResource* CResCache::GetResource(const TString& ResPath)
|
||||
else if (type == "CHAR") Res = CAnimSetLoader::LoadCHAR(file);
|
||||
else if (type == "MREA") Res = CAreaLoader::LoadMREA(file);
|
||||
else if (type == "MLVL") Res = CWorldLoader::LoadMLVL(file);
|
||||
else if (type == "STRG") Res = CStringLoader::LoadSTRG(file);
|
||||
else if (type == "FONT") Res = CFontLoader::LoadFONT(file);
|
||||
else if (type == "SCAN") Res = CScanLoader::LoadSCAN(file);
|
||||
else if (type == "DCLN") Res = CCollisionLoader::LoadDCLN(file);
|
||||
|
||||
@@ -31,10 +31,18 @@ public:
|
||||
|
||||
inline CUniqueID ID() const
|
||||
{
|
||||
TString FileName = mPath.GetFileName();
|
||||
|
||||
if (!mIsPath)
|
||||
return CUniqueID::FromString(mPath.GetFileName());
|
||||
return CUniqueID::FromString(FileName);
|
||||
|
||||
else
|
||||
return CUniqueID::skInvalidID64;
|
||||
{
|
||||
if (FileName.IsHexString() && (FileName.Size() == 8 || FileName.Size() == 16))
|
||||
return CUniqueID::FromString(FileName);
|
||||
else
|
||||
return CUniqueID::skInvalidID64;
|
||||
}
|
||||
}
|
||||
|
||||
inline CFourCC Type() const
|
||||
@@ -64,6 +72,16 @@ public:
|
||||
else
|
||||
return mIsValidPath;
|
||||
}
|
||||
|
||||
inline bool operator==(const CResourceInfo& rkOther) const
|
||||
{
|
||||
return (mPath.GetFileName() == rkOther.mPath.GetFileName());
|
||||
}
|
||||
|
||||
inline bool operator!=(const CResourceInfo& rkOther) const
|
||||
{
|
||||
return (!(*this == rkOther));
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CRESOURCEINFO
|
||||
|
||||
@@ -99,7 +99,7 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& SCLY)
|
||||
CUniqueID ResID = (mVersion < eCorruptionProto ? SCLY.ReadLong() : SCLY.ReadLongLong());
|
||||
const TStringList& rkExtensions = static_cast<CFileTemplate*>(pTemp)->Extensions();
|
||||
|
||||
CResourceInfo Info(ResID, "UNKN");
|
||||
CResourceInfo Info(ResID, CFourCC(!rkExtensions.empty() ? rkExtensions.front() : "UNKN"));
|
||||
|
||||
if (ResID.IsValid())
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
virtual ~IProperty() {}
|
||||
virtual EPropertyType Type() const = 0;
|
||||
virtual TString ToString() const { return ""; }
|
||||
virtual IPropertyValue* RawValue() { return nullptr; }
|
||||
|
||||
inline CPropertyStruct* Parent() const { return mpParent; }
|
||||
|
||||
@@ -68,6 +69,7 @@ public:
|
||||
~TTypedProperty() {}
|
||||
virtual EPropertyType Type() const { return TypeEnum; }
|
||||
virtual TString ToString() const { return mValue.ToString(); }
|
||||
virtual IPropertyValue* RawValue() { return &mValue; }
|
||||
|
||||
inline PropType Get() const { return mValue.Get(); }
|
||||
inline void Set(PropType v) { mValue.Set(v); }
|
||||
@@ -77,7 +79,7 @@ typedef TTypedProperty<char, eByteProperty, CByteValue>
|
||||
typedef TTypedProperty<short, eShortProperty, CShortValue> TShortProperty;
|
||||
typedef TTypedProperty<long, eLongProperty, CLongValue> TLongProperty;
|
||||
typedef TTypedProperty<long, eEnumProperty, CLongValue> TEnumProperty;
|
||||
typedef TTypedProperty<long, eBitfieldProperty, CLongValue> TBitfieldProperty;
|
||||
typedef TTypedProperty<long, eBitfieldProperty, CHexLongValue> TBitfieldProperty;
|
||||
typedef TTypedProperty<float, eFloatProperty, CFloatValue> TFloatProperty;
|
||||
typedef TTypedProperty<TString, eStringProperty, CStringValue> TStringProperty;
|
||||
typedef TTypedProperty<CVector3f, eVector3Property, CVector3Value> TVector3Property;
|
||||
|
||||
@@ -338,13 +338,11 @@ public:
|
||||
CEnumTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
: TLongTemplate(ID, pParent)
|
||||
{
|
||||
mDefaultValue.SetHexStringOutput(true);
|
||||
}
|
||||
|
||||
CEnumTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
: TLongTemplate(ID, rkName, CookPreference, pParent)
|
||||
{
|
||||
mDefaultValue.SetHexStringOutput(true);
|
||||
}
|
||||
|
||||
virtual EPropertyType Type() const { return eEnumProperty; }
|
||||
@@ -393,7 +391,7 @@ public:
|
||||
|
||||
// CBitfieldTemplate - Property template for bitfields, which can have multiple
|
||||
// distinct boolean parameters packed into one property.
|
||||
class CBitfieldTemplate : public TLongTemplate
|
||||
class CBitfieldTemplate : public TTypedPropertyTemplate<u32, eBitfieldProperty, CHexLongValue>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
@@ -411,15 +409,13 @@ class CBitfieldTemplate : public TLongTemplate
|
||||
|
||||
public:
|
||||
CBitfieldTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
: TLongTemplate(ID, pParent)
|
||||
: TTypedPropertyTemplate(ID, pParent)
|
||||
{
|
||||
mDefaultValue.SetHexStringOutput(true);
|
||||
}
|
||||
|
||||
CBitfieldTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
: TLongTemplate(ID, rkName, CookPreference, pParent)
|
||||
: TTypedPropertyTemplate(ID, rkName, CookPreference, pParent)
|
||||
{
|
||||
mDefaultValue.SetHexStringOutput(true);
|
||||
}
|
||||
|
||||
virtual EPropertyType Type() const { return eBitfieldProperty; }
|
||||
|
||||
@@ -17,6 +17,9 @@ class IPropertyValue
|
||||
public:
|
||||
virtual TString ToString() const = 0;
|
||||
virtual void FromString(const TString& rkString) = 0;
|
||||
virtual IPropertyValue* Clone() const = 0;
|
||||
virtual void Copy(IPropertyValue *pValue) = 0;
|
||||
virtual bool Matches(IPropertyValue *pValue) const = 0;
|
||||
};
|
||||
|
||||
template<typename PropType>
|
||||
@@ -28,8 +31,20 @@ protected:
|
||||
public:
|
||||
TTypedPropertyValue() {}
|
||||
|
||||
TTypedPropertyValue(PropType Val)
|
||||
: mValue(Val) {}
|
||||
TTypedPropertyValue(PropType rkVal)
|
||||
: mValue(rkVal) {}
|
||||
|
||||
virtual void Copy(IPropertyValue *pValue)
|
||||
{
|
||||
TTypedPropertyValue *pOther = static_cast<TTypedPropertyValue*>(pValue);
|
||||
mValue = pOther->mValue;
|
||||
}
|
||||
|
||||
virtual bool Matches(IPropertyValue *pValue) const
|
||||
{
|
||||
TTypedPropertyValue *pOther = static_cast<TTypedPropertyValue*>(pValue);
|
||||
return (mValue == pOther->mValue);
|
||||
}
|
||||
|
||||
PropType Get() const
|
||||
{
|
||||
@@ -69,6 +84,11 @@ public:
|
||||
{
|
||||
mValue = (rkString == "true");
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CBoolValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CByteValue : public TTypedPropertyValue<s8>
|
||||
@@ -87,6 +107,11 @@ public:
|
||||
u32 base = (rkString.StartsWith("0x") ? 16 : 10);
|
||||
mValue = (s8) rkString.ToInt32(base);
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CByteValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CShortValue : public TTypedPropertyValue<s16>
|
||||
@@ -105,28 +130,22 @@ public:
|
||||
u32 base = (rkString.StartsWith("0x") ? 16 : 10);
|
||||
mValue = (s16) rkString.ToInt32(base);
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CShortValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CLongValue : public TTypedPropertyValue<s32>
|
||||
{
|
||||
protected:
|
||||
bool mShouldOutputHex;
|
||||
|
||||
public:
|
||||
CLongValue() { mShouldOutputHex = false; mValue = 0; }
|
||||
CLongValue(s32 Val) { mShouldOutputHex = false; mValue = Val; }
|
||||
|
||||
void SetHexStringOutput(bool enable)
|
||||
{
|
||||
mShouldOutputHex = enable;
|
||||
}
|
||||
CLongValue() { mValue = 0; }
|
||||
CLongValue(s32 Val) { mValue = Val; }
|
||||
|
||||
TString ToString() const
|
||||
{
|
||||
if (mShouldOutputHex)
|
||||
return TString::HexString((u32) mValue, true, true, 8);
|
||||
else
|
||||
return TString::FromInt32(mValue, 0, 10);
|
||||
return TString::FromInt32(mValue, 0, 10);
|
||||
}
|
||||
|
||||
void FromString(const TString& rkString)
|
||||
@@ -134,6 +153,34 @@ public:
|
||||
u32 base = (rkString.StartsWith("0x") ? 16 : 10);
|
||||
mValue = (s32) rkString.ToInt32(base);
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CLongValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CHexLongValue : public TTypedPropertyValue<u32>
|
||||
{
|
||||
public:
|
||||
CHexLongValue() { mValue = 0; }
|
||||
CHexLongValue(u32 Val) { mValue = Val; }
|
||||
|
||||
TString ToString() const
|
||||
{
|
||||
return TString::HexString(mValue, true, true, 8);
|
||||
}
|
||||
|
||||
void FromString(const TString& rkString)
|
||||
{
|
||||
u32 base = (rkString.StartsWith("0x") ? 16 : 10);
|
||||
mValue = (s32) rkString.ToInt32(base);
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CHexLongValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CFloatValue : public TTypedPropertyValue<float>
|
||||
@@ -151,6 +198,11 @@ public:
|
||||
{
|
||||
mValue = rkString.ToFloat();
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CFloatValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CStringValue : public TTypedPropertyValue<TString>
|
||||
@@ -169,6 +221,11 @@ public:
|
||||
{
|
||||
mValue = rkString;
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CStringValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CColorValue : public TTypedPropertyValue<CColor>
|
||||
@@ -207,6 +264,11 @@ public:
|
||||
pPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CColorValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CVector3Value : public TTypedPropertyValue<CVector3f>
|
||||
@@ -243,15 +305,26 @@ public:
|
||||
pPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CVector3Value(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CCharacterValue : public TTypedPropertyValue<CAnimationParameters>
|
||||
{
|
||||
public:
|
||||
CCharacterValue() {}
|
||||
CCharacterValue(const CAnimationParameters& rkParams) { mValue = rkParams; }
|
||||
|
||||
TString ToString() const { return ""; }
|
||||
void FromString(const TString&) { }
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CCharacterValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CFileValue : public TTypedPropertyValue<CResourceInfo>
|
||||
@@ -262,15 +335,26 @@ public:
|
||||
|
||||
TString ToString() const { return ""; }
|
||||
void FromString(const TString&) { }
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CFileValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CUnknownValue : public TTypedPropertyValue<std::vector<u8>>
|
||||
{
|
||||
public:
|
||||
CUnknownValue();
|
||||
CUnknownValue(const std::vector<u8>& rkVec) { mValue = rkVec; }
|
||||
|
||||
TString ToString() const { return ""; }
|
||||
void FromString(const TString&) {}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CUnknownValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // IPROPERTYVALUE_H
|
||||
|
||||
Reference in New Issue
Block a user