Commit graph

1249 commits

Author SHA1 Message Date
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
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
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 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 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
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 082c8b8a7d Extend generic selection popup
- Support scrolling. Limit maximum height to 40% of screen height.
- Allow message to be empty.
- Use `std::vector` instead of `std::set` for entries to keep the user-defined order of entries.
- Add `m_SelectionIndex` in addition to `m_pSelection` to get selected item more conveniently for some use-cases.
- Make entry height, entry padding, entry spacing, font size, and popup width configurable.
- Allow alignment of selection popup with the top/bottom of another UI element.
- Support transparent selection buttons.
2023-06-09 14:04:20 +02:00
Robert Müller f0bb4a45d0 Allow adjusting popup border/background color
Add `SPopupMenuProperties` parameter object for `DoPopupMenu`.
2023-06-09 14:02:47 +02:00
Robert Müller 55726e8da3 Simplify list box activation handling
Store the list box active state inside `CListBox` instead of tracking it separately with a pointer.

Allow activating list boxes by clicking the scrollbar. Previously it was only possible to activate list boxes by selecting an item.

Fix country selection list box in players settings not being deactivated properly when name/clan edit boxes are active, because wrong UI element IDs were being used.
2023-06-07 20:46:10 +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 90ae59a666 Make server settings editor height adjustable by dragging
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`.
2023-05-29 12:26:04 +02:00
bors[bot] 03a5dde418
Merge #6639
6639: Fix- Replaced usage of m_ProofBorders and m_MenuProofBorders with enum EProofBorder r=Robyt3 a=tarunsamanta2k20

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

Changes requested.
closes #6609 

<!-- 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
- [x] 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
- [x] 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: Tarun Samanta <tarunsamanta77@gmail.com>
Co-authored-by: Tarun Samanta <55488549+tarunsamanta2k20@users.noreply.github.com>
2023-05-24 18:30:44 +00:00
Tarun Samanta f982dd77c1 fixing linting issue 2023-05-24 01:27:57 +05:30
Tarun Samanta e8a33cfade fiing linting issue 2023-05-23 23:57:08 +05:30
Tarun Samanta 050bf4a9b8 Made sugested changes 2023-05-23 23:46:42 +05:30
Tarun Samanta fcaab778ca modified some files as asked 2023-05-22 23:50:45 +05:30
Robert Müller 6ca74ec39e Clear unused switch/tele properties when filling selection
Set switch number/delay/flags to 0 when unused for a specific tile.

Set tele number to 255 when unused for a specific tile.
2023-05-22 17:46:50 +02:00
Robert Müller d5e4597012 Fix filling switch layer not setting switch number 0
Closes #5464.
2023-05-22 17:46:50 +02:00
Robert Müller a068034e61 Extract duplicate expressions into variables 2023-05-22 17:46:50 +02:00
Tarun Samanta ef78e36c6f replaced second enum 2023-05-22 18:16:25 +05:30
Tarun Samanta 79d8928a03 made requested changes 2023-05-22 01:51:13 +05:30
Tarun Samanta e74c60d9a5 Modified some files 2023-05-22 00:56:23 +05:30
Tarun Samanta f23f74ee9e fixing some error 2023-05-21 22:42:53 +05:30
Tarun Samanta 61ef6210d1 Modifications in three files 2023-05-21 21:30:41 +05:30
Tarun Samanta 523a3c4450 fix- Replaced usage of m_ProofBorders and m_MenuProofBorders with enum EProofBorder 2023-05-21 14:47:27 +05:30
bors[bot] 20032b5a24
Merge #6546
6546: move some editor buttons into menus r=Robyt3 a=Marmare314

The entities and unused buttons are now in a new "Settings" menu.
![menu_settings](https://user-images.githubusercontent.com/49279081/235301689-a1375024-9233-432b-9ab3-4545f982711f.png)

The border and goto buttons got moved to the "Tools" menu.
![tools_menu](https://user-images.githubusercontent.com/49279081/235301690-6883e6a7-0afe-4b2f-826c-3fb48694f7f4.png)


## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: marmare314 <49279081+Marmare314@users.noreply.github.com>
2023-05-17 15:59:42 +00:00
marmare314 76eac08783 fix padding of buttons in settings 2023-05-17 17:25:21 +02:00
marmare314 37791ada99 enable brush coloring -> brush coloring 2023-05-16 22:24:26 +02:00
Robert Müller dd7cf38be5 Fix uninitialized field causing assertion error with MSVC
The modified time was uninitialized for the editor file browser entry corresponding to the downloadedmaps-link. The time is never rendered for links, but the uninitialized time value was still passed to `str_timestamp_ex`, which results in an assertion error due to an incorrect time value being used when compiling with MSVC.

This is fixed by properly initializing the field and also by only calling `str_timestamp_ex` when the time value will be rendered.

Closes #6579.
2023-05-15 22:07:37 +02:00
Robert Müller d08626cf69 Add default argument to CDataFileReader/IMap::GetItem
Add default value `nullptr` for `int *pType` and `int *pID` output parameters of `GetItem` functions.

Use `nullptr` instead of `0`.
2023-05-14 16:39:46 +02:00
Robert Müller d9307ca756 Use FileExists/fs_is_file instead of opening file
This is more concise and works more reliable e.g. on Windows.

See: https://devblogs.microsoft.com/oldnewthing/20071023-00/?p=24713
2023-05-10 21:04:02 +02:00
marmare314 7a0d566ddb combine proof mode buttons 2023-05-01 23:07:58 +02:00
marmare314 02429288f1 move coloring and info to settings 2023-05-01 22:44:03 +02:00
marmare314 9dddc0d8de show current entity type 2023-05-01 18:02:53 +02:00
marmare314 ab20e897a8 add spacing and group unused selector code 2023-04-29 15:07:25 +02:00
marmare314 ae63ea5f9e move unused, entities, goto, border to menu 2023-04-29 14:05:01 +02:00
bors[bot] ab5531f5cb
Merge #6543
6543: adjust corners of Button_Env r=def- a=Marmare314

Before:
![buttons-old](https://user-images.githubusercontent.com/49279081/235272933-a40e8255-67b0-4d11-8e54-bf62f4bc1a76.png)

After:
![buttons-adjusted](https://user-images.githubusercontent.com/49279081/235272940-854fe87e-3916-4e6d-aee4-9a2e1a07667f.png)


## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: marmare314 <49279081+Marmare314@users.noreply.github.com>
2023-04-29 10:51:30 +00:00
marmare314 68bbb613c5 adjust corners of Button_Env 2023-04-29 12:10:15 +02:00