Browse Source

Display Explicitly Defined Image Frames

The Asset Manager can now display images with frames that are explicitly defined. This includes a small fix to GUI rendering and a new header for one of the themes.
Peter Robinson 4 years ago
parent
commit
038ad723ca

+ 35 - 12
editor/AssetAdmin/AssetWindow.cs

@@ -31,9 +31,12 @@ function AssetWindow::displayImageAsset(%this, %imageAsset, %assetID)
 
 
 	%this.setCameraPosition("0 0");
 	%this.setCameraPosition("0 0");
 	%this.setCameraZoom(1);
 	%this.setCameraZoom(1);
+	%size = %this.getWorldSize(%imageAsset.getImageSize());
+	%sizeX = getWord(%size, 0);
+	%sizeY = getWord(%size, 1);
+
 	if(!%imageAsset.getExplicitMode() && %imageAsset.getFrameCount() == 1)
 	if(!%imageAsset.getExplicitMode() && %imageAsset.getFrameCount() == 1)
 	{
 	{
-		%size = %this.getWorldSize(%imageAsset.getFrameSize(0));
 		new Sprite()
 		new Sprite()
 		{
 		{
 			Scene = AssetAdmin.AssetScene;
 			Scene = AssetAdmin.AssetScene;
@@ -50,16 +53,6 @@ function AssetWindow::displayImageAsset(%this, %imageAsset, %assetID)
 		%cellCountX = %imageAsset.getCellCountX();
 		%cellCountX = %imageAsset.getCellCountX();
 		%cellCountY = %imageAsset.getCellCountY();
 		%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;
 		%worldCellWidth = %sizeX / %cellCountX;
 		%worldCellHeight = %sizeY / %cellCountY;
 		%worldCellHeight = %sizeY / %cellCountY;
 
 
@@ -71,7 +64,7 @@ function AssetWindow::displayImageAsset(%this, %imageAsset, %assetID)
 				{
 				{
 					Scene = AssetAdmin.AssetScene;
 					Scene = AssetAdmin.AssetScene;
 					Image = %assetID;
 					Image = %assetID;
-					Frame = (%j * %imageAsset.getCellCountX()) + %i;
+					Frame = (%j * %cellCountX) + %i;
 					size = Vector2Scale(%worldCellWidth SPC %worldCellHeight, 2.8);
 					size = Vector2Scale(%worldCellWidth SPC %worldCellHeight, 2.8);
 					position = ((%worldCellWidth * %i) + (%worldCellWidth/2) - (%sizeX/2)) SPC ((-%worldCellHeight * %j) - (%worldCellHeight/2) + (%sizeY/2));
 					position = ((%worldCellWidth * %i) + (%worldCellWidth/2) - (%sizeX/2)) SPC ((-%worldCellHeight * %j) - (%worldCellHeight/2) + (%sizeY/2));
 					BlendColor = "1 1 1 0";
 					BlendColor = "1 1 1 0";
@@ -84,6 +77,36 @@ function AssetWindow::displayImageAsset(%this, %imageAsset, %assetID)
 			}
 			}
 		}
 		}
 	}
 	}
+	else if(%imageAsset.getExplicitMode())
+	{
+		for(%i = 0; %i < %imageAsset.getExplicitCellCount(); %i++)
+		{
+			%worldCellWidth = %sizeX * (%imageAsset.getExplicitCellWidth(%i) / %imageAsset.getImageWidth());
+			%worldCellHeight = %sizeY * (%imageAsset.getExplicitCellHeight(%i) / %imageAsset.getImageHeight());
+
+			%offset = %imageAsset.getExplicitCellOffset(%i);
+			%offsetX = getWord(%offset, 0);
+			%offsetY = getWord(%offset, 1);
+
+			%worldCellOffsetX = (%sizeX * (%offsetX / %imageAsset.getImageWidth())) - (%sizeX / 2) + (%worldCellWidth / 2);
+			%worldCellOffsetY = (%sizeY - (%sizeY * (%offsetY / %imageAsset.getImageHeight()))) - (%sizeY / 2) - (%worldCellHeight / 2);
+
+			%sprite = new Sprite()
+			{
+				Scene = AssetAdmin.AssetScene;
+				Image = %assetID;
+				Frame = %i;
+				size = Vector2Scale(%worldCellWidth SPC %worldCellHeight, 2.8);
+				position = %worldCellOffsetX SPC %worldCellOffsetY;
+				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)
 function AssetWindow::displayAnimationAsset(%this, %imageAsset, %animationAsset, %assetID)

+ 105 - 0
editor/EditorCore/Themes/LabCoat/LabCoatTheme.cs

@@ -17,3 +17,108 @@ function LabCoatTheme::init(%this)
 
 
 	%this.borderSize = 2;
 	%this.borderSize = 2;
 }
 }
+
+function LabCoatTheme::makePanelProfile(%this)
+{
+	%panelBorderH = new GuiBorderProfile()
+	{
+		padding = 10;
+		paddingHL = 10;
+		paddingSL = 10;
+		paddingNA = 10;
+	};
+
+	%panelBorderV = new GuiBorderProfile()
+	{
+		border = 1;
+		borderHL = 1;
+		borderSL = 1;
+		borderNA = 1;
+
+		borderColor = %this.adjustValue(%this.color3, -50);
+		borderColorHL = %this.adjustValue(%this.color3, -60);
+		borderColorSL = %this.adjustValue(%this.color3, -60);
+		borderColorNA = %this.adjustValue(%this.color3, -50);
+	};
+
+	%this.panelProfile = new GuiControlProfile()
+	{
+		fillColor = %this.color2;
+		fillColorHL = %this.adjustValue(%this.color2, 5);
+		fillColorSL = %this.adjustValue(%this.color2, 5);
+		fillColorNA = %this.setAlpha(%this.color2, 80);
+
+		fontType = %this.font[2];
+		fontDirectory = %this.fontDirectory;
+		fontSize = %this.fontSize - 1;
+		fontColor = %this.color5;
+		fontColorHL = %this.adjustValue(%this.color5, 10);
+		fontColorSL = %this.adjustValue(%this.color5, 20);
+		fontColorNA = %this.setAlpha(%this.color4, 100);
+		align = left;
+		vAlign = middle;
+
+		imageAsset="EditorCore:labCoatBanner1";
+
+		borderDefault = %panelBorderH;
+		borderTop = %panelBorderV;
+		borderBottom = %panelBorderV;
+	};
+
+	//Scrolling panel - a less space demanding scroll bar.
+	%this.scrollingPanelTrackProfile = new GuiControlProfile()
+	{
+		fillColor = %this.color2;
+		fillColorHL = %this.color2;
+		fillColorSL = %this.color2;
+		fillColorNA = %this.setAlpha(%this.color2, 50);
+	};
+
+	%thumbBorder = new GuiBorderProfile()
+	{
+		margin = 3;
+		marginHL = 3;
+		marginSL = 3;
+		paddingNA = 3;
+	};
+
+	%this.scrollingPanelThumbProfile = new GuiControlProfile()
+	{
+		fillColor = %this.color3;
+		fillColorHL = %this.adjustValue(%this.color3, 10);
+		fillColorSL = %this.color5;
+		fillColorNA = %this.setAlpha(%this.color3, 0);
+
+		borderRight = %thumbBorder;
+		borderLeft = %thumbBorder;
+	};
+
+	%buttonBorder = new GuiBorderProfile()
+	{
+		padding = 3;
+		paddingHL = 3;
+		paddingSL = 3;
+		paddingNA = 3;
+	};
+
+	%this.scrollingPanelArrowProfile = new GuiControlProfile()
+	{
+		fillColor = %this.color2;
+		fillColorHL = %this.color2;
+		fillColorSL = %this.color2;
+		fillColorNA = %this.setAlpha(%this.color2, 50);
+
+		fontType = %this.font[1];
+		fontDirectory = %this.fontDirectory;
+		fontColor = %this.color3;
+		fontColorHL = %this.adjustValue(%this.color3, 10);
+		fontColorSL = %this.color5;
+		fontColorNA = %this.setAlpha(%this.color3, 80);
+
+		borderDefault = %buttonBorder;
+	};
+	%this.scrollingPanelProfile = new GuiControlProfile()
+	{
+	    fillColor = %this.color1;
+	};
+}

+ 189 - 0
editor/EditorCore/Themes/LabCoat/images/banner1.asset.taml

@@ -0,0 +1,189 @@
+<ImageAsset
+    AssetName="labCoatBanner1"
+    ImageFile="@assetFile=banner1.png"
+	AssetInternal="1" 
+    FilterMode="NEAREST"
+    ExplicitMode="true">
+    <ImageAsset.Cells>
+        <Cell
+            RegionName="TL1"
+            Offset="0 0"
+            Width="28"
+            Height="8" />
+        <Cell
+            RegionName="TC1"
+            Offset="28 0"
+            Width="2"
+            Height="8" />
+        <Cell
+            RegionName="TR1"
+            Offset="30 0"
+            Width="59"
+            Height="8" />
+        <Cell
+            RegionName="ML1"
+            Offset="0 8"
+            Width="28"
+            Height="2" />
+        <Cell
+            RegionName="MC1"
+            Offset="28 8"
+            Width="2"
+            Height="2" />
+        <Cell
+            RegionName="MR1"
+            Offset="30 8"
+            Width="59"
+            Height="2" />
+        <Cell
+            RegionName="BL1"
+            Offset="0 10"
+            Width="28"
+            Height="2" />
+        <Cell
+            RegionName="BC1"
+            Offset="28 10"
+            Width="2"
+            Height="2" />
+        <Cell
+            RegionName="BR1"
+            Offset="30 10"
+            Width="59"
+            Height="2" />
+        <Cell
+            RegionName="TL2"
+            Offset="0 12"
+            Width="28"
+            Height="8" />
+        <Cell
+            RegionName="TC2"
+            Offset="28 12"
+            Width="2"
+            Height="8" />
+        <Cell
+            RegionName="TR2"
+            Offset="30 12"
+            Width="59"
+            Height="8" />
+        <Cell
+            RegionName="ML2"
+            Offset="0 20"
+            Width="28"
+            Height="2" />
+        <Cell
+            RegionName="MC2"
+            Offset="28 20"
+            Width="2"
+            Height="2" />
+        <Cell
+            RegionName="MR2"
+            Offset="30 20"
+            Width="59"
+            Height="2" />
+        <Cell
+            RegionName="BL2"
+            Offset="0 22"
+            Width="28"
+            Height="2" />
+        <Cell
+            RegionName="BC2"
+            Offset="28 22"
+            Width="2"
+            Height="2" />
+        <Cell
+            RegionName="BR2"
+            Offset="30 22"
+            Width="59"
+            Height="2" />
+        <Cell
+            RegionName="TL3"
+            Offset="0 24"
+            Width="28"
+            Height="8" />
+        <Cell
+            RegionName="TC3"
+            Offset="28 24"
+            Width="2"
+            Height="8" />
+        <Cell
+            RegionName="TR3"
+            Offset="30 24"
+            Width="59"
+            Height="8" />
+        <Cell
+            RegionName="ML3"
+            Offset="0 32"
+            Width="28"
+            Height="2" />
+        <Cell
+            RegionName="MC3"
+            Offset="28 32"
+            Width="2"
+            Height="2" />
+        <Cell
+            RegionName="MR3"
+            Offset="30 32"
+            Width="59"
+            Height="2" />
+        <Cell
+            RegionName="BL3"
+            Offset="0 34"
+            Width="28"
+            Height="2" />
+        <Cell
+            RegionName="BC3"
+            Offset="28 34"
+            Width="2"
+            Height="2" />
+        <Cell
+            RegionName="BR3"
+            Offset="30 34"
+            Width="59"
+            Height="2" />
+        <Cell
+            RegionName="TL4"
+            Offset="0 36"
+            Width="28"
+            Height="8" />
+        <Cell
+            RegionName="TC4"
+            Offset="28 36"
+            Width="2"
+            Height="8" />
+        <Cell
+            RegionName="TR4"
+            Offset="30 36"
+            Width="59"
+            Height="8" />
+        <Cell
+            RegionName="ML4"
+            Offset="0 44"
+            Width="28"
+            Height="2" />
+        <Cell
+            RegionName="MC4"
+            Offset="28 44"
+            Width="2"
+            Height="2" />
+        <Cell
+            RegionName="MR4"
+            Offset="30 44"
+            Width="59"
+            Height="2" />
+        <Cell
+            RegionName="BL4"
+            Offset="0 46"
+            Width="28"
+            Height="2" />
+        <Cell
+            RegionName="BC4"
+            Offset="28 46"
+            Width="2"
+            Height="2" />
+        <Cell
+            RegionName="BR4"
+            Offset="30 46"
+            Width="59"
+            Height="2" />
+    </ImageAsset.Cells>
+</ImageAsset>

BIN
editor/EditorCore/Themes/LabCoat/images/banner1.png


+ 6 - 1
editor/EditorCore/module.taml

@@ -4,4 +4,9 @@
 	Description="Core module for the editor"
 	Description="Core module for the editor"
 	ScriptFile="EditorCore.cs"
 	ScriptFile="EditorCore.cs"
 	CreateFunction="create"
 	CreateFunction="create"
-	DestroyFunction="destroy" />
+	DestroyFunction="destroy">
+		<DeclaredAssets
+			Path="Themes"
+			Extension="asset.taml"
+			Recurse="true"/>
+</ModuleDefinition>

+ 0 - 6
engine/source/gui/guiDefaultControlRender.cc

@@ -250,7 +250,6 @@ void renderSizableBorderedTexture(RectI &bounds, TextureHandle &texture, RectI &
 	destRect.extent.y = Top.extent.y;
 	destRect.extent.y = Top.extent.y;
 	destRect.point.y = bounds.point.y;
 	destRect.point.y = bounds.point.y;
 	stretchRect = Top;
 	stretchRect = Top;
-	stretchRect.inset(1, 0);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 
 
 	//bottom line stretch
 	//bottom line stretch
@@ -259,7 +258,6 @@ void renderSizableBorderedTexture(RectI &bounds, TextureHandle &texture, RectI &
 	destRect.extent.y = Bottom.extent.y;
 	destRect.extent.y = Bottom.extent.y;
 	destRect.point.y = bounds.point.y + bounds.extent.y - Bottom.extent.y;
 	destRect.point.y = bounds.point.y + bounds.extent.y - Bottom.extent.y;
 	stretchRect = Bottom;
 	stretchRect = Bottom;
-	stretchRect.inset(1, 0);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 
 
 	//left line stretch
 	//left line stretch
@@ -268,7 +266,6 @@ void renderSizableBorderedTexture(RectI &bounds, TextureHandle &texture, RectI &
 	destRect.extent.y = bounds.extent.y - TopLeft.extent.y - BottomLeft.extent.y;
 	destRect.extent.y = bounds.extent.y - TopLeft.extent.y - BottomLeft.extent.y;
 	destRect.point.y = bounds.point.y + TopLeft.extent.y;
 	destRect.point.y = bounds.point.y + TopLeft.extent.y;
 	stretchRect = Left;
 	stretchRect = Left;
-	stretchRect.inset(0, 1);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 
 
 	//right line stretch
 	//right line stretch
@@ -277,7 +274,6 @@ void renderSizableBorderedTexture(RectI &bounds, TextureHandle &texture, RectI &
 	destRect.extent.y = bounds.extent.y - TopRight.extent.y - BottomRight.extent.y;
 	destRect.extent.y = bounds.extent.y - TopRight.extent.y - BottomRight.extent.y;
 	destRect.point.y = bounds.point.y + TopRight.extent.y;
 	destRect.point.y = bounds.point.y + TopRight.extent.y;
 	stretchRect = Right;
 	stretchRect = Right;
-	stretchRect.inset(0, 1);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 
 
 	//fill stretch
 	//fill stretch
@@ -286,7 +282,6 @@ void renderSizableBorderedTexture(RectI &bounds, TextureHandle &texture, RectI &
 	destRect.extent.y = bounds.extent.y - Top.extent.y - Bottom.extent.y;
 	destRect.extent.y = bounds.extent.y - Top.extent.y - Bottom.extent.y;
 	destRect.point.y = bounds.point.y + Top.extent.y;
 	destRect.point.y = bounds.point.y + Top.extent.y;
 	stretchRect = Fill;
 	stretchRect = Fill;
-	stretchRect.inset(1, 1);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 	dglDrawBitmapStretchSR(texture, destRect, stretchRect);
 }
 }
 
 
@@ -320,7 +315,6 @@ void renderFixedBitmapBordersFilled(RectI &bounds, S32 baseMultiplier, GuiContro
       destRect.point.y = bounds.point.y;
       destRect.point.y = bounds.point.y;
       //stretch it
       //stretch it
       stretchRect = mBitmapBounds[Fill];
       stretchRect = mBitmapBounds[Fill];
-      stretchRect.inset(1,0);
       //draw it
       //draw it
       dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
       dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
    }
    }