Commit graph

16751 commits

Author SHA1 Message Date
marmare314 76eac08783 fix padding of buttons in settings 2023-05-17 17:25:21 +02:00
marmare314 37791ada99 enable brush coloring -> brush coloring 2023-05-16 22:24:26 +02:00
marmare314 7a0d566ddb combine proof mode buttons 2023-05-01 23:07:58 +02:00
marmare314 02429288f1 move coloring and info to settings 2023-05-01 22:44:03 +02:00
marmare314 9dddc0d8de show current entity type 2023-05-01 18:02:53 +02:00
marmare314 ab20e897a8 add spacing and group unused selector code 2023-04-29 15:07:25 +02:00
marmare314 ae63ea5f9e move unused, entities, goto, border to menu 2023-04-29 14:05:01 +02:00
bors[bot] 2eb7ca3dea
Merge #6541
6541: Add the DDNet git hash and "is steam" to the crash file r=Robyt3 a=Jupeyy

`@def-` what do you think, how hard would it be for the symbols uploaded to the website contain the same git hash in the name, so we could write a script that automatically finds the correct binary and creates a stack trace?

## 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>
2023-04-29 09:27:59 +00:00
bors[bot] dc804f88ac
Merge #6544
6544: make envelope editor resizeable by dragging r=def- a=Marmare314


![resizeable-editor](https://user-images.githubusercontent.com/49279081/235273201-5ee620c3-3784-49d1-ac0c-3bc3d5aca440.gif)


## 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: marmare314 <49279081+Marmare314@users.noreply.github.com>
2023-04-29 09:05:05 +00:00
bors[bot] 4b27611201
Merge #6542
6542: potential fix for #6529 r=def- a=Marmare314


## 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: marmare314 <49279081+Marmare314@users.noreply.github.com>
2023-04-29 08:45:55 +00:00
Jupeyy 40838bf473 Add the DDNet git hash and "is steam" to the crash file
Also put the date before pid for assert logs
2023-04-29 10:26:30 +02:00
marmare314 c9bc524878 make envelope editor resizeable by dragging 2023-04-29 02:26:10 +02:00
marmare314 61ff658cc7 potential fix for #6529 2023-04-29 01:20:51 +02:00
bors[bot] 8375fd83a0
Merge #6540
6540: Fix inconsistent client state after disconnecting with network error r=def- a=Robyt3

The `Disconnect` function did not fully clear all server data, because the client state was already set to offline manually before the function is called. This was causing inconsistent behavior when connecting to another server after being disconnected. For example, the client could get stuck at "getting game info" when connecting the next time.

## 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>
2023-04-28 16:25:23 +00:00
Robert Müller aa95f61f11 Fix inconsistent client state after disconnecting with network error
The `Disconnect` function did not fully clear all server data, because the client state was already set to offline manually before the function is called. This was causing inconsistent behavior when connecting to another server after being disconnected. For example, the client could get stuck at "getting game info" when connecting the next time.
2023-04-28 17:57:58 +02:00
bors[bot] 10567cbef2
Merge #6539
6539: Fix Ctrl+F not activating search box in browser and tee settings r=Jupeyy a=Robyt3

Closes #6537.

## 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>
2023-04-28 15:26:17 +00:00
Robert Müller 11cb72be32 Fix Ctrl+F not activating search box in browser and tee settings
Closes #6537.
2023-04-28 17:17:30 +02:00
bors[bot] 22c6e7ebeb
Merge #6536
6536: Fix client crash on team kill message with invalid team r=def- a=Robyt3

The client crashes when a team kill message specifies a team for which no client can be found. This can easily happen when the server sends an unknown team on purpose. It may also happen sporadically during normal gameplay, assuming a team is dissolved or the last team member leaves at the same time as the kill message is received.

The crash is fixed by not rendering any tee for these kill messages. The kill message text is always set depending on the team number in the team kill message, regardless of whether the team exists.

Closes #6533.

## 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
- [ ] 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>
2023-04-27 22:13:04 +00:00
Robert Müller abbe2ce1de Use Height variable to reduce duplicate code 2023-04-27 20:47:56 +02:00
Robert Müller 5cb9902745 Fix variable name m_VictimTextWidth 2023-04-27 20:46:58 +02:00
Robert Müller be68c5ad7a Fix client crash on team kill message with invalid team
The client crashes when a team kill message specifies a team for which no client can be found. This can easily happen when the server sends an unknown team on purpose. It may also happen sporadically during normal gameplay, assuming a team is dissolved or the last team member leaves at the same time as the kill message is received.

The crash is fixed by not rendering any tee for these kill messages. The kill message text is always set depending on the team number in the team kill message, regardless of whether the team exists.

Closes #6533.
2023-04-27 20:45:30 +02:00
bors[bot] 0a37aa5c01
Merge #6535
6535: Don't send faketunes to new client versions, simplify code r=def- a=trml

This fixes a bug where hook doesn't get predicted if a player has hook disabled, but can still be hooked by other players, which was reported on Discord.

It seems like this bug (and similar bugs) is caused by the client accidentally using the tuning for hook/collision instead of the flags in ddnetcharacter. By sending the correct tunings instead of the fake ones, the handling of tunezones becomes less complicated (and less bug-prone), as the client no longer needs to ignore the tunings for hook and collision (and similar) on ddnet servers.

I didn't test this with older clients yet, but tried to make sure that the conditions for sending the fake tunes are the same as they were before.

## 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
- [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: trml <trml@users.noreply.github.com>
2023-04-26 22:15:26 +00:00
trml d603214133 Don't send faketunes to new client versions, and simplify code 2023-04-26 22:35:23 +02:00
bors[bot] 6dd38c7da0
Merge #6534
6534: Don't render switch number and delay for tiles where they are unused, ignore switch tiles that don't use number for free slot finder, refactoring r=def- a=Robyt3

Closes #5995.

## 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>
2023-04-26 17:49:25 +00:00
Robert Müller 97052e4752 Ignore switch tiles that don't use number for free slot finder 2023-04-26 19:04:57 +02:00
Robert Müller c4eca1a0ba Always set number 0 for switch tiles that don't use the number
And use the new `IsSwitchTile(Flags|Number|Delay)Used` functions accordingly.
2023-04-26 19:04:56 +02:00
Robert Müller 6d23f3e5bd Always set number 255 for tele tiles that don't use the number
Because code previously cast this number to `bool`, we can't use `0` to denote tele tiles where the number is unused.
2023-04-26 19:04:56 +02:00
Robert Müller 2e5f37c61b Don't render switch number and delay for tiles where they are unused 2023-04-26 19:04:56 +02:00
Robert Müller 60c0da7c4d Use IsValid***Tile functions
Use the utility function to check if tele/speedup/switch/tune tile indices are valid.

Using `IsValidSwitchTile` fixes that the switch number and delay were not updated when selecting freeze, deep freeze, deep unfreeze, live freeze and live unfreeze tiles, as those tiles were missing in the existing condition.
2023-04-26 19:04:56 +02:00
Robert Müller 1d9cbba326 Add IsSwitchTile(Flags|Number|Delay)Used functions
To check whether the flags, number or delay of a switch tile is used or not.
2023-04-26 19:04:56 +02:00
Robert Müller 9c841f1e43 Add IsTeleTileNumberUsed function
To check whether the number of a tele tile is used or not.
2023-04-26 19:04:55 +02:00
Robert Müller 245703798b Use bool for IsCheckTeleport and IsCheckEvilTeleport
The tele tile number is not used for `TILE_TELECHECKIN` and `TILE_TELECHECKINEVIL` and the results of these functions were always implicitly converted to `bool` while assuming that the tele number was not `0` for these tiles.
2023-04-26 19:04:54 +02:00
Robert Müller c23c5d900e Remove dead code 2023-04-26 19:04:54 +02:00
bors[bot] fcee2fa6a7
Merge #6532
6532: Fix input as the comments suggest for the next SDL version r=def- a=Jupeyy

Since we want to upgrade SDL version.

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)

<!-- 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: Jupeyy <jupjopjap@gmail.com>
2023-04-25 20:10:25 +00:00
Jupeyy 7fa14139d8 Fix input as the comments suggest for the next SDL version
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)
2023-04-25 18:45:03 +02:00
bors[bot] 181d831411
Merge #6530
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>
2023-04-25 15:47:07 +00:00
bors[bot] 4d39245e58
Merge #6531
6531: fix transparency in grass_main r=Jupeyy a=mindTW

<!-- What is the motivation for the changes of this pull request? -->
Closes  #6499.

before:
![grafik](https://user-images.githubusercontent.com/46008453/233847590-f8462f81-4525-449d-859c-18bfb07f53ff.png)

after:
![grafik](https://user-images.githubusercontent.com/46008453/233847608-211212ed-7fcd-46d3-a2b5-9ad92246f95a.png)


<!-- 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

- [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: mindTW <mindteeworlds@gmail.com>
2023-04-23 19:10:53 +00:00
bors[bot] 8f2df41af1
Merge #6528
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>
2023-04-23 17:39:35 +00:00
mindTW 78993917e0 fix transparency in grass_main 2023-04-23 16:57:22 +02:00
Robert Müller ebb2e4253d Port line input and IME support from 0.7
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.
2023-04-23 15:00:29 +02:00
Robert Müller f77af29094 Add text cursor setting to always render caret (disable blinking)
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.
2023-04-23 15:00:26 +02:00
Robert Müller 08b0a03ca4 Render selection in front of text instead of behind it
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.
2023-04-23 15:00:25 +02:00
Robert Müller ca90d83c10 Allow adjusting height factor of text selection rectangle
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.
2023-04-23 15:00:25 +02:00
Robert Müller d30ebf33e5 Use dynamic size buffer in teehistorian tests instead of CPacker
`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.
2023-04-23 12:40:21 +02:00
bors[bot] facbcfc391
Merge #6527
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>
2023-04-23 10:24:59 +00:00
ChillerDragon ae41ff3fb3 Fix NET_MAX_CHUNKHEADERSIZE 5 -> 3
Probably has no big impact but 5 is just wrong.
Was also casually fixed in upstream.

c2e5771a15 (diff-706d36dc3648350992fd7fb372d2461cbddcec7ac79f1f905f329ada2bcda814L49)
2023-04-23 11:51:34 +02:00
bors[bot] 15620354b9
Merge #6521
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>
2023-04-22 18:43:30 +00:00
bors[bot] 87f4f4fc6b
Merge #6524
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>
2023-04-22 16:39:23 +00:00
Robert Müller 001d11d9ed Refactor CEditorMap::CMapInfo
Reduce duplicate code. Make code more similar to upstream.
2023-04-22 16:46:10 +02:00
Robert Müller c9baa5f0d6 Remove dead code 2023-04-21 18:47:44 +02:00