toggle dev mode with feature flags, document --features dev

This commit is contained in:
yuni 2024-04-26 14:24:24 +02:00
parent 77cdbba7db
commit e50e345d48
3 changed files with 20 additions and 24 deletions

View file

@ -34,7 +34,9 @@ embed-resource = "1.6.3" # embedding of .exe metadata
[features] [features]
default = ["x11", "embed_assets"] default = ["x11", "embed_assets"]
dev = ["bevy/dynamic_linking", "bevy/file_watcher"] mute_music = []
dev_mode = []
dev = ["dev_mode", "mute_music", "bevy/dynamic_linking", "bevy/file_watcher"]
wasm = ["bevy/webgl2"] wasm = ["bevy/webgl2"]
x11 = ["bevy/x11"] x11 = ["bevy/x11"]
wayland = ["bevy/wayland"] wayland = ["bevy/wayland"]

View file

@ -138,12 +138,6 @@ See https://superuser.com/questions/1202989/how-to-you-add-a-parameter-to-an-exe
If there is no package for the version or operating system that you need, or if you wish to tinker on the game, you can also build outfly yourself. If there is no package for the version or operating system that you need, or if you wish to tinker on the game, you can also build outfly yourself.
For development, it's recommended to use `--features dev` to enable dynamic linking for faster compile times, e.g. like this:
```
cargo [run|build] --features dev
```
## On Linux ## On Linux
Install the build dependencies. On ArchLinux, it's the following, though you can replace `rust` with `rustup`: Install the build dependencies. On ArchLinux, it's the following, though you can replace `rust` with `rustup`:
@ -160,8 +154,6 @@ cd outfly
cargo run --release cargo run --release
``` ```
NOTE: Audio is muted by default when run through `cargo run`, unless you add `--release`
## Building for Windows on Linux ## Building for Windows on Linux
``` ```
@ -206,6 +198,21 @@ echo '<script type="module">import init from "./outfly.js"; init()</script>' > w
python -m http.server -d wasm python -m http.server -d wasm
``` ```
## Dev Features
For development, it's recommended to use `--features dev`:
```
cargo [run|build] --features dev
```
This enables the following:
- Mutes music by default (you can still unmute it)
- Enables "dev mode", which changes the game slightly, e.g. enables some debugging features and additional cheats.
- Enables dynamic linking for faster compile times. Note that this makes it harder to run the game directly with `./outfly`, please use `cargo run` instead.
- Enables bevy's "file watcher" feature that auto-reloads changed assets while the game is running. This obviously works if the assets are not embedded directly into the binary with the `embed_assets` feature. To use this, customize the compile features like this: `--no-default-features --features "dev x11"`
# Changelog # Changelog
- git: Add command line options to set window/fullscreen mode - git: Add command line options to set window/fullscreen mode

View file

@ -13,7 +13,6 @@
use bevy::prelude::*; use bevy::prelude::*;
use std::collections::HashMap; use std::collections::HashMap;
use std::env;
pub const SCOPE_SEPARATOR: &str = "$"; pub const SCOPE_SEPARATOR: &str = "$";
@ -122,21 +121,9 @@ pub struct Settings {
impl Default for Settings { impl Default for Settings {
fn default() -> Self { fn default() -> Self {
let dev_mode; let dev_mode = cfg!(feature = "dev_mode");
let default_mute_sfx = false; let default_mute_sfx = false;
let default_mute_music; let default_mute_music = cfg!(feature = "mute_music");
if let Ok(_) = env::var("CARGO") {
// Mute audio by default when run through `cargo`
default_mute_music = cfg!(debug_assertions);
// Enable dev mode when running `cargo run` without `--release`
dev_mode = cfg!(debug_assertions);
}
else {
default_mute_music = false;
dev_mode = false;
}
let version = if let Some(version) = option_env!("CARGO_PKG_VERSION") { let version = if let Some(version) = option_env!("CARGO_PKG_VERSION") {
version.to_string() version.to_string()
} else { } else {