Skip to content

Commit

Permalink
Add map export dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
iMilchshake committed May 4, 2024
1 parent c50b871 commit 48b6604
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::map::Map;
use macroquad::color::Color;
use ndarray::{s, Array2, ShapeBuilder};
use ndarray::{Array2};

/// Allows storing various debug information
#[derive(Debug)]
Expand Down
19 changes: 14 additions & 5 deletions src/editor.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use std::collections::HashMap;




use std::{collections::HashMap, path::PathBuf, str::FromStr};

const STEPS_PER_FRAME: usize = 50;

Expand All @@ -14,6 +10,7 @@ use crate::{
random::Seed,
};
use egui::{epaint::Shadow, Color32, Frame, Margin};
use std::env;

use macroquad::camera::{set_camera, Camera2D};
use macroquad::input::{
Expand Down Expand Up @@ -236,6 +233,18 @@ impl Editor {
}

pub fn handle_user_inputs(&mut self) {
if is_key_pressed(KeyCode::E) {
let cwd = env::current_dir().unwrap();

let initial_path = cwd
.join(self.config.name.clone() + ".json")
.to_string_lossy()
.to_string();
if let Some(path_out) = tinyfiledialogs::save_file_dialog("save map", &initial_path) {
self.gen.map.export(&PathBuf::from_str(&path_out).unwrap());
}
}

if is_key_pressed(KeyCode::R) {
self.zoom = 1.0;
self.offset = Vec2::ZERO;
Expand Down
2 changes: 1 addition & 1 deletion src/rendering.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::debug::DebugLayer;

use crate::{map::BlockType, map::KernelType, position::Position, walker::CuteWalker};
use macroquad::color::colors;
use macroquad::color::Color;
Expand Down
2 changes: 1 addition & 1 deletion src/walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
random::Random,
};

use derivative;


// this walker is indeed very cute
#[derive(Debug)]
Expand Down

0 comments on commit 48b6604

Please sign in to comment.