From ffd7776147f5ea76d57b0470aa8db6486d216cea Mon Sep 17 00:00:00 2001 From: Corantin H Date: Thu, 28 Dec 2023 01:29:17 +0100 Subject: [PATCH] Add cursor types and use resize cursor for dragbars --- CMakeLists.txt | 1 + data/editor/cursor_resize.png | Bin 0 -> 5481 bytes src/game/editor/editor.cpp | 18 ++++++++++++++---- src/game/editor/editor.h | 16 ++++++++++++++-- 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 data/editor/cursor_resize.png diff --git a/CMakeLists.txt b/CMakeLists.txt index 239f3a185..ed53fa771 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1391,6 +1391,7 @@ set(EXPECTED_DATA editor/background.png editor/checker.png editor/cursor.png + editor/cursor_resize.png editor/entities/DDNet.png editor/entities/FNG.png editor/entities/Race.png diff --git a/data/editor/cursor_resize.png b/data/editor/cursor_resize.png new file mode 100644 index 0000000000000000000000000000000000000000..ca696d06e98df0ea23ed5457e424a39de75a292f GIT binary patch literal 5481 zcmV-v6_)CWP)(#DuELHW_uvEDX1>O~EP*MPy{S%}ujR zL7;KIjztHSMj>4g(3YrdREExS>40Q?0YuhJc@wL&xA&gk{y68{K6aGeHw44J$&>bZ z?m55nd;gttp7SUX;e3X7wi!6vIPVn@I@1Fvr9O2(P{^g)K2xYOIY3`w9QqrxzxJo= zlPS)K0!}B0L*H@J>5~m)T>;4m;^4+krBAS5Hjp(1q$)(F$QIvOsREz1@Yx(QV-GkR z!uLfcGNi45b3yPR(v>5v5IEO_hxB<$$pg+s!B2%$WJ=ltJ}<&UYP=4p0Hsu>!hac9 z2OI)!O``o*fZad?aBaGSCe5>m^m}Cp54acT2E<;+lIXWN&|ZMmz_3ghIjxLmNcc;D zt$hR$;Q1u_{`M68jsTUJFqE_cvVfleotAM?N{Q!r0&D~FlIWigd;mycVPRiItObhF zWo$qNWQdD^x*)>=0X_msQ=s*rqcMN}eDQrhsDyWcN$E0qN(E#A-vl}wlO-i3vU>IE zAk*_xq&E!s1nWU7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Vkfkc66X$l(=T#DLV0SHR%LI47wR84b#=g z4z!;FoC3B2SM@Z$vz`Y3U!?bMa>)jeZ0RK+*#MF)y#yp1K(eKmfMf$mw)7H^YyioY fUILO0AldRCO+8sSQJvcX00000NkvXXu0mjfk4j|~ literal 0 HcmV?d00001 diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 8c2d41041..82e6da5c0 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -7828,6 +7828,11 @@ void CEditor::DoEditorDragBar(CUIRect View, CUIRect *pDragBar, EDragSide Side, f static float s_InitialMouseX = 0.0f; static float s_InitialMouseOffsetX = 0.0f; + bool IsVertical = Side == EDragSide::SIDE_TOP || Side == EDragSide::SIDE_BOTTOM; + + if(UI()->MouseInside(pDragBar) && UI()->HotItem() == pDragBar) + m_CursorType = IsVertical ? CURSOR_RESIZE_V : CURSOR_RESIZE_H; + bool Clicked; bool Abrupted; if(int Result = DoButton_DraggableEx(pDragBar, "", 8, pDragBar, &Clicked, &Abrupted, 0, "Change the size of the editor by dragging.")) @@ -7844,8 +7849,6 @@ void CEditor::DoEditorDragBar(CUIRect View, CUIRect *pDragBar, EDragSide Side, f if(Clicked || Abrupted) s_Operation = OP_NONE; - bool IsVertical = Side == EDragSide::SIDE_TOP || Side == EDragSide::SIDE_BOTTOM; - if(s_Operation == OP_CLICKED && absolute(IsVertical ? UI()->MouseY() - s_InitialMouseY : UI()->MouseX() - s_InitialMouseX) > 5.0f) s_Operation = OP_DRAGGING; @@ -7859,6 +7862,8 @@ void CEditor::DoEditorDragBar(CUIRect View, CUIRect *pDragBar, EDragSide Side, f *pValue = clamp(UI()->MouseY() - s_InitialMouseOffsetY - View.y + pDragBar->h, MinValue, MaxValue); else if(Side == EDragSide::SIDE_LEFT) *pValue = clamp(s_InitialMouseOffsetX + View.x + View.w - UI()->MouseX(), MinValue, MaxValue); + + m_CursorType = IsVertical ? CURSOR_RESIZE_V : CURSOR_RESIZE_H; } } } @@ -7945,6 +7950,7 @@ void CEditor::Render() Graphics()->Clear(0.0f, 0.0f, 0.0f); CUIRect View = *UI()->Screen(); UI()->MapScreen(); + m_CursorType = CURSOR_NORMAL; float Width = View.w; float Height = View.h; @@ -8306,8 +8312,10 @@ void CEditor::RenderMousePointer() return; Graphics()->WrapClamp(); - Graphics()->TextureSet(m_CursorTexture); + Graphics()->TextureSet(m_aCursorTextures[m_CursorType]); Graphics()->QuadsBegin(); + if(m_CursorType == CURSOR_RESIZE_V) + Graphics()->QuadsSetRotation(pi / 2); if(ms_pUiGotContext == UI()->HotItem()) Graphics()->SetColor(1, 0, 0, 1); IGraphics::CQuadItem QuadItem(UI()->MouseX(), UI()->MouseY(), 16.0f, 16.0f); @@ -8440,7 +8448,9 @@ void CEditor::Init() m_CheckerTexture = Graphics()->LoadTexture("editor/checker.png", IStorage::TYPE_ALL); m_BackgroundTexture = Graphics()->LoadTexture("editor/background.png", IStorage::TYPE_ALL); - m_CursorTexture = Graphics()->LoadTexture("editor/cursor.png", IStorage::TYPE_ALL); + m_aCursorTextures[CURSOR_NORMAL] = Graphics()->LoadTexture("editor/cursor.png", IStorage::TYPE_ALL); + m_aCursorTextures[CURSOR_RESIZE_H] = Graphics()->LoadTexture("editor/cursor_resize.png", IStorage::TYPE_ALL); + m_aCursorTextures[CURSOR_RESIZE_V] = m_aCursorTextures[CURSOR_RESIZE_H]; m_pTilesetPicker = std::make_shared(this, 16, 16); m_pTilesetPicker->MakePalette(); diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 4446611e3..7f368e2e1 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -397,7 +397,10 @@ public: m_CheckerTexture.Invalidate(); m_BackgroundTexture.Invalidate(); - m_CursorTexture.Invalidate(); + for(int i = 0; i < NUM_CURSORS; i++) + m_aCursorTextures[i].Invalidate(); + + m_CursorType = CURSOR_NORMAL; ms_pUiGotContext = nullptr; @@ -741,7 +744,16 @@ public: IGraphics::CTextureHandle m_CheckerTexture; IGraphics::CTextureHandle m_BackgroundTexture; - IGraphics::CTextureHandle m_CursorTexture; + + enum ECursorType + { + CURSOR_NORMAL, + CURSOR_RESIZE_V, + CURSOR_RESIZE_H, + NUM_CURSORS + }; + IGraphics::CTextureHandle m_aCursorTextures[ECursorType::NUM_CURSORS]; + ECursorType m_CursorType; IGraphics::CTextureHandle GetEntitiesTexture();