Commit graph

1318 commits

Author SHA1 Message Date
Edgar 8c49c2ea4b
Merge pull request #6952 from Robyt3/TextRender-Font-Index-File
Add font index, support font family variants depending on language
2023-08-05 15:49:12 +00:00
Robert Müller d642abd722 Add font index, support font family variants depending on language
Add `fonts/index.json` which specifies:

- List of all font files that should be loaded (filenames).
- Default font (specified by family name or by family and style name).
- Font variants for different languages, using the name of the language file as key.
- Fallback fonts.
- Icon font.

There are characters (e.g. all in `刃直海角骨入`) that look different depending on the language of the content being Japanese, Simplified Chinese, Traditional Chinese and Hangul, because Unicode uses the same codepoint for characters regardless of the language. To render these characters correctly, the active variant font is switched depending on the selected language.

The `ITextRender` interface is changed so the current language variant can be set using `SetFontLanguageVariant` and the default and icon fonts can be toggled using `SetFontPreset`. The class `CFont` is removed entirely.

The text render is restructured: The font faces and font atlas are now managed by a separate class `CGlyphMap` like on upstream. As the text fill and outline textures always have the same size, the texture skyline only needs to be stored once and free positions in the atlas only need to be calculated once for each glyph instead of separately for the fill and outline textures.

The font files and their licenses are also updated:

- Update Source Han Sans to version 2.001.
- Update Glow Sans Japanese Compressed to version 0.93.
- Update Deja Vu Sans to version 2.37.
- Update Font Awesome icons font to March 2023 version.

Closes #6881.
2023-08-01 19:30:25 +02:00
Edgar b909cfadd8
Merge pull request #6943 from Robyt3/Editor-shared_ptr-Refactoring
Use `std::shared_ptr` for editor resources, fix crashes with brush
2023-08-01 09:13:59 +00:00
marmare314 93e95bbd38 add box selection to envelope editor 2023-07-29 15:10:14 +02:00
Robert Müller 6f03aabb34 Use std::shared_ptr for editor resources, fix crashes with brush
Simplify memory management of groups, layers, images, sounds and envelopes by using `std::shared_ptr` for all of them.

Clear brush when creating a new map to prevent crash due to unloaded textures being used in tile layer. Closes #6935.

Also fix crash when restoring a saved brush after removing an image that is being used by it.
2023-07-28 21:17:19 +02:00
marmare314 862c0ca2fc make point hitbox bigger 2023-07-28 17:47:28 +02:00
marmare314 babdbc4b17 add grid to envelope editor 2023-07-28 16:18:56 +02:00
Robert Müller b33c9ca977
Merge pull request #6934 from Marmare314/zoom-reset-big-values
handle big value ranges on envelope zoom reset
2023-07-28 13:25:46 +00:00
Robert Müller c2379591e0
Merge pull request #6941 from Marmare314/zoom-adaption
improve offset adaption for envelope zoom
2023-07-28 12:16:56 +00:00
marmare314 f3353e8062 improve offset adaption for envelope zoom
The offset adaption was not correct. Close to the origin it was not really noticeable,
but further away the points shifted offscreen when zooming.
2023-07-28 12:50:12 +02:00
marmare314 62ee646283 allow multiple selection in envelope editor 2023-07-28 12:41:25 +02:00
marmare314 d964a3d327 handle big value ranges on envelope zoom reset 2023-07-27 19:47:06 +02:00
marmare314 873a8543df calculate zoom factor correctly for target zoom 2023-07-27 18:36:58 +02:00
Robert Müller 22bd19be06
Merge pull request #6920 from Marmare314/layer-drag-bug
reset layer dragging status if no buttons were pressed
2023-07-26 09:01:38 +00:00
marmare314 be861664bc reset layer dragging status if no buttons were pressed 2023-07-26 09:34:36 +02:00
marmare314 3010633099 improve envelope y offset on reset for small value ranges 2023-07-26 00:10:15 +02:00
Robert Müller 71500fd60c Improve server settings editor and status bar
Use icons for all server settings buttons. Rearrange and group buttons.

Show buttons in disabled state when they are not useable instead of hiding them.

Remove checker background from server settings list.

Overhaul hotkeys, also show hotkeys in the tooltips:
- Enter: add command
- Alt+Enter: update command (previously M)
- Alt+Up/Down: move command up/down (previously no hotkey)
- Delete: delete command

Don't activate command lineinput when selecting, moving or deleting elements, as this prevents the listbox from accepting the delete hotkey.

Fix server settings listbox being active while file dialog is open.

Ensure extra editor dragbar area matches the respective toolbar size.

Remove spacing on the left side of extra editors to improve alignment.

Increase status bar button sizes and make them consistent.

Use `enum` to track active extra editor instead of using multiple `bool`s.

Disable extra editor buttons when tile picker is shown, as the extra editors are not rendered in this case.
2023-07-25 21:21:54 +02:00
Robert Müller 177f7485c2 Render editor status bar except tooltip behind popups
So that buttons in the status bar cannot be used while a popup or the file dialog is open.

The tooltip still has to be rendered after popup menus, as popup menus can set the tooltip, which would otherwise not be shown.
2023-07-25 20:17:36 +02:00
Robert Müller d8c05115c9 Add constructor for CSetting and use emplace_back 2023-07-25 20:17:27 +02:00
marmare314 d4110529e4 implement zoom and drag in envelope editor 2023-07-24 22:58:26 +02:00
Robert Müller eb8619e104 Set default name when saving map under new name or as copy
When using "Save as" and "Save copy" set the default map name in the file dialog to the name of the current map.
2023-07-24 19:02:43 +02:00
marmare314 972fc717a6 keep selection when moving layers fixes #6787 2023-07-19 15:24:00 +02:00
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 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
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
Robert Müller 53fad543c0 Fix editor modified state not updated for server settings changes
Closes #6856.
2023-07-15 10:10:26 +00:00
marmare314 974255b3ea fix quadpoint moving on selection 2023-07-14 07:49:16 +02: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 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
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
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
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
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
Robert Müller fa65e19c5d Close quad point popup when selected quad or quad index invalid 2023-07-08 11:43:07 +02:00