mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 15:02:59 +03:00
rename the main editor crate to game -- map editing is just a tiny piece ;)
This commit is contained in:
parent
4410c4977b
commit
caaf0954ab
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
data/ab_test_saves/*
|
||||
data/ab_tests/*
|
||||
data/editor_state/*
|
||||
data/camera_state/*
|
||||
data/edits/*
|
||||
data/input/*
|
||||
data/maps/*
|
||||
|
@ -3,9 +3,9 @@
|
||||
members = [
|
||||
"abstutil",
|
||||
"convert_osm",
|
||||
"editor",
|
||||
"ezgui",
|
||||
"fix_map_geom",
|
||||
"game",
|
||||
"geom",
|
||||
"gtfs",
|
||||
"headless",
|
||||
|
@ -84,8 +84,8 @@ pub fn path_raw_map(map_name: &str) -> String {
|
||||
format!("../data/raw_maps/{}.bin", map_name)
|
||||
}
|
||||
|
||||
pub fn path_editor_state(map_name: &str) -> String {
|
||||
format!("../data/editor_state/{}.json", map_name)
|
||||
pub fn path_camera_state(map_name: &str) -> String {
|
||||
format!("../data/camera_state/{}.json", map_name)
|
||||
}
|
||||
|
||||
pub fn path_pending_screenshots(map_name: &str) -> String {
|
||||
|
@ -15,6 +15,6 @@ if arg.startswith('http://most/'):
|
||||
if arg.startswith('http://tail/'):
|
||||
os.execvp('urxvt', ['urxvt', '-e', 'sh', '-c', 'tail -f ' + arg[len('http://tail/'):]])
|
||||
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:
|
||||
os.execvp('xdg-open', ['xdg-open', arg])
|
||||
|
@ -35,7 +35,7 @@ If you build from source, you won't have the convenient launcher scripts
|
||||
referenced below. Instead:
|
||||
|
||||
```
|
||||
cd editor
|
||||
cd game
|
||||
cargo run --release
|
||||
```
|
||||
|
||||
|
@ -113,7 +113,7 @@ macro cleverness could avoid this.
|
||||
|
||||
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),
|
||||
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
|
||||
recompile all dependencies from scratch when I switch between compiling for
|
||||
Linux and Windows.
|
||||
@ -128,7 +128,7 @@ something awkwardly, but mostly it's forced me to avoid bad ideas.
|
||||
## Appendix: Code organization
|
||||
|
||||
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:
|
||||
|
||||
@ -152,7 +152,7 @@ Traffic simulation:
|
||||
|
||||
Graphics:
|
||||
|
||||
- `editor`: the GUI and main gameplay
|
||||
- `game`: the GUI and main gameplay
|
||||
- `ezgui`: an immediate-mode GUI library
|
||||
|
||||
Common utilities:
|
||||
|
@ -164,7 +164,7 @@ do exactly this.
|
||||
|
||||
A/B Street imports data from PSRC using the `popdat` crate (the canonically
|
||||
trendy rendering of "population data"). This is further processed in
|
||||
`editor/src/mission/trips.rs`.
|
||||
`game/src/mission/trips.rs`.
|
||||
|
||||
## Appendix: discrete-time simulation
|
||||
|
||||
|
@ -4,7 +4,8 @@ Find packages to upgrade: `cargo outdated -R`
|
||||
|
||||
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`
|
||||
|
||||
@ -13,9 +14,9 @@ Diff screencaps: http://www.imagemagick.org/Usage/compare/#methods
|
||||
Debug OpenGL calls:
|
||||
|
||||
```
|
||||
apitrace trace --api gl ../target/debug/editor ../data/raw_maps/montlake.bin
|
||||
qapitrace editor.trace
|
||||
apitrace dump editor.trace
|
||||
apitrace trace --api gl ../target/debug/game ../data/raw_maps/montlake.bin
|
||||
qapitrace game.trace
|
||||
apitrace dump game.trace
|
||||
```
|
||||
|
||||
Understand XML: just use firefox
|
||||
@ -26,10 +27,10 @@ Understand XML: just use firefox
|
||||
|
||||
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
|
||||
top30 --cum
|
||||
```
|
||||
@ -49,8 +50,8 @@ Then:
|
||||
|
||||
```
|
||||
sudo systemctl start docker
|
||||
cross build --release --target x86_64-pc-windows-gnu --bin editor
|
||||
wine target/x86_64-pc-windows-gnu/release/editor.exe data/maps/montlake.bin
|
||||
cross build --release --target x86_64-pc-windows-gnu --bin game
|
||||
wine target/x86_64-pc-windows-gnu/release/game.exe data/maps/montlake.bin
|
||||
```
|
||||
|
||||
## Markdown
|
||||
|
@ -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,
|
||||
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
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "editor"
|
||||
name = "game"
|
||||
version = "0.1.0"
|
||||
authors = ["Dustin Carlino <dabreegster@gmail.com>"]
|
||||
edition = "2018"
|
@ -144,11 +144,11 @@ impl GUI for Game {
|
||||
println!("Secondary sim:");
|
||||
s.sim.dump_before_abort();
|
||||
}
|
||||
self.ui.save_editor_state(canvas);
|
||||
self.ui.save_camera_state(canvas);
|
||||
}
|
||||
|
||||
fn before_quit(&self, canvas: &Canvas) {
|
||||
self.ui.save_editor_state(canvas);
|
||||
self.ui.save_camera_state(canvas);
|
||||
self.ui.cs.save();
|
||||
println!("Saved data/color_scheme.json");
|
||||
}
|
@ -166,7 +166,7 @@ fn splash_screen(
|
||||
.filter(|n| n != current_map)
|
||||
.collect()
|
||||
}) {
|
||||
ui.save_editor_state(ctx.canvas);
|
||||
ui.save_camera_state(ctx.canvas);
|
||||
// This retains no state, but that's probably fine.
|
||||
let mut flags = ui.primary.current_flags.clone();
|
||||
flags.sim_flags.load = PathBuf::from(abstutil::path_map(&name));
|
@ -46,8 +46,8 @@ impl UI {
|
||||
if splash {
|
||||
ctx.canvas.center_on_map_pt(rand_focus_pt);
|
||||
} else {
|
||||
let path = abstutil::path_editor_state(primary.map.get_name());
|
||||
match abstutil::read_json::<EditorState>(&path) {
|
||||
let path = abstutil::path_camera_state(primary.map.get_name());
|
||||
match abstutil::read_json::<CameraState>(&path) {
|
||||
Ok(ref loaded) => {
|
||||
println!("Loaded {}", path);
|
||||
ctx.canvas.cam_x = loaded.cam_x;
|
||||
@ -350,21 +350,21 @@ impl UI {
|
||||
borrows
|
||||
}
|
||||
|
||||
pub fn save_editor_state(&self, canvas: &Canvas) {
|
||||
let state = EditorState {
|
||||
pub fn save_camera_state(&self, canvas: &Canvas) {
|
||||
let state = CameraState {
|
||||
map_name: self.primary.map.get_name().clone(),
|
||||
cam_x: canvas.cam_x,
|
||||
cam_y: canvas.cam_y,
|
||||
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();
|
||||
println!("Saved {}", path);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct EditorState {
|
||||
struct CameraState {
|
||||
pub map_name: String,
|
||||
pub cam_x: f64,
|
||||
pub cam_y: f64,
|
||||
@ -423,7 +423,7 @@ impl ShowObject for ShowEverything {
|
||||
}
|
||||
|
||||
#[derive(StructOpt, Debug, Clone)]
|
||||
#[structopt(name = "editor")]
|
||||
#[structopt(name = "game")]
|
||||
pub struct Flags {
|
||||
#[structopt(flatten)]
|
||||
pub sim_flags: SimFlags,
|
@ -345,7 +345,7 @@ pub fn trips_to_scenario(map: &Map, t1: Duration, t2: Duration, timer: &mut Time
|
||||
.flatten()
|
||||
.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 avail_per_bldg = BTreeMap::new();
|
||||
for b in map.all_buildings() {
|
||||
|
@ -13,9 +13,9 @@ common_release $OUT
|
||||
|
||||
cp release/play_abstreet.sh $OUT
|
||||
|
||||
mkdir $OUT/editor
|
||||
cargo build --release --bin editor
|
||||
cp target/release/editor $OUT/editor
|
||||
mkdir $OUT/game
|
||||
cargo build --release --bin game
|
||||
cp target/release/game $OUT/game
|
||||
|
||||
zip -r $OUT $OUT
|
||||
rm -rf $OUT
|
||||
|
@ -1,2 +1,2 @@
|
||||
cd editor
|
||||
editor.exe > ..\\output.txt
|
||||
cd game
|
||||
game.exe > ..\\output.txt
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd editor
|
||||
./editor
|
||||
cd game
|
||||
./game
|
||||
|
@ -10,9 +10,9 @@ common_release $OUT
|
||||
|
||||
cp release/play_abstreet.bat $OUT
|
||||
|
||||
mkdir $OUT/editor
|
||||
cross build --release --target x86_64-pc-windows-gnu --bin editor
|
||||
cp target/x86_64-pc-windows-gnu/release/editor.exe $OUT/editor
|
||||
mkdir $OUT/game
|
||||
cross build --release --target x86_64-pc-windows-gnu --bin game
|
||||
cp target/x86_64-pc-windows-gnu/release/game.exe $OUT/game
|
||||
|
||||
zip -r $OUT $OUT
|
||||
rm -rf $OUT
|
||||
|
@ -2,7 +2,7 @@ use crate::{CarID, PedestrianID, VehicleType};
|
||||
use geom::{Angle, Distance, Duration, PolyLine, Pt2D};
|
||||
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)]
|
||||
pub struct DrawPedestrianInput {
|
||||
pub id: PedestrianID,
|
||||
|
Loading…
Reference in New Issue
Block a user