Skip to content

Commit

Permalink
fix: create asset directories if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
alicja-januszkiewicz committed Mar 24, 2024
1 parent 098ed69 commit c824936
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ pub fn poll_map_editor_inputs(editor: &mut Editor, layout: &mut Layout<f32>) ->
}

if is_key_down(KeyCode::F5) {
std::fs::create_dir_all("assets/scenarios");
editor.to_json("assets/scenarios/quicksave.json");
}
if is_key_down(KeyCode::F9) {
std::fs::create_dir_all("assets/scenarios");
*editor = Editor::from_json("assets/scenarios/quicksave.json");
}

Expand Down Expand Up @@ -112,9 +114,11 @@ pub fn poll_inputs(game: &mut Game, layout: &mut Layout<f32>) -> bool {

if is_key_down(KeyCode::F5) {
//save_map(&game.world.world, "assets/saves/quicksave.json");
std::fs::create_dir_all("assets/saves");
game.to_json("assets/saves/quicksave.json");
}
if is_key_down(KeyCode::F9) {
std::fs::create_dir_all("assets/saves");
*game = Game::from_json("assets/saves/quicksave.json");
}

Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ async fn load_assets() -> Assets {
//let v: serde_json::Value = serde_json::from_str(data).unwrap();
// let shape: Vec<(f32, f32)> = serde_json::from_str(data).unwrap();
// Open the CSV file
std::fs::create_dir_all("assets/shapes");
shapefiles::extract_vertices("assets/ua_shp/ukr_admbnda_adm0_sspe_20230201.shp", "assets/shapes/ua-100k_v2.csv");
let file = File::open("assets/shapes/ua-100k_v2.csv").unwrap();
let mut rdr = csv::Reader::from_reader(file);
Expand Down

0 comments on commit c824936

Please sign in to comment.