Skip to main content

bevy_convars/
builtin.rs

1//! Builtin CVars that are automatically registered in any application.
2
3use std::ops::Deref;
4
5use bevy_app::Plugin;
6use bevy_ecs::prelude::Resource;
7use bevy_ecs::system::SystemParam;
8
9use crate::{CVarFlags, cvar_collection};
10cvar_collection! {
11    /// Collection of core CVars you can use as a system argument.
12    pub struct CoreCVars & CoreCVarsMut {
13        /// Enables logging ALL cvar modifications. This will log the change as info.
14        log_cvar_changes = cvar LogCVarChanges("core.log_cvar_changes", CVarFlags::RUNTIME): bool = false,
15    }
16
17    /// Plugin that handles registering all the core CVars.
18    #[doc(hidden)]
19    pub struct CoreCVarsPlugin;
20}
21
22static_assertions::assert_impl_all!(CoreCVars: SystemParam);
23static_assertions::assert_impl_all!(CoreCVarsPlugin: Plugin);
24static_assertions::assert_impl_all!(LogCVarChanges: Resource, Deref<Target = bool>);
25
26#[cfg(feature = "config_loader")]
27use std::path::PathBuf;
28
29#[cfg(feature = "config_loader")]
30cvar_collection! {
31    /// Collection of config-loader related CVars you can use as a system parameter.
32    pub struct ConfigLoaderCVars & ConfigLoaderCVarsMut {
33        /// Names of configuration layer files to load in atop the default config.
34        /// # Remarks
35        /// Unlike basically all other CVars, this one cannot be set by file layers, because it defines them.
36        config_layers = cvar ConfigLayers("core.config_layers", CVarFlags::LOCAL): Vec<PathBuf> = vec![],
37    }
38
39    /// Plugin that handles registering all the config loader CVars.
40    #[doc(hidden)]
41    pub struct ConfigLoaderCVarsPlugin;
42}