SDL fixed the bug on Windows that releasing the mouse while tabbing out directly refocuses the window, which broke desktop fullscreen (and maybe windowed fullscreen)
6530: Port line input and IME support from 0.7 r=def- a=Robyt3
Port the line input (UI edit boxes, chat, console) and Input Method Editor (IME) support from upstream. Closes#4397.
General
------------------------------
Fix issues with the text input. Closes#4346. Closes#4524.
Word skipping (when holding Ctrl) is overhauled to be consistent with the Windows / Firefox experience that I took as reference.
Improve usability by not blinking (i.e. always rendering) the caret shortly after is has been moved.
UI text input
------------------------------
https://user-images.githubusercontent.com/23437060/233841419-6648ea97-3ccd-464b-a4c5-e6e5b8dde01c.mp4
Fix inconsistent mouse-based left and right scrolling (closes#4347).
Support smooth left and right scrolling.
Chat
------------------------------
https://user-images.githubusercontent.com/23437060/233841409-3f230b33-f1ad-4172-ade2-e8e5300c9220.mp4
Support keyboard-based text selection of the chat input.
Mouse-based selection could be support in the future when we decide to add something like an ingame UI cursor.
Support smooth up and down scrolling of the chat input, removing the old hack that offsets the input string to simulate scrolling.
Console
------------------------------
https://user-images.githubusercontent.com/23437060/233841427-d3aee499-254d-4bf9-83dd-3a0459ed6bf0.mp4
Also support mouse-based text selection of the command input.
Only text from either the command input or the console log can be selected at the same time. This ensures that Ctrl+C will always copy the text that is currently visually selected in the console.
Check for Ctrl+C input event in event handler instead of in render function, to hopefully fix the issue that copying does not work sometimes (closes#5974 until further notice).
When Ctrl+C is used to copy text from the console log, the selection is cleared. This should make it more clear when text was copied from the log.
Fix an issue that was preventing the console log selection from being cleared, when all log lines are selected.
Remove Ctrl+A/E hotkeys that move cursor to beginning/end respectively. Ctrl+A now selectes all text like for all other inputs. Home and End keys can still be used to go the beginning and end.
Remove Ctrl+U/K hotkeys that clear everything before/after the cursor respectively. Hold shift and use Home/End to select everything instead.
IME support
------------------------------
https://user-images.githubusercontent.com/23437060/233841395-635b6172-7582-4dce-a54f-cccf5e027dc5.mp4
Render list of IME candidates in the client on Windows, so the candidate list can also be viewed in fullscreen mode. There is no API available to retrieve a candidate list on the other operating systems.
**Note that this does not work with SDL 2.0.16, which we are currently using on Windows. See below for details on IME support in different SDL versions.**
Improve composition rendering by underlining the composition text instead of putting it in square brackets.
Track active input globally to properly activate and deactivate IME through the SDL functions.
Closes#1030. Closes#1008.
Password rendering
------------------------------
Fix rendering of passwords containing unicode. Instead of rendering one star character for each UTF-8 `char`, render on star for every unicode codepoint.
Show the composition text also for passwords. Without seeing the composition text it's hard to type a password containing those characters. The candidate window exposes the composition anyway. If you don't want to expose your password this way, e.g. while streaming, you could:
1. Use a latin password and switch off the IME for the password input with the IME hotkey.
2. Blank your screen with an external program while you are streaming and entering passwords.
3. Use binds to authenticate in rcon or to set the server browser password.
Refactoring
------------------------------
Move all text input logic and general rendering to `CLineInput`.
A `CLineInput` is associated with a particular `char` buffer given as a pointer either in the constructor or with `SetBuffer`. The maximum byte size of the buffer must also be specified. The maximum length in unicode codepoints can also be specified separately (e.g. on upstream, name are limited by the number of unicode codepoints instead).
Add `CLineInputBuffered`, which is a `CLineInput` that own a `char` buffer of a fixed size, which is specified as a template argument. As `CLineInput` does not own a buffer anymore, this reduces duplicate code for line inputs that need their own buffer.
Add `CLineInputNumber` which has additional convenience functions to consider the text as an `int` or `float`, to reduce duplicate code in those cases. In the future we could also add an input filter function so that only numbers can be entered in the number input.
Add `CLineInput::SetClipboardLineCallback` to handle the case that multiple lines of text are pasted into a lineinput. This reduces duplicate code, as this behavior was previously implemented separately for chat and console. The behavior is also fixed to be consistent with the console on Windows, so the first line being pasted edits the current input text and then sends it instead of being sent on its own without the existing input text.
Add `CalcFontSizeAndBoundingBox` to UI to reduce duplicate code. Expose `CalcAlignedCursorPos` as static member function to reuse it for line input.
Dispatch input events to UI inputs through the event handler instead of storing them in a duplicate buffer.
Use `size_t` for line input cursor position, length etc. and for `str_utf8_stats`.
Add `IButtonColorFunction` to UI to describe a functions that defines colors for the Default, Active and Hovered states of UI elements. Add some default button color functions. Use button color function to reduce duplicate code in scrollbar rendering.
Use `vec2` instead of two `floats` to represent the mouse positions in the text renderer.
Remove `CaretPosition` again, as it does not calculate the correct Y position near line breaks due to the wrapping being different when not rendering the entire string. Instead, calculate the exact caret position when rending a text container and store the caret position in the text cursor for later use.
IME usage guide (Windows)
------------------------------
1. Install the respective language and the Microsoft-IME keyboard (e.g. for Chinese, Japanese or Korean).
2. Launch the game (or a text editor to first try out the IME). Note that Windows may track the input language separately for every application. You can change this in the Windows input settings so the input language is changed globally.
2. Switch the input language using the hotkey Windows+Space or another hotkey that you configured in the Windows input settings (Alt+Shift is the default, but you should consider disabling it, to avoid accidentally changing the input language while playing).
3. Switch from Latin/English input mode to the respective asian input mode.
- Chinese: Use Ctrl+Space to switch between English and Chinese input mode. You can change this hotkey in the IME's settings.
- Japanese: Use Ctrl+Space to switch between Alphanumeric and Hiragana/Katakana input mode. You can change this hotkey in the IME's settings.
- Korean: Use Right Alt to switch between English and Hangul input mode. You cannot change this hotkey as of yet.
- Note that the input mode is also tracked per application, but there is no setting to change this behavior as far as I know, so you'll need to switch for every application separately.
4. Start typing. The underlined text is the current composition text. While a composition is active, you can only edit the composition text. Confirm the composition with Space or by selecting a candidate from the candidate list with the arrow keys. Cancel the composition with Escape or by using Backspace to delete the composition text. Note that not all languages offer a candidate list.
SDL version-specific issues
------------------------------
- 2.26.5, 2.24.2, 2.0.22: IME candidates work. But there are minor bugs when moving the composition cursor.
- 2.0.18, 2.0.20: IME candidates work.
- 2.0.16 (our current version): IME candidates cannot be determined with Windows API. Windows tries to draw the composition window like before, so this does not work in fullscreen mode.
- 2.0.8 (upstream 0.7): IME candidates work. But this SDL version is too old for us.
## 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
- [X] 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>
6528: Use dynamic size buffer in teehistorian tests instead of `CPacker` r=heinrich5991 a=Robyt3
`CPacker` is simply used as a byte buffer in the teehistorian tests. When the number of UUIDs is increased (in the future or in downstream projects) the tests will start to fail due to the buffer size being limited to 2048 bytes. This is fixed by using an `std::vector<unsigned char>` instead.
Closes#6526.
## 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>
Port the line input (UI edit boxes, chat, console) and Input Method Editor (IME) support from upstream. Closes#4397.
General
------------------------------
Fix issues with the text input. Closes#4346. Closes#4524.
Word skipping (when holding Ctrl) is overhauled to be consistent with the Windows / Firefox experience that I took as reference.
Improve usability by not blinking (i.e. always rendering) the caret shortly after is has been moved.
UI text input
------------------------------
Fix inconsistent mouse-based left and right scrolling (closes#4347).
Support smooth left and right scrolling.
Chat
------------------------------
Support keyboard-based text selection of the chat input.
Mouse-based selection could be support in the future when we decide to add something like an ingame UI cursor.
Support smooth up and down scrolling of the chat input, removing the old hack that offsets the input string to simulate scrolling.
Console
------------------------------
Also support mouse-based text selection of the command input.
Only text from either the command input or the console log can be selected at the same time. This ensures that Ctrl+C will always copy the text that is currently visually selected in the console.
Check for Ctrl+C input event in event handler instead of in render function, to hopefully fix the issue that copying does not work sometimes (closes#5974 until further notice).
When Ctrl+C is used to copy text from the console log, the selection is cleared. This should make it more clear when text was copied from the log.
Fix an issue that was preventing the console log selection from being cleared, when all log lines are selected.
Remove Ctrl+A/E hotkeys that move cursor to beginning/end respectively. Ctrl+A now selectes all text like for all other inputs. Home and End keys can still be used to go the beginning and end.
Remove Ctrl+U/K hotkeys that clear everything before/after the cursor respectively. Hold shift and use Home/End to select everything instead.
IME support
------------------------------
Render list of IME candidates in the client on Windows, so the candidate list can also be viewed in fullscreen mode. There is no API available to retrieve a candidate list on the other operating systems.
Improve composition rendering by underlining the composition text instead of putting it in square brackets.
Track active input globally to properly activate and deactivate IME through the SDL functions.
Closes#1030. Closes#1008.
Password rendering
------------------------------
Fix rendering of passwords containing unicode. Instead of rendering one star character for each UTF-8 `char`, render on star for every unicode codepoint.
Show the composition text also for passwords. Without seeing the composition text it's hard to type a password containing those characters. The candidate window exposes the composition anyway. If you don't want to expose your password this way, e.g. while streaming, you could:
1. Use a latin password and switch off the IME for the password input with the IME hotkey.
2. Blank your screen with an external program while you are streaming and entering passwords.
3. Use binds to authenticate in rcon or to set the server browser password.
Refactoring
------------------------------
Move all text input logic and general rendering to `CLineInput`.
A `CLineInput` is associated with a particular `char` buffer given as a pointer either in the constructor or with `SetBuffer`. The maximum byte size of the buffer must also be specified. The maximum length in unicode codepoints can also be specified separately (e.g. on upstream, name are limited by the number of unicode codepoints instead).
Add `CLineInputBuffered`, which is a `CLineInput` that own a `char` buffer of a fixed size, which is specified as a template argument. As `CLineInput` does not own a buffer anymore, this reduces duplicate code for line inputs that need their own buffer.
Add `CLineInputNumber` which has additional convenience functions to consider the text as an `int` or `float`, to reduce duplicate code in those cases. In the future we could also add an input filter function so that only numbers can be entered in the number input.
Add `CLineInput::SetClipboardLineCallback` to handle the case that multiple lines of text are pasted into a lineinput. This reduces duplicate code, as this behavior was previously implemented separately for chat and console. The behavior is also fixed to be consistent with the console on Windows, so the first line being pasted edits the current input text and then sends it instead of being sent on its own without the existing input text.
Add `CalcFontSizeAndBoundingBox` to UI to reduce duplicate code. Expose `CalcAlignedCursorPos` as static member function to reuse it for line input.
Dispatch input events to UI inputs through the event handler instead of storing them in a duplicate buffer.
Use `size_t` for line input cursor position, length etc. and for `str_utf8_stats`.
Add `IButtonColorFunction` to UI to describe a functions that defines colors for the Default, Active and Hovered states of UI elements. Add some default button color functions. Use button color function to reduce duplicate code in scrollbar rendering.
Use `vec2` instead of two `floats` to represent the mouse positions in the text renderer.
Remove `CaretPosition` again, as it does not calculate the correct Y position near line breaks due to the wrapping being different when not rendering the entire string. Instead, calculate the exact caret position when rending a text container and store the caret position in the text cursor for later use.
IME usage guide (Windows)
------------------------------
1. Install the respective language and the Microsoft-IME keyboard (e.g. for Chinese, Japanese or Korean).
2. Launch the game (or a text editor to first try out the IME). Note that Windows may track the input language separately for every application. You can change this in the Windows input settings so the input language is changed globally.
2. Switch the input language using the hotkey Windows+Space or another hotkey that you configured in the Windows input settings (Alt+Shift is the default, but you should consider disabling it, to avoid accidentally changing the input language while playing).
3. Switch from Latin/English input mode to the respective asian input mode.
- Chinese: Use Ctrl+Space to switch between English and Chinese input mode. You can change this hotkey in the IME's settings.
- Japanese: Use Ctrl+Space to switch between Alphanumeric and Hiragana/Katakana input mode. You can change this hotkey in the IME's settings.
- Korean: Use Right Alt to switch between English and Hangul input mode. You cannot change this hotkey as of yet.
- Note that the input mode is also tracked per application, but there is no setting to change this behavior as far as I know, so you'll need to switch for every application separately.
4. Start typing. The underlined text is the current composition text. While a composition is active, you can only edit the composition text. Confirm the composition with Space or by selecting a candidate from the candidate list with the arrow keys. Cancel the composition with Escape or by using Backspace to delete the composition text. Note that not all languages offer a candidate list.
SDL version-specific issues
------------------------------
- 2.26.5, 2.24.2, 2.0.22: IME candidates work. But there are minor bugs when moving the composition cursor.
- 2.0.18, 2.0.20: IME candidates work.
- 2.0.16 (our current version): IME candidates cannot be determined with Windows API. Windows tries to draw the composition window like before, so this does not work in fullscreen mode.
- 2.0.8 (upstream 0.7): IME candidates work. But this SDL version is too old for us.
Add flag to temporarily cause the caret to not blink, so the caret can be rendered without blinking after it has been moved, which greatly improves usability.
Makes the text selection easier to see, especially when the text selection height is lower than normal.
Change text selection color to light grey instead of blue.
Add `CTextCursor::m_SelectionHeightFactor` setting to adjust the height of the text selection rectangle. For example a value of `0.5f` means that the selection rectangle has half its normal height while still being aligned at the same bottom position.
`CPacker` is simply used as a byte buffer in the teehistorian tests. When the number of UUIDs is increased (in the future or in downstream projects) the tests will start to fail due to the buffer size being limited to 2048 bytes. This is fixed by using an `std::vector<unsigned char>` instead.
6527: Fix `NET_MAX_CHUNKHEADERSIZE` `5` -> `3` r=def- a=ChillerDragon
Probably has no big impact but 5 is just wrong.
Was also casually fixed in upstream.
c2e5771a15 (diff-706d36dc3648350992fd7fb372d2461cbddcec7ac79f1f905f329ada2bcda814L49)
<!-- What is the motivation for the changes of this pull request? -->
<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your 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 (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: ChillerDragon <ChillerDragon@gmail.com>
6521: Minor refactoring of engine input r=Chairn 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
- [X] 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>
6524: Refactor `CEditorMap::CMapInfo` r=def- a=Robyt3
Reduce duplicate code. Make code more similar to upstream.
## 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>
6437: Make team kills condensed in killfeed r=heinrich5991 a=VoxelDoesCode
For those who still have the killfeed on, I wanted to modernize it, by having team kills become one line instead of a bunch!
![image](https://user-images.githubusercontent.com/95713843/226060109-ed74c2f6-1289-4247-81dc-1725428ddf59.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 (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>
6515: Add OnNewSnapshot to component hooks r=heinrich5991 a=ChillerDragon
Waste some clock cycles on zero lines code removed :D
Downstream client maintainers will love it tho
## 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
- [x] 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: ChillerDragon <ChillerDragon@gmail.com>
6516: More minor cleanup and enhancement of the text render r=def- a=Robyt3
More preparation to port lineinput and IME from upstream.
## 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 calculation of `m_LongestLineWidth` was adjusted in bf1e757581 so it's really the width of the line and not the X position of the end of the line. This caused the background rects of chat messages to be rendered incorrectly.
6511: Refactor vertical alignment of UI labels, add more text render convenience functions r=def- a=Robyt3
Should change layout only very little.
### Notes if you are porting this downstream
`SLabelProperties::m_AlignVertically` is removed. The usage was previously confusing and inconvenient, as the `SLabelProperties` parameter object was necessary to change the vertical alignment. If `m_AlignVertically == 1` (which is the default value) then the text is vertically centered and this works correctly also for multi-line text, assuming that the correct rect height is specified and the previous fixes have been applied (#6507). If `m_AlignVertically == 0` then the text is somehow more correctly aligned for some UI elements that span only one line in cases where the previous option doesn't work correctly. Other `m_AlignVertically` values besides `0` and `1` are not used.
With this PR most text is centered vertically by setting `TEXTALIGN_MIDDLE`. The UI code always uses shorthand constants for combinations of horizontal and vertical alignment, e.g. `TEXTALIGN_MC` for `TEXTALIGN_MIDDLE | TEXTALIGN_CENTER`. To port your own code, I'd recommend replacing all of your usages of `TEXTALIGN_LEFT`, `TEXTALIGN_CENTER` and `TEXTALIGN_RIGHT` with `TEXTALIGN_ML`, `TEXTALIGN_MC` and `TEXTALIGN_MR` respectively. Remove all usages of `m_AlignVertically` and also the `SLabelProperties` variables for which only `m_AlignVertically` was changed. This means all text will be vertically centered and have the same horizontal alignment as before. For some labels the vertical centering does not work correctly though, so you'll have to visually check if any of the texts are misaligned and then manually adjust the alignment or the UI rect position and/or size.
## 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>
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.