diff options
| author | oy <Tom_Adams@web.de> | 2011-02-18 11:41:27 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-02-18 11:41:27 +0100 |
| commit | 4f91026a01436d95cb20b3a994e96dce5072544e (patch) | |
| tree | 5faaec04c1404bc473f0f6b5c57b9c243730ec00 /src/game | |
| parent | 169efb129f947209b6d3cdfdc632d3804dcd549d (diff) | |
| download | zcatch-4f91026a01436d95cb20b3a994e96dce5072544e.tar.gz zcatch-4f91026a01436d95cb20b3a994e96dce5072544e.zip | |
added an editor function to show tile informations (index, flip/rotate status)
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/editor/ed_editor.cpp | 19 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.h | 3 | ||||
| -rw-r--r-- | src/game/editor/ed_layer_tiles.cpp | 32 |
3 files changed, 53 insertions, 1 deletions
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index bbe321cf..a4ec3556 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -666,6 +666,17 @@ void CEditor::DoToolbar(CUIRect ToolBar) m_ProofBorders = !m_ProofBorders; } + TB_Top.VSplitLeft(5.0f, 0, &TB_Top); + + // tile info button + TB_Top.VSplitLeft(40.0f, &Button, &TB_Top); + static int s_TileInfoButton = 0; + if(DoButton_Editor(&s_TileInfoButton, Localize("Info"), m_ShowTileInfo, &Button, 0, Localize("[ctrl+i] Show tile informations")) || + (Input()->KeyDown('i') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)))) + { + m_ShowTileInfo = !m_ShowTileInfo; + } + TB_Top.VSplitLeft(15.0f, 0, &TB_Top); // zoom group @@ -812,7 +823,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) static int s_BorderBut = 0; CLayerTiles *pT = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES); - if(DoButton_Editor(&s_BorderBut, Localize("Border"), pT?0:-1, &Button, 0, Localize("Border"))) + if(DoButton_Editor(&s_BorderBut, Localize("Border"), pT?0:-1, &Button, 0, Localize("Adds border tiles"))) { if(pT) DoMapBorder(); @@ -1147,6 +1158,10 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) m_Map.m_pGameGroup->MapScreen(); m_Map.m_pGameLayer->Render(); } + + CLayerTiles *pT = static_cast<CLayerTiles *>(GetSelectedLayerType(0, LAYERTYPE_TILES)); + if(m_ShowTileInfo && pT && pT->m_Visible && m_ZoomLevel <= 300) + pT->ShowInfo(); } static void *s_pEditorID = (void *)&s_pEditorID; @@ -1191,6 +1206,8 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) m_TilesetPicker.m_Image = t->m_Image; m_TilesetPicker.m_TexID = t->m_TexID; m_TilesetPicker.Render(); + if(m_ShowTileInfo) + m_TilesetPicker.ShowInfo(); } } diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index 648a5829..61af9249 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -380,6 +380,7 @@ public: virtual void BrushFlipY(); virtual void BrushRotate(float Amount); + virtual void ShowInfo(); virtual int RenderProperties(CUIRect *pToolbox); virtual void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc); @@ -500,6 +501,7 @@ public: m_GuiActive = true; m_ProofBorders = false; + m_ShowTileInfo = false; m_ShowDetail = true; m_Animate = false; m_AnimateStart = 0; @@ -598,6 +600,7 @@ public: float m_MouseDeltaWx; float m_MouseDeltaWy; + bool m_ShowTileInfo; bool m_ShowDetail; bool m_Animate; int64 m_AnimateStart; diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp index 57b77e36..e26d98bd 100644 --- a/src/game/editor/ed_layer_tiles.cpp +++ b/src/game/editor/ed_layer_tiles.cpp @@ -2,6 +2,7 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include <base/math.h> +#include <engine/client.h> #include <engine/graphics.h> #include <engine/textrender.h> @@ -321,6 +322,37 @@ void CLayerTiles::Shift(int Direction) } } +void CLayerTiles::ShowInfo() +{ + float ScreenX0, ScreenY0, ScreenX1, ScreenY1; + Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); + Graphics()->TextureSet(m_pEditor->Client()->GetDebugFont()); + + int StartY = max(0, (int)(ScreenY0/32.0f)-1); + int StartX = max(0, (int)(ScreenX0/32.0f)-1); + int EndY = min((int)(ScreenY1/32.0f)+1, m_Height); + int EndX = min((int)(ScreenX1/32.0f)+1, m_Width); + + for(int y = StartY; y < EndY; y++) + for(int x = StartX; x < EndX; x++) + { + int c = x + y*m_Width; + if(m_pTiles[c].m_Index) + { + char aBuf[64]; + str_format(aBuf, sizeof(aBuf), "%i", m_pTiles[c].m_Index); + m_pEditor->Graphics()->QuadsText(x*32, y*32, 16.0f, 1,1,1,1, aBuf); + + char aFlags[4] = { m_pTiles[c].m_Flags&TILEFLAG_VFLIP ? 'V' : ' ', + m_pTiles[c].m_Flags&TILEFLAG_HFLIP ? 'H' : ' ', + m_pTiles[c].m_Flags&TILEFLAG_ROTATE? 'R' : ' ', + 0}; + m_pEditor->Graphics()->QuadsText(x*32, y*32+16, 16.0f, 1,1,1,1, aFlags); + } + x += m_pTiles[c].m_Skip; + } +} + int CLayerTiles::RenderProperties(CUIRect *pToolBox) { CUIRect Button; |