mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Merge pull request #7988 from Robyt3/Editor-Button-Refactoring
Refactor editor button functions: replace/remove `DoButton_File`, `DoButton_ButtonDec/Inc` and `DoButton_Menu`
This commit is contained in:
commit
f7b3cc7179
|
@ -218,27 +218,6 @@ int CEditor::DoButton_Env(const void *pID, const char *pText, int Checked, const
|
||||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, 0, pToolTip);
|
return DoButton_Editor_Common(pID, pText, Checked, pRect, 0, pToolTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CEditor::DoButton_File(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
|
|
||||||
{
|
|
||||||
if(Checked)
|
|
||||||
pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_ALL, 3.0f);
|
|
||||||
|
|
||||||
CUIRect Rect;
|
|
||||||
pRect->VMargin(5.0f, &Rect);
|
|
||||||
UI()->DoLabel(&Rect, pText, 10.0f, TEXTALIGN_ML);
|
|
||||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CEditor::DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
|
|
||||||
{
|
|
||||||
pRect->Draw(ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f), IGraphics::CORNER_T, 3.0f);
|
|
||||||
|
|
||||||
CUIRect Rect;
|
|
||||||
pRect->VMargin(5.0f, &Rect);
|
|
||||||
UI()->DoLabel(&Rect, pText, 10.0f, TEXTALIGN_ML);
|
|
||||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CEditor::DoButton_MenuItem(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
|
int CEditor::DoButton_MenuItem(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
|
||||||
{
|
{
|
||||||
if(UI()->HotItem() == pID || Checked)
|
if(UI()->HotItem() == pID || Checked)
|
||||||
|
@ -255,17 +234,17 @@ int CEditor::DoButton_MenuItem(const void *pID, const char *pText, int Checked,
|
||||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CEditor::DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize)
|
int CEditor::DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize, int Align)
|
||||||
{
|
{
|
||||||
pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f);
|
pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f);
|
||||||
|
|
||||||
CUIRect Rect;
|
CUIRect Rect;
|
||||||
pRect->VMargin(pRect->w > 20.0f ? 5.0f : 0.0f, &Rect);
|
pRect->VMargin(((Align & TEXTALIGN_MASK_HORIZONTAL) == TEXTALIGN_CENTER) ? 1.0f : 5.0f, &Rect);
|
||||||
|
|
||||||
SLabelProperties Props;
|
SLabelProperties Props;
|
||||||
Props.m_MaxWidth = Rect.w;
|
Props.m_MaxWidth = Rect.w;
|
||||||
Props.m_EllipsisAtEnd = true;
|
Props.m_EllipsisAtEnd = true;
|
||||||
UI()->DoLabel(&Rect, pText, FontSize, TEXTALIGN_MC, Props);
|
UI()->DoLabel(&Rect, pText, FontSize, Align, Props);
|
||||||
|
|
||||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
||||||
}
|
}
|
||||||
|
@ -283,20 +262,6 @@ int CEditor::DoButton_FontIcon(const void *pID, const char *pText, int Checked,
|
||||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CEditor::DoButton_ButtonInc(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
|
|
||||||
{
|
|
||||||
pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_R, 3.0f);
|
|
||||||
UI()->DoLabel(pRect, pText ? pText : "+", 10.0f, TEXTALIGN_MC);
|
|
||||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CEditor::DoButton_ButtonDec(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
|
|
||||||
{
|
|
||||||
pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_L, 3.0f);
|
|
||||||
UI()->DoLabel(pRect, pText ? pText : "-", 10.0f, TEXTALIGN_MC);
|
|
||||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CEditor::DoButton_DraggableEx(const void *pID, const char *pText, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted, int Flags, const char *pToolTip, int Corners, float FontSize)
|
int CEditor::DoButton_DraggableEx(const void *pID, const char *pText, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted, int Flags, const char *pToolTip, int Corners, float FontSize)
|
||||||
{
|
{
|
||||||
pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f);
|
pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f);
|
||||||
|
@ -1288,7 +1253,7 @@ void CEditor::DoToolbarLayers(CUIRect ToolBar)
|
||||||
{
|
{
|
||||||
// refocus button
|
// refocus button
|
||||||
{
|
{
|
||||||
TB_Bottom.VSplitLeft(45.0f, &Button, &TB_Bottom);
|
TB_Bottom.VSplitLeft(50.0f, &Button, &TB_Bottom);
|
||||||
static int s_RefocusButton = 0;
|
static int s_RefocusButton = 0;
|
||||||
int FocusButtonChecked = MapView()->IsFocused() ? -1 : 1;
|
int FocusButtonChecked = MapView()->IsFocused() ? -1 : 1;
|
||||||
if(DoButton_Editor(&s_RefocusButton, "Refocus", FocusButtonChecked, &Button, 0, "[HOME] Restore map focus") || (m_Dialog == DIALOG_NONE && CLineInput::GetActiveInput() == nullptr && Input()->KeyPress(KEY_HOME)))
|
if(DoButton_Editor(&s_RefocusButton, "Refocus", FocusButtonChecked, &Button, 0, "[HOME] Restore map focus") || (m_Dialog == DIALOG_NONE && CLineInput::GetActiveInput() == nullptr && Input()->KeyPress(KEY_HOME)))
|
||||||
|
@ -6252,7 +6217,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
||||||
ToolBar.VSplitRight(5.0f, &ToolBar, nullptr);
|
ToolBar.VSplitRight(5.0f, &ToolBar, nullptr);
|
||||||
ToolBar.VSplitRight(20.0f, &ToolBar, &Button);
|
ToolBar.VSplitRight(20.0f, &ToolBar, &Button);
|
||||||
static int s_ZoomOutButton = 0;
|
static int s_ZoomOutButton = 0;
|
||||||
if(DoButton_FontIcon(&s_ZoomOutButton, "-", 0, &Button, 0, "[NumPad-] Zoom out horizontally, hold shift to zoom vertically", IGraphics::CORNER_R, 9.0f))
|
if(DoButton_FontIcon(&s_ZoomOutButton, FONT_ICON_MINUS, 0, &Button, 0, "[NumPad-] Zoom out horizontally, hold shift to zoom vertically", IGraphics::CORNER_R, 9.0f))
|
||||||
{
|
{
|
||||||
if(Input()->ShiftIsPressed())
|
if(Input()->ShiftIsPressed())
|
||||||
m_ZoomEnvelopeY.ChangeValue(0.1f * m_ZoomEnvelopeY.GetValue());
|
m_ZoomEnvelopeY.ChangeValue(0.1f * m_ZoomEnvelopeY.GetValue());
|
||||||
|
@ -6267,7 +6232,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
||||||
|
|
||||||
ToolBar.VSplitRight(20.0f, &ToolBar, &Button);
|
ToolBar.VSplitRight(20.0f, &ToolBar, &Button);
|
||||||
static int s_ZoomInButton = 0;
|
static int s_ZoomInButton = 0;
|
||||||
if(DoButton_FontIcon(&s_ZoomInButton, "+", 0, &Button, 0, "[NumPad+] Zoom in horizontally, hold shift to zoom vertically", IGraphics::CORNER_L, 9.0f))
|
if(DoButton_FontIcon(&s_ZoomInButton, FONT_ICON_PLUS, 0, &Button, 0, "[NumPad+] Zoom in horizontally, hold shift to zoom vertically", IGraphics::CORNER_L, 9.0f))
|
||||||
{
|
{
|
||||||
if(Input()->ShiftIsPressed())
|
if(Input()->ShiftIsPressed())
|
||||||
m_ZoomEnvelopeY.ChangeValue(-0.1f * m_ZoomEnvelopeY.GetValue());
|
m_ZoomEnvelopeY.ChangeValue(-0.1f * m_ZoomEnvelopeY.GetValue());
|
||||||
|
@ -6319,7 +6284,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int s_PrevButton = 0;
|
static int s_PrevButton = 0;
|
||||||
if(DoButton_ButtonDec(&s_PrevButton, nullptr, 0, &Dec, 0, "Previous Envelope"))
|
if(DoButton_FontIcon(&s_PrevButton, FONT_ICON_MINUS, 0, &Dec, 0, "Previous Envelope", IGraphics::CORNER_L, 7.0f))
|
||||||
{
|
{
|
||||||
m_SelectedEnvelope--;
|
m_SelectedEnvelope--;
|
||||||
if(m_SelectedEnvelope < 0)
|
if(m_SelectedEnvelope < 0)
|
||||||
|
@ -6328,7 +6293,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int s_NextButton = 0;
|
static int s_NextButton = 0;
|
||||||
if(DoButton_ButtonInc(&s_NextButton, nullptr, 0, &Inc, 0, "Next Envelope"))
|
if(DoButton_FontIcon(&s_NextButton, FONT_ICON_PLUS, 0, &Inc, 0, "Next Envelope", IGraphics::CORNER_R, 7.0f))
|
||||||
{
|
{
|
||||||
m_SelectedEnvelope++;
|
m_SelectedEnvelope++;
|
||||||
if(m_SelectedEnvelope >= (int)m_Map.m_vpEnvelopes.size())
|
if(m_SelectedEnvelope >= (int)m_Map.m_vpEnvelopes.size())
|
||||||
|
@ -7679,7 +7644,7 @@ void CEditor::RenderMenubar(CUIRect MenuBar)
|
||||||
CUIRect FileButton;
|
CUIRect FileButton;
|
||||||
static int s_FileButton = 0;
|
static int s_FileButton = 0;
|
||||||
MenuBar.VSplitLeft(60.0f, &FileButton, &MenuBar);
|
MenuBar.VSplitLeft(60.0f, &FileButton, &MenuBar);
|
||||||
if(DoButton_Menu(&s_FileButton, "File", 0, &FileButton, 0, nullptr))
|
if(DoButton_Ex(&s_FileButton, "File", 0, &FileButton, 0, nullptr, IGraphics::CORNER_T, EditorFontSizes::MENU, TEXTALIGN_ML))
|
||||||
{
|
{
|
||||||
static SPopupMenuId s_PopupMenuFileId;
|
static SPopupMenuId s_PopupMenuFileId;
|
||||||
UI()->DoPopupMenu(&s_PopupMenuFileId, FileButton.x, FileButton.y + FileButton.h - 1.0f, 120.0f, 174.0f, this, PopupMenuFile, PopupProperties);
|
UI()->DoPopupMenu(&s_PopupMenuFileId, FileButton.x, FileButton.y + FileButton.h - 1.0f, 120.0f, 174.0f, this, PopupMenuFile, PopupProperties);
|
||||||
|
@ -7690,7 +7655,7 @@ void CEditor::RenderMenubar(CUIRect MenuBar)
|
||||||
CUIRect ToolsButton;
|
CUIRect ToolsButton;
|
||||||
static int s_ToolsButton = 0;
|
static int s_ToolsButton = 0;
|
||||||
MenuBar.VSplitLeft(60.0f, &ToolsButton, &MenuBar);
|
MenuBar.VSplitLeft(60.0f, &ToolsButton, &MenuBar);
|
||||||
if(DoButton_Menu(&s_ToolsButton, "Tools", 0, &ToolsButton, 0, nullptr))
|
if(DoButton_Ex(&s_ToolsButton, "Tools", 0, &ToolsButton, 0, nullptr, IGraphics::CORNER_T, EditorFontSizes::MENU, TEXTALIGN_ML))
|
||||||
{
|
{
|
||||||
static SPopupMenuId s_PopupMenuToolsId;
|
static SPopupMenuId s_PopupMenuToolsId;
|
||||||
UI()->DoPopupMenu(&s_PopupMenuToolsId, ToolsButton.x, ToolsButton.y + ToolsButton.h - 1.0f, 200.0f, 64.0f, this, PopupMenuTools, PopupProperties);
|
UI()->DoPopupMenu(&s_PopupMenuToolsId, ToolsButton.x, ToolsButton.y + ToolsButton.h - 1.0f, 200.0f, 64.0f, this, PopupMenuTools, PopupProperties);
|
||||||
|
@ -7701,7 +7666,7 @@ void CEditor::RenderMenubar(CUIRect MenuBar)
|
||||||
CUIRect SettingsButton;
|
CUIRect SettingsButton;
|
||||||
static int s_SettingsButton = 0;
|
static int s_SettingsButton = 0;
|
||||||
MenuBar.VSplitLeft(60.0f, &SettingsButton, &MenuBar);
|
MenuBar.VSplitLeft(60.0f, &SettingsButton, &MenuBar);
|
||||||
if(DoButton_Menu(&s_SettingsButton, "Settings", 0, &SettingsButton, 0, nullptr))
|
if(DoButton_Ex(&s_SettingsButton, "Settings", 0, &SettingsButton, 0, nullptr, IGraphics::CORNER_T, EditorFontSizes::MENU, TEXTALIGN_ML))
|
||||||
{
|
{
|
||||||
static SPopupMenuId s_PopupMenuEntitiesId;
|
static SPopupMenuId s_PopupMenuEntitiesId;
|
||||||
UI()->DoPopupMenu(&s_PopupMenuEntitiesId, SettingsButton.x, SettingsButton.y + SettingsButton.h - 1.0f, 200.0f, 92.0f, this, PopupMenuSettings, PopupProperties);
|
UI()->DoPopupMenu(&s_PopupMenuEntitiesId, SettingsButton.x, SettingsButton.y + SettingsButton.h - 1.0f, 200.0f, 92.0f, this, PopupMenuSettings, PopupProperties);
|
||||||
|
|
|
@ -827,14 +827,8 @@ public:
|
||||||
int DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
|
int DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
|
||||||
int DoButton_Env(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pToolTip, ColorRGBA Color, int Corners);
|
int DoButton_Env(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pToolTip, ColorRGBA Color, int Corners);
|
||||||
|
|
||||||
int DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize = 10.0f);
|
int DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize = EditorFontSizes::MENU, int Align = TEXTALIGN_MC);
|
||||||
int DoButton_FontIcon(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize = 10.0f);
|
int DoButton_FontIcon(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize = 10.0f);
|
||||||
int DoButton_ButtonDec(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
|
|
||||||
int DoButton_ButtonInc(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
|
|
||||||
|
|
||||||
int DoButton_File(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
|
|
||||||
|
|
||||||
int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
|
|
||||||
int DoButton_MenuItem(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags = 0, const char *pToolTip = nullptr);
|
int DoButton_MenuItem(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags = 0, const char *pToolTip = nullptr);
|
||||||
|
|
||||||
int DoButton_DraggableEx(const void *pID, const char *pText, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted, int Flags, const char *pToolTip = nullptr, int Corners = IGraphics::CORNER_ALL, float FontSize = 10.0f);
|
int DoButton_DraggableEx(const void *pID, const char *pText, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted, int Flags, const char *pToolTip = nullptr, int Corners = IGraphics::CORNER_ALL, float FontSize = 10.0f);
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
|
|
||||||
|
#include <engine/textrender.h>
|
||||||
|
|
||||||
#include <game/editor/mapitems/image.h>
|
#include <game/editor/mapitems/image.h>
|
||||||
#include <game/editor/mapitems/sound.h>
|
#include <game/editor/mapitems/sound.h>
|
||||||
|
|
||||||
|
using namespace FontIcons;
|
||||||
|
|
||||||
const ColorRGBA CEditor::ms_DefaultPropColor = ColorRGBA(1, 1, 1, 0.5f);
|
const ColorRGBA CEditor::ms_DefaultPropColor = ColorRGBA(1, 1, 1, 0.5f);
|
||||||
|
|
||||||
int CEditor::DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, const std::vector<ColorRGBA> &vColors)
|
int CEditor::DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, const std::vector<ColorRGBA> &vColors)
|
||||||
|
@ -44,13 +48,13 @@ SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pPro
|
||||||
Change = i;
|
Change = i;
|
||||||
State = NewValueRes.m_State;
|
State = NewValueRes.m_State;
|
||||||
}
|
}
|
||||||
if(DoButton_ButtonDec((char *)&pIDs[i] + 1, nullptr, 0, &Dec, 0, "Decrease"))
|
if(DoButton_FontIcon((char *)&pIDs[i] + 1, FONT_ICON_MINUS, 0, &Dec, 0, "Decrease", IGraphics::CORNER_L, 7.0f))
|
||||||
{
|
{
|
||||||
*pNewVal = pProps[i].m_Value - 1;
|
*pNewVal = pProps[i].m_Value - 1;
|
||||||
Change = i;
|
Change = i;
|
||||||
State = EEditState::ONE_GO;
|
State = EEditState::ONE_GO;
|
||||||
}
|
}
|
||||||
if(DoButton_ButtonInc(((char *)&pIDs[i]) + 2, nullptr, 0, &Inc, 0, "Increase"))
|
if(DoButton_FontIcon(((char *)&pIDs[i]) + 2, FONT_ICON_PLUS, 0, &Inc, 0, "Increase", IGraphics::CORNER_R, 7.0f))
|
||||||
{
|
{
|
||||||
*pNewVal = pProps[i].m_Value + 1;
|
*pNewVal = pProps[i].m_Value + 1;
|
||||||
Change = i;
|
Change = i;
|
||||||
|
@ -61,13 +65,13 @@ SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pPro
|
||||||
{
|
{
|
||||||
CUIRect No, Yes;
|
CUIRect No, Yes;
|
||||||
Shifter.VSplitMid(&No, &Yes);
|
Shifter.VSplitMid(&No, &Yes);
|
||||||
if(DoButton_ButtonDec(&pIDs[i], "No", !pProps[i].m_Value, &No, 0, ""))
|
if(DoButton_Ex(&pIDs[i], "No", !pProps[i].m_Value, &No, 0, "", IGraphics::CORNER_L))
|
||||||
{
|
{
|
||||||
*pNewVal = 0;
|
*pNewVal = 0;
|
||||||
Change = i;
|
Change = i;
|
||||||
State = EEditState::ONE_GO;
|
State = EEditState::ONE_GO;
|
||||||
}
|
}
|
||||||
if(DoButton_ButtonInc(((char *)&pIDs[i]) + 1, "Yes", pProps[i].m_Value, &Yes, 0, ""))
|
if(DoButton_Ex(((char *)&pIDs[i]) + 1, "Yes", pProps[i].m_Value, &Yes, 0, "", IGraphics::CORNER_R))
|
||||||
{
|
{
|
||||||
*pNewVal = 1;
|
*pNewVal = 1;
|
||||||
Change = i;
|
Change = i;
|
||||||
|
@ -85,14 +89,14 @@ SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pPro
|
||||||
|
|
||||||
auto NewValueRes = UiDoValueSelector(&pIDs[i], &Shifter, "", Value, pProps[i].m_Min, pProps[i].m_Max, Shift ? 1 : 45, Shift ? 1.0f : 10.0f, "Use left mouse button to drag and change the value. Hold shift to be more precise. Rightclick to edit as text.", false, false, 0);
|
auto NewValueRes = UiDoValueSelector(&pIDs[i], &Shifter, "", Value, pProps[i].m_Min, pProps[i].m_Max, Shift ? 1 : 45, Shift ? 1.0f : 10.0f, "Use left mouse button to drag and change the value. Hold shift to be more precise. Rightclick to edit as text.", false, false, 0);
|
||||||
int NewValue = NewValueRes.m_Value;
|
int NewValue = NewValueRes.m_Value;
|
||||||
if(DoButton_ButtonDec(&pIDs[i] + 1, nullptr, 0, &Dec, 0, "Decrease"))
|
if(DoButton_FontIcon(&pIDs[i] + 1, FONT_ICON_MINUS, 0, &Dec, 0, "Decrease", IGraphics::CORNER_L, 7.0f))
|
||||||
{
|
{
|
||||||
NewValue = (std::ceil((pProps[i].m_Value / (float)Step)) - 1) * Step;
|
NewValue = (std::ceil((pProps[i].m_Value / (float)Step)) - 1) * Step;
|
||||||
if(NewValue < 0)
|
if(NewValue < 0)
|
||||||
NewValue += 360;
|
NewValue += 360;
|
||||||
State = EEditState::ONE_GO;
|
State = EEditState::ONE_GO;
|
||||||
}
|
}
|
||||||
if(DoButton_ButtonInc(&pIDs[i] + 2, nullptr, 0, &Inc, 0, "Increase"))
|
if(DoButton_FontIcon(&pIDs[i] + 2, FONT_ICON_PLUS, 0, &Inc, 0, "Increase", IGraphics::CORNER_R, 7.0f))
|
||||||
{
|
{
|
||||||
NewValue = (pProps[i].m_Value + Step) / Step * Step;
|
NewValue = (pProps[i].m_Value + Step) / Step * Step;
|
||||||
State = EEditState::ONE_GO;
|
State = EEditState::ONE_GO;
|
||||||
|
@ -149,25 +153,25 @@ SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pPro
|
||||||
Shifter.VSplitRight(10.0f, &Shifter, &Down);
|
Shifter.VSplitRight(10.0f, &Shifter, &Down);
|
||||||
Shifter.Draw(ColorRGBA(1, 1, 1, 0.5f), IGraphics::CORNER_NONE, 0.0f);
|
Shifter.Draw(ColorRGBA(1, 1, 1, 0.5f), IGraphics::CORNER_NONE, 0.0f);
|
||||||
UI()->DoLabel(&Shifter, "Y", 10.0f, TEXTALIGN_MC);
|
UI()->DoLabel(&Shifter, "Y", 10.0f, TEXTALIGN_MC);
|
||||||
if(DoButton_ButtonDec(&pIDs[i], "-", 0, &Left, 0, "Left"))
|
if(DoButton_FontIcon(&pIDs[i], FONT_ICON_MINUS, 0, &Left, 0, "Left", IGraphics::CORNER_L, 7.0f))
|
||||||
{
|
{
|
||||||
*pNewVal = DIRECTION_LEFT;
|
*pNewVal = DIRECTION_LEFT;
|
||||||
Change = i;
|
Change = i;
|
||||||
State = EEditState::ONE_GO;
|
State = EEditState::ONE_GO;
|
||||||
}
|
}
|
||||||
if(DoButton_ButtonInc(((char *)&pIDs[i]) + 3, "+", 0, &Right, 0, "Right"))
|
if(DoButton_FontIcon(((char *)&pIDs[i]) + 3, FONT_ICON_PLUS, 0, &Right, 0, "Right", IGraphics::CORNER_R, 7.0f))
|
||||||
{
|
{
|
||||||
*pNewVal = DIRECTION_RIGHT;
|
*pNewVal = DIRECTION_RIGHT;
|
||||||
Change = i;
|
Change = i;
|
||||||
State = EEditState::ONE_GO;
|
State = EEditState::ONE_GO;
|
||||||
}
|
}
|
||||||
if(DoButton_ButtonDec(((char *)&pIDs[i]) + 1, "-", 0, &Up, 0, "Up"))
|
if(DoButton_FontIcon(((char *)&pIDs[i]) + 1, FONT_ICON_MINUS, 0, &Up, 0, "Up", IGraphics::CORNER_L, 7.0f))
|
||||||
{
|
{
|
||||||
*pNewVal = DIRECTION_UP;
|
*pNewVal = DIRECTION_UP;
|
||||||
Change = i;
|
Change = i;
|
||||||
State = EEditState::ONE_GO;
|
State = EEditState::ONE_GO;
|
||||||
}
|
}
|
||||||
if(DoButton_ButtonInc(((char *)&pIDs[i]) + 2, "+", 0, &Down, 0, "Down"))
|
if(DoButton_FontIcon(((char *)&pIDs[i]) + 2, FONT_ICON_PLUS, 0, &Down, 0, "Down", IGraphics::CORNER_R, 7.0f))
|
||||||
{
|
{
|
||||||
*pNewVal = DIRECTION_DOWN;
|
*pNewVal = DIRECTION_DOWN;
|
||||||
Change = i;
|
Change = i;
|
||||||
|
@ -244,13 +248,13 @@ SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pPro
|
||||||
State = NewValueRes.m_State;
|
State = NewValueRes.m_State;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DoButton_ButtonDec((char *)&pIDs[i] + 1, nullptr, 0, &Dec, 0, "Previous Envelope"))
|
if(DoButton_FontIcon((char *)&pIDs[i] + 1, FONT_ICON_MINUS, 0, &Dec, 0, "Previous Envelope", IGraphics::CORNER_L, 7.0f))
|
||||||
{
|
{
|
||||||
*pNewVal = pProps[i].m_Value - 1;
|
*pNewVal = pProps[i].m_Value - 1;
|
||||||
Change = i;
|
Change = i;
|
||||||
State = EEditState::ONE_GO;
|
State = EEditState::ONE_GO;
|
||||||
}
|
}
|
||||||
if(DoButton_ButtonInc(((char *)&pIDs[i]) + 2, nullptr, 0, &Inc, 0, "Next Envelope"))
|
if(DoButton_FontIcon(((char *)&pIDs[i]) + 2, FONT_ICON_PLUS, 0, &Inc, 0, "Next Envelope", IGraphics::CORNER_R, 7.0f))
|
||||||
{
|
{
|
||||||
*pNewVal = pProps[i].m_Value + 1;
|
*pNewVal = pProps[i].m_Value + 1;
|
||||||
Change = i;
|
Change = i;
|
||||||
|
|
|
@ -15,4 +15,8 @@ struct SEditBoxDropdownContext
|
||||||
int m_Width = 0;
|
int m_Width = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace EditorFontSizes {
|
||||||
|
MAYBE_UNUSED static constexpr float MENU = 10.0f;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <engine/keys.h>
|
#include <engine/keys.h>
|
||||||
#include <engine/shared/config.h>
|
#include <engine/shared/config.h>
|
||||||
#include <engine/storage.h>
|
#include <engine/storage.h>
|
||||||
|
#include <engine/textrender.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include <game/client/ui_scrollregion.h>
|
#include <game/client/ui_scrollregion.h>
|
||||||
|
@ -18,6 +19,8 @@
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "editor_actions.h"
|
#include "editor_actions.h"
|
||||||
|
|
||||||
|
using namespace FontIcons;
|
||||||
|
|
||||||
CUI::EPopupMenuFunctionResult CEditor::PopupMenuFile(void *pContext, CUIRect View, bool Active)
|
CUI::EPopupMenuFunctionResult CEditor::PopupMenuFile(void *pContext, CUIRect View, bool Active)
|
||||||
{
|
{
|
||||||
CEditor *pEditor = static_cast<CEditor *>(pContext);
|
CEditor *pEditor = static_cast<CEditor *>(pContext);
|
||||||
|
@ -260,11 +263,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMenuSettings(void *pContext, CUIRect
|
||||||
pEditor->UI()->DoLabel(&Label, "Brush coloring", 10.0f, TEXTALIGN_ML);
|
pEditor->UI()->DoLabel(&Label, "Brush coloring", 10.0f, TEXTALIGN_ML);
|
||||||
static int s_ButtonNo = 0;
|
static int s_ButtonNo = 0;
|
||||||
static int s_ButtonYes = 0;
|
static int s_ButtonYes = 0;
|
||||||
if(pEditor->DoButton_ButtonDec(&s_ButtonNo, "No", !pEditor->m_BrushColorEnabled, &No, 0, "Disable brush coloring"))
|
if(pEditor->DoButton_Ex(&s_ButtonNo, "No", !pEditor->m_BrushColorEnabled, &No, 0, "Disable brush coloring", IGraphics::CORNER_L))
|
||||||
{
|
{
|
||||||
pEditor->m_BrushColorEnabled = false;
|
pEditor->m_BrushColorEnabled = false;
|
||||||
}
|
}
|
||||||
if(pEditor->DoButton_ButtonInc(&s_ButtonYes, "Yes", pEditor->m_BrushColorEnabled, &Yes, 0, "Enable brush coloring"))
|
if(pEditor->DoButton_Ex(&s_ButtonYes, "Yes", pEditor->m_BrushColorEnabled, &Yes, 0, "Enable brush coloring", IGraphics::CORNER_R))
|
||||||
{
|
{
|
||||||
pEditor->m_BrushColorEnabled = true;
|
pEditor->m_BrushColorEnabled = true;
|
||||||
}
|
}
|
||||||
|
@ -285,11 +288,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMenuSettings(void *pContext, CUIRect
|
||||||
{
|
{
|
||||||
static int s_ButtonNo = 0;
|
static int s_ButtonNo = 0;
|
||||||
static int s_ButtonYes = 0;
|
static int s_ButtonYes = 0;
|
||||||
if(pEditor->DoButton_ButtonDec(&s_ButtonNo, "No", !pEditor->m_AllowPlaceUnusedTiles, &No, 0, "[ctrl+u] Disallow placing unused tiles"))
|
if(pEditor->DoButton_Ex(&s_ButtonNo, "No", !pEditor->m_AllowPlaceUnusedTiles, &No, 0, "[ctrl+u] Disallow placing unused tiles", IGraphics::CORNER_L))
|
||||||
{
|
{
|
||||||
pEditor->m_AllowPlaceUnusedTiles = false;
|
pEditor->m_AllowPlaceUnusedTiles = false;
|
||||||
}
|
}
|
||||||
if(pEditor->DoButton_ButtonInc(&s_ButtonYes, "Yes", pEditor->m_AllowPlaceUnusedTiles, &Yes, 0, "[ctrl+u] Allow placing unused tiles"))
|
if(pEditor->DoButton_Ex(&s_ButtonYes, "Yes", pEditor->m_AllowPlaceUnusedTiles, &Yes, 0, "[ctrl+u] Allow placing unused tiles", IGraphics::CORNER_R))
|
||||||
{
|
{
|
||||||
pEditor->m_AllowPlaceUnusedTiles = true;
|
pEditor->m_AllowPlaceUnusedTiles = true;
|
||||||
}
|
}
|
||||||
|
@ -311,7 +314,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMenuSettings(void *pContext, CUIRect
|
||||||
static int s_ButtonOff = 0;
|
static int s_ButtonOff = 0;
|
||||||
static int s_ButtonDec = 0;
|
static int s_ButtonDec = 0;
|
||||||
static int s_ButtonHex = 0;
|
static int s_ButtonHex = 0;
|
||||||
if(pEditor->DoButton_ButtonDec(&s_ButtonOff, "Off", pEditor->m_ShowTileInfo == SHOW_TILE_OFF, &Off, 0, "Do not show tile information"))
|
if(pEditor->DoButton_Ex(&s_ButtonOff, "Off", pEditor->m_ShowTileInfo == SHOW_TILE_OFF, &Off, 0, "Do not show tile information", IGraphics::CORNER_L))
|
||||||
{
|
{
|
||||||
pEditor->m_ShowTileInfo = SHOW_TILE_OFF;
|
pEditor->m_ShowTileInfo = SHOW_TILE_OFF;
|
||||||
pEditor->m_ShowEnvelopePreview = SHOWENV_NONE;
|
pEditor->m_ShowEnvelopePreview = SHOWENV_NONE;
|
||||||
|
@ -321,7 +324,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMenuSettings(void *pContext, CUIRect
|
||||||
pEditor->m_ShowTileInfo = SHOW_TILE_DECIMAL;
|
pEditor->m_ShowTileInfo = SHOW_TILE_DECIMAL;
|
||||||
pEditor->m_ShowEnvelopePreview = SHOWENV_NONE;
|
pEditor->m_ShowEnvelopePreview = SHOWENV_NONE;
|
||||||
}
|
}
|
||||||
if(pEditor->DoButton_ButtonInc(&s_ButtonHex, "Hex", pEditor->m_ShowTileInfo == SHOW_TILE_HEXADECIMAL, &Hex, 0, "[ctrl+shift+i] Show tile information in hexadecimal"))
|
if(pEditor->DoButton_Ex(&s_ButtonHex, "Hex", pEditor->m_ShowTileInfo == SHOW_TILE_HEXADECIMAL, &Hex, 0, "[ctrl+shift+i] Show tile information in hexadecimal", IGraphics::CORNER_R))
|
||||||
{
|
{
|
||||||
pEditor->m_ShowTileInfo = SHOW_TILE_HEXADECIMAL;
|
pEditor->m_ShowTileInfo = SHOW_TILE_HEXADECIMAL;
|
||||||
pEditor->m_ShowEnvelopePreview = SHOWENV_NONE;
|
pEditor->m_ShowEnvelopePreview = SHOWENV_NONE;
|
||||||
|
@ -342,11 +345,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMenuSettings(void *pContext, CUIRect
|
||||||
|
|
||||||
static int s_ButtonNo = 0;
|
static int s_ButtonNo = 0;
|
||||||
static int s_ButtonYes = 0;
|
static int s_ButtonYes = 0;
|
||||||
if(pEditor->DoButton_ButtonDec(&s_ButtonNo, "No", !g_Config.m_EdAlignQuads, &No, 0, "Do not perform quad alignment to other quads/points when moving quads"))
|
if(pEditor->DoButton_Ex(&s_ButtonNo, "No", !g_Config.m_EdAlignQuads, &No, 0, "Do not perform quad alignment to other quads/points when moving quads", IGraphics::CORNER_L))
|
||||||
{
|
{
|
||||||
g_Config.m_EdAlignQuads = false;
|
g_Config.m_EdAlignQuads = false;
|
||||||
}
|
}
|
||||||
if(pEditor->DoButton_ButtonInc(&s_ButtonYes, "Yes", g_Config.m_EdAlignQuads, &Yes, 0, "Allow quad alignment to other quads/points when moving quads"))
|
if(pEditor->DoButton_Ex(&s_ButtonYes, "Yes", g_Config.m_EdAlignQuads, &Yes, 0, "Allow quad alignment to other quads/points when moving quads", IGraphics::CORNER_R))
|
||||||
{
|
{
|
||||||
g_Config.m_EdAlignQuads = true;
|
g_Config.m_EdAlignQuads = true;
|
||||||
}
|
}
|
||||||
|
@ -366,11 +369,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMenuSettings(void *pContext, CUIRect
|
||||||
|
|
||||||
static int s_ButtonNo = 0;
|
static int s_ButtonNo = 0;
|
||||||
static int s_ButtonYes = 0;
|
static int s_ButtonYes = 0;
|
||||||
if(pEditor->DoButton_ButtonDec(&s_ButtonNo, "No", !g_Config.m_EdShowQuadsRect, &No, 0, "Do not show quad bounds when moving quads"))
|
if(pEditor->DoButton_Ex(&s_ButtonNo, "No", !g_Config.m_EdShowQuadsRect, &No, 0, "Do not show quad bounds when moving quads", IGraphics::CORNER_L))
|
||||||
{
|
{
|
||||||
g_Config.m_EdShowQuadsRect = false;
|
g_Config.m_EdShowQuadsRect = false;
|
||||||
}
|
}
|
||||||
if(pEditor->DoButton_ButtonInc(&s_ButtonYes, "Yes", g_Config.m_EdShowQuadsRect, &Yes, 0, "Show quad bounds when moving quads"))
|
if(pEditor->DoButton_Ex(&s_ButtonYes, "Yes", g_Config.m_EdShowQuadsRect, &Yes, 0, "Show quad bounds when moving quads", IGraphics::CORNER_R))
|
||||||
{
|
{
|
||||||
g_Config.m_EdShowQuadsRect = true;
|
g_Config.m_EdShowQuadsRect = true;
|
||||||
}
|
}
|
||||||
|
@ -2829,7 +2832,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupAnimateSettings(void *pContext, CUIR
|
||||||
pEditor->UI()->DoLabel(&Label, "Speed", 10.0f, TEXTALIGN_ML);
|
pEditor->UI()->DoLabel(&Label, "Speed", 10.0f, TEXTALIGN_ML);
|
||||||
|
|
||||||
static char s_DecreaseButton;
|
static char s_DecreaseButton;
|
||||||
if(pEditor->DoButton_Ex(&s_DecreaseButton, "-", 0, &ButtonDecrease, 0, "Decrease animation speed", IGraphics::CORNER_L))
|
if(pEditor->DoButton_FontIcon(&s_DecreaseButton, FONT_ICON_MINUS, 0, &ButtonDecrease, 0, "Decrease animation speed", IGraphics::CORNER_L, 7.0f))
|
||||||
{
|
{
|
||||||
pEditor->m_AnimateSpeed -= pEditor->m_AnimateSpeed <= 1.0f ? 0.1f : 0.5f;
|
pEditor->m_AnimateSpeed -= pEditor->m_AnimateSpeed <= 1.0f ? 0.1f : 0.5f;
|
||||||
pEditor->m_AnimateSpeed = maximum(pEditor->m_AnimateSpeed, MIN_ANIM_SPEED);
|
pEditor->m_AnimateSpeed = maximum(pEditor->m_AnimateSpeed, MIN_ANIM_SPEED);
|
||||||
|
@ -2837,7 +2840,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupAnimateSettings(void *pContext, CUIR
|
||||||
}
|
}
|
||||||
|
|
||||||
static char s_IncreaseButton;
|
static char s_IncreaseButton;
|
||||||
if(pEditor->DoButton_Ex(&s_IncreaseButton, "+", 0, &ButtonIncrease, 0, "Increase animation speed", IGraphics::CORNER_R))
|
if(pEditor->DoButton_FontIcon(&s_IncreaseButton, FONT_ICON_PLUS, 0, &ButtonIncrease, 0, "Increase animation speed", IGraphics::CORNER_R, 7.0f))
|
||||||
{
|
{
|
||||||
if(pEditor->m_AnimateSpeed < 0.1f)
|
if(pEditor->m_AnimateSpeed < 0.1f)
|
||||||
pEditor->m_AnimateSpeed = 0.1f;
|
pEditor->m_AnimateSpeed = 0.1f;
|
||||||
|
|
Loading…
Reference in a new issue