mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Editor: added a goto button
This commit is contained in:
parent
6a5d99daf1
commit
ae8b9914aa
|
@ -1080,6 +1080,21 @@ void CEditor::DoToolbar(CUIRect ToolBar)
|
|||
TB_Bottom.VSplitLeft(5.0f, nullptr, &TB_Bottom);
|
||||
}
|
||||
|
||||
// goto xy button
|
||||
{
|
||||
TB_Bottom.VSplitLeft(50.0, &Button, &TB_Bottom);
|
||||
static int s_GotoButton = 0;
|
||||
if(DoButton_Editor(&s_GotoButton, "Goto XY", 0, &Button, 0, "Go to a specified coordinate point on the map"))
|
||||
{
|
||||
static int s_ModifierPopupID = 0;
|
||||
if(!UiPopupExists(&s_ModifierPopupID))
|
||||
{
|
||||
UiInvokePopupMenu(&s_ModifierPopupID, 0, Button.x, Button.y + Button.h, 120, 52, PopupGoto);
|
||||
}
|
||||
}
|
||||
TB_Bottom.VSplitLeft(5.0f, nullptr, &TB_Bottom);
|
||||
}
|
||||
|
||||
// tile manipulation
|
||||
{
|
||||
static int s_BorderBut = 0;
|
||||
|
@ -6147,6 +6162,12 @@ void CEditor::ZoomMouseTarget(float ZoomFactor)
|
|||
m_WorldOffsetY += (Mwy - m_WorldOffsetY) * (1 - ZoomFactor);
|
||||
}
|
||||
|
||||
void CEditor::Goto(float X, float Y)
|
||||
{
|
||||
m_WorldOffsetX = X * 32;
|
||||
m_WorldOffsetY = Y * 32;
|
||||
}
|
||||
|
||||
void CEditorMap::DeleteEnvelope(int Index)
|
||||
{
|
||||
if(Index < 0 || Index >= (int)m_vpEnvelopes.size())
|
||||
|
|
|
@ -824,6 +824,8 @@ public:
|
|||
m_PreventUnusedTilesWasWarned = false;
|
||||
m_AllowPlaceUnusedTiles = 0;
|
||||
m_BrushDrawDestructive = true;
|
||||
m_GotoX = 0;
|
||||
m_GotoY = 0;
|
||||
|
||||
m_Mentions = 0;
|
||||
}
|
||||
|
@ -1225,6 +1227,8 @@ public:
|
|||
static int PopupSpeedup(CEditor *pEditor, CUIRect View, void *pContext);
|
||||
static int PopupSwitch(CEditor *pEditor, CUIRect View, void *pContext);
|
||||
static int PopupTune(CEditor *pEditor, CUIRect View, void *pContext);
|
||||
static int PopupGoto(CEditor *pEditor, CUIRect View, void *pContext);
|
||||
void Goto(float X, float Y);
|
||||
unsigned char m_TeleNumber;
|
||||
|
||||
unsigned char m_TuningNum;
|
||||
|
@ -1235,6 +1239,9 @@ public:
|
|||
|
||||
unsigned char m_SwitchNum;
|
||||
unsigned char m_SwitchDelay;
|
||||
|
||||
unsigned char m_GotoX;
|
||||
unsigned char m_GotoY;
|
||||
};
|
||||
|
||||
// make sure to inline this function
|
||||
|
|
|
@ -1774,6 +1774,62 @@ int CEditor::PopupTune(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CEditor::PopupGoto(CEditor *pEditor, CUIRect View, void *pContext)
|
||||
{
|
||||
CUIRect CoordXPicker;
|
||||
CUIRect CoordYPicker;
|
||||
|
||||
View.HSplitMid(&CoordXPicker, &CoordYPicker);
|
||||
CoordXPicker.VSplitRight(2.f, &CoordXPicker, nullptr);
|
||||
|
||||
int MaxX = pEditor->m_Map.m_pGameLayer->m_Width - 1;
|
||||
int MaxY = pEditor->m_Map.m_pGameLayer->m_Height - 1;
|
||||
|
||||
if(pEditor->m_GotoX > MaxX)
|
||||
pEditor->m_GotoX = MaxX;
|
||||
if(pEditor->m_GotoY > MaxY)
|
||||
pEditor->m_GotoY = MaxY;
|
||||
|
||||
static ColorRGBA s_Color = ColorRGBA(1, 1, 1, 0.5f);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_CoordX = 0,
|
||||
PROP_CoordY,
|
||||
NUM_PROPS,
|
||||
};
|
||||
|
||||
CProperty aProps[] = {
|
||||
{"X", pEditor->m_GotoX, PROPTYPE_INT_STEP, 0, MaxX},
|
||||
{"Y", pEditor->m_GotoY, PROPTYPE_INT_STEP, 0, MaxY},
|
||||
{nullptr},
|
||||
};
|
||||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&CoordXPicker, aProps, s_aIds, &NewVal, s_Color);
|
||||
|
||||
if(Prop == PROP_CoordX)
|
||||
{
|
||||
pEditor->m_GotoX = NewVal;
|
||||
}
|
||||
else if(Prop == PROP_CoordY)
|
||||
{
|
||||
pEditor->m_GotoY = NewVal;
|
||||
}
|
||||
|
||||
CUIRect Button;
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
|
||||
static int s_Button;
|
||||
if(pEditor->DoButton_Editor(&s_Button, "Go", 0, &Button, 0, ""))
|
||||
{
|
||||
pEditor->Goto(pEditor->m_GotoX + 0.5f, pEditor->m_GotoY + 0.5f);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CEditor::PopupColorPicker(CEditor *pEditor, CUIRect View, void *pContext)
|
||||
{
|
||||
CUIRect SVPicker, HuePicker;
|
||||
|
|
Loading…
Reference in a new issue