mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Add cursor types and use resize cursor for dragbars
This commit is contained in:
parent
c2ce2c9d1a
commit
ffd7776147
|
@ -1391,6 +1391,7 @@ set(EXPECTED_DATA
|
||||||
editor/background.png
|
editor/background.png
|
||||||
editor/checker.png
|
editor/checker.png
|
||||||
editor/cursor.png
|
editor/cursor.png
|
||||||
|
editor/cursor_resize.png
|
||||||
editor/entities/DDNet.png
|
editor/entities/DDNet.png
|
||||||
editor/entities/FNG.png
|
editor/entities/FNG.png
|
||||||
editor/entities/Race.png
|
editor/entities/Race.png
|
||||||
|
|
BIN
data/editor/cursor_resize.png
Normal file
BIN
data/editor/cursor_resize.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
|
@ -7828,6 +7828,11 @@ void CEditor::DoEditorDragBar(CUIRect View, CUIRect *pDragBar, EDragSide Side, f
|
||||||
static float s_InitialMouseX = 0.0f;
|
static float s_InitialMouseX = 0.0f;
|
||||||
static float s_InitialMouseOffsetX = 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 Clicked;
|
||||||
bool Abrupted;
|
bool Abrupted;
|
||||||
if(int Result = DoButton_DraggableEx(pDragBar, "", 8, pDragBar, &Clicked, &Abrupted, 0, "Change the size of the editor by dragging."))
|
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)
|
if(Clicked || Abrupted)
|
||||||
s_Operation = OP_NONE;
|
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)
|
if(s_Operation == OP_CLICKED && absolute(IsVertical ? UI()->MouseY() - s_InitialMouseY : UI()->MouseX() - s_InitialMouseX) > 5.0f)
|
||||||
s_Operation = OP_DRAGGING;
|
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);
|
*pValue = clamp(UI()->MouseY() - s_InitialMouseOffsetY - View.y + pDragBar->h, MinValue, MaxValue);
|
||||||
else if(Side == EDragSide::SIDE_LEFT)
|
else if(Side == EDragSide::SIDE_LEFT)
|
||||||
*pValue = clamp(s_InitialMouseOffsetX + View.x + View.w - UI()->MouseX(), MinValue, MaxValue);
|
*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);
|
Graphics()->Clear(0.0f, 0.0f, 0.0f);
|
||||||
CUIRect View = *UI()->Screen();
|
CUIRect View = *UI()->Screen();
|
||||||
UI()->MapScreen();
|
UI()->MapScreen();
|
||||||
|
m_CursorType = CURSOR_NORMAL;
|
||||||
|
|
||||||
float Width = View.w;
|
float Width = View.w;
|
||||||
float Height = View.h;
|
float Height = View.h;
|
||||||
|
@ -8306,8 +8312,10 @@ void CEditor::RenderMousePointer()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Graphics()->WrapClamp();
|
Graphics()->WrapClamp();
|
||||||
Graphics()->TextureSet(m_CursorTexture);
|
Graphics()->TextureSet(m_aCursorTextures[m_CursorType]);
|
||||||
Graphics()->QuadsBegin();
|
Graphics()->QuadsBegin();
|
||||||
|
if(m_CursorType == CURSOR_RESIZE_V)
|
||||||
|
Graphics()->QuadsSetRotation(pi / 2);
|
||||||
if(ms_pUiGotContext == UI()->HotItem())
|
if(ms_pUiGotContext == UI()->HotItem())
|
||||||
Graphics()->SetColor(1, 0, 0, 1);
|
Graphics()->SetColor(1, 0, 0, 1);
|
||||||
IGraphics::CQuadItem QuadItem(UI()->MouseX(), UI()->MouseY(), 16.0f, 16.0f);
|
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_CheckerTexture = Graphics()->LoadTexture("editor/checker.png", IStorage::TYPE_ALL);
|
||||||
m_BackgroundTexture = Graphics()->LoadTexture("editor/background.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<CLayerTiles>(this, 16, 16);
|
m_pTilesetPicker = std::make_shared<CLayerTiles>(this, 16, 16);
|
||||||
m_pTilesetPicker->MakePalette();
|
m_pTilesetPicker->MakePalette();
|
||||||
|
|
|
@ -397,7 +397,10 @@ public:
|
||||||
|
|
||||||
m_CheckerTexture.Invalidate();
|
m_CheckerTexture.Invalidate();
|
||||||
m_BackgroundTexture.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;
|
ms_pUiGotContext = nullptr;
|
||||||
|
|
||||||
|
@ -741,7 +744,16 @@ public:
|
||||||
|
|
||||||
IGraphics::CTextureHandle m_CheckerTexture;
|
IGraphics::CTextureHandle m_CheckerTexture;
|
||||||
IGraphics::CTextureHandle m_BackgroundTexture;
|
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();
|
IGraphics::CTextureHandle GetEntitiesTexture();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue