소스 검색

Merge pull request #1325 from Areloch/Standardized_AB_AssetManagement

Updates most of the handling of asset types to follow a more standardized type-registration system.
Brian Roberts 5 달 전
부모
커밋
798936ebd2
45개의 변경된 파일2158개의 추가작업 그리고 3443개의 파일을 삭제
  1. 16 16
      Engine/source/T3D/SubScene.cpp
  2. 6 6
      Engine/source/T3D/SubScene.h
  3. 14 0
      Engine/source/T3D/assets/CppAsset.cpp
  4. 3 3
      Engine/source/T3D/assets/CppAsset.h
  5. 3 12
      Engine/source/T3D/assets/LevelAsset.cpp
  6. 0 3
      Engine/source/T3D/assets/LevelAsset.h
  7. 166 0
      Engine/source/T3D/assets/SubSceneAsset.cpp
  8. 113 0
      Engine/source/T3D/assets/SubSceneAsset.h
  9. 47 0
      Engine/source/assets/assetManager.cpp
  10. 3 0
      Engine/source/assets/assetManager.h
  11. 14 0
      Engine/source/assets/assetManager_ScriptBinding.h
  12. 6 27
      Templates/BaseGame/game/tools/assetBrowser/main.tscript
  13. 419 398
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript
  14. 0 86
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/assetTypeExample.tscript
  15. 0 143
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/component.tscript
  16. 126 74
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cpp.tscript
  17. 7 49
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cubemap.tscript
  18. 50 148
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/datablockObjects.tscript
  19. 0 0
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/decal.tscript
  20. 0 0
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/explosion.tscript
  21. 86 32
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/folder.tscript
  22. 0 0
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/forest.tscript
  23. 0 285
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/gameObject.tscript
  24. 351 0
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/genericAsset.tscript
  25. 25 79
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/gui.tscript
  26. 35 425
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.tscript
  27. 32 219
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.tscript
  28. 10 7
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/looseFiles.tscript
  29. 39 408
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.tscript
  30. 0 0
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/particle.tscript
  31. 70 60
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/postFX.tscript
  32. 18 30
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/prefab.tscript
  33. 93 65
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/script.tscript
  34. 50 272
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript
  35. 12 51
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shapeAnimation.tscript
  36. 26 39
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/sound.tscript
  37. 0 161
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.tscript
  38. 156 0
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/subScene.tscript
  39. 31 81
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/terrain.tscript
  40. 27 79
      Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/terrainMaterial.tscript
  41. 33 0
      Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.tscript
  42. 58 133
      Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.tscript
  43. 2 6
      Templates/BaseGame/game/tools/assetBrowser/scripts/newAsset.tscript
  44. 9 44
      Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.tscript
  45. 2 2
      Templates/BaseGame/game/tools/gui/fieldTypes/listField.tscript

+ 16 - 16
Engine/source/T3D/SubScene.cpp

@@ -24,7 +24,7 @@ IMPLEMENT_CALLBACK(SubScene, onUnloaded, void, (), (),
    "@brief Called when a subScene has been unloaded and has game mode implications.\n\n");
    "@brief Called when a subScene has been unloaded and has game mode implications.\n\n");
 
 
 SubScene::SubScene() :
 SubScene::SubScene() :
-   mLevelAssetId(StringTable->EmptyString()),
+   mSubSceneAssetId(StringTable->EmptyString()),
    mGameModesNames(StringTable->EmptyString()),
    mGameModesNames(StringTable->EmptyString()),
    mScopeDistance(-1),
    mScopeDistance(-1),
    mLoaded(false),
    mLoaded(false),
@@ -67,7 +67,7 @@ void SubScene::initPersistFields()
 {
 {
    addGroup("SubScene");
    addGroup("SubScene");
    addField("isGlobalLayer", TypeBool, Offset(mGlobalLayer, SubScene), "");
    addField("isGlobalLayer", TypeBool, Offset(mGlobalLayer, SubScene), "");
-   INITPERSISTFIELD_LEVELASSET(Level, SubScene, "The level asset to load.");
+   INITPERSISTFIELD_SUBSCENEASSET(SubScene, SubScene, "The subscene asset to load.");
    addField("tickPeriodMS", TypeS32, Offset(mTickPeriodMS, SubScene), "evaluation rate (ms)");
    addField("tickPeriodMS", TypeS32, Offset(mTickPeriodMS, SubScene), "evaluation rate (ms)");
    addField("gameModes", TypeGameModeList, Offset(mGameModesNames, SubScene), "The game modes that this subscene is associated with.");
    addField("gameModes", TypeGameModeList, Offset(mGameModesNames, SubScene), "The game modes that this subscene is associated with.");
    endGroup("SubScene");
    endGroup("SubScene");
@@ -265,13 +265,13 @@ void SubScene::processTick(const Move* move)
 
 
 void SubScene::_onFileChanged(const Torque::Path& path)
 void SubScene::_onFileChanged(const Torque::Path& path)
 {
 {
-   if(mLevelAsset.isNull() || Torque::Path(mLevelAsset->getLevelPath()) != path)
+   if(mSubSceneAsset.isNull() || Torque::Path(mSubSceneAsset->getLevelPath()) != path)
       return;
       return;
 
 
    if (mSaving)
    if (mSaving)
       return;
       return;
 
 
-   AssertFatal(path == mLevelAsset->getLevelPath(), "Prefab::_onFileChanged - path does not match filename.");
+   AssertFatal(path == mSubSceneAsset->getLevelPath(), "SubScene::_onFileChanged - path does not match filename.");
 
 
    _closeFile(false);
    _closeFile(false);
    _loadFile(false);
    _loadFile(false);
@@ -307,9 +307,9 @@ void SubScene::_closeFile(bool removeFileNotify)
 
 
    _removeContents(SimGroupIterator(this));
    _removeContents(SimGroupIterator(this));
 
 
-   if (removeFileNotify && mLevelAsset.notNull() && mLevelAsset->getLevelPath() != StringTable->EmptyString())
+   if (removeFileNotify && mSubSceneAsset.notNull() && mSubSceneAsset->getLevelPath() != StringTable->EmptyString())
    {
    {
-      Torque::FS::RemoveChangeNotification(mLevelAsset->getLevelPath(), this, &SubScene::_onFileChanged);
+      Torque::FS::RemoveChangeNotification(mSubSceneAsset->getLevelPath(), this, &SubScene::_onFileChanged);
    }
    }
 
 
    mGameModesList.clear();
    mGameModesList.clear();
@@ -319,18 +319,18 @@ void SubScene::_loadFile(bool addFileNotify)
 {
 {
    AssertFatal(isServerObject(), "Trying to load a SubScene file on the client is bad!");
    AssertFatal(isServerObject(), "Trying to load a SubScene file on the client is bad!");
 
 
-   if(mLevelAsset.isNull() || mLevelAsset->getLevelPath() == StringTable->EmptyString())
+   if(mSubSceneAsset.isNull() || mSubSceneAsset->getLevelPath() == StringTable->EmptyString())
       return;
       return;
 
 
-   String evalCmd = String::ToString("exec(\"%s\");", mLevelAsset->getLevelPath());
+   String evalCmd = String::ToString("exec(\"%s\");", mSubSceneAsset->getLevelPath());
 
 
    String instantGroup = Con::getVariable("InstantGroup");
    String instantGroup = Con::getVariable("InstantGroup");
    Con::setIntVariable("InstantGroup", this->getId());
    Con::setIntVariable("InstantGroup", this->getId());
-   Con::evaluate((const char*)evalCmd.c_str(), false, mLevelAsset->getLevelPath());
+   Con::evaluate((const char*)evalCmd.c_str(), false, mSubSceneAsset->getLevelPath());
    Con::setVariable("InstantGroup", instantGroup.c_str());
    Con::setVariable("InstantGroup", instantGroup.c_str());
 
 
    if (addFileNotify)
    if (addFileNotify)
-      Torque::FS::AddChangeNotification(mLevelAsset->getLevelPath(), this, &SubScene::_onFileChanged);
+      Torque::FS::AddChangeNotification(mSubSceneAsset->getLevelPath(), this, &SubScene::_onFileChanged);
 }
 }
 
 
 void SubScene::load()
 void SubScene::load()
@@ -432,7 +432,7 @@ bool SubScene::save()
    if (size() == 0 || !isLoaded())
    if (size() == 0 || !isLoaded())
       return false;
       return false;
 
 
-   if (mLevelAsset.isNull())
+   if (mSubSceneAsset.isNull())
       return false;
       return false;
 
 
    if (mSaving)
    if (mSaving)
@@ -446,7 +446,7 @@ bool SubScene::save()
 
 
    PersistenceManager prMger;
    PersistenceManager prMger;
 
 
-   StringTableEntry levelPath = mLevelAsset->getLevelPath();
+   StringTableEntry levelPath = mSubSceneAsset->getLevelPath();
 
 
    FileStream fs;
    FileStream fs;
    fs.open(levelPath, Torque::FS::File::Write);
    fs.open(levelPath, Torque::FS::File::Write);
@@ -460,7 +460,7 @@ bool SubScene::save()
       {
       {
          if ((*itr)->isMethod("onSaving"))
          if ((*itr)->isMethod("onSaving"))
          {
          {
-            Con::executef((*itr), "onSaving", mLevelAssetId);
+            Con::executef((*itr), "onSaving", mSubSceneAssetId);
          }
          }
 
 
          if (childObj->getGroup() == this)
          if (childObj->getGroup() == this)
@@ -481,14 +481,14 @@ bool SubScene::save()
    bool saveSuccess = false;
    bool saveSuccess = false;
 
 
    //Get the level asset
    //Get the level asset
-   if (mLevelAsset.isNull())
+   if (mSubSceneAsset.isNull())
       return saveSuccess;
       return saveSuccess;
 
 
    //update the gamemode list as well
    //update the gamemode list as well
-   mLevelAsset->setDataField(StringTable->insert("gameModesNames"), NULL, StringTable->insert(mGameModesNames));
+   mSubSceneAsset->setDataField(StringTable->insert("gameModesNames"), NULL, StringTable->insert(mGameModesNames));
 
 
    //Finally, save
    //Finally, save
-   saveSuccess = mLevelAsset->saveAsset();
+   saveSuccess = mSubSceneAsset->saveAsset();
 
 
    mSaving = false;
    mSaving = false;
 
 

+ 6 - 6
Engine/source/T3D/SubScene.h

@@ -5,8 +5,8 @@
 #ifndef SCENE_GROUP_H
 #ifndef SCENE_GROUP_H
 #include "SceneGroup.h"
 #include "SceneGroup.h"
 #endif
 #endif
-#ifndef LEVEL_ASSET_H
-#include "assets/LevelAsset.h"
+#ifndef SUBSCENE_ASSET_H
+#include "assets/SubSceneAsset.h"
 #endif
 #endif
 
 
 class GameMode;
 class GameMode;
@@ -21,13 +21,13 @@ public:
       NextFreeMask = Parent::NextFreeMask << 0
       NextFreeMask = Parent::NextFreeMask << 0
    };
    };
 
 
-   void onLevelChanged() {}
+   void onSubSceneChanged() {}
 
 
 protected:
 protected:
    static bool smTransformChildren;
    static bool smTransformChildren;
 
 
 private:
 private:
-   DECLARE_LEVELASSET(SubScene, Level, onLevelChanged);
+   DECLARE_SUBSCENEASSET(SubScene, SubScene, onSubSceneChanged);
 
 
    StringTableEntry mGameModesNames;
    StringTableEntry mGameModesNames;
    Vector<GameMode*> mGameModesList;
    Vector<GameMode*> mGameModesList;
@@ -61,7 +61,7 @@ public:
 
 
    static void initPersistFields();
    static void initPersistFields();
    static void consoleInit();
    static void consoleInit();
-   StringTableEntry getTypeHint() const override { return (getLevelAsset()) ? getLevelAsset()->getAssetName() : StringTable->EmptyString(); }
+   StringTableEntry getTypeHint() const override { return (getSubSceneAsset()) ? getSubSceneAsset()->getAssetName() : StringTable->EmptyString(); }
 
 
    // SimObject
    // SimObject
    bool onAdd() override;
    bool onAdd() override;
@@ -122,6 +122,6 @@ public:
 
 
    DECLARE_CALLBACK(void, onLoaded, ());
    DECLARE_CALLBACK(void, onLoaded, ());
    DECLARE_CALLBACK(void, onUnloaded, ());
    DECLARE_CALLBACK(void, onUnloaded, ());
-   DECLARE_ASSET_SETGET(SubScene, Level);
+   DECLARE_ASSET_SETGET(SubScene, SubScene);
 };
 };
 #endif
 #endif

+ 14 - 0
Engine/source/T3D/assets/CppAsset.cpp

@@ -178,3 +178,17 @@ void CppAsset::onAssetRefresh(void)
 
 
    mHeaderPath = getOwned() ? expandAssetFilePath(mHeaderFile) : mHeaderPath;
    mHeaderPath = getOwned() ? expandAssetFilePath(mHeaderFile) : mHeaderPath;
 }
 }
+
+DefineEngineMethod(CppAsset, getCodePath, const char*, (), ,
+   "Gets the code file filepath of this asset.\n"
+   "@return File path of the code file.")
+{
+   return object->getCppFilePath();
+}
+
+DefineEngineMethod(CppAsset, getHeaderPath, const char*, (), ,
+   "Gets the header file filepath of this asset.\n"
+   "@return File path of the header file.")
+{
+   return object->getHeaderFilePath();
+}

+ 3 - 3
Engine/source/T3D/assets/CppAsset.h

@@ -66,6 +66,9 @@ public:
    void                    setHeaderFile(const char* pHeaderFile);
    void                    setHeaderFile(const char* pHeaderFile);
    inline StringTableEntry getHeaderFile(void) const { return mHeaderFile; };
    inline StringTableEntry getHeaderFile(void) const { return mHeaderFile; };
 
 
+   inline StringTableEntry getCppFilePath(void) const { return mCodePath; };
+   inline StringTableEntry getHeaderFilePath(void) const { return mHeaderPath; };
+
 protected:
 protected:
 	void            initializeAsset(void) override;
 	void            initializeAsset(void) override;
 	void            onAssetRefresh(void) override;
 	void            onAssetRefresh(void) override;
@@ -73,9 +76,6 @@ protected:
    static bool setCppFile(void *obj, const char *index, const char *data) { static_cast<CppAsset*>(obj)->setCppFile(data); return false; }
    static bool setCppFile(void *obj, const char *index, const char *data) { static_cast<CppAsset*>(obj)->setCppFile(data); return false; }
    static const char* getCppFile(void* obj, const char* data) { return static_cast<CppAsset*>(obj)->getCppFile(); }
    static const char* getCppFile(void* obj, const char* data) { return static_cast<CppAsset*>(obj)->getCppFile(); }
 
 
-   inline StringTableEntry getCppFilePath(void) const { return mCodePath; };
-   inline StringTableEntry getHeaderFilePath(void) const { return mHeaderPath; };
-
    static bool setHeaderFile(void *obj, const char *index, const char *data) { static_cast<CppAsset*>(obj)->setHeaderFile(data); return false; }
    static bool setHeaderFile(void *obj, const char *index, const char *data) { static_cast<CppAsset*>(obj)->setHeaderFile(data); return false; }
    static const char* getHeaderFile(void* obj, const char* data) { return static_cast<CppAsset*>(obj)->getHeaderFile(); }
    static const char* getHeaderFile(void* obj, const char* data) { return static_cast<CppAsset*>(obj)->getHeaderFile(); }
 };
 };

+ 3 - 12
Engine/source/T3D/assets/LevelAsset.cpp

@@ -101,7 +101,7 @@ ConsoleSetType(TypeLevelAssetId)
 }
 }
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
-LevelAsset::LevelAsset() : AssetBase(), mIsSubLevel(false)
+LevelAsset::LevelAsset() : AssetBase()
 {
 {
    mLevelName = StringTable->EmptyString();
    mLevelName = StringTable->EmptyString();
    mLevelFile = StringTable->EmptyString();
    mLevelFile = StringTable->EmptyString();
@@ -117,7 +117,6 @@ LevelAsset::LevelAsset() : AssetBase(), mIsSubLevel(false)
    mNavmeshPath = StringTable->EmptyString();
    mNavmeshPath = StringTable->EmptyString();
 
 
    mGameModesNames = StringTable->EmptyString();
    mGameModesNames = StringTable->EmptyString();
-   mMainLevelAsset = StringTable->EmptyString();
 
 
    mEditorFile = StringTable->EmptyString();
    mEditorFile = StringTable->EmptyString();
    mBakedSceneFile = StringTable->EmptyString();
    mBakedSceneFile = StringTable->EmptyString();
@@ -158,7 +157,6 @@ void LevelAsset::initPersistFields()
    addProtectedField("BakedSceneFile", TypeAssetLooseFilePath, Offset(mBakedSceneFile, LevelAsset),
    addProtectedField("BakedSceneFile", TypeAssetLooseFilePath, Offset(mBakedSceneFile, LevelAsset),
       &setBakedSceneFile, &getBakedSceneFile, "Path to the level file with the objects generated as part of the baking process");
       &setBakedSceneFile, &getBakedSceneFile, "Path to the level file with the objects generated as part of the baking process");
 
 
-   addField("isSubScene", TypeBool, Offset(mIsSubLevel, LevelAsset), "Is this a sublevel to another Scene");
    addField("gameModesNames", TypeString, Offset(mGameModesNames, LevelAsset), "Name of the Game Mode to be used with this level");
    addField("gameModesNames", TypeString, Offset(mGameModesNames, LevelAsset), "Name of the Game Mode to be used with this level");
 }
 }
 
 
@@ -481,15 +479,8 @@ GuiControl* GuiInspectorTypeLevelAssetPtr::constructEditControl()
    // Create "Open in Editor" button
    // Create "Open in Editor" button
    mEditButton = new GuiBitmapButtonCtrl();
    mEditButton = new GuiBitmapButtonCtrl();
 
 
-   String setSubSceneValue = "$createLevelAssetIsSubScene = \"\";";
-   if(dynamic_cast<SubScene*>(mInspector->getInspectObject()) != NULL)
-   {
-      setSubSceneValue = "$createLevelAssetIsSubScene = true;";
-   }
-
-   dSprintf(szBuffer, sizeof(szBuffer), "$createAndAssignField = %s; %s AssetBrowser.setupCreateNewAsset(\"LevelAsset\", AssetBrowser.selectedModule, \"createAndAssignLevelAsset\");",
-      getIdString(),
-      setSubSceneValue.c_str());
+   dSprintf(szBuffer, sizeof(szBuffer), "$createAndAssignField = %s; AssetBrowser.setupCreateNewAsset(\"LevelAsset\", AssetBrowser.selectedModule, \"createAndAssignLevelAsset\");",
+      getIdString());
    mEditButton->setField("Command", szBuffer);
    mEditButton->setField("Command", szBuffer);
 
 
    char bitmapName[512] = "ToolsModule:iconAdd_image";
    char bitmapName[512] = "ToolsModule:iconAdd_image";

+ 0 - 3
Engine/source/T3D/assets/LevelAsset.h

@@ -66,9 +66,6 @@ class LevelAsset : public AssetBase
    StringTableEntry        mEditorFile;
    StringTableEntry        mEditorFile;
    StringTableEntry        mBakedSceneFile;
    StringTableEntry        mBakedSceneFile;
 
 
-   bool                    mIsSubLevel;
-   StringTableEntry        mMainLevelAsset;
-
    StringTableEntry        mGameModesNames;
    StringTableEntry        mGameModesNames;
 
 
    Vector<AssetBase*>      mAssetDependencies;
    Vector<AssetBase*>      mAssetDependencies;

+ 166 - 0
Engine/source/T3D/assets/SubSceneAsset.cpp

@@ -0,0 +1,166 @@
+#include "SubSceneAsset.h"
+
+#include "T3D/SubScene.h"
+IMPLEMENT_CONOBJECT(SubSceneAsset);
+
+
+ConsoleType(SubSceneAssetPtr, TypeSubSceneAssetPtr, const char*, "")
+
+//-----------------------------------------------------------------------------
+
+ConsoleGetType(TypeSubSceneAssetPtr)
+{
+   // Fetch asset Id.
+   return *((const char**)(dptr));
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleSetType(TypeSubSceneAssetPtr)
+{
+   // Was a single argument specified?
+   if (argc == 1)
+   {
+      // Yes, so fetch field value.
+      *((const char**)dptr) = StringTable->insert(argv[0]);
+
+      return;
+   }
+
+   // Warn.
+   Con::warnf("(TypeSubSceneAssetPtr) - Cannot set multiple args to a single asset.");
+}
+
+//-----------------------------------------------------------------------------
+ConsoleType(assetIdString, TypeSubSceneAssetId, const char*, "")
+
+ConsoleGetType(TypeSubSceneAssetId)
+{
+   // Fetch asset Id.
+   return *((const char**)(dptr));
+}
+
+ConsoleSetType(TypeSubSceneAssetId)
+{
+   // Was a single argument specified?
+   if (argc == 1)
+   {
+      *((const char**)dptr) = StringTable->insert(argv[0]);
+
+      return;
+   }
+
+   // Warn.
+   Con::warnf("(TypeSubSceneAssetId) - Cannot set multiple args to a single asset.");
+}
+
+SubSceneAsset::SubSceneAsset() : LevelAsset()
+{
+}
+
+SubSceneAsset::~SubSceneAsset()
+{
+}
+
+void SubSceneAsset::initPersistFields()
+{
+   docsURL;
+   Parent::initPersistFields();
+}
+
+
+//-----------------------------------------------------------------------------
+// GuiInspectorTypeAssetId
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_CONOBJECT(GuiInspectorTypeSubSceneAssetPtr);
+
+ConsoleDocClass(GuiInspectorTypeSubSceneAssetPtr,
+   "@brief Inspector field type for Shapes\n\n"
+   "Editor use only.\n\n"
+   "@internal"
+);
+
+void GuiInspectorTypeSubSceneAssetPtr::consoleInit()
+{
+   Parent::consoleInit();
+
+   ConsoleBaseType::getType(TypeSubSceneAssetPtr)->setInspectorFieldType("GuiInspectorTypeSubSceneAssetPtr");
+}
+
+GuiControl* GuiInspectorTypeSubSceneAssetPtr::constructEditControl()
+{
+   // Create base filename edit controls
+   GuiControl* retCtrl = Parent::constructEditControl();
+   if (retCtrl == NULL)
+      return retCtrl;
+
+   // Change filespec
+   char szBuffer[512];
+   dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"SubSceneAsset\", \"AssetBrowser.changeAsset\", %s, \"\");",
+      getIdString());
+   mBrowseButton->setField("Command", szBuffer);
+
+   setDataField(StringTable->insert("targetObject"), NULL, mInspector->getInspectObject()->getIdString());
+
+   // Create "Open in Editor" button
+   mEditButton = new GuiBitmapButtonCtrl();
+
+   dSprintf(szBuffer, sizeof(szBuffer), "$createAndAssignField = %s; AssetBrowser.setupCreateNewAsset(\"SubSceneAsset\", AssetBrowser.selectedModule);",
+      getIdString());
+   mEditButton->setField("Command", szBuffer);
+
+   char bitmapName[512] = "ToolsModule:iconAdd_image";
+   mEditButton->setBitmap(StringTable->insert(bitmapName));
+
+   mEditButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
+   mEditButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
+   mEditButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
+   mEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Test play this sound");
+
+   mEditButton->registerObject();
+   addObject(mEditButton);
+
+   return retCtrl;
+}
+
+bool GuiInspectorTypeSubSceneAssetPtr::updateRects()
+{
+   S32 dividerPos, dividerMargin;
+   mInspector->getDivider(dividerPos, dividerMargin);
+   Point2I fieldExtent = getExtent();
+   Point2I fieldPos = getPosition();
+
+   mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y);
+   mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y);
+
+   bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
+   if (mBrowseButton != NULL)
+   {
+      mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4);
+      resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent);
+   }
+
+   if (mEditButton != NULL)
+   {
+      RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4);
+      resized |= mEditButton->resize(shapeEdRect.point, shapeEdRect.extent);
+   }
+
+   return resized;
+}
+
+IMPLEMENT_CONOBJECT(GuiInspectorTypeSubSceneAssetId);
+
+ConsoleDocClass(GuiInspectorTypeSubSceneAssetId,
+   "@brief Inspector field type for SubScene\n\n"
+   "Editor use only.\n\n"
+   "@internal"
+);
+
+void GuiInspectorTypeSubSceneAssetId::consoleInit()
+{
+   Parent::consoleInit();
+
+   ConsoleBaseType::getType(TypeSubSceneAssetId)->setInspectorFieldType("GuiInspectorTypeSubSceneAssetId");
+}

+ 113 - 0
Engine/source/T3D/assets/SubSceneAsset.h

@@ -0,0 +1,113 @@
+#pragma once
+#ifndef SUBSCENE_ASSET_H
+#define SUBSCENE_ASSET_H
+
+#ifndef LEVEL_ASSET_H
+#include "LevelAsset.h"
+#endif
+
+#ifndef _ASSET_DEFINITION_H_
+#include "assets/assetDefinition.h"
+#endif
+
+#ifndef _GUI_INSPECTOR_TYPES_H_
+#include "gui/editor/guiInspectorTypes.h"
+#endif
+
+class SubSceneAsset : public LevelAsset
+{
+   typedef LevelAsset Parent;
+
+public:
+   SubSceneAsset();
+   virtual ~SubSceneAsset();
+
+   /// Engine.
+   static void initPersistFields();
+
+   /// Declare Console Object.
+   DECLARE_CONOBJECT(SubSceneAsset);
+};
+
+#ifdef TORQUE_TOOLS
+class GuiInspectorTypeSubSceneAssetPtr : public GuiInspectorTypeFileName
+{
+   typedef GuiInspectorTypeFileName Parent;
+public:
+
+   GuiBitmapButtonCtrl* mEditButton;
+
+   DECLARE_CONOBJECT(GuiInspectorTypeSubSceneAssetPtr);
+   static void consoleInit();
+
+   GuiControl* constructEditControl() override;
+   bool updateRects() override;
+};
+
+class GuiInspectorTypeSubSceneAssetId : public GuiInspectorTypeSubSceneAssetPtr
+{
+   typedef GuiInspectorTypeSubSceneAssetPtr Parent;
+public:
+
+   DECLARE_CONOBJECT(GuiInspectorTypeSubSceneAssetId);
+   static void consoleInit();
+};
+#endif
+
+DefineConsoleType(TypeSubSceneAssetPtr, SubSceneAsset)
+DefineConsoleType(TypeSubSceneAssetId, String)
+
+#pragma region Singular Asset Macros
+
+//Singular assets
+/// <Summary>
+/// Declares an SubScene asset
+/// This establishes the assetId, asset and legacy filepath fields, along with supplemental getter and setter functions
+/// </Summary>
+#define DECLARE_SUBSCENEASSET(className, name, changeFunc) public: \
+   StringTableEntry m##name##AssetId;\
+   AssetPtr<SubSceneAsset>  m##name##Asset;\
+public: \
+   const AssetPtr<SubSceneAsset> & get##name##Asset() const { return m##name##Asset; }\
+   void set##name##Asset(const AssetPtr<SubSceneAsset> &_in) { m##name##Asset = _in;}\
+   \
+   bool _set##name(StringTableEntry _in)\
+   {\
+      if(m##name##AssetId != _in)\
+      {\
+         if (m##name##Asset.notNull())\
+         {\
+            m##name##Asset->getChangedSignal().remove(this, &className::changeFunc);\
+         }\
+         if (_in == NULL || _in == StringTable->EmptyString())\
+         {\
+            m##name##AssetId = StringTable->EmptyString();\
+            m##name##Asset = NULL;\
+            return true;\
+         }\
+         if (AssetDatabase.isDeclaredAsset(_in))\
+         {\
+            m##name##AssetId = _in;\
+            m##name##Asset = _in;\
+            return true;\
+         }\
+      }\
+      \
+      if(get##name() == StringTable->EmptyString())\
+         return true;\
+      \
+      return false;\
+   }\
+   \
+   const StringTableEntry get##name() const\
+   {\
+      return m##name##AssetId;\
+   }\
+   bool name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); }
+
+#define INITPERSISTFIELD_SUBSCENEASSET(name, consoleClass, docs) \
+   addProtectedField(assetText(name, Asset), TypeSubSceneAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.));
+
+#pragma endregion
+
+#endif // SUBSCENE_ASSET_H

+ 47 - 0
Engine/source/assets/assetManager.cpp

@@ -1563,6 +1563,53 @@ bool AssetManager::restoreAssetTags( void )
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
+const char* AssetManager::getAssetLooseFiles(const char* pAssetId)
+{
+   // Debug Profiling.
+   PROFILE_SCOPE(AssetManager_getAssetLooseFIles);
+
+   // Sanity!
+   AssertFatal(pAssetId != NULL, "Cannot look up NULL asset Id.");
+
+   // Find asset.
+   AssetDefinition* pAssetDefinition = findAsset(pAssetId);
+
+   // Did we find the asset?
+   if (pAssetDefinition == NULL)
+   {
+      // No, so warn.
+      Con::warnf("Asset Manager: Failed to find asset Id '%s' as it does not exist.", pAssetId);
+      return String::EmptyString;
+   }
+
+   // Info.
+   if (mEchoInfo)
+   {
+      Con::printSeparator();
+      Con::printf("Asset Manager: Started getting loose files of Asset Id '%s'...", pAssetId);
+   }
+
+   String looseFileList = "";
+   Vector<StringTableEntry>& assetLooseFiles = pAssetDefinition->mAssetLooseFiles;
+   for (Vector<StringTableEntry>::iterator looseFileItr = assetLooseFiles.begin(); looseFileItr != assetLooseFiles.end(); ++looseFileItr)
+   {
+      // Fetch loose file.
+      StringTableEntry looseFile = *looseFileItr;
+
+      looseFileList += looseFile;
+
+      if (looseFileItr != assetLooseFiles.end())
+         looseFileList += "\t";
+   }
+
+   char* ret = Con::getReturnBuffer(1024);
+   dSprintf(ret, 1024, "%s", looseFileList.c_str());
+
+   return ret;
+}
+
+//-----------------------------------------------------------------------------
+
 S32 QSORT_CALLBACK descendingAssetDefinitionLoadCount(const void* a, const void* b)
 S32 QSORT_CALLBACK descendingAssetDefinitionLoadCount(const void* a, const void* b)
 {
 {
     // Debug Profiling.
     // Debug Profiling.

+ 3 - 0
Engine/source/assets/assetManager.h

@@ -341,6 +341,9 @@ public:
     bool restoreAssetTags( void );
     bool restoreAssetTags( void );
     inline AssetTagsManifest* getAssetTags( void ) const { return mAssetTagsManifest; }
     inline AssetTagsManifest* getAssetTags( void ) const { return mAssetTagsManifest; }
 
 
+    /// Loose File management
+    const char* getAssetLooseFiles(const char* pAssetId);
+
     /// Info.
     /// Info.
     inline U32 getDeclaredAssetCount( void ) const { return (U32)mDeclaredAssets.size(); }
     inline U32 getDeclaredAssetCount( void ) const { return (U32)mDeclaredAssets.size(); }
     inline U32 getReferencedAssetCount( void ) const { return (U32)mReferencedAssets.size(); }
     inline U32 getReferencedAssetCount( void ) const { return (U32)mReferencedAssets.size(); }

+ 14 - 0
Engine/source/assets/assetManager_ScriptBinding.h

@@ -432,6 +432,20 @@ DefineEngineMethod(AssetManager, getAssetTags, S32, (), ,
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
+DefineEngineMethod(AssetManager, getAssetLooseFiles, const char*, (const char* assetId), (""),
+   "Finds the specified asset Id and gets a list of its loose files.\n"
+   "@param assetId The selected asset Id.\n"
+   "@return A tab-delinated list of loose files associated to the assetId.\n")
+{
+   // Fetch asset Id.
+   const char* pAssetId = assetId;
+
+   // Delete asset.
+   return object->getAssetLooseFiles(pAssetId);
+}
+
+//-----------------------------------------------------------------------------
+
 DefineEngineMethod(AssetManager, findAllAssets, S32, (const char* assetQuery, bool ignoreInternal, bool ignorePrivate), ("", true, true),
 DefineEngineMethod(AssetManager, findAllAssets, S32, (const char* assetQuery, bool ignoreInternal, bool ignorePrivate), ("", true, true),
    "Performs an asset query searching for all assets optionally ignoring internal assets.\n"
    "Performs an asset query searching for all assets optionally ignoring internal assets.\n"
    "@param assetQuery The asset query object that will be populated with the results.\n"
    "@param assetQuery The asset query object that will be populated with the results.\n"

+ 6 - 27
Templates/BaseGame/game/tools/assetBrowser/main.tscript

@@ -27,30 +27,9 @@ function initializeAssetBrowser()
    $AssetBrowser::collectionSetsFile = "tools/assetBrowser/searchCollectionSets.xml";
    $AssetBrowser::collectionSetsFile = "tools/assetBrowser/searchCollectionSets.xml";
    $AssetBrowser::currentImportConfig = "";
    $AssetBrowser::currentImportConfig = "";
    
    
-   if(!isObject(AssetFilterTypeList))
-   {
-      new ArrayObject(AssetFilterTypeList);
+   if(!isObject(ABAssetTypesList))
+      new ArrayObject(ABAssetTypesList){};
 
 
-      AssetFilterTypeList.add("All");
-      AssetFilterTypeList.add("ComponentAsset");
-      AssetFilterTypeList.add("CppAsset");
-      AssetFilterTypeList.add("CubemapAsset");
-      AssetFilterTypeList.add("GameObjectAsset");
-      AssetFilterTypeList.add("GUIAsset");
-      AssetFilterTypeList.add("ImageAsset");
-      AssetFilterTypeList.add("LevelAsset");
-      AssetFilterTypeList.add("MaterialAsset");
-      AssetFilterTypeList.add("ParticleAsset");
-      AssetFilterTypeList.add("PostFXAsset");
-      AssetFilterTypeList.add("ScriptAsset");
-      AssetFilterTypeList.add("ShapeAsset");
-      AssetFilterTypeList.add("ShapeAnimationAsset");
-      AssetFilterTypeList.add("SoundAsset");
-      AssetFilterTypeList.add("StateMachineAsset");
-      AssetFilterTypeList.add("TerrainAsset");
-      AssetFilterTypeList.add("TerrainMaterialAsset");
-   }
-   
    exec("./scripts/profiles." @ $TorqueScriptFileExtension);
    exec("./scripts/profiles." @ $TorqueScriptFileExtension);
    
    
    exec("./guis/assetBrowser.gui");
    exec("./guis/assetBrowser.gui");
@@ -90,19 +69,19 @@ function initializeAssetBrowser()
    exec("./scripts/utils." @ $TorqueScriptFileExtension);
    exec("./scripts/utils." @ $TorqueScriptFileExtension);
    
    
    //Processing for the different asset types
    //Processing for the different asset types
-   exec("./scripts/assetTypes/component." @ $TorqueScriptFileExtension); 
+   exec("./scripts/assetTypes/genericAsset." @ $TorqueScriptFileExtension); 
+   
    exec("./scripts/assetTypes/cpp." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/cpp." @ $TorqueScriptFileExtension);
-   exec("./scripts/assetTypes/gameObject." @ $TorqueScriptFileExtension);   
    exec("./scripts/assetTypes/gui." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/gui." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/image." @ $TorqueScriptFileExtension);  
    exec("./scripts/assetTypes/image." @ $TorqueScriptFileExtension);  
    exec("./scripts/assetTypes/level." @ $TorqueScriptFileExtension); 
    exec("./scripts/assetTypes/level." @ $TorqueScriptFileExtension); 
+   exec("./scripts/assetTypes/subScene." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/material." @ $TorqueScriptFileExtension);   
    exec("./scripts/assetTypes/material." @ $TorqueScriptFileExtension);   
    exec("./scripts/assetTypes/postFX." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/postFX." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/script." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/script." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/shape." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/shape." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/shapeAnimation." @ $TorqueScriptFileExtension); 
    exec("./scripts/assetTypes/shapeAnimation." @ $TorqueScriptFileExtension); 
-   exec("./scripts/assetTypes/sound." @ $TorqueScriptFileExtension); 
-   exec("./scripts/assetTypes/stateMachine." @ $TorqueScriptFileExtension);   
+   exec("./scripts/assetTypes/sound." @ $TorqueScriptFileExtension);    
    exec("./scripts/assetTypes/cubemap." @ $TorqueScriptFileExtension);  
    exec("./scripts/assetTypes/cubemap." @ $TorqueScriptFileExtension);  
    exec("./scripts/assetTypes/folder." @ $TorqueScriptFileExtension);  
    exec("./scripts/assetTypes/folder." @ $TorqueScriptFileExtension);  
    exec("./scripts/assetTypes/terrain." @ $TorqueScriptFileExtension);
    exec("./scripts/assetTypes/terrain." @ $TorqueScriptFileExtension);

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 419 - 398
Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript


+ 0 - 86
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/assetTypeExample.tscript

@@ -1,86 +0,0 @@
-
-//Builds the preview data of the asset for the Asset Browser
-function AssetBrowser::build_AssetPreview(%this, %assetDef, %previewData)
-{
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = "";
-   %previewData.doubleClickCommand = "";
-   
-   %previewData.previewImage = "tools/assetBrowser/art/gameObjectIcon";
-   
-   %previewData.assetFriendlyName = %assetDef.gameObjectName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %assetDef.gameObjectName;
-}
-
-//Some last-step setup for the creation of the new asset before we do the actual making
-//This is generally intended to just set up any type-specific fields for creation
-function AssetBrowser::setupCreateNew_Asset(%this)
-{
-}
-
-//Performs the actual creation of the asset, including loose file copy or generation
-function AssetBrowser::create_Asset(%this)
-{
-}
-
-//This is a pre-process step to prepare the asset item for import
-function AssetBrowser::prepareImport_Asset(%this, %assetItem)
-{
-   
-}
-
-//Performs the action of actually importing the asset item
-function AssetBrowser::import_Asset(%this, %assetDef)
-{
-}
-
-//Editing the asset
-function AssetBrowser::edit_Asset(%this, %assetDef)
-{
-}
-
-//Duplicates the asset
-function AssetBrowser::duplicate_Asset(%this, %assetDef, %targetModule)
-{
-}
-
-//Renames the asset
-function AssetBrowser::rename_Asset(%this, %assetDef, %newAssetName)
-{
-}
-
-//Deletes the asset
-function AssetBrowser::delete_Asset(%this, %assetDef)
-{
-}
-
-//Moves the asset to a new path/module
-function AssetBrowser::move_Asset(%this, %assetDef, %destinationFolder)
-{
-}
-
-//Drag and drop action onto a GUI control
-function AssetBrowser::dragAndDrop_Asset(%this, %assetDef, %dropTarget)
-{
-   if(!isObject(%dropTarget))
-      return;
-}
-
-//Even for when 
-function AssetBrowser::on_AssetEditorDropped(%this, %assetDef, %position)
-{
-}
-
-//Clicking of the button for the asset type inspector field
-function GuiInspectorType_AssetPtr::onClick( %this, %fieldName )
-{
-   //Get our data
-   %obj = %this.getInspector().getInspectObject(0);
-}
-
-//Drag and droppin onto the asset type inspector field
-function GuiInspectorType_AssetPtr::onControlDropped( %this, %payload, %position )
-{
-   
-}

+ 0 - 143
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/component.tscript

@@ -1,143 +0,0 @@
-function AssetBrowser::createComponentAsset(%this)
-{
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
-   %modulePath = "data/" @ %moduleName;
-      
-   %assetName = AssetBrowser.newAssetSettings.assetName;
-   
-   %tamlpath = %modulePath @ "/components/" @ %assetName @ ".asset.taml";
-   %scriptPath = %modulePath @ "/components/" @ %assetName @ "." @ $TorqueScriptFileExtension;
-   
-   %asset = new ComponentAsset()
-   {
-      AssetName = %assetName;
-      versionId = 1;
-      componentName = %assetName;
-      componentClass = AssetBrowser.newAssetSettings.parentClass;
-      friendlyName = AssetBrowser.newAssetSettings.friendlyName;
-      componentType = AssetBrowser.newAssetSettings.componentGroup;
-      description = AssetBrowser.newAssetSettings.description;
-      scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
-   };
-   
-   TamlWrite(%asset, %tamlpath);
-   
-   %file = new FileObject();
-	%templateFile = new FileObject();
-	
-   %templateCodeFilePath = %this.templateFilesPath @ "componentFile." @ $TorqueScriptFileExtension @ ".template";
-   
-   if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%templateCodeFilePath))
-   {
-      while( !%templateFile.isEOF() )
-      {
-         %line = %templateFile.readline();
-         %line = strreplace( %line, "@@", %assetName );
-         
-         %file.writeline(%line);
-         echo(%line);
-      }
-      
-      %file.close();
-      %templateFile.close();
-   }
-   else
-   {
-      %file.close();
-      %templateFile.close();
-      
-      warnf("CreateComponentAsset - Something went wrong and we couldn't write the Component script file!");
-   }
-	
-	Canvas.popDialog(AssetBrowser_newComponentAsset);
-	
-	%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
-	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
-
-	AssetBrowser.refresh();
-	
-	return %tamlpath;
-}
-
-function AssetBrowser::editComponentAsset(%this, %assetDef)
-{
-   %scriptFile = %assetDef.scriptFile;
-   
-   EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);
-}
-
-function AssetBrowser::duplicateComponentAsset(%this, %assetId)
-{
-   
-}
-
-function AssetBrowser::renameComponentAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
-{
-   %assetPath = AssetDatabase.getAssetFilePath(%newAssetId);
-   
-   //rename the file to match
-   %path = filePath(%assetPath);
-         
-   %oldScriptFilePath = %assetDef.scriptFile;
-   %scriptFilePath = filePath(%assetDef.scriptFile);
-   %scriptExt = fileExt(%assetDef.scriptFile);
-   
-   %newScriptFileName = %scriptFilePath @ "/" @ %newName @ %scriptExt;
-   %newAssetFile = %path @ "/" @ %newName @ ".asset.taml";
-   
-   %assetDef.componentName = %newName;
-   %assetDef.scriptFile = %newScriptFileName;
-   
-   TamlWrite(%assetDef, %newAssetFile);
-   fileDelete(%assetPath);
-   
-   pathCopy(%oldScriptFilePath, %newScriptFileName);
-   fileDelete(%oldScriptFilePath);
-   
-   //Go through our scriptfile and replace the old namespace with the new
-   %editedFileContents = "";
-   
-   %file = new FileObject();
-   if ( %file.openForRead( %newScriptFileName ) ) 
-   {
-      while ( !%file.isEOF() ) 
-      {
-         %line = %file.readLine();
-         %line = trim( %line );
-         
-         %editedFileContents = %editedFileContents @ strreplace(%line, %originalName, %newName) @ "\n";
-      }
-      
-      %file.close();
-   }
-   
-   if(%editedFileContents !$= "")
-   {
-      %file.openForWrite(%newScriptFileName);
-      
-      %file.writeline(%editedFileContents);
-      
-      %file.close();
-   }
-   
-   exec(%newScriptFileName);   
-}
-
-//not used
-function AssetBrowser::importComponentAsset(%this, %assetId)
-{
-   
-}
-
-function AssetBrowser::buildComponentAssetPreview(%this, %assetDef, %previewData)
-{
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.scriptFile;
-   %previewData.doubleClickCommand = "EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
-   
-   %previewData.previewImage = "ToolsModule:componentIcon_image";
-   
-   %previewData.assetFriendlyName = %assetDef.friendlyName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %assetDef.friendlyName @ "\n" @ %assetDef;
-}

+ 126 - 74
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cpp.tscript

@@ -1,44 +1,21 @@
-function AssetBrowser::buildCppPreview(%this, %assetDef, %previewData)
-{
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.codeFilePath;
-   %previewData.doubleClickCommand = "echo(\"Not yet implemented to edit C++ files from the editor\");";//"EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
-   
-   %previewData.previewImage = "ToolsModule:cppIcon_image";
-   
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %assetDef.assetName;
-}
-
-function AssetBrowser::buildCppAssetPreview(%this, %assetDef, %previewData)
-{
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.codeFilePath;
-   %previewData.doubleClickCommand = "echo(\"Not yet implemented to edit C++ files from the editor\");";//"EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
-   
-   %previewData.previewImage = "ToolsModule:cppIcon_image";
-   
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %assetDef.assetName;
-}
+AssetBrowser::registerAssetType("CppAsset", "C++ Assets", "");
+AssetBrowser::registerFileType("CPPFileType", "C++ Files", ".cpp;.h;.c", false);
 
 
-function AssetBrowser::createCppAsset(%this)
+function CppAsset::onCreateNew()
 {
 {
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
+   %moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
    %modulePath = "data/" @ %moduleName;
    %modulePath = "data/" @ %moduleName;
       
       
-   %assetName = AssetBrowser.newAssetSettings.assetName;  
+   %assetName = $CurrentAssetBrowser.newAssetSettings.assetName;  
    
    
    %assetPath = NewAssetTargetAddress.getText() @ "/";     
    %assetPath = NewAssetTargetAddress.getText() @ "/";     
    
    
-   //%tamlpath = %assetPath @ %assetName @ ".asset.taml";
+   %tamlpath = %assetPath @ %assetName @ ".asset.taml";
    %codePath = %assetPath @ %assetName @ ".cpp";
    %codePath = %assetPath @ %assetName @ ".cpp";
    %headerPath = %assetPath @ %assetName @ ".h";
    %headerPath = %assetPath @ %assetName @ ".h";
    
    
    //Do the work here
    //Do the work here
-   /*%assetType = AssetBrowser.newAssetSettings.assetType;
+   //%assetType = $CurrentAssetBrowser.newAssetSettings.assetType;
    
    
    %asset = new CppAsset()
    %asset = new CppAsset()
    {
    {
@@ -48,7 +25,7 @@ function AssetBrowser::createCppAsset(%this)
       headerFile = %headerPath;
       headerFile = %headerPath;
    };
    };
    
    
-   TamlWrite(%asset, %tamlpath);*/
+   TamlWrite(%asset, %tamlpath);
    
    
    %tamlpath = %assetPath @ %assetName @ ".asset.taml";
    %tamlpath = %assetPath @ %assetName @ ".asset.taml";
 
 
@@ -67,28 +44,28 @@ function AssetBrowser::createCppAsset(%this)
 	
 	
 	if($AssetBrowser::newAssetTypeOverride $= "StaticClass")
 	if($AssetBrowser::newAssetTypeOverride $= "StaticClass")
 	{
 	{
-	   %cppTemplateCodeFilePath = %this.templateFilesPath @ "CppStaticClassFile.cpp.template";
-	   %cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppStaticClassFile.h.template";
+	   %cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppStaticClassFile.cpp.template";
+	   %cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppStaticClassFile.h.template";
 	}
 	}
 	else if($AssetBrowser::newAssetTypeOverride $= "ScriptClass")
 	else if($AssetBrowser::newAssetTypeOverride $= "ScriptClass")
 	{
 	{
-	   %cppTemplateCodeFilePath = %this.templateFilesPath @ "CppScriptClassFile.cpp.template";
-	   %cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppScriptClassFile.h.template";
+	   %cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppScriptClassFile.cpp.template";
+	   %cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppScriptClassFile.h.template";
 	}
 	}
 	else if($AssetBrowser::newAssetTypeOverride $= "AssetTypeCppClass")
 	else if($AssetBrowser::newAssetTypeOverride $= "AssetTypeCppClass")
 	{
 	{
-	   %cppTemplateCodeFilePath = %this.templateFilesPath @ "CppAssetTypeClassFile.cpp.template";
-	   %cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppAssetTypeClassFile.h.template";
+	   %cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppAssetTypeClassFile.cpp.template";
+	   %cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppAssetTypeClassFile.h.template";
 	}
 	}
 	else if($AssetBrowser::newAssetTypeOverride $= "RenderCppClass")
 	else if($AssetBrowser::newAssetTypeOverride $= "RenderCppClass")
 	{
 	{
-	   %cppTemplateCodeFilePath = %this.templateFilesPath @ "CppRenderClassFile.cpp.template";
-	   %cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppRenderClassFile.h.template";
+	   %cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppRenderClassFile.cpp.template";
+	   %cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppRenderClassFile.h.template";
 	}
 	}
 	else if($AssetBrowser::newAssetTypeOverride $= "SceneObjectCppClass")
 	else if($AssetBrowser::newAssetTypeOverride $= "SceneObjectCppClass")
 	{
 	{
-	   %cppTemplateCodeFilePath = %this.templateFilesPath @ "CppSceneObjectClassFile.cpp.template";
-	   %cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppSceneObjectClassFile.h.template";
+	   %cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppSceneObjectClassFile.cpp.template";
+	   %cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppSceneObjectClassFile.h.template";
 	}
 	}
 	
 	
 	$AssetBrowser::newAssetTypeOverride = "";
 	$AssetBrowser::newAssetTypeOverride = "";
@@ -101,7 +78,6 @@ function AssetBrowser::createCppAsset(%this)
          %line = strreplace( %line, "@", %assetName );
          %line = strreplace( %line, "@", %assetName );
          
          
          %file.writeline(%line);
          %file.writeline(%line);
-         //echo(%line);
       }
       }
       
       
       %file.close();
       %file.close();
@@ -134,7 +110,7 @@ function AssetBrowser::createCppAsset(%this)
       %file.close();
       %file.close();
       %templateFile.close();
       %templateFile.close();
       
       
-      warnf("CreateNewCppAsset - Something went wrong and we couldn't write the C++ header file!");
+      warn("CreateNewCppAsset - Something went wrong and we couldn't write the C++ header file!");
    }
    }
 	
 	
 	//Last, check that we have a C++ Module definition. If not, make one so anything important can be initialized on startup there
 	//Last, check that we have a C++ Module definition. If not, make one so anything important can be initialized on startup there
@@ -144,7 +120,7 @@ function AssetBrowser::createCppAsset(%this)
 	   %file = new FileObject();
 	   %file = new FileObject();
 	   %templateFile = new FileObject();
 	   %templateFile = new FileObject();
    
    
-      if(%file.openForWrite(%cppModuleFilePath) && %templateFile.openForRead(%this.templateFilesPath @ "CppModuleFile.cpp"))
+      if(%file.openForWrite(%cppModuleFilePath) && %templateFile.openForRead($CurrentAssetBrowser.templateFilesPath @ "CppModuleFile.cpp"))
       {
       {
          while( !%templateFile.isEOF() )
          while( !%templateFile.isEOF() )
          {
          {
@@ -163,57 +139,133 @@ function AssetBrowser::createCppAsset(%this)
          %file.close();
          %file.close();
          %templateFile.close();
          %templateFile.close();
          
          
-         warnf("CreateNewCppAsset - Something went wrong and we couldn't write the C++ module file!");
+         warn("CreateNewCppAsset - Something went wrong and we couldn't write the C++ module file!");
       }
       }
 	}
 	}
    
    
 	return "";
 	return "";
 }
 }
 
 
-function AssetBrowser::editCppAsset(%this, %assetDef)
+function CppAsset::buildBrowserElement(%this, %previewData)
+{
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.codeFilePath;
+   //%previewData.doubleClickCommand = "echo(\"Not yet implemented to edit C++ files from the editor\");";//"EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
+   
+   %previewData.previewImage = "ToolsModule:cppIcon_image";
+   
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = %this.assetName;
+}
+
+function CppAsset::onEditCodeFile(%this, %filePath)
+{
+   if(isFunction("systemCommand"))
+      eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getCodeFile() @ "\\\"\");");
+   else  
+      warn("CppAsset::onEditCodeFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
+}
+
+function CppAsset::onEditHeaderFile(%this, %filePath)
 {
 {
+   if(isFunction("systemCommand"))
+      eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getHeaderFile() @ "\\\"\");");
+   else  
+      warn("CppAsset::onEditHeaderFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
 }
 }
 
 
-//Renames the asset
-function AssetBrowser::renameCppAsset(%this, %assetDef, %newAssetName)
+function CppAsset::onShowActionMenu(%this)
 {
 {
-   %newCodeLooseFilename = renameAssetLooseFile(%assetDef.codefile, %newAssetName);
+   GenericAsset::onShowActionMenu(%this);
    
    
-   if(!%newCodeLooseFilename $= "")
-      return;
-      
-   %newHeaderLooseFilename = renameAssetLooseFile(%assetDef.headerFile, %newAssetName);
+   if( !isObject( EditCPPFilesSubmenuPopup ) )
+   {
+      new PopupMenu( EditCPPFilesSubmenuPopup )
+      {
+         superClass = "MenuBuilder";
+         class = "EditorWorldMenu";
+
+         jumpFileName = "";
+         jumpLineNumber = "";
+      };
+   }
    
    
-   if(!%newHeaderLooseFilename $= "")
-      return;
-      
-   %assetDef.codefile = %newCodeLooseFilename;
-   %assetDef.headerFile = %newHeaderLooseFilename;
-   %assetDef.saveAsset();
+   //Regen the menu so we're fully up and current with options and references
+   EditCPPFilesSubmenuPopup.clearItems();
+   
+   EditCPPFilesSubmenuPopup.item[ 0 ] = "Code file" TAB "" TAB %this @ ".onEditCodeFile();";
+   EditCPPFilesSubmenuPopup.item[ 1 ] = "Header file" TAB "" TAB %this @ ".onEditHeaderFile();";
+
+   EditCPPFilesSubmenuPopup.reloadItems();
    
    
-   renameAssetFile(%assetDef, %newAssetName);
+   EditAssetPopup.item[ 0 ] = "Edit C++ Files" TAB EditCPPFilesSubmenuPopup;
+   
+   EditAssetPopup.reloadItems();
+   
+   EditAssetPopup.showPopup(Canvas); 
+   
+   $CurrentAssetBrowser.popupMenu = EditAssetPopup;
+}
+//==============================================================================
+function CPPFileType::buildBrowserElement(%filePath, %previewData)
+{
+   %previewData.assetName = fileName(%filePath);
+   %previewData.assetPath = %filePath;
+   //%previewData.doubleClickCommand = "echo(\"Not yet implemented to edit C++ files from the editor\");";//"EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
+   
+   %previewData.previewImage = "ToolsModule:cppIcon_image";
+   
+   %previewData.assetFriendlyName = %previewData.assetName;
+   %previewData.assetDesc = %filePath;
+   %previewData.tooltip = %filePath;
 }
 }
 
 
-//Deletes the asset
-function AssetBrowser::deleteCppAsset(%this, %assetDef)
+function CPPFileType::onEdit(%filePath)
 {
 {
-   AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
+   if(isFunction("systemCommand"))
+      eval("systemCommand(\"start \\\"\\\" \\\"" @ %filePath @ "\\\"\");");
+   else  
+      warn("CPPFileType::onEdit() - systemCommand function disabled in this build. Unable to launch application to edit file.");
 }
 }
 
 
-//Moves the asset to a new path/module
-function AssetBrowser::moveCppAsset(%this, %assetDef, %destination)
+function CPPFileType::onShowActionMenu(%filePath)
 {
 {
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
+   if( !isObject( EditCPPFileTypePopup ) )
+   {
+      new PopupMenu( EditCPPFileTypePopup )
+      {
+         superClass = "MenuBuilder";
+         class = "EditorWorldMenu";
+
+         jumpFileName = "";
+         jumpLineNumber = "";
+      };
+   }
    
    
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
+   //Regen the menu so we're fully up and current with options and references
+   EditCPPFileTypePopup.clearItems();
    
    
-   if(%newAssetPath $= "")
-      return false;
+   EditCPPFileTypePopup.item[ 0 ] = "Edit C++ File" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();";
+   EditCPPFileTypePopup.item[ 1 ] = "Rename File" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();";
+   EditCPPFileTypePopup.item[ 2 ] = "-";
+   EditCPPFileTypePopup.item[ 3 ] = "Duplicate File" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();";
+   EditCPPFileTypePopup.item[ 4 ] = "-";
+   EditCPPFileTypePopup.item[ 5 ] = "Open File Location" TAB "" TAB $CurrentAssetBrowser @ ".openFileLocation();";
+   EditCPPFileTypePopup.item[ 6 ] = "-";
+   EditCPPFileTypePopup.item[ 7 ] = "Delete File" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();";
 
 
-   moveAssetLooseFile(%assetDef.codeFile, %destination);
-   moveAssetLooseFile(%assetDef.headerFile, %destination);
+   EditCPPFileTypePopup.objectData = %filePath;
+   EditCPPFileTypePopup.objectType = "CPPFileType";
    
    
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
+   EditCPPFileTypePopup.reloadItems();
+   
+   EditCPPFileTypePopup.showPopup(Canvas); 
+   
+   $CurrentAssetBrowser.popupMenu = EditCPPFileTypePopup;
 }
 }
+
+function CPPFileType::onEditProperties(%this, %inspector)
+{
+   
+}

+ 7 - 49
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cubemap.tscript

@@ -1,9 +1,11 @@
-function AssetBrowser::createCubemapAsset(%this)
+AssetBrowser::registerAssetType("CubemapAsset", "Cubemaps");
+
+function CubemapAsset::onCreateNew()
 {
 {
    Canvas.pushDialog(CubemapEditor);
    Canvas.pushDialog(CubemapEditor);
    return;
    return;
    
    
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
+   /*%moduleName = AssetBrowser.newAssetSettings.moduleName;
    %modulePath = "data/" @ %moduleName;
    %modulePath = "data/" @ %moduleName;
       
       
    %assetName = AssetBrowser.newAssetSettings.assetName;
    %assetName = AssetBrowser.newAssetSettings.assetName;
@@ -30,57 +32,13 @@ function AssetBrowser::createCubemapAsset(%this)
 
 
 	AssetBrowser.refresh();
 	AssetBrowser.refresh();
 	
 	
-	return %tamlpath;
+	return %tamlpath;*/
 }
 }
 
 
-function AssetBrowser::editCubemapAsset(%this, %assetDef)
+function CubemapAsset::onEdit(%this)
 {
 {
    %this.hideDialog();
    %this.hideDialog();
-   CubemapEditor.openCubemapAsset(%assetDef);    
-}
-
-//Renames the asset
-function AssetBrowser::renameCubemapAsset(%this, %assetDef, %newAssetName)
-{
-   /*%newCodeLooseFilename = renameAssetLooseFile(%assetDef.codefile, %newAssetName);
-   
-   if(!%newCodeLooseFilename $= "")
-      return;
-      
-   %newHeaderLooseFilename = renameAssetLooseFile(%assetDef.headerFile, %newAssetName);
-   
-   if(!%newHeaderLooseFilename $= "")
-      return;
-      
-   %assetDef.codefile = %newCodeLooseFilename;
-   %assetDef.headerFile = %newHeaderLooseFilename;
-   %assetDef.saveAsset();
-   
-   renameAssetFile(%assetDef, %newAssetName);*/
-}
-
-//Deletes the asset
-function AssetBrowser::deleteCubemapAsset(%this, %assetDef)
-{
-   AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
-}
-
-//Moves the asset to a new path/module
-function AssetBrowser::moveCubemapAsset(%this, %assetDef, %destination)
-{
-   /*%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.codeFile, %destination);
-   moveAssetLooseFile(%assetDef.headerFile, %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);*/
+   CubemapEditor.openCubemapAsset(%this);    
 }
 }
 
 
 function GuiInspectorTypeCubemapAssetPtr::onControlDropped( %this, %payload, %position )
 function GuiInspectorTypeCubemapAssetPtr::onControlDropped( %this, %payload, %position )

+ 50 - 148
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/datablockObjects.tscript

@@ -1,54 +1,29 @@
-function AssetBrowser::createNewDatablock(%this)
-{
-   AssetBrowser_newFolderNameTxt.text = "NewFolder";
-   Canvas.pushDialog(AssetBrowser_newFolder);
-}
+AssetBrowser::registerObjectType("DatablockObjectType", "Datablock Objects", "GameBaseData");
 
 
-function AssetBrowser::doCreateNewDatablock(%this)
+function DatablockObjectType::onEdit(%this, %className)
 {
 {
-   %newFolderName = AssetBrowser_newFolderNameTxt.getText();
-   
-   if(%newFolderName $= "")
-      %newFolderName = "NewFolder";
-      
-   %newFolderIdx = "";
-   %matched = true;
-   %newFolderPath = "";
-   while(%matched == true)
+   if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
    {
    {
-      %newFolderPath = AssetBrowser.dirHandler.currentAddress @ "/" @ %newFolderName @ %newFolderIdx;
-      if(!isDirectory(%newFolderPath))
-      {
-         %matched = false;
-      }
-      else
-      {
-         %newFolderIdx++;         
-      }
-   }
-   
-   //make a dummy file
-   %file = new FileObject();
-   %file.openForWrite(%newFolderPath @ "/test");
-   %file.close();
-   
-   fileDelete(%newFolderPath @ "/test");
+      $CurrentAssetBrowser.hideDialog();
    
    
-   //refresh the directory
-   AssetBrowser.loadDirectories();
-   
-   %this.navigateTo(%newFolderPath);
+      DatablockEditorPlugin.openDatablock(%this);
+   }
+   else
+   {
+      %this.onWorldEditorDropped();
+   } 
 }
 }
 
 
-function AssetBrowser::buildDatablockPreview(%this, %assetDef, %previewData)
+function DatablockObjectType::buildBrowserElement(%this, %className, %previewData)
 {
 {
-   %previewData.assetName = %assetDef;
-   %previewData.assetPath = "";
+   echo("DatablockObjectType::buildBrowserElement() - " @ %this @ ", " @ %previewData);
+   %previewData.assetName = %this.getName();
+   %previewData.assetPath = %this.getFileName();
    
    
    %previewData.previewImage = "ToolsModule:datablockIcon_image";
    %previewData.previewImage = "ToolsModule:datablockIcon_image";
    
    
    //Lets see if we have a icon for specifically for this datablock type
    //Lets see if we have a icon for specifically for this datablock type
-   %dataClass = %assetDef.getClassName();
+   %dataClass = %this.getClassName();
    %dataClass = strreplace(%dataClass, "Data", "");
    %dataClass = strreplace(%dataClass, "Data", "");
    
    
    %previewImage = "tools/classIcons/" @ %dataClass @ ".png";
    %previewImage = "tools/classIcons/" @ %dataClass @ ".png";
@@ -58,130 +33,57 @@ function AssetBrowser::buildDatablockPreview(%this, %assetDef, %previewData)
    }
    }
    
    
    //%previewData.assetFriendlyName = %assetDef.assetName;
    //%previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef;
-   %previewData.tooltip =  "\nDatablock Name: " @ %assetDef @ 
-                           "\nDatablock Type: " @ %assetDef.getClassName() @
-                           "\nDefinition Path: " @ %assetDef.getFilename();
+   %previewData.assetDesc = %this;
+   %previewData.tooltip =  "\nDatablock Name: " @ %previewData.assetName @ 
+                           "\nDatablock Type: " @ %dataClass @
+                           "\nDefinition Path: " @ %previewData.assetPath;
                            
                            
-   
-   if(%this.selectMode)
-   {
-      %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
-   }
-   else
-   {
-      if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
-      {
-         %previewData.doubleClickCommand = "DatablockEditorPlugin.openDatablock( "@%assetDef@" );";
-      }
-      else
-      {
-         %previewData.doubleClickCommand = "AssetBrowser.onDatablockEditorDropped( "@%assetDef@" );";
-      }
-   }
 }
 }
 
 
-function spawnDatablockObject(%datablock)
+function DatablockObjectType::onShowActionMenu(%this, %className)
 {
 {
-   %name = %datablock.getName();
-   %class = %datablock.getClassName();
-   %cmd = %class @ "::create(" @ %name @ ");";
-   
-   %shapePath = ( %datablock.shapeAsset !$= "" ) ? %datablock.shapeFile : %datablock.shapeName;
-   %createCmd = "ObjectCreator.createObject( \"" @ %cmd @ "\" );";
-   return eval(%createCmd);//eval("showImportDialog( \"" @ %shapePath @ "\", \"" @ %createCmd @ "\" );");
-}
+   if( !isObject( EditDatablockObjectTypePopup ) )
+   {
+      new PopupMenu( EditDatablockObjectTypePopup )
+      {
+         superClass = "MenuBuilder";
+         class = "EditorWorldMenu";
 
 
-function AssetBrowser::renameDatablock(%this, %folderPath, %newFolderName)
-{
-   %fullPath = makeFullPath(%folderPath);
-   %newFullPath = makeFullPath(%folderPath);
-   
-   %fullPath = strreplace(%fullPath, "//", "/");
-   
-   %count = getTokenCount(%fullPath, "/");
-   %basePath = getTokens(%fullPath, "/", 0, %count-2);
-   %oldName = getToken(%fullPath, "/", %count-1);
-   
-   //We need to ensure that no files are 'active' while we try and clean up behind ourselves with the delete action
-   //so, we nix any assets active for the module, do the delete action on the old folder, and then re-acquire our assets.
-   //This will have the added benefit of updating paths for asset items
-   
-   %module = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress);
-   %moduleId = %module.ModuleId;
-   
-   AssetDatabase.removeDeclaredAssets(%moduleId);
+         jumpFileName = "";
+         jumpLineNumber = "";
+      };
+   }
    
    
-   %copiedSuccess = %this.dirHandler.copyDatablock(%fullPath, %basePath @ "/" @ %newFolderName);
-   %this.dirHandler.deleteDatablock(%fullPath);
+   EditDatablockObjectTypePopup.objectData = %this;
+   EditDatablockObjectTypePopup.objectType = "DatablockObjectType";
    
    
-   %this.loadDirectories();
+   //Regen the menu so we're fully up and current with options and references
+   EditDatablockObjectTypePopup.clearItems();
    
    
-   AssetDatabase.addModuleDeclaredAssets(%moduleId);
-}
+   EditDatablockObjectTypePopup.item[ 0 ] = "Edit Datablock" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();";
+   EditDatablockObjectTypePopup.item[ 1 ] = "-";
+   EditDatablockObjectTypePopup.item[ 2 ] = "Open Datablock Location" TAB "" TAB $CurrentAssetBrowser @ ".openFolderLocation(" @ %this.getFilename() @ ");";
 
 
-function AssetBrowser::moveDatablock(%this, %folderPath, %newFolderPath)
-{
-   %fullPath = makeFullPath(%folderPath);
-   %newFullPath = makeFullPath(%newFolderPath);
+   EditDatablockObjectTypePopup.reloadItems();
    
    
-   %fullPath = strreplace(%fullPath, "//", "/");
-   %newFullPath = strreplace(%newFullPath, "//", "/");
+   EditDatablockObjectTypePopup.showPopup(Canvas); 
    
    
-   %count = getTokenCount(%fullPath, "/");
-   %basePath = getTokens(%fullPath, "/", 0, %count-2);
-   %oldName = getToken(%fullPath, "/", %count-1);
-   
-   %copiedSuccess = %this.dirHandler.copyDatablock(%fullPath, %newFullPath);
-   %this.dirHandler.deleteDatablock(%fullPath);
-   
-   %this.loadDirectories();
-   
-   //thrash the modules and reload them
-   %oldModule = %this.dirHandler.getModuleFromAddress(%folderPath);
-   %newModule = %this.dirHandler.getModuleFromAddress(%newFolderPath);
-   
-   //if we didn't move modules, then we don't need to do anything other than refresh the assets within it
-   if(%oldModule == %newModule)
-   {
-      //only do a refresh to update asset loose file paths
-      AssetDatabase.refreshAllAssets();
-   }
-   else
-   {
-      //they're different moduels now, so we gotta unload/reload both
-      ModuleDatabase.unloadExplicit(%oldModule.getModuleId());
-      ModuleDatabase.loadExplicit(%oldModule.getModuleId());
-      
-      ModuleDatabase.unloadExplicit(%newModule.getModuleId());
-      ModuleDatabase.loadExplicit(%newModule.getModuleId());
-   }
+   $CurrentAssetBrowser.popupMenu = EditDatablockObjectTypePopup;
 }
 }
 
 
-function AssetBrowser::deleteDatablock(%this, %folderPath)
+function spawnDatablockObject(%datablock)
 {
 {
-   %this.dirHandler.deleteDatablock(%folderPath);
+   %name = %datablock.getName();
+   %class = %datablock.getClassName();
+   %cmd = %class @ "::create(" @ %name @ ");";
    
    
-   %this.refresh();
+   %shapePath = ( %datablock.shapeAsset !$= "" ) ? %datablock.shapeFile : %datablock.shapeName;
+   %createCmd = "ObjectCreator.createObject( \"" @ %cmd @ "\" );";
+   return eval(%createCmd);//eval("showImportDialog( \"" @ %shapePath @ "\", \"" @ %createCmd @ "\" );");
 }
 }
 
 
-function AssetBrowser::onDatablockEditorDropped(%this, %assetDef, %position)
+function DatablockObjectType::onWorldEditorDropped(%this, %position)
 {
 {
-   %targetPosition = EWorldEditor.unproject(%position SPC 1);
-   %camPos = LocalClientConnection.camera.getPosition();
-   %rayResult = containerRayCast(%camPos, %targetPosition, -1);
-   
-   %pos = ObjectCreator.getCreateObjectPosition();
-
-   if(%rayResult != 0)
-   {
-      %pos = getWords(%rayResult, 1, 3);
-   }
-   else
-   {
-      %pos = "0 0 0";  
-   }
-   
-   %newObj = spawnDatablockObject(%assetDef);
-   %newObj.position = %pos;
+   %newObj = spawnDatablockObject(%this);
+   %newObj.position = %position;
 }
 }

+ 0 - 0
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/decal.tscript


+ 0 - 0
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/explosion.tscript


+ 86 - 32
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/folder.tscript

@@ -1,4 +1,6 @@
-function AssetBrowser::createNewFolder(%this)
+AssetBrowser::registerFileType("FolderObjectType", "Folder", "/", false);
+
+function FolderObjectType::setupCreateNew()
 {
 {
    AssetBrowser_newFolderNameTxt.text = "NewFolder";
    AssetBrowser_newFolderNameTxt.text = "NewFolder";
    Canvas.pushDialog(AssetBrowser_newFolder, 99, true);
    Canvas.pushDialog(AssetBrowser_newFolder, 99, true);
@@ -6,7 +8,7 @@ function AssetBrowser::createNewFolder(%this)
    AssetBrowser_newFolderNameTxt.selectAllText();
    AssetBrowser_newFolderNameTxt.selectAllText();
 }
 }
 
 
-function AssetBrowser::doCreateNewFolder(%this)
+function FolderObjectType::onCreateNew()
 {
 {
    %newFolderName = AssetBrowser_newFolderNameTxt.getText();
    %newFolderName = AssetBrowser_newFolderNameTxt.getText();
    
    
@@ -19,7 +21,7 @@ function AssetBrowser::doCreateNewFolder(%this)
    }
    }
    else
    else
    {
    {
-      %currentAddressPath = AssetBrowser.dirHandler.currentAddress;
+      %currentAddressPath = $CurrentAssetBrowser.dirHandler.currentAddress;
    }
    }
       
       
    %newFolderIdx = "";
    %newFolderIdx = "";
@@ -46,29 +48,65 @@ function AssetBrowser::doCreateNewFolder(%this)
    fileDelete(%newFolderPath @ "/test");
    fileDelete(%newFolderPath @ "/test");
    
    
    //refresh the directory
    //refresh the directory
-   AssetBrowser.loadDirectories();
+   $CurrentAssetBrowser.loadDirectories();
    
    
-   %this.navigateTo(%newFolderPath);
+   $CurrentAssetBrowser.navigateTo(%newFolderPath);
    
    
    //On the off chance we're trying to select a path, we'll update the select path window too
    //On the off chance we're trying to select a path, we'll update the select path window too
    if(SelectAssetPath.isAwake())
    if(SelectAssetPath.isAwake())
       SelectAssetPath.showDialog(%newFolderPath, SelectAssetPath.callback);
       SelectAssetPath.showDialog(%newFolderPath, SelectAssetPath.callback);
 }
 }
 
 
-function AssetBrowser::buildFolderPreview(%this, %assetDef, %previewData)
+function FolderObjectType::buildBrowserElement(%folderPath, %previewData)
 {
 {
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.dirPath;
+   %folderName = fileBase(%folderPath);
+   
+   %previewData.assetName = %folderName;
+   %previewData.assetPath = %folderPath;
    
    
    %previewData.previewImage = "ToolsModule:FolderIcon_image";
    %previewData.previewImage = "ToolsModule:FolderIcon_image";
    
    
    //%previewData.assetFriendlyName = %assetDef.assetName;
    //%previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %assetDef.dirPath;
-   %previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
+   %previewData.assetDesc = "Folder";
+   %previewData.tooltip = %folderPath;
+   %previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %folderPath @"\");"; //browseTo %this.dirPath / %this.assetName
+}
+
+function FolderObjectType::onShowActionMenu(%folderPath)
+{
+   if( !isObject( EditFolderTypePopup ) )
+   {
+      new PopupMenu( EditFolderTypePopup )
+      {
+         superClass = "MenuBuilder";
+         class = "EditorWorldMenu";
+
+         jumpFileName = "";
+         jumpLineNumber = "";
+      };
+   }
+   
+   EditFolderTypePopup.objectData = %folderPath;
+   EditFolderTypePopup.objectType = "FolderObjectType";
+   
+   //Regen the menu so we're fully up and current with options and references
+   EditFolderTypePopup.clearItems();
+   
+   EditFolderTypePopup.item[ 0 ] = "Rename Folder" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();";
+   EditFolderTypePopup.item[ 1 ] = "Duplicate Folder" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();";
+   EditFolderTypePopup.item[ 2 ] = "-";
+   EditFolderTypePopup.item[ 3 ] = "Open Folder Location" TAB "" TAB $CurrentAssetBrowser @ ".openFolderLocation(" @ %folderPath @ ");";
+   EditFolderTypePopup.item[ 4 ] = "-";
+   EditFolderTypePopup.item[ 5 ] = "Delete Folder" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();";
+
+   EditFolderTypePopup.reloadItems();
+   
+   EditFolderTypePopup.showPopup(Canvas); 
+   
+   $CurrentAssetBrowser.popupMenu = EditFolderTypePopup;
 }
 }
 
 
-function AssetBrowser::renameFolder(%this, %folderPath, %newFolderName)
+function FolderObjectType::onRename(%folderPath, %newFolderName)
 {
 {
    %fullPath = makeFullPath(%folderPath);
    %fullPath = makeFullPath(%folderPath);
    %newFullPath = makeFullPath(%folderPath);
    %newFullPath = makeFullPath(%folderPath);
@@ -83,23 +121,40 @@ function AssetBrowser::renameFolder(%this, %folderPath, %newFolderName)
    //so, we nix any assets active for the module, do the delete action on the old folder, and then re-acquire our assets.
    //so, we nix any assets active for the module, do the delete action on the old folder, and then re-acquire our assets.
    //This will have the added benefit of updating paths for asset items
    //This will have the added benefit of updating paths for asset items
    
    
-   %module = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress);
+   %module = $CurrentAssetBrowser.dirHandler.getModuleFromAddress($CurrentAssetBrowser.dirHandler.currentAddress);
    %moduleId = %module.ModuleId;
    %moduleId = %module.ModuleId;
    
    
-   AssetDatabase.removeDeclaredAssets(%moduleId);
+   $CurrentAssetBrowser.removeDeclaredAssets(%moduleId);
+   
+   %copiedSuccess = $CurrentAssetBrowser.dirHandler.copyFolder(%fullPath, %basePath @ "/" @ %newFolderName);
+   $CurrentAssetBrowser.dirHandler.deleteFolder(%fullPath);
    
    
-   %copiedSuccess = %this.dirHandler.copyFolder(%fullPath, %basePath @ "/" @ %newFolderName);
-   %this.dirHandler.deleteFolder(%fullPath);
+   $CurrentAssetBrowser.loadDirectories();
    
    
-   %this.loadDirectories();
+   $CurrentAssetBrowser.addModuleDeclaredAssets(%moduleId);
+}
+
+function FolderObjectType::onDelete(%folderPath)
+{
+   $CurrentAssetBrowser.dirHandler.deleteFolder(%folderPath);
    
    
-   AssetDatabase.addModuleDeclaredAssets(%moduleId);
+   $CurrentAssetBrowser.refresh();
+}
+
+function FolderObjectType::onWorldEditorDropped(%folderPath, %position)
+{
+   //We do nothing with this as we don't process entire folders for spawning
+}
+
+function FolderObjectType::onGuiEditorDropped(%folderPath, %position)
+{
+   //We do nothing with this as we don't process entire folders for spawning
 }
 }
 
 
-function AssetBrowser::moveFolder(%this, %folderPath, %newFolderPath)
+function FolderObjectType::onMovePath(%folderPath, %destinationPath)
 {
 {
    %fullPath = makeFullPath(%folderPath);
    %fullPath = makeFullPath(%folderPath);
-   %newFullPath = makeFullPath(%newFolderPath);
+   %newFullPath = makeFullPath(%destinationPath);
    
    
    %fullPath = strreplace(%fullPath, "//", "/");
    %fullPath = strreplace(%fullPath, "//", "/");
    %newFullPath = strreplace(%newFullPath, "//", "/");
    %newFullPath = strreplace(%newFullPath, "//", "/");
@@ -108,14 +163,20 @@ function AssetBrowser::moveFolder(%this, %folderPath, %newFolderPath)
    %basePath = getTokens(%fullPath, "/", 0, %count-2);
    %basePath = getTokens(%fullPath, "/", 0, %count-2);
    %oldName = getToken(%fullPath, "/", %count-1);
    %oldName = getToken(%fullPath, "/", %count-1);
    
    
-   %copiedSuccess = %this.dirHandler.copyFolder(%fullPath, %newFullPath);
-   %this.dirHandler.deleteFolder(%fullPath);
+   %copiedSuccess = $CurrentAssetBrowser.dirHandler.copyFolder(%fullPath, %newFullPath);
+   $CurrentAssetBrowser.dirHandler.deleteFolder(%fullPath);
    
    
-   %this.loadDirectories();
+   $CurrentAssetBrowser.loadDirectories();
+}
+
+function FolderObjectType::onMoveModule(%folderPath, %destinationPath)
+{
+   //Same logic as a regular folder move
+   FolderObjectType::onMovePath(%folderPath, %destinationPath);
    
    
    //thrash the modules and reload them
    //thrash the modules and reload them
-   %oldModule = %this.dirHandler.getModuleFromAddress(%folderPath);
-   %newModule = %this.dirHandler.getModuleFromAddress(%newFolderPath);
+   %oldModule = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(%folderPath);
+   %newModule = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(%destinationPath);
    
    
    //if we didn't move modules, then we don't need to do anything other than refresh the assets within it
    //if we didn't move modules, then we don't need to do anything other than refresh the assets within it
    if(%oldModule == %newModule)
    if(%oldModule == %newModule)
@@ -132,11 +193,4 @@ function AssetBrowser::moveFolder(%this, %folderPath, %newFolderPath)
       ModuleDatabase.unloadExplicit(%newModule.getModuleId());
       ModuleDatabase.unloadExplicit(%newModule.getModuleId());
       ModuleDatabase.loadExplicit(%newModule.getModuleId());
       ModuleDatabase.loadExplicit(%newModule.getModuleId());
    }
    }
-}
-
-function AssetBrowser::deleteFolder(%this, %folderPath)
-{
-   %this.dirHandler.deleteFolder(%folderPath);
-   
-   %this.refresh();
 }
 }

+ 0 - 0
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/forest.tscript


+ 0 - 285
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/gameObject.tscript

@@ -1,285 +0,0 @@
-function AssetBrowser::createGameObjectAsset(%this)
-{
-   GameObjectCreatorObjectName.text = "";
-   
-   %activeSelection = EWorldEditor.getActiveSelection();
-   if( %activeSelection.getCount() == 0 )
-      return;
-      
-   GameObjectCreator.selectedEntity = %activeSelection.getObject( 0 );
-
-   Canvas.pushDialog(GameObjectCreator);
-}
-
-function AssetBrowser::editGameObjectAsset(%this, %assetDef)
-{
-   //We have no dedicated GO editor for now, so just defer to the script editing aspect
-   %this.editGameObjectAssetScript(%assetDef);
-}
-
-function AssetBrowser::editGameObjectAssetScript(%this, %assetDef)
-{
-   %scriptFile = %assetDef.scriptFile;
-   
-   if(%scriptFile !$= "")
-      EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);  
-}
-
-function AssetBrowser::applyInstanceToGameObject(%this, %assetDef)
-{
-   %obj = EditGameObjectAssetPopup.object;
-   
-   //TODO add proper validation against the original GO asset
-   %obj.dirtyGameObject = true;
-   
-   TamlWrite(%obj, %assetDef.TAMLFilePath);
-}
-
-function AssetBrowser::duplicateGameObjectAsset(%this, %assetDef, %targetModule)
-{
-   //Check if we have a target module, if not we need to select one
-   if(%targetModule $= "")
-   {
-      error("AssetBrowser::duplicateGameObjectAsset - No target module selected!");
-      return;
-   }
-   
-   %assetId = %assetDef.getAssetId();
-   %assetName = AssetDatabase.getAssetName(%assetId);
-   
-   //First step, copy the files
-   %modulePath = "data/" @ %targetModule @ "/gameObjects/";
-   
-   if(!isDirectory(%modulePath))
-      createPath(%modulePath);
-   
-   %assetFile = AssetDatabase.getAssetFilePath(%assetId);
-   %scriptFile = %assetDef.scriptFile;
-   %gameObjectFile = %assetDef.TAMLFile;
-   
-   echo("AssetBrowser::duplicateGameObjectAsset - duplicating! " @ %assetId @ " to " @ %targetModule);
-   
-   %tamlPath = %modulePath @ fileName(%assetFile);
-   
-   pathCopy(%assetFile, %tamlPath);
-   pathCopy(%scriptFile, %modulePath @ fileName(%scriptFile));
-   pathCopy(%gameObjectFile, %modulePath @ fileName(%gameObjectFile));
-   
-   echo("AssetBrowser::duplicateGameObjectAsset - duplicated!");
-   
-   //Register the asset
-   %moduleDef = ModuleDatabase.findModule(%targetModule, 1);
-   
-	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlPath);
-
-   //Refresh the browser
-	AssetBrowser.refresh();
-	
-	//Rename it for convenience
-	AssetBrowser.performRenameAsset(%assetName, "New" @ %assetName);
-}
-
-//not used
-function AssetBrowser::importGameObjectAsset(%this, %assetId)
-{
-   
-}
-
-function AssetBrowser::dragAndDropGameObjectAsset(%this, %assetDef, %dropTarget)
-{
-   if(!isObject(%dropTarget))
-      return;
-      
-   if(%dropTarget.getId() == EWorldEditor.getId())
-   {
-      if(isObject(%assetDef))
-      {
-         %gameObject = %assetDef.createObject(); 
-         
-         getScene(0).add(%gameObject);
-         
-         %pos = ObjectCreator.getCreateObjectPosition(); //LocalClientConnection.camera.position; 
-      
-         %gameObject.position = %pos;
-         
-         EWorldEditor.clearSelection();
-         EWorldEditor.selectObject(%gameObject); 
-      }
-      else
-      {
-         error("WorldEditor::onControlDropped - unable to create GameObject"); 
-      }
-   }
-}
-
-function AssetBrowser::onGameObjectAssetEditorDropped(%this, %assetDef, %position)
-{
-   //echo("DROPPED A SHAPE ON THE EDITOR WINDOW!"); 
-
-   %targetPosition = EWorldEditor.unproject(%position SPC 1);
-   %camPos = LocalClientConnection.camera.getPosition();
-   %rayResult = containerRayCast(%camPos, %targetPosition, -1);
-   
-   %pos = ObjectCreator.getCreateObjectPosition();
-
-   if(%rayResult != 0)
-   {
-      %pos = getWords(%rayResult, 1, 3);
-   }
-   
-   %gameObject = %assetDef.createObject(); 
-         
-   getScene(0).add(%gameObject);
-
-   %gameObject.position = %pos;
-   
-   EWorldEditor.clearSelection();
-   EWorldEditor.selectObject(%gameObject); 
-      
-   EWorldEditor.isDirty = true;
-   
-}
-
-function AssetBrowser::renameGameObjectAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
-{
-   %oldScriptFilePath = %assetDef.scriptFile;
-   %scriptFilePath = filePath(%assetDef.scriptFile);
-   %scriptExt = fileExt(%assetDef.scriptFile);
-   
-   %oldGOFilePath = %assetDef.TAMLFile;
-   
-   %filepath = AssetDatabase.getAssetFilePath(%assetDef.getAssetId());
-   %path = makeRelativePath(filePath(%filepath));
-   
-   %newScriptFileName = %path @ "/" @ %newName @ %scriptExt;
-   %newAssetFile = %path @ "/" @ %newName @ ".asset.taml";
-   %newGOFile = %path @ "/" @ %newName @ ".taml";
-   
-   %assetDef.gameObjectName = %newName;
-   %assetDef.scriptFile = %newScriptFileName;
-   %assetDef.TAMLFile = %newGOFile;
-   
-   TamlWrite(%assetDef, %newAssetFile);
-   fileDelete(%filepath);
-   
-   //Quick check, if we duplicated the asset to a new module, the old path may not line up so we'll want to update that to be relevent
-   if(filePath(%oldScriptFilePath) !$= %path)
-   {
-     %oldFileBase = fileName(%oldScriptFilePath);
-     %oldScriptFilePath = %path @ "/" @ %oldFileBase;
-   }
-   
-   %scriptFileCopySuccess = pathCopy(%oldScriptFilePath, %newScriptFileName);
-   fileDelete(%oldScriptFilePath);
-   
-   if(!%scriptFileCopySuccess)
-      error("AssetBrowser::renameGameObjectAsset - unable to copy scriptFile");
-   
-   if(filePath(%oldGOFilePath) !$= %path)
-   {
-     %oldFileBase = fileName(%oldGOFilePath);
-     %oldGOFilePath = %path @ "/" @ %oldFileBase;
-   }
-   
-   %goFileCopySuccess = pathCopy(%oldGOFilePath, %newGOFile);
-   fileDelete(%oldGOFilePath);
-   
-   if(!%scriptFileCopySuccess)
-      error("AssetBrowser::renameGameObjectAsset - unable to copy gameObject");
-   
-   //Go through our scriptfile and replace the old namespace with the new
-   %editedFileContents = "";
-   
-   %file = new FileObject();
-   if ( %file.openForRead( %newScriptFileName ) ) 
-   {
-      while ( !%file.isEOF() ) 
-      {
-         %line = %file.readLine();
-         %line = trim( %line );
-         
-         %editedFileContents = %editedFileContents @ strreplace(%line, %originalName, %newName) @ "\n";
-      }
-      
-      %file.close();
-   }
-   
-   if(%editedFileContents !$= "")
-   {
-      %file.openForWrite(%newScriptFileName);
-      
-      %file.writeline(%editedFileContents);
-      
-      %file.close();
-   }
-   
-   exec(%newScriptFileName);
-   
-   %gameObj = TAMLRead(%newGOFile);
-   
-   %gameObj.className = %newName;
-   %gameObj.GameObject = %assetDef.getAssetId();
-   
-   TAMLWrite(%gameObj, %newGOFile);
-}
-
-//Deletes the asset
-function AssetBrowser::deleteGameObjectAsset(%this, %assetDef)
-{
-   AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
-}
-
-//Moves the asset to a new path/module
-function AssetBrowser::moveGameObjectAsset(%this, %assetDef, %destination)
-{
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.scriptFile, %destination);
-   moveAssetLooseFile(%assetDef.TAMLFile, %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
-}
-
-
-function AssetBrowser::buildGameObjectAssetPreview(%this, %assetDef, %previewData)
-{
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.scriptFile;
-   %previewData.doubleClickCommand = "EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
-   
-   %previewData.previewImage = "ToolsModule:gameObjectIcon_image";
-   
-   %previewData.assetFriendlyName = %assetDef.gameObjectName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = "Asset Name: " @ %assetDef.gameObjectName @ "\nDefinition Path: " @ %assetDef.getFilename();
-}
-
-function GuiInspectorTypeGameObjectAssetPtr::onClick( %this, %fieldName )
-{
-   //Get our data
-   %obj = %this.getInspector().getInspectObject(0);
-   
-   EditGameObjectAssetPopup.object = %obj;
-   
-   %assetId = %obj.getFieldValue(%fieldName);
-   
-   if(%assetId !$= "")
-   {
-      EditGameObjectAssetPopup.assetId = %assetId;
-      
-      
-      EditGameObjectAssetPopup.showPopup(Canvas);
-   }
-   else
-   {
-      //We've gotta be trying to create a GameObject, so kick that off  
-      AssetBrowser.createGameObjectAsset();
-   }
-}

+ 351 - 0
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/genericAsset.tscript

@@ -0,0 +1,351 @@
+//This function registers the asset type, associated file extensions and human-readable name with the Asset Browser
+//This is primarily so there's an easy hook-in point for the 'type' namespace, as well as registration for AB
+//filter modes and file scanning
+AssetBrowser::registerAssetType("GenericAsset", "", "", false);
+
+//This function is called when we want to have adjustable field information for a new asset
+//This could be a secondary name or description, a 'preview image' or anything else beyond
+//just the basic AssetName and AssetDescription files
+function GenericAsset::setupCreateNew()
+{
+   echo("GenericAsset::setupCreateNew()");
+}
+
+//This is called when we actually finally decide to create the new asset itself
+//We create the asset definition, supplemental files, save everything to disk and
+//then register with the AssetDatabase so it's available for use
+function GenericAsset::onCreateNew()
+{
+   echo("GenericAsset::onCreateNew()");
+}
+
+//This us called when we are creating a 'card' in the AssetBrowser for viewing
+//when navigating. It packs whatever relevent information such as the preview image
+//into the %previewData object that the AssetBrowser then uses to actually display
+function GenericAsset::buildBrowserElement(%this, %previewData)
+{
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.getFileName();
+   %previewData.doubleClickCommand = "";
+
+   %previewData.previewImage = "ToolsModule:genericAssetIcon_image";
+
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ "\nDefinition Path: " @ %previewData.assetPath;
+}
+
+//This is called when we specifically need to special-handle generation of a preview image
+//Such as rendering a shape or material to a cached image file, rather than simply using a 
+//basic image to represent the type in the AssetBrowser
+function GenericAsset::generatePreviewImage(%this, %previewButton, %forceRegenerate)
+{
+}
+
+//Called when we rename the asset. The place we would change the asset definition name
+//as well as update the name for any associated files
+function GenericAsset::onRename(%this, %newAssetName)
+{
+   %assetPath = makeFullPath($CurrentAssetBrowser.getAssetFilePath(%this.getAssetId()));
+   %assetFilepath = filePath(%assetPath);
+   %assetFileExt = fileExt(%assetPath);
+   
+   %newAssetPath = %assetFilepath @ "/" @ %newAssetName @ ".asset.taml";
+   
+   %copiedSuccess = pathCopy(%assetPath, %newAssetPath);
+   
+   if(!%copiedSuccess)
+      return "";
+      
+   replaceInFile(%newAssetPath, %this.assetName, %newAssetName);
+   
+   %looseFilesList = AssetDatabase.getAssetLooseFiles(%this.getAssetId());
+   
+   for(%i=0; %i < getFieldCount(%looseFilesList); %i++)
+   {
+      %looseFile = getField(%looseFilesList, %i);
+      
+      if(!isFile(%looseFile))
+      {
+         errorf("GenericAsset::onMovePath() - could not find loose file: " @ %looseFile);
+         continue;
+      }
+      
+      %newLooseFileName = strReplace(fileName(%looseFile), %this.assetName, %newAssetName);
+      %looseFileExt = fileExt(%looseFile);
+      
+      echo("GenericAsset::onRename() - renamed loose file from: " @ %looseFile @ " to: " @ %assetPath @ "/" @ %newLooseFileName @ %looseFileExt);
+      
+      %looseFileNewPath = %assetPath @ "/" @ %newLooseFileName @ %looseFileExt;
+      %copiedSuccess = pathCopy(%looseFile, %looseFileNewPath);
+      if(!%copiedSuccess)
+      {
+         errorf("GenericAsset::onDuplicate() - failed to duplicate loose file: " @ %looseFile);
+      }
+      else
+      {
+         fileDelete(%looseFile);
+         replaceInFile(%looseFileNewPath, %this.assetName, %newAssetName);
+      }
+   }
+   
+   %module = getModuleFromAddress(%newAssetPath);
+      
+   //Add with the new file
+   $CurrentAssetBrowser.addDeclaredAsset(%module, %newAssetPath);
+   
+   GenericAsset::onDelete(%this);
+      
+   return %newAssetPath;
+}
+
+//Called when duplicating the asset. A copy is made, and then we perform a rename action
+//on the copy to ensure there's no name conflicts
+function GenericAsset::onDuplicate(%this, %newAssetName)
+{
+   %assetPath = makeFullPath($CurrentAssetBrowser.getAssetFilePath(%this.getAssetId()));
+   %assetFilepath = filePath(%assetPath);
+   %assetFileExt = fileExt(%assetPath);
+   
+   %newAssetPath = %assetFilepath @ "/" @ %newAssetName @ ".asset.taml";
+   
+   %copiedSuccess = pathCopy(%assetPath, %newAssetPath);
+   
+   if(!%copiedSuccess)
+      return "";
+      
+   replaceInFile(%newAssetPath, %this.assetName, %newAssetName);
+   
+   %looseFilesList = AssetDatabase.getAssetLooseFiles(%this.getAssetId());
+   
+   for(%i=0; %i < getFieldCount(%looseFilesList); %i++)
+   {
+      %looseFile = getField(%looseFilesList, %i);
+      
+      if(!isFile(%looseFile))
+      {
+         errorf("GenericAsset::onMovePath() - could not find loose file: " @ %looseFile);
+         continue;
+      }
+      
+      %newLooseFileName = strReplace(fileName(%looseFile), %this.assetName, %newAssetName);
+      %looseFileExt = fileExt(%looseFile);
+      
+      echo("GenericAsset::onDuplicate() - renamed loose file from: " @ %looseFile @ " to: " @ %assetPath @ "/" @ %newLooseFileName @ %looseFileExt);
+      
+      %looseFileNewPath = %assetPath @ "/" @ %newLooseFileName @ %looseFileExt;
+      %copiedSuccess = pathCopy(%looseFile, %looseFileNewPath);
+      if(!%copiedSuccess)
+      {
+         errorf("GenericAsset::onDuplicate() - failed to duplicate loose file: " @ %looseFile);
+      }
+      else
+      {
+         replaceInFile(%looseFileNewPath, %this.assetName, %newAssetName);
+      }
+   }
+   
+   %module = getModuleFromAddress(%newAssetPath);
+      
+   //Add with the new file
+   $CurrentAssetBrowser.addDeclaredAsset(%module, %newAssetPath);
+      
+   $CurrentAssetBrowser.refresh();
+   
+   return %newAssetPath;
+}
+
+//Called when the asset is deleted. This would be where and associated files 
+//are also removed from the system
+function GenericAsset::onDelete(%this)
+{
+   AssetDatabase.deleteAsset(%this.getAssetId(), true);
+   
+   $CurrentAssetBrowser.refresh();
+}
+
+//Called when the asset is moved from one file path to another. Associated files would be
+//likewise moved
+function GenericAsset::onMovePath(%this, %destinationPath)
+{
+   %assetPath = makeFullPath($CurrentAssetBrowser.getAssetFilePath(%this.getAssetId()));
+   
+   moveAssetFile(%this, %destinationPath);
+      
+   %looseFilesList = AssetDatabase.getAssetLooseFiles(%this.getAssetId());
+   for(%i=0; %i < getFieldCount(%looseFilesList); %i++)
+   {
+      %looseFile = getField(%looseFilesList, %i);
+      
+      moveAssetLooseFile(%looseFile, %destinationPath);
+   }
+   
+   AssetDatabase.refreshAsset(%this.getAssetId());
+
+   $CurrentAssetBrowser.refresh();
+}
+
+function GenericAsset::onMoveModule(%this, %destinationPath)
+{
+   %assetPath = makeFullPath($CurrentAssetBrowser.getAssetFilePath(%this.getAssetId()));
+   
+   %newAssetPath = moveAssetFile(%this, %destinationPath);
+   
+   %looseFilesList = AssetDatabase.getAssetLooseFiles(%this.getAssetId());
+   for(%i=0; %i < getFieldCount(%looseFilesList); %i++)
+   {
+      %looseFile = getField(%looseFilesList, %i);
+      
+      moveAssetLooseFile(%looseFile, %destinationPath);
+   }
+   
+   %targetModule = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(%destinationPath);
+
+   AssetDatabase.removeDeclaredAsset(%this.getAssetId());
+   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
+      
+   $CurrentAssetBrowser.refresh();
+}
+
+//Called when there is an InspectorType field for this AssetType and a Asset preview
+//has been dragged and dropped from the AssetBrowser onto this field in the inspector
+//Generally this would see the field assigned with the dropped asset's ID
+/*function GuiInspectorType<AssetType>Ptr::onControlDropped(%this, %payload, %position)
+{
+}*/
+
+//Called when the asset is edited. This can either open the asset in the respective 
+//editor(MaterialAsset opens MaterialEd, etc) or performs some other action, such as loading
+//a LevelAsset in the editor or possibly opening an associated file in a system program for editing
+function GenericAsset::onEdit(%this)
+{
+   echo("GenericAsset::onEdit() - " @ %this);
+}
+
+//Called when the asset's Preview has been right-clicked to do a context popup menu
+//Allows for special-menu population per-type if desired, as not all assets will or should
+//offer the same 'actions' for editing and management
+function GenericAsset::onShowActionMenu(%this)
+{
+   if( !isObject( EditAssetPopup ) )
+   {
+      new PopupMenu( EditAssetPopup )
+      {
+         superClass = "MenuBuilder";
+         class = "EditorWorldMenu";
+
+         jumpFileName = "";
+         jumpLineNumber = "";
+      };
+   }
+   
+   //Regen the menu so we're fully up and current with options and references
+   EditAssetPopup.clearItems();
+   
+   EditAssetPopup.item[ 0 ] = "Edit Asset" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();";
+   EditAssetPopup.item[ 1 ] = "Rename Asset" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();";
+   EditAssetPopup.item[ 2 ] = "Reload Asset" TAB "" TAB $CurrentAssetBrowser @ ".refreshAsset();";
+   EditAssetPopup.item[ 3 ] = "Asset Properties" TAB "" TAB $CurrentAssetBrowser @ ".editAssetInfo();";
+   EditAssetPopup.item[ 4 ] = "-";
+   EditAssetPopup.item[ 5 ] = "Duplicate Asset" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();";
+   EditAssetPopup.item[ 6 ] = "-";
+   EditAssetPopup.item[ 7 ] = "Regenerate Preview Image" TAB "" TAB $CurrentAssetBrowser @ ".regeneratePreviewImage();";
+   EditAssetPopup.item[ 8 ] = "-";
+   EditAssetPopup.item[ 9 ] = "Re-Import Asset" TAB "" TAB $CurrentAssetBrowser @ ".reImportAsset();";
+   EditAssetPopup.item[ 10 ] = "-";
+   EditAssetPopup.item[ 11 ] = "Open File Location" TAB "" TAB $CurrentAssetBrowser @ ".openFileLocation();";
+   EditAssetPopup.item[ 12 ] = "-";
+   EditAssetPopup.item[ 13 ] = "Delete Asset" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();";
+   
+   %assetId = %this.getAssetId();
+   %assetType = AssetDatabase.getAssetType(%assetId);
+   
+   EditAssetPopup.objectData = %assetId;
+   EditAssetPopup.objectType = %assetType;
+   
+   EditAssetPopup.reloadItems();
+   
+   EditAssetPopup.showPopup(Canvas); 
+   
+   $CurrentAssetBrowser.popupMenu = EditAssetPopup;
+}
+
+//Called when editing the asset's properties, generally presented via an inspector
+//This function allows for special type handling if just inspecting the Type's object 
+//is insufficient
+function GenericAsset::onEditProperties(%this)
+{
+   Canvas.pushDialog(AssetBrowser_editAsset);
+   
+   AssetBrowser_editAssetWindow.text = "Asset Properties - " @ %this.getAssetId();
+   
+   AssetEditInspector.tempAsset = %this.deepClone();
+   
+   AssetEditInspector.inspect(AssetEditInspector.tempAsset);  
+   AssetBrowser_editAsset.editedObjectData = %this.getAssetId();
+   AssetBrowser_editAsset.editedObject = AssetEditInspector.tempAsset;
+   AssetBrowser_editAsset.editedObjectType = AssetDatabase.getAssetType(%this.getAssetId());
+   
+   //remove some of the groups we don't need:
+   for(%i=0; %i < AssetEditInspector.getCount(); %i++)
+   {
+      %caption = AssetEditInspector.getObject(%i).caption;
+      
+      if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing" 
+         || %caption $= "Persistence" || %caption $= "Dynamic Fields")
+      {
+         AssetEditInspector.remove(AssetEditInspector.getObject(%i));
+         %i--;
+      }
+   }
+}
+
+//Called when the AssetType has it's properties saved from the onEditProperties process
+function GenericAsset::onSaveProperties(%this)
+{
+   %assetId = %this.getAssetId();
+   %file = AssetDatabase.getAssetFilePath(%assetId);
+   %success = TamlWrite(AssetBrowser_editAsset.editedObject, %file);
+   
+   AssetDatabase.releaseAsset(%assetId);
+   
+   $CurrentAssetBrowser.reloadAsset(%assetId);
+
+   $CurrentAssetBrowser.refresh();
+
+   %this.refreshAsset();
+}
+
+//Called when the asset's Preview has been dragged and dropped into the world editor
+//This would usually spawn an associated instance, or a scene object that can utilize the
+//asset in question(ie, Dropping a SoundAsset spawns a SoundEmitter)
+function GenericAsset::onWorldEditorDropped(%this, %position)
+{
+   echo("GenericAsset::onWorldEditorDropped() - " @ %this @ ", " @ %position);
+}
+
+//Called when the asset's Preview has been dragged and dropped into the GUI editor
+//This would usually spawn an associated instance, or a gui object that can utilize the
+//asset in question(ie, Dropping a SoundAsset spawns a guiAudioCtrl)
+function GenericAsset::onGuiEditorDropped(%this, %position)
+{
+   echo("GenericAsset::onGuiEditorDropped() - " @ %this @ ", " @ %position);
+}
+
+//An example case of handling other specialized editors, such as dropping a Datablock
+//Preview into the DatablockEditor. This would be very case-by-case
+/*function GenericAsset::on<Editor>EditorDropped()
+{
+}*/
+
+//Called when the asset has been detected as having had files on the system changed. Allows
+//for automatically responding to those changes, such as re-execing script files
+function GenericAsset::onChanged(%this)
+{
+   echo("GenericAsset::onChanged() - " @ %this);
+}
+
+function GenericAsset::onStatusChanged(%this, %newStstus)
+{
+   echo("GenericAsset::onStatusChanged() - " @ %this @ ", " @ %newStstus);
+}

+ 25 - 79
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/gui.tscript

@@ -1,9 +1,12 @@
-function AssetBrowser::createGUIAsset(%this)
+AssetBrowser::registerFileType("GUIFileType", "GUI Files", ".gui;.gui.dso", false);
+AssetBrowser::registerAssetType("GUIAsset", "GUIs");
+
+function GUIAsset::onCreateNew()
 {
 {
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
+   %moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
    %modulePath = "data/" @ %moduleName;
    %modulePath = "data/" @ %moduleName;
       
       
-   %assetName = AssetBrowser.newAssetSettings.assetName;
+   %assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
    
    
    %assetPath = NewAssetTargetAddress.getText() @ "/";
    %assetPath = NewAssetTargetAddress.getText() @ "/";
    
    
@@ -24,7 +27,7 @@ function AssetBrowser::createGUIAsset(%this)
    %file = new FileObject();
    %file = new FileObject();
    %templateFile = new FileObject();
    %templateFile = new FileObject();
    
    
-   %guiTemplateCodeFilePath = %this.templateFilesPath @ "guiFile.gui.template";
+   %guiTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "guiFile.gui.template";
    
    
    if(%file.openForWrite(%guipath) && %templateFile.openForRead(%guiTemplateCodeFilePath))
    if(%file.openForWrite(%guipath) && %templateFile.openForRead(%guiTemplateCodeFilePath))
    {
    {
@@ -45,10 +48,10 @@ function AssetBrowser::createGUIAsset(%this)
       %file.close();
       %file.close();
       %templateFile.close();
       %templateFile.close();
       
       
-      warnf("CreateGUIAsset - Something went wrong and we couldn't write the GUI file!");
+      warn("GUIAsset::onCreateNew() - Something went wrong and we couldn't write the GUI file!");
    }
    }
    
    
-   %scriptTemplateCodeFilePath = %this.templateFilesPath @ "guiFile." @ $TorqueScriptFileExtension @ ".template";
+   %scriptTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "guiFile." @ $TorqueScriptFileExtension @ ".template";
    
    
    if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%scriptTemplateCodeFilePath))
    if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%scriptTemplateCodeFilePath))
    {
    {
@@ -69,7 +72,7 @@ function AssetBrowser::createGUIAsset(%this)
       %file.close();
       %file.close();
       %templateFile.close();
       %templateFile.close();
       
       
-      warnf("CreateGUIAsset - Something went wrong and we couldn't write the GUI script file!");
+      warn("GUIAsset::onCreateNew() - Something went wrong and we couldn't write the GUI script file!");
    }
    }
    
    
 	//load the gui
 	//load the gui
@@ -79,31 +82,17 @@ function AssetBrowser::createGUIAsset(%this)
 	%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
 	%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
 	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
 	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
 
 
-	AssetBrowser.refresh();
+	$CurrentAssetBrowser.refresh();
 	
 	
 	return %tamlpath;  
 	return %tamlpath;  
 }
 }
 
 
-function AssetBrowser::inspectImportingGUIAsset(%this, %assetItem)
+function GUIAsset::onEdit(%this)
 {
 {
-   AssetImportCtrl-->NewAssetsInspector.startGroup("GUI");
-   
-   AssetImportCtrl-->NewAssetsInspector.addField("GUIFile", "GUI File Path", "filename", "Intended usage case of this image. Used to map to material slots and set up texture profiles.", "", 
-                                                      "", %assetItem);
-                                                      
-   //Make this a callback so that if it's set we can callback to a validator function
-   //This function(and others for other asset types) would check if the loosefile audit window is open, and if it is, remove the file from the list
-   AssetImportCtrl-->NewAssetsInspector.addField("ScriptFile", "Script File Path", "filename", "Intended usage case of this image. Used to map to material slots and set up texture profiles.", "", 
-                                                      "", %assetItem);                                                  
-   AssetImportCtrl-->NewAssetsInspector.endGroup();                                                
-}
-
-function AssetBrowser::editGUIAsset(%this, %assetDef)
-{
-   if(!isObject(%assetDef.assetName))
+   if(!isObject(%this.assetName))
    {
    {
-      exec(%assetDef.GUIFilePath);
-      exec(%assetDef.mScriptFilePath);
+      exec(%this.GUIFilePath);
+      exec(%this.mScriptFilePath);
    }
    }
    
    
    if( EditorIsActive() && !GuiEditor.toggleIntoEditorGui )
    if( EditorIsActive() && !GuiEditor.toggleIntoEditorGui )
@@ -112,63 +101,20 @@ function AssetBrowser::editGUIAsset(%this, %assetDef)
    if( !$InGuiEditor && !GuiEditorIsActive() )
    if( !$InGuiEditor && !GuiEditorIsActive() )
       GuiEditor.open();
       GuiEditor.open();
       
       
-   GuiEditContent(%assetDef.assetName);  
-}
-
-//Renames the asset
-function AssetBrowser::renameGUIAsset(%this, %assetDef, %newAssetName)
-{
-   %newScriptLooseFilename = renameAssetLooseFile(%assetDef.scriptFile, %newAssetName);
-   
-   if(!%newScriptLooseFilename $= "")
-      return;
-      
-   %newGUILooseFilename = renameAssetLooseFile(%assetDef.guiFile, %newAssetName);
-   
-   if(!%newGUILooseFilename $= "")
-      return;
-      
-   %assetDef.scriptFile = %newScriptLooseFilename;
-   %assetDef.guiFile = %newGUILooseFilename;
-   %assetDef.saveAsset();
-   
-   renameAssetFile(%assetDef, %newAssetName);
+   GuiEditContent(%this.assetName);  
 }
 }
 
 
-//Deletes the asset
-function AssetBrowser::deleteGUIAsset(%this, %assetDef)
+function GUIAsset::buildBrowserElement(%this, %previewData)
 {
 {
-   AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
-}
-
-//Moves the asset to a new path/module
-function AssetBrowser::moveGUIAsset(%this, %assetDef, %destination)
-{
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.getGUIPath(), %destination);
-   moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
-}
-
-
-function AssetBrowser::buildGUIAssetPreview(%this, %assetDef, %previewData)
-{
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.GUIFilePath;
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.getGUIPath();
    %previewData.doubleClickCommand = "";
    %previewData.doubleClickCommand = "";
    
    
    %previewData.previewImage = "ToolsModule:guiIcon_image";
    %previewData.previewImage = "ToolsModule:guiIcon_image";
    
    
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getScriptPath();
-}
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ 
+                          "\nGUI Path: " @ %this.getGUIPath() @ 
+                          "\nScript Path: " @ %this.getScriptPath();
+}

+ 35 - 425
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.tscript

@@ -1,208 +1,33 @@
-function AssetBrowser::prepareImportImageAsset(%this, %assetItem)
-{
-   if((getAssetImportConfigValue("Images/GenerateMaterialOnImport", "1") == 1 && %assetItem.parentAssetItem $= "") || %assetItem.parentAssetItem !$= "")
-   {
-      //First, see if this already has a suffix of some sort based on our import config logic. Many content pipeline tools like substance automatically appends them
-      %foundSuffixType = parseImageSuffixes(%assetItem);
-      
-      if(%foundSuffixType $= "")
-      {
-         %noSuffixName = %assetItem.AssetName;
-      }
-      else
-      {
-         %suffixPos = strpos(strlwr(%assetItem.AssetName), strlwr(%assetItem.ImageType), 0);
-         %noSuffixName = getSubStr(%assetItem.AssetName, 0, %suffixPos);
-      }
-   
-      //Check if our material already exists
-      //First, lets double-check that we don't already have an
-      %materialAsset = ImportAssetWindow.findImportingAssetByName(%noSuffixName);
-      %cratedNewMaterial = false;
-      
-      //Sanity catch in the case we have some naming convention shenanigans in play
-      if(%materialAsset != 0 && %materialAsset.assetType !$= "MaterialAsset")
-         %materialAsset = 0;
-      
-      if(%materialAsset == 0)
-      {
-         %filePath = %assetItem.filePath;
-         if(%filePath !$= "")
-            %materialAsset = AssetBrowser.addImportingAsset("MaterialAsset", "", "", %noSuffixName);
-            
-         //%materialAsset.filePath = filePath(%assetItem.filePath) @ "/" @ %noSuffixName;
-         
-         ImportAssetItems.add(%materialAsset);
-            
-         %cratedNewMaterial = true;
-      }
-      
-      if(isObject(%materialAsset))
-      {
-         if(%assetItem.parentAssetItem !$= "")
-         {
-            %parentIndex = %assetItem.parentAssetItem.childAssetItems.getIndexFromKey(%assetItem);
-            %assetItem.parentAssetItem.childAssetItems.erase(%parentIndex);
-         }
-         else
-         {
-            //if we didn't have a parent until now, we're going to pull from it from our ImportAssetItems list
-            %itemIndex = ImportAssetItems.getIndexFromKey(%assetItem);
-            ImportAssetItems.erase(%itemIndex);
-         }
-         
-         //Establish parentage
-         %materialAsset.childAssetItems.add(%assetItem);
-         %assetItem.parentAssetItem = %materialAsset;
-         
-         ImportAssetWindow.assetHeirarchyChanged = true;
-      }
-      
-      //Lets do some cleverness here. If we're generating a material we can parse like assets being imported(similar file names) but different suffixes
-      //if we find these, we'll just populate into the original's material
-      
-      //If we need to append the diffuse suffix and indeed didn't find a suffix on the name, do that here
-      if(%foundSuffixType $= "")
-      {
-         if(getAssetImportConfigValue("Images/UseDiffuseSuffixOnOriginImg", "1") == 1)
-         {
-            if(%foundSuffixType $= "")
-            {
-               %diffuseToken = getToken(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",", 0);
-               %assetItem.AssetName = %assetItem.AssetName @ %diffuseToken;
-            }
-         }
-         else
-         {
-            //We need to ensure that our image asset doesn't match the same name as the material asset, so if we're not trying to force the diffuse suffix
-            //we'll give it a generic one
-            if(%materialAsset.assetName $= %assetItem.assetName)
-            {
-               %assetItem.AssetName = %assetItem.AssetName @ "_image";
-            }
-         }
-         
-         %foundSuffixType = "diffuse";
-      }
-      
-      if(%foundSuffixType !$= "")
-      {
-         //otherwise, if we have some sort of suffix, we'll want to figure out if we've already got an existing material, and should append to it  
-         
-         if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "1") == 1)
-         {
-            if(%foundSuffixType $= "diffuse")
-               %assetItem.ImageType = "Albedo";
-            else if(%foundSuffixType $= "normal")
-               %assetItem.ImageType = "Normal";
-            else if(%foundSuffixType $= "metalness")
-               %assetItem.ImageType = "metalness";
-            else if(%foundSuffixType $= "roughness")
-               %assetItem.ImageType = "roughness";
-            else if(%foundSuffixType $= "specular")
-               %assetItem.ImageType = "specular";
-            else if(%foundSuffixType $= "AO")
-               %assetItem.ImageType = "AO";
-            else if(%foundSuffixType $= "composite")
-               %assetItem.ImageType = "composite";
-         }
-      }
-      
-      //If we JUST created this material, we need to do a process pass on it to do any other setup for it
-      /*if(%cratedNewMaterial)
-      {
-         AssetBrowser.prepareImportMaterialAsset(%materialAsset);
-      }*/
-   }
-
-   %assetItem.processed = true;
-   
-   refreshImportAssetWindow();
-}
-
-function AssetBrowser::inspectImportingImageAsset(%this, %assetItem)
-{
-   AssetImportCtrl-->NewAssetsInspector.startGroup("Image");
-   AssetImportCtrl-->NewAssetsInspector.addField("ImageType", "Image Type", "list", "Intended usage case of this image. Used to map to material slots and set up texture profiles.", "GUI", 
-                                                      "Albedo,Normal,Composite,Roughness,AO,Metalness,Glow,GUI,Particle,Decal", %assetItem);
-                                                      
-   AssetImportCtrl-->NewAssetsInspector.endGroup();                                                
-}
-
-function AssetBrowser::importImageAsset(%this, %assetItem)
-{
-   %moduleName = AssetImportTargetModule.getText();
-   
-   %assetType = %assetItem.AssetType;
-   %filePath = %assetItem.filePath;
-   %assetName = %assetItem.assetName;
-   %assetImportSuccessful = false;
-   %assetId = %moduleName@":"@%assetName;
-   
-   %assetPath = NewAssetTargetAddress.getText() @ "/";
-   
-   %assetFullPath = %assetPath @ "/" @ fileName(%filePath);
-   
-   %newAsset = new ImageAsset()
-   {
-      assetName = %assetName;
-      versionId = 1;
-      imageFile = fileName(%filePath);
-      imageType = %assetItem.imageType;
-   };
-   
-   //No point in indicating the original path data if it was imported in-place
-   if(!startsWith(makeFullPath(%filePath), getMainDotCsDir()))
-   {
-      %newAsset.originalFilePath = %filePath;
-   }
-   
-   %assetImportSuccessful = TAMLWrite(%newAsset, %assetPath @ "/" @ %assetName @ ".asset.taml"); 
-   
-   //and copy the file into the relevent directory
-   %doOverwrite = !AssetBrowser.isAssetReImport;
-   if(!pathCopy(%filePath, %assetFullPath, %doOverwrite))
-   {
-      error("Unable to import asset: " @ %filePath);
-      return;
-   }
-   
-   %moduleDef = ModuleDatabase.findModule(%moduleName,1);
-         
-   if(!AssetBrowser.isAssetReImport)
-      AssetDatabase.addDeclaredAsset(%moduleDef, %assetPath @ "/" @ %assetName @ ".asset.taml");
-   else
-      AssetDatabase.refreshAsset(%assetId);
-}
+AssetBrowser::registerAssetType("ImageAsset", "Images"); 
 
 
-function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData)
+function ImageAsset::buildBrowserElement(%this, %previewData)
 {
 {
    //%module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getImagePath())));
    //%module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getImagePath())));
       
       
    %previewData.previewImage = "ToolsModule:genericAssetIcon_image";
    %previewData.previewImage = "ToolsModule:genericAssetIcon_image";
    %previewData.previewLoaded = false; //this marks it for loading progressively later
    %previewData.previewLoaded = false; //this marks it for loading progressively later
    
    
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.scriptFile;
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.scriptFile;
    
    
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
    
    
    //image info
    //image info
    //%info = %assetDef.getImageInfo();
    //%info = %assetDef.getImageInfo();
    
    
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ "\n" @
       "Asset Type: Image Asset\n" @ 
       "Asset Type: Image Asset\n" @ 
-      "Asset Definition ID: " @ %assetDef @ "\n" @ 
-      "Image Type: " @ %assetDef.imageType @ "\n" @ 
+      "Asset Definition ID: " @ %this @ "\n" @ 
+      "Image Type: " @ %this.imageType @ "\n" @ 
      /* "Format: " @ getWord(%info, 0) @ "\n" @ 
      /* "Format: " @ getWord(%info, 0) @ "\n" @ 
       "Height: " @ getWord(%info, 1) @ "\n" @ 
       "Height: " @ getWord(%info, 1) @ "\n" @ 
       "Width: " @ getWord(%info, 2) @ "\n" @ 
       "Width: " @ getWord(%info, 2) @ "\n" @ 
       "Depth: " @ getWord(%info, 3) @ "\n" @ */
       "Depth: " @ getWord(%info, 3) @ "\n" @ */
-      "Image File path: " @ %assetDef.getImagePath();
+      "Image File path: " @ %this.getImagePath();
 }
 }
 
 
-function AssetBrowser::generateImageAssetPreviewImage(%this, %previewButton, %forceRegenerate)
+function ImageAsset::generatePreviewImage(%this, %previewButton, %forceRegenerate)
 {
 {
    if(%forceRegenerate $= "")
    if(%forceRegenerate $= "")
       %forceRegenerate = false;
       %forceRegenerate = false;
@@ -211,24 +36,20 @@ function AssetBrowser::generateImageAssetPreviewImage(%this, %previewButton, %fo
    
    
    if(!IsDirectory(%previewPath))
    if(!IsDirectory(%previewPath))
    {
    {
-      %this.dirHandler.createFolder(%previewPath);
+      $CurrentAssetBrowser.dirHandler.createFolder(%previewPath);
    }
    }
    
    
-   %assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName;
-      
-   %assetDef = AssetDatabase.acquireAsset(%assetId);
-   
-   %previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.png";
-   if(!isFile(%previewFilePath) || (compareFileTimes(%assetDef.getImagePath(), %previewFilePath) == 1))
+   %previewFilePath = %previewPath @ %this.assetName @ "_Preview.png";
+   if(!isFile(%previewFilePath) || (compareFileTimes(%this.getImagePath(), %previewFilePath) == 1))
    {
    {
       %generatePreview = true;
       %generatePreview = true;
    }
    }
    
    
-   %previewAssetName = %previewButton.moduleName @ "_" @ %assetDef.assetName @ "_PreviewImage";
+   %previewAssetName = %previewButton.moduleName @ "_" @ %this.assetName @ "_PreviewImage";
    
    
    if(%generatePreview || %forceRegenerate)
    if(%generatePreview || %forceRegenerate)
    {
    {
-      %success = saveScaledImage(%assetDef.getImagePath(), %previewFilePath, EditorSettings.value("Assets/Browser/PreviewImageSize"));
+      %success = saveScaledImage(%this.getImagePath(), %previewFilePath, EditorSettings.value("Assets/Browser/PreviewImageSize"));
       
       
       if(%success)
       if(%success)
       {
       {
@@ -252,81 +73,42 @@ function AssetBrowser::generateImageAssetPreviewImage(%this, %previewButton, %fo
             if(!%success)
             if(!%success)
             {
             {
                return false; //failed to register the preview image for some reason?
                return false; //failed to register the preview image for some reason?
+            }
+         }
+            
+            %previewButton.bitmapAsset = %previewAssetName;
+            return true;
          }
          }
       }
       }
-         
-         %previewButton.bitmapAsset = %previewAssetName;
-         return true;
+      else
+      {
+         //just map the existing one then
+         if(AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName))
+      {
+            %previewButton.bitmapAsset = "ToolsModule:" @ %previewAssetName;
+            return true;
       }
       }
    }
    }
-   else
-   {
-      //just map the existing one then
-      if(AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName))
-   {
-         %previewButton.bitmapAsset = "ToolsModule:" @ %previewAssetName;
-         return true;
-   }
-   }
    
    
    return false;
    return false;
 }
 }
 
 
-//Renames the asset
-function AssetBrowser::renameImageAsset(%this, %assetDef, %newAssetName)
+function ImageAsset::onShowActionMenu(%this)
 {
 {
-   %newFilename = renameAssetLooseFile(%assetDef.getImagePath(), %newAssetName);
-   
-   if(!%newFilename $= "")
-      return;
-
-   %assetDef.imageFile = %newFilename;
-   %assetDef.saveAsset();
-   
-   renameAssetFile(%assetDef, %newAssetName);
+   GenericAsset::onShowActionMenu(%this);
 }
 }
 
 
-//Duplicates the asset
-function AssetBrowser::duplicateImageAsset(%this, %assetDef, %newAssetName)
+function ImageAsset::onEditProperties(%this)
 {
 {
-   %duplicatedAsset = duplicateAssetFile(%assetDef, %newAssetName);
-   
-   %newFilename = duplicateAssetLooseFile(%assetDef.imageFile, %newAssetName);
-   
-   if(!%newFilename $= "")
-      return;
-      
-   %module = AssetBrowser.dirHandler.getModuleFromAddress(%duplicatedAsset);
-      
-   %dupAssetDef = AssetDatabase.acquireAsset(%module.ModuleId @ ":" @ %newAssetName);
-
-   %dupAssetDef.imageFile = fileName(%newFilename);
-   %dupAssetDef.saveAsset();
+   GenericAsset::onEditProperties(%this);
 }
 }
 
 
-//Deletes the asset
-function AssetBrowser::deleteImageAsset(%this, %assetDef)
+//Called when the AssetType has it's properties saved from the onEditProperties process
+function ImageAsset::onSaveProperties(%this)
 {
 {
-   AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
+   GenericAsset::onSaveProperties(%this);
 }
 }
-
-//Moves the asset to a new path/module
-function AssetBrowser::moveImageAsset(%this, %assetDef, %destination)
-{
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.getImagePath(), %destination);
    
    
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
-}
-
 function GuiInspectorTypeImageAssetPtr::onControlDropped( %this, %payload, %position )
 function GuiInspectorTypeImageAssetPtr::onControlDropped( %this, %payload, %position )
 {
 {
    Canvas.popDialog(EditorDragAndDropLayer);
    Canvas.popDialog(EditorDragAndDropLayer);
@@ -346,176 +128,4 @@ function GuiInspectorTypeImageAssetPtr::onControlDropped( %this, %payload, %posi
    }
    }
    
    
    EWorldEditor.isDirty = true;
    EWorldEditor.isDirty = true;
-}
-
-function parseImageSuffixes(%assetItem)
-{
-   //diffuse
-   %suffixCount = getTokenCount(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
-      {
-         %assetItem.ImageType = %suffixToken;
-         return "diffuse";
-      }
-   }
-   
-   //normal
-   %suffixCount = getTokenCount(getAssetImportConfigValue("Images/NormalTypeSuffixes", ""), ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(getAssetImportConfigValue("Images/NormalTypeSuffixes", ""), ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
-      {
-         %assetItem.ImageType = %suffixToken;
-         return "normal";
-      }
-   }
-   
-   //roughness
-   %suffixCount = getTokenCount(getAssetImportConfigValue("Images/RoughnessTypeSuffixes", ""), ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(getAssetImportConfigValue("Images/RoughnessTypeSuffixes", ""), ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
-      {
-         %assetItem.ImageType = %suffixToken;
-         return "roughness";
-      }
-   }
-   
-   //Ambient Occlusion
-   %suffixCount = getTokenCount(getAssetImportConfigValue("Images/AOTypeSuffixes", ""), ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(getAssetImportConfigValue("Images/AOTypeSuffixes", ""), ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
-      {
-         %assetItem.ImageType = %suffixToken;
-         return "AO";
-      }
-   }
-   
-   //metalness
-   %suffixCount = getTokenCount(getAssetImportConfigValue("Images/MetalnessTypeSuffixes", ""), ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(getAssetImportConfigValue("Images/MetalnessTypeSuffixes", ""), ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
-      {
-         %assetItem.ImageType = %suffixToken;
-         return "metalness";
-      }
-   }
-   
-   //composite
-   %suffixCount = getTokenCount(getAssetImportConfigValue("Images/CompositeTypeSuffixes", ""), ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(getAssetImportConfigValue("Images/CompositeTypeSuffixes", ""), ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
-      {
-         %assetItem.ImageType = %suffixToken;
-         return "composite";
-      }
-   }
-   
-   //specular
-   /*%suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
-      {
-         %assetItem.imageSuffixType = %suffixToken;
-         return "specular";
-      }
-   }*/
-   
-   return "";
-}
-
-function parseImagePathSuffixes(%filePath)
-{
-   //diffuse
-   %diffuseSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", "");
-   %suffixCount = getTokenCount(%diffuseSuffixes, ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(%diffuseSuffixes, ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %filePath))
-      {
-         return "diffuse";
-      }
-   }
-   
-   //normal
-   %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.NormalTypeSuffixes, ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(ImportAssetWindow.activeImportConfig.NormalTypeSuffixes, ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %filePath))
-      {
-         return "normal";
-      }
-   }
-   
-   //roughness
-   %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %filePath))
-      {
-         return "roughness";
-      }
-   }
-   
-   //Ambient Occlusion
-   %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %filePath))
-      {
-         return "AO";
-      }
-   }
-   
-   //metalness
-   %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %filePath))
-      {
-         return "metalness";
-      }
-   }
-   
-   //composite
-   %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %filePath))
-      {
-         return "composite";
-      }
-   }
-   
-   //specular
-   %suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;");
-   for(%sfx = 0; %sfx < %suffixCount; %sfx++)
-   {
-      %suffixToken = getToken(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;", %sfx);
-      if(strIsMatchExpr("*"@%suffixToken, %filePath))
-      {
-         return "specular";
-      }
-   }
-   
-   return "";
 }
 }

+ 32 - 219
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.tscript

@@ -1,30 +1,20 @@
-function AssetBrowser::setupCreateNewLevelAsset(%this)
+AssetBrowser::registerAssetType("LevelAsset", "Levels"); 
+
+function LevelAsset::setupCreateNew()
 {
 {
    NewAssetPropertiesInspector.startGroup("Level");
    NewAssetPropertiesInspector.startGroup("Level");
-   NewAssetPropertiesInspector.addField("LevelName", "Level Name", "String",  "Human-readable name of new level", "", "", %this.newAssetSettings);
-   NewAssetPropertiesInspector.addField("levelPreviewImage", "Level Preview Image", "Image",  "Preview Image for the level", "", "", %this.newAssetSettings);
-   
-   //If we forcefully set it elsewhere, adhere
-   if($createLevelAssetIsSubScene == true)
-      %this.newAssetSettings.isSubScene = true;
-   else
-      %this.newAssetSettings.isSubScene = false;
+   NewAssetPropertiesInspector.addField("LevelName", "Level Name", "String",  "Human-readable name of new level", "", "", $CurrentAssetBrowser.newAssetSettings);
+   NewAssetPropertiesInspector.addField("levelPreviewImage", "Level Preview Image", "Image",  "Preview Image for the level", "", "", $CurrentAssetBrowser.newAssetSettings);
    
    
-   NewAssetPropertiesInspector.addField("isSubScene", "Is SubScene", "bool", "Is this levelAsset intended as a subScene", %this.newAssetSettings.isSubScene, "", %this.newAssetSettings);
-
    NewAssetPropertiesInspector.endGroup();
    NewAssetPropertiesInspector.endGroup();
 }
 }
 
 
-function AssetImporter::importLevelAsset(%this, %assetItem)
+function LevelAsset::onCreateNew(%this)
 {
 {
-}
-
-function AssetBrowser::createLevelAsset(%this)
-{
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
+   %moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
    %modulePath = "data/" @ %moduleName;
    %modulePath = "data/" @ %moduleName;
    
    
-   %assetName = AssetBrowser.newAssetSettings.assetName;
+   %assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
    
    
    %assetPath = NewAssetTargetAddress.getText() @ "/";
    %assetPath = NewAssetTargetAddress.getText() @ "/";
    
    
@@ -43,10 +33,10 @@ function AssetBrowser::createLevelAsset(%this)
       PostFXPresetFile = %assetName @ ".postfxpreset." @ $TorqueScriptFileExtension;
       PostFXPresetFile = %assetName @ ".postfxpreset." @ $TorqueScriptFileExtension;
       ForestFile = %assetName @ ".forest";
       ForestFile = %assetName @ ".forest";
       NavmeshFile = %assetName @ ".nav";
       NavmeshFile = %assetName @ ".nav";
-      LevelName = AssetBrowser.newAssetSettings.levelName;
-      AssetDescription = AssetBrowser.newAssetSettings.description;
-      PreviewImage = AssetBrowser.newAssetSettings.levelPreviewImage;
-      isSubScene = AssetBrowser.newAssetSettings.isSubScene;
+      LevelName = $CurrentAssetBrowser.newAssetSettings.levelName;
+      AssetDescription = $CurrentAssetBrowser.newAssetSettings.description;
+      PreviewImage = $CurrentAssetBrowser.newAssetSettings.levelPreviewImage;
+      isSubScene = $CurrentAssetBrowser.newAssetSettings.isSubScene;
    };
    };
    
    
    TamlWrite(%asset, %tamlpath);
    TamlWrite(%asset, %tamlpath);
@@ -90,219 +80,42 @@ function AssetBrowser::createLevelAsset(%this)
 	
 	
 	if(!%addSuccess)
 	if(!%addSuccess)
 	{
 	{
-	   error("AssetBrowser::createLevelAsset() - failed to add declared asset: " @ %tamlpath @ " for module: " @ %moduleDef);
+	   error("LevelAsset::onCreateNew() - failed to add declared asset: " @ %tamlpath @ " for module: " @ %moduleDef);
 	}
 	}
 
 
-	AssetBrowser.refresh();
+	$CurrentAssetBrowser.refresh();
+	
+	if(%addSuccess && isObject($createAndAssignField))
+	{
+      $createAndAssignField.apply(%moduleName @ ":" @ %assetName);
+      $createAndAssignField = "";
+	}
 	
 	
 	return %tamlpath;  
 	return %tamlpath;  
 }
 }
 
 
-//==============================================================================
-//SubScene derivative
-//==============================================================================
-function AssetBrowser::setupCreateNewSubScene(%this)
-{
-   %this.newAssetSettings.isSubScene = true;
-   %this.newAssetSettings.assetType = "LevelAsset";
-}
-
-//==============================================================================
-
-function AssetBrowser::editLevelAsset(%this, %assetDef)
-{
-   echo("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
-   echo(%assetDef @ ".isSubScene = " @ %assetDef.isSubScene);
-   if(!%assetDef.isSubScene)
-      schedule( 1, 0, "EditorOpenMission", %assetDef);
-}
-
-//Renames the asset
-function AssetBrowser::renameLevelAsset(%this, %assetDef, %newAssetName)
-{
-   %newFilename = renameAssetLooseFile(%assetDef.LevelFile, %newAssetName);
-   
-   if(!%newFilename $= "")
-      return;
-      
-   //TODO the other loose files
-      
-   %assetDef.LevelFile = %newFilename;
-   %assetDef.saveAsset();
-   
-   renameAssetFile(%assetDef, %newAssetName);
-}
-
-//Duplicates the asset
-function AssetBrowser::duplicateLevelAsset(%this, %assetDef, %newAssetName)
+function LevelAsset::onEdit(%this)
 {
 {
-   %duplicatedAsset = duplicateAssetFile(%assetDef, %newAssetName);
-   
-   %newFilename = duplicateAssetLooseFile(%assetDef.LevelFile, %newAssetName);
-   
-   if(!%newFilename $= "")
-      return;
-      
-   %module = AssetBrowser.dirHandler.getModuleFromAddress(%duplicatedAsset);
-      
-   %dupAssetDef = AssetDatabase.acquireAsset(%module.ModuleId @ ":" @ %newAssetName);
-
-   %dupAssetDef.LevelFile = fileName(%newFilename);
-   %dupAssetDef.saveAsset();
+   schedule( 1, 0, "EditorOpenMission", %this);
 }
 }
 
 
-//Deletes the asset
-function AssetBrowser::deleteLevelAsset(%this, %assetDef)
-{
-   AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
-}
-
-//Moves the asset to a new path/module
-function AssetBrowser::moveLevelAsset(%this, %assetDef, %destination)
-{
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.getLevelPath(), %destination);
-   moveAssetLooseFile(%assetDef.getPreviewImagePath(), %destination);
-   moveAssetLooseFile(%assetDef.getPostFXPresetPath(), %destination);
-   moveAssetLooseFile(%assetDef.getDecalsPath(), %destination);
-   moveAssetLooseFile(%assetDef.getForestPath(), %destination);
-   moveAssetLooseFile(%assetDef.getNavmeshPath(), %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
-}
-   
-function AssetBrowser::buildLevelAssetPreview(%this, %assetDef, %previewData)
+function LevelAsset::buildBrowserElement(%this, %previewData)
 {
 {
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.getLevelPath();
-
-   if(%this.selectMode || %assetDef.isSubScene)
-   {
-      %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
-   }
-   else
-   {
-      %previewData.doubleClickCommand = "schedule( 1, 0, \"EditorOpenMission\", "@%assetDef@");";
-   }
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.getLevelPath();
+   %previewData.doubleClickCommand = "schedule( 1, 0, \"EditorOpenMission\", "@%this@");";
    
    
-   %levelPreviewImage = %assetDef.PreviewImage;
+   %levelPreviewImage = %this.PreviewImage;
          
          
    if(isFile(%levelPreviewImage))
    if(isFile(%levelPreviewImage))
       %previewData.previewImage = %levelPreviewImage;
       %previewData.previewImage = %levelPreviewImage;
    else
    else
       %previewData.previewImage = "ToolsModule:levelIcon_image";
       %previewData.previewImage = "ToolsModule:levelIcon_image";
    
    
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ "\n" @
       "Asset Type: Level Asset\n" @ 
       "Asset Type: Level Asset\n" @ 
-      "Asset Definition ID: " @ %assetDef @ "\n" @ 
-      "Level File path: " @ %assetDef.getLevelPath(); 
-}
-
-function createAndAssignLevelAsset(%moduleName, %assetName)
-{
-   if(AssetDatabase.isDeclaredAsset(%moduleName))
-      $createAndAssignField.apply(%moduleName);
-   else
-      $createAndAssignField.apply(%moduleName @ ":" @ %assetName);
-}
-
-function EWorldEditor::createSelectedAsSubScene( %this, %object )
-{
-   //create new level asset here
-   AssetBrowser.setupCreateNewAsset("SubScene", AssetBrowser.selectedModule, "finishCreateSelectedAsSubScene");
-   %this.contextActionObject = %object;
-}
-
-function finishCreateSelectedAsSubScene(%assetId)
-{
-   echo("finishCreateSelectedAsSubScene");
-   
-   %subScene = new SubScene() {
-      levelAsset = %assetId;
-   };
-   
-   %levelAssetDef = AssetDatabase.acquireAsset(%assetId);
-   %levelFilePath = %levelAssetDef.getLevelPath();
-   
-   //write out to file
-   EWorldEditor.contextActionObject.save(%levelFilePath);
-   
-   AssetDatabase.releaseAsset(%assetId);
-   
-   getRootScene().add(%subScene);
-   
-   EWorldEditor.contextActionObject.delete();
-   
-   %subScene.load();
-   
-   %subScene.recalculateBounds();
-   
-   %scalar = $SubScene::createScalar;
-   if(%scalar $= "")
-      %scalar = 1.5;
-   
-   //pad for loading boundary
-   %subScene.scale = VectorScale(%subScene.scale, %scalar);
-}
-
-function GuiInspectorTypeLevelAssetPtr::onControlDropped( %this, %payload, %position )
-{
-   Canvas.popDialog(EditorDragAndDropLayer);
-   
-   // Make sure this is a color swatch drag operation.
-   if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
-      return;
-
-   %assetType = %payload.assetType;
-   %module = %payload.moduleName;
-   %assetName = %payload.assetName;
-   
-   if(%assetType $= "LevelAsset")
-   {
-      %cmd = %this @ ".apply(\""@ %module @ ":" @ %assetName @ "\");";
-      eval(%cmd);
-   }
-   
-   EWorldEditor.isDirty = true;
-}
-
-function AssetBrowser::onLevelAssetEditorDropped(%this, %assetDef, %position)
-{
-   %assetId = %assetDef.getAssetId();
-   
-   if(!%assetDef.isSubScene)
-   {
-      errorf("Cannot drag-and-drop LevelAsset into WorldEditor");
-      return;  
-   }
-   
-   %newSubScene = new SubScene()
-   {
-      position = %position;
-      levelAsset = %assetId;
-   };
-   
-   getScene(0).add(%newSubScene);
-   
-   %newSubScene.load();
-   %newSubScene.recalculateBounds();
-   
-   EWorldEditor.clearSelection();
-   EWorldEditor.selectObject(%newSubScene);
-   
-   EWorldEditor.dropSelection();
-      
-   EWorldEditor.isDirty = true;
-   
-   MECreateUndoAction::submit(%newSubScene );
+      "Asset Definition ID: " @ %this @ "\n" @ 
+      "Level File path: " @ %this.getLevelPath(); 
 }
 }

+ 10 - 7
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/looseFiles.tscript

@@ -1,14 +1,17 @@
-function AssetBrowser::buildLooseFilePreview(%this, %assetDef, %previewData)
+AssetBrowser::registerFileType("NonAssetLooseFile", "Loose Files", "-");
+
+function NonAssetLooseFile::buildBrowserElement(%filePath, %previewData)
 {
 {
-   %fullPath = %assetDef.dirPath @ "/" @ %assetDef.assetName;
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %fullPath;
+   %fileName = fileName(%filePath);
+   
+   %previewData.assetName = %fileName;
+   %previewData.assetPath = %filePath;
    
    
    %previewData.previewImage = "ToolsModule:looseFileIcon_image";
    %previewData.previewImage = "ToolsModule:looseFileIcon_image";
    
    
    //%previewData.assetFriendlyName = %assetDef.assetName;
    //%previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %fullPath;
+   %previewData.assetDesc = %filePath;
+   %previewData.tooltip = %filePath;
    //%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
    //%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
-   %previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %fullPath @ "\");";
+   //%previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %fullPath @ "\");";
 }
 }

+ 39 - 408
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.tscript

@@ -1,4 +1,6 @@
-function AssetBrowser::createMaterialAsset(%this)
+AssetBrowser::registerAssetType("MaterialAsset", "Materials"); 
+
+function MaterialAsset::createMaterialAsset(%this)
 {
 {
    %assetName = AssetBrowser.newAssetSettings.assetName;
    %assetName = AssetBrowser.newAssetSettings.assetName;
    
    
@@ -33,15 +35,15 @@ function AssetBrowser::createMaterialAsset(%this)
 	return %tamlpath;
 	return %tamlpath;
 }
 }
 
 
-function AssetBrowser::editMaterialAsset(%this, %assetDef)
+function MaterialAsset::onEdit(%this)
 {
 {
-   %assetDef.materialDefinitionName.reload();
+   %this.materialDefinitionName.reload();
    
    
    EditorGui.setEditor(MaterialEditorPlugin);
    EditorGui.setEditor(MaterialEditorPlugin);
    
    
-   MaterialEditorGui.currentMaterialAsset = %assetDef.getAssetId();
-   MaterialEditorGui.currentMaterial = %assetDef.materialDefinitionName;
-   MaterialEditorGui.setActiveMaterial( %assetDef.materialDefinitionName );
+   MaterialEditorGui.currentMaterialAsset = %this.getAssetId();
+   MaterialEditorGui.currentMaterial = %this.materialDefinitionName;
+   MaterialEditorGui.setActiveMaterial( %this.materialDefinitionName );
    
    
    AssetBrowser.hideDialog();
    AssetBrowser.hideDialog();
 }
 }
@@ -60,451 +62,82 @@ function AssetBrowser::renameMaterialAsset(%this, %assetDef, %newAssetName)
    renameAssetFile(%assetDef, %newAssetName);
    renameAssetFile(%assetDef, %newAssetName);
 }
 }
 
 
-//Deletes the asset
-function AssetBrowser::deleteMaterialAsset(%this, %assetDef)
-{
-   AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
-}
-
-//Moves the asset to a new path/module
-function AssetBrowser::moveMaterialAsset(%this, %assetDef, %destination)
-{
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
-}
-
-function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
-{
-   ImportActivityLog.add("Preparing Material for Import: " @ %assetItem.assetName);
-   
-   //Iterate over to find appropriate images for
-         
-   //Fetch just the fileBase name
-   %fileDir = filePath(%assetItem.filePath);
-   %fileName = fileBase(%assetItem.filePath);
-   %fileExt = fileExt(%assetItem.filePath);
-   
-   %assetItem.generatedAsset = true;
-   
-   //Check if we need to filter this material out or not
-   if(getAssetImportConfigValue("Materials/IgnoreMaterials", "") !$= "")
-   {
-      %ignoredMatNamesCount = getTokenCount(getAssetImportConfigValue("Materials/IgnoreMaterials", ""), ",;");
-      for(%i=0; %i < %ignoredMatNamesCount; %i++)
-      {
-        %ignoreName = getToken(getAssetImportConfigValue("Materials/IgnoreMaterials", ""), ",;", %i);
-        
-        if(strIsMatchExpr(%ignoreName, %fileName))
-        {
-            //We fit the bill, ignore this material and skip it
-            %assetItem.skip = true;
-            
-            ImportActivityLog.add(%assetItem.assetName @ " has been ignored due to config Materials/IgnoreMaterials settings");
-            
-            return;  
-        }
-      }
-   }
-   
-   if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "1") == 1)
-   {
-      ImportActivityLog.add("Attempting to Auto-Populate Material Maps");
-      
-      for(%i=0; %i < %assetItem.childAssetItems.count(); %i++)
-      {
-         %childAssetItem = %assetItem.childAssetItems.getKey(%i);
-         
-         if(!isObject(%childAssetItem) || %childAssetItem.skip || %childAssetItem.processed == true || %childAssetItem.assetType !$= "ImageAsset")
-            return;
-            
-         if(%childAssetItem.imageType $= "Albedo")
-         {
-            %assetItem.diffuseImageAsset = %childAssetItem;
-         }
-      }
-      
-      /*%materialItemId = ImportAssetTree.findItemByObjectId(%assetItem);
-      
-      if(%assetItem.diffuseImageAsset $= "")
-      {
-         %diffuseTypeSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", "");
-         
-         %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %diffuseTypeSuffixes);
-         
-         if(%targetFilePath !$= "")
-         {
-            ImportActivityLog.add("Auto-Populated Diffuse Map Image Asset via file: " @ %targetFilePath);
-            
-            %diffuseAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
-            %assetItem.diffuseImageAsset = %diffuseAsset;
-         }
-      }
-      
-      //Now, iterate over our comma-delimited suffixes to see if we have any matches. We'll use the first match in each case, if any.
-      if(%assetItem.normalImageAsset $= "")
-      {
-         %normalTypeSuffixes = getAssetImportConfigValue("Images/NormalTypeSuffixes", "");
-         
-         //First, normal map
-         %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %normalTypeSuffixes);
-         
-         if(%targetFilePath !$= "")
-         {
-            ImportActivityLog.add("Auto-Populated Normal Map Image Asset via file: " @ %targetFilePath);
-            
-            %normalAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
-            %assetItem.normalImageAsset = %normalAsset;
-         }
-      }
-      
-      if(%assetItem.metalImageAsset $= "")
-      {
-         %metalnessTypeSuffixes = getAssetImportConfigValue("Images/MetalnessTypeSuffixes", "");
-         
-         %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %metalnessTypeSuffixes);
-         
-         if(%targetFilePath !$= "")
-         {
-            ImportActivityLog.add("Auto-Populated Metalness Map Image Asset via file: " @ %targetFilePath);
-            
-            %metalAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
-            %assetItem.metalImageAsset = %metalAsset;
-         }
-      }
-      
-      if(%assetItem.roughnessImageAsset $= "")
-      {
-         %roughnessTypeSuffixes = getAssetImportConfigValue("Images/RoughnessTypeSuffixes", "");
-         
-         %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %roughnessTypeSuffixes);
-         
-         if(%targetFilePath !$= "")
-         {
-            ImportActivityLog.add("Auto-Populated Roughness Map Image Asset via file: " @ %targetFilePath);
-            
-            %roughnessAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
-            %assetItem.roughnessImageAsset = %roughnessAsset;
-         }
-      }
-      
-      if(%assetItem.smoothnessImageAsset $= "")
-      {
-         %smoothnessTypeSuffixes = getAssetImportConfigValue("Images/SmoothnessTypeSuffixes", "");
-         
-         %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %smoothnessTypeSuffixes);
-         
-         if(%targetFilePath !$= "")
-         {
-            ImportActivityLog.add("Auto-Populated Smoothness Map Image Asset via file: " @ %targetFilePath);
-            
-            %smoothnessAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
-            %assetItem.SmoothnessImageAsset = %smoothnessAsset;
-         }
-      }
-      
-      if(%assetItem.AOImageAsset $= "")
-      {
-         %aoTypeSuffixes = getAssetImportConfigValue("Images/AOTypeSuffixes", "");
-         
-         %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %aoTypeSuffixes);
-         
-         if(%targetFilePath !$= "")
-         {
-            ImportActivityLog.add("Auto-Populated AO Map Image Asset via file: " @ %targetFilePath);
-            
-            %AOAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
-            %assetItem.AOImageAsset = %AOAsset;
-         }
-      }
-      
-      if(%assetItem.compositeImageAsset $= "")
-      {
-         %compositeTypeSuffixes = getAssetImportConfigValue("Images/CompositeTypeSuffixes", "");
-         
-         %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %compositeTypeSuffixes);
-         
-         if(%targetFilePath !$= "")
-         {
-            ImportActivityLog.add("Auto-Populated Composite Map Image Asset via file: " @ %targetFilePath);
-            
-            %compositeAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
-            %assetItem.compositeImageAsset = %compositeAsset;
-         }
-      }
-      
-      //If after the above we didn't find any, check to see if we should be generating one
-      if(%assetItem.compositeImageAsset $= "" && 
-         (%assetItem.roughnessImageAsset !$= "" || %assetItem.AOImageAsset !$= "" || %assetItem.metalnessImageAsset !$= "") &&
-         getAssetImportConfigValue("Materials/CreateComposites", "1") == 1)
-      {
-         %assetItem.roughnessImageAsset.skip = true;
-         %assetItem.AOImageAsset.skip = true;
-         %assetItem.metalnessImageAsset.skip = true;
-         
-         %compositeAssetPath = AssetBrowser.dirHandler.currentAddress @ "/";
-         %saveAsPath = %compositeAssetPath @ "/" @ %assetItem.assetName @ "_composite.png";
-         
-         ImportActivityLog.add("Auto-Generated Composite Map from ORM maps");
-         
-         %compositeAsset = AssetBrowser.addImportingAsset("ImageAsset", "", %assetItem, %assetItem.assetName @ "_composite");
-         %compositeAsset.generatedAsset = true;
-         %compositeAsset.filePath = %saveAsPath;
-         
-         %assetItem.compositeImageAsset = %compositeAsset;
-      }*/
-   }
-   
-   %assetItem.processed = true;
-   
-   refreshImportAssetWindow();
-}
-
-function AssetBrowser::findMaterialMapFileWSuffix(%this, %fileDir, %filename, %fileExt, %suffixesList)
-{
-   %listCount = getTokenCount(%suffixesList, ",;");
-   
-   %foundFile = 0;
-   %filePath = "";
-   for(%i=0; %i < %listCount; %i++)
-   {
-      %entryText = getToken(%suffixesList, ",;", %i);
-      
-      if(%fileExt $= "")
-      {
-         %filePath = findFirstFile(%fileDir @ "/" @ %filename @ %entryText @ ".*");
-         %foundFile = isFile(%filePath);
-      }
-      else
-      {
-         %filePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt;
-         %foundFile = isFile(%filePath);
-      }
-      
-      if(%foundFile)
-      {
-         return %filePath;
-      }
-   }
-   
-   return "";
-}
-
-function AssetBrowser::importMaterialAsset(%this, %assetItem)
-{
-   %moduleName = AssetImportTargetModule.getText();
-   
-   %assetType = %assetItem.AssetType;
-   %filePath = %assetItem.filePath;
-   %assetName = %assetItem.assetName;
-   %assetImportSuccessful = false;
-   %assetId = %moduleName@":"@%assetName;
-   
-   %assetPath = NewAssetTargetAddress.getText() @ "/";
-   %tamlpath = %assetPath @ %assetName @ ".asset.taml";
-   %sgfPath = %assetPath @ %assetName @ ".sgf";
-   %scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
-   
-   %newAsset = new MaterialAsset()
-   {
-      assetName = %assetName;
-      versionId = 1;
-      shaderGraph = %sgfPath;
-      scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
-      materialDefinitionName = %assetName;
-   };
-   
-   //No point in indicating the original path data if it was imported in-place
-   %mainPath = getMainDotCsDir();
-   if(!startsWith(makeFullPath(%filePath), getMainDotCsDir()))
-   {
-      %newAsset.originalFilePath = %filePath;
-   }
-   
-   //check dependencies
-   %dependencySlotId = 0;
-   for(%i=0; %i < %assetItem.childAssetItems.count(); %i++)
-   {
-      %childAssetItem = %assetItem.childAssetItems.getKey(%i);
-      
-      if(!isObject(%childAssetItem) || %childAssetItem.skip || %childAssetItem.processed == false)
-         continue;
-
-      %depAssetType = %childAssetItem.assetType;
-      if(%depAssetType $= "ImageAsset")
-      {
-         %matSet = "%newAsset.imageMap"@%dependencySlotId@"=\"@asset="@%moduleName@":"@%childAssetItem.assetName@"\";";
-         eval(%matSet);
-         %dependencySlotId++;
-      }
-   }
-   
-   %assetImportSuccessful = TamlWrite(%newAsset, %tamlpath);
-   
-   //if we're set to save a composite image, we do that first
-   if(getAssetImportConfigValue("Materials/CreateComposites", "1") == 1)
-   {
-      //don't save a composite if we've already got one bound
-      if(%assetItem.compositeImageAsset !$= "" && %assetItem.compositeImageAsset.generatedAsset)
-      {
-         if(%assetItem.roughnessImageAsset !$= "" || %assetItem.AOImageAsset !$= "" || %assetItem.metalnessImageAsset !$= "")
-         {
-            %channelKey = "0 1 2 3";
-            
-            saveCompositeTexture(%assetItem.AOImageAsset.filePath,
-                                 %assetItem.roughnessImageAsset.filePath,
-                                 %assetItem.metalnessImageAsset.filePath,"",
-                                 %channelKey, 
-                                 %assetItem.compositeImageAsset.filePath); 
-                                 
-            %compositeAssetId = %moduleName @ ":" @ assetItem.compositeImageAsset.assetName;
-            AssetDatabase.refreshAsset(%compositeAssetId);
-         }
-      }
-   }
-   
-   %file = new FileObject();
-
-   if(%file.openForWrite(%scriptPath))
-   {
-      %file.writeline("//--- OBJECT WRITE BEGIN ---");
-      %file.writeline("singleton Material(" @ %assetName @ ") {");
-      
-      //TODO: pass along the shape's target material for this just to be sure
-      %file.writeLine("   mapTo = \"" @ %assetName @ "\";"); 
-      
-      //now we re-iterate back over our child items so we can map them correctly
-      for(%i=0; %i < %assetItem.childAssetItems.count(); %i++)
-      {
-         %childAssetItem = %assetItem.childAssetItems.getKey(%i);
-         
-         if(!isObject(%childAssetItem) || %childAssetItem.skip || %childAssetItem.processed == false)
-            continue;
-
-         if(%childAssetItem.assetType $= "ImageAsset")
-         {
-            %mapFieldName = "";
-            if(%childAssetItem.imageType $= "Albedo")
-               %mapFieldName = "DiffuseMap";
-            else if(%childAssetItem.imageType $= "Normal")
-               %mapFieldName = "NormalMap";
-            else if(%childAssetItem.imageType $= "Metalness")
-               %mapFieldName = "MetalMap";
-            else if(%childAssetItem.imageType $= "Roughness")
-               %mapFieldName = "RoughnessMap";
-            else if(%childAssetItem.imageType $= "AO")
-               %mapFieldName = "AOMap";
-            else if(%childAssetItem.imageType $= "Composite")
-               %mapFieldName = "ORMConfigMap";
-            
-            %path = fileName(%childAssetItem.filePath);
-            %file.writeline("   "@ %mapFieldName @ "[0] = \"" @ %path @"\";");
-            %file.writeline("   "@ %mapFieldName @ "Asset[0] = \"" @ %moduleName @ ":" @ %childAssetItem.assetName @"\";");
-         }
-      }
-      %file.writeline("};");
-      %file.writeline("//--- OBJECT WRITE END ---");
-      
-      %file.close();
-   }
-   
-   %moduleDef = ModuleDatabase.findModule(%moduleName,1);
-         
-   if(!AssetBrowser.isAssetReImport)
-      AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
-   else
-      AssetDatabase.refreshAsset(%assetId);
-}
-
-function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate)
+function MaterialAsset::buildBrowserElement(%this, %previewData)
 {   
 {   
    %previewData.previewImage = "ToolsModule:genericAssetIcon_image";
    %previewData.previewImage = "ToolsModule:genericAssetIcon_image";
    %previewData.previewLoaded = false; //this marks it for loading progressively later
    %previewData.previewLoaded = false; //this marks it for loading progressively later
       
       
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.scriptFile;
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.scriptFile;
    
    
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
 
 
    if(%this.selectMode)
    if(%this.selectMode)
-      %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
+      %previewData.doubleClickCommand = $CurrentAssetBrowser @ ".selectAsset( " @ $CurrentAssetBrowser @ ".selectedAsset );";
    else
    else
-      %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );";
+      %previewData.doubleClickCommand = $CurrentAssetBrowser @ ".editAsset( "@%this@" );";
       
       
-   %definitionPath = %assetDef.getScriptPath();
+   %definitionPath = %this.getScriptPath();
    if(%definitionPath $= "")
    if(%definitionPath $= "")
-      %definitionPath = %assetDef.getFilename();
+      %definitionPath = %this.getFilename();
    
    
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ 
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ 
                            "\nAsset Type: Material Asset" @  
                            "\nAsset Type: Material Asset" @  
-                           "\nAsset Definition ID: " @  %assetDef @
+                           "\nAsset Definition ID: " @  %this @
                            "\nDefinition Path: " @ %definitionPath;
                            "\nDefinition Path: " @ %definitionPath;
                            
                            
-   if(!%this.selectMode)
+   if(!$CurrentAssetBrowser.selectMode)
    {
    {
-      %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );";
+      %previewData.doubleClickCommand = $CurrentAssetBrowser @ ".editAsset( "@%this@" );";
    }
    }
 }
 }
 
 
-function AssetBrowser::generateMaterialAssetPreviewImage(%this, %previewButton, %forceRegenerate)
+function MaterialAsset::generatePreviewImage(%this, %previewButton, %forceRegenerate)
 {
 {
    if(%forceRegenerate $= "")
    if(%forceRegenerate $= "")
       %forceRegenerate = false;
       %forceRegenerate = false;
       
       
-   %assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName;
-      
-   %assetDef = AssetDatabase.acquireAsset(%assetId);
-      
-   %module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%assetDef.getAssetId()))));
+   %module = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%this.getAssetId()))));
    %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/";
    %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/";
 
 
    if(!IsDirectory(%previewPath))
    if(!IsDirectory(%previewPath))
    {
    {
-      %this.dirHandler.createFolder(%previewPath);
+      $CurrentAssetBrowser.dirHandler.createFolder(%previewPath);
    }
    }
 
 
    %generatePreview = false;
    %generatePreview = false;
 
 
-   %previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.dds";
+   %previewFilePath = %previewPath @ %this.assetName @ "_Preview.dds";
    if(!isFile(%previewFilePath))
    if(!isFile(%previewFilePath))
    {
    {
       %generatePreview = true;
       %generatePreview = true;
    }
    }
    else
    else
    {
    {
-      if(isObject(%assetDef.materialDefinitionName))
+      if(isObject(%this.materialDefinitionName))
       {
       {
-         if(compareFileTimes(%assetDef.materialDefinitionName.getDiffuseMap(0), %previewFilePath) == 1 ||
-            compareFileTimes(%assetDef.materialDefinitionName.getFilename(), %previewFilePath) == 1)
+         if(compareFileTimes(%this.materialDefinitionName.getDiffuseMap(0), %previewFilePath) == 1 ||
+            compareFileTimes(%this.materialDefinitionName.getFilename(), %previewFilePath) == 1)
             %generatePreview = true;
             %generatePreview = true;
       }
       }
    }
    }
 
 
-   %previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage";
+   %previewAssetName = %module.moduleId @ "_" @ %this.assetName @ "_PreviewImage";
                                    
                                    
    if(%generatePreview || %forceRegenerate)
    if(%generatePreview || %forceRegenerate)
    {
    {
-      if(isObject(%assetDef.materialDefinitionName))
+      if(isObject(%this.materialDefinitionName))
       {
       {
          //real fast, we'll be 100% sure that the image resource we need is loaded
          //real fast, we'll be 100% sure that the image resource we need is loaded
-         %diffuseMapAssetId = %assetDef.materialDefinitionName.getDiffuseMapAsset(0);
+         %diffuseMapAssetId = %this.materialDefinitionName.getDiffuseMapAsset(0);
          if(AssetDatabase.isDeclaredAsset(%diffuseMapAssetId))
          if(AssetDatabase.isDeclaredAsset(%diffuseMapAssetId))
          {
          {
             %diffuseMapAsset = AssetDatabase.acquireAsset(%diffuseMapAssetId);
             %diffuseMapAsset = AssetDatabase.acquireAsset(%diffuseMapAssetId);
             AssetDatabase.releaseAsset(%diffuseMapAssetId);
             AssetDatabase.releaseAsset(%diffuseMapAssetId);
          }
          }
          %previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape");
          %previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape");
-         %generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, %assetDef.materialDefinitionName);
+         %generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, %this.materialDefinitionName);
       
       
          pathCopy(%generatedFilePath, %previewFilePath, false);
          pathCopy(%generatedFilePath, %previewFilePath, false);
          fileDelete(%generatedFilePath);
          fileDelete(%generatedFilePath);
@@ -548,7 +181,7 @@ function AssetBrowser::generateMaterialAssetPreviewImage(%this, %previewButton,
    return false;
    return false;
 }
 }
 
 
-function AssetBrowser::onMaterialAssetEditorDropped(%this, %assetDef, %position)
+function MaterialAsset::onWorldEditorDropped(%this, %position)
 {
 {
    //echo("DROPPED A SHAPE ON THE EDITOR WINDOW!"); 
    //echo("DROPPED A SHAPE ON THE EDITOR WINDOW!"); 
    //first, see if we hit a static shape
    //first, see if we hit a static shape
@@ -558,26 +191,24 @@ function AssetBrowser::onMaterialAssetEditorDropped(%this, %assetDef, %position)
    %camPos = LocalClientConnection.camera.getPosition();
    %camPos = LocalClientConnection.camera.getPosition();
    %rayResult = materialRayCast(%camPos, %targetPosition, -1, 0, false);
    %rayResult = materialRayCast(%camPos, %targetPosition, -1, 0, false);
    
    
-   %validTarget = false;
    if(%rayResult != 0)
    if(%rayResult != 0)
    {
    {
       %obj = getWord(%rayResult, 0);
       %obj = getWord(%rayResult, 0);
       if(%obj.isMemberOfClass("TSStatic"))
       if(%obj.isMemberOfClass("TSStatic"))
       {
       {
          //oh, cool a valid target! 
          //oh, cool a valid target! 
-         %obj.materialSlot0 = %assetDef.getAssetId();
-         echo("MaterialSlot0 set to " @ %assetDef.getAssetId());
+         %obj.materialSlot0 = %this.getAssetId();
+         //echo("MaterialSlot0 set to " @ %this.getAssetId());
       }
       }
       else if(%obj.isField("materialAsset"))
       else if(%obj.isField("materialAsset"))
       {
       {
-         %obj.materialAsset = %assetDef.getAssetId();
-         echo("materialAsset set to " @ %assetDef.getAssetId());
+         %obj.materialAsset = %this.getAssetId();
+         //echo("materialAsset set to " @ %this.getAssetId());
       }
       }
       %obj.inspectPostApply();
       %obj.inspectPostApply();
+      
+      EWorldEditor.isDirty = true;
    }
    }
-
-   EWorldEditor.isDirty = true;
-   
 }
 }
 
 
 function GuiInspectorTypeMaterialAssetPtr::onControlDropped( %this, %payload, %position )
 function GuiInspectorTypeMaterialAssetPtr::onControlDropped( %this, %payload, %position )

+ 0 - 0
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/particle.tscript


+ 70 - 60
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/postFX.tscript

@@ -1,8 +1,10 @@
-function AssetBrowser::createPostEffectAsset(%this)
+AssetBrowser::registerAssetType("PostEffectAsset", "Post Effects");
+
+function PostEffectAsset::onCreateNew()
 {
 {
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
+   %moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
       
       
-   %assetName = AssetBrowser.newAssetSettings.assetName;   
+   %assetName = $CurrentAssetBrowser.newAssetSettings.assetName;   
    %assetPath = NewAssetTargetAddress.getText() @ "/";
    %assetPath = NewAssetTargetAddress.getText() @ "/";
    
    
    %tamlpath = %assetPath @ %assetName @ ".asset.taml";
    %tamlpath = %assetPath @ %assetName @ ".asset.taml";
@@ -27,7 +29,7 @@ function AssetBrowser::createPostEffectAsset(%this)
    %file = new FileObject();
    %file = new FileObject();
 	%templateFile = new FileObject();
 	%templateFile = new FileObject();
 	
 	
-   %postFXTemplateCodeFilePath = %this.templateFilesPath @ "postFXFile." @ $TorqueScriptFileExtension @ ".template";
+   %postFXTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "postFXFile." @ $TorqueScriptFileExtension @ ".template";
    
    
    if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
    if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
    {
    {
@@ -37,7 +39,7 @@ function AssetBrowser::createPostEffectAsset(%this)
          %line = strreplace( %line, "@@", %assetName );
          %line = strreplace( %line, "@@", %assetName );
          
          
          %file.writeline(%line);
          %file.writeline(%line);
-         echo(%line);
+         //echo(%line);
       }
       }
       
       
       %file.close();
       %file.close();
@@ -48,11 +50,11 @@ function AssetBrowser::createPostEffectAsset(%this)
       %file.close();
       %file.close();
       %templateFile.close();
       %templateFile.close();
       
       
-      warnf("CreatePostFXAsset - Something went wrong and we couldn't write the PostFX script file!");
+      warn("PostEffectAsset::onCreateNew() - Something went wrong and we couldn't write the PostFX script file!");
    }
    }
    
    
    //hlsl shader
    //hlsl shader
-   %postFXTemplateCodeFilePath = %this.templateFilesPath @ "postFXFileP.hlsl.template";
+   %postFXTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "postFXFileP.hlsl.template";
    
    
    if(%file.openForWrite(%hlslPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
    if(%file.openForWrite(%hlslPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
    {
    {
@@ -62,7 +64,7 @@ function AssetBrowser::createPostEffectAsset(%this)
          %line = strreplace( %line, "@@", %assetName );
          %line = strreplace( %line, "@@", %assetName );
          
          
          %file.writeline(%line);
          %file.writeline(%line);
-         echo(%line);
+         //echo(%line);
       }
       }
       
       
       %file.close();
       %file.close();
@@ -73,11 +75,11 @@ function AssetBrowser::createPostEffectAsset(%this)
       %file.close();
       %file.close();
       %templateFile.close();
       %templateFile.close();
       
       
-      warnf("CreatePostFXAsset - Something went wrong and we couldn't write the PostFX hlsl file!");
+      warn("PostEffectAsset::onCreateNew() - Something went wrong and we couldn't write the PostFX hlsl file!");
    }
    }
    
    
    //glsl shader
    //glsl shader
-   %postFXTemplateCodeFilePath = %this.templateFilesPath @ "postFXFileP.glsl.template";
+   %postFXTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "postFXFileP.glsl.template";
    
    
    if(%file.openForWrite(%glslPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
    if(%file.openForWrite(%glslPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
    {
    {
@@ -87,7 +89,7 @@ function AssetBrowser::createPostEffectAsset(%this)
          %line = strreplace( %line, "@@", %assetName );
          %line = strreplace( %line, "@@", %assetName );
          
          
          %file.writeline(%line);
          %file.writeline(%line);
-         echo(%line);
+         //echo(%line);
       }
       }
       
       
       %file.close();
       %file.close();
@@ -98,72 +100,80 @@ function AssetBrowser::createPostEffectAsset(%this)
       %file.close();
       %file.close();
       %templateFile.close();
       %templateFile.close();
       
       
-      warnf("CreatePostFXAsset - Something went wrong and we couldn't write the PostFX glsl file!");
+      warn("PostEffectAsset::onCreateNew() - Something went wrong and we couldn't write the PostFX glsl file!");
    }
    }
    
    
 	return %tamlpath;
 	return %tamlpath;
 }
 }
 
 
-//Renames the asset
-function AssetBrowser::renamePostEffectAsset(%this, %assetDef, %newAssetName)
+function PostEffectAsset::buildBrowserElement(%this, %previewData)
 {
 {
-   %newScriptFilename = renameAssetLooseFile(%assetDef.scriptPath, %newAssetName);
-   
-   if(!%newScriptFilename $= "")
-      return;
-      
-   %newHLSLFilename = renameAssetLooseFile(%assetDef.hlslShader, %newAssetName);
-   
-   if(!%newHLSLFilename $= "")
-      return;
-      
-   %newGLSLFilename = renameAssetLooseFile(%assetDef.glslShader, %newAssetName);
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.scriptFilePath;
+   %previewData.doubleClickCommand = "";
    
    
-   if(!%newGLSLFilename $= "")
-      return;
-      
-   %assetDef.scriptPath = %newScriptFilename;
-   %assetDef.hlslShader = %newHLSLFilename;
-   %assetDef.glslShader = %newGLSLFilename;
-   %assetDef.saveAsset();
+   %previewData.previewImage = "ToolsModule:postEffectIcon_image";
    
    
-   renameAssetFile(%assetDef, %newAssetName);
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ 
+                          "\nDefinition Path: " @ %this.getFilename();
 }
 }
 
 
-//Deletes the asset
-function AssetBrowser::deletePostEffectAsset(%this, %assetDef)
+function PostEffectAsset::onShowActionMenu(%this)
 {
 {
-   AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
-}
+   GenericAsset::onShowActionMenu(%this);
+   
+   if( !isObject( EditPostFXAssetSubmenuPopup ) )
+   {
+      new PopupMenu( EditPostFXAssetSubmenuPopup )
+      {
+         superClass = "MenuBuilder";
+         class = "EditorWorldMenu";
 
 
-//Moves the asset to a new path/module
-function AssetBrowser::movePostEffectAsset(%this, %assetDef, %destination)
-{
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
+         jumpFileName = "";
+         jumpLineNumber = "";
+      };
+   }
    
    
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
+   //Regen the menu so we're fully up and current with options and references
+   EditPostFXAssetSubmenuPopup.clearItems();
    
    
-   if(%newAssetPath $= "")
-      return false;
+   EditPostFXAssetSubmenuPopup.item[ 0 ] = "Script file" TAB "" TAB %this @ ".onEditScriptFile();";
+   EditPostFXAssetSubmenuPopup.item[ 1 ] = "HLSL file" TAB "" TAB %this @ ".onEditHLSLFile();";
+   EditPostFXAssetSubmenuPopup.item[ 2 ] = "GLSL file" TAB "" TAB %this @ ".onEditHLSLFile();";
 
 
-   moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
-   moveAssetLooseFile(%assetDef.getHLSLShaderPath(), %destination);
-   moveAssetLooseFile(%assetDef.getGLSLShaderPath(), %destination);
+   EditPostFXAssetSubmenuPopup.reloadItems();
    
    
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
+   EditAssetPopup.item[ 0 ] = "Edit PostFX Asset Files" TAB EditPostFXAssetSubmenuPopup;
+   
+   EditAssetPopup.reloadItems();
+   
+   EditAssetPopup.showPopup(Canvas); 
+   
+   $CurrentAssetBrowser.popupMenu = EditAssetPopup;
 }
 }
 
 
-function AssetBrowser::buildPostEffectAssetPreview(%this, %assetDef, %previewData)
+function PostEffectAsset::onEditScriptFile(%this)
 {
 {
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.scriptFilePath;
-   %previewData.doubleClickCommand = "";
-   
-   %previewData.previewImage = "ToolsModule:postEffectIcon_image";
-   
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getFilename();
+   if(isFunction("systemCommand"))
+      eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getScriptPath() @ "\\\"\");");
+   else  
+      warn("PostEffectAsset::onEditScriptFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
+}
+
+function PostEffectAsset::onEditHLSLFile(%this)
+{
+   if(isFunction("systemCommand"))
+      eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getHLSLShaderPath() @ "\\\"\");");
+   else  
+      warn("PostEffectAsset::onEditHLSLFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
+}
+
+function PostEffectAsset::onEditGLSLFile(%this)
+{
+   if(isFunction("systemCommand"))
+      eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getGLSLShaderPath() @ "\\\"\");");
+   else  
+      warn("PostEffectAsset::onEditGLSLFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
 }
 }

+ 18 - 30
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/prefab.tscript

@@ -1,9 +1,11 @@
-function AssetBrowser::createPrefab(%this)
+AssetBrowser::registerFileType("PrefabFileType", "Prefabs", ".prefab");
+
+function PrefabFileType::onCreateNew()
 {
 {
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
+   %moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
    %modulePath = "data/" @ %moduleName;
    %modulePath = "data/" @ %moduleName;
       
       
-   %assetName = AssetBrowser.newAssetSettings.assetName;  
+   %assetName = $CurrentAssetBrowser.newAssetSettings.assetName;  
    
    
    %assetPath = NewAssetTargetAddress.getText() @ "/";    
    %assetPath = NewAssetTargetAddress.getText() @ "/";    
    
    
@@ -13,46 +15,32 @@ function AssetBrowser::createPrefab(%this)
    EWorldEditor.makeSelectionPrefab( %prefabFilePath );    
    EWorldEditor.makeSelectionPrefab( %prefabFilePath );    
    
    
    EditorTree.buildVisibleTree( true ); 
    EditorTree.buildVisibleTree( true ); 
+   
+   $CurrentAssetBrowser.refresh();
 }
 }
 
 
-function AssetBrowser::buildPrefabPreview(%this, %assetDef, %previewData)
+function PrefabFileType::buildBrowserElement(%filePath, %previewData)
 {
 {
-   %fullPath = %assetDef.dirPath @ "/" @ %assetDef.assetName;
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %fullPath;
+   %previewData.assetName = fileName(%filePath);
+   %previewData.assetPath = %filePath;
+   
+   echo("PrefabFileType::buildBrowserElement() - name, path: " @ %previewData.assetName @ ", " @ %filePath);
    
    
    %previewData.previewImage = "ToolsModule:prefabIcon_image";
    %previewData.previewImage = "ToolsModule:prefabIcon_image";
    
    
    //%previewData.assetFriendlyName = %assetDef.assetName;
    //%previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %fullPath;
+   %previewData.assetDesc = %filePath;
+   %previewData.tooltip = %filePath;
    //%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
    //%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
-   %previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %fullPath @ "\");";
+   %previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %filePath @ "\");";
 }
 }
 
 
-function AssetBrowser::onPrefabEditorDropped(%this, %assetDef, %position)
+function PrefabFileType::onWorldEditorDropped(%filePath, %position)
 {
 {
-   //echo("DROPPED A SHAPE ON THE EDITOR WINDOW!"); 
-
-   %targetPosition = EWorldEditor.unproject(%position SPC 1);
-   %camPos = LocalClientConnection.camera.getPosition();
-   %rayResult = containerRayCast(%camPos, %targetPosition, -1);
-   
-   %pos = ObjectCreator.getCreateObjectPosition();
-
-   if(%rayResult != 0)
-   {
-      %pos = getWords(%rayResult, 1, 3);
-   }
-   else
-   {
-      %pos = "0 0 0";  
-   }
-   
    %newPrefab = new Prefab()
    %newPrefab = new Prefab()
    {
    {
-      position = %pos;
-      fileName = %assetDef;
+      position = %position;
+      fileName = %filePath;
    };
    };
    
    
    getScene(0).add(%newPrefab);
    getScene(0).add(%newPrefab);

+ 93 - 65
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/script.tscript

@@ -1,9 +1,12 @@
-function AssetBrowser::createScriptAsset(%this)
+AssetBrowser::registerFileType("ScriptFileType", "Script Files", ".tscript;.cs;.dso;.tscript.dso;.cs.dso", false);
+AssetBrowser::registerAssetType("ScriptAsset", "Scripts");
+
+function ScriptAsset::onCreateNew()
 {
 {
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
+   %moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
    %modulePath = "data/" @ %moduleName;
    %modulePath = "data/" @ %moduleName;
       
       
-   %assetName = AssetBrowser.newAssetSettings.assetName;  
+   %assetName = $CurrentAssetBrowser.newAssetSettings.assetName;  
    
    
    %assetPath = NewAssetTargetAddress.getText() @ "/";    
    %assetPath = NewAssetTargetAddress.getText() @ "/";    
    
    
@@ -32,97 +35,122 @@ function AssetBrowser::createScriptAsset(%this)
 	return %tamlpath;
 	return %tamlpath;
 }
 }
 
 
-function AssetBrowser::editScriptAsset(%this, %assetDef)
+function ScriptAsset::onEdit(%this)
 {
 {
-   %scriptFile = %assetDef.scriptFile;
+   %scriptFile = %this.scriptFile;
    
    
-   //EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);
+   if(isFunction("systemCommand"))
+      eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.fileName @ "\\\"\");");
+   else  
+      warn("ScriptAsset::onEdit() - systemCommand function disabled in this build. Unable to launch application to edit file.");
 }
 }
 
 
-function AssetBrowser::duplicateScriptAsset(%this, %assetDef, %targetModule)
-{
-}
-
-function AssetBrowser::importScriptAsset(%this, %assetId)
+function ScriptAsset::buildBrowserElement(%this, %previewData)
 {
 {
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.fileName;
+   
+   if(%this.isServerSide)
+      %previewData.previewImage = "ToolsModule:serverScriptIcon_image";
+   else
+      %previewData.previewImage = "ToolsModule:clientScriptIcon_image";
+   
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.fileName;
+   %previewData.tooltip = "Script Asset: " @ %this.getAssetId() @ "\n" @ 
+                          "File path: " @ %this.fileName;
 }
 }
 
 
-function AssetBrowser::onScriptAssetEditorDropped(%this, %assetDef, %position)
+function GuiInspectorTypeScriptAssetPtr::onClick( %this, %fieldName )
 {
 {
-
+   //Get our data
+   %obj = %this.getInspector().getInspectObject(0);
 }
 }
 
 
-//Renames the asset
-function AssetBrowser::renameScriptAsset(%this, %assetDef, %newAssetName)
+//==============================================================================
+// Handling for random script files in the browser
+//==============================================================================
+function ScriptFileType::buildBrowserElement(%filePath, %previewData)
 {
 {
-   %newFilename = renameAssetLooseFile(%assetDef.scriptFile, %newAssetName);
+   %previewData.assetName = fileName(%filePath);
+   %previewData.assetPath = %filePath;
+   %previewData.doubleClickCommand = "systemCommand(\"start \\\"\\\" \\\"" @ %filePath @ "\\\"\");";
    
    
-   if(!%newFilename $= "")
-      return;
-
-   %assetDef.scriptFile = %newFilename;
-   %assetDef.saveAsset();
+   /*if(%assetDef.isServerSide)
+      %previewData.previewImage = "ToolsModule:serverScriptIcon_image";
+   else
+      %previewData.previewImage = "ToolsModule:clientScriptIcon_image";*/
+   %previewData.previewImage = "ToolsModule:clientScriptIcon_image";
    
    
-   renameAssetFile(%assetDef, %newAssetName);
+   %previewData.assetFriendlyName = %previewData.assetName;
+   %previewData.assetDesc = %filePath;
+   %previewData.tooltip = "Script File: " @ %filePath;
 }
 }
 
 
-//Deletes the asset
-function AssetBrowser::deleteScriptAsset(%this, %assetDef)
+function ScriptAssetType::onEdit(%filePath)
 {
 {
-   AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
+   if(isFunction("systemCommand"))
+      eval("systemCommand(\"start \\\"\\\" \\\"" @ %filePath @ "\\\"\");");
+   else  
+      warn("ScriptAssetType::onEdit() - systemCommand function disabled in this build. Unable to launch application to edit file.");
 }
 }
 
 
-//Moves the asset to a new path/module
-function AssetBrowser::moveScriptAsset(%this, %assetDef, %destination)
+function ScriptFileType::onShowActionMenu(%filePath)
 {
 {
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
+   if( !isObject( EditScriptFileTypePopup ) )
+   {
+      new PopupMenu( EditScriptFileTypePopup )
+      {
+         superClass = "MenuBuilder";
+         class = "EditorWorldMenu";
 
 
-   moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
-}
+         jumpFileName = "";
+         jumpLineNumber = "";
+      };
+   }
+   
+   //Regen the menu so we're fully up and current with options and references
+   EditScriptFileTypePopup.clearItems();
+   
+   EditScriptFileTypePopup.item[ 0 ] = "Edit File" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();";
+   EditScriptFileTypePopup.item[ 1 ] = "Rename File" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();";
+   EditScriptFileTypePopup.item[ 2 ] = "-";
+   EditScriptFileTypePopup.item[ 3 ] = "Duplicate File" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();";
+   EditScriptFileTypePopup.item[ 4 ] = "-";
+   EditScriptFileTypePopup.item[ 5 ] = "Open File Location" TAB "" TAB $CurrentAssetBrowser @ ".openFileLocation();";
+   EditScriptFileTypePopup.item[ 6 ] = "-";
+   EditScriptFileTypePopup.item[ 7 ] = "Delete File" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();";
+   EditScriptFileTypePopup.item[ 8 ] = "-";
+   EditScriptFileTypePopup.item[ 9 ] = "File Properties" TAB "" TAB $CurrentAssetBrowser @ ".editAssetInfo();";
 
 
-function AssetBrowser::buildScriptAssetPreview(%this, %assetDef, %previewData)
-{
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.scriptFile;
-   //%previewData.doubleClickCommand = "EditorOpenFileInTorsion( \""@%previewData.assetPath@"\", 0 );";
+   EditScriptFileTypePopup.objectData = %filePath;
+   EditScriptFileTypePopup.objectType = "ScriptFileType";
    
    
-   if(%assetDef.isServerSide)
-      %previewData.previewImage = "ToolsModule:serverScriptIcon_image";
-   else
-      %previewData.previewImage = "ToolsModule:clientScriptIcon_image";
+   EditScriptFileTypePopup.reloadItems();
    
    
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getFilename();
+   EditScriptFileTypePopup.showPopup(Canvas); 
+   
+   $CurrentAssetBrowser.popupMenu = EditScriptFileTypePopup;
 }
 }
 
 
-function AssetBrowser::buildTScriptPreview(%this, %assetDef, %previewData)
+function ScriptFileType::onEditProperties(%filePath)
 {
 {
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.scriptFile;
-   //%previewData.doubleClickCommand = "EditorOpenFileInTorsion( \""@%previewData.assetPath@"\", 0 );";
+   Canvas.pushDialog(AssetBrowser_editAsset);
    
    
-   if(%assetDef.isServerSide)
-      %previewData.previewImage = "ToolsModule:serverScriptIcon_image";
-   else
-      %previewData.previewImage = "ToolsModule:clientScriptIcon_image";
+   AssetBrowser_editAssetWindow.text = "Script File Properties - " @ %filePath;
    
    
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getFilename();
+   AssetBrowser_editAsset.editedObjectData = %filePath;
+   //AssetBrowser_editAsset.editedObject = SpecialAssetEditInspector.tempAsset;
+   AssetBrowser_editAsset.editedObjectType = "ScriptFileType";
+   
+   AssetEditInspector.startGroup("Script File Properties");
+   AssetEditInspector.addField("$ScriptFileType::ExecutionMode", "Execution Mode", "list", "How should this script file be executed by the module", "Server", "Client;Server;Shared;None");
+   AssetEditInspector.addField("$ScriptFileType::ExecutionOverride", "Do Execution Override", "bool", "Should this execution override files that share the same name?", "false");
+   AssetEditInspector.addField("$ScriptFileType::ExecutionConditions", "Execution Conditional", "command", "Does the execution of this script file have special conditionals?", "");
+   AssetEditInspector.endGroup("Script File Properties");
 }
 }
 
 
-function GuiInspectorTypeScriptAssetPtr::onClick( %this, %fieldName )
+function ScriptFileType::onSaveProperties(%filePath)
 {
 {
-   //Get our data
-   %obj = %this.getInspector().getInspectObject(0);
+   //Do voodoo here
 }
 }

+ 50 - 272
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript

@@ -1,285 +1,60 @@
-function AssetBrowser::createShapeAsset(%this)
-{
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
-   %modulePath = "data/" @ %moduleName;
-      
-   %assetName = AssetBrowser.newAssetSettings.assetName;
-   
-   %assetPath = NewAssetTargetAddress.getText() @ "/";
-   
-   %tamlpath = %assetPath @ %assetName @ ".asset.taml";
-   %shapeFilePath = %assetPath @ %assetName @ ".dae";
-   
-   %asset = new ShapeAsset()
-   {
-      AssetName = %assetName;
-      versionId = 1;
-      friendlyName = AssetBrowser.newAssetSettings.friendlyName;
-      description = AssetBrowser.newAssetSettings.description;
-      fileName = %assetName @ ".dae";
-   };
-   
-   TamlWrite(%asset, %tamlpath);
-   
-   Canvas.popDialog(AssetBrowser_newComponentAsset);
-	
-	%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
-	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
-
-	AssetBrowser.refresh();
-	
-	return %tamlpath;
-}
-
-function AssetBrowser::editShapeAsset(%this, %assetDef)
-{
-   %this.hideDialog();
-    EditorGui.setEditor( ShapeEditorPlugin );
-   ShapeEditorPlugin.openShapeAsset(%assetDef);    
-}
+AssetBrowser::registerAssetType("ShapeAsset", "Shapes"); 
 
 
-function AssetBrowser::onShapeAssetChanged(%this, %assetDef)
+function ShapeAsset::onEdit(%this)
 {
 {
+   if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
+   {
+      $CurrentAssetBrowser.hideDialog();
+      EditorGui.setEditor( ShapeEditorPlugin );
+      ShapeEditorPlugin.openShapeAsset(%this); 
+   }
+   else
+   {
+      %this.onWorldEditorDropped();
+   } 
 }
 }
 
 
-function AssetBrowser::deleteShapeAsset(%this, %assetDef)
-{
-   
-}
-
-function AssetBrowser::moveShapeAsset(%this, %assetDef, %destination)
+function ShapeAsset::onShowActionMenu(%assetDef)
 {
 {
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.getShapePath(), %destination);
-   moveAssetLooseFile(%assetDef.getShapeConstructorFilePath(), %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
+   GenericAsset::onShowActionMenu(%assetDef);
 }
 }
 
 
-function AssetBrowser::prepareImportShapeAsset(%this, %assetItem)
+function ShapeAsset::onChanged(%this)
 {
 {
-   ImportActivityLog.add("Preparing Shape for Import: " @ %assetItem.assetName);
-   
-   %fileExt = fileExt(%assetItem.filePath);
-   
-   if(!isObject(%assetItem.shapeInfo))
-   {
-      %shapeInfo = new GuiTreeViewCtrl();
-      if(%fileExt $= ".dae")
-      {
-         enumColladaForImport(%assetItem.filePath, %shapeInfo, false);  
-      }
-      else if(%fileExt $= ".dts")
-      {
-         %shapeInfo.insertItem(0, "Shape", 1);
-         %shapeInfo.insertItem(0, "Animations", 0);
-      }
-      else
-      {
-         GetShapeInfo(%assetItem.filePath, %shapeInfo, false);
-      }
-      
-      %assetItem.shapeInfo = %shapeInfo;
-   }
-
-   %shapeCount = %assetItem.shapeInfo._meshCount;
-   %shapeItem = %assetItem.shapeInfo.findItemByName("Meshes");
-   
-   //%shapeId = ImportAssetTree.findItemByObjectId(%assetItem);
-   
-   if(getAssetImportConfigValue("Meshes/ImportMesh", "1") == 1 && %shapeCount > 0)
-   {
-   }
-   
-   %animCount = %assetItem.shapeInfo._animCount;
-   %animItem = %assetItem.shapeInfo.findItemByName("Animations");
-   
-   if(getAssetImportConfigValue("Animations/ImportAnimations", "1") == 1 && %animCount > 0)
-   {
-   }
-
-   %matCount = %assetItem.shapeInfo._materialCount;
-   %matItem = %assetItem.shapeInfo.findItemByName("Materials");
-   
-   ImportActivityLog.add("   Shape Info: Mesh Count: " @ %shapeCount @ " | Material Count: " @ %matCount @ " | Anim Count: " @ %animCount);
-   
-   if(getAssetImportConfigValue("Materials/ImportMaterials", "1") == 1 && %matCount > 0)
-   {
-      %materialItem = %assetItem.shapeInfo.getChild(%matItem);
-      processShapeMaterialInfo(%assetItem, %materialItem);
-      
-      %materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem);
-      while(%materialItem != 0)
-      {
-         processShapeMaterialInfo(%assetItem, %materialItem);
-            
-         %materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem);
-      }
-   }
+   echo("ShapeAsset::onChanged() - asset " @ %this.assetId @ " has changed!");
 }
 }
 
 
-function AssetBrowser::importShapeAsset(%this, %assetItem)
+function ShapeAsset::onDelete(%this)
 {
 {
-   %moduleName = AssetImportTargetModule.getText();
-   
-   %assetType = %assetItem.AssetType;
-   %filePath = %assetItem.filePath;
-   %assetName = %assetItem.assetName;
-   %assetImportSuccessful = false;
-   %assetId = %moduleName@":"@%assetName;
-   
-   %assetPath = NewAssetTargetAddress.getText() @ "/";
-   %assetFullPath = %assetPath @ fileName(%filePath);
-   
-   %newAsset = new ShapeAsset()
-   {
-      assetName = %assetName;
-      versionId = 1;
-      fileName = fileName(%filePath);
-      isNewShape = true;
-   };
-   
-   //No point in indicating the original path data if it was imported in-place
-   if(!startsWith(makeFullPath(%filePath), getMainDotCsDir()))
-   {
-      %newAsset.originalFilePath = %filePath;
-   }
-   
-   //check dependencies
-   %dependencySlotId = 0;
-   for(%i=0; %i < %assetItem.childAssetItems.count(); %i++)
-   {
-      %childAssetItem = %assetItem.childAssetItems.getKey(%i);
-      
-      if(!isObject(%childAssetItem) || %childAssetItem.skip || %childAssetItem.processed == false)
-         continue;
+   //Special handle the cache preview image
+   %module = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%this.getShapePath())));
+   %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/" @ %this.assetName @ "_Preview.dds";
 
 
-      %depAssetType = %childAssetItem.assetType;
-      if(%childAssetItem.assetType $= "MaterialAsset")
-      {
-         %matSet = "%newAsset.materialSlot"@%dependencySlotId@"=\"@asset="@%moduleName@":"@%childAssetItem.assetName@"\";";
-         eval(%matSet);
-         %dependencySlotId++;
-      }
-      else if(%depAssetType $= "AnimationAsset")
-      {
-         %matSet = "%newAsset.animationSequence"@%dependencySlotId@"=\"@asset="@%moduleName@":"@%childAssetItem.assetName@"\";";
-         eval(%matSet);
-         %dependencySlotId++;
-      }
-   }
-   
-   %assetImportSuccessful = TAMLWrite(%newAsset, %assetPath @ %assetName @ ".asset.taml"); 
-   
-   //and copy the file into the relevent directory
-   if(filePath(%filePath) !$= filePath(%assetFullPath))
+   if(isFile(%previewPath))
    {
    {
-      %doOverwrite = !AssetBrowser.isAssetReImport;
-      if(!pathCopy(%filePath, %assetFullPath, %doOverwrite))
-      {
-         error("Unable to import asset: " @ %filePath);
-      }
+      $CurrentAssetBrowser.dirHandler.deleteFile(%previewPath);
    }
    }
    
    
-   %constructor = ShapeEditor.findConstructor( %assetFullPath );
-   
-   if(!isObject(%constructor))
-      %constructor = ShapeEditor.createConstructor(%assetFullPath);
-   
-   //We'll update any relevent bits to the ShapeConstructor here
-   $TSShapeConstructor::neverImportMat = "";
-   
-   if(getAssetImportConfigValue("Materials/IgnoreMaterials", "") !$= "")
-   {
-      %ignoreMaterialList = getAssetImportConfigValue("Materials/IgnoreMaterials", "");
-      %ignoredMatNamesCount = getTokenCount(%ignoreMaterialList, ",;");
-      for(%i=0; %i < %ignoredMatNamesCount; %i++)
-      {
-         if(%i==0)
-            $TSShapeConstructor::neverImportMat = getToken(%ignoreMaterialList, ",;", %i);
-         else
-            $TSShapeConstructor::neverImportMat = $TSShapeConstructor::neverImportMat TAB getToken(%ignoreMaterialList, ",;", %i);
-      }
-   } 
-   
-   if(getAssetImportConfigValue("Materials/DoUpAxisOverride", "") $= "1")
-      %constructor.upAxis = getAssetImportConfigValue("Meshes/UpAxisOverride", "Z_AXIS");
-      
-   if(getAssetImportConfigValue("Meshes/DoScaleOverride", "0") $= "1")
-      %constructor.unit = getAssetImportConfigValue("Meshes/ScaleOverride", "1");
-   else
-      %constructor.unit = -1;
-
-   %constructor.lodType = getAssetImportConfigValue("Meshes/LODType", "0");
-   //%constructor.singleDetailSize = getAssetImportConfigValue("Meshes/convertLeftHanded", "0");
-   %constructor.alwaysImport = getAssetImportConfigValue("Meshes/AlwaysImportedNodes", "");
-   %constructor.neverImport = getAssetImportConfigValue("Meshes/AlwaysIgnoreNodes", "");
-   %constructor.alwaysImportMesh = getAssetImportConfigValue("Meshes/AlwaysImportMeshes", "");
-   %constructor.neverImportMesh = getAssetImportConfigValue("Meshes/AlwaysIgnoreMeshes", "");   
-   %constructor.ignoreNodeScale = getAssetImportConfigValue("Meshes/IgnoreNodeScale", "0"); 
-   %constructor.adjustCenter = getAssetImportConfigValue("Meshes/AdjustCenter", "0");  
-   %constructor.adjustFloor = getAssetImportConfigValue("Meshes/AdjustFloor", "0");  
-   
-   %constructor.convertLeftHanded = getAssetImportConfigValue("Meshes/convertLeftHanded", "0");
-   %constructor.calcTangentSpace = getAssetImportConfigValue("Meshes/calcTangentSpace", "0");
-   %constructor.genUVCoords = getAssetImportConfigValue("Meshes/genUVCoords", "0");
-   %constructor.flipUVCoords = getAssetImportConfigValue("Meshes/flipUVCoords", "0");
-   %constructor.findInstances = getAssetImportConfigValue("Meshes/findInstances", "0");
-   %constructor.limitBoneWeights = getAssetImportConfigValue("Meshes/limitBoneWeights", "0");
-   %constructor.joinIdenticalVerts = getAssetImportConfigValue("Meshes/joinIdenticalVerts", "0");
-   %constructor.reverseWindingOrder = getAssetImportConfigValue("Meshes/reverseWindingOrder", "0");
-   %constructor.invertNormals = getAssetImportConfigValue("Meshes/invertNormals", "0");   
-   %constructor.removeRedundantMats = getAssetImportConfigValue("Meshes/removeRedundantMats", "0");
-   %constructor.animTiming = getAssetImportConfigValue("Animations/animTiming", "Seconds");
-   %constructor.animFPS = getAssetImportConfigValue("Animations/animFPS", "2");
-   
-   %constructor.neverImportMat = $TSShapeConstructor::neverImportMat;
-   ShapeEditor.saveConstructor( %constructor );
-   
-   //now, force-load the file if it's collada
-   /*%fileExt = fileExt(%assetFullPath);
-   if(isSupportedFormat(getSubStr(%fileExt,1)))
-   {
-      %tempShape = new TSStatic()
-      {
-         shapeName = %assetFullPath;
-      };
-      
-      %tempShape.delete();
-   }*/
-   
-   %moduleDef = ModuleDatabase.findModule(%moduleName,1);
-         
-   if(!AssetBrowser.isAssetReImport)
-      AssetDatabase.addDeclaredAsset(%moduleDef, %assetPath @ %assetName @ ".asset.taml");
-   else
-      AssetDatabase.refreshAsset(%assetId);
+   //then just let the Generic function handle the rest
+   GenericAsset::onDelete(%this);
 }
 }
 
 
-function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate)
+function ShapeAsset::buildBrowserElement(%this, %previewData)
 {
 {
    %previewData.previewImage = "ToolsModule:genericAssetIcon_image";
    %previewData.previewImage = "ToolsModule:genericAssetIcon_image";
    %previewData.previewLoaded = false; //this marks it for loading progressively later
    %previewData.previewLoaded = false; //this marks it for loading progressively later
    
    
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.fileName;
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.fileName;
    
    
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @ 
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ "\n" @ 
                            "Asset Type: Shape Asset\n" @ 
                            "Asset Type: Shape Asset\n" @ 
-                           "Asset Definition ID: " @  %assetDef @ "\n" @ 
-                           "Shape File path: " @ %assetDef.getShapePath();
+                           "Asset Definition ID: " @  %this @ "\n" @ 
+                           "Shape File path: " @ %this.getShapePath();
                            
                            
-   if(%this.selectMode)
+   /*if(%this.selectMode)
    {
    {
       %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
       %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
    }
    }
@@ -293,41 +68,39 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData, %f
       {
       {
          %previewData.doubleClickCommand = "AssetBrowser.onShapeAssetEditorDropped( "@%assetDef@" );";
          %previewData.doubleClickCommand = "AssetBrowser.onShapeAssetEditorDropped( "@%assetDef@" );";
       }
       }
-   }
+   }*/
 }
 }
 
 
-function AssetBrowser::generateShapeAssetPreviewImage(%this, %previewButton, %forceRegenerate)
+function ShapeAsset::generatePreviewImage(%this, %previewButton, %forceRegenerate)
 {
 {
    if(%forceRegenerate $= "")
    if(%forceRegenerate $= "")
       %forceRegenerate = false;
       %forceRegenerate = false;
       
       
-   %assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName;
-      
-   %assetDef = AssetDatabase.acquireAsset(%assetId);
-      
-   %module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getShapePath())));
+   %assetId = %this.getAssetId();
+
+   %module = %previewButton.assetBrowser.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%this.getShapePath())));
    %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/";
    %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/";
    
    
    if(!IsDirectory(%previewPath))
    if(!IsDirectory(%previewPath))
    {
    {
-      %this.dirHandler.createFolder(%previewPath);
+      %previewButton.assetBrowser.dirHandler.createFolder(%previewPath);
    }
    }
    
    
    %generatePreview = false;
    %generatePreview = false;
    
    
-   %previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.dds";
-   if(!isFile(%previewFilePath) || (compareFileTimes(%assetDef.getShapePath(), %previewFilePath) == 1))
+   %previewFilePath = %previewPath @ %this.assetName @ "_Preview.dds";
+   if(!isFile(%previewFilePath) || (compareFileTimes(%this.getShapePath(), %previewFilePath) == 1))
    {
    {
       %generatePreview = true;
       %generatePreview = true;
    }
    }
    
    
-   %previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage";
+   %previewAssetName = %module.moduleId @ "_" @ %this.assetName @ "_PreviewImage";
    
    
    if(%generatePreview || %forceRegenerate)
    if(%generatePreview || %forceRegenerate)
    {
    {
       //real fast, we'll be 100% sure that the image resource we need is loaded
       //real fast, we'll be 100% sure that the image resource we need is loaded
       
       
-      %matSlot0AssetId = %assetDef.materialSlot0;
+      %matSlot0AssetId = %this.materialSlot0;
       if(AssetDatabase.isDeclaredAsset(%matSlot0AssetId))
       if(AssetDatabase.isDeclaredAsset(%matSlot0AssetId))
       {
       {
          %matAsset = AssetDatabase.acquireAsset(%matSlot0AssetId);
          %matAsset = AssetDatabase.acquireAsset(%matSlot0AssetId);
@@ -337,7 +110,7 @@ function AssetBrowser::generateShapeAssetPreviewImage(%this, %previewButton, %fo
       //This is slightly hacky, but we're going to utilize the imposter/last detail system
       //This is slightly hacky, but we're going to utilize the imposter/last detail system
       //to generate our previews for us and then clean up the unneeded bits
       //to generate our previews for us and then clean up the unneeded bits
       
       
-      %filePath = %assetDef.generateCachedPreviewImage();
+      %filePath = %this.generateCachedPreviewImage();
       
       
       pathCopy(%filePath, %previewFilePath, false);
       pathCopy(%filePath, %previewFilePath, false);
       fileDelete(%filePath); //cleanup
       fileDelete(%filePath); //cleanup
@@ -380,7 +153,7 @@ function AssetBrowser::generateShapeAssetPreviewImage(%this, %previewButton, %fo
    return false;
    return false;
 }
 }
 
 
-function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position)
+function ShapeAsset::onWorldEditorDropped(%assetDef, %position)
 {
 {
    %assetId = %assetDef.getAssetId();
    %assetId = %assetDef.getAssetId();
    
    
@@ -402,6 +175,11 @@ function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position)
    MECreateUndoAction::submit(%newStatic );
    MECreateUndoAction::submit(%newStatic );
 }
 }
 
 
+function ShapeAsset::onGUIEditorDropped(%assetDef, %position)
+{
+   
+}
+
 function GuiInspectorTypeShapeAssetPtr::onControlDropped( %this, %payload, %position )
 function GuiInspectorTypeShapeAssetPtr::onControlDropped( %this, %payload, %position )
 {
 {
    Canvas.popDialog(EditorDragAndDropLayer);
    Canvas.popDialog(EditorDragAndDropLayer);

+ 12 - 51
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shapeAnimation.tscript

@@ -1,57 +1,16 @@
-function AssetBrowser::createShapeAnimationAsset(%this)
-{
-   %dlg = new OpenFileDialog()
-   {
-      Filters        = "Animation Files(*.dae, *.cached.dts)|*.dae;*.cached.dts";
-      DefaultPath    = $Pref::WorldEditor::LastPath;
-      DefaultFile    = "";
-      ChangePath     = false;
-      OverwritePrompt = true;
-      forceRelativePath = false;
-      //MultipleFiles = true;
-   };
+AssetBrowser::registerAssetType("ShapeAnimationAsset", "Shape Anims"); 
 
 
-   %ret = %dlg.Execute();
-   
-   if ( %ret )
-   {
-      $Pref::WorldEditor::LastPath = filePath( %dlg.FileName );
-      %fullPath = %dlg.FileName;
-   }   
-   
-   %dlg.delete();
-   
-   if ( !%ret )
-      return;  
-}
-
-function AssetBrowser::editShapeAnimationAsset(%this, %assetDef)
+function ShapeAnimationAsset::onEdit(%this)
 {
 {
-   %this.hideDialog();
+   $CurrentAssetBrowser.hideDialog();
    EditorGui.setEditor( ShapeEditorPlugin );
    EditorGui.setEditor( ShapeEditorPlugin );
-   ShapeEditorPlugin.openShapeAsset(%assetDef);   
-}
-
-function AssetBrowser::moveShapeAnimationAsset(%this, %assetDef, %destination)
-{
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.getAnimationPath(), %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
+   ShapeEditorPlugin.openShapeAsset(%this);   
 }
 }
 
 
-function AssetBrowser::buildShapeAnimationAssetPreview(%this, %assetDef, %previewData)
+function ShapeAnimationAsset::buildBrowserElement(%this, %previewData)
 {
 {
-   %previewData.assetName = %assetDef.animationName;
-   %previewData.assetPath = %assetDef.scriptFile;
+   %previewData.assetName = %this.animationName;
+   %previewData.assetPath = %this.scriptFile;
 
 
    //Lotta prepwork
    //Lotta prepwork
    /*%previewData.doubleClickCommand = %assetDef@".materialDefinitionName.reload(); "
    /*%previewData.doubleClickCommand = %assetDef@".materialDefinitionName.reload(); "
@@ -66,7 +25,9 @@ function AssetBrowser::buildShapeAnimationAssetPreview(%this, %assetDef, %previe
    
    
    %previewData.previewImage = "ToolsModule:animationIcon_image";
    %previewData.previewImage = "ToolsModule:animationIcon_image";
    
    
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %assetDef.friendlyName @ "\n" @ %assetDef @ "\nShape File path: " @ %assetDef.getShapePath();
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = %this.friendlyName @ "\n" 
+                          @ %this @ "\nShape File path: " 
+                          @ %this.getShapePath();
 }
 }

+ 26 - 39
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/sound.tscript

@@ -1,61 +1,50 @@
-function AssetBrowser::editSoundAsset(%this, %assetDef)
+AssetBrowser::registerAssetType("SoundAsset", "Sounds"); 
+
+function SoundAsset::onEdit(%this)
 {
 {
    if (isObject($PreviewSoundSource))
    if (isObject($PreviewSoundSource))
         sfxStop($PreviewSoundSource);
         sfxStop($PreviewSoundSource);
-   $PreviewSoundSource = %assetDef.playSound();
+   $PreviewSoundSource = %this.playSound();
 }
 }
 
 
-function AssetBrowser::onSoundAssetChanged(%this, %assetDef)
+function SoundAsset::onChanged(%this)
 {
 {
    if (isObject($PreviewSoundSource))
    if (isObject($PreviewSoundSource))
         sfxStop($PreviewSoundSource);
         sfxStop($PreviewSoundSource);
 }
 }
 
 
-function AssetBrowser::moveSoundAsset(%this, %assetDef, %destination)
+function SoundAsset::buildBrowserElement(%this, %previewData)
 {
 {
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.getSoundPath(), %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
-}
-
-function AssetBrowser::buildSoundAssetPreview(%this, %assetDef, %previewData)
-{
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.soundFilePath;
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.soundFilePath;
    
    
    if(%this.selectMode)
    if(%this.selectMode)
    {
    {
-      %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
+      %previewData.doubleClickCommand = $CurrentAssetBrowser @ ".selectAsset( " @ $CurrentAssetBrowser @ ".selectedAsset );";
    }
    }
    else
    else
    {
    {
-      if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
+      %previewData.doubleClickCommand = $CurrentAssetBrowser @ ".editAsset( "@ %this @" );";
+      
+      /*if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
       {
       {
-      %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );";
+         %previewData.doubleClickCommand = $CurrentAssetBrowser @ ".editAsset( "@ %this @" );";
       }
       }
       else
       else
       {
       {
-         %previewData.doubleClickCommand = "AssetBrowser.onSoundAssetEditorDropped( "@%assetDef@" );";
-      }
+         %previewData.doubleClickCommand = $CurrentAssetBrowser @ ".onSoundAssetEditorDropped( "@ %this @" );";
+      }*/
    }
    }
    
    
    %previewData.previewImage = "ToolsModule:soundIcon_image";   
    %previewData.previewImage = "ToolsModule:soundIcon_image";   
    
    
-   %previewData.assetFriendlyName = %assetDef.assetName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getFilename();
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ 
+                          "\nDefinition Path: " @ %this.getFilename();
 }
 }
 
 
-function AssetBrowser::onSoundAssetEditorDropped(%this, %assetDef, %position)
+function SoundAsset::onWorldEditorDropped(%this, %position)
 {
 {
    %targetPosition = EWorldEditor.unproject(%position SPC 1);
    %targetPosition = EWorldEditor.unproject(%position SPC 1);
    %camPos = LocalClientConnection.camera.getPosition();
    %camPos = LocalClientConnection.camera.getPosition();
@@ -72,14 +61,12 @@ function AssetBrowser::onSoundAssetEditorDropped(%this, %assetDef, %position)
       %pos = "0 0 0";  
       %pos = "0 0 0";  
    }
    }
    
    
-   %assetId = %assetDef.getAssetId();
-   
    %newSFXEmitter = new SFXEmitter()
    %newSFXEmitter = new SFXEmitter()
    {
    {
       position = %pos;
       position = %pos;
-      soundAsset = %assetDef.getAssetId();
-      pitch = %assetDef.pitchAdjust;
-      volume = %assetDef.volumeAdjust;
+      soundAsset = %this.getAssetId();
+      pitch = %this.pitchAdjust;
+      volume = %this.volumeAdjust;
    };
    };
    
    
    getScene(0).add(%newSFXEmitter);
    getScene(0).add(%newSFXEmitter);
@@ -91,15 +78,15 @@ function AssetBrowser::onSoundAssetEditorDropped(%this, %assetDef, %position)
    
    
 }
 }
 
 
-function AssetBrowser::onSoundAssetGUIEditorDropped(%this, %assetDef, %position)
+function SoundAsset::onGUIEditorDropped(%this, %position)
 {    
 {    
-   %assetId = %assetDef.getAssetId();
+   %assetId = %this.getAssetId();
    %cmd = "new GuiAudioCtrl(){";
    %cmd = "new GuiAudioCtrl(){";
    %cmd = %cmd @ "SoundAsset =\""@ %assetId @"\";";
    %cmd = %cmd @ "SoundAsset =\""@ %assetId @"\";";
    %cmd = %cmd @ "position =\""@ %position @"\";";
    %cmd = %cmd @ "position =\""@ %position @"\";";
    %cmd = %cmd @ "};";
    %cmd = %cmd @ "};";
    %ctrl = GuiEditCanvas.createObject(%cmd);
    %ctrl = GuiEditCanvas.createObject(%cmd);
-   echo(%ctrl SPC "created");
+   //echo(%ctrl SPC "created");
 }
 }
 
 
 function GuiInspectorTypeSoundAssetPtr::onControlDropped( %this, %payload, %position )
 function GuiInspectorTypeSoundAssetPtr::onControlDropped( %this, %payload, %position )

+ 0 - 161
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.tscript

@@ -1,161 +0,0 @@
-function AssetBrowser::createStateMachineAsset(%this)
-{
-   %assetName = AssetBrowser.newAssetSettings.assetName;
-   %moduleName = AssetBrowser.selectedModule;
-   %assetPath = NewAssetTargetAddress.getText() @ "/";
-      
-   %assetQuery = new AssetQuery();
-   
-   %matchingAssetCount = AssetDatabase.findAssetName(%assetQuery, %assetName);
-   
-   %i=1;
-   while(%matchingAssetCount > 0)
-   {
-      %newAssetName = %assetName @ %i;
-      %i++;
-      
-      %matchingAssetCount = AssetDatabase.findAssetName(%assetQuery, %newAssetName);
-   }
-   
-   %assetName = %newAssetName;
-   
-   %assetQuery.delete();
-   
-   %tamlpath = %assetPath @ %assetName @ ".asset.taml";
-   %smFilePath = %assetPath @ %assetName @ ".xml";
-   
-   %asset = new StateMachineAsset()
-   {
-      AssetName = %assetName;
-      versionId = 1;
-      stateMachineFile = %assetName @ ".xml";
-   };
-   
-   %xmlDoc = new SimXMLDocument();
-   %xmlDoc.saveFile(%smFilePath);
-   %xmlDoc.delete();
-   
-   TamlWrite(%asset, %tamlpath);
-   
-   //Now write our XML file
-   %xmlFile = new FileObject();
-	%xmlFile.openForWrite(%smFilePath);
-	%xmlFile.writeLine("<StateMachine>");
-	%xmlFile.writeLine("</StateMachine>");
-	%xmlFile.close();
-   
-   %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
-	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
-
-	AssetBrowser.refresh();
-   
-	return %tamlpath;
-}
-
-function AssetBrowser::editStateMachineAsset(%this, %assetDef)
-{
-   eval("AssetBrowser.tempAsset = new " @ %assetDef.getClassName() @ "();");
-   AssetBrowser.tempAsset.assignFieldsFrom(%assetDef);
-   
-   SMAssetEditInspector.inspect(AssetBrowser.tempAsset);  
-   AssetBrowser_editAsset.editedAssetId = EditAssetPopup.assetId;
-   AssetBrowser_editAsset.editedAsset = AssetBrowser.tempAsset;
-   
-   //remove some of the groups we don't need:
-   for(%i=0; %i < SMAssetEditInspector.getCount(); %i++)
-   {
-      %caption = SMAssetEditInspector.getObject(%i).caption;
-      
-      if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing" 
-         || %caption $= "Persistence" || %caption $= "Dynamic Fields")
-      {
-         SMAssetEditInspector.remove(SMAssetEditInspector.getObject(%i));
-         %i--;
-      }
-   }
-
-   Canvas.pushDialog(StateMachineEditor);
-   StateMachineEditor.loadStateMachineAsset(EditAssetPopup.assetId);
-   StateMachineEditor-->Window.text = "State Machine Editor ("@EditAssetPopup.assetId@")";
-}
-
-function AssetBrowser::duplicateStateMachineAsset(%this, %assetDef)
-{
-   // TODO:
-   %targetModule = "";
-
-   //Check if we have a target module, if not we need to select one
-   if(%targetModule $= "")
-   {
-      error("AssetBrowser::duplicateStateMachineAsset - No target module selected!");
-      return;
-   }
-   
-   %assetId = %assetDef.getAssetId();
-   %assetName = AssetDatabase.getAssetName(%assetId);
-   
-   //First step, copy the files
-   %modulePath = "data/" @ %targetModule @ "/stateMachines/";
-   
-   if(!isDirectory(%modulePath))
-      createPath(%modulePath);
-   
-   %assetFile = AssetDatabase.getAssetFilePath(%assetId);
-   %stateMachineFile = %assetDef.stateMachineFile;
-    
-   echo("AssetBrowser::duplicateGameObjectAsset - duplicating! " @ %assetId @ " to " @ %targetModule);
-   
-   %tamlPath = %modulePath @ fileName(%assetFile);
-   
-   pathCopy(%assetFile, %tamlPath);
-   pathCopy(%stateMachineFile, %modulePath @ fileName(%stateMachineFile));
-   
-   echo("AssetBrowser::duplicateStateMachineAsset - duplicated!");
-   
-   //Register the asset
-   %moduleDef = ModuleDatabase.findModule(%targetModule, 1);
-   
-	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlPath);
-
-   //Refresh the browser
-	AssetBrowser.refresh();
-	
-	//Rename it for convenience
-	AssetBrowser.performRenameAsset(%assetName, "New" @ %assetName);
-}
-
-function AssetBrowser::renameGameObjectAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
-{
-   %assetPath = AssetDatabase.getAssetFilePath(%newAssetId);
-   
-   //rename the file to match
-   %path = filePath(%assetPath);
-         
-   %oldScriptFilePath = %assetDef.stateMachineFile;
-   %scriptFilePath = filePath(%assetDef.stateMachineFile);
-   %scriptExt = fileExt(%assetDef.stateMachineFile);
-   
-   %newScriptFileName = %scriptFilePath @ "/" @ %newName @ %scriptExt;
-   %newAssetFile = %path @ "/" @ %newName @ ".asset.taml";
-   
-   %assetDef.stateMachineFile = %newScriptFileName;
-   
-   TamlWrite(%assetDef, %newAssetFile);
-   fileDelete(%assetPath);
-   
-   pathCopy(%oldScriptFilePath, %newScriptFileName);
-   fileDelete(%oldScriptFilePath); 
-}
-
-function AssetBrowser::buildStateMachineAssetPreview(%this, %assetDef, %previewData)
-{
-   %previewData.assetName = %assetDef.assetName;
-   %previewData.assetPath = %assetDef.scriptFile;
-   %previewData.doubleClickCommand = "AssetBrowser.editStateMachineAsset( "@%assetDef@" );";
-   
-   %previewData.previewImage = "ToolsModule:stateMachineIcon_image";
-   
-   %previewData.assetFriendlyName = %assetDef.friendlyName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %assetDef.friendlyName @ "\n" @ %assetDef;
-}

+ 156 - 0
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/subScene.tscript

@@ -0,0 +1,156 @@
+AssetBrowser::registerAssetType("SubSceneAsset", "SubScenes"); 
+
+function SubSceneAsset::setupCreateNew()
+{
+   NewAssetPropertiesInspector.startGroup("SubScene");
+   NewAssetPropertiesInspector.addField("LevelName", "SubScene Name", "String",  "Human-readable name of new subScene", "", "", $CurrentAssetBrowser.newAssetSettings);
+   
+   NewAssetPropertiesInspector.endGroup();
+}
+
+function SubSceneAsset::onCreateNew(%this)
+{
+   %moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
+   %modulePath = "data/" @ %moduleName;
+   
+   %assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
+   
+   %assetPath = NewAssetTargetAddress.getText() @ "/";
+   
+   %misExtension = ".subMis";
+   
+   %tamlpath = %assetPath @ %assetName @ ".asset.taml";
+   %levelPath = %assetPath @ %assetName @ %misExtension;
+   
+   %asset = new SubSceneAsset()
+   {
+      AssetName = %assetName;
+      versionId = 1;
+      LevelFile = %assetName @ %misExtension;
+      LevelName = $CurrentAssetBrowser.newAssetSettings.levelName;
+      AssetDescription = $CurrentAssetBrowser.newAssetSettings.description;
+   };
+   
+   TamlWrite(%asset, %tamlpath);
+   
+   %fileObj = new FileObject();
+   if (!%fileObj.openForWrite(%levelPath)) 
+   {
+      echo("Unable to write subScene file!");
+   }
+   else
+   {
+      %fileObj.writeLine("");
+      %fileObj.close();
+      %fileObj.delete();  
+   }
+
+	%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
+	%addSuccess = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
+	
+	if(!%addSuccess)
+	{
+	   error("SubSceneAsset::onCreateNew() - failed to add declared asset: " @ %tamlpath @ " for module: " @ %moduleDef);
+	}
+
+	$CurrentAssetBrowser.refresh();
+	
+	if(%addSuccess && isObject($createAndAssignField))
+	{
+      $createAndAssignField.apply(%moduleName @ ":" @ %assetName);
+      $createAndAssignField = "";
+	}
+	
+	return %tamlpath;  
+}
+
+function SubSceneAsset::buildBrowserElement(%this, %previewData)
+{
+   %previewData.assetName = %this.assetName;
+   %previewData.assetPath = %this.getLevelPath();
+   %previewData.doubleClickCommand = "AssetBrowser.selectAsset(" @ %this @ ");";
+   
+   %levelPreviewImage = %this.PreviewImage;
+         
+   if(isFile(%levelPreviewImage))
+      %previewData.previewImage = %levelPreviewImage;
+   else
+      %previewData.previewImage = "ToolsModule:levelIcon_image";
+   
+   %previewData.assetFriendlyName = %this.assetName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ "\n" @
+      "Asset Type: SubScene Asset\n" @ 
+      "Asset Definition ID: " @ %this @ "\n" @ 
+      "SubScene File path: " @ %this.getLevelPath(); 
+}
+
+function EWorldEditor::createSelectedAsSubScene( %this, %object )
+{
+   //create new level asset here
+   AssetBrowser.setupCreateNewAsset("SubSceneAsset", AssetBrowser.selectedModule, "finishCreateSelectedAsSubScene");
+   %this.contextActionObject = %object;
+}
+
+function finishCreateSelectedAsSubScene(%assetId)
+{
+   //echo("finishCreateSelectedAsSubScene");
+   
+   %subScene = new SubScene() {
+      levelAsset = %assetId;
+   };
+   
+   %levelAssetDef = AssetDatabase.acquireAsset(%assetId);
+   %levelFilePath = %levelAssetDef.getLevelPath();
+   
+   //write out to file
+   EWorldEditor.contextActionObject.save(%levelFilePath);
+   
+   AssetDatabase.releaseAsset(%assetId);
+   
+   getRootScene().add(%subScene);
+   
+   EWorldEditor.contextActionObject.delete();
+   
+   %subScene.load();
+   
+   %subScene.recalculateBounds();
+   
+   %scalar = $SubScene::createScalar;
+   if(%scalar $= "")
+      %scalar = 1.5;
+   
+   //pad for loading boundary
+   %subScene.scale = VectorScale(%subScene.scale, %scalar);
+}
+
+function SubSceneAsset::onWorldEditorDropped(%assetDef, %position)
+{
+   %assetId = %assetDef.getAssetId();
+   
+   if(!%assetDef.isSubScene)
+   {
+      errorf("Cannot drag-and-drop LevelAsset into WorldEditor");
+      return;  
+   }
+   
+   %newSubScene = new SubScene()
+   {
+      position = %position;
+      levelAsset = %assetId;
+   };
+   
+   getScene(0).add(%newSubScene);
+   
+   %newSubScene.load();
+   %newSubScene.recalculateBounds();
+   
+   EWorldEditor.clearSelection();
+   EWorldEditor.selectObject(%newSubScene);
+   
+   EWorldEditor.dropSelection();
+      
+   EWorldEditor.isDirty = true;
+   
+   MECreateUndoAction::submit(%newSubScene );
+}

+ 31 - 81
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/terrain.tscript

@@ -1,23 +1,25 @@
-function AssetBrowser::setupCreateNewTerrainAsset(%this)
+AssetBrowser::registerAssetType("TerrainAsset", "Terrains"); 
+
+function TerrainAsset::setupCreateNew()
 {
 {
    NewAssetPropertiesInspector.startGroup("Terrain");
    NewAssetPropertiesInspector.startGroup("Terrain");
-   NewAssetPropertiesInspector.addField("resolution", "Terrain Texture Resolution", "list",  "Is this script used on the server?", "1024", "256,512,1024,2048,4096", %this.newAssetSettings);
-   NewAssetPropertiesInspector.addField("genWithNoise", "Generate Terrain With Noise", "bool",  "Is this script used on the server?", "0", "2", %this.newAssetSettings);
+   NewAssetPropertiesInspector.addField("resolution", "Terrain Texture Resolution", "list",  "Is this script used on the server?", "1024", "256,512,1024,2048,4096", $CurrentAssetBrowser.newAssetSettings);
+   NewAssetPropertiesInspector.addField("genWithNoise", "Generate Terrain With Noise", "bool",  "Is this script used on the server?", "0", "2", $CurrentAssetBrowser.newAssetSettings);
    NewAssetPropertiesInspector.endGroup();
    NewAssetPropertiesInspector.endGroup();
    
    
    /*NewAssetPropertiesInspector.startGroup("Terrain - Import");
    /*NewAssetPropertiesInspector.startGroup("Terrain - Import");
-   NewAssetPropertiesInspector.addField("importDetails", "Import Heightmap", "button",  "Import an existing heightmap", "", "Canvas.pushDialog( TerrainImportGui );", %this.newAssetSettings);
+   NewAssetPropertiesInspector.addField("importDetails", "Import Heightmap", "button",  "Import an existing heightmap", "", "Canvas.pushDialog( TerrainImportGui );", $CurrentAssetBrowser.newAssetSettings);
    NewAssetPropertiesInspector.endGroup();*/
    NewAssetPropertiesInspector.endGroup();*/
 }
 }
 
 
-function AssetBrowser::createTerrainAsset(%this)
+function TerrainAsset::onCreateNew()
 {
 {
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
+   %moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
    %modulePath = "data/" @ %moduleName;
    %modulePath = "data/" @ %moduleName;
       
       
-   %assetName = AssetBrowser.newAssetSettings.assetName;      
+   %assetName = $CurrentAssetBrowser.newAssetSettings.assetName;      
    
    
-   %assetType = AssetBrowser.newAssetSettings.assetType;
+   %assetType = $CurrentAssetBrowser.newAssetSettings.assetType;
    %assetPath = NewAssetTargetAddress.getText() @ "/";
    %assetPath = NewAssetTargetAddress.getText() @ "/";
    
    
    //Ensure anything we generate goes into the right directory
    //Ensure anything we generate goes into the right directory
@@ -31,8 +33,8 @@ function AssetBrowser::createTerrainAsset(%this)
       AssetName = %assetName;
       AssetName = %assetName;
       versionId = 1;
       versionId = 1;
       terrainFile = %assetName @ ".ter";
       terrainFile = %assetName @ ".ter";
-      resolution = %this.newAssetSettings.resolution;
-      genWithNoise = %this.newAssetSettings.genWithNoise;
+      resolution = $CurrentAssetBrowser.newAssetSettings.resolution;
+      genWithNoise = $CurrentAssetBrowser.newAssetSettings.genWithNoise;
    };
    };
    
    
    TamlWrite(%asset, %tamlpath);
    TamlWrite(%asset, %tamlpath);
@@ -40,9 +42,9 @@ function AssetBrowser::createTerrainAsset(%this)
    %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
    %moduleDef = ModuleDatabase.findModule(%moduleName, 1);
 	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
 	AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
 
 
-	AssetBrowser.refresh();
+	$CurrentAssetBrowser.refresh();
 	
 	
-	$createdTerrainBlock = TerrainBlock::createNew( %assetName, %this.newAssetSettings.resolution, "", %this.newAssetSettings.genWithNoise );
+	$createdTerrainBlock = TerrainBlock::createNew( %assetName, $CurrentAssetBrowser.newAssetSettings.resolution, "", $CurrentAssetBrowser.newAssetSettings.genWithNoise );
 	
 	
 	MECreateUndoAction::submit($createdTerrainBlock);
 	MECreateUndoAction::submit($createdTerrainBlock);
       
       
@@ -55,12 +57,12 @@ function AssetBrowser::createTerrainAsset(%this)
       // This will update an existing terrain with the name %terrainName,
       // This will update an existing terrain with the name %terrainName,
       // or create a new one if %terrainName isn't a TerrainBlock
       // or create a new one if %terrainName isn't a TerrainBlock
       $createdTerrainBlock = TerrainBlock::import(  $createdTerrainBlock, 
       $createdTerrainBlock = TerrainBlock::import(  $createdTerrainBlock, 
-                                                    AssetBrowser.newAssetSettings.heightMapPng, 
-                                                    AssetBrowser.newAssetSettings.metersPerPixel, 
-                                                    AssetBrowser.newAssetSettings.heightScale, 
-                                                    AssetBrowser.newAssetSettings.opacityNames, 
-                                                    AssetBrowser.newAssetSettings.materialNames,
-                                                    AssetBrowser.newAssetSettings.flipYAxis );
+                                                    $CurrentAssetBrowser.newAssetSettings.heightMapPng, 
+                                                    $CurrentAssetBrowser.newAssetSettings.metersPerPixel, 
+                                                    $CurrentAssetBrowser.newAssetSettings.heightScale, 
+                                                    $CurrentAssetBrowser.newAssetSettings.opacityNames, 
+                                                    $CurrentAssetBrowser.newAssetSettings.materialNames,
+                                                    $CurrentAssetBrowser.newAssetSettings.flipYAxis );
 
 
       if ( isObject( $createdTerrainBlock ) )
       if ( isObject( $createdTerrainBlock ) )
       {
       {
@@ -130,87 +132,35 @@ function createTerrainBlock(%assetId)
    //
    //
 }
 }
 
 
-function AssetBrowser::editTerrainAsset(%this, %assetDef)
-{
-}
-
-function AssetBrowser::duplicateTerrainAsset(%this, %assetDef, %targetModule)
-{
-}
-
-function AssetBrowser::importTerrainAsset(%this, %assetDef)
-{
-}
-
-function AssetBrowser::dragAndDropTerrainAsset(%this, %assetDef, %dropTarget)
-{
-   if(!isObject(%dropTarget))
-      return;
-}
-
-function AssetBrowser::onTerrainAssetEditorDropped(%this, %assetDef, %position)
-{
-   createTerrainBlock(%assetDef.getAssetId());
-}
-
-function AssetBrowser::renameTerrainAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
-{
-}
-
-function AssetBrowser::deleteTerrainAsset(%this, %assetDef)
-{
-}
 
 
-function AssetBrowser::moveTerrainAsset(%this, %assetDef, %destination)
+function TerrainAsset::onWorldEditorDropped(%this, %position)
 {
 {
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.getTerrainFilePath(), %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
+   createTerrainBlock(%this.getAssetId());
 }
 }
 
 
-function AssetBrowser::buildTerrainAssetPreview(%this, %assetDef, %previewData)
+function TerrainAsset::buildBrowserElement(%this, %previewData)
 {
 {
-   %previewData.assetName = %assetDef.assetName;
+   %previewData.assetName = %this.assetName;
    %previewData.assetPath = "";
    %previewData.assetPath = "";
    
    
    %previewData.previewImage = "ToolsModule:terrainIcon_image";
    %previewData.previewImage = "ToolsModule:terrainIcon_image";
    
    
-   %previewData.assetFriendlyName = %assetDef.gameObjectName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @
+   %previewData.assetFriendlyName = %this.gameObjectName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @
       "\nAsset Type: Terrain Asset" @ 
       "\nAsset Type: Terrain Asset" @ 
-      "\nAsset Definition ID: " @ %assetDef @
-      "\nDefinition Path: " @ %assetDef.getTerrainFilePath(); 
+      "\nAsset Definition ID: " @ %this @
+      "\nDefinition Path: " @ %this.getTerrainFilePath(); 
       
       
    if(%this.selectMode)
    if(%this.selectMode)
    {
    {
-      %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
+      %previewData.doubleClickCommand = $CurrentAssetBrowser @ ".selectAsset( " @ $CurrentAssetBrowser @ ".selectedAsset );";
    }
    }
    else
    else
    {
    {
       if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
       if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
          %previewData.doubleClickCommand = "";
          %previewData.doubleClickCommand = "";
       else
       else
-         %previewData.doubleClickCommand = "createTerrainBlock(\""@%assetDef.getAssetId()@"\");";
+         %previewData.doubleClickCommand = "createTerrainBlock(\""@%this.getAssetId()@"\");";
    }
    }
-}
-
-function GuiInspectorTypeTerrainAssetPtr::onClick( %this, %fieldName )
-{
-   //Get our data
-   %obj = %this.getInspector().getInspectObject(0);
-}
-
-function GuiInspectorTypeTerrainAssetPtr::onControlDropped( %this, %payload, %position )
-{
-   
 }
 }

+ 27 - 79
Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/terrainMaterial.tscript

@@ -1,11 +1,13 @@
-function AssetBrowser::createTerrainMaterialAsset(%this)
+AssetBrowser::registerAssetType("TerrainMaterialAsset", "Terrain Materials"); 
+
+function TerrainMaterialAsset::onCreateNew()
 {
 {
-   %moduleName = AssetBrowser.newAssetSettings.moduleName;
+   %moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
    %modulePath = "data/" @ %moduleName;
    %modulePath = "data/" @ %moduleName;
       
       
-   %assetName = AssetBrowser.newAssetSettings.assetName;      
+   %assetName = $CurrentAssetBrowser.newAssetSettings.assetName;      
    
    
-   %assetType = AssetBrowser.newAssetSettings.assetType;
+   %assetType = $CurrentAssetBrowser.newAssetSettings.assetType;
    %assetPath = NewAssetTargetAddress.getText() @ "/";    
    %assetPath = NewAssetTargetAddress.getText() @ "/";    
    
    
    %tamlpath = %assetPath @ %assetName @ ".asset.taml";
    %tamlpath = %assetPath @ %assetName @ ".asset.taml";
@@ -57,7 +59,7 @@ function AssetBrowser::createTerrainMaterialAsset(%this)
 	
 	
 	AssetDatabase.acquireAsset("\"" @ %moduleName @ ":" @ %assetName @ "\"");
 	AssetDatabase.acquireAsset("\"" @ %moduleName @ ":" @ %assetName @ "\"");
 
 
-	AssetBrowser.refresh();
+	$CurrentAssetBrowser.refresh();
 	
 	
    //If we've got the terrain mat editor open, go ahead and update it all
    //If we've got the terrain mat editor open, go ahead and update it all
    TerrainMaterialDlg.onWake();
    TerrainMaterialDlg.onWake();
@@ -65,112 +67,70 @@ function AssetBrowser::createTerrainMaterialAsset(%this)
 	return %tamlpath;
 	return %tamlpath;
 }
 }
 
 
-function AssetBrowser::editTerrainMaterialAsset(%this, %assetDef)
+function TerrainAssetMaterial::onEdit(%this)
 {
 {
    TerrainMaterialDlg.show(0, 0, 0);
    TerrainMaterialDlg.show(0, 0, 0);
-   TerrainMaterialDlg.setActiveMaterial(%assetDef.assetName);
+   TerrainMaterialDlg.setActiveMaterial(%this.assetName);
 }
 }
 
 
-function AssetBrowser::duplicateTerrainMaterialAsset(%this, %assetDef, %targetModule)
-{
-}
-
-function AssetBrowser::importTerrainMaterialAsset(%this, %assetDef)
-{
-}
-
-function AssetBrowser::dragAndDropTerrainMaterialAsset(%this, %assetDef, %dropTarget)
-{
-   if(!isObject(%dropTarget))
-      return;
-}
-
-function AssetBrowser::renameTerrainMaterialAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
-{
-}
-
-function AssetBrowser::deleteTerrainMaterialAsset(%this, %assetDef)
-{
-}
-
-function AssetBrowser::moveTerrainMaterialAsset(%this, %assetDef, %destination)
-{
-   %currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
-   %targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
-   
-   %newAssetPath = moveAssetFile(%assetDef, %destination);
-   
-   if(%newAssetPath $= "")
-      return false;
-
-   moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
-   
-   AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
-   AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
-}
-
-function AssetBrowser::buildTerrainMaterialAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate)
+function TerrainAssetMaterial::buildBrowserElement(%this, %previewData)
 {
 {
    %previewData.previewImage = "ToolsModule:genericAssetIcon_image";
    %previewData.previewImage = "ToolsModule:genericAssetIcon_image";
    %previewData.previewLoaded = false; //this marks it for loading progressively later
    %previewData.previewLoaded = false; //this marks it for loading progressively later
       
       
-   %previewData.assetName = %assetDef.assetName;
+   %previewData.assetName = %this.assetName;
    %previewData.assetPath = "";
    %previewData.assetPath = "";
    %previewData.doubleClickCommand = "";
    %previewData.doubleClickCommand = "";
    
    
-   %previewData.assetFriendlyName = %assetDef.gameObjectName;
-   %previewData.assetDesc = %assetDef.description;
-   %previewData.tooltip = %assetDef.gameObjectName;
+   %previewData.assetFriendlyName = %this.gameObjectName;
+   %previewData.assetDesc = %this.description;
+   %previewData.tooltip = %this.gameObjectName;
    
    
-   %definitionPath = %assetDef.getScriptPath();
+   %definitionPath = %this.getScriptPath();
    if(%definitionPath $= "")
    if(%definitionPath $= "")
-      %definitionPath = %assetDef.getFilename();
+      %definitionPath = %this.getFilename();
    
    
-   %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ 
+   %previewData.tooltip = "Asset Name: " @ %this.assetName @ 
                            "\nAsset Type: Terrain Material Asset" @  
                            "\nAsset Type: Terrain Material Asset" @  
-                           "\nAsset Definition ID: " @  %assetDef @
+                           "\nAsset Definition ID: " @  %this @
                            "\nDefinition Path: " @ %definitionPath;
                            "\nDefinition Path: " @ %definitionPath;
 }
 }
 
 
-function AssetBrowser::generateTerrainMaterialAssetPreviewImage(%this, %previewButton, %forceRegenerate)
+function TerrainAssetMaterial::generatePreviewImage(%this, %previewButton, %forceRegenerate)
 {
 {
    if(%forceRegenerate $= "")
    if(%forceRegenerate $= "")
       %forceRegenerate = false;
       %forceRegenerate = false;
       
       
-   %assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName;
-      
-   %assetDef = AssetDatabase.acquireAsset(%assetId);
-      
-   %module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%assetDef.getAssetId()))));
+   %module = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%this.getAssetId()))));
    %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/";
    %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/";
 
 
    if(!IsDirectory(%previewPath))
    if(!IsDirectory(%previewPath))
    {
    {
-      %this.dirHandler.createFolder(%previewPath);
+      $CurrentAssetBrowser.dirHandler.createFolder(%previewPath);
    }
    }
 
 
    %generatePreview = false;
    %generatePreview = false;
 
 
-   %previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.dds";
+   %previewFilePath = %previewPath @ %this.assetName @ "_Preview.dds";
    if(!isFile(%previewFilePath))
    if(!isFile(%previewFilePath))
    {
    {
       %generatePreview = true;
       %generatePreview = true;
    }
    }
    else
    else
    {
    {
-      if(isObject(%assetDef.materialDefinitionName))
+      if(isObject(%this.materialDefinitionName))
       {
       {
-         if(compareFileTimes(%assetDef.materialDefinitionName.getDiffuseMap(), %previewFilePath) == 1 ||
-            compareFileTimes(%assetDef.materialDefinitionName.getFilename(), %previewFilePath) == 1)
+         if(compareFileTimes(%this.materialDefinitionName.getDiffuseMap(), %previewFilePath) == 1 ||
+            compareFileTimes(%this.materialDefinitionName.getFilename(), %previewFilePath) == 1)
          %generatePreview = true;
          %generatePreview = true;
       }
       }
    }
    }
 
 
-   %previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage";
+   %previewAssetName = %module.moduleId @ "_" @ %this.assetName @ "_PreviewImage";
                                    
                                    
    if(%generatePreview || %forceRegenerate)
    if(%generatePreview || %forceRegenerate)
    {
    {
-      if(isObject(%assetDef.materialDefinitionName))
+      if(isObject(%this.materialDefinitionName))
       {
       {
          %previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape");
          %previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape");
          %generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, DummyTerrMatPreview);
          %generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, DummyTerrMatPreview);
@@ -178,7 +138,6 @@ function AssetBrowser::generateTerrainMaterialAssetPreviewImage(%this, %previewB
          pathCopy(%generatedFilePath, %previewFilePath);
          pathCopy(%generatedFilePath, %previewFilePath);
          fileDelete(%generatedFilePath);
          fileDelete(%generatedFilePath);
 
 
-
          if(!AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName))
          if(!AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName))
          {
          {
             %previewAsset = new ImageAsset()
             %previewAsset = new ImageAsset()
@@ -216,15 +175,4 @@ function AssetBrowser::generateTerrainMaterialAssetPreviewImage(%this, %previewB
    }
    }
       
       
    return false;
    return false;
-}
-
-function GuiInspectorTypeTerrainMaterialAssetPtr::onClick( %this, %fieldName )
-{
-   //Get our data
-   %obj = %this.getInspector().getInspectObject(0);
-}
-
-function GuiInspectorTypeTerrainMaterialAssetPtr::onControlDropped( %this, %payload, %position )
-{
-   
 }
 }

+ 33 - 0
Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.tscript

@@ -179,6 +179,39 @@ function directoryHandler::getModuleFromAddress(%this, %address)
    return "";
    return "";
 }
 }
 
 
+function getModuleFromAddress(%address)
+{
+   %moduleList = ModuleDatabase.findModules();
+   
+   for(%i=0; %i < getWordCount(%moduleList); %i++)
+   {
+      %module = getWord(%moduleList, %i);
+      %modulePath = makeRelativePath(%module.ModulePath);
+      
+      //We don't want to add stuff directly to the root core or tools modules
+      //if(%modulePath $= "Core" || %modulePath $= "Tools")
+      //   continue;
+         
+      if(startsWith(%address, %modulePath))
+      {
+         return %module;
+      }
+   }
+   /*//break down the address
+   %folderCount = getTokenCount(%address, "/");
+      
+   for(%f=0; %f < %folderCount; %f++)
+   {
+      %folderName = getToken(%address, "/", %f);
+
+      %module = ModuleDatabase.findModule(%folderName);
+      if(%module !$= "")
+         return %module;
+   }*/
+   
+   return "";
+}
+
 function directoryHandler::getFolderTreeItemFromAddress(%this, %address)
 function directoryHandler::getFolderTreeItemFromAddress(%this, %address)
 {
 {
    //break down the address
    //break down the address

+ 58 - 133
Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.tscript

@@ -1,68 +1,31 @@
 function AssetBrowser_editAsset::saveAsset(%this)
 function AssetBrowser_editAsset::saveAsset(%this)
 {
 {
-   %file = AssetDatabase.getAssetFilePath(%this.editedAssetId);
-   %success = TamlWrite(AssetBrowser_editAsset.editedAsset, %file);
+   AssetBrowser_editAssetWindow.text = "Asset Properties";
    
    
-   AssetBrowser.reloadAsset(%this.editedAssetId);
-
-   AssetBrowser.refresh();
-   
-   %assetType = AssetDatabase.getAssetType(%this.editedAssetId);
-   %assetDef = AssetDatabase.acquireAsset(%this.editedAssetId);
-   %assetDef.refreshAsset();
-   
-   AssetBrowser.call("on" @ %assetType @ "Changed", %assetDef);
-   AssetDatabase.releaseAsset(%this.editedAssetId);
+   AssetBrowser.callAssetTypeFunc(%this.editedObjectType, "onSaveProperties", %this.editedObjectData);
+   AssetBrowser.callAssetTypeFunc(%this.editedObjectType, "onChanged", %this.editedObjectData);
 
 
    Canvas.popDialog(AssetBrowser_editAsset);
    Canvas.popDialog(AssetBrowser_editAsset);
 }
 }
 
 
 function AssetBrowser::editAsset(%this, %assetDef)
 function AssetBrowser::editAsset(%this, %assetDef)
 {
 {
-   //Find out what type it is
-   //If the passed-in definition param is blank, then we're likely called via a popup
-   if(%assetDef $= "")
+   if(%this.selectMode)
    {
    {
-      if(AssetDatabase.isDeclaredAsset(EditAssetPopup.assetId))
+      %this.selectAsset(%this.selectedAsset);
+   }
+   else
+   {
+      if(isObject(%assetDef))
       {
       {
-         %assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
+         %assetType = AssetDatabase.getAssetType(%assetDef.getAssetId());
+         %this.callAssetTypeFunc(%assetType, "onEdit", %assetDef);
       }
       }
-      else
+      else if(%this.popupMenu.objectType !$= "" && %this.popupMenu.objectData !$= "")
       {
       {
-         //if it's not a valid asset at all, then it's probably a folder
-         %folder = strreplace(EditAssetPopup.assetId, ":", "/");
-         if(isDirectory(%folder))
-         {
-            AssetBrowser.navigateTo(%folder);
-         }
-         else
-         {
-            %object = getToken(EditAssetPopup.assetId, ":", 1);
-            if(isObject(%object))
-            {
-               if(%object.isMemberOfClass("SimDatablock"))
-               {
-                  DatablockEditorPlugin.openDatablock( %object );
-               }
-            }
-         }
+         %this.callAssetTypeFunc(%this.popupMenu.objectType, "onEdit", %this.popupMenu.objectData);
       }
       }
    }
    }
-   else if(AssetDatabase.isDeclaredAsset(%assetDef))
-   {
-      //Turns out we were passed an assetid, not an asset definition. 
-      //Grab the asset def from that  
-      %assetDef = AssetDatabase.acquireAsset(%assetDef);
-   }
-      
-   if(%assetDef !$= "")
-   {
-      %assetType = %assetDef.getClassName();
-      
-      //Build out the edit command
-      %buildCommand = %this @ ".edit" @ %assetType @ "(" @ %assetDef @ ");";
-      eval(%buildCommand);
-   }
 }
 }
 
 
 function AssetBrowser::appendSubLevel(%this)
 function AssetBrowser::appendSubLevel(%this)
@@ -75,27 +38,9 @@ function AssetBrowser::appendSubLevel(%this)
 
 
 function AssetBrowser::editAssetInfo(%this)
 function AssetBrowser::editAssetInfo(%this)
 {
 {
-   Canvas.pushDialog(AssetBrowser_editAsset); 
-   
-   %assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
-   
-   AssetBrowser.tempAsset = %assetDef.deepClone();
-   
-   AssetEditInspector.inspect(AssetBrowser.tempAsset);  
-   AssetBrowser_editAsset.editedAssetId = EditAssetPopup.assetId;
-   AssetBrowser_editAsset.editedAsset = AssetBrowser.tempAsset;
-   
-   //remove some of the groups we don't need:
-   for(%i=0; %i < AssetEditInspector.getCount(); %i++)
+   if(%this.popupMenu.objectType !$= "" && %this.popupMenu.objectData !$= "")
    {
    {
-      %caption = AssetEditInspector.getObject(%i).caption;
-      
-      if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing" 
-         || %caption $= "Persistence" || %caption $= "Dynamic Fields")
-      {
-         AssetEditInspector.remove(AssetEditInspector.getObject(%i));
-         %i--;
-      }
+      %this.callAssetTypeFunc(%this.popupMenu.objectType, "onEditProperties", %this.popupMenu.objectData);
    }
    }
 }
 }
 
 
@@ -127,17 +72,17 @@ function AssetBrowser::refreshAsset(%this, %assetId)
 //------------------------------------------------------------
 //------------------------------------------------------------
 function AssetBrowser::regeneratePreviewImage(%this)
 function AssetBrowser::regeneratePreviewImage(%this)
 {
 {
-   %assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
+   %assetDef = AssetDatabase.acquireAsset(AssetBrowser.popupMenu.objectData);
    %dummyObj = new ScriptObject();
    %dummyObj = new ScriptObject();
-   %dummyObj.moduleName = AssetDatabase.getAssetModule(EditAssetPopup.assetId).moduleId;
-   %dummyObj.assetName = AssetDatabase.getAssetName(EditAssetPopup.assetId);
-
-   %regenCommand = "AssetBrowser.generate" @ EditAssetPopup.assetType @ 
-                     "PreviewImage(" @ %dummyObj @ ", true);";
-   eval(%regenCommand);
+   %dummyObj.moduleName = AssetDatabase.getAssetModule(AssetBrowser.popupMenu.objectData).moduleId;
+   %dummyObj.assetName = AssetDatabase.getAssetName(AssetBrowser.popupMenu.objectData);
+   
+   %assetType = AssetBrowser.popupMenu.objectType;
+   
+   AssetBrowser.callAssetTypeFunc(%assetType, "generatePreviewImage", %dummyObj, true);
 
 
    %dummyObj.delete();
    %dummyObj.delete();
-   AssetDatabase.releaseAsset(EditAssetPopup.assetId);
+   AssetDatabase.releaseAsset(AssetBrowser.popupMenu.objectData);
 }
 }
 
 
 //------------------------------------------------------------
 //------------------------------------------------------------
@@ -344,8 +289,8 @@ function moveAssetLooseFile(%file, %destinationPath)
 
 
 function AssetBrowser::duplicateAsset(%this)
 function AssetBrowser::duplicateAsset(%this)
 {
 {
-   %assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
-   %assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
+   %assetDef = AssetDatabase.acquireAsset(%this.popupMenu.objectData);
+   %assetType = %this.popupMenu.objectType;
    
    
    %trailingNum = getTrailingNumber(%assetDef.assetName);
    %trailingNum = getTrailingNumber(%assetDef.assetName);
    if(%trailingNum != -1)
    if(%trailingNum != -1)
@@ -370,18 +315,16 @@ function AssetBrowser::duplicateAsset(%this)
 
 
 function AssetBrowser::doDuplicateAsset(%this)
 function AssetBrowser::doDuplicateAsset(%this)
 {
 {
-   %assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
-   %assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
+   %assetType = %this.popupMenu.objectType;
+   %assetDef = AssetDatabase.acquireAsset(%this.popupMenu.objectData);
    
    
    if(AssetBrowser_assetNameEditTxt.text !$= "" && AssetBrowser_assetNameEditTxt.text !$= %assetDef.assetName)
    if(AssetBrowser_assetNameEditTxt.text !$= "" && AssetBrowser_assetNameEditTxt.text !$= %assetDef.assetName)
    {
    {
-      //this acts as a redirect based on asset type and will enact the appropriate function
-      //so for a GameObjectAsset, it'll become %this.duplicateGameObjectAsset(%assetDef, %targetModule);
-      //and call to the tools/assetBrowser/scripts/assetTypes/gameObject.tscript file for implementation
-      if(%this.isMethod("duplicate"@%assetType))
-         eval(%this @ ".duplicate"@%assetType@"("@%assetDef@","@AssetBrowser_assetNameEditTxt.text@");");
-         
-      AssetBrowser.refresh();
+      AssetDatabase.releaseAsset(%this.popupMenu.objectData);
+      
+      %this.callAssetTypeFunc(%assetType, "onDuplicate", %this.popupMenu.objectData, AssetBrowser_assetNameEditTxt.text);
+   
+      %this.refresh();
    }
    }
 }
 }
 
 
@@ -440,31 +383,8 @@ function AssetBrowser::confirmDeleteAsset(%this)
    %currentSelectedItem = AssetBrowserFilterTree.getSelectedItem();
    %currentSelectedItem = AssetBrowserFilterTree.getSelectedItem();
    %currentItemParent = AssetBrowserFilterTree.getParentItem(%currentSelectedItem);
    %currentItemParent = AssetBrowserFilterTree.getParentItem(%currentSelectedItem);
    
    
-   if(EditFolderPopup.visible)
-   {
-      if(EditFolderPopup.dirPath !$= "")
-         %folderPath = EditFolderPopup.dirPath;
-      else
-         %folderPath = AssetBrowserFilterTree.getItemValue(%currentSelectedItem) @ "/" @ AssetBrowserFilterTree.getItemText(%currentSelectedItem);
-         
-      if(%this.isMethod("deleteFolder"))
-         eval(%this @ ".deleteFolder(\""@%folderPath@"\");");
-   }   
-   else
-   {
-      %assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
-      %assetType = AssetDatabase.getAssetType(EditAssetPopup.assetType);
-      
-      if(!isObject(%assetDef))
-         return;
-      
-      //Do any cleanup required given the type
-      if(%this.isMethod("delete"@%assetType))
-         eval(%this @ ".delete"@%assetType@"("@%assetDef@");");
-      
-      AssetDatabase.deleteAsset(EditAssetPopup.assetId, true, false);
-   }
-
+   %this.callAssetTypeFunc(%this.popupMenu.objectType, "onDelete", %this.popupMenu.objectData);
+   
    %this.refresh();
    %this.refresh();
 }
 }
 
 
@@ -522,21 +442,27 @@ function AssetBrowser::updateAssetReference(%this, %targetPath, %oldAssetId, %ne
 
 
 function AssetBrowser::openFileLocation(%this)
 function AssetBrowser::openFileLocation(%this)
 {
 {
+   if(isFunction("systemCommand"))
+   {
+      warnf("AssetBrowser::openFileLocation() - systemCommand function disabled in this build. Unable to launch application to edit file.");
+      return;  
+   }
+   
    %filePath = "";
    %filePath = "";
-   if(EditAssetPopup.assetId !$= "")
+   if(%this.popuMenu.assetId !$= "")
    {
    {
-      if(AssetDatabase.isDeclaredAsset(EditAssetPopup.assetId))
+      if(AssetDatabase.isDeclaredAsset(%this.popuMenu.objectData))
       {
       {
-         %filePath = AssetDatabase.getAssetPath(EditAssetPopup.assetId);
+         %filePath = AssetDatabase.getAssetPath(%this.popuMenu.objectData);
       }
       }
       else
       else
       {
       {
          //probably a file path
          //probably a file path
-         %pathSplit = strpos(EditAssetPopup.assetId, ":");
+         %pathSplit = strpos(%this.popuMenu.objectData, ":");
          if(%pathSplit != -1)
          if(%pathSplit != -1)
          {
          {
-            %path = getSubStr(EditAssetPopup.assetId, 0, %pathSplit);
-            %file = getSubStr(EditAssetPopup.assetId, %pathSplit + 1);
+            %path = getSubStr(%this.popuMenu.objectData, 0, %pathSplit);
+            %file = getSubStr(%this.popuMenu.objectData, %pathSplit + 1);
             
             
             //datablocks pack the originator file in the parent path as-is, so check that
             //datablocks pack the originator file in the parent path as-is, so check that
             if(fileExt(%path) !$= "")
             if(fileExt(%path) !$= "")
@@ -550,14 +476,6 @@ function AssetBrowser::openFileLocation(%this)
          }
          }
       }
       }
    }
    }
-   else if(EditLevelAssetPopup.assetId !$= "")
-   {
-      %filePath = AssetDatabase.getAssetPath(EditAssetPopup.assetId);
-   }
-   else if(EditTerrainAssetPopup.assetId !$= "")
-   {
-      %filePath = AssetDatabase.getAssetPath(EditAssetPopup.assetId);
-   }
    
    
    if(isFile(%filePath) || isDirectory(%filePath))
    if(isFile(%filePath) || isDirectory(%filePath))
    {
    {
@@ -578,20 +496,27 @@ function AssetBrowser::openFileLocation(%this)
    }
    }
 }
 }
 
 
-function AssetBrowser::openFolderLocation(%this)
+function AssetBrowser::openFolderLocation(%this, %folderPath)
 {
 {
-   %filePath = AssetBrowser.dirHandler.currentAddress;
+   if(!isFunction("systemCommand"))
+   {
+      warn("AssetBrowser::openFolderLocation() - systemCommand function disabled in this build. Unable to launch application to open this folder.");
+      return;
+   }
+   
+   if(%folderPath $= "")
+      %folderPath = filePath(%this.dirHandler.currentAddress);
    
    
-   if(%filePath !$= "")
+   if(%folderPath !$= "")
    {
    {
       if($platform $= "windows")
       if($platform $= "windows")
       {
       {
-         %cmd = "cd \"" @ makeFullPath(%filePath) @ "\" && start .";
+         %cmd = "cd \"" @ makeFullPath(%folderPath) @ "\" && start .";
          systemCommand(%cmd);
          systemCommand(%cmd);
       }
       }
       else
       else
       {
       {
-         %cmd = "open \"" @ makeFullPath(%filePath) @ "\"";
+         %cmd = "open \"" @ makeFullPath(%folderPath) @ "\"";
          systemCommand(%cmd);
          systemCommand(%cmd);
       }
       }
    }
    }

+ 2 - 6
Templates/BaseGame/game/tools/assetBrowser/scripts/newAsset.tscript

@@ -119,11 +119,7 @@ function AssetBrowser::setupCreateNewAsset(%this, %assetType, %moduleName, %call
    NewAssetPropertiesInspector.addCallbackField("description", "Description", "Command",  "Description of the new asset", "", "", "updateNewAssetField", %this.newAssetSettings);   
    NewAssetPropertiesInspector.addCallbackField("description", "Description", "Command",  "Description of the new asset", "", "", "updateNewAssetField", %this.newAssetSettings);   
    NewAssetPropertiesInspector.endGroup();
    NewAssetPropertiesInspector.endGroup();
    
    
-   if(%this.isMethod("setupCreateNew"@%assetType))
-   {
-      %command = %this @ ".setupCreateNew"@%assetType @"();";
-      eval(%command);
-   }
+   %this.callAssetTypeFunc(%assetType, "setupCreateNew");
    
    
    NewAssetPropertiesInspector.refresh();
    NewAssetPropertiesInspector.refresh();
 }
 }
@@ -255,7 +251,7 @@ function CreateNewAsset()
 		return;
 		return;
 	}
 	}
 	
 	
-	%assetFilePath = eval(AssetBrowser @ ".create"@%assetType@"();");
+	%assetFilePath = AssetBrowser.callAssetTypeFunc(%assetType, "onCreateNew");
 	
 	
 	Canvas.popDialog(AssetBrowser_newAsset);
 	Canvas.popDialog(AssetBrowser_newAsset);
 	
 	

+ 9 - 44
Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.tscript

@@ -183,8 +183,6 @@ function AssetBrowser::buildPopupMenus(%this)
          item[12] = "View Loose Files" TAB "" TAB "AssetBrowser.importLooseFiles();";
          item[12] = "View Loose Files" TAB "" TAB "AssetBrowser.importLooseFiles();";
          Item[ 13 ] = "-";
          Item[ 13 ] = "-";
          item[ 14 ] = "Open Folder Location" TAB "" TAB "AssetBrowser.openFolderLocation();";
          item[ 14 ] = "Open Folder Location" TAB "" TAB "AssetBrowser.openFolderLocation();";
-         
-      
       };
       };
    }
    }
    
    
@@ -266,13 +264,18 @@ function AssetBrowser::buildPopupMenus(%this)
          radioSelection = false;
          radioSelection = false;
       };
       };
       
       
-      AssetTypeListPopup.addItem(0, AssetFilterTypeList.getKey(0) TAB "" TAB "AssetBrowser.toggleAssetTypeFilter(" @ 0 @ ");");
+      AssetTypeListPopup.addItem(0, "All" TAB "" TAB %this @ ".toggleAssetTypeFilter(0);");
       AssetTypeListPopup.addItem(1, "-");
       AssetTypeListPopup.addItem(1, "-");
       
       
-      for(%i=1; %i < AssetFilterTypeList.Count(); %i++)
+      %listIndex = 1;
+      for(%i=0; %i < ABAssetTypesList.Count(); %i++)
       {
       {
-         %assetTypeName = AssetFilterTypeList.getKey(%i);
-         AssetTypeListPopup.addItem(%i+1, %assetTypeName TAB "" TAB "AssetBrowser.toggleAssetTypeFilter(" @ %i + 1 @ ");");
+         %assetTypeData = ABAssetTypesList.getValue(%i);
+         if(getField(%assetTypeData, 3) != true)
+            continue;
+            
+         AssetTypeListPopup.addItem(%listIndex, getField(%assetTypeData,1) TAB "" TAB %this @ ".toggleAssetTypeFilter(" @ %listIndex @ ");");
+         %listIndex++;
       }
       }
    }
    }
    
    
@@ -315,44 +318,6 @@ function AssetBrowser::buildPopupMenus(%this)
       };
       };
    }
    }
    
    
-   if( !isObject( EditGameObjectAssetPopup ) )
-   {
-      new PopupMenu( EditGameObjectAssetPopup )
-      {
-         superClass = "MenuBuilder";
-         class = "EditorWorldMenu";
-         //isPopup = true;
-         
-         item[ 0 ] = "Open GameObject Editor" TAB "" TAB "echo(\"Not yet implemented.\");";
-         item[ 1 ] = "Edit GameObject Script" TAB "" TAB "AssetBrowser.editGameObjectAssetScript(AssetDatabase.acquireAsset(EditGameObjectAssetPopup.assetId));";
-         item[ 2 ] = "-";
-         item[ 3 ] = "Apply Instance to GameObject" TAB "" TAB "AssetBrowser.applyInstanceToGameObject(AssetDatabase.acquireAsset(EditGameObjectAssetPopup.assetId));";
-         item[ 4 ] = "Reset Instance to GameObject" TAB "" TAB "echo(\"Not yet implemented.\");";
-         item[ 5 ] = "-";
-         item[ 6 ] = "Create Child GameObject" TAB "" TAB "echo(\"Not yet implemented.\");";
-      };
-   }
-   
-   //Asset Import Resolution menus
-   if( !isObject( ImportAssetResolutionsPopup ) )
-   {
-      %this.ImportAssetResolutionsPopup = new PopupMenu( ImportAssetResolutionsPopup )
-      {
-         superClass = "MenuBuilder";
-         class = "EditorWorldMenu";
-         
-         item[0] = "Use original Asset for duplicates" TAB "" TAB "";
-         item[1] = "Override duplicate with new Asset" TAB "" TAB "";
-         item[2] = "-";
-         item[3] = "Rename Asset" TAB "" TAB "";
-         item[4] = "-";
-         item[5] = "Find missing file" TAB "" TAB "ImportAssetWindow.findMissingFile(ImportAssetResolutionsPopup.assetItem);";
-         item[6] = "-";
-         item[7] = "Edit Asset properties" TAB "" TAB "";
-      
-      };
-   }
-
    //
    //
    // Import Asset Actions
    // Import Asset Actions
    //
    //

+ 2 - 2
Templates/BaseGame/game/tools/gui/fieldTypes/listField.tscript

@@ -87,11 +87,11 @@ function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabe
       eval(%setCommand);
       eval(%setCommand);
    }
    }
    
    
-   %listCount = getTokenCount(%fieldDataVals, ",");
+   %listCount = getTokenCount(%fieldDataVals, ",;");
    
    
    for(%i=0; %i < %listCount; %i++)
    for(%i=0; %i < %listCount; %i++)
    {
    {
-      %entryText = getToken(%fieldDataVals, ",", %i);
+      %entryText = getToken(%fieldDataVals, ",;", %i);
       %editControl.add(%entryText); 
       %editControl.add(%entryText); 
    }
    }
 
 

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.