mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-14 23:56:23 +00:00
Added ability to test Int properties as Choices. Added functionality to fix the property name map keeping track of unused type/ID pairs. Fixed various UI bugs.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "NPropertyMap.h"
|
||||
#include "NGameList.h"
|
||||
#include <Common/NBasics.h>
|
||||
#include <Common/Serialization/XML.h>
|
||||
|
||||
@@ -202,6 +203,21 @@ void SaveMap(bool Force /*= false*/)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make sure all game templates are loaded and clear out ID-type pairs that aren't used
|
||||
// This mostly occurs when type names are changed - unneeded pairings with the old type can be left in the map
|
||||
NGameList::LoadAllGameTemplates();
|
||||
|
||||
for (auto Iter = gNameMap.begin(); Iter != gNameMap.end(); Iter++)
|
||||
{
|
||||
SNameValue& Value = Iter->second;
|
||||
|
||||
if (Value.PropertyList.empty())
|
||||
{
|
||||
Iter = gNameMap.erase(Iter);
|
||||
}
|
||||
}
|
||||
|
||||
// Perform the actual save
|
||||
CXMLWriter Writer(gpkMapPath, "PropertyMap");
|
||||
ASSERT(Writer.IsValid());
|
||||
Writer << SerialParameter("PropertyMap", gNameMap, SH_HexDisplay);
|
||||
|
||||
@@ -69,6 +69,12 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
|
||||
mTypeNames = rkParams.TypeNames;
|
||||
}
|
||||
|
||||
// If TestIntsAsChoices is enabled, and int is in the type list, then choice must be in the type list too.
|
||||
if (rkParams.TestIntsAsChoices && NBasics::VectorContains(mTypeNames, TString("int")))
|
||||
{
|
||||
NBasics::VectorAddUnique(mTypeNames, TString("choice"));
|
||||
}
|
||||
|
||||
// If we haven't loaded the word list yet, load it.
|
||||
// If we are still loading the word list, wait until we're finished.
|
||||
if (!mWordListLoadFinished)
|
||||
@@ -202,7 +208,7 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
|
||||
}
|
||||
|
||||
PropertyName.Name += rkParams.Suffix;
|
||||
PropertyName.Type = mTypeNames[TypeIdx];
|
||||
PropertyName.Type = pkTypeName;
|
||||
PropertyName.ID = PropertyID;
|
||||
|
||||
if (SaveResults)
|
||||
@@ -253,7 +259,7 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
|
||||
}
|
||||
|
||||
/** Returns whether a given property ID is valid */
|
||||
bool CPropertyNameGenerator::IsValidPropertyID(u32 ID, const char* pkType, const SPropertyNameGenerationParameters& rkParams)
|
||||
bool CPropertyNameGenerator::IsValidPropertyID(u32 ID, const char*& pkType, const SPropertyNameGenerationParameters& rkParams)
|
||||
{
|
||||
if (!mValidTypePairMap.empty())
|
||||
{
|
||||
@@ -261,7 +267,20 @@ bool CPropertyNameGenerator::IsValidPropertyID(u32 ID, const char* pkType, const
|
||||
|
||||
if (Find != mValidTypePairMap.end())
|
||||
{
|
||||
return strcmp( Find->second, pkType ) == 0;
|
||||
if (strcmp( Find->second, pkType ) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (rkParams.TestIntsAsChoices && strcmp(pkType, "choice") == 0)
|
||||
{
|
||||
if (strcmp( Find->second, "int" ) == 0)
|
||||
{
|
||||
pkType = "int";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
@@ -270,6 +289,17 @@ bool CPropertyNameGenerator::IsValidPropertyID(u32 ID, const char* pkType, const
|
||||
{
|
||||
bool IsAlreadyNamed;
|
||||
bool IsValid = NPropertyMap::IsValidPropertyID(ID, pkType, &IsAlreadyNamed);
|
||||
|
||||
if (!IsValid && rkParams.TestIntsAsChoices && strcmp(pkType, "choice") == 0)
|
||||
{
|
||||
IsValid = NPropertyMap::IsValidPropertyID(ID, "int", &IsAlreadyNamed);
|
||||
|
||||
if (IsValid)
|
||||
{
|
||||
pkType = "int";
|
||||
}
|
||||
}
|
||||
|
||||
return IsValid && (!IsAlreadyNamed || !rkParams.ExcludeAccuratelyNamedProperties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ struct SPropertyNameGenerationParameters
|
||||
/** Whether to exclude properties that already have accurate names from the generation results. */
|
||||
bool ExcludeAccuratelyNamedProperties;
|
||||
|
||||
/** Whether to test int properties as choices */
|
||||
bool TestIntsAsChoices;
|
||||
|
||||
/** Whether to print the output from the generation process to the log */
|
||||
bool PrintToLog;
|
||||
};
|
||||
@@ -102,7 +105,7 @@ public:
|
||||
void Generate(const SPropertyNameGenerationParameters& rkParams, IProgressNotifier* pProgressNotifier);
|
||||
|
||||
/** Returns whether a given property ID is valid */
|
||||
bool IsValidPropertyID(u32 ID, const char* pkType, const SPropertyNameGenerationParameters& rkParams);
|
||||
bool IsValidPropertyID(u32 ID, const char*& pkType, const SPropertyNameGenerationParameters& rkParams);
|
||||
|
||||
/** Accessors */
|
||||
bool IsRunning() const
|
||||
|
||||
@@ -518,10 +518,11 @@ bool IProperty::UsesNameMap()
|
||||
|
||||
bool IProperty::HasAccurateName()
|
||||
{
|
||||
// Exceptions for the three hardcoded 4CC property IDs
|
||||
// Exceptions for the three hardcoded 4CC property IDs, and for 0xFFFFFFFF (root properties)
|
||||
if (mID == FOURCC('XFRM') ||
|
||||
mID == FOURCC('INAM') ||
|
||||
mID == FOURCC('ACTV'))
|
||||
mID == FOURCC('ACTV') ||
|
||||
mID == 0xFFFFFFFF)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -543,10 +544,24 @@ bool IProperty::HasAccurateName()
|
||||
Hash.Hash(HashableTypeName());
|
||||
u32 GeneratedID = Hash.Digest();
|
||||
|
||||
// Some choice properties are incorrectly declared as ints, so account for
|
||||
// this and allow matching ints against choice typenames as well.
|
||||
if (GeneratedID != mID && Type() == EPropertyType::Int)
|
||||
{
|
||||
Hash = CCRC32();
|
||||
Hash.Hash(*mName);
|
||||
Hash.Hash("choice");
|
||||
GeneratedID = Hash.Digest();
|
||||
}
|
||||
|
||||
if (GeneratedID == mID)
|
||||
{
|
||||
mFlags.SetFlag( EPropertyFlag::HasCorrectPropertyName );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFlags.ClearFlag( EPropertyFlag::HasCorrectPropertyName );
|
||||
}
|
||||
|
||||
mFlags.SetFlag(EPropertyFlag::HasCachedNameCheck);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user