Commit graph

4444 commits

Author SHA1 Message Date
bors[bot] 17c06423d2
Merge #6711 #6712
6711: Improve color picker popup in settings (use new popup system, add alpha support, support mouse locking) r=def- a=Robyt3

Use the popup system ported from the editor to reimplement the color picker popup.

- Before: 
![screenshot_2023-06-05_21-57-46](https://github.com/ddnet/ddnet/assets/23437060/52d6adfa-7d62-4323-b6df-8d18a26b6cc6)
- After:
![screenshot_2023-06-05_21-57-26](https://github.com/ddnet/ddnet/assets/23437060/773115db-178c-48ab-a750-35b136a4fb30)

Remove special handling necessary for the hard-coded color picker.

Add alpha support to the color picker popup.

Support locking mouse position when dragging value selectors also in menus (color pickers), which improves usability of value selectors. Previously this was only supported in the editor.

Replace large HSLA scrollbar color picker for UI color setting with inline color picker popup:
- Before:
![screenshot_2023-06-05_21-57-57](https://github.com/ddnet/ddnet/assets/23437060/bb6cee4d-5438-40a3-b602-90abccc959ee)
- After:
![screenshot_2023-06-05_21-57-01](https://github.com/ddnet/ddnet/assets/23437060/e0a565a6-2956-403f-9fc0-4ab11a764400)


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


6712: Fix crash when enabling `dbg_dummies` on running server r=def- a=Robyt3

The server normally needs to be reloaded to spawn the debug dummies, so this code was not checking if a debug dummy player exists. Decreasing the number of debug dummies while the server is running also causes them to simply not be snapped instead of completely destroying them.

For debugging any number of dummies can be useful, so the maximum number of debug dummies is increased to the maximum number of clients.

See #6702.

## 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: Robert Müller <robytemueller@gmail.com>
2023-06-05 21:56:58 +00:00
Robert Müller b21e98a227 Use color picker popup for UI color setting
Replace large HSLA scrollbar color picker for UI color setting with inline color picker popup.
2023-06-05 22:37:27 +02:00
Robert Müller e50bd4bb6c Add generic color picker popup to UI, add alpha support
Use the popup system ported from the editor to reimplement the color picker popup.

Remove special handling necessary for the hard-coded color picker.

Add alpha support to the color picker popup.
2023-06-05 22:37:27 +02:00
Robert Müller 938c57e03a Support mouse position locking in menus UI
Support locking mouse position when dragging value selectors also in menus (color pickers), which improves usability of value selectors.

Previously this was only supported in the editor.

When enabling locked mouse a UI element ID must be specified. The mouse lock is stopped when this element is no longer active. This ensures that the mouse doesn't gets stuck in this state when the value selector isn't active anymore.
2023-06-05 22:37:26 +02:00
Robert Müller ef217b69c9 Track updated mouse position in UI instead of menus
Simplify the UI usage for the menu by keeping the calculated mouse position variable together with the other mouse handling in `CUI`.
2023-06-05 22:37:26 +02:00
Robert Müller 68ea55e232 Move DoValueSelector to UI and refactor
Move `CMenus::DoValueSelector` to `CUI`.

Add parameter object `SValueSelectorProperties` for optional parameters to improve usability.
2023-06-05 22:37:26 +02:00
Robert Müller 351dc88b21 Disable resolution list box when popup is open
So hotkeys are not used by the list box before popup menus.
2023-06-05 21:09:58 +02:00
Robert Müller 2359e38913 Add CLineInputNumber::GetInteger64/SetInteger64, add prefix
Support entering `int64_t` with line inputs.

Add argument to specify length of zero-prefix for hexadecimal numbers.
2023-06-05 21:09:22 +02:00
Robert Müller 9ce76a1713 Use real instead of display string for number line inputs
Set input string if it's not identical to the real input string instead of comparing to the display string, which would be incorrect for hidden number inputs.
2023-06-05 19:13:20 +02:00
Robert Müller 6aa03c878e Fix escape not working in settings menu anymore
The color picker was always consuming the escape hotkey even when already disabled. Regression from #6705 due to changed order of hotkey consumption.
2023-06-05 16:56:07 +02:00
Robert Müller 265f16e23a Fix UI element check with m_HintCanChangePositionOrSize
It was incorrectly checked for `UIElement.Rect(0)->m_Y != pRect->h`, so any UI rect using `m_HintCanChangePositionOrSize` would be updated every frame (although, no UI element currently uses this hint).

Additionally, checks for changed rounding size and corners are added so UI elements are updated when those are changed.
2023-06-05 00:11:54 +02:00
bors[bot] 72108c42a7
Merge #6703 #6704
6703: Only highlight hovered edit boxes when they are the hot item r=def- a=Robyt3

Prevent highlighting when edit box hovered but behind a popup menu.

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


6704: Extract `CMenus::UpdateColors` and `CUI::DebugRender` functions to improve readability of `CMenus::OnRender` 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-06-04 18:27:22 +00:00
Robert Müller 455d2e5ccb Handle escape to go to start menu after popup menus
Popup menus should be closed before escape is used to navigate back to the start menu.
2023-06-04 17:33:45 +02:00
Robert Müller 1c16d0e799 Extract CUI::DebugRender function 2023-06-04 17:27:42 +02:00
Robert Müller 322e06e4a5 Extract CMenus::UpdateColors function 2023-06-04 17:26:32 +02:00
Robert Müller efea2de9d5 Only highlight hovered edit boxes when they are the hot item
Prevent highlighting when edit box hovered but behind a popup menu.
2023-06-04 17:25:12 +02:00
bors[bot] c227ed4bc5
Merge #6684 #6685 #6699
6684: Make server settings editor height adjustable by dragging r=heinrich5991 a=Robyt3

Same as for the envelope editor. Extract `RenderExtraEditorDragBar` function to reduce duplicate code.

Fix height being changed by repeated clicking on the draggable element by also resetting `s_Operation` when `Clicked` is `true`.

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


6685: Support dragging demo player controls to move them, fix minor related issues r=heinrich5991 a=Robyt3

Allow dragging the demo player controls anywhere on the screen. The controls can't be moved outside of the screen. Round corners are automatically disabled when the controls are on the edge of the screen.

https://github.com/ddnet/ddnet/assets/23437060/72510c1f-4fd2-426b-a631-3a78db5f7b8b

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


6699: Add dragger prediction r=def- a=trml

..for servers with the new ddnetlaser. Tested this locally and on Fun server, and seems to work.

Also adjusted the criteria for when to send the original dragger id slightly, to improve prediction in some edge cases when going through solo/unsolo while being dragged.

## 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>
Co-authored-by: trml <trml@users.noreply.github.com>
2023-06-03 20:46:26 +00:00
Jupeyy 9be2a78356 Fix killmessages might drop text container indices, if a killmsg was invalid
initially caused by #3430, probably triggered more often since our team kill msgs
2023-06-03 22:02:09 +02:00
trml 8121abf877 Add dragger prediction 2023-06-03 20:39:06 +02:00
Robert Müller 81d7b9f890 Add "No server selected" message to server details
Otherwise the tab is completely empty when no server is selected.
2023-06-01 22:29:14 +02:00
trml a090ba8cb3 Don't predict other players in solo 2023-05-29 15:01:38 +02:00
Robert Müller 3130649721 Support dragging demo player controls to move them
Allow dragging the demo player controls anywhere on the screen. The controls can't be moved outside of the screen. Round corners are automatically disabled when the controls are on the edge of the screen.
2023-05-29 12:35:23 +02:00
Robert Müller 6aa7d3dc63 Delay menu (de)activation until end of render call
The escape key was previously always causing the menus to be toggled in addition to the normal key handling.

Now the menu is activated/deactivated by using the same UI hotkey system as in the rest of the menus. By checking for the escape hotkey last in the render call, other parts of the menu, especially popup menus, can use the hotkey first.

Fixes escape key in the demo player closing demo controls and slice popup at the same time. Now the popup is closed first.
2023-05-29 12:30:17 +02:00
Robert Müller bbe2430be9 Fix tooltips being active behind popups and outside clipping rects
Ensure that tooltips are only activated when the associated UI element is currently the hot item. This prevents tooltips from being activated for UI elements that are currently not enabled due to them being behind a popup or outside of a clipping rect.
2023-05-29 12:29:02 +02:00
Robert Müller d9b5a8c3c4 Use X icon for demo close button, remove DoButton_DemoPlayer 2023-05-28 21:53:04 +02:00
Robert Müller 6feb46183e Improve demo slice popup
Show begin time, end time and length of demo cut in popup.

Replace demo slice error/confirm messages with generic popups.

Improve layout. Remove unnecessary empty space.
2023-05-28 15:03:52 +02:00
Robert Müller 1667861857 Use nullptr instead of 0 2023-05-28 14:59:46 +02:00
Robert Müller 6ff418322b Support rendering generic popup menus in demo player
Due to different code paths for the demo player, the `RenderPopupMenus` funtion needs to be called separately.
2023-05-28 14:59:46 +02:00
Robert Müller be8a601e9e Render demo popups above/after other demo controls
Prevent using other demo controls while a demo popup is open.
2023-05-28 14:59:45 +02:00
Robert Müller 20ce930765 Move variable declarations closer to usages 2023-05-28 14:59:45 +02:00
Robert Müller b01e8b7bc5 Extract CMenus::RenderDemoPlayerSliceSavePopup function 2023-05-28 14:59:45 +02:00
Robert Müller 1015176ae1 Fix inconsistent width/height calculation for generic popups
Sometimes the calculated popup width and height do not perfectly match the width and height when the text is rendered, so a small nudge value is added to prevent cases where this was noticeable.
2023-05-28 14:59:45 +02:00
Robert Müller 4ec4560679 Show error instead of replacing existing demo when renaming
Renaming a demo to the name of another demo would overwrite the target demo. Now an error message popup is shown instead to prevent this.

After a demo rename error popup is shown, return to the demo rename popup instead of closing the popup.
2023-05-28 14:02:08 +02:00
Robert Müller 08e0a87ff1 Use icons for refresh and connect buttons, refactor DoButtonMenu
Use less space for refresh and connect buttons to improve layout with 5:4 and 4:3 resolutions. Closes #5605. Closes #5878.

The "Refreshing..." text is replaced with combined refresh and ellipsis icons.

Alpha and saturation of the green color of the connect button are increased.

Move `CMenus::DoButtonMenu` to `CUI::DoButton_Menu`. Simplify usage by adding `SMenuButtonProperties` parameter object for all optional arguments. Remove unused `ColorHot` parameter.
2023-05-27 19:48:32 +02:00
Jupeyy fe20459138 Clear Victim Team render info on skin changes 2023-05-27 09:10:39 +02:00
bors[bot] 144bb1dd7f
Merge #6671
6671: Ensure line inputs are deactivated when they are not rendered r=def- a=Robyt3

Check if the active line input was not rendered and deactivate it in that case.

This can happen e.g. when an input in the ingame menu is active and the menu is closed or when switching between menu and editor with an active input.

This was causing the IME candidate list to be rendered ingame after closing the menu. Closes #6666.

## 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-05-26 22:26:18 +00:00
Robert Müller 71c56f1e70 Ensure line inputs are deactivated when they are not rendered
Check if the active line input was not rendered and deactivate it in that case.

This can happen e.g. when an input in the ingame menu is active and the menu is closed or when switching between menu and editor with an active input.

This was causing the IME candidate list to be rendered ingame after closing the menu. Closes #6666.
2023-05-26 23:58:04 +02:00
bors[bot] 4070a9587a
Merge #6670
6670: Delete selection with backspace/delete regardless of word mode r=def- a=Robyt3

Also delete the lineinput selection when pressing backspace/delete and the key for skipping words (Ctrl/GUI key, Alt on macOS) is held. This is consistent with the behavior in other applications.

## 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-05-26 21:46:52 +00:00
Robert Müller b0c4d3fcde Delete selection with backspace/delete regardless of word mode
Also delete the lineinput selection when pressing backspace/delete and the key for skipping words (Ctrl/GUI key, Alt on macOS) is held. This is consistent with the behavior in other applications.
2023-05-26 23:32:17 +02:00
Jupeyy 52d61244cd Remove inp_mouseold config
Because it causes trouble with newer SDL2 versions
`https://github.com/libsdl-org/SDL/issues/7159`
2023-05-26 22:44:32 +02:00
Robert Müller 34b66d2107 Pass nullptr instead of unused UI rect 2023-05-24 21:16:13 +02:00
Robert Müller 60ac3b3d48 Remove settings checkbox for cl_threadsoundloading
The default value `1` should be fine for most users and this setting is not likely to be changed very often, so it doesn't need a checkbox in the settings menu.
2023-05-24 21:12:44 +02:00
Robert Müller 70b5e4b5bd Remove settings edit box for snd_rate
The default setting `48000` should be fine for the majority of the users so it's not necessary to be able to change this in the settings menu.
2023-05-24 21:12:43 +02:00
Robert Müller 23d8acd96c Replace country server filter fullscreen popup with smaller popup
Replace the large hard-coded popup to select the country for the server filter with a small overlay popup for better usability.
2023-05-22 20:32:15 +02:00
Robert Müller 83c19a1e96 Add highlight color when hovering country button of server filter 2023-05-22 20:32:15 +02:00
Robert Müller 4dcb80e462 Enable country button also when filter not enabled
Selecting a flag will also enable the filter in this case.
2023-05-22 20:32:14 +02:00
Robert Müller f16f77ce26 Slightly decrease size of country flag in server filter 2023-05-22 20:32:14 +02:00
Robert Müller 9be72db36a Remove unnecessary margin on left side of server filter
To improve layout. The "Filter connecting players" checkbox can now use the original font size without being resized.
2023-05-22 20:31:02 +02:00
Robert Müller 0d0f9ed232 Remove dead code 2023-05-22 20:31:02 +02:00
Robert Müller 59fafdbf4e Only activate server browser list box when no popup is open
To support popup menus over the server browser.
2023-05-22 20:30:06 +02:00