Move `CMenus::RenderDropDown` to `CUI::DoDropDown` and refactor by using a generic selection popup to implement the drop down menu.
This improves the usability and layout, as the drop down is now rendered as a popup above the rest of the menu, instead of taking space from the menu that holds the drop down button. The latter could cause issues when several drop down menus are open at the same time and with drop down buttons at the bottom of the menu, as the drop down cannot scroll properly.
- Support scrolling. Limit maximum height to 40% of screen height.
- Allow message to be empty.
- Use `std::vector` instead of `std::set` for entries to keep the user-defined order of entries.
- Add `m_SelectionIndex` in addition to `m_pSelection` to get selected item more conveniently for some use-cases.
- Make entry height, entry padding, entry spacing, font size, and popup width configurable.
- Allow alignment of selection popup with the top/bottom of another UI element.
- Support transparent selection buttons.
Currently this must be added when calculating the required height of a UI rect for a scroll region to get a perfect fit.
It is extracted into a constant so it can be used in other parts to get list boxes with the perfect size.
Reduce duplicate code for handling label format, value scaling and special infinity value.
The current value is now shown for all settings. Previously it was not shown for some settings, e.g. the sound volumes.
The infinity-value is now all the way on the right side of the settings scrollbars, which makes more sense, as the values get larger when going to the right. This is also more convenient, as previously it was necessary to pass the lowest value before going to infinity, which would e.g. temporarily lag the client when selecting a low refresh rate.
Use logarithmic scrollbar for sounds volumes.
Hide scrollbar options that are disabled by checkboxes consistently. Previously this was only done for some checkboxes.
Replaced labeled scrollbar option for selecting ingame controller mode with two button for relative and absolute controller mode.
Make better use of space for controller axis picker. Replace left column with just the axis number. Fix checkbox labels being very small on 5:4 and 4:3 resolutions.
Split space for label and scrollbar in middle for consistent layout. Previously the label was just as large as it needed to be, which was causing differently sized scrollbars for all settings. Now the scrollbars have a consistent size.
Fix minimum scrollbar option value not being selectable when `Min > 0` and `SCROLLBAR_OPTION_INFINITE`.
Add optional suffix parameter to `DoScrollbarOption` to specify units/scales like `Hz` and `%`.
Support combining `SCROLLBAR_OPTION_INFINITE` and `SCROLLBAR_OPTION_NOCLAMPVALUE` flags.
Add `SCROLLBAR_OPTION_MULTILINE` flag for multi line scrollbar options where the label is above the scrollbar.
6719: Fix escape not working in server browser and demo browser r=Jupeyy a=Robyt3
Closes#6718.
## 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>
6716: Improve usage of `CCountryFlags::Render` function r=def- a=Robyt3
Pass color by value instead of pointer to simplify usage.
Add separate function that accepts a country flag directly instead of an index.
## 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)
6717: Simplify list box activation handling, more highlighting fixes when popups are open r=def- a=Robyt3
Store the list box active state inside `CListBox` instead of tracking it separately with a pointer.
Allow activating list boxes by clicking the scrollbar. Previously it was only possible to activate list boxes by selecting an item.
Fix country selection list box in players settings not being deactivated properly when name/clan edit boxes are active, because wrong UI element IDs were being used.
Fix highlighting of menu tab buttons while popup open.
Fix highlighting of scroll region scroll bars while popup open.
## 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>
6715: Disallow multiple emotes in the same tick, respect high bandwidth setting r=Robyt3 a=Jupeyy
closes#6714
## 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 (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: Jupeyy <jupjopjap@gmail.com>
Store the list box active state inside `CListBox` instead of tracking it separately with a pointer.
Allow activating list boxes by clicking the scrollbar. Previously it was only possible to activate list boxes by selecting an item.
Fix country selection list box in players settings not being deactivated properly when name/clan edit boxes are active, because wrong UI element IDs were being used.
6711: Improve color picker popup in settings (use new popup system, add alpha support, support mouse locking) r=def- a=Robyt3
Use the popup system ported from the editor to reimplement the color picker popup.
- Before:
![screenshot_2023-06-05_21-57-46](https://github.com/ddnet/ddnet/assets/23437060/52d6adfa-7d62-4323-b6df-8d18a26b6cc6)
- After:
![screenshot_2023-06-05_21-57-26](https://github.com/ddnet/ddnet/assets/23437060/773115db-178c-48ab-a750-35b136a4fb30)
Remove special handling necessary for the hard-coded color picker.
Add alpha support to the color picker popup.
Support locking mouse position when dragging value selectors also in menus (color pickers), which improves usability of value selectors. Previously this was only supported in the editor.
Replace large HSLA scrollbar color picker for UI color setting with inline color picker popup:
- Before:
![screenshot_2023-06-05_21-57-57](https://github.com/ddnet/ddnet/assets/23437060/bb6cee4d-5438-40a3-b602-90abccc959ee)
- After:
![screenshot_2023-06-05_21-57-01](https://github.com/ddnet/ddnet/assets/23437060/e0a565a6-2956-403f-9fc0-4ab11a764400)
## 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 (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)
6712: Fix crash when enabling `dbg_dummies` on running server r=def- a=Robyt3
The server normally needs to be reloaded to spawn the debug dummies, so this code was not checking if a debug dummy player exists. Decreasing the number of debug dummies while the server is running also causes them to simply not be snapped instead of completely destroying them.
For debugging any number of dummies can be useful, so the maximum number of debug dummies is increased to the maximum number of clients.
See #6702.
## 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
- [X] 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>
Use the popup system ported from the editor to reimplement the color picker popup.
Remove special handling necessary for the hard-coded color picker.
Add alpha support to the color picker popup.
Support locking mouse position when dragging value selectors also in menus (color pickers), which improves usability of value selectors.
Previously this was only supported in the editor.
When enabling locked mouse a UI element ID must be specified. The mouse lock is stopped when this element is no longer active. This ensures that the mouse doesn't gets stuck in this state when the value selector isn't active anymore.
The server normally needs to be reloaded to spawn the debug dummies, so this code was not checking if a debug dummy player exists. Decreasing the number of debug dummies while the server is running also causes them to simply not be snapped instead of completely destroying them.
6710: Use real instead of display string for number line inputs r=def- a=Robyt3
Set input string if it's not identical to the real input string instead of comparing to the display string, which would be incorrect for hidden number inputs.
## 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>
Set input string if it's not identical to the real input string instead of comparing to the display string, which would be incorrect for hidden number inputs.
6709: Fix escape not working in settings menu anymore r=Jupeyy a=Robyt3
The color picker was always consuming the escape hotkey even when already disabled. Regression from #6705 due to changed order of hotkey consumption.
## 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>
6708: Add logappend setting r=heinrich5991 a=def-
To append to log file instead of overwriting it. To use you can create an autoexec_client.cfg with:
```
logfile "client.log"
logappend 1
```
I'm not sure if it should be the default.
## Checklist
- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [x] 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: Dennis Felsing <dennis@felsin9.de>
To append to log file instead of overwriting it. To use you can create a
data/autoexec_client.cfg with:
logfile "client.log"
logappend 1
Enabled by default
6706: Fix `color_cast` between `ColorHSLA` and `ColorHSVA` losing alpha, add test 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
- [X] 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>
6707: Fix UI element check with `m_HintCanChangePositionOrSize` r=def- a=Robyt3
It was incorrectly checked for `UIElement.Rect(0)->m_Y != pRect->h`, so any UI rect using `m_HintCanChangePositionOrSize` would be updated every frame (although, no UI element currently uses this hint).
Additionally, checks for changed rounding size and corners are added so UI elements are updated when those are changed.
## 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>
It was incorrectly checked for `UIElement.Rect(0)->m_Y != pRect->h`, so any UI rect using `m_HintCanChangePositionOrSize` would be updated every frame (although, no UI element currently uses this hint).
Additionally, checks for changed rounding size and corners are added so UI elements are updated when those are changed.
6703: Only highlight hovered edit boxes when they are the hot item r=def- a=Robyt3
Prevent highlighting when edit box hovered but behind a popup menu.
## 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)
6704: Extract `CMenus::UpdateColors` and `CUI::DebugRender` functions to improve readability of `CMenus::OnRender` 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>
6705: Handle escape to go to start menu after popup menus r=def- a=Robyt3
Popup menus should be closed before escape is used to navigate back to the start menu.
## 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>