mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-26 16:02:23 +03:00
finally get the first community proposal baked in!
This commit is contained in:
parent
39f55c7b8f
commit
5c0c133253
304
data/system/proposals/stay healthy lake wash blvd.json
Normal file
304
data/system/proposals/stay healthy lake wash blvd.json
Normal file
@ -0,0 +1,304 @@
|
||||
{
|
||||
"map_name": "lakeslice",
|
||||
"edits_name": "stay healthy lake wash blvd",
|
||||
"commands": [
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 332355469,
|
||||
"i1": {
|
||||
"osm_node_id": 1726088131
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 53217949
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": true,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 332355469,
|
||||
"i1": {
|
||||
"osm_node_id": 1726088131
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 53217949
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": false,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 337741610,
|
||||
"i1": {
|
||||
"osm_node_id": 491939945
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 3448001552
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": true,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 337741610,
|
||||
"i1": {
|
||||
"osm_node_id": 491939945
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 3448001552
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": false,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 337741611,
|
||||
"i1": {
|
||||
"osm_node_id": 3448001552
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 53143682
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": true,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 337741611,
|
||||
"i1": {
|
||||
"osm_node_id": 3448001552
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 53143682
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": false,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 404136301,
|
||||
"i1": {
|
||||
"osm_node_id": 1724731506
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 4064101356
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": true,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 404136301,
|
||||
"i1": {
|
||||
"osm_node_id": 1724731506
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 4064101356
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": false,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 404136302,
|
||||
"i1": {
|
||||
"osm_node_id": 4064101356
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 491939945
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": true,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 404136302,
|
||||
"i1": {
|
||||
"osm_node_id": 4064101356
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 491939945
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": false,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 537681170,
|
||||
"i1": {
|
||||
"osm_node_id": 53096936
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 1724731506
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": true,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 537681170,
|
||||
"i1": {
|
||||
"osm_node_id": 53096936
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 1724731506
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": false,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 537681170,
|
||||
"i1": {
|
||||
"osm_node_id": 53217949
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 53096936
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": true,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ChangeLaneType": {
|
||||
"id": {
|
||||
"parent": {
|
||||
"osm_way_id": 537681170,
|
||||
"i1": {
|
||||
"osm_node_id": 53217949
|
||||
},
|
||||
"i2": {
|
||||
"osm_node_id": 53096936
|
||||
}
|
||||
},
|
||||
"num_fwd": 2,
|
||||
"num_back": 2,
|
||||
"fwd": false,
|
||||
"idx": 0
|
||||
},
|
||||
"lt": "Biking",
|
||||
"orig_lt": "Driving"
|
||||
}
|
||||
}
|
||||
],
|
||||
"proposal_description": [
|
||||
"Convert Lake Washington Blvd to a Stay Healthy Street",
|
||||
"No vehicle access north of Madison"
|
||||
]
|
||||
}
|
@ -141,9 +141,6 @@ impl Btn {
|
||||
let label = label.into();
|
||||
BtnBuilder::TextFG(label.clone(), Text::from(Line(label)), None)
|
||||
}
|
||||
pub fn custom_text_fg(normal: Text) -> BtnBuilder {
|
||||
BtnBuilder::TextFG(String::new(), normal, None)
|
||||
}
|
||||
|
||||
pub fn text_bg<I: Into<String>>(
|
||||
label: I,
|
||||
@ -429,7 +426,7 @@ impl BtnBuilder {
|
||||
pub fn inactive(mut self, ctx: &EventCtx) -> Widget {
|
||||
match self {
|
||||
BtnBuilder::TextFG(_, txt, _) => {
|
||||
let btn = Btn::custom_text_fg(txt.change_fg(Color::grey(0.5)))
|
||||
let btn = BtnBuilder::TextFG(String::new(), txt.change_fg(Color::grey(0.5)), None)
|
||||
.build(ctx, "dummy", None)
|
||||
.take_btn();
|
||||
Widget::new(Box::new(JustDraw {
|
||||
|
@ -1,7 +1,8 @@
|
||||
use crate::app::App;
|
||||
use crate::challenges::challenges_picker;
|
||||
use crate::devtools::DevToolsMode;
|
||||
use crate::game::{State, Transition};
|
||||
use crate::edit::apply_map_edits;
|
||||
use crate::game::{msg, State, Transition};
|
||||
use crate::managed::{Callback, ManagedGUIState, WrappedComposite, WrappedOutcome};
|
||||
use crate::sandbox::{GameplayMode, SandboxMode, TutorialPointer};
|
||||
use ezgui::{
|
||||
@ -264,34 +265,55 @@ fn about(ctx: &mut EventCtx) -> Box<dyn State> {
|
||||
fn proposals_picker(ctx: &mut EventCtx, app: &App) -> Box<dyn State> {
|
||||
let mut cbs: Vec<(String, Callback)> = Vec::new();
|
||||
let mut buttons: Vec<Widget> = Vec::new();
|
||||
for map_name in abstutil::list_all_objects(abstutil::path_all_maps()) {
|
||||
for (_, edits) in
|
||||
abstutil::load_all_objects::<PermanentMapEdits>(abstutil::path_all_edits(&map_name))
|
||||
{
|
||||
if !edits.proposal_description.is_empty() {
|
||||
let mut txt = Text::new();
|
||||
for l in &edits.proposal_description {
|
||||
txt.add(Line(l));
|
||||
}
|
||||
let path = abstutil::path_edits(&map_name, &edits.edits_name);
|
||||
buttons.push(Btn::custom_text_fg(txt).build(ctx, &path, None));
|
||||
let map_name = map_name.clone();
|
||||
cbs.push((
|
||||
path,
|
||||
Box::new(move |ctx, app| {
|
||||
// TODO apply edits
|
||||
Some(Transition::Push(Box::new(SandboxMode::new(
|
||||
ctx,
|
||||
app,
|
||||
GameplayMode::PlayScenario(
|
||||
abstutil::path_map(&map_name),
|
||||
"weekday".to_string(),
|
||||
),
|
||||
))))
|
||||
}),
|
||||
));
|
||||
}
|
||||
for (name, edits) in
|
||||
abstutil::load_all_objects::<PermanentMapEdits>("../data/system/proposals".to_string())
|
||||
{
|
||||
let mut txt = Text::new();
|
||||
txt.add(Line(&edits.proposal_description[0]));
|
||||
for l in edits.proposal_description.iter().skip(1) {
|
||||
txt.add(Line(l).secondary());
|
||||
}
|
||||
let path = format!("../data/system/proposals/{}.json", name);
|
||||
buttons.push(
|
||||
Btn::text_bg(&path, txt, app.cs.section_bg, app.cs.hovering)
|
||||
.tooltip(Text::new())
|
||||
.build_def(ctx, None),
|
||||
);
|
||||
cbs.push((
|
||||
path,
|
||||
Box::new(move |ctx, app| {
|
||||
// Apply edits before setting up the sandbox, for simplicity
|
||||
let map_name = edits.map_name.clone();
|
||||
let edits = edits.clone();
|
||||
let maybe_err = ctx.loading_screen("apply edits", |ctx, mut timer| {
|
||||
if &edits.map_name != app.primary.map.get_name() {
|
||||
app.switch_map(ctx, abstutil::path_map(&edits.map_name));
|
||||
}
|
||||
match PermanentMapEdits::from_permanent(edits, &app.primary.map) {
|
||||
Ok(edits) => {
|
||||
apply_map_edits(ctx, app, edits);
|
||||
app.primary
|
||||
.map
|
||||
.recalculate_pathfinding_after_edits(&mut timer);
|
||||
None
|
||||
}
|
||||
Err(err) => Some(err),
|
||||
}
|
||||
});
|
||||
if let Some(err) = maybe_err {
|
||||
Some(Transition::Push(msg("Can't load proposal", vec![err])))
|
||||
} else {
|
||||
Some(Transition::Push(Box::new(SandboxMode::new(
|
||||
ctx,
|
||||
app,
|
||||
GameplayMode::PlayScenario(
|
||||
abstutil::path_map(&map_name),
|
||||
"weekday".to_string(),
|
||||
),
|
||||
))))
|
||||
}
|
||||
}),
|
||||
));
|
||||
}
|
||||
|
||||
let mut c = WrappedComposite::new(
|
||||
|
@ -192,8 +192,9 @@ impl EditEffects {
|
||||
// These mirror the above, except they use permanent IDs that have a better chance of surviving
|
||||
// basemap updates over time.
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct PermanentMapEdits {
|
||||
pub map_name: String,
|
||||
pub edits_name: String,
|
||||
commands: Vec<PermanentEditCmd>,
|
||||
|
||||
@ -201,7 +202,7 @@ pub struct PermanentMapEdits {
|
||||
pub proposal_description: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
enum PermanentEditIntersection {
|
||||
StopSign {
|
||||
#[serde(
|
||||
@ -224,7 +225,7 @@ struct OriginalLane {
|
||||
idx: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
enum PermanentEditCmd {
|
||||
ChangeLaneType {
|
||||
id: OriginalLane,
|
||||
@ -251,6 +252,7 @@ enum PermanentEditCmd {
|
||||
impl PermanentMapEdits {
|
||||
fn to_permanent(edits: &MapEdits, map: &Map) -> PermanentMapEdits {
|
||||
PermanentMapEdits {
|
||||
map_name: map.get_name().to_string(),
|
||||
edits_name: edits.edits_name.clone(),
|
||||
proposal_description: edits.proposal_description.clone(),
|
||||
commands: edits
|
||||
|
Loading…
Reference in New Issue
Block a user