mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Add [map_renderer.render_passes] section to SpacemanDMM.toml
This commit is contained in:
parent
4beb1f35af
commit
a19cc58e32
3 changed files with 16 additions and 2 deletions
|
|
@ -238,7 +238,7 @@ fn run(opt: &Opt, command: &Command, context: &mut Context) {
|
|||
..
|
||||
} = *context;
|
||||
|
||||
let render_passes = &dmm_tools::render_passes::configure(enable, disable);
|
||||
let render_passes = &dmm_tools::render_passes::configure(&context.dm_context.config().map_renderer, enable, disable);
|
||||
let paths: Vec<&Path> = files.iter().map(|p| p.as_ref()).collect();
|
||||
let errors: RwLock<HashSet<String>> = Default::default();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ pub struct Config {
|
|||
pub langserver: Langserver,
|
||||
pub dmdoc: DMDoc,
|
||||
pub debugger: Debugger,
|
||||
pub map_renderer: MapRenderer,
|
||||
}
|
||||
|
||||
/// General error display options
|
||||
|
|
@ -81,6 +82,7 @@ pub enum WarningLevel {
|
|||
Unset = 6,
|
||||
}
|
||||
|
||||
/// Available debug engines.
|
||||
#[derive(Debug, Deserialize, Clone, Copy, PartialEq)]
|
||||
pub enum DebugEngine {
|
||||
#[serde(alias = "extools")]
|
||||
|
|
@ -89,6 +91,16 @@ pub enum DebugEngine {
|
|||
Auxtools,
|
||||
}
|
||||
|
||||
/// Config for the map renderer.
|
||||
#[derive(Debug, Default, Deserialize, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct MapRenderer {
|
||||
/// Map from render pass name to whether it should be enabled/disabled.
|
||||
///
|
||||
/// Priority is: CLI arguments > config > defaults.
|
||||
pub render_passes: HashMap<String, bool>,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
/// Read a config TOML and generate a [`Config`] struct
|
||||
///
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ pub const RENDER_PASSES: &[RenderPassInfo] = &[
|
|||
pass!(SmartCables, "smart-cables", "Handle smart cable layout.", true),
|
||||
];
|
||||
|
||||
pub fn configure(include: &str, exclude: &str) -> Vec<Box<dyn RenderPass>> {
|
||||
pub fn configure(options: &dm::config::MapRenderer, include: &str, exclude: &str) -> Vec<Box<dyn RenderPass>> {
|
||||
let include: Vec<&str> = include.split(",").collect();
|
||||
let exclude: Vec<&str> = exclude.split(",").collect();
|
||||
let include_all = include.iter().any(|&name| name == "all");
|
||||
|
|
@ -130,6 +130,8 @@ pub fn configure(include: &str, exclude: &str) -> Vec<Box<dyn RenderPass>> {
|
|||
true
|
||||
} else if exclude_all {
|
||||
false
|
||||
} else if let Some(&value) = options.render_passes.get(pass.name) {
|
||||
value
|
||||
} else {
|
||||
pass.default
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue