Skip to content

Commit

Permalink
text_wrap_debug scale factor commandline args (#9951)
Browse files Browse the repository at this point in the history
# Objective

Add commandline arguments to `text_wrap_debug` to set the window and UI
scale factors.
  • Loading branch information
ickshonpe authored Sep 28, 2023
1 parent 20ed3e0 commit 4184050
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion examples/ui/text_wrap_debug.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
//! This example demonstrates text wrapping and use of the `LineBreakOn` property.

use argh::FromArgs;
use bevy::prelude::*;
use bevy::text::BreakLineOn;
use bevy::window::WindowResolution;
use bevy::winit::WinitSettings;

#[derive(FromArgs, Resource)]
/// `text_wrap_debug` demonstrates text wrapping and use of the `LineBreakOn` property
struct Args {
#[argh(option)]
/// window scale factor
scale_factor: Option<f64>,

#[argh(option, default = "1.")]
/// ui scale factor
ui_scale: f64,
}

fn main() {
let args: Args = argh::from_env();
let window = if let Some(scale_factor) = args.scale_factor {
Window {
resolution: WindowResolution::default().with_scale_factor_override(scale_factor),
..Default::default()
}
} else {
Window::default()
};

App::new()
.add_plugins(DefaultPlugins)
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(window),
..Default::default()
}))
.insert_resource(WinitSettings::desktop_app())
.insert_resource(UiScale(args.ui_scale))
.add_systems(Startup, spawn)
.run();
}
Expand Down

0 comments on commit 4184050

Please sign in to comment.