mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
adjust edit overlay color, and add an explicit reset button to edits
This commit is contained in:
parent
718c6a346a
commit
b3028fd69c
@ -939,7 +939,7 @@ impl Overlays {
|
||||
edits.original_intersections.len()
|
||||
)));
|
||||
|
||||
let changed = Color::RED;
|
||||
let changed = Color::CYAN;
|
||||
let mut colorer = Colorer::new(txt, vec![("modified lane/intersection", changed)]);
|
||||
|
||||
for l in edits.original_lts.keys().chain(&edits.reversed_lanes) {
|
||||
|
@ -16,9 +16,9 @@ use crate::render::{DrawIntersection, DrawLane, DrawRoad, MIN_ZOOM_FOR_DETAIL};
|
||||
use crate::sandbox::{GameplayMode, SandboxMode};
|
||||
use abstutil::Timer;
|
||||
use ezgui::{
|
||||
hotkey, lctrl, Btn, Choice, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment,
|
||||
Key, Line, Outcome, RewriteColor, ScreenRectangle, Text, VerticalAlignment, Widget,
|
||||
WrappedWizard,
|
||||
hotkey, lctrl, Btn, Button, Choice, Color, Composite, EventCtx, GeomBatch, GfxCtx,
|
||||
HorizontalAlignment, Key, Line, Outcome, RewriteColor, ScreenRectangle, Text,
|
||||
VerticalAlignment, Widget, WrappedWizard,
|
||||
};
|
||||
use geom::Polygon;
|
||||
use map_model::{
|
||||
@ -135,6 +135,13 @@ impl State for EditMode {
|
||||
Some(Transition::Pop)
|
||||
})));
|
||||
}
|
||||
"reset edits" => {
|
||||
if app.primary.map.get_edits().edits_name != "untitled edits" {
|
||||
// Autosave, then cut over to blank edits.
|
||||
app.primary.map.save_edits();
|
||||
}
|
||||
apply_map_edits(ctx, app, MapEdits::new(app.primary.map.get_name()));
|
||||
}
|
||||
"undo" => {
|
||||
let mut edits = app.primary.map.get_edits().clone();
|
||||
let id = match edits.commands.pop().unwrap() {
|
||||
@ -299,7 +306,7 @@ fn make_load_edits(btn: ScreenRectangle, mode: GameplayMode) -> Box<dyn State> {
|
||||
|
||||
// TODO Exclude current
|
||||
let current_edits_name = app.primary.map.get_edits().edits_name.clone();
|
||||
let map_name = app.primary.map.get_name().clone();
|
||||
let map_name = app.primary.map.get_name();
|
||||
let (_, new_edits) = wizard.choose_exact(
|
||||
(
|
||||
HorizontalAlignment::Centered(btn.center().x),
|
||||
@ -317,7 +324,7 @@ fn make_load_edits(btn: ScreenRectangle, mode: GameplayMode) -> Box<dyn State> {
|
||||
);
|
||||
list.push(Choice::new(
|
||||
"start over with blank edits",
|
||||
MapEdits::new(map_name.clone()),
|
||||
MapEdits::new(map_name),
|
||||
));
|
||||
list
|
||||
},
|
||||
@ -363,6 +370,11 @@ fn make_topcenter(ctx: &mut EventCtx, app: &App) -> Composite {
|
||||
)
|
||||
})
|
||||
.margin(15),
|
||||
if !app.primary.map.get_edits().commands.is_empty() {
|
||||
Btn::text_fg("reset edits").build_def(ctx, None).margin(5)
|
||||
} else {
|
||||
Button::inactive_button(ctx, "reset edits").margin(5)
|
||||
},
|
||||
])
|
||||
.centered(),
|
||||
Btn::text_fg("finish editing")
|
||||
|
@ -321,7 +321,7 @@ fn exit_sandbox(wiz: &mut Wizard, ctx: &mut EventCtx, app: &mut App) -> Option<T
|
||||
if resp == "keep playing" {
|
||||
return Some(Transition::Pop);
|
||||
}
|
||||
let map_name = app.primary.map.get_name().to_string();
|
||||
let map_name = app.primary.map.get_name().clone();
|
||||
if resp == "save edits and quit" {
|
||||
save_edits_as(&mut wizard, app)?;
|
||||
}
|
||||
@ -329,7 +329,7 @@ fn exit_sandbox(wiz: &mut Wizard, ctx: &mut EventCtx, app: &mut App) -> Option<T
|
||||
if app.primary.map.get_edits().edits_name != "untitled edits"
|
||||
|| !app.primary.map.get_edits().commands.is_empty()
|
||||
{
|
||||
apply_map_edits(ctx, app, MapEdits::new(map_name));
|
||||
apply_map_edits(ctx, app, MapEdits::new(&map_name));
|
||||
app.primary
|
||||
.map
|
||||
.recalculate_pathfinding_after_edits(&mut timer);
|
||||
@ -337,7 +337,7 @@ fn exit_sandbox(wiz: &mut Wizard, ctx: &mut EventCtx, app: &mut App) -> Option<T
|
||||
app.primary.clear_sim();
|
||||
app.set_prebaked(None);
|
||||
});
|
||||
ctx.canvas.save_camera_state(app.primary.map.get_name());
|
||||
ctx.canvas.save_camera_state(&map_name);
|
||||
Some(Transition::Clear(vec![main_menu(ctx, app)]))
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,9 @@ pub struct EditEffects {
|
||||
}
|
||||
|
||||
impl MapEdits {
|
||||
pub fn new(map_name: String) -> MapEdits {
|
||||
pub fn new(map_name: &str) -> MapEdits {
|
||||
MapEdits {
|
||||
map_name,
|
||||
map_name: map_name.to_string(),
|
||||
// Something has to fill this out later
|
||||
edits_name: "untitled edits".to_string(),
|
||||
proposal_description: Vec::new(),
|
||||
@ -70,7 +70,7 @@ impl MapEdits {
|
||||
|
||||
pub fn load(map_name: &str, edits_name: &str, timer: &mut Timer) -> MapEdits {
|
||||
if edits_name == "untitled edits" {
|
||||
return MapEdits::new(map_name.to_string());
|
||||
return MapEdits::new(map_name);
|
||||
}
|
||||
abstutil::read_json(abstutil::path_edits(map_name, edits_name), timer)
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ impl Map {
|
||||
pathfinder: None,
|
||||
pathfinder_dirty: false,
|
||||
name: "blank".to_string(),
|
||||
edits: MapEdits::new("blank".to_string()),
|
||||
edits: MapEdits::new("blank"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -699,7 +699,7 @@ impl Map {
|
||||
}
|
||||
|
||||
pub fn save_edits(&mut self) {
|
||||
let mut edits = std::mem::replace(&mut self.edits, MapEdits::new(self.name.clone()));
|
||||
let mut edits = std::mem::replace(&mut self.edits, MapEdits::new(&self.name));
|
||||
edits.save(self);
|
||||
self.edits = edits;
|
||||
}
|
||||
@ -825,7 +825,7 @@ fn make_half_map(
|
||||
pathfinder: None,
|
||||
pathfinder_dirty: false,
|
||||
name: raw.name.clone(),
|
||||
edits: MapEdits::new(raw.name.clone()),
|
||||
edits: MapEdits::new(&raw.name),
|
||||
};
|
||||
|
||||
let road_id_mapping: BTreeMap<OriginalRoad, RoadID> = initial_map
|
||||
|
Loading…
Reference in New Issue
Block a user