Enum support in SettingsGroup derive macro, implemented key attribute#23719
Enum support in SettingsGroup derive macro, implemented key attribute#23719alice-i-cecile merged 16 commits intobevyengine:mainfrom
Conversation
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
24abb12 to
6b56f1f
Compare
|
FAO reviewers: i've added the fix for #23722 to this PR as it touches the same code. I can split out into a separate PR if preferred. |
kfc35
left a comment
There was a problem hiding this comment.
Just some doc refinements and some code clean-ups that I’d like to see get done (specifically that removal of the redundant code block)
Also @DavidCrossman ’s comment is valid
Feel free to re-request after you’ve addressed everything!
Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
39e74ca to
0606b3d
Compare
|
The wasm build failing is unrelated to the PR, but is a legitimate issue that needs to be resolved before CI can pass (probably should be a separate PR) Copied from the logs for convenience: |
…ures (#23779) # Objective - Unblock #23719 - The PR revealed that wasm builds are currently broken for `bevy_settings` when trying to merge to main. - On main, if you try to build an example that requires `bevy_settings` for wasm targets, it fails with the same compilation error (i.e. `cargo build --release --example persisting_preferences --target wasm32-unknown-unknown --features=“bevy_settings”`) ## Solution - Fix up `store_wasm.rs`. The function signatures should match those in `store_fs.rs`, and remove any references that do not exist. ## Testing - With the `Cargo.toml` change from #23719, was able to build the wasm target described in Objective successfully. Then, prepared the wasm target and served it locally following the examples/README.md directions. The example works as expected for web interactions.
|
Now that #23779 is merged, I think this just needs main merged into it, and then it should pass CI |
…ures (bevyengine#23779) # Objective - Unblock bevyengine#23719 - The PR revealed that wasm builds are currently broken for `bevy_settings` when trying to merge to main. - On main, if you try to build an example that requires `bevy_settings` for wasm targets, it fails with the same compilation error (i.e. `cargo build --release --example persisting_preferences --target wasm32-unknown-unknown --features=“bevy_settings”`) ## Solution - Fix up `store_wasm.rs`. The function signatures should match those in `store_fs.rs`, and remove any references that do not exist. ## Testing - With the `Cargo.toml` change from bevyengine#23719, was able to build the wasm target described in Objective successfully. Then, prepared the wasm target and served it locally following the examples/README.md directions. The example works as expected for web interactions.
…bevyengine#23719) # Objective Implements part of bevyengine#23302 Fixes: bevyengine#23722 For background on bevy settings see the initial PR: bevyengine#23034 ## Solution Supports `unit-like` Enum resources: ```rust #[derive(Resource, SettingsGroup, Reflect, Debug, Default)] #[reflect(Resource, SettingsGroup, Default)] enum CounterRefreshRateSettings { #[default] Slow, Fast, } ``` Assuming the above is initialised as `CounterRefreshRateSettings::Slow`, results in: ```toml [counter_refresh_rate_settings] counter_refresh_rate_settings = "Slow" ``` Setting the `group` attribute works the same as structs: ```rust #[settings_group(group = "counter_settings")] ``` Results in: ```toml [counter_settings] counter_refresh_rate_settings = "Slow" ``` This PR adds a `key` attribute which can only be used on enums (for now), otherwise a compile-time error is thrown: ```rust #[settings_group(key = "refresh_rate")] ``` Results in: ```toml [counter_refresh_rate_settings] refresh_rate = "Slow" ``` ## Testing - Added tests that checks merging enums into groups and round trip serialisation. - Added a "cheat sheet" for the derive syntax, immitating other derive macros in the file. --------- Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com> Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Objective
Implements part of #23302
Fixes: #23722
For background on bevy settings see the initial PR:
#23034
Solution
Supports
unit-likeEnum resources:Assuming the above is initialised as
CounterRefreshRateSettings::Slow, results in:Setting the
groupattribute works the same as structs:#[settings_group(group = "counter_settings")]Results in:
This PR adds a
keyattribute which can only be used on enums (for now), otherwise a compile-time error is thrown:#[settings_group(key = "refresh_rate")]Results in:
Testing