mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
solved the mystery of the spurious recompiles -- editor_state and color_scheme need to live outside the crate root, so modtimes are nice
This commit is contained in:
parent
0bcda36380
commit
92c0af2f41
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,7 +2,7 @@
|
||||
/target/
|
||||
*.swp
|
||||
|
||||
editor/editor_state
|
||||
editor_state
|
||||
|
||||
data/ab_tests/*
|
||||
data/edits/*
|
||||
|
@ -5,13 +5,9 @@ use std::process::Command;
|
||||
fn main() {
|
||||
let output = Path::new(&env::var("OUT_DIR").unwrap()).join("init_colors.rs");
|
||||
|
||||
// TODO Argh, this runs even when nothing in the editor crate has changed! Constant
|
||||
// recompilation. :(
|
||||
assert!(Command::new("/usr/bin/python2")
|
||||
.args(&["extract_colorscheme.py", output.to_str().unwrap()])
|
||||
.status()
|
||||
.unwrap()
|
||||
.success());
|
||||
// TODO Uncomment this to avoid spurious rebuilds, but don't check this in.
|
||||
//println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ struct ModifiedColors {
|
||||
|
||||
impl ColorScheme {
|
||||
pub fn load() -> Result<ColorScheme, Error> {
|
||||
let modified: ModifiedColors = abstutil::read_json("color_scheme")?;
|
||||
let modified: ModifiedColors = abstutil::read_json("../color_scheme")?;
|
||||
let mut map: HashMap<String, Color> = default_colors();
|
||||
for (name, c) in &modified.map {
|
||||
map.insert(name.clone(), *c);
|
||||
@ -28,7 +28,8 @@ impl ColorScheme {
|
||||
}
|
||||
|
||||
pub fn save(&self) {
|
||||
abstutil::write_json("color_scheme", &self.modified).expect("Saving color_scheme failed");
|
||||
abstutil::write_json("../color_scheme", &self.modified)
|
||||
.expect("Saving color_scheme failed");
|
||||
}
|
||||
|
||||
// Get, but specify the default inline. The default is extracted before compilation by a script
|
||||
|
@ -284,7 +284,7 @@ impl<S: UIState> UI<S> {
|
||||
cs: ColorScheme::load().unwrap(),
|
||||
};
|
||||
|
||||
match abstutil::read_json::<EditorState>("editor_state") {
|
||||
match abstutil::read_json::<EditorState>("../editor_state") {
|
||||
Ok(ref state) if ui.state.get_state().primary.map.get_name() == &state.map_name => {
|
||||
info!("Loaded previous editor_state");
|
||||
ui.canvas.cam_x = state.cam_x;
|
||||
@ -360,7 +360,7 @@ impl<S: UIState> UI<S> {
|
||||
cam_zoom: self.canvas.cam_zoom,
|
||||
};
|
||||
// TODO maybe make state line up with the map, so loading from a new map doesn't break
|
||||
abstutil::write_json("editor_state", &state).expect("Saving editor_state failed");
|
||||
abstutil::write_json("../editor_state", &state).expect("Saving editor_state failed");
|
||||
info!("Saved editor_state");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user