6509: Fix client crash when spectating on server with missing game info 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>
Add `CaretPosition` function to get position of text caret. Replace some existing usages of `TextWidth`, which would no longer work correctly for multi-line text.
Having this function is also useful when porting the upstream UI lineinput.
Add separate `STextBoundingBox` to describe text bounding box (same as on upstream). Add `GetBoundingBoxTextContainer` to get bounding box for a text container. Add `TextBoundingBox` function to get bounding box with old text render interface.
Using this function to get the bounding box width and height is cleaner than using `TextWidth`. This function additionally can get the bounding box X and Y position for convenience.
Some usages of `TextWidth` are replaced with `TextBoundingBox` to improve readability.
It will be useful to have these functions when porting the upstream UI lineinput.
Add separate constants `TEXTALIGN_TOP`, `TEXTALIGN_MIDDLE` and `TEXTALIGN_BOTTOM` for vertical alignment.
Add shorthand constants for all possible combinations of horizontal and vertical alignment, e.g. `TEXTALIGN_MC` for `TEXTALIGN_MIDDLE | TEXTALIGN_CENTER`.
Replace usage of `SLabelProperties::m_AlignVertically` with these constants in all menu and editor code for more convenient and versatile alignment of text. Use combined horizontal-vertical alignment constants for all existing labels. Manually adjust layout for some elements which were initially misaligned with the new implementation.
Refactoring:
- Use `CORNER_NONE` instead of `0`.
- Improve some `CUIRect` variables names and usage.
6508: Use `Localizable` instead of comment with `Localize` r=Jupeyy a=Robyt3
## 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: Robert Müller <robytemueller@gmail.com>
Previously when calculating `m_LongestLineWidth` for a `CTextCursor` the position `m_StartX` of the cursor was always zero, because `m_LongestLineWidth` was only used to calculate the text width with a non-rendered cursor aligned at (0, 0).
To ensure that the calculation is correct also when the text cursor is not positioned at X=0, the width calculation must be offset by the start position.
Round up the calculated text width to prevent inconsistent text wrapping in the popups in cases where the current text width is very close to the maximum line width.
Calculate text height for popups with `TextWidth` instead of using `TextLineCount`, which can be incorrect if the aligned font size differs from the normal one.
Also calculate text height in `TextWidth`.
Use calculated text height to verically center UI labels.
The text cursor flags (in particular, the `TEXTFLAG_STOP_AT_END` flag) must also be passed to `TextWidth`. Otherwise, for example, when `TEXTFLAG_STOP_AT_END` is missing, the wrong text height is calculated, as text is rendered over multiple lines instead of stopping at the end of the first line.
Closes#5396.
6503: Move generic popup handling to UI (port from editor and upstream) r=def- a=Robyt3
Support using editor popup rendering in game client.
Support unlimited number of popup menus instead of maximum of 8.
Fix non-active popups handling key events. Add `Active` parameter to popup function, so key events are only processed by the active (top-most) popup. Previously the "New folder" popup could be confirmed with enter while an error message is shown, which causes multiple error messages to stack.
Allow popups to close without closing their child popups. Previously a popup could not open another popup and close itself immediately afterwards, as this was causing the newly opened popup to be closed instead.
Support using return/enter keys to confirm binary choice popups and to close message popups for more convenient usage.
## 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>
Support using editor popup rendering in game client.
Support unlimited number of popup menus instead of maximum of 8.
Fix non-active popups handling key events. Add `Active` parameter to popup function, so key events are only processed by the active (top-most) popup. Previously the "New folder" popup could be confirmed with enter while an error message is shown, which causes multiple error messages to stack.
Allow popups to close without closing their child popups. Previously a popup could not open another popup and close itself immediately afterwards, as this was causing the newly opened popup to be closed instead.
Support using return/enter keys to confirm binary choice popups and to close message popups for more convenient usage.
There is not enought space for the button in the file browser on 4:3 and 5:4 resolutions.
The button fits in the file menu, as it allows to adjust the map details which are specific to the current map file.
6501: Fix image/sound readding broken by error messages r=def- a=Robyt3
When an image/sound is readded, this reuses the `ReplaceImage/Sound` callback functions. The added error handling to prevent duplicate images/sounds was causing this to not work, as the image/sound being readded was already present. The implementation is separated from the callback functions and an additional parameter is added to toggle the duplicate name check.
Previously this was hard to notice, as the error message popup was not shown due to the top-most popup being closed immediately. This will be fixed separately by a larger refactoring, so a popup can close itself immediately after opening another popup without closing the child popup instead.
Closes#6500.
## 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>
When an image/sound is readded, this reuses the `ReplaceImage/Sound` callback functions. The added error handling to prevent duplicate images/sounds was causing this to not work, as the image/sound being readded was already present. The implementation is separated from the callback functions and an additional parameter is added to toggle the duplicate name check.
Previously this was hard to notice, as the error message popup was not shown due to the top-most popup being closed immediately. This will be fixed separately by a larger refactoring, so a popup can close itself immediately after opening another popup without closing the child popup instead.
Closes#6500.
6496: Highlight 0XF game type r=def- a=0xfaulty
Highlight 0XF game type
## 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: Valentin Bashkirov <valenteen3d@ya.ru>
6495: Fix swapping with dragger beams and plasmas r=def- a=Robyt3
The client ID referenced by dragger beams and plasmas must also be swapped when two clients are swapped, as those entities should refer to the same character entity as before the swap.
For dragger beams, swapping previously caused the active beams to switch target to another character.
For plasmas, swapping previously caused already shot plasmas to not have an effect on their original target character.
Closes#5865.
## 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>
The client ID referenced by dragger beams and plasmas must also be swapped when two clients are swapped, as those entities should refer to the same character entity as before the swap.
For dragger beams, swapping previously caused the active beams to switch target to another character.
For plasmas, swapping previously caused already shot plasmas to not have an effect on their original target character.
Closes#5865.
6494: Bring every Font Icon unicode into a namespace r=def- a=VoxelDoesCode
For readability and cleanliness inside the code.
## 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
- [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: VoxelDoesCode <dante_n_cedroni@hotmail.com>
Co-authored-by: Dennis Felsing <dennis@felsin9.de>
Swap buttons so confirm button is on the right and cancel button is on the left consistently.
Decrease empty space and popup size.
Add missing title for `POPEVENT_LOADCURRENT` (caught by the added assertion).
Improve messages by adding additional empty line for existing line breaks.