Refactor and rearrange misc App/PerMap things to prepare for extracting some shared functionality to other crates.

This commit is contained in:
Dustin Carlino 2020-11-22 19:48:09 -08:00
parent f7504bf4d1
commit 67446d32b9
2 changed files with 5 additions and 6 deletions

View File

@ -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 =

View File

@ -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
}