diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index aa343f81f..40540c1ab 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -836,11 +836,11 @@ function OptionsMenuSettingsList::addOptionBoolRow(%this, %label, %targetPrefVar if(%qualityLevelList $= $yesNoList && isInt(%defaultValue)) { - %defaultValue = convertBoolToYesNo(!%defaultValue); + %defaultValue = convertBoolToYesNo(%defaultValue); } else if(%qualityLevelList $= $onOffList && isInt(%defaultValue)) { - %defaultValue = convertBoolToOnOff(!%defaultValue); + %defaultValue = convertBoolToOnOff(%defaultValue); } return %this.addOptionRow(%label, %targetPrefVar, %qualityLevelList, @@ -995,9 +995,11 @@ function MenuOptionsButton::onChange(%this) OptionsMenu.unappliedChanges.add(%targetVar, "\"" @ %saveReadyValue @ "\"" ); } else + { OptionsMenu.unappliedChanges.setValue("\"" @ %saveReadyValue @ "\"", %prefIndex); } } + } else if(%optionMode == 1) { %currentValue = %this.getValue(); @@ -1009,7 +1011,9 @@ function MenuOptionsButton::onChange(%this) OptionsMenu.unappliedChanges.add(%targetVar, "\"" @ %currentValue @ "\"" ); } else + { OptionsMenu.unappliedChanges.setValue("\"" @ %currentValue @ "\"", %prefIndex); + } } //Update the UI in case there's responsive logic diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui index 29c282c5b..c4df19d95 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui @@ -276,6 +276,7 @@ $guiContent = new GuiControl(AssetBrowser) { hovertime = "1000"; isContainer = "0"; internalName = "ImportAssetButton"; + command="AssetBrowser.importNewFile();"; canSave = "1"; canSaveDynamicFields = "0"; }; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript index fd3a7b213..3dd7b881d 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript @@ -368,8 +368,6 @@ function AssetBrowser::buildAssetPreview( %this, %asset, %moduleName ) %this.previewData.doubleClickCommand = ""; } - AssetPreviewArray.empty(); - %previewImage = "core/art/warnmat"; if(/*%moduleName !$= "" && */ModuleDatabase.findModule(%moduleName, 1) !$= "") @@ -512,6 +510,7 @@ function AssetBrowser::buildAssetPreview( %this, %asset, %moduleName ) textLocation = "Bottom"; extent = %previewSize.x SPC %previewSize.y + %textBottomPad; buttonType = "RadioButton"; + buttonMargin = "0 -10"; profile = ToolsGuiDefaultProfile; }; @@ -528,11 +527,15 @@ function AssetBrowser::buildAssetPreview( %this, %asset, %moduleName ) %previewButton.iconLocation = "Left"; %previewButton.textLocation = "Right"; %previewButton.setextent(120,20); + + 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; @@ -549,6 +552,8 @@ function AssetBrowser::buildAssetPreview( %this, %asset, %moduleName ) %doubleClickCommand = "AssetBrowser.editAsset( "@%assetDesc@" );"; } + %this.previewData.previewLoaded = true; + //Build out the preview %buildCommand = %this @ ".build" @ %assetType @ "Preview(\"" @ %assetDesc @ "\"," @ %this.previewData @ ");"; eval(%buildCommand); @@ -579,7 +584,8 @@ function AssetBrowser::buildAssetPreview( %this, %asset, %moduleName ) AssetBrowser-->assetList.add(%previewButton); // add to the array object for reference later - AssetPreviewArray.add( %previewButton, %this.previewData.previewImage ); + if(%this.previewData.previewLoaded == false) + AssetPreviewArray.add( %previewButton ); } function AssetBrowser::refresh(%this) @@ -607,6 +613,25 @@ function AssetBrowser::doRefresh(%this) %this.dirty = false; } } + +function AssetBrowser::populatePreviewImages(%this) +{ + 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) @@ -716,7 +741,6 @@ function AssetBrowser::loadDirectories( %this ) //} // } - AssetPreviewArray.empty(); AssetBrowser-->filterTree.buildVisibleTree(true); @@ -1776,6 +1800,8 @@ function AssetBrowser::doRebuildAssetArray(%this) 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"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.tscript index 167b3f197..f118fc078 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.tscript @@ -175,20 +175,48 @@ function AssetBrowser::importImageAsset(%this, %assetItem) AssetDatabase.refreshAsset(%assetId); } -function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate) +function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData) { - if(%forcePreviewRegenerate $= "") - %forcePreviewRegenerate = false; + //%module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getImagePath()))); - %module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getImagePath()))); - %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/"; + %previewData.previewImage = "ToolsModule:genericAssetIcon_image"; + %previewData.previewLoaded = false; //this marks it for loading progressively later + + %previewData.assetName = %assetDef.assetName; + %previewData.assetPath = %assetDef.scriptFile; + + %previewData.assetFriendlyName = %assetDef.assetName; + %previewData.assetDesc = %assetDef.description; + + //image info + //%info = %assetDef.getImageInfo(); + + %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @ + "Asset Type: Image Asset\n" @ + "Asset Definition ID: " @ %assetDef @ "\n" @ + "Image Type: " @ %assetDef.imageType @ "\n" @ + /* "Format: " @ getWord(%info, 0) @ "\n" @ + "Height: " @ getWord(%info, 1) @ "\n" @ + "Width: " @ getWord(%info, 2) @ "\n" @ + "Depth: " @ getWord(%info, 3) @ "\n" @ */ + "Image File path: " @ %assetDef.getImagePath(); +} + +function AssetBrowser::generateImageAssetPreviewImage(%this, %previewButton, %forceRegenerate) +{ + if(%forceRegenerate $= "") + %forceRegenerate = false; + + %previewPath = "tools/resources/previewCache/" @ %previewButton.moduleName @ "/"; if(!IsDirectory(%previewPath)) { %this.dirHandler.createFolder(%previewPath); } - %generatePreview = false; + %assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName; + + %assetDef = AssetDatabase.acquireAsset(%assetId); %previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.png"; if(!isFile(%previewFilePath) || (compareFileTimes(%assetDef.getImagePath(), %previewFilePath) == 1)) @@ -196,12 +224,10 @@ function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData, %f %generatePreview = true; } - %previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage"; + %previewAssetName = %previewButton.moduleName @ "_" @ %assetDef.assetName @ "_PreviewImage"; - if(%generatePreview || %forcePreviewRegenerate) + if(%generatePreview || %forceRegenerate) { - displayEditorLoadingGui("Generating Image Asset Preview..."); - %success = saveScaledImage(%assetDef.getImagePath(), %previewFilePath, EditorSettings.value("Assets/Browser/PreviewImageSize")); if(%success) @@ -222,49 +248,28 @@ function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData, %f %toolsModuleDef = ModuleDatabase.findModule("ToolsModule",1); %success = AssetDatabase.addDeclaredAsset(%toolsModuleDef, %previewImgAssetPath); + + if(!%success) + { + return false; //failed to register the preview image for some reason? } } - else - { - %previewFilePath = %assetDef.getImagePath(); - %previewAssetName = %module.moduleId @ ":" @ %assetDef.assetName; + + %previewButton.bitmapAsset = %previewAssetName; + return true; } - - hideEditorLoadingGui(); } else { - %previewAssetName = "ToolsModule:" @ %previewAssetName; - } - - //Revalidate. If it didn't work, just use the default placeholder one - if(!isFile(%previewFilePath)) + //just map the existing one then + if(AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName)) { - %previewData.previewImage = "ToolsModule:genericAssetIcon_image"; + %previewButton.bitmapAsset = "ToolsModule:" @ %previewAssetName; + return true; } - else - { - %previewData.previewImage = %previewAssetName; } - %previewData.assetName = %assetDef.assetName; - %previewData.assetPath = %assetDef.scriptFile; - - %previewData.assetFriendlyName = %assetDef.assetName; - %previewData.assetDesc = %assetDef.description; - - //image info - %info = %assetDef.getImageInfo(); - - %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @ - "Asset Type: Image Asset\n" @ - "Asset Definition ID: " @ %assetDef @ "\n" @ - "Image Type: " @ %assetDef.imageType @ "\n" @ - "Format: " @ getWord(%info, 0) @ "\n" @ - "Height: " @ getWord(%info, 1) @ "\n" @ - "Width: " @ getWord(%info, 2) @ "\n" @ - "Depth: " @ getWord(%info, 3) @ "\n" @ - "Image File path: " @ %assetDef.getImagePath(); + return false; } //Renames the asset diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.tscript index d6d48819c..12c6d4e3d 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.tscript @@ -426,8 +426,43 @@ function AssetBrowser::importMaterialAsset(%this, %assetItem) function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate) { - if(%forcePreviewRegenerate $= "") - %forcePreviewRegenerate = false; + %previewData.previewImage = "ToolsModule:genericAssetIcon_image"; + %previewData.previewLoaded = false; //this marks it for loading progressively later + + %previewData.assetName = %assetDef.assetName; + %previewData.assetPath = %assetDef.scriptFile; + + %previewData.assetFriendlyName = %assetDef.assetName; + %previewData.assetDesc = %assetDef.description; + + if(%this.selectMode) + %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );"; + else + %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );"; + + %definitionPath = %assetDef.getScriptPath(); + if(%definitionPath $= "") + %definitionPath = %assetDef.getFilename(); + + %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ + "\nAsset Type: Material Asset" @ + "\nAsset Definition ID: " @ %assetDef @ + "\nDefinition Path: " @ %definitionPath; + + if(!%this.selectMode) + { + %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );"; + } +} + +function AssetBrowser::generateMaterialAssetPreviewImage(%this, %previewButton, %forceRegenerate) +{ + if(%forceRegenerate $= "") + %forceRegenerate = false; + + %assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName; + + %assetDef = AssetDatabase.acquireAsset(%assetId); %module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%assetDef.getAssetId())))); %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/"; @@ -456,10 +491,8 @@ function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData, %previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage"; - if(%generatePreview || %forcePreviewRegenerate) + if(%generatePreview || %forceRegenerate) { - displayEditorLoadingGui("Generating Material Asset Preview..."); - if(isObject(%assetDef.materialDefinitionName)) { //real fast, we'll be 100% sure that the image resource we need is loaded @@ -490,50 +523,28 @@ function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData, %toolsModuleDef = ModuleDatabase.findModule("ToolsModule",1); %success = AssetDatabase.addDeclaredAsset(%toolsModuleDef, %previewImgAssetPath); + + if(!%success) + { + return false; //failed to register the preview image for some reason? } } - else + + %previewButton.bitmapAsset = %previewAssetName; + return true; + } + } + else + { + //just map the existing one then + if(AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName)) { - error("Failed to generate preview for material: " @ %assetDef.materialDefinitionName); + %previewButton.bitmapAsset = "ToolsModule:" @ %previewAssetName; + return true; } - - hideEditorLoadingGui(); - } - - //Revalidate. If it didn't work, just use the default placeholder one - if(!isFile(%previewFilePath)) - { - %previewData.previewImage = "ToolsModule:materialIcon_image"; - } - else - { - %previewData.previewImage = "ToolsModule:" @ %previewAssetName; } - %previewData.assetName = %assetDef.assetName; - %previewData.assetPath = %assetDef.scriptFile; - - %previewData.assetFriendlyName = %assetDef.assetName; - %previewData.assetDesc = %assetDef.description; - - if(%this.selectMode) - %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );"; - else - %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );"; - - %definitionPath = %assetDef.getScriptPath(); - if(%definitionPath $= "") - %definitionPath = %assetDef.getFilename(); - - %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ - "\nAsset Type: Material Asset" @ - "\nAsset Definition ID: " @ %assetDef @ - "\nDefinition Path: " @ %definitionPath; - - if(!%this.selectMode) - { - %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );"; - } + return false; } function AssetBrowser::onMaterialAssetEditorDropped(%this, %assetDef, %position) diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript index c70750e90..4195cf1b9 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript @@ -265,8 +265,44 @@ function AssetBrowser::importShapeAsset(%this, %assetItem) function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate) { - if(%forcePreviewRegenerate $= "") - %forcePreviewRegenerate = false; + %previewData.previewImage = "ToolsModule:genericAssetIcon_image"; + %previewData.previewLoaded = false; //this marks it for loading progressively later + + %previewData.assetName = %assetDef.assetName; + %previewData.assetPath = %assetDef.fileName; + + %previewData.assetFriendlyName = %assetDef.assetName; + %previewData.assetDesc = %assetDef.description; + %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @ + "Asset Type: Shape Asset\n" @ + "Asset Definition ID: " @ %assetDef @ "\n" @ + "Shape File path: " @ %assetDef.getShapePath(); + + if(%this.selectMode) + { + %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );"; + } + else + { + if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset") + { + %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );"; + } + else + { + %previewData.doubleClickCommand = "AssetBrowser.onShapeAssetEditorDropped( "@%assetDef@" );"; + } + } +} + +function AssetBrowser::generateShapeAssetPreviewImage(%this, %previewButton, %forceRegenerate) +{ + if(%forceRegenerate $= "") + %forceRegenerate = false; + + %assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName; + + %assetDef = AssetDatabase.acquireAsset(%assetId); %module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getShapePath()))); %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/"; @@ -286,10 +322,8 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData, %f %previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage"; - if(%generatePreview || %forcePreviewRegenerate) + if(%generatePreview || %forceRegenerate) { - displayEditorLoadingGui("Generating Shape Asset Preview..."); - //real fast, we'll be 100% sure that the image resource we need is loaded %matSlot0AssetId = %assetDef.materialSlot0; @@ -322,46 +356,31 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData, %f %toolsModuleDef = ModuleDatabase.findModule("ToolsModule",1); %success = AssetDatabase.addDeclaredAsset(%toolsModuleDef, %previewImgAssetPath); - } - hideEditorLoadingGui(); + if(!%success) + { + return false; //failed to register the preview image for some reason? } - - //Revalidate. If it didn't work, just use the default placeholder one - if(!isFile(%previewFilePath)) - { - %previewData.previewImage = "ToolsModule:genericAssetIcon_image"; } else { - %previewData.previewImage = "ToolsModule:" @ %previewAssetName; + %previewAssetName = "ToolsModule:" @ %previewAssetName; } - %previewData.assetName = %assetDef.assetName; - %previewData.assetPath = %assetDef.fileName; - - %previewData.assetFriendlyName = %assetDef.assetName; - %previewData.assetDesc = %assetDef.description; - %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @ - "Asset Type: Shape Asset\n" @ - "Asset Definition ID: " @ %assetDef @ "\n" @ - "Shape File path: " @ %assetDef.getShapePath(); - - if(%this.selectMode) - { - %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );"; + %previewButton.bitmapAsset = %previewAssetName; + return true; } else { - if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset") + //just map the existing one then + if(AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName)) { - %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );"; - } - else - { - %previewData.doubleClickCommand = "AssetBrowser.onShapeAssetEditorDropped( "@%assetDef@" );"; + %previewButton.bitmapAsset = "ToolsModule:" @ %previewAssetName; + return true; } } + + return false; } function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position) diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/terrainMaterial.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/terrainMaterial.tscript index 8176d0da0..ded898e9f 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/terrainMaterial.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/terrainMaterial.tscript @@ -111,8 +111,35 @@ function AssetBrowser::moveTerrainMaterialAsset(%this, %assetDef, %destination) function AssetBrowser::buildTerrainMaterialAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate) { - if(%forcePreviewRegenerate $= "") - %forcePreviewRegenerate = false; + %previewData.previewImage = "ToolsModule:genericAssetIcon_image"; + %previewData.previewLoaded = false; //this marks it for loading progressively later + + %previewData.assetName = %assetDef.assetName; + %previewData.assetPath = ""; + %previewData.doubleClickCommand = ""; + + %previewData.assetFriendlyName = %assetDef.gameObjectName; + %previewData.assetDesc = %assetDef.description; + %previewData.tooltip = %assetDef.gameObjectName; + + %definitionPath = %assetDef.getScriptPath(); + if(%definitionPath $= "") + %definitionPath = %assetDef.getFilename(); + + %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ + "\nAsset Type: Terrain Material Asset" @ + "\nAsset Definition ID: " @ %assetDef @ + "\nDefinition Path: " @ %definitionPath; +} + +function AssetBrowser::generateTerrainMaterialAssetPreviewImage(%this, %previewButton, %forceRegenerate) +{ + if(%forceRegenerate $= "") + %forceRegenerate = false; + + %assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName; + + %assetDef = AssetDatabase.acquireAsset(%assetId); %module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%assetDef.getAssetId())))); %previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/"; @@ -141,10 +168,8 @@ function AssetBrowser::buildTerrainMaterialAssetPreview(%this, %assetDef, %previ %previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage"; - if(%generatePreview || %forcePreviewRegenerate) + if(%generatePreview || %forceRegenerate) { - displayEditorLoadingGui("Generating Material Asset Preview..."); - if(isObject(%assetDef.materialDefinitionName)) { %previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape"); @@ -169,38 +194,28 @@ function AssetBrowser::buildTerrainMaterialAssetPreview(%this, %assetDef, %previ %toolsModuleDef = ModuleDatabase.findModule("ToolsModule",1); %success = AssetDatabase.addDeclaredAsset(%toolsModuleDef, %previewImgAssetPath); + + if(!%success) + { + return false; //failed to register the preview image for some reason? } } - hideEditorLoadingGui(); + %previewButton.bitmapAsset = %previewAssetName; + return true; } - - //Revalidate. If it didn't work, just use the default placeholder one - if(!isFile(%previewFilePath)) - { - %previewData.previewImage = "ToolsModule:terrainMaterialIcon_image"; } else { - %previewData.previewImage = "ToolsModule:" @ %previewAssetName; + //just map the existing one then + if(AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName)) + { + %previewButton.bitmapAsset = "ToolsModule:" @ %previewAssetName; + return true; + } } - %previewData.assetName = %assetDef.assetName; - %previewData.assetPath = ""; - %previewData.doubleClickCommand = ""; - - %previewData.assetFriendlyName = %assetDef.gameObjectName; - %previewData.assetDesc = %assetDef.description; - %previewData.tooltip = %assetDef.gameObjectName; - - %definitionPath = %assetDef.getScriptPath(); - if(%definitionPath $= "") - %definitionPath = %assetDef.getFilename(); - - %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ - "\nAsset Type: Terrain Material Asset" @ - "\nAsset Definition ID: " @ %assetDef @ - "\nDefinition Path: " @ %definitionPath; + return false; } function GuiInspectorTypeTerrainMaterialAssetPtr::onClick( %this, %fieldName ) diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/newAsset.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/newAsset.tscript index e3a813862..c4fe9b537 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/newAsset.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/newAsset.tscript @@ -139,6 +139,33 @@ function newAssetUpdatePath(%newPath) NewAssetTargetModule.text = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress).ModuleId; } +// +function AssetBrowser::importNewFile(%this) +{ + %importingPath = ""; + + %dlg = new OpenFileDialog() + { + Filters = "(All Files (*.*)|*.*|"; + DefaultFile = ""; + ChangePath = false; + MustExist = true; + MultipleFiles = false; + forceRelativePath = false; + }; + + if ( %dlg.Execute() ) + { + %importingPath = makeFullPath(%dlg.FileName); + } + + %dlg.delete(); + + AssetBrowser.onBeginDropFiles(); + AssetBrowser.onDropFile(%importingPath); + AssetBrowser.onEndDropFiles(); +} + // function NewAssetTargetModule::onSelect(%this, %idx, %idy) { diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/profiles.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/profiles.tscript index b8825155e..5c3f03ba7 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/profiles.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/profiles.tscript @@ -1,7 +1,7 @@ singleton GuiControlProfile(AssetBrowserPreviewImageAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected - //fillColorNA = "230 126 0 255"; //fill color default + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "230 126 0 255"; @@ -10,7 +10,8 @@ singleton GuiControlProfile(AssetBrowserPreviewImageAsset : ToolsGuiDefaultProfi singleton GuiControlProfile(AssetBrowserPreviewMaterialAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "0 100 0 255"; @@ -19,7 +20,8 @@ singleton GuiControlProfile(AssetBrowserPreviewMaterialAsset : ToolsGuiDefaultPr singleton GuiControlProfile(AssetBrowserPreviewShapeAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "0 0 200 255"; @@ -28,7 +30,8 @@ singleton GuiControlProfile(AssetBrowserPreviewShapeAsset : ToolsGuiDefaultProfi singleton GuiControlProfile(AssetBrowserPreviewShapeAnimationAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "0 0 200 255"; @@ -37,7 +40,8 @@ singleton GuiControlProfile(AssetBrowserPreviewShapeAnimationAsset : ToolsGuiDef singleton GuiControlProfile(AssetBrowserPreviewSoundAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "75 101 135 255"; @@ -46,7 +50,8 @@ singleton GuiControlProfile(AssetBrowserPreviewSoundAsset : ToolsGuiDefaultProfi singleton GuiControlProfile(AssetBrowserPreviewTerrainAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "200 198 198 255"; @@ -55,7 +60,8 @@ singleton GuiControlProfile(AssetBrowserPreviewTerrainAsset : ToolsGuiDefaultPro singleton GuiControlProfile(AssetBrowserPreviewTerrainMaterialAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "200 198 198 255"; @@ -64,7 +70,8 @@ singleton GuiControlProfile(AssetBrowserPreviewTerrainMaterialAsset : ToolsGuiDe singleton GuiControlProfile(AssetBrowserPreviewStateMachineAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "0 76 135 255"; @@ -73,7 +80,8 @@ singleton GuiControlProfile(AssetBrowserPreviewStateMachineAsset : ToolsGuiDefau singleton GuiControlProfile(AssetBrowserPreviewGUIAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "17 5 44 255"; @@ -82,7 +90,8 @@ singleton GuiControlProfile(AssetBrowserPreviewGUIAsset : ToolsGuiDefaultProfile singleton GuiControlProfile(AssetBrowserPreviewLevelAsset : ToolsGuiDefaultProfile) { - fillColor = "128 128 128 255"; //hovered/selected + fillcolor = EditorSettings.value("Theme/windowBackgroundColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); border = true; borderColor = "0 208 186 255"; diff --git a/Templates/BaseGame/game/tools/gui/profiles.ed.tscript b/Templates/BaseGame/game/tools/gui/profiles.ed.tscript index 65d068e8a..478c15ce7 100644 --- a/Templates/BaseGame/game/tools/gui/profiles.ed.tscript +++ b/Templates/BaseGame/game/tools/gui/profiles.ed.tscript @@ -285,6 +285,12 @@ new GuiControlProfile( ToolsGuiTextArrayProfile : ToolsGuiTextProfile ) if( !isObject( ToolsGuiTextListProfile ) ) new GuiControlProfile( ToolsGuiTextListProfile : ToolsGuiTextProfile ) { + fontColor = EditorSettings.value("Theme/fieldTextColor"); + fontColorHL = EditorSettings.value("Theme/fieldTextHLColor"); + fontColorSEL = EditorSettings.value("Theme/fieldTextSELColor"); + fillColor = EditorSettings.value("Theme/fieldBGColor"); + fillColorHL = EditorSettings.value("Theme/fieldBGHLColor"); + fillColorSEL = EditorSettings.value("Theme/fieldBGSELColor"); tab = true; canKeyFocus = true; category = "Tools"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainImportGui.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainImportGui.gui index ae0342a2a..3576e8734 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainImportGui.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainImportGui.gui @@ -586,7 +586,7 @@ function TerrainImportGuiAddOpacityMap( %name ) // once per channel in the file // currently it works with just grayscale. %channelsTxt = "R" TAB "G" TAB "B" TAB "A"; - %bitmapInfo = getBitmapinfo( %name ); + %bitmapInfo = getBitmapinfo( makeFullPath(%name) ); %channelCount = getWord( %bitmapInfo, 2 ); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/menus.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/menus.ed.tscript index 48cb8c5d5..0fd609019 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/menus.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/menus.ed.tscript @@ -158,7 +158,7 @@ function EditorGui::buildMenus(%this) //%fileMenu.appendItem("Create Blank Terrain" TAB "" TAB "Canvas.pushDialog( CreateNewTerrainGui );"); %fileMenu.appendItem("Create Blank Terrain" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"TerrainAsset\", AssetBrowser.selectedModule, createTerrainBlock);"); - %fileMenu.appendItem("Import Terrain Heightmap" TAB "" TAB "Canvas.pushDialog( TerrainImportGui );"); + %fileMenu.appendItem("Import Terrain Heightmap" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"TerrainAsset\", AssetBrowser.selectedModule, createTerrainBlock); Canvas.pushDialog( TerrainImportGui );"); %fileMenu.appendItem("Export Terrain Heightmap" TAB "" TAB "Canvas.pushDialog( TerrainExportGui );"); %fileMenu.appendItem("-");