Commit graph

4317 commits

Author SHA1 Message Date
bors[bot] cdd19beee4
Merge #6437
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>
2023-04-21 10:37:40 +00:00
VoxelDoesCode 049d89ca41 Simplify NetMsg even more, with help from Fokko
Quick changes

Add m_First

one more thing

fokko pointed this out at 3 am

Final push
2023-04-18 07:51:44 -04:00
bors[bot] 391c127cb3
Merge #6515
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>
2023-04-18 11:33:14 +00:00
Robert Müller a2c9b752e0 Remove unused CListBox::FilterMatches 2023-04-15 13:07:40 +02:00
ChillerDragon 7c2c5aeee7 Add OnNewSnapshot to component hooks 2023-04-15 12:47:33 +02:00
Robert Müller c7cea0a37f Fix incorrect chat background rect width calculation
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.
2023-04-15 12:17:49 +02:00
bors[bot] b1f2862cff
Merge #6511
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>
2023-04-10 17:29:23 +00:00
bors[bot] 4d697c7be3
Merge #6509
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>
2023-04-10 17:08:19 +00:00
Robert Müller 301567507f Fix client crash when spectating on server with missing game info 2023-04-10 17:27:21 +02:00
Robert Müller 8f5708a882 Use TextBoundingBox for tooltip rendering
Calculate correct height for tooltip and apply consistent padding.

Ensure tooltip width and height do not exceed size of screen.
2023-04-10 17:22:10 +02:00
Robert Müller a6f9fdd6d5 Add function to get caret position to ITextRender
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.
2023-04-10 17:22:10 +02:00
Robert Müller 9ad2f9f4df Add functions to get text bounding box to ITextRender
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.
2023-04-10 17:22:10 +02:00
Robert Müller 8507a651d1 Refactor vertical alignment in UI
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.
2023-04-10 17:22:09 +02:00
Robert Müller 76ad9e2e3b Use Localizable instead of comment with Localize 2023-04-10 16:43:53 +02:00
Robert Müller 430e96346f Fix inconsistent text wrapping of popup labels
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.
2023-04-09 20:10:44 +02:00
Robert Müller 6decf14137 Use Text instead of TextEx for popup labels
To reduce duplicate code and ensure that the same flags are used with `TextWidth` and when actually rendering the text.
2023-04-09 20:10:44 +02:00
Robert Müller 9bb9c7ce6b Replace usages of TextLineCount with TextWidth
Calculate text height for popups with `TextWidth` instead of using `TextLineCount`, which can be incorrect if the aligned font size differs from the normal one.
2023-04-09 20:10:44 +02:00
Robert Müller 9693d4beac Fix vertical centering of multi-line UI labels
Also calculate text height in `TextWidth`.

Use calculated text height to verically center UI labels.

The text cursor flags (in particular, the `TEXTFLAG_STOP_AT_END` flag) must also be passed to `TextWidth`. Otherwise, for example, when `TEXTFLAG_STOP_AT_END` is missing, the wrong text height is calculated, as text is rendered over multiple lines instead of stopping at the end of the first line.

Closes #5396.
2023-04-09 20:10:09 +02:00
Robert Müller 07c59d130b Minor refactoring of DoLabel functions 2023-04-09 20:10:09 +02:00
Robert Müller ede3e5631f Move generic popup handling to UI (port from editor and upstream)
Support using editor popup rendering in game client.

Support unlimited number of popup menus instead of maximum of 8.

Fix non-active popups handling key events. Add `Active` parameter to popup function, so key events are only processed by the active (top-most) popup. Previously the "New folder" popup could be confirmed with enter while an error message is shown, which causes multiple error messages to stack.

Allow popups to close without closing their child popups. Previously a popup could not open another popup and close itself immediately afterwards, as this was causing the newly opened popup to be closed instead.

Support using return/enter keys to confirm binary choice popups and to close message popups for more convenient usage.
2023-04-07 17:16:16 +02:00
Robert Müller 72775f236b Let CUI::Screen return a const pointer
Callers should never modify the UI screen.
2023-04-07 11:50:48 +02:00
Valentin Bashkirov 85485d23ce highlight game type 2023-04-05 20:02:25 +02:00
VoxelDoesCode df48c44e78 Bring every Font Icon unicode into a namespace
Fix namespace hopefully
2023-04-03 20:25:28 -04:00
VoxelDoesCode 0dfced4ca4 Bring Team logic into teams.cpp
MsgPlus -> Msg
2023-04-02 21:40:39 -04:00
Dennis Felsing 5fa2fefd35 Remove unused DoFilter
Thanks to cheeser0613
2023-04-01 13:39:20 +02:00
Jupeyy ffe3d26e59 fix start size of freezing flakes particles & vel of player death 2023-03-28 21:33:48 +02:00
bors[bot] a27dbb1219
Merge #6435
6435: add proof mode for menu backgrounds closes #3009 r=def- a=Marmare314


![backgroundproof](https://user-images.githubusercontent.com/49279081/225979288-3fb43d41-79f7-477e-8479-6b3d106fbd5b.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-03-27 14:48:18 +00:00
VoxelDoesCode 5b1a716aa2 Simplify KillMsgTeams NetMsg, fixing bugs
Clang format before squash

Split apart OnMessage() before squash

forgot something
2023-03-26 23:32:34 -04:00
bors[bot] b207826df1
Merge #6470
6470: Fix ninja not getting predicted r=heinrich5991 a=Zwelf

Fixes #6464

This was regressed by #6246 by the wrong transformation of `if(!m_FreezeTime)` to `if(m_FreezeTime != 0)` instead of the correct `if(m_FreezeTime == 0)`.

And take additional measure to never set m_FreezeTime to a negative number in client prediction code.

## 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: Zwelf <zwelf@strct.cc>
2023-03-26 14:50:25 +00:00
Zwelf d40ff12d9a Fix ninja dash not getting predicted correctly
Fixes #6464

This was regressed by #6246 by the wrong transformation of `if(!m_FreezeTime)`
to `if(m_FreezeTime != 0)` instead of the correct `if(m_FreezeTime == 0)`.

And take additional measure to never set m_FreezeTime to a negative
number in client prediction code.
2023-03-26 16:42:31 +02:00
Robert Müller 1b19895204 Ensure texture is cleared when rendering MOTD background
Seems like there are cases where the texture is not cleared when the MOTD background is rendered, so part of the font texture is used for the round rect.
2023-03-26 13:15:36 +02:00
Ravie 20ac914e0e Tooltip ID 2023-03-25 16:13:29 +01:00
Ravie eb41ecf3d7 Icon button, tooltip and various fixes 2023-03-25 15:43:25 +01:00
Ravie 705be7c6e3 Implement random skin button 2023-03-25 13:11:47 +01:00
Robert Müller 880ced2de0 Fix dummy tee being able to ping main tee in chat
Main and dummy tee cannot ping each other anymore. Other main and dummy tees can still ping your own main and dummy tees.

We must ensure to only use `m_aLocalIDs[1]` when the dummy is connected, as this ID is not updated when no dummy is connected, so it can refer to another client if you disconnect your dummy and another client subsequently takes its client ID.

Closes #3699.
2023-03-23 20:24:28 +01:00
bors[bot] 971b166488
Merge #6439
6439: Refactor `random` functions r=heinrich5991 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>
2023-03-23 12:56:55 +00:00
Robert Müller a91b51c8a2 Select language on first start based on user locale
On first client start (when `cl_show_welcome` is `1`), determine the user locale with `os_locale_str` and initially select the most fitting language for this locale.

For this the language index must also be loaded immediately on client launch, before the initial language is loaded.
2023-03-21 21:17:40 +01:00
Robert Müller 481698c7d0 Move CLanguage and LoadLanguageIndexfile to localization
The `CLanguage` class and `LoadLanguageIndexfile` function are more appropriately located in the file for the other localization functions.
2023-03-21 21:17:40 +01:00
VoxelDoesCode 929675be68 Make team kills condensed in killfeed
Clang + Formatting test before merge
2023-03-18 23:27:59 -04: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 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 0cbc725235 fix formatting and include array 2023-03-18 08:07:25 +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
marmare314 fe221dab23 implement draggable layers 2023-03-17 11:28:08 +01: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