Skip to content

Persist game settings like music volume or graphic settings in a nice toml file in the right location.

License

Notifications You must be signed in to change notification settings

Lan-Game-Studios/bevy-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bevy Settings

License: MIT Doc Crate Build Status Bevy tracking dependency status

The goal of this project is to store settings in a resource throughout game launches.

Discord

Currently this crate supports Linux, Mac and Windows.

The crate will choose the appropriate path for each OS to store the config file.

TODO

  • multi storage support
  • file naming support
  • obfuscation support, this should just make it minimal hard to change the data, it is not really secure

Usage

This example will generate a config file on your system but it probably will not hurt you if you pick something non existent

use bevy::prelude::*; 
use bevy_settings::{Serialize, Deserialize};

#[derive(Resource, Default, Serialize, Deserialize, Clone, Copy)]
#[serde(crate = "bevy_settings::serde")]
struct Settings {
    master_volume: f64,
    custom_cursor: bool,
}

fn main () {
    App::new()
        .add_plugin(bevy_settings::SettingsPlugin::<Settings>::new(
            "My awesome game studio",
            "The name of the game"
        ))
        .run();
}

on e.g. my linux machine this will create

❯ cat ~/.config/myawesomegamestudio/My awesome game studio.toml 
master_volume = 0.0
custom_cursor = false

Known limitations

  • the toml crate has problems with large numbers e.g. u64::MAX
  • there is a problem with tuple structs e.g. TestSetting(u32) does not work but TestSetting{ test: u32 } works fine.

Checkout the basic example to see how to persist the configuration.

Version Bevy Version
0.1.0 0.9
0.2.0 0.10
0.3.1 0.11
0.4.0 0.12
0.5.0 0.13
0.6.0 0.14

Lan Game Studios

This crate is part of an effort to crate a game studio. Checkout Mega Giga Cookie Destoryer TD or the mission of Lan Game Studios if you like games or game development.

About

Persist game settings like music volume or graphic settings in a nice toml file in the right location.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages