about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-10-09 18:38:23 +0200
committeroy <Tom_Adams@web.de>2010-10-09 18:38:23 +0200
commitb3c81e7258cabc72cf9f610da0aa6aa494dd30a9 (patch)
treeea81ac04883e905efa6eb2f2800c837fe91f79a7 /src/game
parentab2df146410e47bc4d30d1088b383aac03766d6f (diff)
downloadzcatch-b3c81e7258cabc72cf9f610da0aa6aa494dd30a9.tar.gz
zcatch-b3c81e7258cabc72cf9f610da0aa6aa494dd30a9.zip
added the possibility to shift the tiles of a layer into any direction
Diffstat (limited to 'src/game')
-rw-r--r--src/game/editor/ed_editor.cpp37
-rw-r--r--src/game/editor/ed_editor.h2
-rw-r--r--src/game/editor/ed_layer_tiles.cpp39
3 files changed, 76 insertions, 2 deletions
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp
index 270f3efd..0b84fe38 100644
--- a/src/game/editor/ed_editor.cpp
+++ b/src/game/editor/ed_editor.cpp
@@ -1668,6 +1668,41 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIds, int *
 				Change = i;
 			}
 		}
+		else if(pProps[i].m_Type == PROPTYPE_SHIFT)
+		{
+			CUIRect Left, Right, Up, Down;
+			Shifter.VSplitMid(&Left, &Up);
+			Left.VSplitRight(1.0f, &Left, 0);
+			Up.VSplitLeft(1.0f, 0, &Up);
+			Left.VSplitLeft(10.0f, &Left, &Shifter);
+			Shifter.VSplitRight(10.0f, &Shifter, &Right);
+			RenderTools()->DrawUIRect(&Shifter, vec4(1,1,1,0.5f), 0, 0.0f);
+			UI()->DoLabel(&Shifter, "X", 10.0f, 0, -1);
+			Up.VSplitLeft(10.0f, &Up, &Shifter);
+			Shifter.VSplitRight(10.0f, &Shifter, &Down);
+			RenderTools()->DrawUIRect(&Shifter, vec4(1,1,1,0.5f), 0, 0.0f);
+			UI()->DoLabel(&Shifter, "Y", 10.0f, 0, -1);
+			if(DoButton_ButtonDec(&pIds[i], "-", 0, &Left, 0, Localize("Left")))
+			{
+				*pNewVal = 1;
+				Change = i;
+			}
+			if(DoButton_ButtonInc(((char *)&pIds[i])+3, "+", 0, &Right, 0, Localize("Right")))
+			{
+				*pNewVal = 2;
+				Change = i;
+			}
+			if(DoButton_ButtonDec(((char *)&pIds[i])+1, "-", 0, &Up, 0, Localize("Up")))
+			{
+				*pNewVal = 4;
+				Change = i;
+			}
+			if(DoButton_ButtonInc(((char *)&pIds[i])+2, "+", 0, &Down, 0, Localize("Down")))
+			{
+				*pNewVal = 8;
+				Change = i;
+			}
+		}
 	}
 
 	return Change;
@@ -1779,7 +1814,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
 					m_SelectedGroup = g;
 					static int s_LayerPopupId = 0;
 					if(Result == 2)
-						UiInvokePopupMenu(&s_LayerPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 150, PopupLayer);
+						UiInvokePopupMenu(&s_LayerPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 180, PopupLayer);
 				}
 
 				LayerCur += 14.0f;
diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h
index bf6e6dec..2c8cc730 100644
--- a/src/game/editor/ed_editor.h
+++ b/src/game/editor/ed_editor.h
@@ -340,6 +340,7 @@ enum
 	PROPTYPE_COLOR,
 	PROPTYPE_IMAGE,
 	PROPTYPE_ENVELOPE,
+	PROPTYPE_SHIFT,
 };
 
 typedef struct
@@ -355,6 +356,7 @@ public:
 	~CLayerTiles();
 
 	void Resize(int NewW, int NewH);
+	void Shift(int Direction);
 
 	void MakePalette();
 	virtual void Render();
diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp
index adc747d0..ae3e28e5 100644
--- a/src/game/editor/ed_layer_tiles.cpp
+++ b/src/game/editor/ed_layer_tiles.cpp
@@ -280,6 +280,39 @@ void CLayerTiles::Resize(int NewW, int NewH)
 	m_Height = NewH;
 }
 
+void CLayerTiles::Shift(int Direction)
+{
+	switch(Direction)
+	{
+	case 1:
+		{
+			// left
+			for(int y = 0; y < m_Height; ++y)
+				mem_move(&m_pTiles[y*m_Width], &m_pTiles[y*m_Width+1], (m_Width-1)*sizeof(CTile));
+		}
+		break;
+	case 2:
+		{
+			// right
+			for(int y = 0; y < m_Height; ++y)
+				mem_move(&m_pTiles[y*m_Width+1], &m_pTiles[y*m_Width], (m_Width-1)*sizeof(CTile));
+		}
+		break;
+	case 4:
+		{
+			// up
+			for(int y = 0; y < m_Height-1; ++y)
+				mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y+1)*m_Width], m_Width*sizeof(CTile));
+		}
+		break;
+	case 8:
+		{
+			// down
+			for(int y = m_Height-1; y > 0; --y)
+				mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y-1)*m_Width], m_Width*sizeof(CTile));
+		}
+	}
+}
 
 int CLayerTiles::RenderProperties(CUIRect *pToolBox)
 {
@@ -327,6 +360,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
 	{
 		PROP_WIDTH=0,
 		PROP_HEIGHT,
+		PROP_SHIFT,
 		PROP_IMAGE,
 		NUM_PROPS,
 	};
@@ -334,12 +368,13 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
 	CProperty aProps[] = {
 		{Localize("Width"), m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000},
 		{Localize("Height"), m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000},
+		{Localize("Shift"), 0, PROPTYPE_SHIFT, 0, 0},
 		{Localize("Image"), m_Image, PROPTYPE_IMAGE, 0, 0},
 		{0},
 	};
 	
 	if(m_pEditor->m_Map.m_pGameLayer == this) // remove the image from the selection if this is the game layer
-		aProps[2].m_pName = 0;
+		aProps[3].m_pName = 0;
 	
 	static int s_aIds[NUM_PROPS] = {0};
 	int NewVal = 0;
@@ -349,6 +384,8 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
 		Resize(NewVal, m_Height);
 	else if(Prop == PROP_HEIGHT && NewVal > 1)
 		Resize(m_Width, NewVal);
+	else if(Prop == PROP_SHIFT)
+		Shift(NewVal);
 	else if(Prop == PROP_IMAGE)
 	{
 		if (NewVal == -1)