5998: Fix Ctrl+F hotkey not checking for Ctrl key, minor improvement to tile details popup layout r=def- a=Robyt3


## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
bors[bot] 2022-11-01 22:10:19 +00:00 committed by GitHub
commit e71ce8fcde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 38 deletions

View file

@ -1112,15 +1112,10 @@ void CEditor::DoToolbar(CUIRect ToolBar)
// tile manipulation // tile manipulation
{ {
static int s_BorderBut = 0;
CLayerTiles *pT = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES); CLayerTiles *pT = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES);
if(pT && !pT->m_Tele && !pT->m_Speedup && !pT->m_Switch && !pT->m_Front && !pT->m_Tune)
// no border for tele layer, speedup, front and switch
if(pT && (pT->m_Tele || pT->m_Speedup || pT->m_Switch || pT->m_Front || pT->m_Tune))
pT = nullptr;
if(pT)
{ {
static int s_BorderBut = 0;
TB_Bottom.VSplitLeft(60.0f, &Button, &TB_Bottom); TB_Bottom.VSplitLeft(60.0f, &Button, &TB_Bottom);
if(DoButton_Ex(&s_BorderBut, "Border", 0, &Button, 0, "Place tiles in a 2-tile wide border at the edges of the layer", IGraphics::CORNER_ALL)) if(DoButton_Ex(&s_BorderBut, "Border", 0, &Button, 0, "Place tiles in a 2-tile wide border at the edges of the layer", IGraphics::CORNER_ALL))
{ {
@ -1132,35 +1127,35 @@ void CEditor::DoToolbar(CUIRect ToolBar)
// do tele/tune/switch/speedup button // do tele/tune/switch/speedup button
{ {
int (*pPopupFunc)(CEditor * peditor, CUIRect View, void *pContext) = nullptr;
const char *pButtonName = nullptr;
float Height = 0.0f;
CLayerTiles *pS = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES); CLayerTiles *pS = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES);
if(pS) if(pS)
{ {
const char *pButtonName = nullptr;
int (*pfnPopupFunc)(CEditor * pEditor, CUIRect View, void *pContext) = nullptr;
int Rows = 0;
if(pS == m_Map.m_pSwitchLayer) if(pS == m_Map.m_pSwitchLayer)
{ {
pButtonName = "Switch"; pButtonName = "Switch";
pPopupFunc = PopupSwitch; pfnPopupFunc = PopupSwitch;
Height = 36; Rows = 2;
} }
else if(pS == m_Map.m_pSpeedupLayer) else if(pS == m_Map.m_pSpeedupLayer)
{ {
pButtonName = "Speedup"; pButtonName = "Speedup";
pPopupFunc = PopupSpeedup; pfnPopupFunc = PopupSpeedup;
Height = 53; Rows = 3;
} }
else if(pS == m_Map.m_pTuneLayer) else if(pS == m_Map.m_pTuneLayer)
{ {
pButtonName = "Tune"; pButtonName = "Tune";
pPopupFunc = PopupTune; pfnPopupFunc = PopupTune;
Height = 23; Rows = 1;
} }
else if(pS == m_Map.m_pTeleLayer) else if(pS == m_Map.m_pTeleLayer)
{ {
pButtonName = "Tele"; pButtonName = "Tele";
pPopupFunc = PopupTele; pfnPopupFunc = PopupTele;
Height = 23; Rows = 1;
} }
if(pButtonName != nullptr) if(pButtonName != nullptr)
@ -1175,7 +1170,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
static int s_ModifierPopupID = 0; static int s_ModifierPopupID = 0;
if(!UiPopupExists(&s_ModifierPopupID)) if(!UiPopupExists(&s_ModifierPopupID))
{ {
UiInvokePopupMenu(&s_ModifierPopupID, 0, Button.x, Button.y + Button.h, 120, Height, pPopupFunc); UiInvokePopupMenu(&s_ModifierPopupID, 0, Button.x, Button.y + Button.h, 120, 10.0f + Rows * 13.0f, pfnPopupFunc);
} }
} }
TB_Bottom.VSplitLeft(5.0f, nullptr, &TB_Bottom); TB_Bottom.VSplitLeft(5.0f, nullptr, &TB_Bottom);

View file

@ -1508,11 +1508,13 @@ int CEditor::PopupTele(CEditor *pEditor, CUIRect View, void *pContext)
View.VSplitRight(15.f, &NumberPicker, &FindEmptySlot); View.VSplitRight(15.f, &NumberPicker, &FindEmptySlot);
NumberPicker.VSplitRight(2.f, &NumberPicker, nullptr); NumberPicker.VSplitRight(2.f, &NumberPicker, nullptr);
FindEmptySlot.HSplitTop(13.0f, &FindEmptySlot, nullptr);
FindEmptySlot.HMargin(1.0f, &FindEmptySlot);
// find empty number button // find empty number button
{ {
static int s_EmptySlotPid = 0; static int s_EmptySlotPid = 0;
if(pEditor->DoButton_Editor(&s_EmptySlotPid, "F", 0, &FindEmptySlot, 0, "[ctrl+f] Find empty slot") || pEditor->Input()->KeyPress(KEY_F)) if(pEditor->DoButton_Editor(&s_EmptySlotPid, "F", 0, &FindEmptySlot, 0, "[ctrl+f] Find empty slot") || (pEditor->Input()->ModifierIsPressed() && pEditor->Input()->KeyPress(KEY_F)))
{ {
int number = -1; int number = -1;
for(int i = 1; i <= 255; i++) for(int i = 1; i <= 255; i++)
@ -1567,9 +1569,6 @@ int CEditor::PopupTele(CEditor *pEditor, CUIRect View, void *pContext)
int CEditor::PopupSpeedup(CEditor *pEditor, CUIRect View, void *pContext) int CEditor::PopupSpeedup(CEditor *pEditor, CUIRect View, void *pContext)
{ {
CUIRect Button;
View.HSplitBottom(12.0f, &View, &Button);
enum enum
{ {
PROP_FORCE = 0, PROP_FORCE = 0,
@ -1606,16 +1605,15 @@ int CEditor::PopupSwitch(CEditor *pEditor, CUIRect View, void *pContext)
CUIRect NumberPicker; CUIRect NumberPicker;
CUIRect FindEmptySlot; CUIRect FindEmptySlot;
CUIRect DelayPicker; View.VSplitRight(15.f, &NumberPicker, &FindEmptySlot);
View.HSplitMid(&NumberPicker, &DelayPicker);
NumberPicker.VSplitRight(15.f, &NumberPicker, &FindEmptySlot);
NumberPicker.VSplitRight(2.f, &NumberPicker, nullptr); NumberPicker.VSplitRight(2.f, &NumberPicker, nullptr);
FindEmptySlot.HSplitTop(13.0f, &FindEmptySlot, nullptr);
FindEmptySlot.HMargin(1.0f, &FindEmptySlot);
// find empty number button // find empty number button
{ {
static int s_EmptySlotPid = 0; static int s_EmptySlotPid = 0;
if(pEditor->DoButton_Editor(&s_EmptySlotPid, "F", 0, &FindEmptySlot, 0, "[ctrl+f] Find empty slot") || pEditor->Input()->KeyPress(KEY_F)) if(pEditor->DoButton_Editor(&s_EmptySlotPid, "F", 0, &FindEmptySlot, 0, "[ctrl+f] Find empty slot") || (pEditor->Input()->ModifierIsPressed() && pEditor->Input()->KeyPress(KEY_F)))
{ {
int number = -1; int number = -1;
for(int i = 1; i <= 255; i++) for(int i = 1; i <= 255; i++)
@ -1676,9 +1674,6 @@ int CEditor::PopupSwitch(CEditor *pEditor, CUIRect View, void *pContext)
int CEditor::PopupTune(CEditor *pEditor, CUIRect View, void *pContext) int CEditor::PopupTune(CEditor *pEditor, CUIRect View, void *pContext)
{ {
CUIRect Button;
View.HSplitBottom(12.0f, &View, &Button);
enum enum
{ {
PROP_TUNE = 0, PROP_TUNE = 0,
@ -1702,12 +1697,6 @@ int CEditor::PopupTune(CEditor *pEditor, CUIRect View, void *pContext)
int CEditor::PopupGoto(CEditor *pEditor, CUIRect View, void *pContext) int CEditor::PopupGoto(CEditor *pEditor, CUIRect View, void *pContext)
{ {
CUIRect CoordXPicker;
CUIRect CoordYPicker;
View.HSplitMid(&CoordXPicker, &CoordYPicker);
CoordXPicker.VSplitRight(2.f, &CoordXPicker, nullptr);
static ColorRGBA s_Color = ColorRGBA(1, 1, 1, 0.5f); static ColorRGBA s_Color = ColorRGBA(1, 1, 1, 0.5f);
enum enum
@ -1725,7 +1714,7 @@ int CEditor::PopupGoto(CEditor *pEditor, CUIRect View, void *pContext)
static int s_aIds[NUM_PROPS] = {0}; static int s_aIds[NUM_PROPS] = {0};
int NewVal = 0; int NewVal = 0;
int Prop = pEditor->DoProperties(&CoordXPicker, aProps, s_aIds, &NewVal, s_Color); int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal, s_Color);
if(Prop == PROP_CoordX) if(Prop == PROP_CoordX)
{ {