Skip to content

Move close_on_esc to bevy_dev_tools#12855

Merged
james7132 merged 5 commits intobevyengine:mainfrom
BD103:close-on-esc
Apr 3, 2024
Merged

Move close_on_esc to bevy_dev_tools#12855
james7132 merged 5 commits intobevyengine:mainfrom
BD103:close-on-esc

Conversation

@BD103
Copy link
Member

@BD103 BD103 commented Apr 3, 2024

Objective

  • As @james7132 said on Discord, the close_on_esc system is forcing bevy_window to depend on bevy_input.
  • close_on_esc is not likely to be used in production, so it arguably does not have a place in bevy_window.

Solution

  • As suggested by @afonsolage, move close_on_esc into bevy_dev_tools.
    • Add an example to the documentation too.
  • Remove bevy_window's dependency on bevy_input.
    • Add bevy_reflect's smol_str feature to bevy_window because it was implicitly depended upon with bevy_input before it was removed.
  • Remove any usage of close_on_esc from the examples.
    • bevy_dev_tools is not enabled by default. I personally find it frustrating to run examples with additional features, so I opted to remove it entirely.
    • This is up for discussion if you have an alternate solution.

Changelog

  • Moved bevy_window::close_on_esc to bevy_dev_tools::close_on_esc.
  • Removed usage of bevy_dev_tools::close_on_esc from all examples.

Migration Guide

bevy_window::close_on_esc has been moved to bevy_dev_tools::close_on_esc. You will first need to enable bevy_dev_tools as a feature in your Cargo.toml:

[dependencies]
bevy = { version = "0.14", features = ["bevy_dev_tools"] }

Finally, modify any imports to use bevy_dev_tools instead:

// Old:
// use bevy::window::close_on_esc;

// New:
use bevy::dev_tools::close_on_esc;

App::new()
    .add_systems(Update, close_on_esc)
    // ...
    .run();

BD103 added 3 commits April 2, 2024 20:35
I chose to remove references to `close_on_esc` in examples, since `bevy_dev_tools` is not enabled by default.
Additionally add `smol_str` feature to `bevy_reflect`, since it was depended on by `bevy_window` implicitly.
@BD103 BD103 requested a review from james7132 April 3, 2024 00:52
@alice-i-cecile alice-i-cecile added M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide A-Dev-Tools Tools used to debug Bevy applications. labels Apr 3, 2024
@BD103 BD103 added the A-Windowing Platform-agnostic interface layer to run your app in label Apr 3, 2024
@alice-i-cecile alice-i-cecile added the C-Examples An addition or correction to our examples label Apr 3, 2024
BD103 added 2 commits April 2, 2024 21:08
I resolved to just remove the links, since the only other solution I could think of was to feature-gate `bevy_input` to only be included when building the docs.
@james7132 james7132 enabled auto-merge April 3, 2024 01:25
@james7132 james7132 added this pull request to the merge queue Apr 3, 2024
Merged via the queue into bevyengine:main with commit 97131e1 Apr 3, 2024
@BD103 BD103 deleted the close-on-esc branch April 3, 2024 01:59
chompaa pushed a commit to chompaa/bevy that referenced this pull request Apr 5, 2024
# Objective

- As @james7132 said [on
Discord](https://discord.com/channels/691052431525675048/692572690833473578/1224626740773523536),
the `close_on_esc` system is forcing `bevy_window` to depend on
`bevy_input`.
- `close_on_esc` is not likely to be used in production, so it arguably
does not have a place in `bevy_window`.

## Solution

- As suggested by @afonsolage, move `close_on_esc` into
`bevy_dev_tools`.
  - Add an example to the documentation too.
- Remove `bevy_window`'s dependency on `bevy_input`.
- Add `bevy_reflect`'s `smol_str` feature to `bevy_window` because it
was implicitly depended upon with `bevy_input` before it was removed.
- Remove any usage of `close_on_esc` from the examples.
- `bevy_dev_tools` is not enabled by default. I personally find it
frustrating to run examples with additional features, so I opted to
remove it entirely.
  - This is up for discussion if you have an alternate solution.

---

## Changelog

- Moved `bevy_window::close_on_esc` to `bevy_dev_tools::close_on_esc`.
- Removed usage of `bevy_dev_tools::close_on_esc` from all examples.

## Migration Guide

`bevy_window::close_on_esc` has been moved to
`bevy_dev_tools::close_on_esc`. You will first need to enable
`bevy_dev_tools` as a feature in your `Cargo.toml`:

```toml
[dependencies]
bevy = { version = "0.14", features = ["bevy_dev_tools"] }
```

Finally, modify any imports to use `bevy_dev_tools` instead:

```rust
// Old:
// use bevy::window::close_on_esc;

// New:
use bevy::dev_tools::close_on_esc;

App::new()
    .add_systems(Update, close_on_esc)
    // ...
    .run();
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Dev-Tools Tools used to debug Bevy applications. A-Windowing Platform-agnostic interface layer to run your app in C-Examples An addition or correction to our examples M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants