Commit graph

12618 commits

Author SHA1 Message Date
Robert Müller a4b489aa87 Fix incorrect sixup detection when snapping pickups
For 0.7 clients the client version is not `VERSION_NONE`, so `IsSixup` was never called for them, which leads to version 0.6 pickups being snapped for 0.7 clients. This causes snapshot CRC errors for the 0.7 clients, as the 0.6 and 0.7 pickup structs have different sizes.

Now the version is no longer checked before calling `IsSixup`, which is the case in all other locations where the function is called and was also the case before this bug was introduced by #6330.
2023-03-20 19:01:44 +01:00
bors[bot] 8a9489292e
Merge #6443
6443: Reveal selection when scrolling layer list with up/down arrow keys r=def- a=Robyt3

Closes #6441.

## 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-03-19 13:19:54 +00:00
Robert Müller baa448580a Use str_format_v for log_log_impl
Reduces duplicate code. This also ensures that the log messages are properly zero-terminated and that they do not end with truncated unicode characters.
2023-03-19 12:50:28 +01:00
Robert Müller 0c6c52e8d9 Reveal selection when scrolling layer list with up/down arrow keys
Closes #6441.
2023-03-19 12:34:50 +01:00
bors[bot] 854445d4e1
Merge #6434
6434: Show popups in editor when loading/saving file fails, fix minor issues with preview image r=def- a=Robyt3

![screenshot_2023-03-17_13-00-59](https://user-images.githubusercontent.com/23437060/225899583-fb264a56-ad9d-455e-b80b-885aad2fbd51.png)

![screenshot_2023-03-17_13-00-46](https://user-images.githubusercontent.com/23437060/225899589-d143d9db-ccaf-47d6-92cf-dea3dd49ab80.png)

![screenshot_2023-03-17_13-00-38](https://user-images.githubusercontent.com/23437060/225899590-527bb926-a244-4a55-ab3b-69953b836cf3.png)

![screenshot_2023-03-17_13-00-16](https://user-images.githubusercontent.com/23437060/225899598-abfa9c44-d2c5-4261-8459-2a4d612d480f.png)

![screenshot_2023-03-19_11-12-28](https://user-images.githubusercontent.com/23437060/226169030-e4d33cb1-238f-4e7d-a57d-1cf0a8bb18ea.png)

![screenshot_2023-03-17_12-59-42](https://user-images.githubusercontent.com/23437060/225899607-3613b4b6-2ef8-45c9-8803-61380ef675a7.png)

When using Ctrl+S:

![screenshot_2023-03-17_12-59-31](https://user-images.githubusercontent.com/23437060/225899610-44dbda9d-1207-4456-8219-a5a4947691fe.png)

Closes #6430.

## 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-03-19 11:21:51 +00:00
Robert Müller 99ef97a0f8 Use variadic arguments for ShowFileDialogError formatting
Reduces duplicate code when calling the function.

Also increase the size of the message popup message, as it was not large enough for all paths.
2023-03-19 11:48:39 +01:00
Robert Müller d0fe1087db Add str_format_v with va_list argument
So the string formatting can be reused in other places. Passing variadic arguments directly to another function is not possible.

The function must have a different name, as overloading `str_format` would cause the wrong function to be called when passing the `va_list`. The same naming with suffix `_v` is used for the logging functions.
2023-03-19 11:48:39 +01:00
bors[bot] 22b7e5eaf4
Merge #6438
6438: Fix incorrect tee blood color being shown in settings r=def- a=Robyt3

When the tee color lighting is set to 0, the blood color was shown as black instead of the actual tee blood color. The blood color used ingame is already correct and now matches the color shown in the settings.

## 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-03-18 22:14:29 +00:00
Robert Müller c5f2727a3f Fix inconsistent slow mouse in editor
The mouse slow flag must be reset at the beginning of the render function in the editor instead of at the beginning of the update function, as it otherwise only works very inconsistently.
2023-03-18 22:26:43 +01:00
Robert Müller 484df7fc79 Support holding shift for slow mouse with color pickers
When picking a color with a color picker also support holding shift to move the mouse slowly (at 5% normal speed) like for scrollbars.
2023-03-18 22:24:46 +01:00
Robert Müller a9ef757475 Add random_float functions with min and max arguments
Add `random_float(float min, float max)` to generate a random `float` between `min` and `max`.

Add `random_float(float max)` to generate a random `float` between `0.0f` and `max`.
2023-03-18 12:09:37 +01:00
Robert Müller 0cf5dd7ad3 Add random_direction function
Replace existing `RandomDir` with this function. This function was biased towards the corners, as it first generates a random `vec2` with `x` and `y` in `[-0.5f;0.5f]` and then normalizes it, which doesn't result in a uniform distribution of directions. Now the random direction is generated by taking a random angle and then converting it to a direction which is per definition already normalized.
2023-03-18 12:09:37 +01:00
Robert Müller ea6e267d98 Add random_angle function
To generate a random angle in the range `[0.0f;2.0f * pi[`. This ensures that the random angle cannot be `2.0f * pi`, which would be identical to the angle `0.0f` and therefore cause the random angle to be less uniformly selected.

Note that this first casts `RAND_MAX` to a `float` and then uses `std::nextafter` to get the next larger `float`. Using `RAND_MAX + 1` would cause an integer overflow on systems where `RAND_MAX == INT_MAX` (e.g. Ubuntu and macOS).
2023-03-18 12:07:52 +01:00
Robert Müller d2bd863c79 Fix incorrect tee blood color being shown in settings
When the tee color lighting is set to 0, the blood color was shown as black instead of the actual tee blood color. The blood color used ingame is already correct and now matches the color shown in the settings.
2023-03-18 11:09:49 +01:00
marmare314 7f0c0523fd fix formatting 2023-03-18 08:19:52 +01:00
marmare314 0cbc725235 fix formatting and include array 2023-03-18 08:07:25 +01:00
marmare314 8e2869e280 add tooltips 2023-03-18 07:53:18 +01:00
marmare314 9537656e57 use array again and consider checkpoints 2023-03-17 19:25:50 +01:00
marmare314 0ce70f863b add proof mode for menu backgrounds closes #3009 2023-03-17 18:37:55 +01:00
Robert Müller 3ab0fa7653 Fix editor preview image not being updated after searching
The preview image was not being updated after the search term is changed. Changing the search term causes the selected image to be changed, so the preview image also needs to be updated.
2023-03-17 12:58:25 +01:00
Robert Müller 9b8d8e4965 Don't reload editor preview image every frame if it's invalid
If the preview image in the "Add image" dialog could not be loaded it was retried every frame, which causes a debug message to be printed each time.

Now a tristate variable is used to ensure that the image is not reloaded after is previously failed to load.
2023-03-17 12:58:25 +01:00
Robert Müller 0c67d033ea Show popups in editor when loading/saving file fails
Show error message in a popup at the current mouse position when a file operation fails. Also works when pressing Ctrl+S to save.

When replacing images/sounds also first check if an image/sound with that name already exists.

When replacing sounds also first check whether the replacement sound could be loaded and don't replace existing sound with invalid sound on failure.

Replace existing error message for "Create folder" dialog with the new mechanism.

Closes #6430.
2023-03-17 12:58:24 +01:00
bors[bot] 5e2e1e25e3
Merge #6433
6433: add show directory button in filedialog closes #6422 r=Robyt3 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
- [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-03-17 11:30:35 +00:00
marmare314 b477173b8a add show directory button in filedialog 2023-03-17 12:17:31 +01:00
marmare314 fe221dab23 implement draggable layers 2023-03-17 11:28:08 +01:00
marmare314 1ccd357f53 check for success when decoding audio 2023-03-17 10:39:17 +01:00
marmare314 115cd4c4a3 fix bug when loading invalid opus file 2023-03-17 09:12:15 +01:00
bors[bot] cc612a7e18
Merge #6423
6423: Always enable editor panning and zooming when GUI is hidden r=heinrich5991 a=Robyt3

The `UI()->MouseInside(&View)` check does work when the mouse is all the way at the right or bottom side. Changing the `MouseInside` functions introduces other problems due to UI element and mouse positions being floating point numbers and not corresponding to exact pixels.

As a workaround to enable unlimited editor panning in all direction when the GUI is hidden the check is omitted, as the map editor encompasses the entire view and so the check is not necessary in this case.

Closes #4553.

## 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-03-16 20:51:17 +00:00
bors[bot] 5241c4ce5f
Merge #6425
6425: Don't add duplicate consecutive commands to console history r=heinrich5991 a=Robyt3

Don't add entered command to console history, if the last console history entry is identical to this command. For example, entering the commands `1`, `2`, `3`, `3`, `2`, `1` adds 5 entries to the history, i.e. only one entry for the command `3`.

## 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-03-16 20:29:33 +00:00
Robert Müller 66ad9536fe Extend CScrollRegion to support scrolling when mouse at edge
Add `ScrollRelative` function to initiate relative scrolling programmatically, to realise scroll regions that scroll when the mouse is being dragged at the edge.

Add `DoEdgeScrolling` to encapsulate all the necessary edge scrolling logic based on the position of the mouse. The edge scrolling starts at a fixed distance from the edges. The scrolling speed is dependent on the distance of the mouse from this border.
2023-03-16 13:07:04 +01:00
Robert Müller d08f784a97 Don't add duplicate consecutive commands to console history
Don't add entered command to console history, if the last console history entry is identical to this command. For example, entering the commands `1`, `2`, `3`, `3`, `2`, `1` adds 5 entries to the history, i.e. only one entry for the command `3`.
2023-03-14 23:33:06 +01:00
Robert Müller 3808a23bc7 Always enable editor panning and zooming when GUI is hidden
The `UI()->MouseInside(&View)` check does work when the mouse is all the way at the right or bottom side. Changing the `MouseInside` functions introduces other problems due to UI element and mouse positions being floating point numbers and not corresponding to exact pixels.

As a workaround to enable unlimited editor panning in all direction when the GUI is hidden the check is omitted, as the map editor encompasses the entire view and so the check is not necessary in this case.

Closes #4553.
2023-03-14 22:19:40 +01:00
bors[bot] 762f1a1262
Merge #6421
6421: ignore tiles that dont use ids in ContainsElementWithId r=Robyt3 a=Marmare314

See #5908. As far as I can tell this function is only used in the popup, so this should not break anything.

## 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: marmare314 <49279081+Marmare314@users.noreply.github.com>
2023-03-14 20:02:14 +00:00
bors[bot] 5f7f30d009
Merge #6419
6419: add sorting by name and time modified to filedialog r=Robyt3 a=Marmare314

As suggested in #4508 it would be nice to have at least some basic sorting ability in the filedialog. This PR implements at least the two most important sorting criteria: filename and time modified. Also the time modified is now displayed.
At the moment the characters ▲ and ▼ are used to indicate the sorting direction. Maybe there is a nicer way to display this.
![file_dialog_1](https://user-images.githubusercontent.com/49279081/224561567-d3335ca0-d9c9-4d44-ab97-31ce177d287e.png)
![dialog_2](https://user-images.githubusercontent.com/49279081/224561570-4182ba16-bfe0-42d7-b2ee-0f49895fec85.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
- [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-03-14 18:55:19 +00:00
marmare314 71c8aad8d4 ignore tiles that dont use ids in ContainsElementWithId 2023-03-14 18:39:12 +01:00
marmare314 223813e519 reset timemodified sort 2023-03-14 17:17:24 +01:00
Robert Müller 1e74e06908 Fix slash removal when multiple slashes are pasted in editor
When pasting text containing multiple consecutive (back)slashes in the editor save dialog not all slashes where removed. For example with the text `/a//bb/\/ccc////dddd//\//`.
2023-03-14 13:32:06 +01:00
marmare314 fb5cb3e131 fix formatting 2023-03-12 19:57:46 +01:00
marmare314 c338eca199 ignore time for links and root folder 2023-03-12 19:41:58 +01:00
marmare314 e2449ac3b8 use str_timestamp_ex and fix codestyle 2023-03-12 18:54:57 +01:00
marmare314 9540d27a10 fix formatting issues and clean up indicator selection 2023-03-12 18:39:11 +01:00
marmare314 f012716af6 add sorting by name and time modified to filedialog 2023-03-12 18:10:22 +01:00
bors[bot] 20ae11567f
Merge #6416
6416: use ValueSelector for envelope selection #3598 r=def- a=Marmare314

Allow choosing envelopes by typing its ID.

## 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: marmare314 <49279081+Marmare314@users.noreply.github.com>
2023-03-12 15:29:12 +00:00
marmare314 05204bbcb8 use ValueSelector for envelope selection closes #3598 2023-03-12 15:58:38 +01:00
Robert Müller 1b1fc8de3e Save screenshot in separate thread to avoid lags
Encoding the image as PNG and saving it to a file comprises the majority of the time when taking a screenshot.

To avoid the client freezing while a screenshot is being saved, this task is moved to a separate background thread.
2023-03-11 13:19:57 +01:00
bors[bot] 2323359ea5
Merge #6409
6409: Refactor server process launching from client 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>
2023-03-10 23:20:28 +00:00
bors[bot] f5970645e8
Merge #6406
6406: Fix deprecation warning in ffmpeg 6 (fixes #6398) r=Robyt3 a=def-

<!-- 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: Dennis Felsing <dennis@felsin9.de>
2023-03-10 19:59:05 +00:00
Robert Müller 3996ee01a7 Close process handle on Windows after process is killed
Prevent leak of process handle. Keep the handle open if the process could not be killed, so killing can be attempted again.
2023-03-10 18:02:39 +01:00
Robert Müller 128d3e4758 Handle return value of kill_process
Only clear process handle if the process was actually killed.
2023-03-10 17:59:36 +01:00
Robert Müller a0c61a1b60 Add INVALID_PROCESS to represent invalid PROCESS value 2023-03-10 17:39:24 +01:00
Robert Müller 4834cfdac9 Rename CServerProcess::Process to CServerProcess::m_Process 2023-03-10 17:38:04 +01:00
Robert Müller 8d225fd3e7 Remove unused CServerProcess members 2023-03-10 17:36:33 +01:00
Robert Müller 4a94ab340f Fix some potentially undefined editor member variables
See #6407.
2023-03-10 17:18:24 +01:00
Dennis Felsing 3428968702 Fix deprecation warning in ffmpeg 6 (fixes #6398) 2023-03-10 14:38:37 +01:00
Robert Müller e07d9ae724 Use std::size(g_Config.m_SvMotd) instead of magic number 900
The size of the `sv_motd` config variable is also `900`.
2023-03-10 00:32:51 +01:00
Robert Müller de99fecaa0 Use text container for ingame server info MOTD
Optimize MOTD rendering in ingame menu by caching the text.

Use the correct text height based on the aligned font size instead of the original font size, to fix the discrepancy between the scrollable height and the text height.
2023-03-09 23:48:31 +01:00
Robert Müller c286f32b17 Use text and quad containers for ingame MOTD, refactor variables
Optimize MOTD rendering by caching the round rect and the text.

Align font and rect sizes so exactly 24 lines of text fit in the MOTD rect with margins on all sizes.
2023-03-09 23:04:19 +01:00
Robert Müller a02738bd2e Mark CMotd::IsActive as const 2023-03-09 23:04:19 +01:00
Robert Müller 53635deb35 Encapsulate CMotd::m_aServerMotd with getter 2023-03-09 23:04:18 +01:00
Robert Müller f7d7592cb7 Add CTextCursor::Height() to calculate actual height of cursor 2023-03-09 23:04:18 +01:00
Robert Müller a0f1b4118d Use round_to_int in text render
For positive numbers, which the text positions always are, the result of `(int)(x + 0.5f)` is identical to `round_to_int(x)`.
2023-03-09 23:04:18 +01:00
Robert Müller 92615617b2 Use mem_copy instead of memcpy for websockets
Replace all remaining usages of `memcpy`.
2023-03-09 13:16:49 +01:00
Panagiotis "Ivory" Vasilopoulos 776eabcc78 Replace leftover memcpy with mem_copy
This change was made as I was doing some tests for the Haiku port.
2023-03-09 11:50:15 +01:00
bors[bot] 0fd284a6f3
Merge #6392
6392: Add missing default value for custom parallax zoom property r=def- a=Robyt3

The "Custom Zoom" property was not initialized when creating a new layer group, leading to the property editor not working correctly and an undefined value being saved to the map file.

![property-editor](https://user-images.githubusercontent.com/23437060/223575784-81ce5eeb-992e-4084-985b-183b4389090c.png)

## 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-03-07 23:22:28 +00:00
Robert Müller 96ccfbb4c2 Add missing default value for custom parallax zoom property
The "Custom Zoom" property was not initialized when creating a new layer group, leading to the property editor not working correctly and an undefined value being saved to the map file.
2023-03-08 00:15:15 +01:00
Robert Müller da08533adf Revert "When GUI inactive, unlock mouse and don't render popup menus"
This reverts commit 0e476dfd70.
2023-03-07 22:51:56 +01:00
Robert Müller d69084ca0d Revert "Close editor popups and prevent popups from opening when GUI hidden"
This reverts commit 5c4d5fb571.
2023-03-07 22:43:35 +01:00
Robert Müller 5c4d5fb571 Close editor popups and prevent popups from opening when GUI hidden
Prevent editor popups (quad point, quad pivot, sound source) from being opened while the editor GUI is hidden. The opened popups would not be visible, which results in multiple identical popups being opened at the same time. This cannot happen while the GUI is shown, as the already opened popup takes focus so no second identical popup can be opened at the same time.

Additionally, all opened popups are now closed when the GUI is hidden. Otherwise this results in crashes, as the already opened popups reference the current layer and quad selection, which can change or become invalidated while the GUI is hidden.

Closes #6383.
2023-03-07 00:31:31 +01:00
bors[bot] 5107b38d04
Merge #6324 #6345
6324: Optimize client ids map update r=def- a=0xfaulty

I have launched support for 128 players in testing mode on my server, it's means it's time for another step in this direction here. Perhaps not all changes will be clear, I am ready to answer/discuss them as usual. Let me know if I forgot or didn't take anything into account.

## 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)


6345: Set constant and uniform names for the server and client CMake targets r=def- a=Kaffeine

This MR set the server and client CMake target names to `game-server` and `game-client` which are uniform with other targets such as `engine-gfx`, `engine-shared`, and `game-shared`.

Set uniform names for the targets to:
1. Avoid long rebuilds on the target _executable_ name changed
2. Provide the same name for different executables and/or different setup (use-cases are `cmake --build . --target game-server` and various CMake target lookups in IDEs)

Those changes are necessary but not enough to allow CI for custom app name on all platforms.

Personally this 'll allow me switch to between DDNet and Infclass branches faster and without breaking the targets configuration (e.g. with that patchset I can have `game-client` as an active target in both branches), and also reduces the conflicts in `CMakeLists.txt`.
Easier to switch between the forks => easier to contribute.

Co-authored-by: Valentin Bashkirov <valenteen3d@ya.ru>
Co-authored-by: Valentin Bashkirov <v.bashkirov@dev.tassta.com>
Co-authored-by: Alexander Akulich <akulichalexander@gmail.com>
2023-03-05 16:53:37 +00:00
ChillerDragon 97ac4e791e Flush NETMSG_PING and NETMSG_PING_REPLY
The client measures the time difference between
ping send and ping reply receive.
Without MSGFLAG_FLUSH the server keeps the chunk
until the next flush which makes the ping dependend
on when the next flush happens.
2023-03-05 17:29:14 +01:00
Dennis Felsing 0ff19c617a Fix color in json (fixes remaining #6366 hopefully) 2023-03-05 15:43:15 +01:00
Dennis Felsing 38933d319f Fix invalid json (partially fixes #6366) 2023-03-05 15:43:15 +01:00
Dennis Felsing d6f617debd Version 16.8 2023-03-05 15:41:26 +01:00
bors[bot] a14f32cf47
Merge #6369
6369: Fix Move also requesting the current canvas size, which should report… r=Robyt3 a=Jupeyy

… a resize event

fixes #6368

For some reason KDE seems to set the current window'd size of the window (even if i use fullscreen)  for the window when its minimized. And ::Move re-requests the canvas size.

This resulted in the incorrect viewport.

Funnily enough for me under KDE this also means that the check for GotResized, to only notify the components when the canvas actually resized is now useless.

`@Robyt3` can you check if Windows is not doing this behavior? Else the previous patch is useless for the crash bug :D
On the other hand, this *could* have been part of the text container bug, tho I cannot imagine yet why

## 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-03-05 11:53:12 +00:00
Robert Müller 75d371743e Disable editor file browser hotkeys while another popup is open
Prevent enter, escape, up/down and F5 keys from manipulating the editor file browser while a popup menu (map details, new folder) is open.
2023-03-03 22:28:56 +01:00
Robert Müller dc2601f335 Fix opening file in editor with enter not working after searching
The filename of the selected file is tracked separately and was not updated when the search term in the Open File dialog is changed.
2023-03-03 22:28:08 +01:00
ChillerDragon 20853793ee Fix server logfile error message 2023-03-02 09:44:27 +01:00
bors[bot] 0f5d4d8bec
Merge #6372
6372: Check in CI that no C standard headers are used, replace all usages of C standard headers with C++ headers, replace usages of C math functions r=def- a=Robyt3

Closes #6334.

## 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-03-01 22:34:26 +00:00
Robert Müller db4ec4a12d Replace usages of C math functions
Replacing the C standard headers with the C++ standard headers causes various `error: call to 'floor' promotes float to double [performance-type-promotion-in-math-fn,-warnings-as-errors]`, which are fixed by using the C++ std math functions or our own math functions instead of the C math functions.

- Use `absolute` instead of `abs` and `fabs`.
- Use `std::floor` instead of `floor` and `floorf`.
- Use `std::ceil` instead of `ceil`, `ceilf` and `round_ceil`.
- Use `std::round` instead of `round` and `roundf`.
- Use `std::sin` instead of `sin` and `sinf`.
- Use `std::asin` instead of `asin` and `asinf`.
- Use `std::cos` instead of `cos` and `cosf`.
- Use `std::acos` instead of `acos` and `acosf`.
- Use `std::tan` instead of `tan` and `tanf`.
- Use `std::atan` instead of `atan` and `atanf`.
- Use `std::pow` instead of `pow` and `powf`.
- Use `std::log` instead of `log` and `logf`.
- Use `std::log2` instead of `log2` and `log2f`.
- Use `std::log10` instead of `log10` and `log10f`.
- Use `std::pow` instead of `pow` and `powf`.
- Use `std::sqrt` instead of `sqrt` and `sqrtf`.
- Use `std::fmod` instead of `fmod` and `fmodf`.
- Use `direction(Angle)` instead of `vec2(std::cos(Angle), std::sin(Angle))`.
- Use `length(vec2(x, y))` instead of `std::sqrt(x * x + y * y)`.
- Remove unused `NormalizeAngular` and `AngularDistance` functions.
2023-03-01 19:26:53 +01:00
Robert Müller a76fb9b99a Replace all usages of C standard headers with C++ headers 2023-03-01 19:26:51 +01:00
Robert Müller 24fd7e626d Fix client crash when cl_chat_old config is used
The graphics are not initialised when `RebuildChat` is called by `ConchainChatOld`, which causes the client to crash if `cl_chat_old` is present in the user's config or used as a command line argument.
2023-02-28 21:43:21 +01:00
Valentin Bashkirov 287d36c4d1 fixed comments 2023-02-28 13:06:50 +01:00
Jupeyy c7362ba6c4 Fix Move and SetWindowScreen also requesting the current canvas size, which should report a resize event 2023-02-26 13:56:37 +01:00
bors[bot] e992089d02
Merge #6364
6364: Fix incorrect text wrapping in ingame server info r=def- a=Robyt3

The maximum width for the server info and game info text was too small, which previously didn't matter, because the manual newlines broke text wrapping in this case, but with the fix from #6353 this now causes the text to break after the colons already.

This is fixed by using the maximum available width for the text instead of a too small magic number (`250.0f`).

For completeness, the maximum width for the title texts is unset (`-1.0f`), because they should never wrap, which is consistent with the MOTD title text.

Before:

![screenshot_2023-02-26_11-46-26](https://user-images.githubusercontent.com/23437060/221405841-30c0a57a-d7ce-44c5-8c2e-958d67c801a4.png)

After:

![screenshot_2023-02-26_11-41-24](https://user-images.githubusercontent.com/23437060/221405844-faf9095f-07d9-4dde-bfd5-9e44197d1fce.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
- [ ] 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-02-26 11:52:18 +00:00
Robert Müller d1a9f0a76a Fix erratic smooth scrolling when scroll time is changed
Remember the maximum animation time when initiating a smooth scroll, so the smooth scrolling does not change erratically when `ui_smooth_scroll_time` is changed while smooth scrolling is in progress.
2023-02-26 12:12:08 +01:00
Robert Müller ffa4801220 Fix incorrect text wrapping in ingame server info
The maximum width for the server info and game info text was too small, which previously didn't matter, because the manual newlines broke text wrapping in this case, but with the fix from #6353 this now causes the text to break after the colons already.

This is fixed by using the maximum available width for the text instead of a too small magic number (`250.0f`).

For completeness, the maximum width for the title texts is unset (`-1.0f`), because they should never wrap, which is consistent with the MOTD title text.
2023-02-26 11:43:55 +01:00
Jupeyy 9530077588 Only call onresize events if actual size changed
clearify difference between resize and window property change for resolution list
2023-02-25 16:02:38 +01:00
Dennis Felsing fa3675d328 Improve warning text in backend_sdl 2023-02-25 10:40:36 +01:00
Robert Müller aace33fc3c Support 4 and 8 digit RGBA color values in console
In addition to values in `$RGB` and `$RRGGBB` format, also support the `$RGBA` and `$RRGGBBAA` formats for color variables.
2023-02-24 20:32:44 +01:00
Robert Müller cd15b93517 Remove unnecessary temporary variables 2023-02-24 18:11:16 +01:00
Robert Müller f5221caf50 Mark ColorRGBA/ColorHSLA functions as const 2023-02-24 18:10:32 +01:00
bors[bot] 931ea6d828
Merge #6351
6351: Fix client crash when echoing client message to chat, use em dash for client messages in chat like on upstream r=def- a=Robyt3

![client-message](https://user-images.githubusercontent.com/23437060/220452193-1ce5cc5b-b79b-4632-a675-5ca70c37e7f0.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
- [ ] 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-02-24 08:25:43 +00:00
Robert Müller a1821986fa Align color picker buttons on right side
Align the color picker selection and reset buttons on the right side instead of the left side dependent on the label width.

Closes #6237.

The `UseCheckBox` argument is removed and instead `pCheckBoxValue != nullptr` is used.
2023-02-23 22:32:04 +01:00
Robert Müller 541115022a Fix client crash when echoing client message to chat
The client crashes when printing a client message to the chat from a config file or from the command line, as the graphics have not been initialized at that point.

Closes #6350.
2023-02-23 21:49:56 +01:00
Robert Müller 284f3326a7 Use em dash for client messages in chat like on upstream 2023-02-23 21:49:56 +01:00
bors[bot] ebe605ab2e
Merge #6355
6355: Mark absolute #includes as absolute r=def- a=heinrich5991

Also verify that absolute imports are done using `#include <>` in CI.

## 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: heinrich5991 <heinrich5991@gmail.com>
2023-02-23 15:26:02 +00:00
heinrich5991 1a2c82c0b1 Mark absolute #includes as absolute 2023-02-23 10:53:16 +01:00
Robert Müller 3cd294372a Fix text rendering over maximum line width with newline
When a word is rendered over the maximum line width it should be moved to the next line.

However, this was not working correctly if the word ends with a newline instead of a space, because then the text x-advance including this word did not exceed the maximum width, as the newline caused the x-advance to be reset before it can be used.

This is fixed by replacing the unused flag `TEXTFLAG_ALLOW_NEWLINE` with the flag `TEXTFLAG_DISALLOW_NEWLINE`, which causes newline characters to be replaced with space characters. This flag is then used when calculating whether the next word fits in the current line.

Closes #4541.
2023-02-21 23:38:41 +01:00
Robert Müller 61bf48c1ed Add chat message constants from upstream, remove redundant comments
Add `CLIENT_MSG = -2` and `SERVER_MSG = -1` constants from upstream.

Remove comments for self-documenting code.
2023-02-21 20:46:17 +01:00
Robert Müller 8286105804 Use RecreateTextContainer, reorder parameters
The `RecreateTextContainer` function calls `DeleteTextContainer` and then `CreateTextContainer`.

The arguments of `RecreateTextContainer` and `RecreateTextContainerSoft` are reordered so all functions take the text container as their first argument.
2023-02-20 23:39:43 +01:00