mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 21:10:32 +00:00
Converts all game, gui editor, and system classes to utilize assets
Processed core, tools and default modules to utilize assets Converted all console types that were string based, such as TypeImageFilename to utilize const char*/the string table, which avoids a lot of type swapping shenanigans and avoids string corruption Removed unneeded MainEditor mockup module Removed some unused/duplicate image assets from the tools
This commit is contained in:
parent
83b0432283
commit
5525f8ecdd
1708 changed files with 19619 additions and 4596 deletions
|
|
@ -315,6 +315,32 @@ S32 AssetBase::getAssetDependencyFieldCount(const char* pFieldName)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
StringTableEntry AssetBase::getAssetDependencyField(const char* pFieldName, S32 index)
|
||||
{
|
||||
SimFieldDictionary* fieldDictionary = getFieldDictionary();
|
||||
for (SimFieldDictionaryIterator itr(fieldDictionary); *itr; ++itr)
|
||||
{
|
||||
SimFieldDictionary::Entry* entry = *itr;
|
||||
|
||||
String slotName = String(entry->slotName);
|
||||
|
||||
if (slotName.startsWith(pFieldName))
|
||||
{
|
||||
S32 trailingNum;
|
||||
String::GetTrailingNumber(slotName.c_str(), trailingNum);
|
||||
|
||||
if (trailingNum == index)
|
||||
{
|
||||
return StringTable->insert(String(entry->value).replace(ASSET_ID_FIELD_PREFIX, "").c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return StringTable->EmptyString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AssetBase::clearAssetDependencyFields(const char* pFieldName)
|
||||
{
|
||||
SimFieldDictionary* fieldDictionary = getFieldDictionary();
|
||||
|
|
@ -340,7 +366,7 @@ void AssetBase::addAssetDependencyField(const char* pFieldName, const char* pAss
|
|||
dSprintf(depSlotName, sizeof(depSlotName), "%s%d", pFieldName, existingFieldCount);
|
||||
|
||||
char depValue[255];
|
||||
dSprintf(depValue, sizeof(depValue), "@Asset=%s", pAssetId);
|
||||
dSprintf(depValue, sizeof(depValue), "%s=%s", ASSET_ID_SIGNATURE, pAssetId);
|
||||
|
||||
setDataField(StringTable->insert(depSlotName), NULL, StringTable->insert(depValue));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ protected:
|
|||
bool mAssetInitialized;
|
||||
AssetDefinition* mpAssetDefinition;
|
||||
U32 mAcquireReferenceCount;
|
||||
U32 mLoadedState;
|
||||
|
||||
public:
|
||||
enum AssetErrCode
|
||||
|
|
@ -87,7 +88,7 @@ public:
|
|||
if (errCode > AssetErrCode::Extended) return "undefined error";
|
||||
return mErrCodeStrings[errCode];
|
||||
};
|
||||
|
||||
U32 getStatus() { return mLoadedState; };
|
||||
AssetBase();
|
||||
virtual ~AssetBase();
|
||||
|
||||
|
|
@ -124,6 +125,7 @@ public:
|
|||
void refreshAsset(void);
|
||||
|
||||
S32 getAssetDependencyFieldCount(const char* pFieldName);
|
||||
StringTableEntry getAssetDependencyField(const char* pFieldName, S32 index = 0);
|
||||
void clearAssetDependencyFields(const char* pFieldName);
|
||||
void addAssetDependencyField(const char* pFieldName, const char* pAssetId);
|
||||
|
||||
|
|
@ -167,5 +169,10 @@ private:
|
|||
void setOwned(AssetManager* pAssetManager, AssetDefinition* pAssetDefinition);
|
||||
};
|
||||
|
||||
//helper macro for stitching string and non string values togeather sans quotes
|
||||
#define assetText(x,suff) std::string(std::string(#x) + std::string(#suff)).c_str()
|
||||
#define macroText(x) std::string(std::string(#x)).c_str()
|
||||
#define assetDoc(x,suff) std::string(std::string("@brief") + std::string(#x) + std::string(#suff)).c_str()
|
||||
|
||||
#endif // _ASSET_BASE_H_
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,15 @@ DefineEngineMethod(AssetBase, getAssetDependencyFieldCount, S32, (const char* pF
|
|||
return object->getAssetDependencyFieldCount(pFieldName);
|
||||
}
|
||||
|
||||
DefineEngineMethod(AssetBase, getAssetDependencyField, const char*, (const char* pFieldName, S32 index), ("", 0),
|
||||
"Gets an asset dependency field to the asset definition at a given index.\n"
|
||||
"@param fieldName The name of the field.\n"
|
||||
"@param index The index of the field to look up in the event there are multiple dependency fields. Defaults to 0"
|
||||
"@return The assetID assigned to the given dependency field.\n")
|
||||
{
|
||||
return object->getAssetDependencyField(pFieldName, index);
|
||||
}
|
||||
|
||||
DefineEngineMethod(AssetBase, clearAssetDependencyFields, void, (const char* pFieldName), (""),
|
||||
"Clears any asset dependency fields matching the name provided.\n"
|
||||
"@param fieldName The name of the fields to be cleared")
|
||||
|
|
@ -71,3 +80,15 @@ DefineEngineMethod(AssetBase, saveAsset, bool, (), ,
|
|||
{
|
||||
return object->saveAsset();
|
||||
}
|
||||
|
||||
DefineEngineMethod(AssetBase, getStatus, S32, (), , "get status")\
|
||||
{
|
||||
return object->getStatus();
|
||||
}
|
||||
|
||||
DefineEngineMethod(AssetBase, getStatusString, const char*, (), ,
|
||||
"Returns the load status of the asset.\n"
|
||||
"@return What status code the asset had after being loaded.\n")
|
||||
{
|
||||
return object->getAssetErrstrn(object->getStatus());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue