Commit graph

9499 commits

Author SHA1 Message Date
marmare314 c9bd00b2ec make all quadpoints selectable with boxselect 2023-07-19 13:20:42 +02:00
heinrich5991 27b812287e
Merge pull request #6871 from Robyt3/UI-LastActiveItem-Cleanup
Remove usages of `CUI::LastActiveItem`
2023-07-19 10:54:07 +00:00
Robert Müller 3991d19966
Merge pull request #6887 from ChillerDragon/pr_goto_switch_tele
Add ``goto_switch`` and ``goto_tele``
2023-07-18 17:18:00 +00:00
ChillerDragon fb8d2a18d5 Add `goto_switch and goto_tele`
Set the clients view to a given teleporter or switch number
2023-07-18 14:34:51 +02:00
Robert Müller 6ee3928665 Fix ingame animations not using correct envelope points anymore
Add `CMapBasedEnvelopePointAccess::SetPointsRange` function so the start point and number of points that should be considered when using this envelope point storage can be configured. In the editor, this range always includes all points, as each envelope directly stores only its own points, so animations were rendered correctly there. However, all points are stored in one array when loading them from the map file (i.e. when rendering the map ingame), so the start point and number of points specified for the envelopes have to be considered when accessing their envelope points.

Closes #6886.
2023-07-18 12:43:31 +02:00
Robert Müller 47f4f21266 Remove usages of CUI::LastActiveItem
Use `CLineInput::GetActiveInput` and `CLineInput::IsActive` instead for consistency.

The last active item pointer is now only tracked internally in `CUI` to deactivate the active line input when it's no longer used in the UI.
2023-07-16 20:49:03 +02:00
Robert Müller 8abf9a7549 Use temporary file when saving editor map
Write the map to a temporary file first. When the map was saved to the temporary file successfully, first delete the existing map file having the real filename, then rename the temporary file to the real filename.

If deleting or renaming fails, show an error message popup and log an error message to the console.

The implementation is consistent with the way temporary files are utilized by Microsoft Word, so this should work on Windows.

See: https://support.microsoft.com/en-us/topic/description-of-how-word-creates-temporary-files-66b112fb-d2c0-8f40-a0be-70a367cc4c85

Different from #4482, this first deletes the old map file before renaming the temporary file. Although it appears that renaming a file would also override the target file, it could be that this does not work on all systems. Additionally, this adds descriptive error messages in the cases of failure.

Closes #4476.

Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2023-07-16 20:26:11 +02:00
Robert Müller a7f29568a2 Rename variable df to Writer 2023-07-16 19:26:01 +02:00
heinrich5991 9c0c7550ba Don't support loading RGB images ingame
They're essentially unused and not supporting them ingame probably
allows to keep that part of the map format unused.

See https://github.com/ddnet/ddnet/pull/5737#issuecomment-1538284956 or
https://github.com/teeworlds/teeworlds/issues/2812.
2023-07-16 15:26:00 +02:00
Dennis Felsing 8d12bceae4
Merge pull request #5737 from Robyt3/Map-Format-Port
Support bezier envelope curves in maps and editor, forward compatiblity for upstream map item changes
2023-07-16 12:27:10 +00:00
Robert Müller 1acb94ffbf Use lambdas for editor index modify and sort functions
For cleaner code with less global state variables.
2023-07-16 13:29:48 +02:00
Robert Müller 54df98be37 Support loading CMapItemImage version 2
This map item version adds the `m_Format` field, which specifies the image format for embedded images. The default value is `CImageInfo::FORMAT_RGBA` for map items of the previous version.
2023-07-16 12:46:34 +02:00
Robert Müller 4ae0928b47 Support bezier envelope curves in maps and editor
Port map and editor support for `CURVETYPE_BEZIER` from upstream, i.e. support bezier curves with configurable in- and out-tangents for every envelope point.

The in- and out-tangents are represented by triangles and can be dragged in the envelope editor like the envelope points.

Support reading and writing the bezier information as a separate UUID-based map item. If the bezier information is not found, bezier will default to linear behavior. Old clients will still be able to read the new maps and ignore the unknown map item. The unknown curvetype will also be handled as linear by old clients.

Allow reading upstream maps that use `CMapItemEnvelope` version 3. On upstream, a different struct is used to store all envelope points including bezier information, which broke compatibility to old clients.

Fix holding Ctrl for slow envelope point editing not working for vertical movement.

Highlight the currently selected element (envelope point or bezier tangent marker) which is being used with the value/time edit boxes.

Hide the value/time edit boxes when no element is selected.
2023-07-16 12:46:34 +02:00
Robert Müller 32f2fe936a Extract CMap::ExtractTiles with more validation
To reduce duplicate code and to add validation for tile skip everywhere.

Add separate `CMapItemLayerTilemap::TILE_SKIP_MIN_VERSION` constant and change `CMapItemVersion::CURRENT_VERSION` back to the previous version, as maps with tile skip can be loaded but skip is not used when saving.
2023-07-16 12:46:33 +02:00
Robert Müller a92ab45c3c Also support loading maps with tilemap skip in front layer 2023-07-16 12:46:33 +02:00
oy 9c4b0c03b4 Finished skip tile based map loading 2023-07-16 12:46:33 +02:00
oy 19d78b9f40 Made client/server check for correct map version on load 2023-07-16 12:46:32 +02:00
devdenn 7f100e2620 Fix bug, increase dump_log max seconds to 10min 2023-07-15 14:57:12 +00:00
Robert Müller 53fad543c0 Fix editor modified state not updated for server settings changes
Closes #6856.
2023-07-15 10:10:26 +00:00
Robert Müller 9788763ce8 Use member instead of static variables in CGameClient 2023-07-15 10:09:18 +00:00
Robert Müller ba94727a8d Use member instead of static variables for confirm popup buttons
Otherwise this would cause issues when showing multiple confirm popups at the same time.
2023-07-15 10:08:05 +00:00
Robert Müller dd06e9ae1c Initially keep server list scrolled to the top
When first launching the client, keep the server list scrolled to the top instead of scrolling to the selected server.

Closes #6845.
2023-07-15 09:30:54 +00:00
Robert Müller cfdc696315 Delay "Ingame moved" warning in editor
Delay showing the warning for ingame movement until the player has stopped moving while the editor is open, so the warning doesn't show immediately when the player performs an action (like jumping) and opens the editor shortly after.

Closes #6852.
2023-07-14 22:34:33 +00:00
Robert Müller 65a64b6fc4 Fix server browser filter highlighting of non-ASCII text
By calculating the correct length of the string matched in the haystack using the added `end` parameter of `str_utf8_find_nocase`.

Closes #6850.
2023-07-14 17:18:21 +00:00
marmare314 974255b3ea fix quadpoint moving on selection 2023-07-14 07:49:16 +02:00
bors[bot] fc6bf6545b
Merge #6824
6824: Improve Multi-View UX r=Robyt3 a=Vy0x2

- [x] You can now see who you are spectating in the spectator menu and even add/remove people from it (left mouse button)
- [x] Teleports are now being processed slower (more smoothly)
- [x] Workaround for starting multi-view from free-view (chooses now the nearest player to be the focus)
- [x] Added two more important variables to be able to customize it for specific scenarios (youtubers)

before:
![screenshot_2023-07-09_18-34-29](https://github.com/ddnet/ddnet/assets/24738662/a2ff8b77-c626-4ac2-b200-1eea70f85213)
after:
![screenshot_2023-07-09_18-32-49](https://github.com/ddnet/ddnet/assets/24738662/a54f0b06-b228-43ac-a1fc-eab95e7d9c20)

Edit: Thats the feedback i got from people. Hope its okay.

## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [x] 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: devdenn <denispaul43@gmail.com>
2023-07-13 20:52:43 +00:00
devdenn 3f201a45e7 Improve Multi-View UX
keep a bit more care with who we choose to spectate when frozen
only show active team as clickable in the spec menu
enable switchting teams in Multi-View by closing the spec menu
make the whole spectator menu clickablefix naming
twerk symbols a bit
remove unused ui
add more multi-view variables
add slow acceleration when teleported, add indication in spec menu
make players clickable in spectator menu
change focus with the spectator menu
2023-07-13 18:10:34 +02:00
VoxelDoesCode 36d8dd587c Send KillMsg for started + unlocked teams 2023-07-13 11:39:07 -04:00
bors[bot] 8d9843d934
Merge #6840
6840: Fix enter not working in server browser when no server selected, fix enter not working in editor save dialog when no map selected 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-07-13 13:26:25 +00:00
Robert Müller 71ed093b9e Fix enter not working in editor save dialog when no map selected 2023-07-13 14:19:15 +02:00
Robert Müller 8fad911b8b Fix enter not working in server browser when no server selected 2023-07-13 14:19:00 +02:00
Robert Müller 6cfdbd9986 Handle editor input events in OnUpdate instead of OnRender
To make input handling consistent with the gameclient. Also skip input events that are not valid, same as in the gameclient, as this otherwise causes input events to be handled multiple times.
2023-07-12 17:27:37 +02:00
Robert Müller da2da7b36f Fix editor hotkeys triggering while some editboxes are active
Replace `CEditor::m_EditBoxActive` which only works with editboxes created from the editor with `CLineInput::GetActiveInput` which also works for editboxes which are created by generic UI functions, e.g. the value selector editboxes of color pickers.
2023-07-12 17:27:22 +02:00
bors[bot] c8eae4c512
Merge #6834
6834: Support showing multiple different error messages in editor r=def- a=Robyt3

Previously the same message popup context was used for all error messages. While multiple message popups could be opened at the same time, the message would always be the same for all, as the same buffer was used for all popups.

This is fixed by creating and destroying the message popup contexts dynamically, so there can be any number of message popups with different messages. Additionally, if a popup with an identical message is already open, it will first be closed and then reopened at the new position, to prevent duplicate message popups.

## 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-07-11 21:30:03 +00:00
Robert Müller fcd219bf22 Support showing multiple different error messages in editor
Previously the same message popup context was used for all error messages. While multiple message popups could be opened at the same time, the message would always be the same for all, as the same buffer was used for all popups.

This is fixed by creating and destroying the message popup contexts dynamically, so there can be any number of message popups with different messages. Additionally, if a popup with an identical message is already open, it will first be closed and then reopened at the new position, to prevent duplicate message popups.
2023-07-11 20:24:41 +02:00
bors[bot] 3e5daf0a68
Merge #6833
6833: Support deleting/renaming demo folders, improve demo popups r=def- a=Robyt3

Support deleting and renaming folders in the demo browser. Only empty folders can be deleted.

Ensure only files and folders in the save directory can be deleted and renamed.

Also check if a folder with a demo rename/render filename already exists.

Fix broken `m_DemolistSelectedIsDir` checks by using `m_vDemos[m_DemolistSelectedIndex].m_IsDir` instead.

Append `.mp4` file extension only internally instead of appending it to the render filename lineinput, as this causes the file extension to appear when rendering doesn't start due an error message.

Use more efficient `FileExists` instead of `FindFile` to check if rendered demo video file already exists.

Change popup preconditions to assertions.

## 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-07-11 17:38:32 +00:00
Robert Müller 44bcbef0c1 Support deleting/renaming demo folders, improve demo popups
Support deleting and renaming folders in the demo browser. Only empty folders can be deleted.

Ensure only files and folders in the save directory can be deleted and renamed.

Also check if a folder with a demo rename/render filename already exists.

Fix broken `m_DemolistSelectedIsDir` checks by using `m_vDemos[m_DemolistSelectedIndex].m_IsDir` instead.

Append `.mp4` file extension only internally instead of appending it to the render filename lineinput, as this causes the file extension to appear when rendering doesn't start due an error message.

Use more efficient `FileExists` instead of `FindFile` to check if rendered demo video file already exists.

Change popup preconditions to assertions.
2023-07-11 18:58:40 +02:00
Robert Müller 43109bec3c Show message in editor when player is moved ingame
Show a short message below the existing chat mentions message that is shown in the top left area of the editor above the layers/images/sounds button when the player character is moved ingame while the editor is open. The messages are cleared when the editor is activated and when the client is disconnected.

Closes #1993.
2023-07-11 18:19:27 +02:00
Robert Müller 3a5228bb8f Use DoButton_Ex instead of DoButton_Tab
Reduce duplicate code.
2023-07-11 18:08:32 +02:00
Robert Müller c7c44705e1 Refactor rendering of editor mentions and modebar 2023-07-11 18:08:32 +02:00
bors[bot] c9642e103f
Merge #6819
6819: Improve demo browser layout r=heinrich5991 a=Robyt3

Use separate columns for icons and spacing like in the server browser.

Always show scrollbar for more consistent layout.

Show ellipsis if filename is too long, also for the filename shown in the demo player.

Hide number of markers and length if the demo is invalid.

Screenshots:
- Browser:
   - Before:
![Browser old](https://github.com/ddnet/ddnet/assets/23437060/55f4de41-e225-43eb-b07d-435cb4f9292d)
   - After:
![Browser new2](https://github.com/ddnet/ddnet/assets/23437060/56005b8c-a4e9-47eb-80a3-50013a856852)
- Player:
   - Before:
![Player old](https://github.com/ddnet/ddnet/assets/23437060/ef74c873-a62a-4184-8f90-08289ab2b829)
   - After:
![Player new2](https://github.com/ddnet/ddnet/assets/23437060/54f06bfa-28a8-480a-9125-f5ff9ffc81e0)

## 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-07-11 15:33:00 +00:00
Robert Müller ea219d9c15 Perform sanity check and show errors when loading map in editor
Add `CEditorMap::PerformSanityChecks` to perform additional sanity checks when loading a map in the editor.

In particular, the following is added: Check if there are any images with a width or height that is not divisible by 16 which are used in tile layers. Reset the image for these layers, to prevent crashes with some drivers.

Closes #6519.
2023-07-10 23:39:18 +02:00
Robert Müller 756740e57e Fix hook-through not being fully removed when filling selection
Closes #6782.
2023-07-10 21:28:30 +02:00
Robert Müller e0cc11e617 Rename variables tile to Tile 2023-07-10 21:27:51 +02:00
Robert Müller eb79b17308 Improve demo browser layout
Use separate columns for icons and spacing like in the server browser.

Always show scrollbar for more consistent layout.

Show ellipsis if filename is too long, also for the filename shown in the demo player.

Hide number of markers and length if the demo is invalid.
2023-07-09 10:47:04 +02:00
Robert Müller 9efab4964b Add parameter to force showing scrollbar with listbox 2023-07-09 10:47:04 +02:00
Dennis Felsing b376fbb331 Version 17.1.1 2023-07-09 00:15:42 +02:00
bors[bot] 0684d5e1a7
Merge #6820
6820: Improve demo (video) renderer UX r=def- a=Kaffeine

<!-- What is the motivation for the changes of this pull request? -->
In this MR I want to address three issues with video recorder:
1. A bug: if I start a rendering with 0.25x speed and click on 'Increase the speed' during the rendering, I expect to get the next speed (0.5x) but as the speed index is not set (kept default `4`), the speed is boosted to 1.25x.
2. Usecase: I want to adjust the camera (change position, decrease zoom, etc) for the demos and I don't want to use extra video editor to cut the first frames with the unwanted camera moves/setups from the demo. I came to a simple solution: start the rendering pre-paused to do the needed adjustments before anything is added to the video.
3. NotABug: All recorded video files have double `.demo.mp4` extension which is ugly.

Probably I have to change something to fit DDNet codebase. E.g. I don't know if `Localize("(paused)")` is acceptable here.

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

## Before
![image](https://github.com/ddnet/ddnet/assets/374839/7273dd5b-e3d1-4f73-87bd-e09493d106a0)

## After
![image](https://github.com/ddnet/ddnet/assets/374839/7d62028d-04bc-45af-babf-5a2e8cb243dc)

## 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: Alexander Akulich <akulichalexander@gmail.com>
2023-07-08 15:04:37 +00:00
Alexander Akulich 5ba2a21528 Client: Make it possible to start demo rendering pre-paused
The pause can be useful e.g. to adjust the camera position and zoom
right on the first video frame.
2023-07-08 15:43:42 +03:00
Alexander Akulich 7802dc2760 Client: Omit '.demo' extension from the video file name 2023-07-08 15:43:42 +03:00
bors[bot] 4260d51dd9
Merge #6823
6823: Mark `NETMSGTYPE_CL_STARTINFO` as `MSGFLAG_FLUSH` r=def- a=Robyt3

This makes the client connect to the server faster. It's especially noticeable on servers with a low ping.

Closes #6811.

## 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-07-08 10:17:17 +00:00
Robert Müller 4ee75c8946 Mark NETMSGTYPE_CL_STARTINFO as MSGFLAG_FLUSH
This makes the client connect to the server faster. It's especially noticeable on servers with a low ping.

Closes #6811.
2023-07-08 12:00:49 +02:00
Robert Müller fa65e19c5d Close quad point popup when selected quad or quad index invalid 2023-07-08 11:43:07 +02:00
Robert Müller 2cc03a1444 Closes all popup menus when loading map in editor
The targets of many popup menus become invalid when loading or creating a new map with the editor hotkeys, so all popup menus have to be closed in this case, otherwise this can cause crashes with several different popups.
2023-07-08 11:42:46 +02:00
Robert Müller 8de39e769c Remove dead code of removed undo feature 2023-07-08 11:42:40 +02:00
Alexander Akulich f93c6c7659 IDemoPlayer: Make SetSpeedIndex() actually set index 2023-07-08 04:09:46 +03:00
Alexander Akulich 0a657225ce CDataFileWriter: Make it clear that Add methods do not modify the data 2023-07-08 02:44:53 +03:00
bors[bot] 74789f86dc
Merge #6818
6818: Fix HUD PlayerState weapons rendering r=def- a=Kaffeine

<!-- What is the motivation for the changes of this pull request? -->
The proper offset for the first available weapon is provided only for Hammer but sometimes (in some mods) the character has no hammer and the icons got a wrong left margin.

### Current code

83a2ad0e24/src/game/client/components/hud.cpp (L882-L895)

Notice the `x -= 3;` in the hammer rendering branch. It fixes the `x` offset for this and further weapons but it works only if the character has a hammer (other weapons has no such line).
`-3` is specific for the hammer, we need different "first item" offsets for other weapons.

## Before

![image](https://github.com/ddnet/ddnet/assets/374839/419f97be-d1e3-4eff-94a6-387e89d6ef64)
(the hammer offset is _correct_)

![image](https://github.com/ddnet/ddnet/assets/374839/400ab01f-02a2-4d2a-bd6f-97806e12cbef)
but if the character has no hammer then the things go _wrong_.

![image](https://github.com/ddnet/ddnet/assets/374839/262e45a5-cee8-45b9-bd8b-a982761a5dc5)
Shotgun/Grenade Launcher/Laser has just a small offset but the _wrong_ placement of katana indicator if very noticeable.

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

## After
![image](https://github.com/ddnet/ddnet/assets/374839/af24c361-228e-4461-b7ea-0b4531ffedf0)
(no difference in the hammer icon rendering)

![image](https://github.com/ddnet/ddnet/assets/374839/04b30b2e-5560-431d-a949-b37b63e27b9e)
(fixed gun offset)

![image](https://github.com/ddnet/ddnet/assets/374839/5abb5be3-212c-48b1-9c78-169441d6442e)
(fixed shotgun offset)

![image](https://github.com/ddnet/ddnet/assets/374839/918ef960-162e-4942-916f-b8eb9802c2e4)
(fixed grenade launcher offset)

![image](https://github.com/ddnet/ddnet/assets/374839/7a8e1257-590b-4589-877a-51f90298d6f7)
(fixed laser offset)

![image](https://github.com/ddnet/ddnet/assets/374839/157258b6-f7de-4411-8b63-140083b883c3)
(fixed katana offset)

## 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: Alexander Akulich <akulichalexander@gmail.com>
2023-07-07 18:45:19 +00:00
bors[bot] 6dcb2d1828
Merge #6663
6663: New spectate mode (multiview) r=def- a=Vy0x2

<!-- What is the motivation for the changes of this pull request? -->

Adding a new spectator mode, that can spectate a team by moving the camera in the middle and zooming in/out
Works with team 0 or any team, but you have to work with it a bit to get used to it. I tried to make it as intuitive as possible.
Pr is as ready as it can get, please test it.

![screenshot_2023-06-30_19-17-42](https://github.com/ddnet/ddnet/assets/24738662/0446d568-d34b-4d14-8682-dd077f121e91)

Youtube video:<a href="http://www.youtube.com/watch?feature=player_embedded&v=7GM6DA3EYAI" target="_blank">
 <img src="http://img.youtube.com/vi/7GM6DA3EYAI/maxresdefault.jpg" alt="Watch the video" width="192" height="108"/>
</a>


<!-- 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
- [x] 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: devdenn <denispaul43@gmail.com>
Co-authored-by: Vy0x2 <denispaul43@gmail.com>
2023-07-07 18:24:44 +00:00
Alexander Akulich bf956c4c1c CHud::RenderPlayerState: Rework weapons rendering (+provide offsets) 2023-07-07 21:07:17 +03:00
Alexander Akulich ba7be6982d CHud::RenderPlayerState: Split ninja state rendering 2023-07-07 20:56:53 +03:00
Alexander Akulich a2ad543877 CHud: Refactor weapons rendering (1/3) 2023-07-07 20:56:50 +03:00
Robert Müller 7eb79fdcec Fix editor crash when filling entities layer with empty brush
The brush passed to `FillSelection` can be `nullptr` when the selection is empty.

Regression from #6648.

Closes #6815.
2023-07-07 19:22:16 +02:00
Dennis Felsing f3e7d55bfc Version 17.1 2023-07-07 00:28:55 +02:00
bors[bot] f63ff6237b
Merge #6809
6809: Fix text alignment in large confirmation popups with long text, increase buffer size for generic popup message  r=edg-l a=Robyt3

Closes #6806.

The message can contain a filename, so it should be large enough to contain that and the message itself.

Screenshots:
- Before: 
![screenshot_2023-07-04_18-09-12](https://github.com/ddnet/ddnet/assets/23437060/39cd4761-8cd0-4ac1-a24a-5115c8eed8c9)
- After:
![screenshot_2023-07-04_21-43-45](https://github.com/ddnet/ddnet/assets/23437060/c8f05f83-3f32-445a-8451-3a8be14a6007)
- Before (filename is truncated): 
![screenshot_2023-07-04_21-49-49](https://github.com/ddnet/ddnet/assets/23437060/16dfade5-f330-45b8-ac2f-1bc0d9a3fda1)
- After (full filename is shown):
![screenshot_2023-07-04_21-49-33](https://github.com/ddnet/ddnet/assets/23437060/eae1d789-f8e4-45c4-853e-ba655ab98168)

There is a separate issue with the text wrapping not working correctly with this long Unicode filename, which is causing the font size to decrease instead. See #6810.

## 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-07-04 20:06:14 +00:00
Robert Müller 89a52812cd Increase buffer size for generic popup message
The message can contain a filename, so it should be large enough to contain that and the message itself.
2023-07-04 21:41:53 +02:00
Robert Müller 3f50729fc2 Fix text alignment in large confirmation popups with long text
Closes #6806.
2023-07-04 21:40:47 +02:00
Robert Müller ef7a8d6cc6 Fix online clan friends not being removable via UI 2023-07-04 18:16:18 +02:00
bors[bot] 06fe73619e
Merge #6752
6752: Ensure `ListDirectory/Info` entries are unique, support selecting storage location in demo browser and editor file browser r=def- a=Robyt3

Description in commits below. Screenshots/video:

- Storage location selection for demos:
![screenshot_2023-06-18_17-25-23](https://github.com/ddnet/ddnet/assets/23437060/bcc94977-50ba-494b-894d-7bd8fea7f91e)

- Storage location selection for maps:
![screenshot_2023-06-18_17-25-33](https://github.com/ddnet/ddnet/assets/23437060/2b8b7822-b4b9-409f-86eb-e44f5c072541)

- Link to "themes" folder:
![screenshot_2023-06-18_17-26-02](https://github.com/ddnet/ddnet/assets/23437060/eba661a6-0bee-4977-ab95-35e400b5b291)

- Video showing navigation between storages (`temp` is the save directory and `temp2`, `temp3` and `data` are other storages)

https://github.com/ddnet/ddnet/assets/23437060/5736d212-3848-44c2-aa81-7f2da9b98008

Closes #5496.

## 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-07-03 19:05:42 +00:00
Robert Müller a4465ab8d6 Render editor pressed keys and saving message behind file dialog
The messages were previously rendered on top of the file dialog and popup menus.
2023-07-03 20:25:36 +02:00
Robert Müller f19d102f70 Support selecting storage location in editor file browser
Initially the file browser (maps, images, sound) shows the files from all storage locations combined like before when opening a file for reading. When saving a map, only the save storage location is shown and used like before.

The folder ".." is now also shown in the root folder, to navigate up to the storage location selection, if more than one storage location is present where a "maps"/"mapres" folder exists (whichever the dialog is currently showing). Only the locations where one of those folders exists are shown in the storage location selection. Additionally "All combined" can be selected to go back to the combined view.

The "Show directory" button behavior is adjusted so that the folder that contains the currently selected item is opened. When the storage location selection is shown, the button opens the selected storage location instead.

When navigating to the parent folder, the previous folder is now initially selected instead of resetting the selection.

Add a link to the "themes" folder same as the link to the "downloadedmaps" folder to allow easier access to the themes with the map editor.

The "folder tree" icon which is used for the ".." folder is now also used for the folder links in the storage location selection and for the links to the "downloadedmaps" and "themes" folders.

Always sort links above normal folders but below the ".." folder.

Fix alignment of font icons by using the correct flags.
2023-07-03 20:06:40 +02:00
Robert Müller e1035c3319 Support selecting storage location in demo browser
Initially the demo browser shows the demos from all storage locations combined like before.

The folder ".." is now also shown in the root folder, to navigate up to the storage location selection, if more than one storage location is present where a "demos" folder exists. Only the locations where one of those folders exists are shown in the storage location selection. Additionally "All combined" can be selected to go back to the combined view.

When navigating to the parent folder, the previous folder is now initially selected instead of resetting the selection.

The "Demos directory" button behavior is adjusted so that the folder that contains the currently selected item is opened. When the storage location selection is shown, the button opens the selected storage location instead.

The "folder tree" icon which is used for the ".." folder is now also for the folder links in the storage location selection.

Fix alignment of font icons by using the correct flags.

The config variable `ui_demo_selected` is removed and replaced with an internal buffer. The selected demo was always reset when restarting anyway and this would also not work with demos in subfolders either.
2023-07-03 20:06:40 +02:00
Robert Müller 2b64a66dc6 Improve font scaling of long editor texts, improve ellipsis
For long editor texts (group name, layer name, image name, sound name, file names, tooltips) make use of the font scaling and ellipsis functionality implemented in `DoLabel` instead of implementing it separately in the editor.
2023-07-02 23:34:58 +02:00
Robert Müller 0a7361090f Add ellipsis flag to DoLabel, support stop-at-end with max width
Add `SLabelProperties::m_EllipsisAtEnd` to render an ellipsis when using `DoLabel`.

Fix `m_StopAtEnd` and `m_EllipsisAtEnd` not working together with the automatic font scaling. Now the stop-at-end and ellipsis flags will only have an effect when the automatic font scaling has reached the minimum font size already.

Add `SLabelProperties` argument to `DoLabelStreamed` and adjust usages in server browser. Font scaling now has to be disabled explicitly for the server name, gametype and map, as these should use the stop-at-end flag without the font-scaling.
2023-07-02 23:34:58 +02:00
devdenn f397ba4346 Minor fixes 2023-07-02 19:56:50 +02:00
ChillerDragon 9d2f4318d5 Allow server to redirect clients
This is a preperation for #6754 (redirect players on map vote)
And an implementation of #5662 (redirect players)
2023-07-02 14:05:11 +02:00
Robert Müller e2ef536e43 Fix incorrect popup being closed when gametile popup used
When selecting a gametile the layer popup was being closed instead of the top-most gametile popup.

Regression from #6503.
2023-07-02 12:43:30 +02:00
Robert Müller b252e7402b Fix height of layer popup when automapper properties shown
Regression from #6755.
2023-07-02 12:42:45 +02:00
trml 8335fdae79 Fix wrong predicted reload timer after ninja pickup 2023-07-02 02:22:12 +02:00
bors[bot] 4bd14933b8
Merge #6790 #6793
6790: Prevent /swap with paused players r=def- a=Robyt3

Prevent swapping if either of the players is paused (i.e. their character is not in the gameworld), as this can cause them to be stuck in midair after swapping, which can be exploited to skip parts.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [X] Tested in combination with possibly related configuration options (servers with `sv_pauseable 0` were and are unaffected)
- [ ] 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)


6793: Use `std::vector` and `std::deque` instead of most `std::list`s r=def- a=Robyt3

Use `std::vector` in cases where elements are only inserted at the end of the collection.

Use `std::deque` in cases where elements are only inserted/deleted at the beginning/end of the collection.

Use `std::list` in the remaining single case where elements are being removed from arbitrary positions and added at either the beginning or the end of the collection.

Adjust variables names. Don't use separate prefix for `std::deque`s and `std::list`s, as they are only used very rarely. Closes #6779.

## 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-07-01 16:04:13 +00:00
bors[bot] a2d2f32ded
Merge #6792
6792: Fix proximity radius of predicted pickups r=def- a=trml

Radius was set to 0 before this, so pickups were sometimes not predicted.

## 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: trml <trml@users.noreply.github.com>
2023-07-01 15:44:57 +00:00
Robert Müller bc73ea30c7 Use std::vector and std::deque instead of most std::lists
Use `std::vector` in cases where elements are only inserted at the end of the collection.

Use `std::deque` in cases where elements are only inserted/deleted at the beginning/end of the collection.

Use `std::list` in the remaining single case where elements are being removed from arbitrary positions and added at either the beginning or the end of the collection.

Adjust variables names. Don't use separate prefix for `std::deque`s and `std::list`s, as they are only used very rarely. Closes #6779.
2023-07-01 15:44:35 +02:00
trml 678e3cad0c Set physsize of predicted pickups 2023-07-01 14:07:03 +02:00
Robert Müller c6b4302b21 Prevent /swap with paused players
Prevent swapping if either of the players is paused (i.e. their character is not in the gameworld), as this can cause them to be stuck in midair after swapping, which can be exploited to skip parts.
2023-07-01 11:01:18 +02:00
Dennis Felsing 9ea16f660b Add new contributors for 17.1 2023-07-01 09:43:00 +02:00
Vy0x2 0b8ed51614
Merge branch 'master' into pr-poc-mv-clean 2023-06-30 18:07:12 +02:00
devdenn d16fb877dc Add multi view 2023-06-30 18:03:24 +02:00
bors[bot] 3d60334d10
Merge #6786
6786: Fix inconsistent size and corners of connect button r=def- a=Robyt3

The connect button had `5.0f` units less width, which was causing the corners of the refresh and connect buttons to look differently.

Screenshots:
- Before: 
![connect-button old](https://github.com/ddnet/ddnet/assets/23437060/1ed567b9-d108-4a7a-9141-c43fab89d4aa)
- After:
![connect-button new](https://github.com/ddnet/ddnet/assets/23437060/e054018d-cd2d-4257-96c4-e1d57e111c68)

## 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-06-30 14:00:03 +00:00
Robert Müller 3159cc58fb Fix inconsistent size and corners of connect button
The connect button had `5.0f` units less width, which was causing the corners of the refresh and connect buttons to look differently.
2023-06-30 15:52:24 +02:00
bors[bot] b6eb2eb3eb
Merge #6776
6776: Allow 'bind x' to be used like 'binds x' r=def- a=ArijanJ

<!-- What is the motivation for the changes of this pull request? -->
This makes the 'bind' command optionally take only one argument, in which case it behaves like 'binds x'. This falls in line with how most popular games do it, and may prevent confusion in the future.

![image](https://github.com/ddnet/ddnet/assets/56356662/893508af-2b64-405f-be2c-da65387063aa)

This introduces a tiny bit of duplication though, because I just copied the if statement from 'binds', but it should be fine.

<!-- 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
- [x] 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: ArijanJ <ajakshik@gmail.com>
2023-06-30 07:42:34 +00:00
bors[bot] 05ddfba954
Merge #6755
6755: Remove individual RGBA sliders from editor color picker, add shift+rightclick/leftclick to copy/paste color in editor r=Jupeyy a=Robyt3

Remove the individual RGBA sliders for editor color pickers and only show one button that opens the color picker popup instead.

Decrease size of layer and point popups that previously had color properties which need less space now.

Support shift-rightclicking color picker buttons to copy the color to the clipboard in RRGGBBAA hex format.

Support shift-leftclicking color picker buttons to paste a color from the clipboard in RGB, RGBA, RRGGBB or RRGGBBAA format with optional leading `#` or `$`.

Screenshots:
- Before:
![screenshot_2023-06-20_20-39-43](https://github.com/ddnet/ddnet/assets/23437060/4a8b230c-a66b-4e2a-9744-cb5f80f6a799)
- After:
![screenshot_2023-06-20_20-40-00](https://github.com/ddnet/ddnet/assets/23437060/517f90cf-06a5-4332-9eb8-6a87cbc91b32)
- After (color picker open):
![screenshot_2023-06-25_17-35-55](https://github.com/ddnet/ddnet/assets/23437060/30320b56-e4cb-4e93-bf7b-8cfc8d96620b)


Suggested by `@HiRavie` in https://github.com/ddnet/ddnet/pull/6743#issuecomment-1593886873, though it was easier and also looks better to me when the color picker button has exactly the same size as the other value selectors.

## 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-06-27 19:29:43 +00:00
ArijanJ 7e3ad335be Allow 'bind x' to be used like 'binds x' 2023-06-27 09:46:32 +02:00
bors[bot] 67ddd93401
Merge #6772
6772: Various minor demo player usability improvements r=def- a=Robyt3

- Also skip to beginning and end when there are no demo markers. Previously the buttons to skip to the next/previous demo marker were skipping to the end/beginning respectively, if there is no next/previous marker, but only if there were any map markers. Now the button immediately skip to the beginning/end also when there are no demo markers at all.
- Fix demo seeking not working at beginning and end.
- Pause demo playback when skipping to end. It's otherwise inconvenient when the playback continues, as it will immediate rewind to the beginning when reaching the end.
- Allow right-clicking slice buttons to reset cut beginning/end.

## 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-26 21:36:48 +00:00
bors[bot] 5d89b975be
Merge #6763
6763: Autosave copy of current editor map periodically to `auto` folder, use separate thread to finish saving maps, add saving indicator r=def- a=Robyt3

A copy of the map currently open in the editor is saved every 10 minutes to the `maps/auto` folder (interval configurable, see below). The automatically saved map uses the filename of the original map with an additional timestamp. Per map name 10 autosaves are kept in the `auto` folder before old autosaves will be deleted (number configurable, see below).

Add config variable `ed_autosave_interval` (0 - 240, default 10) to configure the interval in minutes at which a copy of the current editor map is automatically saved to the 'auto' folder.

Add config variable `ed_autosave_max` (0 - 1000, default 10) to configure the maximum number of autosaves that are kept per map name (0 = no limit).

Autosaving will not take place in the 5 seconds immediately after the map was last modified by the user, to avoid interrupting the user with the autosave.
This will only delay autosaving for up to 1 minute though, so autosaves are not prevented entirely, should the user continuously edit the map.

When the editor is reopened after being closed for more than 10 seconds, the autosave timer will be adjusted to compensate for the time that was not spent on editing in the editor.

When the map is saved manually by the user the autosave file is also updated, if it's outdated by at least half of the configured autosave interval. This ensures that autosaves are always available as a periodic backup of the map.

When a copy of the current map is saved, this does not update the autosave and will also no longer reset the modified state. The modified state should reflect whether changes have been made that are not saved to the current map file. As saving a copy does not update the current file, the modified state should not be reset in this case.

Closes #6693.

Compressing the data with zlib takes the majority of the time when saving a datafile. Therefore, compressing is now delayed until the `CDataFileWriter::Finish` function is called. This function is then off-loaded to another thread to make saving maps in the editor not block the rendering.

A message "Saving…" is shown in the bottom right of the editor view while a job to save a map is running in the background.

While a map is being finished in a background thread another save for the same filename cannot be initiated to prevent multiples accesses to the same file.

Closes #6762.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [X] Tested in combination with possibly related configuration options
- [X] 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-26 21:13:01 +00:00
Robert Müller d519ad194b Remove dead code
Checking `m_DemoPlayerState` is only necessary inside the demo player but not in the demo file browser.
2023-06-26 22:40:40 +02:00
Robert Müller ff454f6dc5 Allow right-clicking slice buttons to reset cut beginning/end 2023-06-26 22:40:31 +02:00
Robert Müller d9c737673a Pause demo playback when skipping to end
It's otherwise inconvenient when the playback continues, as it will immediate rewind to the beginning when reaching the end.
2023-06-26 22:40:23 +02:00
Robert Müller 84457980e9 Fix demo seeking not working at beginning and end 2023-06-26 22:40:16 +02:00
Robert Müller 5501a33148 Also skip to beginning and end when there are no demo markers
Previously the buttons to skip to the next/previous demo marker were skipping to the end/beginning respectively, if there is no next/previous marker, but only if there were any map markers. Now the button immediately skip to the beginning/end also when there are no demo markers at all.
2023-06-26 22:39:52 +02:00
Robert Müller 01b99f668a Fix images/sounds not being loaded with correct file extension
Regression from #6764.
2023-06-26 22:37:00 +02:00
Robert Müller 2126d8570f Use separate thread to finish saving maps, add saving indicator
Compressing the data with zlib takes the majority of the time when saving a datafile. Therefore, compressing is now delayed until the `CDataFileWriter::Finish` function is called. This function is then off-loaded to another thread to make saving maps in the editor not block the rendering.

A message "Saving…" is shown in the bottom right of the editor view while a job to save a map is running in the background.

While a map is being finished in a background thread another save for the same filename cannot be initiated to prevent multiples accesses to the same file.

Closes #6762.
2023-06-26 21:58:04 +02:00
Robert Müller 5c3e5bf67c Extract CEditor::RenderMousePointer function 2023-06-26 21:58:04 +02:00
Robert Müller 525c33f1b8 Extract CEditor::RenderPressedKeys function 2023-06-26 21:58:04 +02:00
Robert Müller 1810d972f4 Autosave copy of current editor map periodically to auto folder
A copy of the map currently open in the editor is saved every 10 minutes to the `maps/auto` folder (interval configurable, see below). The automatically saved map uses the filename of the original map with an additional timestamp. Per map name 10 autosaves are kept in the `auto` folder before old autosaves will be deleted (number configurable, see below).

Add config variable `ed_autosave_interval` (0 - 240, default 10) to configure the interval in minutes at which a copy of the current editor map is automatically saved to the 'auto' folder.

Add config variable `ed_autosave_max` (0 - 1000, default 10) to configure the maximum number of autosaves that are kept per map name (0 = no limit).

Autosaving will not take place in the 5 seconds immediately after the map was last modified by the user, to avoid interrupting the user with the autosave.
This will only delay autosaving for up to 1 minute though, so autosaves are not prevented entirely, should the user continuously edit the map.

When the editor is reopened after being closed for more than 10 seconds, the autosave timer will be adjusted to compensate for the time that was not spent on editing in the editor.

When the map is saved manually by the user the autosave file is also updated, if it's outdated by at least half of the configured autosave interval. This ensures that autosaves are always available as a periodic backup of the map.

When a copy of the current map is saved, this does not update the autosave and will also no longer reset the modified state. The modified state should reflect whether changes have been made that are not saved to the current map file. As saving a copy does not update the current file, the modified state should not be reset in this case.

Closes #6693.
2023-06-26 21:58:04 +02:00
bors[bot] d840233951
Merge #6765
6765: Add play/stop button and duration label for editor sounds  r=def- a=Robyt3

Add button to play/stop audio preview and label showing selected sound duration in editor sound list and sound file browser.

Show error message instead of preview in editor image/sound file browser when selected file cannot be loaded.

Screenshots:
- ![screenshot_2023-06-25_21-53-14](https://github.com/ddnet/ddnet/assets/23437060/a2eb810c-e132-4fa8-9d0d-730b78088651)
- ![screenshot_2023-06-25_21-53-01](https://github.com/ddnet/ddnet/assets/23437060/1a742abc-51f9-4526-aada-d941d42e481d)
- ![screenshot_2023-06-25_21-53-05](https://github.com/ddnet/ddnet/assets/23437060/bf500772-ab6b-409f-8cc4-1bfbaeae55eb)


## 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-06-26 08:48:05 +00:00
Robert Müller af9c271a85 Fix editor save dialog filename showing file extension
Which was causing the listbox selection to be cleared when activating the filename editbox, as the filename search expects names without the file extension.
2023-06-25 21:51:36 +02:00
Robert Müller f8a4cee979 Add play/stop button and duration label for editor sounds
Add button to play/stop audio preview and label showing selected sound duration in editor sound list and sound file browser.

Show error message instead of preview in editor image/sound file browser when selected file cannot be loaded.
2023-06-25 21:41:12 +02:00
Robert Müller 72fbfaad46 Fix save copy callback not called when confirmation popup used
When using "Save Copy" to save a copy of the current map to a new file and selecting a file that already exists, a confirmation popup is shown. However, this confirmation popup did not differentiate between regular saving and saving a copy, so the regular save callback was always called.
2023-06-25 11:01:14 +02:00
Robert Müller e04eee9d44 Extract CEditor::HandleCursorMovement function 2023-06-25 11:01:14 +02:00
Robert Müller 4372932480 Remove unnecessary storage argument of CEditorMap::Load/Save
The editor map has a pointer to the editor, which has a pointer to the storage, so it's not necessary to pass the storage separately.
2023-06-25 10:50:06 +02:00
Robert Müller 34df022c79 Use IO_MAX_PATH_LENGTH for editor map saving and loading 2023-06-25 10:50:02 +02:00
Dennis Felsing e320c85fdd Fix bind crashes (fixes #6758) 2023-06-23 17:55:36 +02:00
Robert Müller c966b5d752 Show circle icon next to editor filename when unsaved changes
Show a circle icon next to the filename in the editor menu bar when there are unsaved changes in the current map.
2023-06-22 19:34:17 +02:00
Robert Müller 7d9f4e1cfb Increase size of info in editor menu bar, show X/Y decimal places
When the text is slightly longer (e.g. X and Y positions having multiple digits), the font size of the info text in the menubar decreases because not enough space is available.

Show one decimal place also for the current world X and Y position of the mouse, which allows to determine the position of the mouse inside the currently hovered tile.
2023-06-22 19:34:17 +02:00
Robert Müller 7b9823688f Add shift+rightclick/leftclick to copy/paste color in editor
Support shift-rightclicking color picker buttons to copy the color to the clipboard in RRGGBBAA hex format.

Support shift-leftclicking color picker buttons to paste a color from the clipboard in RGB, RGBA, RRGGBB or RRGGBBAA format with optional leading `#` or `$`.
2023-06-20 23:30:30 +02:00
Robert Müller f30682be04 Add color4_base::PackAlphaLast and UnpackAlphaLast
So pack and unpack colors as 4 byte unsigned values with the alpha component last. Existing functions assume that alpha is the first component.
2023-06-20 23:22:33 +02:00
Robert Müller bb5e203f3a Remove individual RGBA sliders from editor color picker
Remove the individual RGBA sliders for editor color pickers and only show one button that opens the color picker popup instead.

Decrease size of layer and point popups that previously had color properties which need less space now.
2023-06-20 20:51:31 +02:00
bors[bot] e22e0c9777
Merge #6750
6750: Select new demo file after renaming and slicing demo, scroll to selected demo when sorting, refreshing etc. 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-16 22:07:53 +00:00
Robert Müller 4ac3358e8e Scroll to selected demo when sorting, refreshing etc. 2023-06-16 22:44:25 +02:00
Robert Müller abfd9333b0 Select new demo file after renaming and slicing demo 2023-06-16 22:43:51 +02:00
bors[bot] 96927e1b6a
Merge #6747
6747: Fix uninitialized `CLineInput` member variables r=def- a=Robyt3

Closes #6745.

## 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-16 20:26:27 +00:00
bors[bot] 9ebcdf4b15
Merge #6748 #6749
6748: When all DDNet filter entries selected, deselect with right click r=def- a=Robyt3

Allow deselecting just one filter entry by right clicking the entry (country or game type) when all entries are currently selected (i.e. none are excluded). Previously the first right click always deselected all filters except the clicked one (same as the left click).

Closes #6746.

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


6749: Fix alignment of font icon buttons in editor, use font icon for editor proof mode selection button r=def- a=Robyt3

Before:
![screenshot_2023-06-16_18-00-17](https://github.com/ddnet/ddnet/assets/23437060/65cb056a-eadc-4037-83b1-ad50af0980a3)

After:
![screenshot_2023-06-16_17-59-17](https://github.com/ddnet/ddnet/assets/23437060/c17ae4ed-971c-49ed-a430-951614e553bc)

## 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-06-16 19:57:40 +00:00
Robert Müller fa787d354e When all DDNet filter entries selected, deselect with right click
Allow deselecting just one filter entry by right clicking the entry (country or game type) when all entries are currently selected (i.e. none are excluded). Previously the first right click always deselected all filters except the clicked one (same as the left click).

Closes #6746.
2023-06-16 17:53:44 +02:00
Robert Müller 5b3efaa4cd Fix uninitialized CLineInput member variables
Closes #6745.
2023-06-16 17:39:44 +02:00
Robert Müller e51fe4a86e Use font icon for editor proof mode selection button 2023-06-14 23:14:24 +02:00
Robert Müller d172d63815 Fix alignment of font icon buttons in editor 2023-06-14 23:14:23 +02:00
Robert Müller 34c2e5649b Improve editor color picker popup
By replacing the editor specific color picker popup with the generic UI color picker popup.

Improve layout of the editor color picker button. Improve spacing and ensure that the button is square. Slightly enlarge button on mouse hover.
2023-06-14 20:36:06 +02:00
Robert Müller 7ce9fd9949 Refactor UI color picker
- Improve variable names.
- Use `ColorHSVA` instead of `unsigned int`.
- Allow `m_pHslaColor` to be `nullptr` when HSLA color unused.
2023-06-14 20:17:27 +02:00
bors[bot] 6cfac056ec
Merge #6740
6740: Don't remove the `.map` suffix in editor file dialog r=def- a=Robyt3

This otherwise breaks file loading because the file extension is expected in this input buffer even when the input is not rendered.

Regression from #6736.

## 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-13 23:44:52 +00:00
Robert Müller 090433bc5e Don't remove the .map suffix in editor file dialog
This otherwise breaks file loading because the file extension is expected in this input buffer even when the input is not rendered.

Regression from #6736.
2023-06-14 00:43:35 +02:00
Robert Müller 3ad581aeb8 Ensure proper buffer size is used with DDNet server filter
By passing the buffer size when calling `DDNetFilterAdd` and `DDNetFilterRem`.

Mark functions and pointer parameters as `const`.
2023-06-14 00:04:01 +02:00
Robert Müller 9a57def5a6 Add templated str_append function for arrays with fixed size 2023-06-14 00:04:01 +02:00
bors[bot] 183086700f
Merge #6737
6737: Refactor `str_copy` usages and buffer sizes in editor r=def- a=Robyt3

Use templated `str_copy` function in most cases to specify the correct buffer size.

Fixes two cases where the buffer size was hard-coded to a number.

Fix buffer size not being checked when copying auto mapper configuration name. Loading an auto mapper configuration with a name longer than 128 bytes could cause an out-of-bounds write.

Increase sizes of some text buffers that were potentially too small.

## 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-13 20:50:34 +00:00
Robert Müller bbe9f23a9c Refactor str_copy usages and buffer sizes in editor
Use templated `str_copy` function in most cases to specify the correct buffer size.

Fixes two cases where the buffer size was hard-coded to a number.

Fix buffer size not being checked when copying auto mapper configuration name. Loading an auto mapper configuration with a name longer than 128 bytes could cause an out-of-bounds write.

Increase sizes of some text buffers that were potentially too small.
2023-06-13 20:45:51 +02:00
Robert Müller b13e8076dc Fix editor save dialog entries not selectable with mouse anymore
Regression from #6530.
2023-06-13 19:51:54 +02:00
Robert Müller 40db5d3c1e Improve UI debug information
Move debug text from the top left to the bottom left, so it does not overlap with the other debug information.

Also render UI element address of next hot item.

Add labels for UI element addresses.
2023-06-12 19:48:54 +02:00
Robert Müller aa937d4fba Refactor CUI::Screen
Remove unnecessary temporary variables.

Remove unnecessary assignment of width and height values in constructor, which will always be overwritten.
2023-06-12 19:48:45 +02:00
Robert Müller 6eb30b00e2 Use nullptr instead of 0 2023-06-12 19:48:44 +02:00
Robert Müller b46a47f14b Remove unused active tooltip item variable 2023-06-12 19:48:42 +02:00
bors[bot] 4d0247a24c
Merge #6734
6734: Use `DoLabel` instead of `Text`/`TextEx` in menus, other minor refactoring of menus 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-11 20:36:46 +00:00
Robert Müller 2fb4a39e10 Refactor CMenus::RenderSettings
Use correct enum literal `SETTINGS_LENGTH` as array size for button containers instead of the `sizeof(apTabs)`, which does not consider the size of the array elements.

Use code for dynamic size calculation directly instead of putting it in comments.
2023-06-11 21:55:36 +02:00
Robert Müller 8d65e0ac34 Minor refactoring of settings menus
- Use `IGraphics::CORNER_NONE` instead of `0`.
- Remove redundant usage of `Localize` for an already localized string.
- Remove redundant `HSplitBottom` with zero size.
2023-06-11 21:55:36 +02:00
Robert Müller 16fd3401e2 Use DoLabel instead of Text/TextEx in menus
Reduce duplicate code for text alignment and automatic sizing.
2023-06-11 21:54:46 +02:00
Jupeyy 845ba50842 Split emoticon sending into nearby and global players 2023-06-11 13:31:50 +02:00
bors[bot] 6a53d72b35
Merge #6721
6721: Improve selection popups and dropdown menus, add dropdown menus to select screen and active controller r=def- a=Robyt3

Screenshots:
- Controls settings:
   - Before: 
![controls old](https://github.com/ddnet/ddnet/assets/23437060/8907c38a-d483-4766-84ad-49464b9760a0)
   - After: 
![controls new](https://github.com/ddnet/ddnet/assets/23437060/f021e961-ce90-4557-aef0-a1e1a4bc7ca4)
- Graphics settings (collapsed):
   - Before: 
![graphics_collapsed old](https://github.com/ddnet/ddnet/assets/23437060/d895c8d8-a72f-4da2-aa57-93d5f08be648)
   - After: 
![graphics_collapsed new](https://github.com/ddnet/ddnet/assets/23437060/e594a599-1210-4ba0-87f2-b2a824043dc4)
- Graphics settings (expanded):
   - Before: 
![graphics_expanded old](https://github.com/ddnet/ddnet/assets/23437060/cce1d8cb-4dff-4d43-a9f0-af2dbfeff27d)
   - After: 
![graphics_expanded_1 new](https://github.com/ddnet/ddnet/assets/23437060/c99c24cb-3398-4a80-9b99-3281ed62f6a7)
![graphics_expanded_2 new](https://github.com/ddnet/ddnet/assets/23437060/83fc2522-0da6-40d8-ad2b-3e3159b74308)
![graphics_expanded_3 new](https://github.com/ddnet/ddnet/assets/23437060/b00b30c4-411b-43a0-97f0-ecd47ebea516)
- The maximum dropdown menu height is limited to 40% of the screen height. The content will begin to scroll if this is exceeded:
![scrolling](https://github.com/ddnet/ddnet/assets/23437060/ac576819-f24f-4fed-82cd-a05d87f9ad71)
- If there is not enough space below the dropdown button to open the dropdown menu popup, then the popup opens to the top instead:
![alignment](https://github.com/ddnet/ddnet/assets/23437060/2f61ea30-996d-4def-8f5d-300b5008c666)

## 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-06-10 14:01:38 +00:00
bors[bot] 5c3a3cefa6
Merge #6726
6726: Fix top alignment of some popup messages r=def- a=Robyt3

The popup message has to be top- and not middle-aligned in some popups:

- First launch
- Existing player for nickname
- Warning

Likely a regression introduced by #6511.

Before:

![screenshot_2023-06-09_14-23-56](https://github.com/ddnet/ddnet/assets/23437060/0a7250d4-4522-4924-b056-463eaa67f546)

After:

![screenshot_2023-06-09_14-23-21](https://github.com/ddnet/ddnet/assets/23437060/40776b1a-6571-4e8d-bb5a-6c11a5a5dbb9)

## 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-06-10 13:30:19 +00:00
Robert Müller 883fb8818c Minor refactoring of CAnimState and tee rendering functions
- Use `nullptr` instead of `0`.
- Remove dead code.
- Mark functions and pointers as `const` when possible.
- Remove unused argument of `CRenderTools::GetRenderTeeAnimScaleAndBaseSize` function.
- Copy tee render info when rendering emote wheel instead of modifying global render info.
- Fix names of static variables.
2023-06-10 13:10:26 +02:00
Robert Müller 1172be1f80 Fix undefined player vote/team change time
The time of the last kick vote and the time of the last team change are initially in an undefined state, which causes the kick vote and team change to fail due to the delay incorrectly being applied.

Closes #6723.
2023-06-10 10:23:27 +02:00
Robert Müller 7af1fe3b52 Fix top alignment of some popup messages
The popup message has to be top- and not middle-aligned in some popups:

- First launch
- Existing player for nickname
- Warning

Likely a regression introduced by #6511.
2023-06-09 14:22:21 +02:00
Robert Müller 5b3f6e8ffd Use dropdown menu to select game controller
Instead of using one button to cycle through all controllers.
2023-06-09 14:04:35 +02:00