mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-14 15:46:17 +00:00
Linux build fixes
This commit is contained in:
@@ -111,19 +111,6 @@ EGame CScriptTemplate::Game() const
|
||||
return mpGame->Game();
|
||||
}
|
||||
|
||||
// ************ PROPERTY FETCHING ************
|
||||
template<class PropType>
|
||||
PropType* TFetchProperty(CStructProperty* pProperties, const TIDString& rkID)
|
||||
{
|
||||
if (rkID.IsEmpty()) return nullptr;
|
||||
IProperty *pProp = pProperties->ChildByIDString(rkID);
|
||||
|
||||
if (pProp && (pProp->Type() == PropEnum))
|
||||
return static_cast<PropType*>(pProp)->ValuePtr();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
|
||||
{
|
||||
if (pObj->Template() != this)
|
||||
|
||||
@@ -52,7 +52,6 @@ public:
|
||||
ScaleEnabled, ScaleDisabled, ScaleVolume
|
||||
};
|
||||
|
||||
private:
|
||||
struct SEditorAsset
|
||||
{
|
||||
enum class EAssetType {
|
||||
@@ -75,6 +74,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<TString> mModules;
|
||||
std::unique_ptr<CStructProperty> mpProperties;
|
||||
std::vector<SEditorAsset> mAssets;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace NGameList
|
||||
{
|
||||
|
||||
/** Path for the templates directory */
|
||||
const TString gkTemplatesDir = "../templates/";
|
||||
const TString gkTemplatesDir = "templates/";
|
||||
|
||||
/** Path to the game list file */
|
||||
const TString gkGameListPath = gkTemplatesDir + "GameList.xml";
|
||||
@@ -33,7 +33,7 @@ struct SGameInfo
|
||||
}
|
||||
}
|
||||
};
|
||||
SGameInfo gGameList[EGame::Max];
|
||||
SGameInfo gGameList[int(EGame::Max)];
|
||||
|
||||
/** Whether the game list has been loaded */
|
||||
bool gLoadedGameList = false;
|
||||
@@ -88,7 +88,7 @@ void LoadGameList()
|
||||
ASSERT(!gLoadedGameList);
|
||||
debugf("Loading game list");
|
||||
|
||||
CXMLReader Reader(gkGameListPath);
|
||||
CXMLReader Reader(gDataDir + gkGameListPath);
|
||||
ASSERT(Reader.IsValid());
|
||||
|
||||
SerializeGameList(Reader);
|
||||
@@ -101,7 +101,7 @@ void SaveGameList()
|
||||
ASSERT(gLoadedGameList);
|
||||
debugf("Saving game list");
|
||||
|
||||
CXMLWriter Writer(gkGameListPath, "GameList");
|
||||
CXMLWriter Writer(gDataDir + gkGameListPath, "GameList");
|
||||
ASSERT(Writer.IsValid());
|
||||
|
||||
SerializeGameList(Writer);
|
||||
@@ -151,7 +151,7 @@ CGameTemplate* GetGameTemplate(EGame Game)
|
||||
// Load the game template, if it hasn't been loaded yet.
|
||||
if (!GameInfo.pTemplate && !GameInfo.Name.IsEmpty())
|
||||
{
|
||||
TString GamePath = gkTemplatesDir + GameInfo.TemplatePath;
|
||||
TString GamePath = gDataDir + gkTemplatesDir + GameInfo.TemplatePath;
|
||||
GameInfo.pTemplate = std::make_unique<CGameTemplate>();
|
||||
GameInfo.pTemplate->Load(GamePath);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace NPropertyMap
|
||||
{
|
||||
|
||||
/** Path to the property map file */
|
||||
const char* gpkLegacyMapPath = "../templates/PropertyMapLegacy.xml";
|
||||
const char* gpkMapPath = "../templates/PropertyMap.xml";
|
||||
const char* gpkLegacyMapPath = "templates/PropertyMapLegacy.xml";
|
||||
const char* gpkMapPath = "templates/PropertyMap.xml";
|
||||
|
||||
/** Whether to do name lookups from the legacy map */
|
||||
const bool gkUseLegacyMapForNameLookups = false;
|
||||
@@ -150,13 +150,13 @@ void LoadMap()
|
||||
|
||||
if ( gkUseLegacyMapForNameLookups )
|
||||
{
|
||||
CXMLReader Reader(gpkLegacyMapPath);
|
||||
CXMLReader Reader(gDataDir + gpkLegacyMapPath);
|
||||
ASSERT(Reader.IsValid());
|
||||
Reader << SerialParameter("PropertyMap", gLegacyNameMap, SH_HexDisplay);
|
||||
}
|
||||
else
|
||||
{
|
||||
CXMLReader Reader(gpkMapPath);
|
||||
CXMLReader Reader(gDataDir + gpkMapPath);
|
||||
ASSERT(Reader.IsValid());
|
||||
Reader << SerialParameter("PropertyMap", gNameMap, SH_HexDisplay);
|
||||
|
||||
@@ -198,7 +198,7 @@ void SaveMap(bool Force /*= false*/)
|
||||
{
|
||||
if( gkUseLegacyMapForUpdates )
|
||||
{
|
||||
CXMLWriter Writer(gpkLegacyMapPath, "PropertyMap");
|
||||
CXMLWriter Writer(gDataDir + gpkLegacyMapPath, "PropertyMap");
|
||||
ASSERT(Writer.IsValid());
|
||||
Writer << SerialParameter("PropertyMap", gLegacyNameMap, SH_HexDisplay);
|
||||
}
|
||||
@@ -219,7 +219,7 @@ void SaveMap(bool Force /*= false*/)
|
||||
}
|
||||
|
||||
// Perform the actual save
|
||||
CXMLWriter Writer(gpkMapPath, "PropertyMap");
|
||||
CXMLWriter Writer(gDataDir + gpkMapPath, "PropertyMap");
|
||||
ASSERT(Writer.IsValid());
|
||||
Writer << SerialParameter("PropertyMap", gNameMap, SH_HexDisplay);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class CAssetProperty : public TSerializeableTypedProperty<CAssetID, EPropertyTyp
|
||||
CResTypeFilter mTypeFilter;
|
||||
|
||||
protected:
|
||||
CAssetProperty::CAssetProperty(EGame Game)
|
||||
CAssetProperty(EGame Game)
|
||||
: TSerializeableTypedProperty(Game)
|
||||
{
|
||||
mDefaultValue = CAssetID::InvalidID( mGame );
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
template<EPropertyType TypeEnum>
|
||||
class TEnumPropertyBase : public TSerializeableTypedProperty<int32, TypeEnum>
|
||||
{
|
||||
using base = TSerializeableTypedProperty<int32, TypeEnum>;
|
||||
friend class IProperty;
|
||||
|
||||
struct SEnumValue
|
||||
@@ -47,17 +48,17 @@ class TEnumPropertyBase : public TSerializeableTypedProperty<int32, TypeEnum>
|
||||
protected:
|
||||
/** Constructor */
|
||||
TEnumPropertyBase(EGame Game)
|
||||
: TSerializeableTypedProperty(Game)
|
||||
: base(Game)
|
||||
, mOverrideTypeName(false)
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual const char* HashableTypeName() const
|
||||
{
|
||||
if (mpArchetype)
|
||||
return mpArchetype->HashableTypeName();
|
||||
if (base::mpArchetype)
|
||||
return base::mpArchetype->HashableTypeName();
|
||||
else if (mOverrideTypeName)
|
||||
return *mName;
|
||||
return *base::mName;
|
||||
else if (TypeEnum == EPropertyType::Enum)
|
||||
return "enum";
|
||||
else
|
||||
@@ -67,15 +68,15 @@ public:
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
// Skip TSerializeableTypedProperty, serialize default value ourselves so we can set SH_HexDisplay
|
||||
TTypedProperty::Serialize(rArc);
|
||||
TTypedProperty<int32, TypeEnum>::Serialize(rArc);
|
||||
|
||||
// Serialize default value
|
||||
TEnumPropertyBase* pArchetype = static_cast<TEnumPropertyBase*>(mpArchetype);
|
||||
TEnumPropertyBase* pArchetype = static_cast<TEnumPropertyBase*>(base::mpArchetype);
|
||||
uint32 DefaultValueFlags = SH_Optional | (TypeEnum == EPropertyType::Enum ? SH_HexDisplay : 0);
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue, DefaultValueFlags, pArchetype ? pArchetype->mDefaultValue : 0);
|
||||
rArc << SerialParameter("DefaultValue", base::mDefaultValue, DefaultValueFlags, pArchetype ? pArchetype->mDefaultValue : 0);
|
||||
|
||||
// Only serialize type name override for root archetypes.
|
||||
if (!mpArchetype)
|
||||
if (!base::mpArchetype)
|
||||
{
|
||||
rArc << SerialParameter("OverrideTypeName", mOverrideTypeName, SH_Optional, false);
|
||||
}
|
||||
@@ -88,19 +89,19 @@ public:
|
||||
|
||||
virtual void SerializeValue(void* pData, IArchive& Arc) const
|
||||
{
|
||||
Arc.SerializePrimitive( (uint32&) ValueRef(pData), 0 );
|
||||
Arc.SerializePrimitive( (uint32&) base::ValueRef(pData), 0 );
|
||||
}
|
||||
|
||||
virtual void InitFromArchetype(IProperty* pOther)
|
||||
{
|
||||
TTypedProperty::InitFromArchetype(pOther);
|
||||
base::InitFromArchetype(pOther);
|
||||
TEnumPropertyBase* pOtherEnum = static_cast<TEnumPropertyBase*>(pOther);
|
||||
mValues = pOtherEnum->mValues;
|
||||
}
|
||||
|
||||
virtual TString ValueAsString(void* pData) const
|
||||
{
|
||||
return TString::FromInt32( Value(pData), 0, 10 );
|
||||
return TString::FromInt32( base::Value(pData), 0, 10 );
|
||||
}
|
||||
|
||||
void AddValue(TString ValueName, uint32 ValueID)
|
||||
@@ -137,21 +138,21 @@ public:
|
||||
bool HasValidValue(void* pPropertyData)
|
||||
{
|
||||
if (mValues.empty()) return true;
|
||||
int ID = ValueRef(pPropertyData);
|
||||
int ID = base::ValueRef(pPropertyData);
|
||||
uint32 Index = ValueIndex(ID);
|
||||
return Index >= 0 && Index < mValues.size();
|
||||
}
|
||||
|
||||
bool OverridesTypeName() const
|
||||
{
|
||||
return mpArchetype ? TPropCast<TEnumPropertyBase>(mpArchetype)->OverridesTypeName() : mOverrideTypeName;
|
||||
return base::mpArchetype ? TPropCast<TEnumPropertyBase>(base::mpArchetype)->OverridesTypeName() : mOverrideTypeName;
|
||||
}
|
||||
|
||||
void SetOverrideTypeName(bool Override)
|
||||
{
|
||||
if (mpArchetype)
|
||||
if (base::mpArchetype)
|
||||
{
|
||||
TEnumPropertyBase* pArchetype = TPropCast<TEnumPropertyBase>(RootArchetype());
|
||||
TEnumPropertyBase* pArchetype = TPropCast<TEnumPropertyBase>(base::RootArchetype());
|
||||
pArchetype->SetOverrideTypeName(Override);
|
||||
}
|
||||
else
|
||||
@@ -159,7 +160,7 @@ public:
|
||||
if (mOverrideTypeName != Override)
|
||||
{
|
||||
mOverrideTypeName = Override;
|
||||
MarkDirty();
|
||||
base::MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ void CPropertyNameGenerator::Warmup()
|
||||
mWords.clear();
|
||||
|
||||
// Load the word list from the file
|
||||
FILE* pListFile = fopen("../resources/WordList.txt", "r");
|
||||
FILE* pListFile = fopen(*(gDataDir + "resources/WordList.txt"), "r");
|
||||
ASSERT(pListFile);
|
||||
|
||||
while (!feof(pListFile))
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "Core/Resource/Script/NGameList.h"
|
||||
#include "Core/Resource/Script/NPropertyMap.h"
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
/** IProperty */
|
||||
IProperty::IProperty(EGame Game)
|
||||
: mpParent( nullptr )
|
||||
@@ -311,7 +313,7 @@ TString IProperty::GetTemplateFileName()
|
||||
pTemplateRoot = pTemplateRoot->RootParent();
|
||||
|
||||
// Now that we have the base property of our template, we can return the file path.
|
||||
static const uint32 kChopAmount = strlen("../templates/");
|
||||
static const uint32 kChopAmount = strlen(*(gDataDir + "templates/"));
|
||||
|
||||
if (pTemplateRoot->ScriptTemplate())
|
||||
{
|
||||
|
||||
@@ -419,29 +419,30 @@ public:
|
||||
template<typename PropType, EPropertyType PropEnum>
|
||||
class TSerializeableTypedProperty : public TTypedProperty<PropType, PropEnum>
|
||||
{
|
||||
using base = TTypedProperty<PropType, PropEnum>;
|
||||
protected:
|
||||
TSerializeableTypedProperty(EGame Game)
|
||||
: TTypedProperty(Game)
|
||||
: base(Game)
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TTypedProperty::Serialize(rArc);
|
||||
TSerializeableTypedProperty* pArchetype = static_cast<TSerializeableTypedProperty*>(mpArchetype);
|
||||
base::Serialize(rArc);
|
||||
TSerializeableTypedProperty* pArchetype = static_cast<TSerializeableTypedProperty*>(base::mpArchetype);
|
||||
|
||||
// Determine if default value should be serialized as optional.
|
||||
// All MP1 properties should be optional. For MP2 and on, we set optional
|
||||
// on property types that don't have default values in the game executable.
|
||||
bool MakeOptional = false;
|
||||
|
||||
if (Game() <= EGame::Prime || pArchetype != nullptr)
|
||||
if (base::Game() <= EGame::Prime || pArchetype != nullptr)
|
||||
{
|
||||
MakeOptional = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (Type())
|
||||
switch (base::Type())
|
||||
{
|
||||
case EPropertyType::String:
|
||||
case EPropertyType::Asset:
|
||||
@@ -457,17 +458,18 @@ public:
|
||||
|
||||
// Branch here to avoid constructing a default value if we don't need to.
|
||||
if (MakeOptional)
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue, SH_Optional, pArchetype ? pArchetype->mDefaultValue : GetSerializationDefaultValue());
|
||||
rArc << SerialParameter("DefaultValue", base::mDefaultValue, SH_Optional,
|
||||
pArchetype ? pArchetype->mDefaultValue : GetSerializationDefaultValue());
|
||||
else
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue);
|
||||
rArc << SerialParameter("DefaultValue", base::mDefaultValue);
|
||||
}
|
||||
|
||||
virtual bool ShouldSerialize() const
|
||||
{
|
||||
TTypedProperty* pArchetype = static_cast<TTypedProperty*>(mpArchetype);
|
||||
base* pArchetype = static_cast<base*>(base::mpArchetype);
|
||||
|
||||
return TTypedProperty::ShouldSerialize() ||
|
||||
!(mDefaultValue == pArchetype->DefaultValue());
|
||||
return base::ShouldSerialize() ||
|
||||
!(base::mDefaultValue == pArchetype->DefaultValue());
|
||||
}
|
||||
|
||||
/** Return default value for serialization - can be customized per type */
|
||||
@@ -480,6 +482,7 @@ public:
|
||||
template<typename PropType, EPropertyType PropEnum>
|
||||
class TNumericalProperty : public TSerializeableTypedProperty<PropType, PropEnum>
|
||||
{
|
||||
using base = TSerializeableTypedProperty<PropType, PropEnum>;
|
||||
friend class IProperty;
|
||||
friend class CTemplateLoader;
|
||||
|
||||
@@ -488,7 +491,7 @@ protected:
|
||||
PropType mMaxValue;
|
||||
|
||||
TNumericalProperty(EGame Game)
|
||||
: TSerializeableTypedProperty(Game)
|
||||
: base(Game)
|
||||
, mMinValue( -1 )
|
||||
, mMaxValue( -1 )
|
||||
{}
|
||||
@@ -496,8 +499,8 @@ protected:
|
||||
public:
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TSerializeableTypedProperty::Serialize(rArc);
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(mpArchetype);
|
||||
base::Serialize(rArc);
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(base::mpArchetype);
|
||||
|
||||
rArc << SerialParameter("Min", mMinValue, SH_Optional, pArchetype ? pArchetype->mMinValue : (PropType) -1)
|
||||
<< SerialParameter("Max", mMaxValue, SH_Optional, pArchetype ? pArchetype->mMaxValue : (PropType) -1);
|
||||
@@ -505,15 +508,15 @@ public:
|
||||
|
||||
virtual bool ShouldSerialize() const
|
||||
{
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(mpArchetype);
|
||||
return TSerializeableTypedProperty::ShouldSerialize() ||
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(base::mpArchetype);
|
||||
return base::ShouldSerialize() ||
|
||||
mMinValue != pArchetype->mMinValue ||
|
||||
mMaxValue != pArchetype->mMaxValue;
|
||||
}
|
||||
|
||||
virtual void InitFromArchetype(IProperty* pOther)
|
||||
{
|
||||
TSerializeableTypedProperty::InitFromArchetype(pOther);
|
||||
base::InitFromArchetype(pOther);
|
||||
TNumericalProperty* pCastOther = static_cast<TNumericalProperty*>(pOther);
|
||||
mMinValue = pCastOther->mMinValue;
|
||||
mMaxValue = pCastOther->mMaxValue;
|
||||
@@ -521,11 +524,11 @@ public:
|
||||
|
||||
virtual void PropertyValueChanged(void* pPropertyData)
|
||||
{
|
||||
TSerializeableTypedProperty::PropertyValueChanged(pPropertyData);
|
||||
base::PropertyValueChanged(pPropertyData);
|
||||
|
||||
if (mMinValue >= 0 && mMaxValue >= 0)
|
||||
{
|
||||
PropType& rValue = ValueRef(pPropertyData);
|
||||
PropType& rValue = base::ValueRef(pPropertyData);
|
||||
rValue = Math::Clamp(mMinValue, mMaxValue, rValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "CVectorProperty.h"
|
||||
|
||||
/** TPropertyRef: Embeds a reference to a property on a specific object */
|
||||
template<class PropertyClass, typename ValueType = PropertyClass::ValueType>
|
||||
template<class PropertyClass, typename ValueType = typename PropertyClass::ValueType>
|
||||
class TPropertyRef
|
||||
{
|
||||
/** Property data being referenced */
|
||||
@@ -96,17 +96,18 @@ typedef TPropertyRef<CArrayProperty> CArrayRef;
|
||||
template<typename ValueType>
|
||||
class TEnumRef : public TPropertyRef<CEnumProperty, ValueType>
|
||||
{
|
||||
using base = TPropertyRef<CEnumProperty, ValueType>;
|
||||
public:
|
||||
TEnumRef()
|
||||
: TPropertyRef()
|
||||
: base()
|
||||
{}
|
||||
|
||||
TEnumRef(void* pInData, IProperty* pInProperty)
|
||||
: TPropertyRef(pInData, pInProperty)
|
||||
: base(pInData, pInProperty)
|
||||
{}
|
||||
|
||||
TEnumRef(void* pInData, CEnumProperty* pInProperty)
|
||||
: TPropertyRef(pInData, pInProperty)
|
||||
: base(pInData, pInProperty)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user