Przeglądaj źródła

Dynamic Asset Response

When you make changes to an Asset in the Asset Manager, they are now dynamically displayed by updating the image above.
Peter Robinson 4 lat temu
rodzic
commit
d66de34e0b

+ 17 - 5
editor/AssetAdmin/AssetAdmin.cs

@@ -33,6 +33,8 @@ function AssetAdmin::create(%this)
 	%this.guiPage.add(%this.buildInspector());
 
 	EditorCore.FinishRegistration(%this.guiPage);
+
+	%this.isOpen = false;
 }
 
 function AssetAdmin::buildLibrary(%this)
@@ -57,8 +59,8 @@ function AssetAdmin::buildLibrary(%this)
 
 	%this.dictionaryList = new GuiChainCtrl()
 	{
-		HorizSizing="bottom";
-		VertSizing="right";
+		HorizSizing="right";
+		VertSizing="bottom";
 		Position="0 0";
 		Extent="310 768";
 		MinExtent="220 200";
@@ -79,8 +81,8 @@ function AssetAdmin::buildDictionary(%this, %title, %type)
 		Class = AssetDictionary;
 		Text=%title;
 		command="";
-		HorizSizing="bottom";
-		VertSizing="right";
+		HorizSizing="right";
+		VertSizing="bottom";
 		Position="0 0";
 		Extent="310 22";
 		MinExtent="80 22";
@@ -121,7 +123,7 @@ function AssetAdmin::buildAssetWindow(%this)
 		extent = "700 444";
 		HorizSizing="width";
 		VertSizing="height";
-		minExtent = "175 111";
+		minExtent = "0 0";
 		cameraPosition = "0 0";
 		cameraSize = "175 111";
 		useWindowInputEvents = false;
@@ -143,6 +145,7 @@ function AssetAdmin::open(%this)
 	%this.Dictionary["AnimationAsset"].load();
 
 	%this.assetScene.setScenePause(false);
+	%this.isOpen = true;
 }
 
 function AssetAdmin::close(%this)
@@ -151,4 +154,13 @@ function AssetAdmin::close(%this)
 	%this.Dictionary["AnimationAsset"].unload();
 
 	%this.assetScene.setScenePause(true);
+	%this.isOpen = false;
+}
+
+function AssetBase::onRefresh(%this)
+{
+	if(AssetAdmin.isOpen  && isObject(AssetAdmin.chosenButton))
+	{
+		AssetAdmin.chosenButton.onClick();
+	}
 }

+ 2 - 0
editor/AssetAdmin/AssetDictionaryButton.cs

@@ -92,6 +92,8 @@ function AssetDictionaryButton::onClick(%this)
 		AssetAdmin.AssetWindow.displayImageAsset(%this.ImageAsset, %this.ImageAssetID);
 		AssetAdmin.inspector.loadImageAsset(%this.ImageAsset, %this.ImageAssetID);
 	}
+
+	AssetAdmin.chosenButton = %this;
 }
 
 function AssetDictionaryButton::onRemove(%this)

+ 5 - 0
editor/AssetAdmin/AssetWindow.cs

@@ -152,4 +152,9 @@ function AssetWindow::onExtentChange(%this, %d)
 	}
 	%area = %topLeft SPC %bottomRight;
 	%this.setCameraArea(%area);
+
+	if(isObject(AssetAdmin.chosenButton))
+	{
+		AssetAdmin.chosenButton.onClick();
+	}
 }

+ 1 - 1
engine/source/2d/assets/ImageAsset.cc

@@ -196,7 +196,7 @@ void ImageAsset::initPersistFields()
 
     // Fields.
     addProtectedField("ImageFile", TypeAssetLooseFilePath, Offset(mImageFile, ImageAsset), &setImageFile, &getImageFile, &defaultProtectedWriteFn, "");
-    addProtectedField("Force16bit", TypeBool, Offset(mForce16Bit, ImageAsset), &setForce16Bit, &defaultProtectedGetFn, &writeForce16Bit, "");
+    addProtectedField("Force16bit", TypeBool, Offset(mForce16Bit, ImageAsset), &setForce16Bit, &defaultProtectedGetFn, &writeForce16Bit, "Forces the image into 16 bit mode.");
     addProtectedField("FilterMode", TypeEnum, Offset(mLocalFilterMode, ImageAsset), &setFilterMode, &defaultProtectedGetFn, &writeFilterMode, 1, &textureFilterTable);   
     addProtectedField("ExplicitMode", TypeBool, Offset(mExplicitMode, ImageAsset), &setExplicitMode, &defaultProtectedGetFn, &writeExplicitMode, "");
 

+ 6 - 0
engine/source/assets/assetBase.cc

@@ -276,6 +276,12 @@ void AssetBase::refreshAsset( void )
 
     // Yes, so refresh the asset via the asset manager.
     mpOwningAssetManager->refreshAsset( getAssetId() );
+
+	//Inform those who want to know
+	if (isMethod("onRefresh"))
+	{
+		Con::executef(this, 1, "onRefresh");
+	}
 }
 
 //-----------------------------------------------------------------------------

+ 1 - 1
engine/source/gui/editor/guiInspector.cc

@@ -576,7 +576,7 @@ bool GuiInspectorField::onAdd()
 	mBounds.extent.y = outerExt.y;
 
 	//Set the tool tip if possible
-	if (mField->pFieldDocs != NULL)
+	if (mField != NULL && mField->pFieldDocs != NULL)
 	{
 		mEdit->setField("tooltip", mField->pFieldDocs);
 		if (mGroup->mInspector->mTooltipProfile != NULL)