diff --git a/Engine/source/T3D/assets/ShapeAsset.cpp b/Engine/source/T3D/assets/ShapeAsset.cpp index f20239070..906a516a4 100644 --- a/Engine/source/T3D/assets/ShapeAsset.cpp +++ b/Engine/source/T3D/assets/ShapeAsset.cpp @@ -117,6 +117,8 @@ ShapeAsset::ShapeAsset() { mFileName = StringTable->EmptyString(); mConstructorFileName = StringTable->EmptyString(); + mFilePath = StringTable->EmptyString(); + mConstructorFilePath = StringTable->EmptyString(); } //----------------------------------------------------------------------------- @@ -163,10 +165,10 @@ void ShapeAsset::initializeAsset() ResourceManager::get().getChangedSignal().notify(this, &ShapeAsset::_onResourceChanged); //Ensure our path is expando'd if it isn't already - if (!Platform::isFullPath(mFileName)) - mFileName = getOwned() ? expandAssetFilePath(mFileName) : mFileName; + if (!Platform::isFullPath(mFilePath)) + mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath; - mConstructorFileName = expandAssetFilePath(mConstructorFileName); + mConstructorFilePath = expandAssetFilePath(mConstructorFilePath); loadShape(); } @@ -258,7 +260,7 @@ bool ShapeAsset::loadShape() } } - mShape = ResourceManager::get().load(mFileName); + mShape = ResourceManager::get().load(mFilePath); if (!mShape) { @@ -439,7 +441,7 @@ void ShapeAsset::onAssetRefresh(void) // Update. if(!Platform::isFullPath(mFileName)) - mFileName = getOwned() ? expandAssetFilePath(mFileName) : mFileName; + mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath; loadShape(); } diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index df2938105..a78dcddbb 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -64,6 +64,8 @@ class ShapeAsset : public AssetBase protected: StringTableEntry mFileName; StringTableEntry mConstructorFileName; + StringTableEntry mFilePath; + StringTableEntry mConstructorFilePath; Resource mShape; //Material assets we're dependent on and use @@ -96,9 +98,9 @@ public: Resource getShapeResource() { return mShape; } void SplitSequencePathAndName(String& srcPath, String& srcName); - StringTableEntry getShapeFilename() { return mFileName; } + StringTableEntry getShapeFilename() { return mFilePath; } - U32 getShapeFilenameHash() { return _StringTable::hashString(mFileName); } + U32 getShapeFilenameHash() { return _StringTable::hashString(mFilePath); } Vector> getMaterialAssets() { return mMaterialAssets; } @@ -128,6 +130,9 @@ public: void setShapeConstructorFile(const char* pScriptFile); inline StringTableEntry getShapeConstructorFile(void) const { return mConstructorFileName; }; + inline StringTableEntry getShapeFilePath(void) const { return mFilePath; }; + inline StringTableEntry getShapeConstructorFilePath(void) const { return mConstructorFilePath; }; + static bool getAssetByFilename(StringTableEntry fileName, AssetPtr* shapeAsset); static StringTableEntry getAssetIdByFilename(StringTableEntry fileName); static bool getAssetById(StringTableEntry assetId, AssetPtr* shapeAsset); diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index afc00ac8a..1b1f8c2b1 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -1833,6 +1833,9 @@ void AssetImporter::resolveAssetItemIssues(AssetImportObject* assetItem) // StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath) { + //Just in case we're reusing the same importer object from another import session, nuke any existing files + resetImportSession(true); + String assetType = getAssetTypeByFile(filePath); if (assetType == String("Folder") || assetType == String("Zip")) @@ -1902,10 +1905,12 @@ StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath) } #if TORQUE_DEBUG + Con::printf("/***************/"); for (U32 i = 0; i < activityLog.size(); i++) { Con::printf(activityLog[i].c_str()); } + Con::printf("/***************/"); #endif if (hasIssues) @@ -2045,7 +2050,7 @@ void AssetImporter::importAssets(AssetImportObject* assetItem) } } - if (assetPath.isEmpty() && importingAssets[i]->assetType != String("MaterialAsset")) + if (assetPath.isEmpty() && childItem->assetType != String("MaterialAsset")) { dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Import attempt of %s failed, so skipping asset.", childItem->assetName.c_str()); activityLog.push_back(importLogBuffer); diff --git a/Engine/source/gui/worldEditor/worldEditor.cpp b/Engine/source/gui/worldEditor/worldEditor.cpp index 84e4e309f..64b1512b4 100644 --- a/Engine/source/gui/worldEditor/worldEditor.cpp +++ b/Engine/source/gui/worldEditor/worldEditor.cpp @@ -3668,7 +3668,7 @@ DefineEngineMethod( WorldEditor, colladaExportSelection, void, ( const char* pat object->colladaExportSelection( path ); } -void WorldEditor::makeSelectionPrefab( const char *filename ) +void WorldEditor::makeSelectionPrefab( const char *filename, bool dontReplaceOriginals ) { if ( mSelected->size() == 0 ) { @@ -3761,25 +3761,28 @@ void WorldEditor::makeSelectionPrefab( const char *filename ) } // Save out .prefab file. - group->save( filename, false, "$ThisPrefab = " ); + group->save( filename, false, "$ThisPrefab = " ); - // Allocate Prefab object and add to level. - Prefab *fab = new Prefab(); - fab->setFile( filename ); - fabMat.inverse(); - fab->setTransform( fabMat ); - fab->registerObject(); - scene->addObject( fab ); + if (!dontReplaceOriginals) + { + // Allocate Prefab object and add to level. + Prefab* fab = new Prefab(); + fab->setFile(filename); + fabMat.inverse(); + fab->setTransform(fabMat); + fab->registerObject(); + scene->addObject(fab); - // Select it, mark level as dirty. - clearSelection(); - selectObject( fab ); - setDirty(); + // Select it, mark level as dirty. + clearSelection(); + selectObject(fab); + setDirty(); - // Delete original objects and temporary SimGroup. - group->deleteObject(); - for ( S32 i = 0; i < cleanup.size(); i++ ) - cleanup[i]->deleteObject(); + // Delete original objects and temporary SimGroup. + group->deleteObject(); + for (S32 i = 0; i < cleanup.size(); i++) + cleanup[i]->deleteObject(); + } } void WorldEditor::explodeSelectedPrefab() @@ -3827,19 +3830,19 @@ void WorldEditor::explodeSelectedPrefab() setDirty(); } -void WorldEditor::makeSelectionAMesh(const char *filename) +bool WorldEditor::makeSelectionAMesh(const char *filename) { if (mSelected->size() == 0) { Con::errorf("WorldEditor::makeSelectionAMesh - Nothing selected."); - return; + return false; } Scene* scene = Scene::getRootScene(); if (!scene) { Con::errorf("WorldEditor::makeSelectionAMesh - Could not find root Scene."); - return; + return false; } Vector< SimObject* > stack; @@ -3887,7 +3890,7 @@ void WorldEditor::makeSelectionAMesh(const char *filename) if (found.empty()) { Con::warnf("WorldEditor::makeSelectionPrefab - No valid objects selected."); - return; + return false; } // SimGroup we collect prefab objects into. @@ -3911,7 +3914,7 @@ void WorldEditor::makeSelectionAMesh(const char *filename) } if ( objectList.empty() ) - return; + return false; // Point3F centroid; @@ -3982,6 +3985,11 @@ void WorldEditor::makeSelectionAMesh(const char *filename) ColladaUtils::exportToCollada(filename, exportData); // + if (Platform::isFile(filename)) + return true; + else + return false; + // Allocate TSStatic object and add to level. TSStatic *ts = new TSStatic(); ts->setShapeFileName(StringTable->insert(filename)); @@ -4000,11 +4008,11 @@ void WorldEditor::makeSelectionAMesh(const char *filename) objectList[i]->deleteObject(); } -DefineEngineMethod( WorldEditor, makeSelectionPrefab, void, ( const char* filename ),, +DefineEngineMethod( WorldEditor, makeSelectionPrefab, void, ( const char* filename, bool dontDeleteOriginals ), (false), "Save selected objects to a .prefab file and replace them in the level with a Prefab object." "@param filename Prefab file to save the selected objects to.") { - object->makeSelectionPrefab( filename ); + object->makeSelectionPrefab( filename, dontDeleteOriginals); } DefineEngineMethod( WorldEditor, explodeSelectedPrefab, void, (),, @@ -4013,11 +4021,11 @@ DefineEngineMethod( WorldEditor, explodeSelectedPrefab, void, (),, object->explodeSelectedPrefab(); } -DefineEngineMethod(WorldEditor, makeSelectionAMesh, void, (const char* filename), , +DefineEngineMethod(WorldEditor, makeSelectionAMesh, bool, (const char* filename), , "Save selected objects to a .dae collada file and replace them in the level with a TSStatic object." "@param filename collada file to save the selected objects to.") { - object->makeSelectionAMesh(filename); + return object->makeSelectionAMesh(filename); } DefineEngineMethod( WorldEditor, mountRelative, void, ( SceneObject *objA, SceneObject *objB ),, diff --git a/Engine/source/gui/worldEditor/worldEditor.h b/Engine/source/gui/worldEditor/worldEditor.h index e903e024b..01c7d396c 100644 --- a/Engine/source/gui/worldEditor/worldEditor.h +++ b/Engine/source/gui/worldEditor/worldEditor.h @@ -114,10 +114,10 @@ class WorldEditor : public EditTSCtrl void colladaExportSelection( const String &path ); - void makeSelectionPrefab( const char *filename ); + void makeSelectionPrefab( const char *filename, bool dontReplaceOriginals = false); void explodeSelectedPrefab(); - void makeSelectionAMesh(const char *filename); + bool makeSelectionAMesh(const char *filename); // static SceneObject* getClientObj(SceneObject *); diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui index 6b2c57a8e..40d772206 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui @@ -310,7 +310,7 @@ }; new GuiIconButtonCtrl() { buttonMargin = "4 4"; - iconBitmap = "tools/gui/images/stencilIcons/return.png"; + iconBitmap = "tools/gui/images/stencilIcons/gear.png"; iconLocation = "Left"; sizeIconToButton = "1"; makeIconSquare = "1"; @@ -328,12 +328,12 @@ profile = "ToolsGuiDefaultProfile"; visible = "1"; active = "1"; - command = "AssetBrowser.refreshDatabases();"; + command = "AssetBrowser.openAssetSettings();"; tooltipProfile = "GuiToolTipProfile"; - tooltip = "Refresh Asset and Module databases."; + tooltip = "Edit the editor settings for Assets."; hovertime = "1000"; isContainer = "0"; - internalName = "refreshDatabasesButton"; + internalName = "editAssetSettingsButton"; canSave = "1"; canSaveDynamicFields = "0"; }; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.cs index d4c30762a..381ccff65 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.cs @@ -1218,11 +1218,11 @@ function AssetBrowserFilterTree::onRightMouseDown(%this, %itemId) // // // -function AssetBrowser::refreshDatabases(%this) +function AssetBrowser::openAssetSettings(%this) { - //ModuleDatabase.scanModules( "data", false ); - //ModuleDatabase.unloadGroup( "Game" ); - //ModuleDatabase.LoadGroup( "Game" ); + ESettingsWindow.toggleEditorSettings(); + %assetEditIndex = ESettingsWindowList.findTextIndex("Asset Editing"); + ESettingsWindowList.setSelectedRow( %assetEditIndex ); } function AssetBrowser::showVisibiltyOptions(%this) diff --git a/Templates/BaseGame/game/tools/gui/images/stencilIcons/gear.png b/Templates/BaseGame/game/tools/gui/images/stencilIcons/gear.png new file mode 100644 index 000000000..095b4ae75 Binary files /dev/null and b/Templates/BaseGame/game/tools/gui/images/stencilIcons/gear.png differ diff --git a/Templates/BaseGame/game/tools/settings.xml b/Templates/BaseGame/game/tools/settings.xml index fa508e139..0239f2466 100644 --- a/Templates/BaseGame/game/tools/settings.xml +++ b/Templates/BaseGame/game/tools/settings.xml @@ -246,7 +246,7 @@ 17 16 15 255 59 58 57 255 50 49 48 255 - 77 77 77 255 + 120 120 120 255 43 43 43 255 72 70 68 255 178 175 172 255 diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs index 7571a34c0..27e9ce4cb 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs @@ -573,10 +573,10 @@ function EditorExplodePrefab() EditorTree.buildVisibleTree( true ); } -function makeSelectedAMesh() +function makeSelectedAMesh(%assetId) { - - %dlg = new SaveFileDialog() + + /*%dlg = new SaveFileDialog() { Filters = "Collada file (*.dae)|*.dae|"; DefaultPath = $Pref::WorldEditor::LastPath; @@ -598,9 +598,45 @@ function makeSelectedAMesh() %dlg.delete(); if ( !%ret ) - return; + return;*/ + + %assetDef = AssetDatabase.acquireAsset(%assetId); - EWorldEditor.makeSelectionAMesh( %saveFile ); + %assetPath = AssetDatabase.getAssetPath(%assetId); + %filePath = %assetPath @ "/" @ %assetDef.AssetName @ ".dae"; + + %fileName = fileName(%filePath); + + %assetDef.fileName = %fileName; + %assetDef.saveAsset(); + + %success = EWorldEditor.makeSelectionAMesh( %filePath ); + + AssetDatabase.refreshAsset(%assetId); + + if(%success) + { + //ok, cool it worked, so clear out the old + //First, get our center of the currently selected objects + %selectionCenter = EWorldEditor.getSelectionCentroid(); + + //Next, for safety purposes(and convenience!) we'll make them a prefab aping off the filepath/name provided + //TODO: Make this an editor option + %prefabPath = %assetPath @ "/" @ %assetDef.AssetName @ ".prefab"; + EWorldEditor.makeSelectionPrefab(%prefabPath, true); + + //Next, nuke 'em + EditorMenuEditDelete(); + + //now make a new static + %newStatic = new TSStatic() + { + shapeAsset = %assetId; + position = %selectionCenter; + }; + + getRootScene().add(%newStatic); + } EditorTree.buildVisibleTree( true ); }