3412: Allow reordering in the settings editor r=def- a=Learath2

Requested by Ravie on discord

![t](https://user-images.githubusercontent.com/490500/102074907-c2ddb380-3e05-11eb-9fb9-594bba6bddb9.png)

## Checklist

- [x] Tested the change ingame
- [x] 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
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] 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: Learath2 <learath2@gmail.com>
This commit is contained in:
bors[bot] 2020-12-14 13:46:33 +00:00 committed by GitHub
commit 32bbf0f0fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5524,6 +5524,24 @@ void CEditor::RenderServerSettingsEditor(CUIRect View, bool ShowServerSettingsEd
str_copy(m_aSettingsCommand, m_Map.m_lSettings[s_CommandSelectedIndex].m_aCommand, sizeof(m_aSettingsCommand));
UI()->SetActiveItem(&m_CommandBox);
}
ToolBar.VSplitRight(25.0f, &ToolBar, &Button);
Button.VSplitRight(5.0f, &Button, 0);
static int s_DownButton = 0;
if(s_CommandSelectedIndex < m_Map.m_lSettings.size() - 1 && DoButton_Editor(&s_DownButton, "", 0, &Button, 0, "Move command down"))
{
std::swap(m_Map.m_lSettings[s_CommandSelectedIndex], m_Map.m_lSettings[s_CommandSelectedIndex + 1]);
s_CommandSelectedIndex++;
}
ToolBar.VSplitRight(25.0f, &ToolBar, &Button);
Button.VSplitRight(5.0f, &Button, 0);
static int s_UpButton = 0;
if(s_CommandSelectedIndex > 0 && DoButton_Editor(&s_UpButton, "", 0, &Button, 0, "Move command up"))
{
std::swap(m_Map.m_lSettings[s_CommandSelectedIndex], m_Map.m_lSettings[s_CommandSelectedIndex - 1]);
s_CommandSelectedIndex--;
}
}
}