mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 19:27:11 +03:00
round of quick fixes to avoid crashes
This commit is contained in:
parent
606325ac77
commit
b033c4f720
@ -4,7 +4,8 @@ use crate::pregame::TitleScreen;
|
||||
use crate::render::DrawOptions;
|
||||
use crate::sandbox::{GameplayMode, SandboxMode};
|
||||
use crate::ui::{Flags, ShowEverything, UI};
|
||||
use ezgui::{Canvas, Color, Drawable, EventCtx, EventLoopMode, GfxCtx, Wizard, GUI};
|
||||
use abstutil::Timer;
|
||||
use ezgui::{Canvas, Color, Drawable, EventCtx, EventLoopMode, GfxCtx, TextureType, Wizard, GUI};
|
||||
use geom::Polygon;
|
||||
|
||||
// This is the top-level of the GUI logic. This module should just manage interactions between the
|
||||
@ -21,6 +22,13 @@ impl Game {
|
||||
&& !flags.sim_flags.load.contains("data/player/save")
|
||||
&& !flags.sim_flags.load.contains("data/system/scenarios")
|
||||
&& mode == GameplayMode::Freeform;
|
||||
ctx.set_textures(
|
||||
vec![
|
||||
("assets/pregame/challenges.png", TextureType::Stretch),
|
||||
("assets/pregame/logo.png", TextureType::Stretch),
|
||||
],
|
||||
&mut Timer::new("load textures"),
|
||||
);
|
||||
let mut ui = UI::new(flags, opts, ctx, title);
|
||||
let states: Vec<Box<dyn State>> = if title {
|
||||
vec![Box::new(TitleScreen::new(ctx, &ui))]
|
||||
|
@ -382,7 +382,7 @@ impl TimePanel {
|
||||
ctx,
|
||||
Text::from(Line(ui.primary.sim.time().ampm_tostring()).size(30)),
|
||||
)
|
||||
.padding(10)
|
||||
.margin(10)
|
||||
.centered_horiz(),
|
||||
{
|
||||
let mut batch = GeomBatch::new();
|
||||
|
@ -7,7 +7,7 @@ use crate::render::{
|
||||
};
|
||||
use crate::sandbox::TutorialState;
|
||||
use abstutil::{MeasureMemory, Timer};
|
||||
use ezgui::{Color, EventCtx, GfxCtx, Prerender, TextureType};
|
||||
use ezgui::{Color, EventCtx, GfxCtx, Prerender};
|
||||
use geom::{Bounds, Circle, Distance, Pt2D};
|
||||
use map_model::{Map, Traversable};
|
||||
use rand::seq::SliceRandom;
|
||||
@ -37,14 +37,6 @@ impl UI {
|
||||
pub fn new(flags: Flags, opts: Options, ctx: &mut EventCtx, splash: bool) -> UI {
|
||||
let cs = ColorScheme::load(opts.color_scheme.clone());
|
||||
let primary = ctx.loading_screen("load map", |ctx, mut timer| {
|
||||
ctx.set_textures(
|
||||
vec![
|
||||
("assets/pregame/challenges.png", TextureType::Stretch),
|
||||
("assets/pregame/logo.png", TextureType::Stretch),
|
||||
],
|
||||
&mut timer,
|
||||
);
|
||||
|
||||
PerMapUI::new(flags, &cs, ctx, &mut timer)
|
||||
});
|
||||
|
||||
|
@ -242,15 +242,17 @@ impl Router {
|
||||
Goal::BikeThenStop { end_dist } => {
|
||||
if end_dist == front {
|
||||
let last_lane = self.head().as_lane();
|
||||
Some(ActionAtEnd::StopBiking(
|
||||
SidewalkSpot::bike_rack(
|
||||
map.get_parent(last_lane)
|
||||
.bike_to_sidewalk(last_lane)
|
||||
.unwrap(),
|
||||
map,
|
||||
)
|
||||
.unwrap(),
|
||||
))
|
||||
if let Some(sidewalk) = map.get_parent(last_lane).bike_to_sidewalk(last_lane) {
|
||||
Some(ActionAtEnd::StopBiking(
|
||||
SidewalkSpot::bike_rack(sidewalk, map).unwrap(),
|
||||
))
|
||||
} else {
|
||||
println!(
|
||||
"WARNING: Can't BikeThenStop on {}, because there's no sidewalk",
|
||||
last_lane
|
||||
);
|
||||
Some(ActionAtEnd::AbortTrip)
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user