rename the main editor crate to game -- map editing is just a tiny piece ;)

This commit is contained in:
Dustin Carlino 2019-09-07 13:09:09 -07:00
parent 4410c4977b
commit caaf0954ab
79 changed files with 44 additions and 43 deletions

2
.gitignore vendored
View File

@ -4,7 +4,7 @@
data/ab_test_saves/* data/ab_test_saves/*
data/ab_tests/* data/ab_tests/*
data/editor_state/* data/camera_state/*
data/edits/* data/edits/*
data/input/* data/input/*
data/maps/* data/maps/*

View File

@ -3,9 +3,9 @@
members = [ members = [
"abstutil", "abstutil",
"convert_osm", "convert_osm",
"editor",
"ezgui", "ezgui",
"fix_map_geom", "fix_map_geom",
"game",
"geom", "geom",
"gtfs", "gtfs",
"headless", "headless",

View File

@ -84,8 +84,8 @@ pub fn path_raw_map(map_name: &str) -> String {
format!("../data/raw_maps/{}.bin", map_name) format!("../data/raw_maps/{}.bin", map_name)
} }
pub fn path_editor_state(map_name: &str) -> String { pub fn path_camera_state(map_name: &str) -> String {
format!("../data/editor_state/{}.json", map_name) format!("../data/camera_state/{}.json", map_name)
} }
pub fn path_pending_screenshots(map_name: &str) -> String { pub fn path_pending_screenshots(map_name: &str) -> String {

View File

@ -15,6 +15,6 @@ if arg.startswith('http://most/'):
if arg.startswith('http://tail/'): if arg.startswith('http://tail/'):
os.execvp('urxvt', ['urxvt', '-e', 'sh', '-c', 'tail -f ' + arg[len('http://tail/'):]]) os.execvp('urxvt', ['urxvt', '-e', 'sh', '-c', 'tail -f ' + arg[len('http://tail/'):]])
elif arg.startswith('http://ui/'): elif arg.startswith('http://ui/'):
os.execvp('urxvt', ['urxvt', '-e', 'sh', '-c', 'cd ~/abstreet/editor; cargo run ' + arg[len('http://ui/'):]]) os.execvp('urxvt', ['urxvt', '-e', 'sh', '-c', 'cd ~/abstreet/game; cargo run ' + arg[len('http://ui/'):]])
else: else:
os.execvp('xdg-open', ['xdg-open', arg]) os.execvp('xdg-open', ['xdg-open', arg])

View File

@ -35,7 +35,7 @@ If you build from source, you won't have the convenient launcher scripts
referenced below. Instead: referenced below. Instead:
``` ```
cd editor cd game
cargo run --release cargo run --release
``` ```

View File

@ -113,7 +113,7 @@ macro cleverness could avoid this.
No surprises here: compile times suck. It's especially frustrating to add a few No surprises here: compile times suck. It's especially frustrating to add a few
lines to `geom` for debugging (not affecting any of the crate's external APIs), lines to `geom` for debugging (not affecting any of the crate's external APIs),
then wait for the dependent crates `map_model`, `sim`, and `editor` to recompile then wait for the dependent crates `map_model`, `sim`, and `game` to recompile
(or maybe just link again, but it sure is slow). It's also frustrating to (or maybe just link again, but it sure is slow). It's also frustrating to
recompile all dependencies from scratch when I switch between compiling for recompile all dependencies from scratch when I switch between compiling for
Linux and Windows. Linux and Windows.
@ -128,7 +128,7 @@ something awkwardly, but mostly it's forced me to avoid bad ideas.
## Appendix: Code organization ## Appendix: Code organization
If you're going to dig into the code, it helps to know what all the crates are. If you're going to dig into the code, it helps to know what all the crates are.
The most interesting crates are `map_model`, `sim`, and `editor`. The most interesting crates are `map_model`, `sim`, and `game`.
Constructing the map: Constructing the map:
@ -152,7 +152,7 @@ Traffic simulation:
Graphics: Graphics:
- `editor`: the GUI and main gameplay - `game`: the GUI and main gameplay
- `ezgui`: an immediate-mode GUI library - `ezgui`: an immediate-mode GUI library
Common utilities: Common utilities:

View File

@ -164,7 +164,7 @@ do exactly this.
A/B Street imports data from PSRC using the `popdat` crate (the canonically A/B Street imports data from PSRC using the `popdat` crate (the canonically
trendy rendering of "population data"). This is further processed in trendy rendering of "population data"). This is further processed in
`editor/src/mission/trips.rs`. `game/src/mission/trips.rs`.
## Appendix: discrete-time simulation ## Appendix: discrete-time simulation

View File

@ -4,7 +4,8 @@ Find packages to upgrade: `cargo outdated -R`
Deal with compile tile: `cargo bloat --time` Deal with compile tile: `cargo bloat --time`
Find why two binary crates aren't sharing dependencies: https://old.reddit.com/r/rust/comments/cqceu4/common_crates_in_cargo_workspace_recompiled/ Find why two binary crates aren't sharing dependencies:
https://old.reddit.com/r/rust/comments/cqceu4/common_crates_in_cargo_workspace_recompiled/
Where's a dependency coming from? `cargo tree -i -p syn` Where's a dependency coming from? `cargo tree -i -p syn`
@ -13,9 +14,9 @@ Diff screencaps: http://www.imagemagick.org/Usage/compare/#methods
Debug OpenGL calls: Debug OpenGL calls:
``` ```
apitrace trace --api gl ../target/debug/editor ../data/raw_maps/montlake.bin apitrace trace --api gl ../target/debug/game ../data/raw_maps/montlake.bin
qapitrace editor.trace qapitrace game.trace
apitrace dump editor.trace apitrace dump game.trace
``` ```
Understand XML: just use firefox Understand XML: just use firefox
@ -26,10 +27,10 @@ Understand XML: just use firefox
Follow Usage from https://crates.io/crates/cpuprofiler Follow Usage from https://crates.io/crates/cpuprofiler
Run editor or headless with `--enable_profiler` Run game or headless with `--enable_profiler`
``` ```
google-pprof --no_strip_temp ../target/debug/editor profile google-pprof --no_strip_temp ../target/debug/game profile
google-pprof --no_strip_temp ../target/release/headless profile google-pprof --no_strip_temp ../target/release/headless profile
top30 --cum top30 --cum
``` ```
@ -49,8 +50,8 @@ Then:
``` ```
sudo systemctl start docker sudo systemctl start docker
cross build --release --target x86_64-pc-windows-gnu --bin editor cross build --release --target x86_64-pc-windows-gnu --bin game
wine target/x86_64-pc-windows-gnu/release/editor.exe data/maps/montlake.bin wine target/x86_64-pc-windows-gnu/release/game.exe data/maps/montlake.bin
``` ```
## Markdown ## Markdown

View File

@ -20,7 +20,7 @@ cargo run --release -- ../data/raw_maps/your_city.bin
``` ```
You should now be able to load the map using the option from the main game menu, You should now be able to load the map using the option from the main game menu,
or by running `cd editor; cargo run --release ../data/maps/your_city.bin`. or by running `cd game; cargo run --release ../data/maps/your_city.bin`.
## Future work ## Future work

View File

@ -32,7 +32,7 @@
- https://escience.washington.edu/dssg/ - https://escience.washington.edu/dssg/
- josie kresner from transport foundry - josie kresner from transport foundry
- https://www.citylab.com/transportation/2019/08/city-planning-transportation-oakland-community-engagement/596050/ - https://www.citylab.com/transportation/2019/08/city-planning-transportation-oakland-community-engagement/596050/
- tweeting small problems -> bug tracker - tweeting small problems -> bug tracker
- https://www.the74million.org/article/building-a-smarter-and-cheaper-school-bus-system-how-a-boston-mit-partnership-led-to-new-routes-that-are-20-more-efficient-use-400-fewer-buses-save-5-million/ - https://www.the74million.org/article/building-a-smarter-and-cheaper-school-bus-system-how-a-boston-mit-partnership-led-to-new-routes-that-are-20-more-efficient-use-400-fewer-buses-save-5-million/
## Similar projects ## Similar projects

View File

@ -1,5 +1,5 @@
[package] [package]
name = "editor" name = "game"
version = "0.1.0" version = "0.1.0"
authors = ["Dustin Carlino <dabreegster@gmail.com>"] authors = ["Dustin Carlino <dabreegster@gmail.com>"]
edition = "2018" edition = "2018"

View File

@ -144,11 +144,11 @@ impl GUI for Game {
println!("Secondary sim:"); println!("Secondary sim:");
s.sim.dump_before_abort(); s.sim.dump_before_abort();
} }
self.ui.save_editor_state(canvas); self.ui.save_camera_state(canvas);
} }
fn before_quit(&self, canvas: &Canvas) { fn before_quit(&self, canvas: &Canvas) {
self.ui.save_editor_state(canvas); self.ui.save_camera_state(canvas);
self.ui.cs.save(); self.ui.cs.save();
println!("Saved data/color_scheme.json"); println!("Saved data/color_scheme.json");
} }

View File

@ -166,7 +166,7 @@ fn splash_screen(
.filter(|n| n != current_map) .filter(|n| n != current_map)
.collect() .collect()
}) { }) {
ui.save_editor_state(ctx.canvas); ui.save_camera_state(ctx.canvas);
// This retains no state, but that's probably fine. // This retains no state, but that's probably fine.
let mut flags = ui.primary.current_flags.clone(); let mut flags = ui.primary.current_flags.clone();
flags.sim_flags.load = PathBuf::from(abstutil::path_map(&name)); flags.sim_flags.load = PathBuf::from(abstutil::path_map(&name));

View File

@ -46,8 +46,8 @@ impl UI {
if splash { if splash {
ctx.canvas.center_on_map_pt(rand_focus_pt); ctx.canvas.center_on_map_pt(rand_focus_pt);
} else { } else {
let path = abstutil::path_editor_state(primary.map.get_name()); let path = abstutil::path_camera_state(primary.map.get_name());
match abstutil::read_json::<EditorState>(&path) { match abstutil::read_json::<CameraState>(&path) {
Ok(ref loaded) => { Ok(ref loaded) => {
println!("Loaded {}", path); println!("Loaded {}", path);
ctx.canvas.cam_x = loaded.cam_x; ctx.canvas.cam_x = loaded.cam_x;
@ -350,21 +350,21 @@ impl UI {
borrows borrows
} }
pub fn save_editor_state(&self, canvas: &Canvas) { pub fn save_camera_state(&self, canvas: &Canvas) {
let state = EditorState { let state = CameraState {
map_name: self.primary.map.get_name().clone(), map_name: self.primary.map.get_name().clone(),
cam_x: canvas.cam_x, cam_x: canvas.cam_x,
cam_y: canvas.cam_y, cam_y: canvas.cam_y,
cam_zoom: canvas.cam_zoom, cam_zoom: canvas.cam_zoom,
}; };
let path = abstutil::path_editor_state(&state.map_name); let path = abstutil::path_camera_state(&state.map_name);
abstutil::write_json(&path, &state).unwrap(); abstutil::write_json(&path, &state).unwrap();
println!("Saved {}", path); println!("Saved {}", path);
} }
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
struct EditorState { struct CameraState {
pub map_name: String, pub map_name: String,
pub cam_x: f64, pub cam_x: f64,
pub cam_y: f64, pub cam_y: f64,
@ -423,7 +423,7 @@ impl ShowObject for ShowEverything {
} }
#[derive(StructOpt, Debug, Clone)] #[derive(StructOpt, Debug, Clone)]
#[structopt(name = "editor")] #[structopt(name = "game")]
pub struct Flags { pub struct Flags {
#[structopt(flatten)] #[structopt(flatten)]
pub sim_flags: SimFlags, pub sim_flags: SimFlags,

View File

@ -345,7 +345,7 @@ pub fn trips_to_scenario(map: &Map, t1: Duration, t2: Duration, timer: &mut Time
.flatten() .flatten()
.collect(); .collect();
// This is another variation of the 'recycle' algorithm in editor's ScenarioManager. // This is another variation of the 'recycle' algorithm in game's ScenarioManager.
let mut individ_parked_cars = BTreeMap::new(); let mut individ_parked_cars = BTreeMap::new();
let mut avail_per_bldg = BTreeMap::new(); let mut avail_per_bldg = BTreeMap::new();
for b in map.all_buildings() { for b in map.all_buildings() {

View File

@ -13,9 +13,9 @@ common_release $OUT
cp release/play_abstreet.sh $OUT cp release/play_abstreet.sh $OUT
mkdir $OUT/editor mkdir $OUT/game
cargo build --release --bin editor cargo build --release --bin game
cp target/release/editor $OUT/editor cp target/release/game $OUT/game
zip -r $OUT $OUT zip -r $OUT $OUT
rm -rf $OUT rm -rf $OUT

View File

@ -1,2 +1,2 @@
cd editor cd game
editor.exe > ..\\output.txt game.exe > ..\\output.txt

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
cd editor cd game
./editor ./game

View File

@ -10,9 +10,9 @@ common_release $OUT
cp release/play_abstreet.bat $OUT cp release/play_abstreet.bat $OUT
mkdir $OUT/editor mkdir $OUT/game
cross build --release --target x86_64-pc-windows-gnu --bin editor cross build --release --target x86_64-pc-windows-gnu --bin game
cp target/x86_64-pc-windows-gnu/release/editor.exe $OUT/editor cp target/x86_64-pc-windows-gnu/release/game.exe $OUT/game
zip -r $OUT $OUT zip -r $OUT $OUT
rm -rf $OUT rm -rf $OUT

View File

@ -2,7 +2,7 @@ use crate::{CarID, PedestrianID, VehicleType};
use geom::{Angle, Distance, Duration, PolyLine, Pt2D}; use geom::{Angle, Distance, Duration, PolyLine, Pt2D};
use map_model::{Map, Traversable, TurnID}; use map_model::{Map, Traversable, TurnID};
// Intermediate structures so that sim and editor crates don't have a cyclic dependency. // Intermediate structures so that sim and game crates don't have a cyclic dependency.
#[derive(Clone)] #[derive(Clone)]
pub struct DrawPedestrianInput { pub struct DrawPedestrianInput {
pub id: PedestrianID, pub id: PedestrianID,