4381: Fix enter behavior when creating new folder in editor r=edg-l a=def-

As reported by louis:

> pressing enter while creating a new folder in the editor (while using
> "save as") does not create the folder but instead enters the selected
> folder in the background

<!-- What is the motivation for the changes of this pull request -->

## 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 if it works standalone, system.c especially
- [ ] 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)


4382: Fix save typing when server settings are open in editor r=edg-l a=def-

As reported by louis:

> while saving a mapname while having the "Server Settings" tab open,
> pressing "m" while typing the mapname will unfocus the cursor from the
> mapname field onto the server settings field

<!-- What is the motivation for the changes of this pull request -->

## 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 if it works standalone, system.c especially
- [ ] 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)


4387: Don't access switchers out of bounds (fixes #4386) r=edg-l a=def-

It's possible that a map was saved with a different amount of switchers
than it has at the moment. Happened on Jao Shooter. I'll check with
mapper if they changed the number of switchers.

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] 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: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2021-11-24 11:57:19 +00:00 committed by GitHub
commit 2376de500d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 9 deletions

View file

@ -47,7 +47,7 @@ CUI::CUI()
m_pHotItem = 0;
m_pActiveItem = 0;
m_pLastActiveItem = 0;
m_pBecommingHotItem = 0;
m_pBecomingHotItem = 0;
m_MouseX = 0;
m_MouseY = 0;
@ -128,10 +128,10 @@ int CUI::Update(float Mx, float My, float Mwx, float Mwy, int Buttons)
m_MouseWorldY = Mwy;
m_LastMouseButtons = m_MouseButtons;
m_MouseButtons = Buttons;
m_pHotItem = m_pBecommingHotItem;
m_pHotItem = m_pBecomingHotItem;
if(m_pActiveItem)
m_pHotItem = m_pActiveItem;
m_pBecommingHotItem = 0;
m_pBecomingHotItem = 0;
return 0;
}

View file

@ -180,7 +180,7 @@ class CUI
const void *m_pHotItem;
const void *m_pActiveItem;
const void *m_pLastActiveItem;
const void *m_pBecommingHotItem;
const void *m_pBecomingHotItem;
float m_MouseX, m_MouseY; // in gui space
float m_MouseDeltaX, m_MouseDeltaY; // in gui space
float m_MouseWorldX, m_MouseWorldY; // in world space
@ -243,7 +243,7 @@ public:
int MouseButtonClicked(int Index) const { return MouseButton(Index) && !((m_LastMouseButtons >> Index) & 1); }
int MouseButtonReleased(int Index) const { return ((m_LastMouseButtons >> Index) & 1) && !MouseButton(Index); }
void SetHotItem(const void *pID) { m_pBecommingHotItem = pID; }
void SetHotItem(const void *pID) { m_pBecomingHotItem = pID; }
void SetActiveItem(const void *pID)
{
m_pActiveItem = pID;
@ -252,7 +252,7 @@ public:
}
void ClearLastActiveItem() { m_pLastActiveItem = 0; }
const void *HotItem() const { return m_pHotItem; }
const void *NextHotItem() const { return m_pBecommingHotItem; }
const void *NextHotItem() const { return m_pBecomingHotItem; }
const void *ActiveItem() const { return m_pActiveItem; }
const void *LastActiveItem() const { return m_pLastActiveItem; }

View file

@ -4248,6 +4248,9 @@ void CEditor::RenderFileDialog()
str_copy(&m_aFileDialogFileName[i], &m_aFileDialogFileName[i + 1], (int)(sizeof(m_aFileDialogFileName)) - i);
m_FilesSelectedIndex = -1;
}
if(m_FileDialogOpening)
UI()->SetActiveItem(&s_FileBoxID);
}
else
{
@ -4403,7 +4406,7 @@ void CEditor::RenderFileDialog()
for(int i = 0; i < Input()->NumEvents(); i++)
{
if(Input()->GetEvent(i).m_Flags & IInput::FLAG_PRESS)
if(Input()->GetEvent(i).m_Flags & IInput::FLAG_PRESS && !UiPopupOpen() && !m_PopupEventActivated)
{
if(Input()->GetEvent(i).m_Key == KEY_RETURN || Input()->GetEvent(i).m_Key == KEY_KP_ENTER)
m_FileDialogActivate = true;

View file

@ -995,7 +995,7 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View, void *pContext)
ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar);
ButtonBar.VSplitLeft(110.0f, &Label, &ButtonBar);
static int s_CreateButton = 0;
if(pEditor->DoButton_Editor(&s_CreateButton, "Create", 0, &Label, 0, 0))
if(pEditor->DoButton_Editor(&s_CreateButton, "Create", 0, &Label, 0, 0) || pEditor->Input()->KeyPress(KEY_RETURN) || pEditor->Input()->KeyPress(KEY_KP_ENTER))
{
// create the folder
if(*pEditor->m_FileDialogNewFolderName)

View file

@ -528,7 +528,7 @@ void CSaveTeam::Load(int Team, bool KeepCurrentWeakStrong)
if(m_pController->GameServer()->Collision()->m_NumSwitchers)
{
for(int i = 1; i < m_pController->GameServer()->Collision()->m_NumSwitchers + 1; i++)
for(int i = 1; i < minimum(m_NumSwitchers, m_pController->GameServer()->Collision()->m_NumSwitchers) + 1; i++)
{
m_pController->GameServer()->Collision()->m_pSwitchers[i].m_Status[Team] = m_pSwitchers[i].m_Status;
if(m_pSwitchers[i].m_EndTime)