environment variable to run specific level

This commit is contained in:
Corwin 2023-08-29 21:11:58 +01:00
parent 56f1b68055
commit 98c96080f9
No known key found for this signature in database

View file

@ -9,6 +9,25 @@ use std::{
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
const LEVEL_NAMES: &[&str] = &[ const LEVEL_NAMES: &[&str] = &[
"level1",
"level2",
"level3",
"level4",
"level5",
"level6",
"level_switch",
"level_spikes",
"level_spikes2",
"level_squid_force_button",
"level_squid_intro",
"level_squid2",
"level_squid1",
"level_squid_item",
"level_squid_button",
"level_squid_drop",
"level_spikes3",
"level_around",
"level_squidprogramming",
"a_familiar_sight", "a_familiar_sight",
"block_push_1", "block_push_1",
"block_push_2", "block_push_2",
@ -23,7 +42,18 @@ fn main() {
let ui_map = load_tmx(&mut tile_loader, "maps/UI.tmx"); let ui_map = load_tmx(&mut tile_loader, "maps/UI.tmx");
let ui_tiles = export_ui_tiles(&ui_map, quote!(ui)); let ui_tiles = export_ui_tiles(&ui_map, quote!(ui));
let levels = LEVEL_NAMES const DPL_LEVELS_ENVIRONMENT_VARIABLE: &str = "DPL_LEVELS";
println!(
"cargo:rerun-if-env-changed={}",
DPL_LEVELS_ENVIRONMENT_VARIABLE
);
let levels: Vec<String> = env::var(DPL_LEVELS_ENVIRONMENT_VARIABLE)
.map(|x| x.split(',').map(|x| x.trim().to_string()).collect())
.unwrap_or(LEVEL_NAMES.iter().map(|x| x.to_string()).collect());
let levels = levels
.iter() .iter()
.map(|level| load_level(&mut tile_loader, &format!("maps/levels/{level}.tmx"))) .map(|level| load_level(&mut tile_loader, &format!("maps/levels/{level}.tmx")))
.collect::<Vec<_>>(); .collect::<Vec<_>>();