| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870 |
- //AssetBrowser.addToolbarButton
- function AssetBrowser::addToolbarButton(%this)
- {
- %button = new GuiBitmapButtonCtrl() {
- canSaveDynamicFields = "0";
- internalName = AssetBrowserBtn;
- Enabled = "1";
- isContainer = "0";
- Profile = "ToolsGuiButtonProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- position = "180 0";
- Extent = "25 19";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- Command = "AssetBrowser.ShowDialog();";
- tooltipprofile = "ToolsGuiToolTipProfile";
- ToolTip = "Asset Browser";
- hovertime = "750";
- bitmapAsset = "ToolsModule:assetBrowser_n_image";
- bitmapMode = "Stretched";
- buttonType = "ToggleButton";
- groupNum = "0";
- useMouseEvents = "0";
- };
- ToolsToolbarArray.add(%button);
- EWToolsToolbar.setExtent((29 + 4) * (ToolsToolbarArray.getCount()) + 4 SPC "32");
- }
- //
- function AssetBrowser::initialize(%this)
- {
- // manage preview array
- if(!isObject(AssetPreviewArray))
- new ArrayObject(AssetPreviewArray);
-
- if(!isObject(ObjectCreator))
- new ScriptObject(ObjectCreator);
-
- if(!isObject(%this.dirHandler))
- {
- %this.dirHandler = makedirectoryHandler(AssetBrowser-->filterTree, "cache,shaderCache", "");
- %this.dirHandler.currentAddress = "data/";
- }
-
- AssetBrowser-->filterTree.buildIconTable( ":tools/classIcons/Prefab:tools/classIcons/Prefab" @
- ":tools/classIcons/SimSet:tools/classIcons/SimSet");
-
- %this.isReImportingAsset = false;
-
- %this.coreModulesFilter = false;
- %this.toolsModulesFilter = false;
- %this.onlyShowModulesWithAssets = false;
-
- %this.folderPanelState = true;
- %this.folderPanelSplit = 0;
-
- %this.templateFilesPath = "tools/assetBrowser/scripts/templateFiles/";
-
- //First, build our our list of active modules
- %modulesList = ModuleDatabase.findModules(true);
-
- AssetBrowser-->previewSlider.setValue(EditorSettings.value("Assets/Browser/previewTileSize", "1.0"));
-
- AssetBrowser-->filterAssetsButton.setActive(true);
- }
- function AssetBrowser::onAdd(%this)
- {
- }
- function AssetBrowser::onWake(%this)
- {
- %this.initialize();
-
- // Make the window fit next to the side panel
- // We do a simple resize so that we don't have to redo the whole GUI layout
- %newWidth = getWord($pref::Video::mode, 0) - 360;
- %vertPos = getWord($pref::Video::mode, 1) - 360 - 35;
- AssetBrowserWindow.resize("0", %vertPos, %newWidth, "360");
- AssetBrowserWindow.dockPanel();
- }
- function AssetBrowser::onDialogPop(%this)
- {
- $AssetBrowser::Open = false;
- %lastPosExt = AssetBrowserWindow.position SPC AssetBrowserWindow.extent;
- EditorSettings.setValue("Assets/Browser/LastPosExt", %lastPosExt);
- }
- function AssetBrowser::onDialogPush(%this)
- {
- $AssetBrowser::Open = true;
- EditorGui.updateSideBar();
- }
- function AssetBrowser::setTab(%this, %tab, %text, %command)
- {
- if(isObject(%tab))
- {
- %tab.setActive(true);
- %tab.setHidden(false);
- %tab.setText(%text);
- %tab.command = %command;
- }
- }
- function AssetBrowser::putToFront(%this)
- {
- // Close the object
- AssetBrowser.hideDialog();
- // Create the object again so it will render on top
- AssetBrowser.ShowDialog();
- // Put the focus on this window
- AssetBrowser.restoreLastPosExt();
- AssetBrowserWindow.selectWindow();
- }
- function AssetBrowser::restoreLastPosExt(%this)
- {
- %lastPosExt = EditorSettings.value("Assets/Browser/LastPosExt", "");
- if(%lastPosExt !$= "")
- {
- AssetBrowserWindow.resize(getWord(%lastPosExt, 0), getWord(%lastPosExt, 1), getWord(%lastPosExt, 2), getWord(%lastPosExt, 3));
- }
- EditorGui.updateSideBar();
- }
- function contentTreeTabBook::onTabSelected(%this, %tabText, %tabIndex)
- {
- if(%tabText $= "Content")
- {
- //Force it to navigate to current active directory, which also rebuilds the
- //tree
- AssetBrowser.dirHandler.navigateTo(AssetBrowser.dirHandler.currentAddress);
- }
- else
- {
- AssetBrowser-->filterTree.clear();
- AssetBrowser-->filterTree.buildVisibleTree(true);
- }
- }
- //Filters
- function AssetBrowser::showFilterPopup(%this)
- {
- BrowserVisibilityPopup.showPopup(Canvas);
- }
- function AssetBrowser::viewCoreModulesFilter(%this)
- {
- %oldVal = EditorSettings.value("Assets/Browser/showCoreModule", false);
- %newVal = !%oldVal;
-
- %this.coreModulesFilter = %newVal;
-
- BrowserVisibilityPopup.checkItem(0,%newVal);
-
- EditorSettings.setValue("Assets/Browser/showCoreModule", %newVal);
-
- AssetBrowser.loadDirectories();
- }
- function AssetBrowser::viewToolsModulesFilter(%this)
- {
- %oldVal = EditorSettings.value("Assets/Browser/showToolsModule", false);
- %newVal = !%oldVal;
-
- %this.toolsModulesFilter = %newVal;
-
- BrowserVisibilityPopup.checkItem(1,%newVal);
-
- EditorSettings.setValue("Assets/Browser/showToolsModule", %newVal);
-
- AssetBrowser.loadDirectories();
- }
- function AssetBrowser::viewPopulatedModulesFilter(%this)
- {
- %oldVal = EditorSettings.value("Assets/Browser/showOnlyPopulatedModule", false);
- %newVal = !%oldVal;
-
- BrowserVisibilityPopup.checkItem(2,%newVal);
-
- EditorSettings.setValue("Assets/Browser/showOnlyPopulatedModule", %newVal);
-
- AssetBrowser.loadDirectories();
- }
- function AssetBrowser::toggleShowingFolders(%this)
- {
- %oldVal = EditorSettings.value("Assets/Browser/showFolders", false);
- %newVal = !%oldVal;
-
- BrowserVisibilityPopup.checkItem(4,%newVal);
-
- EditorSettings.setValue("Assets/Browser/showFolders", %newVal);
-
- AssetBrowser.loadDirectories();
- }
- function AssetBrowser::toggleShowingEmptyFolders(%this)
- {
- %oldVal = EditorSettings.value("Assets/Browser/showEmptyFolders", false);
- %newVal = !%oldVal;
-
- BrowserVisibilityPopup.checkItem(5,%newVal);
-
- EditorSettings.setValue("Assets/Browser/showEmptyFolders", %newVal);
-
- AssetBrowser.refresh();
- }
- function AssetBrowser::toggleAssetTypeFilter(%this, %assetTypeIdx)
- {
- %isChecked = AssetTypeListPopup.isItemChecked(%assetTypeIdx);
-
- //Clear existing filters
- if(%assetTypeIdx == 0)
- {
- for(%i=0; %i < AssetFilterTypeList.Count() + 1; %i++)
- {
- AssetTypeListPopup.checkItem(%i, false);
- }
-
- AssetTypeListPopup.checkItem(0, true);
- }
- else
- {
- if(%isChecked)
- {
- %anyOtherFilters = false;
- for(%i=1; %i < AssetFilterTypeList.Count() + 1; %i++)
- {
- if(%assetTypeIdx == %i)
- continue;
-
- if(AssetTypeListPopup.isItemChecked(%i))
- {
- %anyOtherFilters = true;
- break;
- }
- }
- }
-
- if(%isChecked && !%anyOtherFilters)
- {
- for(%i=0; %i < AssetFilterTypeList.Count() + 1; %i++)
- {
- AssetTypeListPopup.checkItem(%i, false);
- }
-
- AssetTypeListPopup.checkItem(0, true);
- }
- else
- {
- AssetTypeListPopup.checkItem(0, false);
- AssetTypeListPopup.checkItem(%assetTypeIdx, !%isChecked);
- }
- }
-
- //Update the displayed search text!
- //First, clear out the old type search term
- for(%i=0; %i < AssetSearchTerms.count(); %i++)
- {
- %action = AssetSearchTerms.getKey(%i);
- if(%action $= "type")
- {
- AssetSearchTerms.erase(%i);
- %i--;
- }
- }
-
- //Update our search terms
- %newSearchPhrase = "";
- for(%i=0; %i < AssetFilterTypeList.Count() + 1; %i++)
- {
- %isChecked = AssetTypeListPopup.isItemChecked(%i);
-
- if(!%isChecked)
- continue;
-
- %itemText = AssetTypeListPopup.getItemText(%i);
- if(%itemText $= "All")
- continue;
-
- AssetSearchTerms.add("type", %itemText);
- }
-
- %this.updateSearchTextFromFilter();
-
- %this.rebuildAssetArray();
- }
- //
- function AssetBrowser::selectAsset( %this, %asset )
- {
- if(AssetBrowser.selectCallback !$= "")
- {
- // The callback function should be ready to intake the returned material
- //eval("materialEd_previewMaterial." @ %propertyField @ " = " @ %value @ ";");
- if( AssetBrowser.returnType $= "name" )
- {
- // TODO!
- %name = "";
- eval( "" @ AssetBrowser.selectCallback @ "(" @ %name @ ");");
- }
- else
- {
- %command = "" @ AssetBrowser.selectCallback @ "(\"" @ %asset @ "\");";
- eval(%command);
- }
- }
- else
- {
- //try just setting the asset
- %this.changeAsset();
- }
-
- if(isObject(Inspector))
- Inspector.refresh();
-
- AssetBrowser.hideDialog();
- }
- function AssetBrowser::showDialog( %this, %AssetTypeFilter, %selectCallback, %targetObj, %fieldName, %returnType)
- {
- // Set the select callback
- AssetBrowser.selectCallback = %selectCallback;
- AssetBrowser.returnType = %returnType;
- AssetBrowser.assetTypeFilter = %AssetTypeFilter;
- AssetBrowser.fieldTargetObject = %targetObj;
- AssetBrowser.fieldTargetName = %fieldName;
- Canvas.popDialog(AssetBrowser);
- Canvas.pushDialog(AssetBrowser);
-
- AssetBrowser.setVisible(1);
- AssetBrowserWindow.setVisible(1);
- AssetBrowserWindow.selectWindow();
-
- if(AssetBrowserWindow.docked)
- AssetBrowserWindow.dockPanel();
- else
- AssetBrowserWindow.releasePanel();
-
- //If we're special-case filtering(like for selecting a given type), then ignore our normal
- //visibility filter
- if(%AssetTypeFilter !$= "")
- {
- AssetBrowser-->filterAssetsButton.setActive(false);
- }
- else
- {
- AssetBrowser-->filterAssetsButton.setActive(true);
- }
-
- if(%selectCallback $= "")
- {
- //we're not in selection mode, so just hide the select button
- %this-->SelectButton.setHidden(true);
- %this.selectMode = 0;
- }
- else
- {
- %this-->SelectButton.setHidden(false);
- %this.selectMode = 1;
- }
- AssetBrowser.loadDirectories();
-
- AssetBrowser.restoreLastPosExt();
- }
- function AssetBrowser::hideDialog( %this )
- {
- AssetBrowser.setVisible(1);
- AssetBrowserWindow.setVisible(1);
- Canvas.popDialog(AssetBrowser_addModule);
- Canvas.popDialog(ImportAssetWindow);
-
- Canvas.popDialog(AssetBrowser);
- }
- function AssetBrowser::toggleDialog( %this )
- {
- if(AssetBrowser.isAwake())
- {
- AssetBrowser.hideDialog();
- }
- else
- {
- AssetBrowser.showDialog();
- }
- }
- function AssetBrowser::buildAssetPreview( %this, %asset, %moduleName )
- {
- if(!isObject(%this.previewData))
- {
- %this.previewData = new ScriptObject();
- }
- else
- {
- %this.previewData.tooltip = "";
- %this.previewData.assetName = "";
- %this.previewData.previewImage = "";
- %this.previewData.doubleClickCommand = "";
- }
-
- %previewImage = "core/art/warnmat";
-
- if(/*%moduleName !$= "" && */ModuleDatabase.findModule(%moduleName, 1) !$= "")
- {
- %assetDesc = AssetDatabase.acquireAsset(%asset);
- %assetName = AssetDatabase.getAssetName(%asset);
- %assetType = AssetDatabase.getAssetType(%asset);
- }
- else
- {
- //special-case entry
- if(getFieldCount(%asset) > 1)
- {
- %assetType = getField(%asset,0);
- %assetName = getField(%asset, 1);
- %sdfasdgah = true;
-
- if(%assetType $= "Folder")
- {
- %fullPath = %moduleName !$= "" ? %moduleName @ "/" @ %assetName : %assetName;
- %fullPath = strreplace(%fullPath, "/", "_");
-
- if(isObject(%fullPath))
- %assetDesc = %fullPath;
- else
- %assetDesc = new ScriptObject(%fullPath);
-
- %assetDesc.dirPath = %moduleName;
- %assetDesc.assetName = %assetName;
- %assetDesc.description = %moduleName @ "/" @ %assetName;
- %assetDesc.assetType = %assetType;
- }
- else if(%assetType $= "Datablock")
- {
- %assetDesc = %assetName;
- %assetDesc.assetType = %assetType;
- }
- else if(%assetType $= "LooseFile")
- {
- %fullPath = %moduleName !$= "" ? %moduleName @ "/" @ %assetName : %assetName;
- %fullPath = strreplace(%fullPath, "/", "_");
- %fullPath = strreplace(%fullPath, ".", "-");
-
- if(isObject(%fullPath))
- %assetDesc = %fullPath;
- else
- %assetDesc = new ScriptObject(%fullPath);
-
- %assetDesc.dirPath = %moduleName;
- %assetDesc.assetName = %assetName;
- %assetDesc.description = %moduleName @ "/" @ %assetName;
- %assetDesc.assetType = %assetType;
- }
- else if(%assetType $= "Prefab")
- {
- %fullPath = %moduleName !$= "" ? %moduleName @ "/" @ %assetName : %assetName;
- %fullPath = strreplace(%fullPath, "/", "_");
- %fullPath = strreplace(%fullPath, ".", "-");
-
- if(isObject(%fullPath))
- %assetDesc = %fullPath;
- else
- %assetDesc = new ScriptObject(%fullPath);
-
- %assetDesc.dirPath = %moduleName;
- %assetDesc.assetName = %assetName;
- %assetDesc.description = %moduleName @ "/" @ %assetName;
- %assetDesc.assetType = %assetType;
- }
- else if(%assetType $= "Cpp")
- {
- %fullPath = %moduleName !$= "" ? %moduleName @ "/" @ %assetName : %assetName;
- %fullPath = strreplace(%fullPath, "/", "_");
- %fullPath = strreplace(%fullPath, ".", "-");
-
- if(isObject(%fullPath))
- %assetDesc = %fullPath;
- else
- %assetDesc = new ScriptObject(%fullPath);
-
- %assetDesc.dirPath = %moduleName;
- %assetDesc.assetName = %assetName;
- %assetDesc.description = %moduleName @ "/" @ %assetName;
- %assetDesc.assetType = %assetType;
- }
- else if(%assetType $= "tscript")
- {
- %fullPath = %moduleName !$= "" ? %moduleName @ "/" @ %assetName : %assetName;
- %fullPath = strreplace(%fullPath, "/", "_");
- %fullPath = strreplace(%fullPath, ".", "-");
-
- if(isObject(%fullPath))
- %assetDesc = %fullPath;
- else
- %assetDesc = new ScriptObject(%fullPath);
-
- %assetDesc.dirPath = %moduleName;
- %assetDesc.assetName = %assetName;
- %assetDesc.description = %moduleName @ "/" @ %assetName;
- %assetDesc.assetType = %assetType;
- }
- else if(%assetType $= "Creator")
- {
- %assetDesc = %assetName;
- %assetDesc.assetType = %assetType;
- %moduleName = %assetDesc;
- }
- }
- /*%fullPath = %moduleName !$= "" ? %moduleName @ "/" @ %assetName : %assetName;
- %fullPath = strreplace(%fullPath, "/", "_");
-
- if(isObject(%fullPath))
- %assetDesc = %fullPath;
- else
- %assetDesc = new ScriptObject(%fullPath);
-
- %assetDesc.dirPath = %moduleName;
- %assetDesc.assetName = %assetName;
- %assetDesc.description = %moduleName @ "/" @ %assetName;
- %assetDesc.assetType = %assetType;*/
-
- //%assetName = %asset;
- //%assetType = "Folder";
- }
- %previewSize = 100 SPC 100;
- %previewBounds = 20;
-
- %tooltip = %assetName;
-
- %textBottomPad = 20;
-
- %previewButton = new GuiIconButtonCtrl()
- {
- class = "AssetBrowserPreviewButton";
- useMouseEvents = true;
- iconLocation = "Center";
- sizeIconToButton = true;
- makeIconSquare = true;
- textLocation = "Bottom";
- extent = %previewSize.x SPC %previewSize.y + %textBottomPad;
- buttonType = "RadioButton";
- buttonMargin = "0 -10";
- profile = ToolsGuiDefaultIconBtnProfile;
- };
-
- %previewScaleSize = AssetBrowser-->previewSlider.getValue();
-
- if(%previewScaleSize $= "")
- {
- %previewScaleSize = 1;
- AssetBrowser-->previewSlider.setValue(1);
- }
-
- if(%previewScaleSize == 0 || startsWith(AssetBrowser.dirHandler.currentAddress, "Creator"))
- {
- %previewButton.iconLocation = "Left";
- %previewButton.textLocation = "Right";
- %previewButton.setextent(160,34);
- %previewButton.buttonMargin = "8 8";
- %previewButton.textMargin = "6";
-
- AssetBrowser.previewListMode = true;
- }
- else
- {
- %size = %previewSize.x * %previewScaleSize;
- %previewButton.setextent(%size,%size + %textBottomPad);
-
- AssetBrowser.previewListMode = false;
- }
-
- //%previewButton.extent = %previewSize.x + %previewBounds SPC %previewSize.y + %previewBounds + 24;
- %previewButton.assetName = %assetName;
- %previewButton.moduleName = %moduleName;
- %previewButton.assetType = %assetType;
-
- if(%this.selectMode)
- {
- %doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
- }
- else
- {
- %doubleClickCommand = "AssetBrowser.editAsset( "@%assetDesc@" );";
- }
-
- %this.previewData.previewLoaded = true;
-
- //Build out the preview
- %buildCommand = %this @ ".build" @ %assetType @ "Preview(\"" @ %assetDesc @ "\"," @ %this.previewData @ ");";
- eval(%buildCommand);
-
- //debug dump
- %tooltip = %this.previewData.tooltip;
- %assetName = %this.previewData.assetName;
- %previewImage = %this.previewData.previewImage;
-
- if(%this.previewData.doubleClickCommand !$= "")
- %doubleClickCommand = %this.previewData.doubleClickCommand;
-
- %previewButton.assetName = %assetName;
- %previewButton.moduleName = %moduleName;
- %previewButton.assetType = %assetType;
-
- %previewButton.bitmapAsset = %this.previewData.previewImage;
-
- %previewButton.profile = "AssetBrowserPreview" @ %previewButton.assetType;
- %previewButton.tooltip = %this.previewData.tooltip;
- %previewButton.Command = "AssetBrowser.updateSelection( $ThisControl.assetName, $ThisControl.moduleName );";
- %previewButton.altCommand = %doubleClickCommand;
-
- %previewButton.text = %this.previewData.assetName;
- %previewButton.text.originalAssetName = %this.previewData.assetName;
- // add to the gui control array
- AssetBrowser-->assetList.add(%previewButton);
-
- // add to the array object for reference later
- if(%this.previewData.previewLoaded == false)
- AssetPreviewArray.add( %previewButton );
- }
- function AssetBrowser::refresh(%this)
- {
- if(!%this.dirty)
- {
- %this.dirty = true;
-
- %this.schedule(1, "doRefresh");
- }
- }
- function AssetBrowser::doRefresh(%this)
- {
- if(%this.dirty)
- {
- %this.navigateTo(%this.dirHandler.currentAddress);
-
- //Forces a clean collapse of the tree for any not-really-exposed items
- %dataItem = AssetBrowser-->filterTree.findItemByName("data");
- if(%dataItem != 0)
- {
- AssetBrowser-->filterTree.expandItem(%dataItem, false);
- AssetBrowser-->filterTree.expandItem(%dataItem);
- }
-
- %this.dirty = false;
- }
- }
- function AssetBrowser::populatePreviewImages(%this)
- {
- if (AssetPreviewArray.count()>0)
- echo("AssetBrowser::populatePreviewImages() - Previews to generate: " @ AssetPreviewArray.count());
-
- for(%i=0; %i < AssetPreviewArray.count(); %i++)
- {
- %previewButton = AssetPreviewArray.getKey(%i);
- %type = %previewButton.assetType;
-
- echo(" - Generating preview for asset: " @ %previewButton.moduleName @ ":" @ %previewButton.assetName);
-
- AssetBrowser.call("generate" @ %previewButton.assetType @ "PreviewImage", %previewButton);
- AssetPreviewArray.erase(%i);
-
- echo(" - done, scheduling another pass");
- AssetBrowser.schedule(32, "populatePreviewImages");
- return;
- }
- }
- //
- //
- /*function AssetPreviewButton::onClick(%this)
- {
- echo("CLICKED AN ASSET PREVIEW BUTTON");
- }
- function AssetPreviewButton::onDoubleClick(%this)
- {
- echo("DOUBLE CLICKED AN ASSET PREVIEW BUTTON");
- }*/
- //
- //
- function assetBrowserPreviewSlider::onMouseDragged(%this)
- {
- EditorSettings.setValue("Assets/Browser/previewTileSize", %this.getValue());
- AssetBrowser.refresh();
- }
- function AssetBrowser::loadDirectories( %this )
- {
- AssetBrowser-->filterTree.clear();
-
- %dataItem = AssetBrowser-->filterTree.insertItem(0, "Content");
- AssetBrowser-->filterTree.collectionsIdx = AssetBrowser-->filterTree.insertItem(1, "Collections");
-
- AssetBrowser-->filterTree.modulesIdx = AssetBrowser-->filterTree.insertItem(1, "Modules");
-
- %dataItem = AssetBrowser-->filterTree.insertItem(AssetBrowser-->filterTree.modulesIdx, "data");
- AssetBrowser-->filterTree.tagsIdx = AssetBrowser-->filterTree.insertItem(1, "Tags");
-
- AssetBrowser-->filterTree.creatorIdx = AssetBrowser-->filterTree.insertItem(1, "Creator");
-
- AssetBrowser-->filterTree.clearSelection();
-
- if(%this.selectMode)
- {
- //Due to a fluke in how this tracks, it overrides the current addres, so we'll
- //store it real fast
- %curAdd = AssetBrowser.dirHandler.currentAddress;
-
- //Disable these for this go
- AssetBrowser-->filterTree.addSelection(AssetBrowser-->filterTree.collectionsIdx);
- AssetBrowser-->filterTree.addSelection(AssetBrowser-->filterTree.creatorIdx);
- AssetBrowser-->filterTree.hideSelection();
- AssetBrowser-->filterTree.clearSelection();
-
- AssetBrowser.dirHandler.currentAddress = %curAdd;
- }
-
- %this.dirHandler.loadFolders("data", %dataItem);
-
- %this.loadCollectionSets();
-
- %this.loadTags();
-
- if (!%this.selectMode)
- %this.loadCreatorClasses();
-
- //If set to, show core
- if(EditorSettings.value("Assets/Browser/showCoreModule", false) == 1)
- {
- %coreItem = AssetBrowser-->filterTree.insertItem(AssetBrowser-->filterTree.modulesIdx, "core");
- %this.dirHandler.loadFolders("core", %coreItem);
- }
-
- //If set to, show tools
- if(EditorSettings.value("Assets/Browser/showToolsModule", false) == 1)
- {
- %toolsItem = AssetBrowser-->filterTree.insertItem(AssetBrowser-->filterTree.modulesIdx, "tools");
- %this.dirHandler.loadFolders("tools", %toolsItem);
- }
-
- AssetBrowser-->filterTree.buildVisibleTree(true);
-
- //Remove any modules that have no assets if we have that filter on
- if(%this.onlyShowModulesWithAssets)
- {
- %modulesList = ModuleDatabase.findModules();
- for(%i=0; %i < getWordCount(%modulesList); %i++)
- {
- %moduleName = getWord(%modulesList, %i).ModuleId;
-
- %moduleItemId = AssetBrowser-->filterTree.findItemByName(%moduleName);
-
- if(AssetBrowser-->filterTree.isParentItem(%moduleItemId) == false)
- AssetBrowser-->filterTree.removeItem(%moduleItemId);
- }
- }
-
- //special handling for selections
- if(AssetBrowser.newModuleId !$= "")
- {
- AssetBrowser-->filterTree.clearSelection();
- %newModuleItem = AssetBrowser-->filterTree.findItemByName(AssetBrowser.newModuleId);
- AssetBrowser-->filterTree.selectItem(%newModuleItem);
- AssetBrowser.newModuleId = "";
- }
-
- AssetBrowser.dirHandler.expandTreeToAddress(AssetBrowser.dirHandler.currentAddress);
-
- %selectedItem = AssetBrowser.dirHandler.getFolderTreeItemFromAddress(AssetBrowser.dirHandler.currentAddress);
- AssetBrowser-->filterTree.scrollVisibleByObjectId(%selectedItem);
-
- AssetBrowser-->filterTree.buildVisibleTree(true);
-
- AssetBrowser.refresh();
- }
- function AssetBrowser::updateSelection( %this, %asset, %moduleName )
- {
- //If we had an existing selected assetDef, clear the reference
- if(isObject(AssetBrowser.selectedAssetDef))
- AssetDatabase.releaseAsset(AssetBrowser.selectedAssetDef.getAssetId());
-
- //AssetBrowser.selectedMaterial = %asset;
- AssetBrowser.selectedAsset = %moduleName@":"@%asset;
-
- //If it's got slashes, it's a path so it's actually a folder item, not an asset
- if(strstr(%moduleName, "/") != -1)
- return;
-
- //Check if this is an actual assetId, or if it's just a programmatic reference
- //like what we use for the creator entries
- if(AssetDatabase.isDeclaredAsset(AssetBrowser.selectedAsset))
- {
- //Looks good, it's an asset so we'll select the definition while we're at it
- AssetBrowser.selectedAssetDef = AssetDatabase.acquireAsset(AssetBrowser.selectedAsset);
- }
- }
- function AssetBrowser::loadCollectionSets(%this)
- {
- //Process any datablocks and populate their lists categories as tags as well
- %collectionsItem = AssetBrowser-->filterTree.collectionsIdx;
-
- %collectionsCount = AssetBrowserCollectionSets.value("CollectionSetCount", 0);
-
- for ( %i = 0; %i < %collectionsCount; %i++ )
- {
- %collection = AssetBrowserCollectionSets.value("Collection"@%i, "");
- %collectionName = getField(%collection, 0);
- %collectionTerm = getField(%collection, 1);
-
- AssetBrowser-->filterTree.insertItem(%collectionsItem, %collectionName, %collectionTerm);
- }
- }
- function AssetBrowser::setCollectionSetActive(%this, %collectionSet)
- {
- AssetBrowserSearchFilter.setText(%collectionSet);
- AssetBrowserSearchFilter.onReturn();
- }
- function AssetBrowser::loadTags(%this)
- {
- //Process any datablocks and populate their lists categories as tags as well
- %dataGroup = "DataBlockGroup";
- %tagItem = AssetBrowser-->filterTree.tagsIdx;
-
- for ( %i = 0; %i < %dataGroup.getCount(); %i++ )
- {
- %obj = %dataGroup.getObject(%i);
- // echo ("Obj: " @ %obj.getName() @ " - " @ %obj.category );
-
- if ( %obj.category $= "" && %obj.category == 0 )
- continue;
-
- %tagChildItem = AssetBrowser-->filterTree.findChildItemByName(%tagItem, %obj.category);
- if(%tagChildItem == 0)
- {
- //Didn't already exist, so register it in
- AssetBrowser-->filterTree.insertItem(%tagItem, %obj.category);
- }
- }
- }
- function AssetBrowser::setTagActive(%this, %tag)
- {
- %found = false;
-
- for(%i=0; %i < AssetSearchTerms.count(); %i++)
- {
- %action = AssetSearchTerms.getKey(%i);
- %word = AssetSearchTerms.getValue(%i);
-
- if(%action $= "tag" && %word $= %tag)
- {
- //If we found it, we just remove it from our list, toggling it off
- AssetSearchTerms.erase(%i);
- %found = true;
- }
- }
-
- //If we didn't find it, we're going to add it into our list
- if(!%found)
- {
- AssetSearchTerms.add("tag", %tag);
- }
-
- %this.updateSearchTextFromFilter();
-
- %this.rebuildAssetArray();
- }
- //
- //needs to be deleted with the persistence manager and needs to be blanked out of the matmanager
- //also need to update instances... i guess which is the tricky part....
- function AssetBrowser::showDeleteDialog( %this )
- {
- %material = AssetBrowser.selectedAsset;
- %secondFilter = "MaterialFilterMappedArray";
- %secondFilterName = "Mapped";
-
- for( %i = 0; %i < MaterialFilterUnmappedArray.count(); %i++ )
- {
- if( MaterialFilterUnmappedArray.getValue(%i) $= %material )
- {
- %secondFilter = "MaterialFilterUnmappedArray";
- %secondFilterName = "Unmapped";
- break;
- }
- }
-
- if( isObject( %material ) )
- {
- toolsMessageBoxYesNoCancel("Delete Material?",
- "Are you sure you want to delete<br><br>" @ %material.getName() @ "<br><br> Material deletion won't take affect until the engine is quit.",
- "AssetBrowser.deleteMaterial( " @ %material @ ", " @ %secondFilter @ ", " @ %secondFilterName @" );",
- "",
- "" );
- }
- }
- function AssetBrowser::deleteMaterial( %this, %materialName, %secondFilter, %secondFilterName )
- {
- if( !isObject( %materialName ) )
- return;
-
- for( %i = 0; %i <= MaterialFilterAllArray.countValue( %materialName ); %i++)
- {
- %index = MaterialFilterAllArray.getIndexFromValue( %materialName );
- MaterialFilterAllArray.erase( %index );
- }
- MaterialFilterAllArrayCheckbox.setText("All ( " @ MaterialFilterAllArray.count() - 1 @ " ) ");
-
- %checkbox = %secondFilter @ "Checkbox";
- for( %k = 0; %k <= %secondFilter.countValue( %materialName ); %k++)
- {
- %index = %secondFilter.getIndexFromValue( %materialName );
- %secondFilter.erase( %index );
- }
- %checkbox.setText( %secondFilterName @ " ( " @ %secondFilter.count() - 1 @ " ) ");
-
- for( %i = 0; %materialName.getFieldValue("materialTag" @ %i) !$= ""; %i++ )
- {
- %materialTag = %materialName.getFieldValue("materialTag" @ %i);
-
- for( %j = AssetBrowser.staticFilterObjects; %j < AssetBrowser-->filterArray.getCount() ; %j++ )
- {
- if( %materialTag $= AssetBrowser-->filterArray.getObject(%j).getObject(0).filter )
- {
- %count = getWord( AssetBrowser-->filterArray.getObject(%j).getObject(0).getText(), 2 );
- %count--;
- AssetBrowser-->filterArray.getObject(%j).getObject(0).setText( %materialTag @ " ( "@ %count @ " )");
- }
- }
-
- }
-
- UnlistedMaterials.add( "unlistedMaterials", %materialName );
-
- if( %materialName.getFilename() !$= "" &&
- %materialName.getFilename() !$= "tools/gui/AssetBrowser.ed.gui" &&
- %materialName.getFilename() !$= "tools/materialEditor/scripts/materialEditor.ed." @ $TorqueScriptFileExtension )
- {
- AssetBrowserPerMan.removeObjectFromFile(%materialName);
- AssetBrowserPerMan.saveDirty();
- }
-
- AssetBrowser.refresh();
- }
- function AssetBrowser::toggleTagFilterPopup(%this)
- {
- if(TagFilterWindow.visible)
- TagFilterWindow.visible = false;
- else
- TagFilterWindow.visible = true;
-
- return;
- %assetQuery = new AssetQuery();
- %numAssetsFound = AssetDatabase.findAllAssets(%assetQuery);
-
- for( %i=0; %i < %numAssetsFound; %i++)
- {
- %assetId = %assetQuery.getAsset(%i);
-
- //first, get the asset's module, as our major categories
- %module = AssetDatabase.getAssetModule(%assetId);
-
- %moduleName = %module.moduleId;
-
- //check that we don't re-add it
- %moduleItemId = AssetBrowser-->filterTree.findItemByName(%moduleName);
-
- if(%moduleItemId == -1 || %moduleItemId == 0)
- %moduleItemId = AssetBrowser-->filterTree.insertItem(1, %module.moduleId, "", "", 1, 2);
-
- //now, add the asset's category
- %assetType = AssetDatabase.getAssetCategory(%assetId);
-
- // TODO?
- %text = "";
- %var = "";
- %cmd = "";
- %textLength = strlen(%text);
- // end todo
- %checkBox = new GuiCheckBoxCtrl()
- {
- canSaveDynamicFields = "0";
- isContainer = "0";
- Profile = "ToolsGuiCheckBoxListProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- Position = "0 0";
- Extent = (%textLength * 4) @ " 18";
- MinExtent = "8 2";
- canSave = "1";
- Visible = "1";
- Variable = %var;
- tooltipprofile = "ToolsGuiToolTipProfile";
- hovertime = "1000";
- text = %text;
- groupNum = "-1";
- buttonType = "ToggleButton";
- useMouseEvents = "0";
- useInactiveState = "0";
- Command = %cmd;
- };
-
- TagFilterList.add(%checkBox);
- }
- }
- function AssetBrowser::changeAsset(%this)
- {
- %targetObject = %this.fieldTargetObject;
- %inspectorObject = "";
-
- if(isObject(%this.fieldTargetObject) && %this.fieldTargetObject.isInNamespaceHierarchy("GuiInspector"))
- {
- %inspectorObject = %this.fieldTargetObject;
- if(%inspectorObject.getNumInspectObjects() != 0)
- {
- %targetObject = %inspectorObject.getInspectObject();
- %inspectorObject.setObjectField(%this.fieldTargetName, %this.selectedAsset);
- }
- else if(startsWith(%this.fieldTargetName, "$"))
- {
- //we're targeting a variable directly, so deal with that then
- %cmd = %this.fieldTargetName @ "=\"" @ %this.selectedAsset @ "\";";
- }
- }
- else if(isObject(%this.fieldTargetObject))
- {
- //alright, we've selectd an asset for a field, so time to set it!
- if(%this.fieldTargetName $= "")
- %cmd = %targetObject @ ".apply(\""@ %this.selectedAsset @ "\");";
- else
- %cmd = %targetObject @ "." @ %this.fieldTargetName @ "=\"" @ %this.selectedAsset @ "\";";
- //echo("Changing asset via the " @ %cmd @ " command");
- }
- else if(startsWith(%this.fieldTargetName, "$"))
- {
- //we're targeting a variable directly, so deal with that then
- %cmd = %this.fieldTargetName @ "=\"" @ %this.selectedAsset @ "\";";
- }
-
- eval(%cmd);
-
- //Force update our object with the field change
- if(isObject(%targetObject))
- {
- if(%this.fieldTargetObject.isInNamespaceHierarchy("GuiInspector"))
- %this.fieldTargetObject.refresh();
- else
- %targetObject.inspectPostApply();
- }
-
- //Flag us as dirty for editing purposes
- EWorldEditor.setSceneAsDirty();
- }
- function AssetBrowser::reImportAsset(%this)
- {
- //Find out what type it is
- %assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
- %assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
-
- if(%assetType $= "ShapeAsset" || %assetType $= "ImageAsset" || %assetType $= "SoundAsset")
- {
- AssetBrowser.isAssetReImport = true;
- AssetBrowser.reImportingAssetId = EditAssetPopup.assetId;
-
- %reimportingPath = %assetDef.originalFilePath;
-
- if(%reimportingPath $= "" || !isFile(%reimportingPath))
- {
- //if we have no defined original file path, attempt to re-import the
- //current loosefile
- if(%assetType $= "ShapeAsset")
- %reimportingPath = %assetDef.getShapePath();
- else if(%assetType $= "ImageAsset")
- %reimportingPath = %assetDef.getImagePath();
- else if(%assetType $= "SoundAsset")
- %reimportingPath = %assetDef.getSoundPath();
- }
-
- //first, double-check we have an originating file. if we don't then we need to basically go out looking for it
- if(!isFile(%reimportingPath))
- {
- //if(%assetType $= "ImageAsset")
- // %filters = "";
-
- //TODO
- %currentFile = "";
- %dlg = new OpenFileDialog()
- {
- Filters = "(All Files (*.*)|*.*|";
- DefaultFile = %currentFile;
- ChangePath = false;
- MustExist = true;
- MultipleFiles = false;
- forceRelativePath = false;
- };
-
- if ( %dlg.Execute() )
- {
- %reimportingPath = %dlg.FileName;
- }
-
- %dlg.delete();
- }
-
- AssetBrowser.onBeginDropFiles();
- AssetBrowser.onDropFile(%reimportingPath);
- AssetBrowser.onEndDropFiles();
-
- %module = AssetDatabase.getAssetModule(EditAssetPopup.assetId);
-
- //get the selected module data
- ImportAssetModuleList.setText(%module.ModuleId);
- }
- }
- //
- //
- // RMB context popups
- function AssetBrowserPreviewButton::onRightClick(%this)
- {
- AssetBrowser.selectedAssetPreview = %this;
- EditAssetPopup.assetId = %this.moduleName @ ":" @ %this.assetName;
- EditAssetPopup.assetType = %this.assetType;
- %assetType = %this.assetType;
-
- //Do some enabling/disabling of options depending on asset type
- EditAssetPopup.enableItem(0, true);
- EditAssetPopup.enableItem(9, true);
-
- //Is it an editable type?
- if(%assetType $= "ImageAsset" /*|| %assetType $= "GameObjectAsset"*/ || %assetType $= "CppAsset")
- {
- EditAssetPopup.enableItem(0, false);
- }
-
- //Is it an importable type?
- if(%assetType $= "GameObjectAsset" || %assetType $= "ComponentAsset" || %assetType $= "GUIAsset" || %assetType $= "LevelAsset"
- || %assetType $= "MaterialAsset" || %assetType $= "ParticleAsset" || %assetType $= "PostEffectAsset" || %assetType $= "ScriptAsset"
- || %assetType $= "StateMachineAsset")
- {
- EditAssetPopup.enableItem(9, false);
- }
-
- /*if(AssetDatabase.acquireAsset(EditAssetPopup.assetId))
- {
- %assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
- if(%assetDef.originalFilePath $= "" || !isFile(%assetDef.originalFilePath))
- {
- //if we have no noted original import file path or it's invalid
- //we can't reimport either
- EditAssetPopup.enableItem(9, false);
- }
- AssetDatabase.releaseAsset(EditAssetPopup.assetId);
- }*/
-
- if(%assetType $= "LevelAsset")
- {
- EditLevelAssetPopup.showPopup(Canvas);
- }
- else if(%assetType $= "Folder")
- {
- EditFolderPopup.dirPath = %this.moduleName @ "/" @ %this.assetName;
- EditFolderPopup.showPopup(Canvas);
- }
- else if(%assetType $= "TerrainAsset")
- {
- EditTerrainAssetPopup.showPopup(Canvas);
- }
- else
- {
- EditAssetPopup.showPopup(Canvas);
- }
-
- if(%assetType $= "Folder")
- {
- EditAssetPopup.assetId = %this.moduleName @ "/" @ %this.assetName;
- }
- }
- //function AssetListPanel::onRightMouseDown(%this)
- function AssetListPanelInputs::onRightMouseDown(%this)
- {
- AddNewAssetPopup.showPopup(Canvas);
- }
- function AssetBrowserFilterTree::onRightMouseDown(%this, %itemId)
- {
- %count = %this.getSelectedItemsCount();
-
- %itemText = %this.getItemText(%itemId);
- %parentItem = %this.getParentItem(%itemId);
- if(%parentItem == %this.tagsIdx)
- {
- }
- else if(%parentItem == %this.collectionsIdx)
- {
- EditCollectionSets.showPopup(Canvas);
- AssetBrowser.selectedCollectionSet = %itemText;
- }
- else if(%parentItem == %this.creatorIdx)
- {
- }
- else
- {
- if( %this.getSelectedItemsCount() > 0 && (%itemText !$= "data" && %itemText !$="core" && %itemText !$= "tools"))
- {
- //AddNewAssetPopup.showPopup(Canvas);
-
- //We have something clicked, so figure out if it's a sub-filter or a module filter, then push the correct
- //popup menu
- %parentItem = %this.getParentItem(%itemId);
- if(%this.getItemText(%parentItem) $= "data") //if it's a data module, continue
- {
- //find out if it's a folder or a module!
- if(ModuleDatabase.findModule(%itemText))
- {
- //yep, module, push the all-inclusive popup
- EditModulePopup.showPopup(Canvas);
- //also set the module value for creation info
- AssetBrowser.selectedModule = %itemText;
- }
- else
- {
- EditNonModulePopup.showPopup(Canvas);
- EditNonModulePopup.targetFolder = %itemText;
- }
- }
- else
- {
- EditFolderPopup.showPopup(Canvas);
- EditFolderPopup.assetType = "Folder";
- }
- }
- else if(%itemText $= "data")
- {
- AddNewModulePopup.showPopup(Canvas);
- }
- else if(%itemText $= "tools")
- {
- AddNewToolPopup.showPopup(Canvas);
- }
- }
- }
- //
- //
- //
- function AssetBrowser::openAssetSettings(%this)
- {
- ESettingsWindow.toggleEditorSettings();
- %assetEditIndex = ESettingsWindowList.findTextIndex("Asset Editing");
- ESettingsWindowList.setSelectedRow( %assetEditIndex );
- }
- function ESettingsWindow::getAssetManagementSettings(%this)
- {
- SettingsInspector.startGroup("Modules");
- SettingsInspector.addSettingsField("AssetManagement/Modules/coreModulePath", "Core Module Path", "string", "");
- SettingsInspector.addSettingsField("AssetManagement/Modules/gameDataModulePath", "Game Data Module Path", "string", "");
- SettingsInspector.addSettingsField("AssetManagement/Modules/moduleExtension", "Module Extension", "string", "");
-
- %moduleList = ModuleDatabase.findModules(true);
- %moduleList = strreplace(%moduleList, " ", ",");
-
- SettingsInspector.addSettingsField("AssetManagement/Modules/DefaultModule", "Default Module", "list", %moduleList);
- SettingsInspector.endGroup();
-
- SettingsInspector.startGroup("Assets");
- SettingsInspector.addSettingsField("AssetManagement/Assets/assetExtension", "Asset Extension", "string", "");
- SettingsInspector.addSettingsField("AssetManagement/Assets/datablockCaching", "Cache Datablocks", "bool", "");
- //SettingsInspector.addSettingsField("AssetManagement/Assets/moduleExtension", "Module Extension", "string", "");
-
- SettingsInspector.endGroup();
- }
- function ESettingsWindow::getAssetEditingSettings(%this)
- {
- ImportAssetWindow::reloadImportOptionConfigs();
-
- //First, get our list of modules
- %moduleList = ModuleDatabase.findModules();
- %formattedModuleList = "";
-
- %count = getWordCount(%moduleList);
- for(%i=0; %i < %count; %i++)
- {
- %module = getWord(%moduleList, %i);
- if(%module.group !$= "Tools" && %module.group !$= "Core")
- {
- if(%formattedModuleList $= "")
- %formattedModuleList = %module.moduleId;
- else
- %formattedModuleList = %formattedModuleList @ "," @ %module.moduleId;
- }
- }
-
- SettingsInspector.startGroup("Asset Creation");
- SettingsInspector.addSettingsField("Assets/New/defaultModule", "Default Module", "list", "Default Module for new assets to be created into", %formattedModuleList);
- SettingsInspector.addSettingsField("Assets/New/alwaysPromptModuleTarget", "Always Prompt Target Module", "bool", "If off, use the default module");
- SettingsInspector.endGroup();
-
- %formattedConfigList = "";
- for(%i=0; %i < ImportAssetWindow.importConfigsList.Count(); %i++)
- {
- %configName = ImportAssetWindow.importConfigsList.getKey(%i);
- %formattedConfigList = %i == 0 ? %configName : %formattedConfigList @ "," @ %configName;
- }
-
- SettingsInspector.startGroup("Assets Importing");
- SettingsInspector.addField("Edit Import Configs", "Edit Asset Import Configs", "button", "Open Asset Import Config Editor", "", "Canvas.pushDialog(AssetImportConfigEditor);");
- SettingsInspector.addSettingsField("Assets/AssetImporDefaultConfig", "Default Asset Import Config", "list", "", %formattedConfigList);
- SettingsInspector.addSettingsField("Assets/AutoImport", "Automatically Import using default config", "bool", "If on, the asset importing process" @
- "will attempt to automatically import any inbound assets"@
- "using the default config, without prompting the import window."@
- "The window will still display if any issues are detected", "");
- SettingsInspector.addSettingsField("Assets/AutoImportLooseFiles", "Automatically Import Loose Files", "bool", "If on, will automatically import unassociated loose files in assets when navigating the Asset Browser.", "");
- SettingsInspector.endGroup();
-
- SettingsInspector.startGroup("Asset Browser");
- SettingsInspector.addSettingsField("Assets/Browser/showCoreModule", "Show Core Module in Asset Browser", "bool", "");
- SettingsInspector.addSettingsField("Assets/Browser/showToolsModule", "Show Tools Module in Asset Browser", "bool", "");
- SettingsInspector.addSettingsField("Assets/Browser/showOnlyPopulatedModule", "Show Only Modules with Assets in Asset Browser", "bool", "");
- SettingsInspector.addSettingsField("Assets/Browser/showFolders", "Show Folders in Tiles view in Asset Browser", "bool", "");
- SettingsInspector.addSettingsField("Assets/Browser/showEmptyFolders", "Show Empty Folders in Tiles view in Asset Browser", "bool", "");
- SettingsInspector.addSettingsField("Assets/Browser/showLooseFiles", "Show Loose Files when viewing in Asset Browser", "bool", "");
- SettingsInspector.addSettingsField("AssetManagement/Assets/promptOnRename", "Prompt on Rename", "bool", "");
- SettingsInspector.addSettingsField("Assets/Browser/doubleClickAction", "Double Click Action", "list", "Dictates what sort of action double clicking on an asset in the Browser will invoke", "Edit Asset,Spawn Asset");
- SettingsInspector.addSettingsField("AssetManagement/Assets/closeBrowserOnDragAction", "Close Browser on Drag Action", "bool", "If on, the Asset Browser will automatically close after dragging an asset from it to the editor interface.");
- SettingsInspector.endGroup();
- }
- //
- //
- //
- function AssetBrowser::showVisibiltyOptions(%this)
- {
- BrowserVisibilityPopup.showPopup(Canvas);
- }
- function AssetBrowser::saveCurrentFiltersAsCollection(%this)
- {
- %colSetName = CreateNewCollectionSetCtrl-->collectionSetName.getText();
-
- if(%colSetName $= "")
- {
- error("Collection Sets require a name!");
- }
-
- %collectionsCount = AssetBrowserCollectionSets.value("CollectionSetCount", 0);
- %collectionsCount += 1;
-
- AssetBrowserCollectionSets.setValue("CollectionSetCount", %collectionsCount);
-
- %collection = %colSetName TAB AssetBrowserSearchFilter.getText();
-
- AssetBrowserCollectionSets.setValue("Collection"@%collectionsCount-1, %collection);
-
- %success = AssetBrowserCollectionSets.write();
-
- AssetBrowser.loadDirectories();
- }
- function AssetBrowser::deleteCollectionSet(%this)
- {
- %collectionsCount = AssetBrowserCollectionSets.value("CollectionSetCount", 0);
- %tempCollectionListCount = 0;
-
- %found = false;
- for ( %i = 0; %i < %collectionsCount; %i++ )
- {
- %collection = AssetBrowserCollectionSets.value("Collection"@%i, "");
- %collectionName = getField(%collection, 0);
- %collectionTerm = getField(%collection, 1);
-
- if(AssetBrowser.selectedCollectionSet !$= %collectionName)
- {
- %tempCollectionList[%tempCollectionListCount] = %collection;
- %tempCollectionListCount++;
- }
- }
-
- AssetBrowserCollectionSets.setValue("CollectionSetCount", %tempCollectionListCount);
- for(%i=0; %i < %collectionsCount; %i++)
- {
- if(%i < %tempCollectionListCount)
- AssetBrowserCollectionSets.setValue("Collection"@%i, %tempCollectionList[%i]);
- else
- AssetBrowserCollectionSets.remove("Collection"@%i);
- }
-
- AssetBrowserCollectionSets.write();
-
- %this.loadDirectories();
- }
- function AssetBrowser::refreshPreviews(%this)
- {
- AssetBrowserFilterTree.onSelect(AssetBrowser.selectedItem);
- }
- function AssetBrowserFilterTree::onSelect(%this, %itemId)
- {
- if(%itemId == 1)
- //can't select root
- return;
-
- //process special cases
- %parentItem = %this.getParentItem(%itemId);
- if(%parentItem == %this.tagsIdx)
- {
- //we selected a tag, so deal with that
- AssetBrowser.setTagActive(%this.getItemText(%itemId));
- }
- else if(%parentItem == %this.collectionsIdx)
- {
- //A collection set was selected
- AssetBrowser.setCollectionSetActive(%this.getItemValue(%itemId));
- }
- else if(%parentItem == %this.creatorIdx)
- {
- %name = %this.getItemText(%itemId);
- AssetBrowser.dirHandler.currentAddress = "Creator/" @ %name;
- AssetBrowser.rebuildAssetArray();
- AssetBrowser.refresh();
- }
- else
- {
- //Make sure we have an actual module selected!
- %parentId = %this.getParentItem(%itemId);
-
- %name = %this.getItemText(%itemId);
-
- %breadcrumbPath = %this.getItemValue(%itemId);
- if(%breadcrumbPath !$= "")
- %breadcrumbPath = %breadcrumbPath @ "/" @ %this.getItemText(%itemId);
- else
- %breadcrumbPath = %this.getItemText(%itemId);
-
- if(%breadcrumbPath $= "")
- %breadcrumbPath = AssetBrowser.dirHandler.currentAddress;
-
- AssetBrowser.navigateTo(%breadcrumbPath);
- }
- }
- function AssetBrowserFilterTree::hasAsParent(%this, %itemId, %text)
- {
- %parentId = %this.getParentItem(%itemId);
-
- while(%parentId != 0)
- {
- %parentText = %this.getItemText(%parentId);
- if(%parentText $= %text)
- return true;
-
- %parentId = %this.getParentItem(%parentId);
- }
-
-
- return false;
- }
- function AssetBrowser::rebuildAssetArray(%this)
- {
- if(!%this.previewArrayDirty)
- {
- %this.previewArrayDirty = true;
- cancel(%this.pendingRebuild);
- %this.pendingRebuild = %this.schedule(16, "doRebuildAssetArray");
- }
- }
- function AssetBrowser::doRebuildAssetArray(%this)
- {
- if(!%this.previewArrayDirty)
- return;
-
- %breadcrumbPath = AssetBrowser.dirHandler.currentAddress;
-
- // we have to empty out the list; so when we create new guicontrols, these dont linger
- AssetBrowser-->assetList.deleteAllObjects();
- AssetPreviewArray.empty();
- if(isObject($AssetBrowser::AssetArray))
- $AssetBrowser::AssetArray.delete();
-
- $AssetBrowser::AssetArray = new ArrayObject();
-
- //First, Query for our assets
- %assetQuery = new AssetQuery();
- %numAssetsFound = AssetDatabase.findAllAssets(%assetQuery);
- %finalAssetCount = 0;
-
- //Add folders
- if(EditorSettings.value("Assets/Browser/showFolders", true) == true)
- {
- %folders = getDirectoryList(%breadcrumbPath);
- for(%f=0; %f < getFieldCount(%folders); %f++)
- {
- %folderName = getField(%folders, %f);
-
- %searchActive = AssetSearchTerms.count() != 0;
- if(%searchActive)
- {
- if(matchesSearch(%folderName, "Folder", ""))
- {
- $AssetBrowser::AssetArray.add( %breadcrumbPath, "Folder" TAB %folderName );
- continue;
- }
- }
- else
- {
- //got it.
- if(%folderName $= "shaderCache" || %folderName $= "cache" || %folderName $= ".git")
- continue;
-
- if(!%this.coreModulesFilter && %folderName $= "core" && %breadcrumbPath $= "")
- continue;
-
- if(!%this.toolsModulesFilter && %folderName $= "tools" && %breadcrumbPath $= "")
- continue;
-
- $AssetBrowser::AssetArray.add( %breadcrumbPath, "Folder" TAB %folderName );
- }
- }
- }
-
- //now, we'll iterate through, and find the assets that are in this module, and this category
- for( %i=0; %i < %numAssetsFound; %i++)
- {
- %assetId = %assetQuery.getAsset(%i);
-
- %assetPath = makeRelativePath(AssetDatabase.getAssetFilePath(%assetId));
- %assetBasePath = filePath(%assetPath);
-
- //clean up the path
- %assetBasePath = strreplace(%assetBasePath, "//", "/");
-
- %searchActive = AssetSearchTerms.count() != 0;
- if(%assetBasePath $= %breadcrumbPath || (%searchActive && startsWith(%assetBasePath,%breadcrumbPath)))
- {
- //first, get the asset's module, as our major categories
- %module = AssetDatabase.getAssetModule(%assetId);
- %moduleName = %module.moduleId;
-
- //it's good, so test that the category is right!
- %assetType = AssetDatabase.getAssetCategory(%assetId);
- if(%assetType $= "")
- {
- %assetType = AssetDatabase.getAssetType(%assetId);
- }
-
- //stop adding after previewsPerPage is hit
- %assetName = AssetDatabase.getAssetName(%assetId);
- if(%searchActive)
- {
- if(matchesSearch(%assetName, %assetType))
- {
- $AssetBrowser::AssetArray.add( %moduleName, %assetId);
-
- if(%assetType !$= "Folder")
- %finalAssetCount++;
-
- continue;
- }
- }
- else
- {
- if(AssetBrowser.assetTypeFilter !$= "")
- {
- %filtersCount = getWordCount(AssetBrowser.assetTypeFilter);
- for(%fltrIdx = 0; %fltrIdx < %filtersCount; %fltrIdx++)
- {
- %fltr = getWord(AssetBrowser.assetTypeFilter, %fltrIdx);
- if(%fltr $= %assetType)
- {
- $AssetBrowser::AssetArray.add( %moduleName, %assetId );
-
- if(%assetType !$= "Folder")
- %finalAssetCount++;
- }
- }
- }
- else
- {
- //got it.
- $AssetBrowser::AssetArray.add( %moduleName, %assetId );
-
- if(%assetType !$= "Folder")
- %finalAssetCount++;
- }
- }
- }
- }
- //Add Non-Asset Scripted Objects. Datablock, etc based
- %hasDBFilter = true;
- if(AssetBrowser.assetTypeFilter !$= "")
- {
- %hasDBFilter = false;
- %filterCount = getWordCount(AssetBrowser.assetTypeFilter);
- for(%fltrIdx = 0; %fltrIdx < %filterCount; %fltrIdx++)
- {
- %fltr = getWord(AssetBrowser.assetTypeFilter, %fltrIdx);
- if(%fltr $= "Datablock" || %fltr $= "Datablocks")
- {
- %hasDBFilter = true;
- break;
- }
- }
- }
- if(%hasDBFilter && %breadcrumbPath !$= "" && isDirectory(%breadcrumbPath))
- {
- %category = getWord( %breadcrumbPath, 1 );
- %dataGroup = "DataBlockGroup";
-
- for ( %i = 0; %i < %dataGroup.getCount(); %i++ )
- {
- %obj = %dataGroup.getObject(%i);
- // echo ("Obj: " @ %obj.getName() @ " - " @ %obj.category );
-
- //if ( %obj.category $= "" && %obj.category == 0 )
- // continue;
-
- %dbFilename = %obj.getFileName();
- %dbFilePath = filePath(%dbFilename);
-
- %searchActive = AssetSearchTerms.count() != 0;
- if(%searchActive)
- {
- if(startsWith(%dbFilePath, %breadcrumbPath))
- {
- %dbName = %obj.getName();
- if(matchesSearch(%dbName, "Datablock"))
- {
- $AssetBrowser::AssetArray.add( %dbFilename, "Datablock" TAB %dbName );
- }
- }
- }
- else if(%dbFilePath $= %breadcrumbPath)
- {
- %dbName = %obj.getName();
- $AssetBrowser::AssetArray.add( %dbFilename, "Datablock" TAB %dbName );
-
- /*%catItem = AssetBrowser-->filterTree.findItemByName(%obj.category);
-
- if(%catItem == 0)
- AssetBrowser-->filterTree.insertItem(%scriptedItem, %obj.category, "scripted");*/
- /*%ctrl = %this.findIconCtrl( %obj.category );
- if ( %ctrl == -1 )
- {
- %this.addFolderIcon( %obj.category );
- }*/
- }
- }
-
-
- %this.getLooseFilesInDir();
-
- %looseFiles = ABLooseFileArray.count();
- for( %i=0; %i < %looseFiles; %i++)
- {
- %looseFileFullPath = ABLooseFileArray.getKey(%i);
- %looseFilePath = filePath(%looseFileFullPath);
- %looseFileName = fileName(%looseFileFullPath);
- %looseFileExt = fileExt(%looseFileFullPath);
-
- $AssetBrowser::AssetArray.add( %looseFilePath, "LooseFile" TAB %looseFileName );
- }
-
- //Prefabs
- %expr = "*.prefab";
- %fullPrefabPath = findFirstFile( %breadcrumbPath @ "/" @ %expr );
-
- while ( %fullPrefabPath !$= "" )
- {
- %prefabPath = filePath(%fullPrefabPath);
- %prefabName = fileName(%fullPrefabPath);
-
- %searchActive = AssetSearchTerms.count() != 0;
- if(%searchActive)
- {
- if(startsWith(%prefabPath, %breadcrumbPath))
- {
- if(matchesSearch(%prefabName, "Prefab"))
- {
- $AssetBrowser::AssetArray.add( %prefabPath, "Prefab" TAB %prefabName );
- }
- }
- }
- else if(%prefabPath $= %breadcrumbPath)
- {
- $AssetBrowser::AssetArray.add( %prefabPath, "Prefab" TAB %prefabName );
- }
- %fullPrefabPath = findNextFile( %breadcrumbPath @ "/" @ %expr );
- }
-
- //C++ files
- %cppPattern = %breadcrumbPath @ "/" @ "*.cpp";
- for (%fullCppPath = findFirstFile(%cppPattern); %fullCppPath !$= ""; %fullCppPath = findNextFile(%cppPattern))
- {
- %cppPath = filePath(%fullCppPath);
- %cppName = fileName(%fullCppPath);
-
- %searchActive = AssetSearchTerms.count() != 0;
- if(%searchActive)
- {
- if(startsWith(%cppPath, %breadcrumbPath))
- {
- if(matchesSearch(%cppName, "Cpp"))
- {
- $AssetBrowser::AssetArray.add( %cppPath, "Cpp" TAB %cppName );
- }
- }
- }
- else if(%cppPath $= %breadcrumbPath)
- {
- $AssetBrowser::AssetArray.add( %cppPath, "Cpp" TAB %cppName );
- }
- }
-
- //C++ Header files
- %cppPattern = %breadcrumbPath @ "/" @ "*.h";
- for (%fullCppPath = findFirstFile(%cppPattern); %fullCppPath !$= ""; %fullCppPath = findNextFile(%cppPattern))
- {
- %cppPath = filePath(%fullCppPath);
- %cppName = fileName(%fullCppPath);
-
- %searchActive = AssetSearchTerms.count() != 0;
- if(%searchActive)
- {
- if(startsWith(%cppPath, %breadcrumbPath))
- {
- if(matchesSearch(%cppName, "Cpp"))
- {
- $AssetBrowser::AssetArray.add( %cppPath, "Cpp" TAB %cppName );
- }
- }
- }
- else if(%cppPath $= %breadcrumbPath)
- {
- $AssetBrowser::AssetArray.add( %cppPath, "Cpp" TAB %cppName );
- }
- }
-
- //script files
- %tscriptPattern = %breadcrumbPath @ "/" @ "*.tscript";
- for (%fullScriptPath = findFirstFile(%tscriptPattern); %fullScriptPath !$= ""; %fullScriptPath = findNextFile(%tscriptPattern))
- {
- //If it's associated to an asset, we'll want to do extra checks
- %assetQuery = new AssetQuery();
- %foundAssets = AssetDatabase.findAssetLooseFile(%assetQuery, %fullScriptPath);
-
- if(%foundAssets != 0)
- {
- %doSkip = false;
- %count = %assetQuery.getCount();
- for(%i=0; %i < %count; %i++)
- {
- %assetId = %assetQuery.getAsset(%i);
- %foundAssetType = AssetDatabase.getAssetType(%assetId);
- if(%foundAssetType !$= "ScriptAsset" && %foundAssetType !$= "GUIAsset")
- {
- %doSkip = true;
- break;
- }
- }
-
- if(%doSkip)
- continue;
- }
-
- %tscriptPath = filePath(%fullScriptPath);
- %tscriptName = fileName(%fullScriptPath);
-
- %searchActive = AssetSearchTerms.count() != 0;
- if(%searchActive)
- {
- if(startsWith(%tscriptPath, %breadcrumbPath))
- {
- if(matchesSearch(%tscriptName, "tscript"))
- {
- $AssetBrowser::AssetArray.add( %tscriptPath, "tscript" TAB %tscriptName );
- }
- }
- }
- else if(%tscriptPath $= %breadcrumbPath)
- {
- $AssetBrowser::AssetArray.add( %tscriptPath, "tscript" TAB %tscriptName );
- }
- }
- }
-
- //If we've selected into the Creator section, we have special handling for that
- if(startsWith(%breadcrumbPath, "Creator"))
- {
- //One of the creator folders was selected
- %creatorGroup = AssetBrowserFilterTree.getItemText(AssetBrowserFilterTree.getSelectedItem(0));
-
- if(%creatorGroup $= "Creator")
- {
- //add folders for the groups
- %placeholderVar = "";
- }
- else
- {
- for ( %i = 0; %i < AssetBrowser.creatorClassArray.count(); %i++ )
- {
- %group = AssetBrowser.creatorClassArray.getKey( %i );
- //Do some filter logic do skip out of groups if we're in the wrong editor mode for it
- %creatorEditorFilter = "WorldEditor";
- if(GuiEditorIsActive())
- {
- %creatorEditorFilter = "GuiEditor";
- }
-
- %creatorGroupIndex = AssetBrowserCreatorGroupsList.getIndexFromValue(%group);
- %creatorGroupKey = AssetBrowserCreatorGroupsList.getKey(%creatorGroupIndex);
-
- if ( %group $= %creatorGroup && %creatorGroupKey $= %creatorEditorFilter )
- {
- %creatorObj = AssetBrowser.creatorClassArray.getValue( %i );
- %class = %creatorObj.val[0];
- %name = %creatorObj.val[1];
- %func = %creatorObj.val[2];
-
- %searchActive = AssetSearchTerms.count() != 0;
- if(%searchActive && !matchesSearch(%name, "Creator"))
- continue;
-
- $AssetBrowser::AssetArray.add( %name, "Creator" TAB %creatorObj );
- }
- }
- }
- }
-
- for(%i=0; %i < $AssetBrowser::AssetArray.count(); %i++)
- AssetBrowser.buildAssetPreview( $AssetBrowser::AssetArray.getValue(%i), $AssetBrowser::AssetArray.getKey(%i) );
- //Queue population of any non-Type Card preview images
- AssetBrowser.schedule(32, "populatePreviewImages");
-
- AssetBrowser_FooterText.text = %finalAssetCount @ " Assets";
-
- %activeTypeFilterList = "";
- if(AssetBrowser.assetTypeFilter $= "")
- {
- if(!AssetTypeListPopup.isItemChecked(0))
- {
- for(%f=1; %f < AssetFilterTypeList.Count(); %f++)
- {
- %isChecked = AssetTypeListPopup.isItemChecked(%f+1);
-
- if(%isChecked)
- {
- %filterTypeName = AssetFilterTypeList.getKey(%f);
-
- if(%activeTypeFilterList $= "")
- %activeTypeFilterList = %filterTypeName;
- else
- %activeTypeFilterList = %activeTypeFilterList @ ", " @ %filterTypeName;
- }
- }
- }
- }
- else
- {
- %activeTypeFilterList = AssetBrowser.assetTypeFilter;
- }
-
- if(%activeTypeFilterList !$= "")
- AssetBrowser_FooterText.text = AssetBrowser_FooterText.text @ " | Active Type Filters: " @ %activeTypeFilterList;
-
- %this.previewArrayDirty = false;
- }
- //
- //
- // Search
- function AssetBrowser::updateSearchTextFromFilter(%this)
- {
- AssetSearchTerms.sortk();
-
- //Update the displayed search text!
- %newSearchPhrase = "";
- %currentAction = "";
- %actionCount = 0;
- for(%i=0; %i < AssetSearchTerms.count(); %i++)
- {
- %action = AssetSearchTerms.getKey(%i);
- %word = AssetSearchTerms.getValue(%i);
-
- if(%action !$= %currentAction)
- {
- if(%actionCount != 0)
- {
- if(%action !$= "")
- %newSearchPhrase = %newSearchPhrase @ ";" @ %action @ ":" @ %word;
- else
- %newSearchPhrase = %newSearchPhrase @ ";" @ %word;
- }
- else
- {
- if(%action !$= "")
- %newSearchPhrase = %action @ ":" @ %word;
- else
- %newSearchPhrase = %word;
- }
-
- %actionCount++;
- }
- else
- {
- %newSearchPhrase = %newSearchPhrase @ "," @ %word;
- }
-
- %currentAction = %action;
- }
-
- AssetBrowserSearchFilter.setText(%newSearchPhrase);
- }
- function AssetBrowser::processSearchFilter(%this)
- {
- AssetSearchTerms.empty();
-
- %searchText = AssetBrowserSearchFilter.getText();
-
- %termCount = getTokenCount(%searchText, ";");
- for(%s=0; %s < %termCount; %s++)
- {
- %term = getToken(%searchText, ";", %s);
-
- %phraseCount = getTokenCount(%term, ":");
-
- if(%phraseCount == 2)
- {
- //action/words split
- %action = getToken(%term, ":", 0);
- %words = getToken(%term, ":", 1);
- }
- else
- {
- %action = "";
- %words = getToken(%term, ":", 0);
- }
-
- %wordCount = getTokenCount(%words, ",");
- for(%w=0; %w < %wordCount; %w++)
- {
- %word = getToken(%words, ",", %w);
- AssetSearchTerms.add(%action, %word);
- }
- }
- }
- //Takes an item and compares it against the parsed search language
- //This is written to be inclusive, rather than exclusive
- function matchesSearch(%assetName, %assetType)
- {
- if(AssetSearchTerms.count() == 0)
- return true;
-
- %matchTags = false;
- %matchType = false;
- %matchName = false;
-
- %needsTag = false;
- %needsType = false;
- %needsName = false;
- for(%i=0; %i < AssetSearchTerms.count(); %i++)
- {
- %action = AssetSearchTerms.getKey(%i);
- %word = AssetSearchTerms.getValue(%i);
-
- if(%action $= "tag" && %matchTags == false)
- {
- %needsTag = true;
- if(%assetType $= "Datablock")
- {
- if(%assetName.category $= %word)
- %matchTags = true;
- }
- else
- {
- if(strstr(strlwr(%assetName.tags), strlwr(%word)) != -1)
- %matchTags = true;
- }
- }
- else if(%action $= "type" && %matchType == false)
- {
- %needsType = true;
- if(%assetType $= %word)
- %matchType = true;
- }
- else if(%action $= "" && %matchName == false)
- {
- %needsName = true;
- if(strstr(strlwr(%assetName), strlwr(%word)) != -1)
- %matchName = true;
- }
- }
-
- if(((%needsTag && %matchTags) || !%needsTag) &&
- ((%needsType && %matchType) || !%needsType) &&
- ((%needsName && %matchName) || !%needsName))
- return true;
- else
- return false;
- }
- //
- //
- // Search Filters
- function AssetBrowserSearchFilterTxt::onWake( %this )
- {
- /*%filter = %this.treeView.getFilterText();
- if( %filter $= "" )
- %this.setText( "\c2Filter..." );
- else
- %this.setText( %filter );*/
- }
- function AssetBrowserSearchFilterTxt::onGainFirstResponder( %this )
- {
- %this.selectAllText();
- }
- // When Enter is pressed in the filter text control, pass along the text of the control
- // as the treeview's filter.
- function AssetBrowserFolderSearchFilter::onReturn( %this )
- {
- %text = %this.getText();
- if( %text $= "" )
- %this.reset();
-
- AssetBrowser.refresh();
- }
- function AssetBrowserFolderSearchFilter::onEdited(%this)
- {
- if(AssetBrowserFolderSearchFilter.getText() $= "")
- {
- AssetBrowser-->folderSearchBtn.setBitmap("tools/gui/images/stencilIcons/zoom.png");
- }
- else
- {
- AssetBrowser-->folderSearchBtn.setBitmap("tools/gui/images/stencilIcons/cross.png");
- }
- }
- function AssetBrowserSearchFilter::onEdited(%this)
- {
- AssetBrowserSearchFilter.updateButton();
- }
- function AssetBrowserSearchFilter::onReturn( %this )
- {
- %text = %this.getText();
- if( %text $= "" )
- %this.reset();
-
- AssetBrowserSearchFilter.updateButton();
-
- AssetBrowser.processSearchFilter();
-
- AssetBrowser.rebuildAssetArray();
- }
- function AssetBrowserSearchFilter::updateButton(%this)
- {
- if(%this.getText() $= "")
- {
- AssetBrowser-->assetSearchBtn.setBitmap("tools/gui/images/stencilIcons/zoom.png");
- }
- else
- {
- AssetBrowser-->assetSearchBtn.setBitmap("tools/gui/images/stencilIcons/cross.png");
- }
- }
- function AssetBrowserFolderSearchFilter::reset( %this )
- {
- %this.setText( "" );
- AssetBrowser-->folderSearchBtn.setBitmap("tools/gui/images/stencilIcons/zoom.png");
- //AssetBrowser.refresh();
- }
- function AssetBrowserSearchFilter::reset( %this )
- {
- %this.setText( "" );
- AssetBrowser-->assetSearchBtn.setBitmap("tools/gui/images/stencilIcons/zoom.png");
- //AssetBrowser.rebuildAssetArray();
- }
- function AssetBrowserFolderSearchBtn::onClick( %this )
- {
- AssetBrowserFolderSearchFilter.reset();
- AssetBrowser.refresh();
- }
- function AssetBrowserAssetSearchBtn::onClick( %this )
- {
- AssetBrowserSearchFilter.reset();
- AssetBrowser.processSearchFilter();
-
- AssetBrowser.rebuildAssetArray();
- }
- //
- //
- // Navigation
- function AssetBrowser::navigateTo(%this, %address, %historyNav)
- {
- //Sanitize
- if(startsWith(%address, "/"))
- %address = strreplace(%address, "/", "");
-
- //Don't bother navigating if it's to the place we already are
- if(%this.dirHandler.currentAddress !$= %address)
- {
- %this.dirHandler.navigateTo(%address, %historyNav);
-
- //%this.updateNavigationBreadcrumb(%address);
-
- %this.lastValidNavPath = %address;
- %this-->navPath.setText(%address);
-
- %module = %this.dirHandler.getModuleFromAddress(%address);
- if(%module !$= "")
- {
- //legit module, so set it as current target
- %this.SelectedModule = %module.moduleId;
- }
-
- if(%this.hasLooseFilesInDir())
- {
- if(EditorSettings.value("Assets/AutoImportLooseFiles", false) && EditorSettings.value("Assets/AutoImport", false))
- {
- AssetBrowser.autoImportSimpleLooseFiles();
- }
- else
- {
- %this-->AutoImportAssetButton.visible = true;
- }
- }
- else
- {
- %this-->AutoImportAssetButton.visible = false;
- }
- }
-
- %this.rebuildAssetArray();
- %this.refresh();
- }
- function AssetBrowser::navigateHistoryForward(%this)
- {
- %this.dirHandler.navigateHistoryForward();
-
- %this.updateNavigationBreadcrumb();
-
- %address = %this.dirHandler.currentAddress;
-
- %module = AssetBrowser.dirHandler.getModuleFromAddress(%address);
- if(%module !$= "")
- {
- //legit module, so set it as current target
- %this.SelectedModule = %module.moduleId;
- }
-
- %this.lastValidNavPath = %address;
- %this-->navPath.setText(%address);
-
- %this.rebuildAssetArray();
- }
- function AssetBrowser::navigateHistoryBack(%this)
- {
- %this.dirHandler.navigateHistoryBack();
-
- %this.updateNavigationBreadcrumb();
-
- %address = %this.dirHandler.currentAddress;
-
- %module = %this.dirHandler.getModuleFromAddress(%address);
- if(%module !$= "")
- {
- //legit module, so set it as current target
- %this.SelectedModule = %module.moduleId;
- }
-
- %this.lastValidNavPath = %address;
- %this-->navPath.setText(%address);
-
- %this.rebuildAssetArray();
- }
- function AssetBrowser::updateNavigationBreadcrumb(%this, %address)
- {
- //clear the breadcrumb bar
- AssetBrowser_BreadcrumbBar.clear();
-
- //break down the address
- %folderCount = getTokenCount(%address, "/");
-
- %rebuiltPath = "";
- for(%f=0; %f < %folderCount; %f++)
- {
- %folderName = getToken(%address, "/", %f);
-
- %rebuiltPath = %f == 0 ? %folderName : %rebuiltPath @ "/" @ %folderName;
-
- %folderNavButton = new GuiButtonCtrl()
- {
- profile = ToolsGuiButtonProfile;
- text = %folderName;
- command = "AssetBrowser.navigateTo(\"" @ %rebuiltPath @ "\");";
- extent = "100" SPC AssetBrowser_BreadcrumbBar.extent.y;
- };
-
- AssetBrowser_BreadcrumbBar.add(%folderNavButton);
-
- if(%f != %folderCount-1)
- {
- %folderSpacerButton = new GuiBitmapButtonCtrl()
- {
- profile = ToolsGuiButtonProfile;
- bitmapAsset = "ToolsModule:rightArrowWhite_image";
- bitmapMode = "Centered";
- extent = "25" SPC AssetBrowser_BreadcrumbBar.extent.y;
- //command = "AssetBrowser.navigateTo(\"" @ %rebuiltPath @ "\");";
- };
-
- AssetBrowser_BreadcrumbBar.add(%folderSpacerButton);
- }
- }
- //refresh the nav buttons to display the history
- %backButtonHistory = "";
- for(%i=0; %i < AssetBrowser.dirHandler.prevHistoryList.Count(); %i++)
- {
- %prevAddress = AssetBrowser.dirHandler.prevHistoryList.getKey(%i);
- %backButtonHistory = %i==0 ? %prevAddress @ "\n" : %backButtonHistory @ %prevAddress @ "\n";
- }
-
- AssetBrowser_NavigateBackBtn.tooltip = %backButtonHistory;
-
- %foreButtonHistory = "";
- for(%i=0; %i < AssetBrowser.dirHandler.foreHistoryList.Count(); %i++)
- {
- %prevAddress = AssetBrowser.dirHandler.foreHistoryList.getKey(%i);
- %foreButtonHistory = %i==0 ? %prevAddress @ "\n" : %foreButtonHistory @ %prevAddress @ "\n";
- }
-
- AssetBrowser_NavigateForwardBtn.tooltip = %foreButtonHistory;
- }
- function assetBrowserNavPath::onReturn(%this)
- {
- %newPath = %this.getText();
- if(isDirectory(%newPath))
- {
- AssetBrowser.lastValidNavPath = %newPath;
- AssetBrowser.navigateTo(%newPath);
- }
- else
- {
- %this.setText(AssetBrowser.lastValidNavPath);
- AssetBrowser.navigateTo(AssetBrowser.lastValidNavPath);
- }
- }
- //
- //
- //
- function AssetBrowser::reloadModules(%this)
- {
- ModuleDatabase.unloadGroup("Game");
-
- %modulesList = ModuleDatabase.findModules();
-
- %count = getWordCount(%modulesList);
-
- for(%i=0; %i < %count; %i++)
- {
- %moduleId = getWord(%modulesList, %i).ModuleId;
- ModuleDatabase.unloadExplicit(%moduleId);
- }
- ModuleDatabase.scanModules();
-
- %modulesList = ModuleDatabase.findModules();
-
- %count = getWordCount(%modulesList);
-
- for(%i=0; %i < %count; %i++)
- {
- %moduleId = getWord(%modulesList, %i).ModuleId;
- ModuleDatabase.loadExplicit(%moduleId);
- }
-
- //ModuleDatabase.loadGroup("Game");
- }
- //
- //
- //
- function AssetBrowser::toggleFolderCollapseButton(%this)
- {
- %this.folderPanelState = !%this.folderPanelState;
-
- //If we're collapsing
- if(!%this.folderPanelState)
- {
- //Store the original
- %this.folderPanelSplit = AssetBrowser_MainSplit.splitPoint.x;
-
- //collapse it
- AssetBrowser_MainSplit.setSplitPoint(AssetBrowser_MainSplit.splitterSize SPC AssetBrowser_MainSplit.splitPoint.y);
- }
- else
- {
- //restore the original
- AssetBrowser_MainSplit.setSplitPoint(%this.folderPanelSplit SPC AssetBrowser_MainSplit.splitPoint.y);
- }
- }
- //
- //
- // Drag n drop
- function AssetBrowserPreviewButton::onMouseDragged(%this)
- {
- %payload = %this.clone();
- %payload.position = "0 0";
- //%payload.class = "AssetPreviewControl";
-
- %xOffset = getWord( %payload.extent, 0 ) / 2;
- %yOffset = getWord( %payload.extent, 1 ) / 2;
-
- // Compute the initial position of the GuiDragAndDrop control on the cavas based on the current
- // mouse cursor position.
-
- %cursorpos = Canvas.getCursorPos();
- %xPos = getWord( %cursorpos, 0 ) - %xOffset;
- %yPos = getWord( %cursorpos, 1 ) - %yOffset;
-
- if(!isObject(EditorDragAndDropLayer))
- {
- new GuiControl(EditorDragAndDropLayer)
- {
- position = "0 0";
- extent = Canvas.extent;
- };
- }
-
- // Create the drag control.
- %ctrl = new GuiDragAndDropControl()
- {
- canSaveDynamicFields = "0";
- Profile = "ToolsGuiSolidDefaultProfile";
- HorizSizing = "right";
- VertSizing = "bottom";
- Position = %xPos SPC %yPos;
- extent = %payload.extent;
- MinExtent = "4 4";
- canSave = "1";
- Visible = "1";
- hovertime = "1000";
- // Let the GuiDragAndDropControl delete itself on mouse-up. When the drag is aborted,
- // this not only deletes the drag control but also our payload.
- deleteOnMouseUp = true;
-
- useWholeCanvas = true;
- // To differentiate drags, use the namespace hierarchy to classify them.
- // This will allow a color swatch drag to tell itself apart from a file drag, for example.
- class = "AssetPreviewControlType_AssetDrop";
- };
-
- // Add the temporary color swatch to the drag control as the payload.
- %ctrl.add( %payload );
-
- // Start drag by adding the drag control to the canvas and then calling startDragging().
- //Canvas.getContent().add( %ctrl );
- EditorDragAndDropLayer.add(%ctrl);
- Canvas.pushDialog(EditorDragAndDropLayer);
-
- %ctrl.startDragging( %xOffset, %yOffset );
-
- Canvas.repaint();
- }
- function AssetBrowserPreviewButton::onControlDragCancelled(%this)
- {
- Canvas.popDialog(EditorDragAndDropLayer);
- }
- function AssetBrowserPreviewButton::onControlDropped( %this, %payload, %position )
- {
- Canvas.popDialog(EditorDragAndDropLayer);
-
- if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
- return;
- // If dropped on same button whence we came from,
- // do nothing.
- if( %payload.dragSourceControl == %this )
- return;
-
- %assetType = %payload.assetType;
- %assetName = %payload.assetName;
- %moduleName = %payload.moduleName;
-
- %targetAssetName = %this.assetName;
- %targetAssetType = %this.assetType;
- %targetModuleName = %this.moduleName;
- if( %payload.dragSourceControl.class $= "AssetPreviewButton" && %targetAssetType $= "Folder")
- {
- %destination = %targetModuleName @ "/" @ %targetAssetName;
-
- if(%assetType $= "Folder")
- {
- %originFolder = %moduleName @ "/" @ %assetName;
- %destination = %destination @ "/" @ %assetName;
-
- //Do any cleanup required given the type
- if(AssetBrowser.isMethod("moveFolder"))
- eval(AssetBrowser @ ".moveFolder(\""@%originFolder@"\",\""@%destination@"\");");
- }
- else
- {
- %assetId = %moduleName @ ":" @ %assetName;
- %assetDef = AssetDatabase.acquireAsset(%assetId);
- %assetType = AssetDatabase.getAssetType(%assetId);
-
- //Do any cleanup required given the type
- if(AssetBrowser.isMethod("move"@%assetType))
- {
- %command = AssetBrowser @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %destination @ "\");";
- eval(AssetBrowser @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %destination @ "\");");
- }
- }
-
- AssetBrowser.refresh();
- }
- }
- function EWorldEditor::onControlDropped( %this, %payload, %position )
- {
- Canvas.popDialog(EditorDragAndDropLayer);
-
- // Make sure this is a color swatch drag operation.
- if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
- return;
- // If dropped on same button whence we came from,
- // do nothing.
- if( %payload.dragSourceControl == %this )
- return;
- %assetType = %payload.assetType;
-
- %pos = ObjectCreator.getCreateObjectPosition(); //LocalClientConnection.camera.position;
- %module = %payload.moduleName;
- %asset = %payload.assetName;
-
- if(AssetBrowser.isMethod("on" @ %assetType @ "EditorDropped"))
- {
- if(%assetType $= "Datablock")
- {
- %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %asset @ ",\"" @ %pos @ "\");";
- }
- else if(%assetType $= "Prefab")
- {
- %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(\"" @ %module @ "/" @ %asset @ "\",\"" @ %pos @ "\");";
- }
- else if(%assetType $= "Creator")
- {
- %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %module @ ",\"" @ %pos @ "\");";
- }
- else
- {
- %assetDef = AssetDatabase.acquireAsset(%module @ ":" @ %asset);
- %buildCommand = AssetBrowser @ ".on" @ %assetType @ "EditorDropped(" @ %assetDef @ ",\"" @ %pos @ "\");";
- }
- eval(%buildCommand);
-
- if(EditorSettings.value("AssetManagement/Assets/closeBrowserOnDragAction", false))
- {
- AssetBrowser.hideDialog();
- }
- }
-
- EWorldEditor.isDirty = true;
- }
- function GuiEditor::onControlDropped(%this, %payload, %position)
- {
- Canvas.popDialog(EditorDragAndDropLayer);
- // Make sure we have the right kind of D&D.
-
- if( !%payload.parentGroup.isInNamespaceHierarchy( "GuiDragAndDropControlType_GuiControl" ) &&
- !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ))
- return;
-
- if( %payload.dragSourceControl == %this )
- return;
- %pos = %payload.getGlobalPosition();
- %x = getWord(%pos, 0);
- %y = getWord(%pos, 1);
-
- if(%payload.assetType !$= "Creator")
- {
- //dealing with an actual asset, so build the assetName
- %assetId = %payload.moduleName @ ":" @ %payload.assetName;
- %assetType = AssetDatabase.getAssetType(%assetId);
-
- if(AssetBrowser.isMethod("on" @ %assetType @ "GUIEditorDropped"))
- {
- %module = %payload.moduleName;
- %asset = %payload.assetName;
- %assetDef = AssetDatabase.acquireAsset(%module @ ":" @ %asset);
- %buildCommand = AssetBrowser @ ".on" @ %assetType @ "GUIEditorDropped(" @ %assetDef @ ",\"" @ %pos @ "\");";
- eval(%buildCommand);
- }
- else
- {
- //fallback example
- if(%assetType $= "ImageAsset")
- {
- %cmd = "return new guiBitmapCtrl();";
- %ctrl = eval( %cmd );
- %ctrl.bitmap = %assetId;
- }
- }
- }
- else
- {
- %className = %payload.assetName;
- if(%payload.altCommand !$= "")
- {
- %cmd = %payload.altCommand;
- }
- else
- {
- %cmd = "return new " @ %className @ "();";
- }
- %ctrl = eval( %cmd );
- }
- %this.addNewCtrl(%ctrl);
-
- %ctrl.setPositionGlobal(%x, %y);
- %this.setFirstResponder();
-
- if(EditorSettings.value("AssetManagement/Assets/closeBrowserOnDragAction", false))
- {
- AssetBrowser.hideDialog();
- }
- }
- function AssetBrowserFilterTree::onControlDropped( %this, %payload, %position )
- {
- Canvas.popDialog(EditorDragAndDropLayer);
-
- if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
- return;
-
- %assetType = %payload.assetType;
- %assetName = %payload.assetName;
- %moduleName = %payload.moduleName;
-
- %item = %this.getItemAtPosition(%position);
-
- %parent = %this.getParentItem(%item);
-
- if(%item != 1)
- {
- //we're a folder entry, cool
- %path = %this.getItemValue(%item) @ "/" @ %this.getItemText(%item);
-
- if(%path !$= AssetBrowser.dirHandler.CurrentAddress)
- {
- //we're trying to move the asset to a different module!
- //toolsMessageBoxYesNo( "Move Asset", "Do you wish to move asset " @ %assetName @ " to " @ %path @ "?",
- // "AssetBrowser.moveAsset(\""@ %moduleName @ ":" @ %assetName @"\", \""@%path@"\");", "");
-
- if(%assetType $= "Folder")
- {
- %originFolder = %moduleName @ "/" @ %assetName;
- %path = %path @ "/" @ %assetName;
-
- //Do any cleanup required given the type
- if(AssetBrowser.isMethod("moveFolder"))
- {
- eval(AssetBrowser @ ".moveFolder(\""@%originFolder@"\",\""@%path@"\");");
-
- AssetBrowser.refresh();
- }
- }
- else
- {
- %assetId = %moduleName @ ":" @ %assetName;
- %assetDef = AssetDatabase.acquireAsset(%assetId);
- %assetType = AssetDatabase.getAssetType(%assetId);
-
- //Do any cleanup required given the type
- if(AssetBrowser.isMethod("move"@%assetType))
- {
- %command = AssetBrowser @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %path @ "\");";
- eval(AssetBrowser @ ".move" @ %assetType @ "(" @ %assetDef @ ",\"" @ %path @ "\");");
-
- AssetBrowser.refresh();
- }
- }
- }
- }
- }
- function AssetBrowserFilterTree::onDragDropped( %this )
- {
- }
- function AssetBrowser::hasLooseFilesInDir(%this)
- {
- if(!isDirectory(%this.dirHandler.currentAddress))
- return false;
-
- //First, wipe out any files inside the folder first
- %file = findFirstFileMultiExpr( %this.dirHandler.currentAddress @ "/*.*", false);
-
- %aq = new AssetQuery();
- while( %file !$= "" )
- {
- if(!strIsMatchExpr("*.asset.taml", %file) && !strIsMatchExpr("*.taml", %file) && !strIsMatchExpr("*.cached.dts", %file))
- {
- %assetsFound = AssetDatabase.findAssetLooseFile(%aq, %file);
-
- if(%assetsFound == 0)
- {
- %ext = fileExt(%file);
- if(isShapeFormat(%ext) || isImageFormat(%ext) || isSoundFormat(%ext))
- {
- %aq.delete();
- return true;
- }
- }
- }
-
- %file = findNextFileMultiExpr( %this.dirHandler.currentAddress @ "/*.*" );
- }
-
- %aq.delete();
- return false;
- }
- function AssetBrowser::autoImportSimpleLooseFiles(%this)
- {
- %importer = new AssetImporter();
-
- //First, wipe out any files inside the folder first
- %file = findFirstFileMultiExpr( %this.dirHandler.currentAddress @ "/*.*", false);
-
- %aq = new AssetQuery();
- while( %file !$= "" )
- {
- if(!strIsMatchExpr("*.asset.taml", %file) && !strIsMatchExpr("*.taml", %file) && !strIsMatchExpr("*.cached.dts", %file)
- && !strIsMatchExpr("*.cs", %file) && !strIsMatchExpr("*.tscript", %file) && !strIsMatchExpr("*.module", %file))
- {
- %aq.clear();
- %assetsFound = AssetDatabase.findAssetLooseFile(%aq, %file);
-
- if(%assetsFound == 0)
- {
- %ext = fileExt(%file);
- if(isShapeFormat(%ext) || isImageFormat(%ext) || isSoundFormat(%ext))
- {
- %assetId = %importer.autoImportFile(%file);
- }
- }
- }
-
- %file = findNextFileMultiExpr( %this.dirHandler.currentAddress @ "/*.*" );
- }
-
- %aq.delete();
- %importer.delete();
-
- %this.refresh();
- }
- function AssetBrowser::getLooseFilesInDir(%this)
- {
- if(!isObject(ABLooseFileArray))
- new ArrayObject(ABLooseFileArray);
-
- ABLooseFileArray.empty();
-
- %showLooseFiles = EditorSettings.value("Assets/Browser/showLooseFiles", false);
- if(%showLooseFiles == false)
- return;
-
- //First, wipe out any files inside the folder first
- %file = findFirstFileMultiExpr( %this.dirHandler.currentAddress @ "/*.*", false);
-
- %aq = new AssetQuery();
- while( %file !$= "" )
- {
- if(!strIsMatchExpr("*.asset.taml", %file) && !strIsMatchExpr("*.taml", %file) && !strIsMatchExpr("*.cached.dts", %file))
- {
- %assetsFound = AssetDatabase.findAssetLooseFile(%aq, %file);
-
- if(%assetsFound == 0)
- {
- ABLooseFileArray.add(%file);
- }
- }
-
- %file = findNextFileMultiExpr( %this.dirHandler.currentAddress @ "/*.*" );
- }
-
- %aq.delete();
- return false;
- }
- //
- //
- function AssetBrowser::importLooseFiles(%this)
- {
- echo("Adding loose files at directory " @ %this.dirHandler.currentAddress);
- LooseFileAuditWindow.showDialog(%this.dirHandler.currentAddress);
- }
- // -----------------------------------------------------------------------------
- function getAssetPreviewImage(%asset)
- {
- if(isFile(%asset))
- {
- %aq = new AssetQuery();
- %assetsFound = AssetDatabase.findAssetLooseFile(%aq, %asset);
- if(%assetsFound != 0)
- {
- %asset = %aq.getAsset(0);
- }
- else
- {
- %previewPath = %asset;
- }
-
- %aq.delete();
- }
-
- if(AssetDatabase.isDeclaredAsset(%asset))
- {
- %moduleName = AssetDatabase.getAssetModule(%asset).ModuleId;
- %assetName = AssetDatabase.getAssetName(%asset);
- %previewAssetName = "ToolsModule:" @ %moduleName @ "_" @ %assetName @ "_PreviewImage";
-
- if(AssetDatabase.isDeclaredAsset(%previewAssetName))
- {
- %previewDef = AssetDatabase.acquireAsset(%previewAssetName);
- %previewPath = %previewDef.getImagePath();
- AssetDatabase.releaseAsset(%previewAssetName);
- }
- else
- {
- %previewPath = %asset;
- }
- }
- else
- {
- %previewPath = %asset;
- }
-
- if(%previewPath $= "")
- %previewPath = "ToolsModule:unknownImage_image";
-
- return %previewPath;
- }
- // -----------------------------------------------------------------------------
- function AssetBrowserWindow::dockPanel(%this)
- {
- if(%this.docked == true)
- return;
-
- %this.resizing = true;
-
- %this.docked = true;
- %this.canCollapse = "0";
- %this.canMove = "0";
- %this.resizeWidth = "0";
-
- AssetBrowserWindow_UnDockBtn.Visible = "1";
- AssetBrowserWindow_DockBtn.Visible = "0";
-
- EditorGui.updateSideBar();
- }
- function AssetBrowserWindow::releasePanel(%this)
- {
- if(%this.docked == false)
- return;
- %this.canCollapse = "1";
- %this.canMove = "1";
- %this.resizeWidth = "1";
-
- AssetBrowserWindow_UnDockBtn.Visible = "0";
- AssetBrowserWindow_DockBtn.Visible = "1";
-
- // Let's do a small resize so it's visually clear we're "undocking"
- %position = %this.position.x + 6 SPC %this.position.y - 6;
- %extent = %this.extent.x SPC %this.extent.y;
- %this.resize(%position.x, %position.y, %extent.x, %extent.y);
-
- %this.docked = false;
- %this.resizing = false;
-
- EditorGui.updateSideBar();
- }
- function AssetBrowserWindow::onResize(%this, %posX, %posY, %width, %height)
- {
- if (%width>%height)
- AssetBrowser-->assetList.fillRowFirst = true;
- else
- AssetBrowser-->assetList.fillRowFirst = false;
- AssetBrowser.rebuildAssetArray();
- }
|