From 484cb82872089b41443c6d41b870614b5fc9a922 Mon Sep 17 00:00:00 2001 From: VoxelDoesCode Date: Tue, 11 Oct 2022 18:23:11 -0400 Subject: [PATCH] Hex Values in the editor's info feature Clang format before squash --- src/game/editor/editor.cpp | 12 +++++++++++- src/game/editor/editor.h | 2 ++ src/game/editor/layer_tiles.cpp | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index cabf1b598..fb88687e3 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -910,7 +910,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) TB_Top.VSplitLeft(40.0f, &Button, &TB_Top); static int s_TileInfoButton = 0; if(DoButton_Editor(&s_TileInfoButton, "Info", m_ShowTileInfo, &Button, 0, "[ctrl+i] Show tile information") || - (Input()->KeyPress(KEY_I) && ModPressed)) + (Input()->KeyPress(KEY_I) && ModPressed && !ShiftPressed)) { m_ShowTileInfo = !m_ShowTileInfo; m_ShowEnvelopePreview = SHOWENV_NONE; @@ -1250,6 +1250,16 @@ void CEditor::DoToolbar(CUIRect ToolBar) m_BrushDrawDestructive = !m_BrushDrawDestructive; TB_Bottom.VSplitLeft(5.0f, &Button, &TB_Bottom); } + + // Hex values button + if(m_ShowTileInfo) + { + TB_Bottom.VSplitLeft(65.0f, &Button, &TB_Bottom); + static int s_TileInfoHexButton = 0; + if(DoButton_Editor(&s_TileInfoHexButton, "Hex Values", m_ShowTileHexInfo, &Button, 0, "[ctrl+shift+i] Show a tile's hex value") || + (Input()->KeyPress(KEY_I) && ModPressed && ShiftPressed)) + m_ShowTileHexInfo = !m_ShowTileHexInfo; + } } } diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 831f276a5..c2b1890ea 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -835,6 +835,7 @@ public: m_PreventUnusedTilesWasWarned = false; m_AllowPlaceUnusedTiles = 0; m_BrushDrawDestructive = true; + m_ShowTileHexInfo = false; m_GotoX = 0; m_GotoY = 0; @@ -914,6 +915,7 @@ public: bool m_PreventUnusedTilesWasWarned; int m_AllowPlaceUnusedTiles; bool m_BrushDrawDestructive; + bool m_ShowTileHexInfo; int m_Mentions; diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index 98f74ec81..22ca9fc6a 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -663,7 +663,7 @@ void CLayerTiles::ShowInfo() if(m_pTiles[c].m_Index) { char aBuf[64]; - str_format(aBuf, sizeof(aBuf), "%i", m_pTiles[c].m_Index); + str_format(aBuf, sizeof(aBuf), m_pEditor->m_ShowTileHexInfo ? "%02X" : "%i", m_pTiles[c].m_Index); m_pEditor->Graphics()->QuadsText(x * 32, y * 32, 16.0f, aBuf); char aFlags[4] = {m_pTiles[c].m_Flags & TILEFLAG_VFLIP ? 'V' : ' ',