Commit graph

1062 commits

Author SHA1 Message Date
Robert Müller 19bf435d6a Remove redundant assignments
According to cppcheck's `redundantInitialization` and `redundantAssignment` errors:

```
src\game\client\ui.cpp:456:5: style: Redundant initialization for 'tw'. The initialized value is overwritten before it is read. [redundantInitialization]
 tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
    ^
src\game\client\ui.cpp:454:11: note: tw is initialized
 float tw = std::numeric_limits<float>::max();
          ^
src\game\client\ui.cpp:456:5: note: tw is overwritten
 tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
    ^
src\game\client\ui.cpp:529:5: style: Redundant initialization for 'tw'. The initialized value is overwritten before it is read. [redundantInitialization]
 tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
    ^
src\game\client\ui.cpp:527:11: note: tw is initialized
 float tw = std::numeric_limits<float>::max();
          ^
src\game\client\ui.cpp:529:5: note: tw is overwritten
 tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
    ^

src\game\editor\editor.cpp:6051:19: style: Variable 'm_Map.m_Modified' is reassigned a value before the old one has been used. [redundantAssignment]
 m_Map.m_Modified = false;
                  ^
src\game\editor\editor.cpp:6046:19: note: m_Map.m_Modified is assigned
 m_Map.m_Modified = false;
                  ^
src\game\editor\editor.cpp:6051:19: note: m_Map.m_Modified is overwritten
 m_Map.m_Modified = false;
                  ^

src\game\client\prediction\entities\character.cpp:1148:36: style: Variable 'm_LatestInput' is reassigned a value before the old one has been used. [redundantAssignment]
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                                   ^
src\game\client\prediction\entities\character.cpp:1134:16: note: m_LatestInput is assigned
 m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
               ^
src\game\client\prediction\entities\character.cpp:1148:36: note: m_LatestInput is overwritten
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                                   ^
src\game\client\prediction\entities\character.cpp:1148:20: style: Variable 'm_LatestPrevInput' is reassigned a value before the old one has been used. [redundantAssignment]
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                   ^
src\game\client\prediction\entities\character.cpp:1134:36: note: m_LatestPrevInput is assigned
 m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
                                   ^
src\game\client\prediction\entities\character.cpp:1148:20: note: m_LatestPrevInput is overwritten
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                   ^
src\game\client\prediction\entities\character.cpp:1148:50: style: Variable 'm_PrevInput' is reassigned a value before the old one has been used. [redundantAssignment]
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                                                 ^
src\game\client\prediction\entities\character.cpp:1134:50: note: m_PrevInput is assigned
 m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
                                                 ^
src\game\client\prediction\entities\character.cpp:1148:50: note: m_PrevInput is overwritten
 m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input;
                                                 ^
```
2022-11-29 23:32:29 +01:00
Robert Müller 8e675878b0 Remove redundant null-checks
According to cppcheck's `nullPointerRedundantCheck` check:

```
src\game\client\components\menus_settings.cpp:729:8: warning: Either the condition 'pSkinToBeSelected==0' is redundant or there is possible null pointer dereference: pSkinToBeSelected. [nullPointerRedundantCheck]
   if((pSkinToBeSelected->GetName()[0] == 'x' && pSkinToBeSelected->GetName()[1] == '_'))
       ^
src\game\client\components\menus_settings.cpp:732:25: note: Assuming that condition 'pSkinToBeSelected==0' is not redundant
   if(pSkinToBeSelected == 0)
                        ^
src\game\client\components\menus_settings.cpp:729:8: note: Null pointer dereference
   if((pSkinToBeSelected->GetName()[0] == 'x' && pSkinToBeSelected->GetName()[1] == '_'))
       ^

src\game\editor\editor.cpp:5034:19: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
  float EndTime = pEnvelope->EndTime();
                  ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5034:19: note: Null pointer dereference
  float EndTime = pEnvelope->EndTime();
                  ^
src\game\editor\editor.cpp:5038:3: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
  pEnvelope->FindTopBottom(s_ActiveChannels);
  ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5038:3: note: Null pointer dereference
  pEnvelope->FindTopBottom(s_ActiveChannels);
  ^
src\game\editor\editor.cpp:5039:15: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
  float Top = pEnvelope->m_Top;
              ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5039:15: note: Null pointer dereference
  float Top = pEnvelope->m_Top;
              ^
src\game\editor\editor.cpp:5040:18: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
  float Bottom = pEnvelope->m_Bottom;
                 ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5040:18: note: Null pointer dereference
  float Bottom = pEnvelope->m_Bottom;
                 ^
src\game\editor\editor.cpp:5081:23: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck]
   for(int c = 0; c < pEnvelope->m_Channels; c++)
                      ^
src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant
   if(pEnvelope)
      ^
src\game\editor\editor.cpp:5081:23: note: Null pointer dereference
   for(int c = 0; c < pEnvelope->m_Channels; c++)
                      ^
```
2022-11-29 23:32:27 +01:00
Robert Müller e134e4e488 Remove redundant conditions (always either true or false)
According to cppcheck's `knownConditionTrueFalse` error:

```
src\base\system.cpp:1776:11: style: The comparison 'bytes == 0' is always true. [knownConditionTrueFalse]
 if(bytes == 0 && sock->ipv4sock >= 0)
          ^
src\base\system.cpp:1742:14: note: 'bytes' is assigned value '0' here.
 int bytes = 0;
             ^
src\base\system.cpp:1776:11: note: The comparison 'bytes == 0' is always true.
 if(bytes == 0 && sock->ipv4sock >= 0)
          ^

src\game\editor\io.cpp:887:33: style: Condition 'pSoundsItem->m_Version>=1' is always true [knownConditionTrueFalse]
      if(pSoundsItem->m_Version >= 1)
                                ^
src\game\editor\io.cpp:874:33: note: Assuming that condition 'pSoundsItem->m_Version<1' is not redundant
      if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
                                ^
src\game\editor\io.cpp:887:33: note: Condition 'pSoundsItem->m_Version>=1' is always true
      if(pSoundsItem->m_Version >= 1)
                                ^
src\game\editor\io.cpp:914:33: style: Condition 'pSoundsItem->m_Version>=1' is always true [knownConditionTrueFalse]
      if(pSoundsItem->m_Version >= 1)
                                ^
src\game\editor\io.cpp:901:33: note: Assuming that condition 'pSoundsItem->m_Version<1' is not redundant
      if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
                                ^
src\game\editor\io.cpp:914:33: note: Condition 'pSoundsItem->m_Version>=1' is always true
      if(pSoundsItem->m_Version >= 1)
                                ^

src\engine\client\backend\opengl\backend_opengl.cpp:207:68: style: Condition '*pStr=='\0'' is always false [knownConditionTrueFalse]
   else if(LastWasNumber && (*pStr == '.' || *pStr == ' ' || *pStr == '\0'))
                                                                   ^

src\game\client\components\maplayers.cpp:851:110: style: Condition 'DoTextureCoords' is always true [knownConditionTrueFalse]
        mem_copy_special(pUploadData + sizeof(vec2), pTmpTileTexCoords, sizeof(vec3), vtmpTiles.size() * 4, (DoTextureCoords ? (sizeof(vec2)) : 0));
                                                                                                             ^
src\game\client\components\maplayers.cpp:849:11: note: Assuming that condition 'DoTextureCoords' is not redundant
       if(DoTextureCoords)
          ^

src\game\client\components\maplayers.cpp:851:110: note: Condition 'DoTextureCoords' is always true
        mem_copy_special(pUploadData + sizeof(vec2), pTmpTileTexCoords, sizeof(vec3), vtmpTiles.size() * 4, (DoTextureCoords ? (sizeof(vec2)) : 0));
                                                                                                             ^

src\game\client\prediction\gameworld.cpp:567:5: style: Condition 'm_pParent' is always true [knownConditionTrueFalse]
 if(m_pParent && m_pParent->m_pChild && m_pParent->m_pChild != this)
    ^

src\game\client\components\menu_background.cpp:271:7: style: Condition 'NeedImageLoading' is always true [knownConditionTrueFalse]
   if(NeedImageLoading)
      ^
src\game\client\components\menu_background.cpp:268:23: note: Assignment 'NeedImageLoading=true', assigned value is 1
   NeedImageLoading = true;
                      ^
src\game\client\components\menu_background.cpp:271:7: note: Condition 'NeedImageLoading' is always true
   if(NeedImageLoading)
      ^

src\game\editor\editor.cpp:4991:6: style: Condition 'pEnvelope' is always true [knownConditionTrueFalse]
  if(pEnvelope)
     ^
```
2022-11-29 23:32:26 +01:00
Robert Müller 5e06eefcd2 Implement smooth zoom for editor
Port the smooth zoom code from the ingame camera to the editor with some minor adjustments.

The smooth zoom animation time can be adjusted with the existing `cl_smooth_zoom_time` config variable.

Closes #2525.
2022-11-23 23:06:20 +01:00
bors[bot] 56088cb4b0
Merge #6054
6054: Fix editor crash when shifting left/right, fix wrong up/down shifting r=heinrich5991 a=Robyt3

Shifting left/right with a shift value greater than the layer's width crashed the game due to a heap-buffer-overflow.

Shifting up/down with a shift value greater or equal to half the layer's height did not correctly shift the entire layer.

The values of the enum constants `DIRECTION_*` are changed to consecutive numbers instead of exponents of two, as the directions cannot be combined together as flags.

Closes #6036.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [X] Considered possible null pointers and out of bounds array indexing
- [X] Changed no physics that affect existing maps
- [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: Robert Müller <robytemueller@gmail.com>
2022-11-16 20:27:02 +00:00
Robert Müller 8c5bf10d44 Fix editor crash when shifting left/right, fix wrong up/down shifting
Shifting left/right with a shift value greater than the layer's width crashed the game due to a heap-buffer-overflow.

Shifting up/down with a shift value greater or equal to half the layer's height did not correctly shift the entire layer.

The values of the enum constants `DIRECTION_*` are changed to consecutive numbers instead of exponents of two, as the directions cannot be combined together as flags.

Closes #6036.
2022-11-16 20:55:44 +01:00
Robert Müller 4af20240fc Add Shift+G editor hotkey to toggle visibility of game layers
If any game layers are hidden, the hotkey will make them visible.
Else, if all game layers are visible, the hotkey will hide all of them.

Closes #4109.
2022-11-16 18:09:03 +01:00
Robert Müller ab9b6c2b80 Allow both shift keys to be used for all hotkeys
Handle both shift keys in some cases where only the left shift key was previously supported.

The `CChat::m_ReverseTAB` variable is removed because it's unnecessary.
2022-11-15 21:17:55 +01:00
Robert Müller 04be9d6e72 Add IInput::ShiftIsPressed and IInput::AltIsPressed
To avoid duplicate code when checking for both right and left shift or alt keys.
2022-11-15 21:17:55 +01:00
Robert Müller 26c95de743 Remove dead code that compares pointers of different types
This condition cannot be true, as `pGroup` is a `CLayerGroup *` but the layers are `CLayer *`/`CLayerTiles *`/`CLayerGame *` etc., which are not part of the same inheritance hierarchy.

The method `CLayerGroup::Render` already ensures that game layers are not rendered below other layers.
2022-11-15 21:17:55 +01:00
Robert Müller 91ba786b67 Only disable clipping if it was previously enabled 2022-11-15 21:17:55 +01:00
VoxelDoesCode 5d1bec5a83 Change editor UI, fix an overflow bug.
clang

clang2
2022-11-11 20:36:15 -05:00
Robert Müller 964f839410 Show selection popup when multiple images/sounds with same name exist
When readding a sound/image and multiple files with the name exist, a popup is shown that allows the user to choose the wanted file.
If exactly one file is found, it is used without showing a dialog.
As before, if no file is found, an error message popup is shown.
2022-11-05 15:42:39 +01:00
Robert Müller 812a884c06 Add generic selection popup to editor
Add `CEditor::ShowPopupSelection` to show a generic selection popup.

This popups shows a message and buttons for all entries in a `std::set`. Exactly one entry can be selected and the selection will be available to the caller in the given `SSelectionPopupContext`.
2022-11-05 15:42:39 +01:00
Robert Müller 940f5df225 Search for images/sounds in subfolders when readding, add error popup
Use `FindFile` to search for the image/sound file in all subfolders of the mapres folder when using the "Readd" button in the editor.

Show an error message popup when readding fails, i.e. when the file could not be found.
2022-11-05 00:16:44 +01:00
Robert Müller 7079925966 Add generic popup message to editor (e.g. for error message popups)
Add `CEditor::ShowPopupMessage` function to show a generic message in a popup.

The message text and color are configurable with the `SMessagePopupContext` argument object.
Instances of this class must have a static memory location, as the message needs to be available after the `ShowPopupMessage` function returns, and the address of this object is used to uniquely identify it in the UI.
2022-11-05 00:16:44 +01:00
bors[bot] 8d7442e328
Merge #6002 #6003
6002: Explain -DANTIBOT=ON a bit better (fixes #6001) r=heinrich5991 a=def-

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

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

- [ ] 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)


6003: Fix height and margin of sound and image popups 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: Dennis Felsing <dennis@felsin9.de>
Co-authored-by: Robert Müller <robytemueller@gmail.com>
2022-11-04 18:55:46 +00:00
Robert Müller c5bbccfe07 Also append sounds when appending a map to another map 2022-11-03 20:21:45 +01:00
Robert Müller b0a21dab09 Use bool for Load, Save, Append result, true on success
The `Append` method was returning `0` on success while `Load` and `Save` were returning `1`.
Now all three methods use a `bool` as return value and return `true` on success.

The call `SortImages()` is moved inside the `Append` method, as it should always be called when appending succeeded.
2022-11-03 20:17:06 +01:00
Robert Müller 40dbb1b992 Fix height and margin of sound and image popups
The height of the sound popup was too small, as it was not updated when the "Readd" button was added.

The additional `2.0f` margin at the top of the popups is removed, as all popup menus already have default `5.0f` margins on all sides.

The height of the image popup for external images was not including this margin to begin with, so it was slightly too small but is correct now.
The height of the image popup for embedded images is adjusted to no longer include this margin.

Pass `nullptr` instead of calculating unused `CUIRect` values.
2022-11-03 19:53:21 +01:00
Robert Müller abf795d9da Invoke static methods without a class instance
The methods `ReplaceImage` and `ReplaceSound` are static, so they should be called without an object.
2022-11-03 19:32:10 +01:00
bors[bot] e71ce8fcde
Merge #5998
5998: Fix Ctrl+F hotkey not checking for Ctrl key, minor improvement to tile details popup layout 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>
2022-11-01 22:10:19 +00:00
Robert Müller 886ec990fe Add missing check for modifier of Ctrl+F hotkey
The hotkey for the "Find empty slot" button was not correctly checking for a pressed modifier, so it was already being trigger by just the key F instead of the desired Ctrl+F.
2022-11-01 23:01:32 +01:00
Robert Müller 8e9b4ddcd2 Refactor tile details popup height, variable names
The height is calculated based on the number of rows and the row height instead of being entirely hardcoded, which makes maintenance easier.
The total height of the speedup popup was slightly too large, which is also fixed by this.
Variable names and their declaration positions are also refactored.
2022-11-01 23:01:28 +01:00
Robert Müller 0db4b5fe0c Refactor border button condition, move button variable
The conditions can be combined into one if-statement to better readability.
2022-11-01 22:30:56 +01:00
Robert Müller c29d4b984c Remove redundant CUIRects, improve find button height
Some of the CUIRects were calculated but never used.
The height of the "Find empty slot" button is made consistent with the height of the properties shifters.
2022-11-01 22:29:12 +01:00
Robert Müller d6d88d4370 Allow selecting switch number 0 in editor again
This reverts part of #5993 to allow switch number 0 to be selected again.
Switch number 0 is permanently enabled, so it useful for tiles that should always be switched on.
Eventually tiles that don't work with switch 0 (e.g. switch open/close tiles) should be made unplaceable and the switch number should be hidden for tiles where it doesn't have any effect (e.g. jump tiles). See #5995.
2022-11-01 21:52:49 +01:00
bors[bot] 846b569a86
Merge #5994
5994: Change editor hotkey Ctrl+A to Ctrl+T for layer/tile details r=def- a=Robyt3

The hotkey Ctrl+A is already active universally in the editor to open and append a map to the current one. This collides with the hotkeys for opening the layer/tile details popup for tune, tele, speedup and switch layers, which is only active when a layer of said type is select. Pressing the hotkey in this context opens the popup and the append dialog at the same time, which is undesirable. Therefore the hotkey to open the layer/tile details is changed to Ctrl+T instead. This combination is currently unused and seems approriate, as the T could stand for "Tile details".

## 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>
2022-11-01 12:35:28 +00:00
Robert Müller c916e5d262 Change editor hotkey Ctrl+A to Ctrl+T for layer/tile details
The hotkey Ctrl+A is already active universally in the editor to open and append a map to the current one.
This collides with the hotkeys for opening the layer/tile details popup for tune, tele, speedup and switch layers, which is only active when a layer of said type is select.
Pressing the hotkey in this context opens the popup and the append dialog at the same time, which is undesirable.
Therefore the hotkey to open the layer/tile details is changed to Ctrl+T instead. This combination is currently unused and seems approriate, as the T could stand for "Tile details".
2022-11-01 13:13:22 +01:00
Robert Müller c6fa29eb56 Fix incorrect minimum values for tele, speedup and switch layers
It was possible to select tele number 0, speedup force 0 and switch number 0 in the layer details in the editor, because some of the bounds checks or calculations were not excluding the value 0.
As placing those tiles with the value 0 in the editor is not possible and the tiles with this value are ignored by server and client, it also shouldn't be possible to select those values in the first place.
2022-11-01 12:11:18 +01:00
Robert Müller d551617c34 Use str_copy instead of str_format with format "%s"
Using `str_format(aBuf, sizeof(aBuf), "%s", pStr)` is equivalent to `str_copy(aBuf, pStr, sizeof(aBuf))`. Using `str_copy` is more readable and also more efficient as there is no overhead from parsing the format string and from passing varargs.
2022-10-27 21:42:14 +02:00
Robert Müller 6b7563a90b Fix large editor popups being outside of screen, add margin
Large editor popups could be positioned outside of the screen area, when they could not be positioned below or to the right of the cursor without overflowing. This is fixed by making sure the popup does not overflow the top or left side of the screen after adjusting its position.

A small margin is also added so popups don't start or end immediately at the screen border.

Closes #5982.
2022-10-25 20:16:39 +02:00
Rafael Fontenelle cd14660307 Fix misspellings 2022-10-25 13:51:56 -03:00
Robert Müller f5a16c1c77 Fix crash in editor when using up/down keys on empty images list 2022-10-21 20:28:30 +02:00
Robert Müller 4a683e024a Fix crash in editor when using up/down keys on empty sounds list 2022-10-21 20:28:00 +02:00
VoxelDoesCode 484cb82872 Hex Values in the editor's info feature
Clang format before squash
2022-10-11 19:27:12 -04:00
Robert Müller 98848cde70 Use str_comp_filenames to sort maps and demos again
This means that digit characters in filenames will be comparsed as numbers instead of being compared as individual digits.

The use of this function was previously (d2f5714042) removed as it did not sort names case insensitively, whereas now it does.
2022-09-30 14:48:53 +02:00
Robert Müller 72194d28e7 Replace magic numbers with enum EShowEnvelope 2022-09-22 18:02:07 +02:00
bors[bot] 68e2f51280
Merge #5756
5756: Editor: added a goto button r=heinrich5991 a=archimede67

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

This feature was also suggested by Pulsar. It adds a button to go to a specified coordinate point by inputting x and y coordinates through a popup window:

![image](https://user-images.githubusercontent.com/13364635/185762103-48a9fbaf-282e-45d8-86a4-bf5eedf620b0.png)

The two number inputs are constrained between 0 and the width/height of the map (minus 1). When clicking "Go", it focuses the camera at the center of the tile at these coordinates.

## Checklist

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


Co-authored-by: Corantin H <archi0670@gmail.com>
2022-09-16 01:17:56 +00:00
Corantin H e52e443988 Editor: used max int value for goto min and max coordinates 2022-09-15 20:54:20 +02:00
bors[bot] da0dca25c3
Merge #5823
5823: Editor: Added reload button for image and sound popups r=heinrich5991 a=sctt

Automatically reloads the image from mapres folder based on its current name, that's just a quicker "replace" which is convenient while experimenting on image contents, some mappers asked for this.

![Screenshot from 2022-09-10 11-57-58](https://user-images.githubusercontent.com/3328841/189479587-620c812c-0df2-4ba2-94a0-83eca8e42c81.png)

note: image lookup is currently limited to the mapres root folder, no directory recursion has been implemented, this is an improvement that might be added in the future (even though in my understanding, organizing mapres into subfolders is not a very common practice, not even the "search" feature considers that).

## 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] 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: “sctt” <“sctt@sctt.it”>
2022-09-15 06:54:50 +00:00
“sctt” 73d883d16b Editor image reload: renamed reload into readd 2022-09-15 08:46:31 +02:00
bors[bot] cef096ecd7
Merge #5820
5820: Editor: Added "Order" button in quads popup r=heinrich5991 a=sctt

Main purpose is to control quads z index, but i like how this can be used to reveal how many quads a layer has just by placing a new one.
Furthermore, it provides a way to reference quads, that's needed to make custom cli tools work on user selected quads.

![Screenshot from 2022-09-09 19-04-21](https://user-images.githubusercontent.com/3328841/189411505-558ca601-e753-48b2-a6c3-d9f293795951.png)

## 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] 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: “sctt” <“sctt@sctt.it”>
2022-09-11 22:44:13 +00:00
“sctt” 79fa29d8b8 editor: added order button in quads popup 2022-09-10 18:04:38 +02:00
“sctt” 39223dfd8a editor: added reload button for image and sound popups 2022-09-10 12:23:00 +02:00
Robert Müller 19a0544364 Fix editor layer image selection not working 2022-09-08 15:30:22 +02:00
Robert Müller ff471b4d17 Minor refactoring: homogenise code structure of selection popups 2022-09-04 23:00:51 +02:00
Robert Müller 833f690c59 Refactor editor sound selection popup using CScrollRegion
Decrease popup size by remove the unused empty space designated for "previewing" sounds.
2022-09-04 22:59:33 +02:00
Robert Müller cef984294c Fix minimum/maximum values of editor properties
The Order-property maximum value was too large, so it was temporarily (only visually) possible to go beyond the maximum.

The minimum/maximum values for the Color-property were incorrect and redundant, as `PROPTYPE_COLOR` is used for RGBA color properties and not for envelope IDs.
2022-09-04 13:06:15 +02:00
Robert Müller 2e8d203ed4 Fix editor value selector not allowing minimal value change
For example, when the scale is 1, changing the value by exactly 1 was not possible.
2022-09-04 13:02:31 +02:00