diff --git a/Cargo.lock b/Cargo.lock
index 5ec8cde9f3..ddfee3d3b5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -345,6 +345,26 @@ dependencies = [
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "clipboard"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "clipboard-win 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "objc_id 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "clipboard-win"
+version = "2.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "cloudabi"
version = "0.0.3"
@@ -946,6 +966,7 @@ dependencies = [
"abstutil 0.1.0",
"built 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"colorous 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"downcast-rs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ezgui 0.1.0",
@@ -2015,6 +2036,24 @@ dependencies = [
"malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "objc-foundation"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "objc_id 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "objc_id"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "once_cell"
version = "1.3.1"
@@ -3663,6 +3702,14 @@ dependencies = [
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "x11-clipboard"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "x11-dl"
version = "2.18.5"
@@ -3674,6 +3721,15 @@ dependencies = [
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "xcb"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "xdg"
version = "2.2.0"
@@ -3762,6 +3818,8 @@ dependencies = [
"checksum cgl 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff"
"checksum chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2"
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
+"checksum clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25a904646c0340239dcf7c51677b33928bf24fdf424b79a57909c0109075b2e7"
+"checksum clipboard-win 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3a093d6fed558e5fe24c3dfc85a68bb68f1c824f440d3ba5aca189e2998786b"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62"
"checksum cocoa 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8f7b6f3f7f4f0b3ec5c5039aaa9e8c3cef97a7a480a400fd62944841314f293d"
@@ -3938,6 +3996,8 @@ dependencies = [
"checksum num_enum_derive 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d"
"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
"checksum objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
+"checksum objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
+"checksum objc_id 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
"checksum once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b"
"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
"checksum openssl 0.10.29 (registry+https://github.com/rust-lang/crates.io-index)" = "cee6d85f4cb4c4f59a6a85d5b68a233d280c82e29e822913b9c8b129fbf20bdd"
@@ -4127,7 +4187,9 @@ dependencies = [
"checksum winit 0.22.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ccbf7ddb6627828eace16cacde80fc6bf4dbb3469f88487262a02cf8e7862"
"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9"
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
+"checksum x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea"
"checksum x11-dl 2.18.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8"
+"checksum xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de"
"checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
"checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2"
"checksum xml-rs 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2bb76e5c421bbbeb8924c60c030331b345555024d56261dae8f3e786ed817c23"
diff --git a/data/system/assets/tools/clipboard.svg b/data/system/assets/tools/clipboard.svg
new file mode 100644
index 0000000000..f12aba58d0
--- /dev/null
+++ b/data/system/assets/tools/clipboard.svg
@@ -0,0 +1,3 @@
+
diff --git a/game/Cargo.toml b/game/Cargo.toml
index dbe072b6f0..b5224a0f73 100644
--- a/game/Cargo.toml
+++ b/game/Cargo.toml
@@ -7,7 +7,7 @@ edition = "2018"
# TODO Can't toggle based on target_arch. https://github.com/rust-lang/cargo/issues/2524
# cargo web start --target wasm32-unknown-unknown --no-default-features --features wasm
[features]
-default = ["built", "ezgui/glium-backend", "reqwest"]
+default = ["built", "clipboard", "ezgui/glium-backend", "reqwest", "webbrowser"]
wasm = ["ezgui/wasm-backend"]
[dependencies]
@@ -15,6 +15,7 @@ aabb-quadtree = "0.1.0"
abstutil = { path = "../abstutil" }
built = { version = "0.4.2", optional = true, features=["chrono"] }
chrono = "0.4.10"
+clipboard = { version = "0.5.0", optional = true }
colorous = "1.0.1"
downcast-rs = "1.1.1"
ezgui = { path = "../ezgui", default-features=false }
@@ -32,7 +33,7 @@ reqwest = { version = "0.10.4", optional = true, default-features=false, feature
serde = "1.0.110"
svg_face = "0.1.2"
sim = { path = "../sim" }
-webbrowser = "0.5.2"
+webbrowser = { version = "0.5.2", optional = true }
xmltree = "0.10.0"
[build-dependencies]
diff --git a/game/src/devtools/mapping.rs b/game/src/devtools/mapping.rs
index ac279abfa3..7eb26959eb 100644
--- a/game/src/devtools/mapping.rs
+++ b/game/src/devtools/mapping.rs
@@ -360,24 +360,30 @@ impl State for ParkingMapper {
if self.selected.is_some() && ctx.input.new_was_pressed(&hotkey(Key::S).unwrap()) {
if let Some(pt) = ctx.canvas.get_cursor_in_map_space() {
if let Some(gps) = pt.to_gps(app.primary.map.get_gps_bounds()) {
- let _ = webbrowser::open(&format!(
- "https://www.bing.com/maps?cp={}~{}&style=x",
- gps.y(),
- gps.x()
- ));
+ #[cfg(not(target_arch = "wasm32"))]
+ {
+ let _ = webbrowser::open(&format!(
+ "https://www.bing.com/maps?cp={}~{}&style=x",
+ gps.y(),
+ gps.x()
+ ));
+ }
}
}
}
if let Some((ref roads, _)) = self.selected {
if ctx.input.new_was_pressed(&hotkey(Key::O).unwrap()) {
- let _ = webbrowser::open(&format!(
- "https://www.openstreetmap.org/way/{}",
- app.primary
- .map
- .get_r(*roads.iter().next().unwrap())
- .orig_id
- .osm_way_id
- ));
+ #[cfg(not(target_arch = "wasm32"))]
+ {
+ let _ = webbrowser::open(&format!(
+ "https://www.openstreetmap.org/way/{}",
+ app.primary
+ .map
+ .get_r(*roads.iter().next().unwrap())
+ .orig_id
+ .osm_way_id
+ ));
+ }
}
}
@@ -448,8 +454,10 @@ impl State for ParkingMapper {
}
#[cfg(target_arch = "wasm32")]
-fn generate_osmc(data: &BTreeMap, timer: &mut Timer) -> Result<(), Box> {
- Err("Woops, mapping mode isn't supported on the web yet".to_string())
+fn generate_osmc(_: &BTreeMap, _: bool, _: &mut Timer) -> Result<(), Box> {
+ Err("Woops, mapping mode isn't supported on the web yet"
+ .to_string()
+ .into())
}
#[cfg(not(target_arch = "wasm32"))]
diff --git a/game/src/info/lane.rs b/game/src/info/lane.rs
index 96c72abda4..3684550e8f 100644
--- a/game/src/info/lane.rs
+++ b/game/src/info/lane.rs
@@ -1,8 +1,8 @@
use crate::app::App;
use crate::info::{header_btns, make_table, make_tabs, throughput, DataOptions, Details, Tab};
use abstutil::prettyprint_usize;
-use ezgui::{EventCtx, Line, LinePlot, PlotOptions, Series, Text, TextExt, Widget};
-use map_model::LaneID;
+use ezgui::{Btn, EventCtx, Line, LinePlot, PlotOptions, Series, Text, TextExt, Widget};
+use map_model::{LaneID, OriginalLane};
pub fn info(ctx: &EventCtx, app: &App, details: &mut Details, id: LaneID) -> Vec {
let mut rows = header(ctx, app, details, id, Tab::LaneInfo(id));
@@ -121,6 +121,17 @@ pub fn debug(ctx: &EventCtx, app: &App, details: &mut Details, id: LaneID) -> Ve
rows.extend(make_table(ctx, kv));
+ rows.push(Widget::row(vec![
+ "Copy OriginalLane to clipboard: "
+ .draw_text(ctx)
+ .margin_right(15),
+ Btn::svg_def("../data/system/assets/tools/clipboard.svg").build(
+ ctx,
+ "copy OriginalLane",
+ None,
+ ),
+ ]));
+
let mut txt = Text::from(Line(""));
txt.add(Line("Raw OpenStreetMap data"));
rows.push(txt.draw(ctx));
@@ -130,6 +141,20 @@ pub fn debug(ctx: &EventCtx, app: &App, details: &mut Details, id: LaneID) -> Ve
rows
}
+pub fn copy_orig_lane(app: &App, id: LaneID) {
+ #[cfg(not(target_arch = "wasm32"))]
+ {
+ use clipboard::{ClipboardContext, ClipboardProvider};
+
+ let mut cb: ClipboardContext = ClipboardProvider::new().unwrap();
+ cb.set_contents(format!(
+ "{:?}",
+ OriginalLane::to_permanent(id, &app.primary.map)
+ ))
+ .unwrap();
+ }
+}
+
pub fn traffic(
ctx: &mut EventCtx,
app: &App,
diff --git a/game/src/info/mod.rs b/game/src/info/mod.rs
index 466f2ff0f4..ba6fd51868 100644
--- a/game/src/info/mod.rs
+++ b/game/src/info/mod.rs
@@ -436,6 +436,16 @@ impl InfoPanel {
},
))),
)
+ } else if action == "copy OriginalLane" {
+ // TODO Not happy about this :(
+ lane::copy_orig_lane(
+ app,
+ match maybe_id {
+ Some(ID::Lane(l)) => l,
+ _ => unreachable!(),
+ },
+ );
+ return (false, None);
} else {
let mut close_panel = true;
let t =
diff --git a/game/src/pregame.rs b/game/src/pregame.rs
index 31e7b5bb19..1731cf694c 100644
--- a/game/src/pregame.rs
+++ b/game/src/pregame.rs
@@ -206,7 +206,11 @@ impl State for MainMenu {
return Transition::Push(About::new(ctx));
}
"Feedback" => {
- let _ = webbrowser::open("https://forms.gle/ocvbek1bTaZUr3k49");
+ // cargo fmt tries to remove this
+ #[cfg(not(target_arch = "wasm32"))]
+ {
+ let _ = webbrowser::open("https://forms.gle/ocvbek1bTaZUr3k49");
+ }
}
"Community Proposals" => {
return Transition::Push(Proposals::new(ctx, app));
@@ -300,7 +304,11 @@ impl State for About {
return Transition::Pop;
}
"See full credits" => {
- let _ = webbrowser::open("https://github.com/dabreegster/abstreet#credits");
+ // cargo fmt tries to remove this
+ #[cfg(not(target_arch = "wasm32"))]
+ {
+ let _ = webbrowser::open("https://github.com/dabreegster/abstreet#credits");
+ }
}
_ => unreachable!(),
},
diff --git a/map_model/src/edits.rs b/map_model/src/edits.rs
index 66e88d0580..9fec7a0a35 100644
--- a/map_model/src/edits.rs
+++ b/map_model/src/edits.rs
@@ -392,7 +392,7 @@ impl PermanentEditIntersection {
}
impl OriginalLane {
- fn to_permanent(l: LaneID, map: &Map) -> OriginalLane {
+ pub fn to_permanent(l: LaneID, map: &Map) -> OriginalLane {
let r = map.get_parent(l);
let (fwd, idx) = r.dir_and_offset(l);
OriginalLane {