mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
Refactor and rearrange misc App/PerMap things to prepare for extracting some shared functionality to other crates.
This commit is contained in:
parent
f7504bf4d1
commit
67446d32b9
@ -35,8 +35,7 @@ pub struct App {
|
||||
|
||||
impl App {
|
||||
pub fn new(flags: Flags, opts: Options, ctx: &mut EventCtx, splash: bool) -> App {
|
||||
let cs = ColorScheme::new(opts.color_scheme);
|
||||
ctx.set_style(cs.gui_style.clone());
|
||||
let cs = ColorScheme::new(ctx, opts.color_scheme);
|
||||
|
||||
let primary = ctx.loading_screen("load map", |ctx, mut timer| {
|
||||
assert!(flags.sim_flags.modifiers.is_empty());
|
||||
@ -429,8 +428,7 @@ impl App {
|
||||
return false;
|
||||
}
|
||||
self.opts.color_scheme = cs;
|
||||
self.cs = ColorScheme::new(self.opts.color_scheme);
|
||||
ctx.set_style(self.cs.gui_style.clone());
|
||||
self.cs = ColorScheme::new(ctx, self.opts.color_scheme);
|
||||
|
||||
ctx.loading_screen("rerendering map colors", |ctx, timer| {
|
||||
self.primary.draw_map =
|
||||
|
@ -1,6 +1,6 @@
|
||||
use map_model::osm::RoadRank;
|
||||
use map_model::LaneType;
|
||||
use widgetry::{Choice, Color, Fill, Style, Texture};
|
||||
use widgetry::{Choice, Color, EventCtx, Fill, Style, Texture};
|
||||
|
||||
use crate::common::ColorScale;
|
||||
use crate::helpers::loading_tips;
|
||||
@ -149,7 +149,7 @@ pub struct ColorScheme {
|
||||
}
|
||||
|
||||
impl ColorScheme {
|
||||
pub fn new(scheme: ColorSchemeChoice) -> ColorScheme {
|
||||
pub fn new(ctx: &mut EventCtx, scheme: ColorSchemeChoice) -> ColorScheme {
|
||||
let mut cs = match scheme {
|
||||
ColorSchemeChoice::Standard => ColorScheme::standard(),
|
||||
ColorSchemeChoice::NightMode => ColorScheme::night_mode(),
|
||||
@ -165,6 +165,7 @@ impl ColorScheme {
|
||||
ColorSchemeChoice::NegativeSpace => ColorScheme::negative_space(),
|
||||
};
|
||||
cs.scheme = scheme;
|
||||
ctx.set_style(cs.gui_style.clone());
|
||||
cs
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user