From 67446d32b902a76b4144b145b4db53c486b4b713 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Sun, 22 Nov 2020 19:48:09 -0800 Subject: [PATCH] Refactor and rearrange misc App/PerMap things to prepare for extracting some shared functionality to other crates. --- game/src/app.rs | 6 ++---- game/src/colors.rs | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/game/src/app.rs b/game/src/app.rs index c2fe361de4..d6e6919453 100644 --- a/game/src/app.rs +++ b/game/src/app.rs @@ -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 = diff --git a/game/src/colors.rs b/game/src/colors.rs index 8e08671920..39cf4a04a6 100644 --- a/game/src/colors.rs +++ b/game/src/colors.rs @@ -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 }