Browse Source

Asset Admin - View Assets

You can now veiw Image and Animation Assets. Also fixed a bug with the SceneWindow drawing to the entire content of its parent control.
Peter Robinson 4 years ago
parent
commit
abc1ad63ec

+ 81 - 31
editor/AssetAdmin/AssetAdmin.cs

@@ -23,30 +23,38 @@
 function AssetAdmin::create(%this)
 function AssetAdmin::create(%this)
 {
 {
 	exec("./AssetDictionary.cs");
 	exec("./AssetDictionary.cs");
+	exec("./AssetWindow.cs");
+	exec("./AssetDictionaryButton.cs");
 
 
 	%this.guiPage = EditorCore.RegisterEditor("Asset Manager", %this);
 	%this.guiPage = EditorCore.RegisterEditor("Asset Manager", %this);
+	%this.guiPage.add(%this.buildAssetWindow());
+	%this.guiPage.add(%this.buildLibrary());
+	%this.guiPage.add(%this.buildInspector());
 
 
-	%this.scroller = new GuiScrollCtrl()
+	EditorCore.FinishRegistration(%this.guiPage);
+}
+
+function AssetAdmin::buildLibrary(%this)
+{
+	%this.libScroller = new GuiScrollCtrl()
 	{
 	{
 		HorizSizing="left";
 		HorizSizing="left";
 		VertSizing="height";
 		VertSizing="height";
 		Position="700 0";
 		Position="700 0";
 		Extent="324 768";
 		Extent="324 768";
-		MinExtent="220 200";
+		MinExtent="162 384";
 		hScrollBar="dynamic";
 		hScrollBar="dynamic";
 		vScrollBar="alwaysOn";
 		vScrollBar="alwaysOn";
 		constantThumbHeight="0";
 		constantThumbHeight="0";
 		showArrowButtons="1";
 		showArrowButtons="1";
 		scrollBarThickness="14";
 		scrollBarThickness="14";
 	};
 	};
-	ThemeManager.setProfile(%this.scroller, "scrollingPanelProfile");
-	ThemeManager.setProfile(%this.scroller, "scrollingPanelThumbProfile", ThumbProfile);
-	ThemeManager.setProfile(%this.scroller, "scrollingPanelTrackProfile", TrackProfile);
-	ThemeManager.setProfile(%this.scroller, "scrollingPanelArrowProfile", ArrowProfile);
+	ThemeManager.setProfile(%this.libScroller, "scrollingPanelProfile");
+	ThemeManager.setProfile(%this.libScroller, "scrollingPanelThumbProfile", ThumbProfile);
+	ThemeManager.setProfile(%this.libScroller, "scrollingPanelTrackProfile", TrackProfile);
+	ThemeManager.setProfile(%this.libScroller, "scrollingPanelArrowProfile", ArrowProfile);
 
 
-	%this.guiPage.add(%this.scroller);
-
-	%this.dictionaryContainer = new GuiChainCtrl()
+	%this.dictionaryList = new GuiChainCtrl()
 	{
 	{
 		HorizSizing="bottom";
 		HorizSizing="bottom";
 		VertSizing="right";
 		VertSizing="right";
@@ -54,42 +62,80 @@ function AssetAdmin::create(%this)
 		Extent="310 768";
 		Extent="310 768";
 		MinExtent="220 200";
 		MinExtent="220 200";
 	};
 	};
-	ThemeManager.setProfile(%this.dictionaryContainer, "emptyProfile");
-	%this.scroller.add(%this.dictionaryContainer);
+	ThemeManager.setProfile(%this.dictionaryList, "emptyProfile");
+	%this.libScroller.add(%this.dictionaryList);
+
+	%this.dictionaryList.add(%this.buildDictionary("Images", "ImageAsset"));
+	%this.dictionaryList.add(%this.buildDictionary("Animations", "AnimationAsset"));
+
+	return %this.libScroller;
+}
 
 
-	%this.Dictionary["ImageAsset"] = new GuiPanelCtrl()
+function AssetAdmin::buildDictionary(%this, %title, %type)
+{
+	%this.Dictionary[%type] = new GuiPanelCtrl()
 	{
 	{
 		Class = AssetDictionary;
 		Class = AssetDictionary;
-		Text="Image Assets";
+		Text=%title;
 		command="";
 		command="";
 		HorizSizing="bottom";
 		HorizSizing="bottom";
 		VertSizing="right";
 		VertSizing="right";
 		Position="0 0";
 		Position="0 0";
 		Extent="310 22";
 		Extent="310 22";
 		MinExtent="80 22";
 		MinExtent="80 22";
-		Type = "ImageAsset";
+		Type = %type;
 	};
 	};
-	%this.Dictionary["ImageAsset"].setExpandEase("EaseOutBounce", 1500);
-	ThemeManager.setProfile(%this.Dictionary["ImageAsset"], "panelProfile");
-	%this.dictionaryContainer.add(%this.Dictionary["ImageAsset"]);
+	%this.Dictionary[%type].setExpandEase("EaseInOut", 1000);
+	ThemeManager.setProfile(%this.Dictionary[%type], "panelProfile");
+
+	return %this.Dictionary[%type];
+}
 
 
-	%this.Dictionary["AnimationAsset"] = new GuiPanelCtrl()
+function AssetAdmin::buildInspector(%this)
+{
+	%this.insScroller = new GuiScrollCtrl()
 	{
 	{
-		Class = AssetDictionary;
-		Text="Animation Assets";
-		command="";
-		HorizSizing="bottom";
-		VertSizing="right";
-		Position="0 0";
-		Extent="310 22";
-		MinExtent="80 22";
-		Type = "AnimationAsset";
+		HorizSizing="width";
+		VertSizing="top";
+		Position="0 444";
+		Extent="700 324";
+		MinExtent="350 222";
+		hScrollBar="alwaysOn";
+		vScrollBar="alwaysOn";
+		constantThumbHeight="0";
+		showArrowButtons="1";
+		scrollBarThickness="14";
 	};
 	};
-	%this.Dictionary["AnimationAsset"].setExpandEase("EaseOutBounce", 1500);
-	ThemeManager.setProfile(%this.Dictionary["AnimationAsset"], "panelProfile");
-	%this.dictionaryContainer.add(%this.Dictionary["AnimationAsset"]);
+	ThemeManager.setProfile(%this.insScroller, "scrollingPanelProfile");
+	ThemeManager.setProfile(%this.insScroller, "scrollingPanelThumbProfile", ThumbProfile);
+	ThemeManager.setProfile(%this.insScroller, "scrollingPanelTrackProfile", TrackProfile);
+	ThemeManager.setProfile(%this.insScroller, "scrollingPanelArrowProfile", ArrowProfile);
 
 
-	EditorCore.FinishRegistration(%this.guiPage);
+	return %this.insScroller;
+}
+
+function AssetAdmin::buildAssetWindow(%this)
+{
+	%this.assetScene = new Scene();
+	%this.assetScene.setScenePause(true);
+
+	%this.assetWindow = new SceneWindow()
+	{
+		class = AssetWindow;
+		profile = ThemeManager.activeTheme.overlayProfile;
+		position = "0 0";
+		extent = "700 444";
+		HorizSizing="width";
+		VertSizing="height";
+		minExtent = "175 111";
+		cameraPosition = "0 0";
+		cameraSize = "175 111";
+		useWindowInputEvents = false;
+		useObjectInputEvents = true;
+	};
+	%this.assetWindow.setScene(%this.assetScene);
+
+	return %this.assetWindow;
 }
 }
 
 
 function AssetAdmin::destroy(%this)
 function AssetAdmin::destroy(%this)
@@ -101,10 +147,14 @@ function AssetAdmin::open(%this)
 {
 {
 	%this.Dictionary["ImageAsset"].load();
 	%this.Dictionary["ImageAsset"].load();
 	%this.Dictionary["AnimationAsset"].load();
 	%this.Dictionary["AnimationAsset"].load();
+
+	%this.assetScene.setScenePause(false);
 }
 }
 
 
 function AssetAdmin::close(%this)
 function AssetAdmin::close(%this)
 {
 {
 	%this.Dictionary["ImageAsset"].unload();
 	%this.Dictionary["ImageAsset"].unload();
 	%this.Dictionary["AnimationAsset"].unload();
 	%this.Dictionary["AnimationAsset"].unload();
+
+	%this.assetScene.setScenePause(true);
 }
 }

+ 17 - 61
editor/AssetAdmin/AssetDictionary.cs

@@ -54,58 +54,14 @@ function AssetDictionary::load(%this)
 				Class = AssetDictionaryButton;
 				Class = AssetDictionaryButton;
 				HorizSizing="center";
 				HorizSizing="center";
 				VertSizing="center";
 				VertSizing="center";
-				Cmd = "OpenAsset";
 				Tooltip = AssetDatabase.getAssetName(%assetID);
 				Tooltip = AssetDatabase.getAssetName(%assetID);
 				Text = "";
 				Text = "";
+				AssetID = %assetID;
+				Type = %this.Type;
 			};
 			};
 			ThemeManager.setProfile(%button, "buttonProfile");
 			ThemeManager.setProfile(%button, "buttonProfile");
 			ThemeManager.setProfile(%button, "tipProfile", "TooltipProfile");
 			ThemeManager.setProfile(%button, "tipProfile", "TooltipProfile");
 			%this.grid.add(%button);
 			%this.grid.add(%button);
-
-			if(%this.Type $= "ImageAsset" || %this.Type $= "AnimationAsset")
-			{
-				if(%this.Type $= "ImageAsset")
-				{
-					%imageAsset = AssetDatabase.acquireAsset(%assetID);
-				}
-				else if(%this.Type $= "AnimationAsset")
-				{
-					%animationAsset = AssetDatabase.acquireAsset(%assetID);
-					%imageAsset = AssetDatabase.acquireAsset(%animationAsset.getImage());
-				}
-				%size = %imageAsset.getFrameSize(0);
-				%x = getWord(%size, 0);
-				%y = getWord(%size, 1);
-				%ratio = %x / %y;
-				%extent = "50 50";
-				if(%x > %y)
-				{
-					%extent = "50" SPC (50/%ratio);
-				}
-				else if(%x < %y)
-				{
-					%extent = (50*%ratio) SPC "50";
-				}
-				%texture = new GuiSpriteCtrl()
-				{
-					HorizSizing="center";
-					VertSizing="center";
-					Extent = %extent;
-					minExtent=%extent;
-					Position = "0 0";
-				};
-				ThemeManager.setProfile(%texture, "spriteProfile");
-				if(%this.Type $= "ImageAsset")
-				{
-					%texture.setImage(%assetID);
-				}
-				else if(%this.Type $= "AnimationAsset")
-				{
-					%texture.setAnimation(%assetID);
-					AssetDatabase.releaseAsset(%animationAsset.getImage());
-				}
-				%button.add(%texture);
-			}
 		}
 		}
 	}
 	}
 	%query.delete();
 	%query.delete();
@@ -121,27 +77,27 @@ function AssetDictionary::unload(%this)
 	}
 	}
 
 
 	//release all the assets we loaded for this - might take them out of memory
 	//release all the assets we loaded for this - might take them out of memory
-	%query = new AssetQuery();
-	AssetDatabase.findAllAssets(%query);
-	AssetDatabase.findAssetType(%query, %this.Type, true);
-
-	for(%i = 0; %i < %query.getCount(); %i++)
-	{
-		%assetID = %query.getAsset(%i);
-		if(!AssetDatabase.isAssetInternal(%assetID))
-		{
-			AssetDatabase.releaseAsset(%assetID);
-		}
-	}
-	%query.delete();
+	// %query = new AssetQuery();
+	// AssetDatabase.findAllAssets(%query);
+	// AssetDatabase.findAssetType(%query, %this.Type, true);
+	//
+	// for(%i = 0; %i < %query.getCount(); %i++)
+	// {
+	// 	%assetID = %query.getAsset(%i);
+	// 	if(!AssetDatabase.isAssetInternal(%assetID))
+	// 	{
+	// 		AssetDatabase.releaseAsset(%assetID);
+	// 	}
+	// }
+	// %query.delete();
 }
 }
 
 
-function GuiSpriteCtrl::onAnimationEnd(%this, %animationAssetID)
+function AssetDictionarySprite::onAnimationEnd(%this, %animationAssetID)
 {
 {
 	%this.schedule(2000, "restartAnimation", %animationAssetID);
 	%this.schedule(2000, "restartAnimation", %animationAssetID);
 }
 }
 
 
-function GuiSpriteCtrl::restartAnimation(%this, %animationAssetID)
+function AssetDictionarySprite::restartAnimation(%this, %animationAssetID)
 {
 {
 	%this.setAnimation(%animationAssetID);
 	%this.setAnimation(%animationAssetID);
 }
 }

+ 115 - 0
editor/AssetAdmin/AssetDictionaryButton.cs

@@ -0,0 +1,115 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+function AssetDictionaryButton::onAdd(%this)
+{
+	%this.call("load" @ %this.type, %this.assetID);
+	%this.assetID = "";
+}
+
+function AssetDictionaryButton::loadImageAsset(%this, %assetID)
+{
+	%imageAsset = AssetDatabase.acquireAsset(%assetID);
+
+	%extent = %this.getIconExtent(%imageAsset.getFrameSize(0));
+	%texture = %this.buildIcon(%extent);
+	%texture.setImage(%assetID);
+
+	%this.ImageAsset = %imageAsset;
+	%this.ImageAssetID = %assetID;
+
+	%this.add(%texture);
+}
+
+function AssetDictionaryButton::loadAnimationAsset(%this, %assetID)
+{
+	%animationAsset = AssetDatabase.acquireAsset(%assetID);
+	%imageAssetID = %animationAsset.getImage();
+	%imageAsset = AssetDatabase.acquireAsset(%imageAssetID);
+
+	%extent = %this.getIconExtent(%imageAsset.getFrameSize(0));
+	%texture = %this.buildIcon(%extent);
+	%texture.setAnimation(%assetID);
+
+	%this.ImageAsset = %imageAsset;
+	%this.imageAssetID = %imageAssetID;
+	%this.AnimationAsset = %animationAsset;
+	%this.AnimationAssetID = %assetID;
+
+	%this.add(%texture);
+}
+
+function AssetDictionaryButton::getIconExtent(%this, %size)
+{
+	%x = getWord(%size, 0);
+	%y = getWord(%size, 1);
+	%ratio = %x / %y;
+	%extent = "50 50";
+	if(%x > %y)
+	{
+		%extent = "50" SPC (50/%ratio);
+	}
+	else if(%x < %y)
+	{
+		%extent = (50*%ratio) SPC "50";
+	}
+	return %extent;
+}
+
+function AssetDictionaryButton::buildIcon(%this, %extent)
+{
+	%texture = new GuiSpriteCtrl()
+	{
+		class = "AssetDictionarySprite";
+		HorizSizing="center";
+		VertSizing="center";
+		Extent = %extent;
+		minExtent=%extent;
+		Position = "0 0";
+	};
+	ThemeManager.setProfile(%texture, "spriteProfile");
+	return %texture;
+}
+
+function AssetDictionaryButton::onClick(%this)
+{
+	if(isObject(%this.AnimationAsset) && %this.AnimationAssetID !$= "")
+	{
+		AssetAdmin.AssetWindow.displayAnimationAsset(%this.imageAsset, %this.AnimationAsset, %this.AnimationAssetID);
+	}
+	else if(isObject(%this.ImageAsset) && %this.ImageAssetID !$= "")
+	{
+		AssetAdmin.AssetWindow.displayImageAsset(%this.ImageAsset, %this.ImageAssetID);
+	}
+}
+
+function AssetDictionaryButton::onRemove(%this)
+{
+	if(isObject(%this.ImageAsset))
+	{
+		AssetDatabase.releaseAsset(%this.ImageAssetID);
+	}
+	if(isObject(%this.AnimationAsset))
+	{
+		AssetDatabase.releaseAsset(%this.AnimationAssetID);
+	}
+}

+ 155 - 0
editor/AssetAdmin/AssetWindow.cs

@@ -0,0 +1,155 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+function AssetWindow::onAdd(%this)
+{
+
+}
+
+function AssetWindow::displayImageAsset(%this, %imageAsset, %assetID)
+{
+	AssetAdmin.AssetScene.clear(true);
+
+	if(!%imageAsset.getExplicitMode() && %imageAsset.getFrameCount() == 1)
+	{
+		%size = %this.getWorldSize(%imageAsset.getFrameSize(0));
+		new Sprite()
+		{
+			Scene = AssetAdmin.AssetScene;
+			Image = %assetID;
+			size = %size;
+			BlandColor = "1 1 1 1";
+			SceneLayer = 1;
+			Position = "0 0";
+			BodyType = static;
+		};
+	}
+	else if(!%imageAsset.getExplicitMode() && %imageAsset.getFrameCount() > 1)
+	{
+		%cellCountX = %imageAsset.getCellCountX();
+		%cellCountY = %imageAsset.getCellCountY();
+
+		%cellWidth = %imageAsset.getCellWidth();
+		%cellHeight = %imageAsset.getCellHeight();
+
+		%imageSizeX = %cellWidth * %cellCountX;
+		%imageSizeY = %cellHeight * %cellCountY;
+
+		%size = %this.getWorldSize(%imageSizeX SPC %imageSizeY);
+		%sizeX = getWord(%size, 0);
+		%sizeY = getWord(%size, 1);
+
+		%worldCellWidth = %sizeX / %cellCountX;
+		%worldCellHeight = %sizeY / %cellCountY;
+
+		for(%j = 0; %j < %cellCountY; %j++)
+		{
+			for(%i = 0; %i < %cellCountX; %i++)
+			{
+				%sprite = new Sprite()
+				{
+					Scene = AssetAdmin.AssetScene;
+					Image = %assetID;
+					Frame = (%j * %imageAsset.getCellCountX()) + %i;
+					size = Vector2Scale(%worldCellWidth SPC %worldCellHeight, 2.8);
+					position = ((%worldCellWidth * %i) + (%worldCellWidth/2) - (%sizeX/2)) SPC ((-%worldCellHeight * %j) - (%worldCellHeight/2) + (%sizeY/2));
+					BlendColor = "1 1 1 0";
+					SceneLayer = 1;
+					BodyType = static;
+				};
+
+				%sprite.growToTime(Vector2Scale(%worldCellWidth SPC %worldCellHeight, 0.94), 225 + (%i * 20));
+				%sprite.fadetoTime("1 1 1 1", 225 + (%i * 20));
+			}
+		}
+	}
+}
+
+function AssetWindow::displayAnimationAsset(%this, %imageAsset, %animationAsset, %assetID)
+{
+	AssetAdmin.AssetScene.clear(true);
+
+	%size = %this.getWorldSize(%imageAsset.getFrameSize(0));
+	new Sprite()
+	{
+		Scene = AssetAdmin.AssetScene;
+		Animation = %assetID;
+		size = %size;
+		BlandColor = "1 1 1 1";
+		SceneLayer = 1;
+		Position = "0 0";
+		BodyType = static;
+	};
+}
+
+function AssetWindow::getWorldSize(%this, %size)
+{
+	%cameraSize = %this.getCameraSize();
+	%cameraX = getWord(%cameraSize, 0);
+	%cameraY = getWord(%cameraSize, 1);
+
+	%x = getWord(%size, 0);
+	%y = getWord(%size, 1);
+
+	%inset = 10;
+
+	//calculate the finished rect 2 ways
+	%finX1 = %cameraX - %inset;
+	%finY1 = (%y * %finX1) / %x;
+
+	%finY2 = %cameraY - %inset;
+	%finX2 = (%x * %finY2) / %y;
+
+	//Return 1 if it's bigger and fits or if it's smaller and 2 doesn't fit
+	if((%finX1 > %finX2 && %finX1 <= (%cameraX - %inset) && %finY1 <= (%cameraY - %inset)) || (%finX1 < %finX2 && (%finX2 > (%cameraX - %inset) || %finY2 > (%cameraY - %inset))))
+	{
+		return %finX1 SPC %finY1;
+	}
+	else
+	{
+		//otherwise use the second finished rect
+		return %finX2 SPC %finY2;
+	}
+}
+
+function AssetWindow::onExtentChange(%this, %d)
+{
+	%x = getWord(%d, 2);
+	%y = getWord(%d, 3);
+
+	if(%x >= %y)
+	{
+		%mult = 100/%x;
+		%areaY =  (%y * %mult);
+		%topLeft = "-50" SPC (%areaY / 2);
+		%bottomRight = "50" SPC -(%areaY / 2);
+	}
+	else
+	{
+		%mult = 100/%y;
+		%areaX =  (%x * %mult);
+		%topLeft = (%areaX / 2) SPC "-50";
+		%bottomRight = -(%areaX / 2) SPC "50";
+	}
+	%area = %topLeft SPC %bottomRight;
+	%this.setCameraArea(%area);
+}

+ 13 - 4
editor/EditorCore/Themes/ThemeManager.cs

@@ -85,12 +85,21 @@ function ThemeManager::refreshProfiles(%this)
 	{
 	{
 		%obj = %this.controlList.getObject(%i);
 		%obj = %this.controlList.getObject(%i);
 
 
-		if(!isObject(%this.activeTheme.getFieldValue(%obj.profileName)))
+		if(isObject(%obj.gui))
 		{
 		{
-			error("ThemeManager::setProfile - Unable to find profile" SPC %obj.profileName SPC "for theme" SPC %this.activeTheme.name @ "!");
-		}
+			if(!isObject(%this.activeTheme.getFieldValue(%obj.profileName)))
+			{
+				error("ThemeManager::setProfile - Unable to find profile" SPC %obj.profileName SPC "for theme" SPC %this.activeTheme.name @ "!");
+			}
 
 
-		%obj.gui.setFieldValue(%obj.profileTag, %this.activeTheme.getFieldValue(%obj.profileName));
+			%obj.gui.setFieldValue(%obj.profileTag, %this.activeTheme.getFieldValue(%obj.profileName));
+		}
+		else
+		{
+			//let's remove this corpse
+			%this.controlList.remove(%obj);
+			%this.i--;
+		}
 	}
 	}
 }
 }
 
 

+ 9 - 0
engine/source/2d/gui/SceneWindow.cc

@@ -1606,6 +1606,12 @@ void SceneWindow::onRender( Point2I offset, const RectI& updateRect )
     // Debug Profiling.
     // Debug Profiling.
     PROFILE_SCOPE(SceneWindow_onRender);
     PROFILE_SCOPE(SceneWindow_onRender);
 
 
+	//save the old clip
+	RectI oldClipRect = dglGetClipRect();
+
+	//clip to the updateRect
+	dglSetClipRect(updateRect);
+
     // Fetch scene.
     // Fetch scene.
     Scene* pScene = getScene();
     Scene* pScene = getScene();
 
 
@@ -1724,6 +1730,9 @@ void SceneWindow::onRender( Point2I offset, const RectI& updateRect )
 
 
     // Update Window.
     // Update Window.
     setUpdate();
     setUpdate();
+
+	//return the clip rect
+	dglSetClipRect(oldClipRect);
 }
 }
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------