Various fixes

This commit is contained in:
Areloch 2019-05-11 21:42:27 -05:00
parent 60a29777fa
commit 3fa7a0d4fa
27 changed files with 171 additions and 177 deletions

View file

@ -40,6 +40,8 @@
#include "assets/assetPtr.h"
#endif
#include "T3D/entity.h"
// Debug Profiling.
#include "platform/profiler.h"
@ -133,12 +135,14 @@ void GameObjectAsset::copyTo(SimObject* object)
void GameObjectAsset::initializeAsset()
{
//Ensure we have an expanded filepath
mScriptFile = expandAssetFilePath(mScriptFile);
if (!Platform::isFullPath(mScriptFile))
mScriptFile = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptFile;
if (Platform::isFile(mScriptFile))
Con::executeFile(mScriptFile, false, false);
mTAMLFile = expandAssetFilePath(mTAMLFile);
if (!Platform::isFullPath(mTAMLFile))
mTAMLFile = getOwned() ? expandAssetFilePath(mTAMLFile) : mTAMLFile;
}
void GameObjectAsset::onAssetRefresh()
@ -165,7 +169,7 @@ void GameObjectAsset::setScriptFile(const char* pScriptFile)
return;
// Update.
mScriptFile = expandAssetFilePath(pScriptFile);
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : pScriptFile;
// Refresh the asset.
refreshAsset();
@ -185,7 +189,7 @@ void GameObjectAsset::setTAMLFile(const char* pTAMLFile)
return;
// Update.
mTAMLFile = expandAssetFilePath(pTAMLFile);
mTAMLFile = getOwned() ? expandAssetFilePath(pTAMLFile) : pTAMLFile;
// Refresh the asset.
refreshAsset();
@ -218,7 +222,12 @@ const char* GameObjectAsset::create()
}
//Flag it so we know where it came from
pSimObject->setDataField("GameObject", nullptr, getAssetId());
//Entity* e = dynamic_cast<Entity*>(pSimObject);
//e->_setGameObject(getAssetId());
StringTableEntry assetId = getAssetId();
pSimObject->setDataField(StringTable->insert("GameObject"), nullptr, getAssetId());
return pSimObject->getIdString();
}

View file

@ -86,6 +86,7 @@ ConsoleSetType(TypeShapeAssetPtr)
ShapeAsset::ShapeAsset()
{
mFileName = StringTable->EmptyString();
}
//-----------------------------------------------------------------------------
@ -129,6 +130,10 @@ void ShapeAsset::initializeAsset()
ResourceManager::get().getChangedSignal().notify(this, &ShapeAsset::_onResourceChanged);
//Ensure our path is expando'd if it isn't already
if (!Platform::isFullPath(mFileName))
mFileName = getOwned() ? expandAssetFilePath(mFileName) : mFileName;
loadShape();
}
@ -144,8 +149,7 @@ void ShapeAsset::setShapeFile(const char* pShapeFile)
if (pShapeFile == mFileName)
return;
// Update.
mFileName = getOwned() ? expandAssetFilePath(pShapeFile) : StringTable->insert(pShapeFile);
mFileName = pShapeFile;
// Refresh the asset.
refreshAsset();
@ -156,6 +160,8 @@ void ShapeAsset::_onResourceChanged(const Torque::Path &path)
if (path != Torque::Path(mFileName) )
return;
refreshAsset();
loadShape();
}
@ -268,9 +274,13 @@ void ShapeAsset::copyTo(SimObject* object)
void ShapeAsset::onAssetRefresh(void)
{
if (dStrcmp(mFileName, "") == 0)
if (mFileName == StringTable->EmptyString())
return;
// Update.
if(!Platform::isFullPath(mFileName))
mFileName = getOwned() ? expandAssetFilePath(mFileName) : mFileName;
loadShape();
}
@ -405,4 +415,4 @@ bool GuiInspectorTypeShapeAssetPtr::updateRects()
}
return resized;
}
}