about summary refs log tree commit diff
path: root/src/game/editor
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-09-19 17:12:09 +0200
committeroy <Tom_Adams@web.de>2010-09-19 17:12:09 +0200
commit08f6e7dd079380507e5d87022b58b4d586a05c6d (patch)
tree219194dac964e78cae86a0a7ab522cdfd2728f3a /src/game/editor
parentcf2d46d3ba1ee53da02dd78092c7223c1e3787fa (diff)
downloadzcatch-08f6e7dd079380507e5d87022b58b4d586a05c6d.tar.gz
zcatch-08f6e7dd079380507e5d87022b58b4d586a05c6d.zip
added button to resize a quad based on the aspect ratio of the image. Closes #169
Diffstat (limited to 'src/game/editor')
-rw-r--r--src/game/editor/ed_popups.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp
index 68f804b5..3d153222 100644
--- a/src/game/editor/ed_popups.cpp
+++ b/src/game/editor/ed_popups.cpp
@@ -264,8 +264,40 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View)
 		return 1;
 	}
 
-	// square button
 	View.HSplitBottom(10.0f, &View, &Button);
+
+	// aspect ratio button
+	CLayerQuads *pLayer = (CLayerQuads *)pEditor->GetSelectedLayerType(0, LAYERTYPE_QUADS);
+	if(pLayer && pLayer->m_Image >= 0 && pLayer->m_Image < pEditor->m_Map.m_lImages.size())
+	{
+		View.HSplitBottom(12.0f, &View, &Button);
+		static int s_AspectRatioButton = 0;
+		if(pEditor->DoButton_Editor(&s_AspectRatioButton, Localize("Aspect ratio"), 0, &Button, 0, Localize("Resizes the current Quad based on the aspect ratio of the image")))
+		{
+			int Top = pQuad->m_aPoints[0].y;
+			int Left = pQuad->m_aPoints[0].x;
+			int Right = pQuad->m_aPoints[0].x;
+
+			for(int k = 1; k < 4; k++)
+			{
+				if(pQuad->m_aPoints[k].y < Top) Top = pQuad->m_aPoints[k].y;
+				if(pQuad->m_aPoints[k].x < Left) Left = pQuad->m_aPoints[k].x;
+				if(pQuad->m_aPoints[k].x > Right) Right = pQuad->m_aPoints[k].x;
+			}
+
+			int Height = (Right-Left)*pEditor->m_Map.m_lImages[pLayer->m_Image]->m_Height/pEditor->m_Map.m_lImages[pLayer->m_Image]->m_Width;
+			
+			pQuad->m_aPoints[0].x = Left; pQuad->m_aPoints[0].y = Top;
+			pQuad->m_aPoints[1].x = Right; pQuad->m_aPoints[1].y = Top;
+			pQuad->m_aPoints[2].x = Left; pQuad->m_aPoints[2].y = Top+Height;
+			pQuad->m_aPoints[3].x = Right; pQuad->m_aPoints[3].y = Top+Height;
+			return 1;
+		}
+		View.HSplitBottom(6.0f, &View, &Button);
+		
+	}
+
+	// square button
 	View.HSplitBottom(12.0f, &View, &Button);
 	static int s_Button = 0;
 	if(pEditor->DoButton_Editor(&s_Button, Localize("Square"), 0, &Button, 0, Localize("Squares the current quad")))