Przeglądaj źródła

Update ImageAsset.cpp

add change notification on intialize asset use this callback to update information about the image on refresh. Remove notification when the asset is removed and when the imagefile changes
marauder2k7 3 miesięcy temu
rodzic
commit
794a8c900d
1 zmienionych plików z 7 dodań i 0 usunięć
  1. 7 0
      Engine/source/T3D/assets/ImageAsset.cpp

+ 7 - 0
Engine/source/T3D/assets/ImageAsset.cpp

@@ -213,6 +213,8 @@ bool ImageAsset::onAdd()
 
 
 void ImageAsset::onRemove()
 void ImageAsset::onRemove()
 {
 {
+   Torque::FS::RemoveChangeNotification(mImageFile, this, &ImageAsset::_onResourceChanged);
+
    // Call Parent.
    // Call Parent.
    Parent::onRemove();
    Parent::onRemove();
 }
 }
@@ -346,6 +348,9 @@ void ImageAsset::initializeAsset(void)
 
 
    mImageFile = expandAssetFilePath(mImageFile);
    mImageFile = expandAssetFilePath(mImageFile);
 
 
+   if (getOwned())
+      Torque::FS::AddChangeNotification(mImageFile, this, &ImageAsset::_onResourceChanged);
+
    populateImage();
    populateImage();
 }
 }
 
 
@@ -389,6 +394,8 @@ void ImageAsset::setImageFile(StringTableEntry pImageFile)
    if (pImageFile == mImageFile)
    if (pImageFile == mImageFile)
       return;
       return;
 
 
+   Torque::FS::RemoveChangeNotification(mImageFile, this, &ImageAsset::_onResourceChanged);
+
    if (String(pImageFile).startsWith("#") || String(pImageFile).startsWith("$"))
    if (String(pImageFile).startsWith("#") || String(pImageFile).startsWith("$"))
    {
    {
       mImageFile = StringTable->insert(pImageFile);
       mImageFile = StringTable->insert(pImageFile);