mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 06:55:40 +03:00
Always use ctx.style() to construct buttons. Remove the indirection through app's colorscheme.
This commit is contained in:
parent
ca93d438db
commit
2505d64e8b
@ -63,11 +63,10 @@ impl CutsceneBuilder {
|
||||
pub fn build(
|
||||
self,
|
||||
ctx: &mut EventCtx,
|
||||
app: &App,
|
||||
make_task: Box<dyn Fn(&mut EventCtx) -> Widget>,
|
||||
) -> Box<dyn State<App>> {
|
||||
Box::new(CutscenePlayer {
|
||||
panel: make_panel(ctx, app, &self.name, &self.scenes, &make_task, 0),
|
||||
panel: make_panel(ctx, &self.name, &self.scenes, &make_task, 0),
|
||||
name: self.name,
|
||||
scenes: self.scenes,
|
||||
idx: 0,
|
||||
@ -96,36 +95,18 @@ impl State<App> for CutscenePlayer {
|
||||
}
|
||||
"back" => {
|
||||
self.idx -= 1;
|
||||
self.panel = make_panel(
|
||||
ctx,
|
||||
app,
|
||||
&self.name,
|
||||
&self.scenes,
|
||||
&self.make_task,
|
||||
self.idx,
|
||||
);
|
||||
self.panel =
|
||||
make_panel(ctx, &self.name, &self.scenes, &self.make_task, self.idx);
|
||||
}
|
||||
"next" => {
|
||||
self.idx += 1;
|
||||
self.panel = make_panel(
|
||||
ctx,
|
||||
app,
|
||||
&self.name,
|
||||
&self.scenes,
|
||||
&self.make_task,
|
||||
self.idx,
|
||||
);
|
||||
self.panel =
|
||||
make_panel(ctx, &self.name, &self.scenes, &self.make_task, self.idx);
|
||||
}
|
||||
"Skip cutscene" => {
|
||||
self.idx = self.scenes.len();
|
||||
self.panel = make_panel(
|
||||
ctx,
|
||||
app,
|
||||
&self.name,
|
||||
&self.scenes,
|
||||
&self.make_task,
|
||||
self.idx,
|
||||
);
|
||||
self.panel =
|
||||
make_panel(ctx, &self.name, &self.scenes, &self.make_task, self.idx);
|
||||
}
|
||||
"Start" => {
|
||||
return Transition::Pop;
|
||||
@ -136,14 +117,7 @@ impl State<App> for CutscenePlayer {
|
||||
}
|
||||
// TODO Should the Panel for text widgets with wrapping do this instead?
|
||||
if ctx.input.is_window_resized() {
|
||||
self.panel = make_panel(
|
||||
ctx,
|
||||
app,
|
||||
&self.name,
|
||||
&self.scenes,
|
||||
&self.make_task,
|
||||
self.idx,
|
||||
);
|
||||
self.panel = make_panel(ctx, &self.name, &self.scenes, &self.make_task, self.idx);
|
||||
}
|
||||
|
||||
Transition::Keep
|
||||
@ -162,14 +136,13 @@ impl State<App> for CutscenePlayer {
|
||||
|
||||
fn make_panel(
|
||||
ctx: &mut EventCtx,
|
||||
app: &App,
|
||||
name: &str,
|
||||
scenes: &Vec<Scene>,
|
||||
make_task: &Box<dyn Fn(&mut EventCtx) -> Widget>,
|
||||
idx: usize,
|
||||
) -> Panel {
|
||||
let prev = app
|
||||
.cs
|
||||
let prev = ctx
|
||||
.style()
|
||||
.btn_plain_dark_icon("system/assets/tools/circled_prev.svg")
|
||||
.image_dims(45.0)
|
||||
.hotkey(Key::LeftArrow)
|
||||
@ -177,8 +150,8 @@ fn make_panel(
|
||||
.disabled(idx == 0)
|
||||
.build_widget(ctx, "back");
|
||||
|
||||
let next = app
|
||||
.cs
|
||||
let next = ctx
|
||||
.style()
|
||||
.btn_plain_dark_icon("system/assets/tools/circled_next.svg")
|
||||
.image_dims(45.0)
|
||||
.hotkey(hotkeys(vec![Key::RightArrow, Key::Space, Key::Enter]))
|
||||
@ -187,7 +160,7 @@ fn make_panel(
|
||||
let inner = if idx == scenes.len() {
|
||||
Widget::custom_col(vec![
|
||||
(make_task)(ctx),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_primary_light_text("Start")
|
||||
.hotkey(Key::Enter)
|
||||
.build_def(ctx)
|
||||
@ -246,7 +219,7 @@ fn make_panel(
|
||||
.margin_above(100),
|
||||
Widget::col(vec![
|
||||
Widget::row(vec![prev.margin_right(40), next]).centered_horiz(),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_secondary_dark_text("Skip cutscene")
|
||||
.build_def(ctx)
|
||||
.centered_horiz(),
|
||||
@ -258,7 +231,7 @@ fn make_panel(
|
||||
let col = vec![
|
||||
// TODO Can't get this to alignment to work
|
||||
Widget::custom_row(vec![
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_back_light("Home")
|
||||
.build_widget(ctx, "quit")
|
||||
.margin_right(100),
|
||||
|
@ -1,8 +1,7 @@
|
||||
use map_gui::theme::StyledButtons;
|
||||
use map_gui::tools::{MinimapControls, Navigator};
|
||||
use widgetry::{
|
||||
ControlState, EventCtx, GfxCtx, HorizontalAlignment, Key, Panel, ScreenDims, VerticalAlignment,
|
||||
Widget,
|
||||
ControlState, EventCtx, GfxCtx, HorizontalAlignment, Key, Panel, ScreenDims, StyledButtons,
|
||||
VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
use crate::app::App;
|
||||
@ -98,8 +97,8 @@ impl MinimapControls<App> for MinimapController {
|
||||
}
|
||||
|
||||
fn make_tool_panel(ctx: &mut EventCtx, app: &App) -> Widget {
|
||||
let buttons = app
|
||||
.cs
|
||||
let buttons = ctx
|
||||
.style()
|
||||
.btn_primary_light()
|
||||
.image_dims(ScreenDims::square(20.0))
|
||||
// the default transparent button background is jarring for these buttons which are floating
|
||||
|
@ -6,7 +6,8 @@ use map_model::{IntersectionID, Map, RoadID};
|
||||
use sim::{AgentType, TripMode, TripPhaseType};
|
||||
use widgetry::{
|
||||
lctrl, Checkbox, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Panel,
|
||||
ScreenDims, ScreenPt, ScreenRectangle, Text, TextSpan, VerticalAlignment, Widget,
|
||||
ScreenDims, ScreenPt, ScreenRectangle, StyledButtons, Text, TextSpan, VerticalAlignment,
|
||||
Widget,
|
||||
};
|
||||
|
||||
pub use self::minimap::MinimapController;
|
||||
@ -14,7 +15,6 @@ pub use self::warp::Warping;
|
||||
use crate::app::App;
|
||||
use crate::app::Transition;
|
||||
use crate::info::{ContextualActions, InfoPanel, Tab};
|
||||
use map_gui::theme::StyledButtons;
|
||||
|
||||
mod minimap;
|
||||
mod warp;
|
||||
@ -289,13 +289,13 @@ impl CommonState {
|
||||
}
|
||||
|
||||
// TODO Kinda misnomer
|
||||
pub fn tool_panel(ctx: &mut EventCtx, app: &App) -> Panel {
|
||||
pub fn tool_panel(ctx: &mut EventCtx) -> Panel {
|
||||
Panel::new(Widget::row(vec![
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_plain_light_icon("system/assets/tools/home.svg")
|
||||
.hotkey(Key::Escape)
|
||||
.build_widget(ctx, "back"),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_plain_light_icon("system/assets/tools/settings.svg")
|
||||
.build_widget(ctx, "settings"),
|
||||
]))
|
||||
|
@ -43,7 +43,7 @@ pub struct DebugMode {
|
||||
}
|
||||
|
||||
impl DebugMode {
|
||||
pub fn new(ctx: &mut EventCtx, app: &App) -> Box<dyn State<App>> {
|
||||
pub fn new(ctx: &mut EventCtx) -> Box<dyn State<App>> {
|
||||
Box::new(DebugMode {
|
||||
panel: Panel::new(Widget::col(vec![
|
||||
Widget::row(vec![
|
||||
@ -122,7 +122,7 @@ impl DebugMode {
|
||||
.aligned(HorizontalAlignment::Right, VerticalAlignment::Top)
|
||||
.build(ctx),
|
||||
common: CommonState::new(),
|
||||
tool_panel: tool_panel(ctx, app),
|
||||
tool_panel: tool_panel(ctx),
|
||||
objects: objects::ObjectDebugger,
|
||||
hidden: HashSet::new(),
|
||||
layers: ShowLayers::new(),
|
||||
|
@ -60,7 +60,7 @@ impl EditMode {
|
||||
let edits = app.primary.map.get_edits();
|
||||
let layer = crate::layer::map::Static::edits(ctx, app);
|
||||
Box::new(EditMode {
|
||||
tool_panel: tool_panel(ctx, app),
|
||||
tool_panel: tool_panel(ctx),
|
||||
top_center: make_topcenter(ctx, app),
|
||||
changelist: make_changelist(ctx, app),
|
||||
orig_edits: edits.clone(),
|
||||
@ -171,7 +171,7 @@ impl State<App> for EditMode {
|
||||
}
|
||||
|
||||
if app.opts.dev && ctx.input.pressed(lctrl(Key::D)) {
|
||||
return Transition::Push(DebugMode::new(ctx, app));
|
||||
return Transition::Push(DebugMode::new(ctx));
|
||||
}
|
||||
|
||||
match self.top_center.event(ctx) {
|
||||
|
@ -199,7 +199,7 @@ fn header(
|
||||
|
||||
rows.push(Widget::row(vec![
|
||||
Line(id.to_string()).small_heading().draw(ctx),
|
||||
header_btns(ctx, app),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
|
||||
rows.push(make_tabs(
|
||||
|
@ -17,7 +17,7 @@ pub fn stop(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusStopID)
|
||||
|
||||
rows.push(Widget::row(vec![
|
||||
Line("Bus stop").small_heading().draw(ctx),
|
||||
header_btns(ctx, app),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
rows.push(Line(&bs.name).draw(ctx));
|
||||
|
||||
@ -152,7 +152,7 @@ fn bus_header(
|
||||
))
|
||||
.small_heading()
|
||||
.draw(ctx),
|
||||
header_btns(ctx, app),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
rows.push(make_tabs(
|
||||
ctx,
|
||||
@ -173,7 +173,7 @@ pub fn route(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusRouteI
|
||||
Line(format!("Route {}", route.short_name))
|
||||
.small_heading()
|
||||
.draw(ctx),
|
||||
header_btns(ctx, app),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
rows.push(
|
||||
Text::from(Line(&route.full_name))
|
||||
|
@ -9,7 +9,7 @@ pub fn area(ctx: &EventCtx, app: &App, _: &mut Details, id: AreaID) -> Vec<Widge
|
||||
|
||||
rows.push(Widget::row(vec![
|
||||
Line(id.to_string()).small_heading().draw(ctx),
|
||||
header_btns(ctx, app),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
|
||||
let area = app.primary.map.get_a(id);
|
||||
|
@ -405,7 +405,7 @@ fn header(
|
||||
};
|
||||
rows.push(Widget::row(vec![
|
||||
Line(label).small_heading().draw(ctx),
|
||||
header_btns(ctx, app),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
|
||||
rows.push(make_tabs(ctx, &mut details.hyperlinks, tab, {
|
||||
|
@ -251,7 +251,7 @@ fn header(ctx: &EventCtx, app: &App, details: &mut Details, id: LaneID, tab: Tab
|
||||
Line(format!("{} #{}", label, id.0))
|
||||
.small_heading()
|
||||
.draw(ctx),
|
||||
header_btns(ctx, app),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
rows.push(format!("@ {}", r.get_name(app.opts.language.as_ref())).draw_text(ctx));
|
||||
|
||||
|
@ -3,7 +3,6 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||
pub use trip::OpenTrip;
|
||||
|
||||
use geom::{Circle, Distance, Time};
|
||||
use map_gui::theme::StyledButtons;
|
||||
use map_gui::tools::open_browser;
|
||||
use map_gui::ID;
|
||||
use map_model::{AreaID, BuildingID, BusRouteID, BusStopID, IntersectionID, LaneID, ParkingLotID};
|
||||
@ -13,7 +12,8 @@ use sim::{
|
||||
};
|
||||
use widgetry::{
|
||||
Checkbox, Color, ControlState, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key,
|
||||
Line, LinePlot, Outcome, Panel, PlotOptions, Series, TextExt, VerticalAlignment, Widget,
|
||||
Line, LinePlot, Outcome, Panel, PlotOptions, Series, StyledButtons, TextExt, VerticalAlignment,
|
||||
Widget,
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
@ -373,8 +373,8 @@ impl InfoPanel {
|
||||
if let Some(id) = maybe_id.clone() {
|
||||
for (key, label) in ctx_actions.actions(app, id) {
|
||||
cached_actions.push(key);
|
||||
let button = app
|
||||
.cs
|
||||
let button = ctx
|
||||
.style()
|
||||
.btn_hotkey_light(&label, key)
|
||||
.build_widget(ctx, &label);
|
||||
col.push(button);
|
||||
@ -723,13 +723,13 @@ fn make_tabs(
|
||||
Widget::custom_row(row).bg(Color::grey(0.8)).margin_vert(16)
|
||||
}
|
||||
|
||||
fn header_btns(ctx: &EventCtx, app: &App) -> Widget {
|
||||
fn header_btns(ctx: &EventCtx) -> Widget {
|
||||
Widget::row(vec![
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_plain_light_icon("system/assets/tools/location.svg")
|
||||
.hotkey(Key::J)
|
||||
.build_widget(ctx, "jump to object"),
|
||||
app.cs.btn_close_widget(ctx),
|
||||
ctx.style().btn_close_widget(ctx),
|
||||
])
|
||||
.align_right()
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use crate::app::App;
|
||||
use crate::info::{header_btns, make_tabs, Details, Tab};
|
||||
|
||||
pub fn info(ctx: &mut EventCtx, app: &App, details: &mut Details, id: ParkingLotID) -> Vec<Widget> {
|
||||
let mut rows = header(ctx, app, details, id, Tab::ParkingLot(id));
|
||||
let mut rows = header(ctx, details, id, Tab::ParkingLot(id));
|
||||
let pl = app.primary.map.get_pl(id);
|
||||
let capacity = pl.capacity();
|
||||
|
||||
@ -64,17 +64,11 @@ pub fn info(ctx: &mut EventCtx, app: &App, details: &mut Details, id: ParkingLot
|
||||
rows
|
||||
}
|
||||
|
||||
fn header(
|
||||
ctx: &EventCtx,
|
||||
app: &App,
|
||||
details: &mut Details,
|
||||
id: ParkingLotID,
|
||||
tab: Tab,
|
||||
) -> Vec<Widget> {
|
||||
fn header(ctx: &EventCtx, details: &mut Details, id: ParkingLotID, tab: Tab) -> Vec<Widget> {
|
||||
vec![
|
||||
Widget::row(vec![
|
||||
Line(id.to_string()).small_heading().draw(ctx),
|
||||
header_btns(ctx, app),
|
||||
header_btns(ctx),
|
||||
]),
|
||||
make_tabs(
|
||||
ctx,
|
||||
|
@ -437,7 +437,7 @@ pub fn crowd(
|
||||
|
||||
rows.push(Widget::row(vec![
|
||||
Line("Pedestrian crowd").small_heading().draw(ctx),
|
||||
header_btns(ctx, app),
|
||||
header_btns(ctx),
|
||||
]));
|
||||
|
||||
for (idx, id) in members.into_iter().enumerate() {
|
||||
@ -487,13 +487,13 @@ pub fn parked_car(
|
||||
// Little indirect, but the handler of this action is actually the ContextualActions
|
||||
// for SandboxMode.
|
||||
if is_paused {
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_plain_light_icon("system/assets/tools/location.svg")
|
||||
.hotkey(Key::F)
|
||||
.build_widget(ctx, "follow (run the simulation)")
|
||||
} else {
|
||||
// TODO Blink
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_plain_light_icon("system/assets/tools/location.svg")
|
||||
.image_color(Color::hex("#7FFA4D"), ControlState::Default)
|
||||
.hotkey(Key::F)
|
||||
@ -611,13 +611,13 @@ fn header(
|
||||
// Little indirect, but the handler of this action is actually the ContextualActions
|
||||
// for SandboxMode.
|
||||
if is_paused {
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_plain_light_icon("system/assets/tools/location.svg")
|
||||
.hotkey(Key::F)
|
||||
.build_widget(ctx, "follow (run the simulation)")
|
||||
} else {
|
||||
// TODO Blink
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_plain_light_icon("system/assets/tools/location.svg")
|
||||
.image_color(Color::hex("#7FFA4D"), ControlState::Default)
|
||||
.hotkey(Key::F)
|
||||
|
@ -92,7 +92,7 @@ impl PickLayer {
|
||||
Some(ref l) => l.name().unwrap_or(""),
|
||||
};
|
||||
let btn = |name: &str, key| {
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_hotkey_light(name, key)
|
||||
.disabled(name == current)
|
||||
.build_widget(ctx, name)
|
||||
|
@ -7,13 +7,12 @@ use rand_xorshift::XorShiftRng;
|
||||
use abstutil::Timer;
|
||||
use geom::{Duration, Line, Percent, Pt2D, Speed};
|
||||
use map_gui::load::MapLoader;
|
||||
use map_gui::theme::StyledButtons;
|
||||
use map_gui::tools::{open_browser, PopupMsg};
|
||||
use map_model::PermanentMapEdits;
|
||||
use sim::{AlertHandler, ScenarioGenerator, Sim, SimOptions};
|
||||
use widgetry::{
|
||||
hotkeys, Color, ContentMode, DrawBaselayer, EdgeInsets, EventCtx, Font, GfxCtx, Key, Line,
|
||||
Outcome, Panel, ScreenDims, State, Text, UpdateType, Widget,
|
||||
Outcome, Panel, ScreenDims, State, StyledButtons, Text, UpdateType, Widget,
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
@ -46,7 +45,7 @@ impl TitleScreen {
|
||||
Widget::draw_svg(ctx, "system/assets/pregame/logo.svg"),
|
||||
// TODO that nicer font
|
||||
// TODO Any key
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_primary_dark_text("Play")
|
||||
.hotkey(hotkeys(vec![Key::Space, Key::Enter]))
|
||||
.build_widget(ctx, "start game"),
|
||||
@ -69,7 +68,7 @@ impl State<App> for TitleScreen {
|
||||
Outcome::Clicked(x) => match x.as_ref() {
|
||||
"start game" => {
|
||||
app.primary.clear_sim();
|
||||
return Transition::Replace(MainMenu::new(ctx, app));
|
||||
return Transition::Replace(MainMenu::new(ctx));
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
@ -91,7 +90,7 @@ pub struct MainMenu {
|
||||
}
|
||||
|
||||
impl MainMenu {
|
||||
pub fn new(ctx: &mut EventCtx, app: &App) -> Box<dyn State<App>> {
|
||||
pub fn new(ctx: &mut EventCtx) -> Box<dyn State<App>> {
|
||||
let col = vec![
|
||||
{
|
||||
let mut txt = Text::from(Line("A/B STREET").display_title());
|
||||
@ -99,8 +98,8 @@ impl MainMenu {
|
||||
txt.draw(ctx).centered_horiz()
|
||||
},
|
||||
Widget::row({
|
||||
let btn_builder = app
|
||||
.cs
|
||||
let btn_builder = ctx
|
||||
.style()
|
||||
.btn_primary_dark()
|
||||
.image_dims(ScreenDims::new(200.0, 100.0))
|
||||
.font_size(40)
|
||||
@ -154,7 +153,7 @@ impl MainMenu {
|
||||
})
|
||||
.centered(),
|
||||
Widget::row(vec![
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_secondary_light_text("Community Proposals")
|
||||
.tooltip({
|
||||
let mut txt = Text::tooltip(ctx, Key::P, "Community Proposals");
|
||||
@ -163,7 +162,7 @@ impl MainMenu {
|
||||
})
|
||||
.hotkey(Key::P)
|
||||
.build_widget(ctx, "Community Proposals"),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_secondary_light_text("Internal Dev Tools")
|
||||
.hotkey(Key::D)
|
||||
.build_widget(ctx, "Internal Dev Tools"),
|
||||
@ -171,8 +170,10 @@ impl MainMenu {
|
||||
.centered(),
|
||||
Widget::col(vec![
|
||||
Widget::row(vec![
|
||||
app.cs.btn_secondary_light_text("About").build_def(ctx),
|
||||
app.cs.btn_secondary_light_text("Feedback").build_def(ctx),
|
||||
ctx.style().btn_secondary_light_text("About").build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_secondary_light_text("Feedback")
|
||||
.build_def(ctx),
|
||||
]),
|
||||
built_info::time().draw(ctx),
|
||||
])
|
||||
@ -253,7 +254,7 @@ struct About {
|
||||
impl About {
|
||||
fn new(ctx: &mut EventCtx, app: &App) -> Box<dyn State<App>> {
|
||||
let col = vec![
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_back_light("Home")
|
||||
.hotkey(Key::Escape)
|
||||
.build_widget(ctx, "back")
|
||||
@ -287,7 +288,7 @@ impl About {
|
||||
.bg(app.cs.panel_bg)
|
||||
.padding(16)
|
||||
},
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_primary_dark_text("See full credits")
|
||||
.build_def(ctx)
|
||||
.centered_horiz(),
|
||||
@ -361,20 +362,20 @@ impl Proposals {
|
||||
|
||||
if edits.proposal_link.is_some() {
|
||||
current_tab.push(
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_primary_dark_text("Read detailed write-up")
|
||||
.build_def(ctx)
|
||||
.margin_below(10),
|
||||
);
|
||||
}
|
||||
current_tab.push(
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_primary_dark_text("Try out this proposal")
|
||||
.build_def(ctx),
|
||||
);
|
||||
|
||||
buttons.push(
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_primary_dark_text(&edits.proposal_description[0])
|
||||
.disabled(true)
|
||||
.build_def(ctx)
|
||||
@ -382,7 +383,7 @@ impl Proposals {
|
||||
);
|
||||
} else {
|
||||
buttons.push(
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_primary_dark_text(&edits.proposal_description[0])
|
||||
.no_tooltip()
|
||||
.build_widget(ctx, &name)
|
||||
@ -411,7 +412,7 @@ impl Proposals {
|
||||
Box::new(Proposals {
|
||||
proposals,
|
||||
panel: Panel::new(Widget::custom_col(vec![
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_back_light("Home")
|
||||
.hotkey(Key::Escape)
|
||||
.build_widget(ctx, "back")
|
||||
|
@ -59,7 +59,7 @@ impl OptimizeCommute {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn cutscene_pt1(ctx: &mut EventCtx, app: &App, mode: &GameplayMode) -> Box<dyn State<App>> {
|
||||
pub fn cutscene_pt1(ctx: &mut EventCtx, _: &App, mode: &GameplayMode) -> Box<dyn State<App>> {
|
||||
CutsceneBuilder::new("Optimize one commute: part 1")
|
||||
.boss("Listen up, I've got a special job for you today.")
|
||||
.player("What is it? The scooter coalition back with demands for more valet parking?")
|
||||
@ -78,10 +78,10 @@ impl OptimizeCommute {
|
||||
"(Somebody's blackmailing the boss. Guess it's time to help this Very Impatient \
|
||||
Person.)",
|
||||
)
|
||||
.build(ctx, app, cutscene_task(mode))
|
||||
.build(ctx, cutscene_task(mode))
|
||||
}
|
||||
|
||||
pub fn cutscene_pt2(ctx: &mut EventCtx, app: &App, mode: &GameplayMode) -> Box<dyn State<App>> {
|
||||
pub fn cutscene_pt2(ctx: &mut EventCtx, _: &App, mode: &GameplayMode) -> Box<dyn State<App>> {
|
||||
// TODO The person chosen for this currently has more of an issue needing PBLs, actually.
|
||||
CutsceneBuilder::new("Optimize one commute: part 2")
|
||||
.boss("I've got another, er, friend who's sick of this parking situation.")
|
||||
@ -99,7 +99,7 @@ impl OptimizeCommute {
|
||||
)
|
||||
.boss("Everyone's calling in favors these days. Just make it happen!")
|
||||
.player("(Too many people have dirt on the boss. Guess we have another VIP to help.)")
|
||||
.build(ctx, app, cutscene_task(mode))
|
||||
.build(ctx, cutscene_task(mode))
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ fn make_meter(
|
||||
Panel::new(Widget::col(vec![
|
||||
Widget::horiz_separator(ctx, 0.2),
|
||||
Widget::row(vec![
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_plain_light_icon("system/assets/tools/location.svg")
|
||||
.build_widget(ctx, "locate VIP"),
|
||||
format!("{}/{} trips done", done, trips).draw_text(ctx),
|
||||
|
@ -38,7 +38,7 @@ impl FixTrafficSignals {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn cutscene_pt1(ctx: &mut EventCtx, app: &App, _: &GameplayMode) -> Box<dyn State<App>> {
|
||||
pub fn cutscene_pt1(ctx: &mut EventCtx, _: &App, _: &GameplayMode) -> Box<dyn State<App>> {
|
||||
CutsceneBuilder::new("Traffic signal survivor")
|
||||
.boss("I hope you've had your coffee. There's a huge mess downtown.")
|
||||
.player("Did two buses get tangled together again?")
|
||||
@ -79,7 +79,7 @@ impl FixTrafficSignals {
|
||||
the worst problems first.",
|
||||
)
|
||||
.player("Sigh... it's going to be a long day.")
|
||||
.build(ctx, app, Box::new(cutscene_pt1_task))
|
||||
.build(ctx, Box::new(cutscene_pt1_task))
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ fn make_meter(ctx: &mut EventCtx, app: &App, worst: Option<(IntersectionID, Dura
|
||||
}),
|
||||
])
|
||||
.draw(ctx),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_plain_light_icon("system/assets/tools/location.svg")
|
||||
.build_widget(ctx, "go to slowest intersection")
|
||||
.align_right(),
|
||||
|
@ -3,7 +3,6 @@ use rand::Rng;
|
||||
|
||||
use abstutil::Timer;
|
||||
use geom::{Distance, Polygon};
|
||||
use map_gui::theme::StyledButtons;
|
||||
use map_gui::tools::{
|
||||
grey_out_map, nice_map_name, open_browser, CityPicker, PopupMsg, PromptInput,
|
||||
};
|
||||
@ -12,7 +11,7 @@ use map_model::{BuildingID, IntersectionID, Position, NORMAL_LANE_THICKNESS};
|
||||
use sim::{IndividTrip, PersonSpec, Scenario, TripEndpoint, TripMode, TripPurpose};
|
||||
use widgetry::{
|
||||
lctrl, Choice, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel,
|
||||
SimpleState, Spinner, State, Text, TextExt, VerticalAlignment, Widget,
|
||||
SimpleState, Spinner, State, StyledButtons, Text, TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
@ -107,26 +106,26 @@ impl GameplayState for Freeform {
|
||||
Line("Sandbox").small_heading().draw(ctx),
|
||||
Widget::vert_separator(ctx, 50.0),
|
||||
"Map:".draw_text(ctx),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_popup_light(nice_map_name(app.primary.map.get_name()))
|
||||
.hotkey(lctrl(Key::L))
|
||||
.build_widget(ctx, "change map"),
|
||||
"Scenario:".draw_text(ctx),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_popup_light("none")
|
||||
.hotkey(Key::S)
|
||||
.build_widget(ctx, "change scenario"),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_secondary_light_icon_text("system/assets/tools/pencil.svg", "Edit map")
|
||||
.hotkey(lctrl(Key::E))
|
||||
.build_widget(ctx, "edit map"),
|
||||
])
|
||||
.centered(),
|
||||
Widget::row(vec![
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_secondary_light_text("Start a new trip")
|
||||
.build_def(ctx),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_secondary_light_text("Record trips as a scenario")
|
||||
.build_def(ctx),
|
||||
])
|
||||
|
@ -348,7 +348,7 @@ impl State<App> for FinalScore {
|
||||
|
||||
if self.chose_next {
|
||||
return Transition::Clear(vec![
|
||||
MainMenu::new(ctx, app),
|
||||
MainMenu::new(ctx),
|
||||
// Constructing the cutscene doesn't require the map/scenario to be loaded.
|
||||
SandboxMode::simple_new(ctx, app, self.next_mode.clone().unwrap()),
|
||||
(Challenge::find(self.next_mode.as_ref().unwrap())
|
||||
@ -358,10 +358,7 @@ impl State<App> for FinalScore {
|
||||
]);
|
||||
}
|
||||
if self.chose_back_to_challenges {
|
||||
return Transition::Clear(vec![
|
||||
MainMenu::new(ctx, app),
|
||||
ChallengesPicker::new(ctx, app),
|
||||
]);
|
||||
return Transition::Clear(vec![MainMenu::new(ctx), ChallengesPicker::new(ctx, app)]);
|
||||
}
|
||||
|
||||
Transition::Keep
|
||||
|
@ -2,12 +2,11 @@ use std::collections::BTreeSet;
|
||||
|
||||
use maplit::btreeset;
|
||||
|
||||
use map_gui::theme::StyledButtons;
|
||||
use map_gui::tools::{grey_out_map, nice_map_name, ChooseSomething, CityPicker, PopupMsg};
|
||||
use sim::{ScenarioModifier, TripMode};
|
||||
use widgetry::{
|
||||
lctrl, Choice, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, Slider,
|
||||
Spinner, State, Text, TextExt, VerticalAlignment, Widget,
|
||||
Spinner, State, StyledButtons, Text, TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
@ -116,16 +115,16 @@ impl GameplayState for PlayScenario {
|
||||
Line("Sandbox").small_heading().draw(ctx),
|
||||
Widget::vert_separator(ctx, 50.0),
|
||||
"Map:".draw_text(ctx),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_popup_light(nice_map_name(app.primary.map.get_name()))
|
||||
.hotkey(lctrl(Key::L))
|
||||
.build_widget(ctx, "change map"),
|
||||
"Scenario:".draw_text(ctx),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_popup_light(&self.scenario_name)
|
||||
.hotkey(Key::S)
|
||||
.build_widget(ctx, "change scenario"),
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_secondary_light_icon_text("system/assets/tools/pencil.svg", "Edit map")
|
||||
.hotkey(lctrl(Key::E))
|
||||
.build_widget(ctx, "edit map"),
|
||||
@ -133,7 +132,7 @@ impl GameplayState for PlayScenario {
|
||||
.centered(),
|
||||
if self.scenario_name != "empty" {
|
||||
Widget::row(vec![
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_primary_light_icon("system/assets/tools/pencil.svg")
|
||||
.build_widget(ctx, "edit traffic patterns")
|
||||
.centered_vert(),
|
||||
|
@ -67,7 +67,7 @@ impl Tutorial {
|
||||
.unwrap_or(TutorialPointer::new(0, 0)),
|
||||
),
|
||||
)),
|
||||
Transition::Push(intro_story(ctx, app)),
|
||||
Transition::Push(intro_story(ctx)),
|
||||
])
|
||||
}
|
||||
|
||||
@ -874,7 +874,7 @@ impl TutorialState {
|
||||
fire_station: app.primary.map.find_b_by_osm_id(bldg(731238736)).unwrap(),
|
||||
};
|
||||
|
||||
let tool_panel = tool_panel(ctx, app);
|
||||
let tool_panel = tool_panel(ctx);
|
||||
let time = TimePanel::new(ctx, app);
|
||||
let speed = SpeedControls::new(ctx, app);
|
||||
let agent_meter = AgentMeter::new(ctx, app);
|
||||
@ -1366,7 +1366,7 @@ pub fn execute(ctx: &mut EventCtx, app: &mut App, id: ID, action: &str) -> Trans
|
||||
Transition::Push(response)
|
||||
}
|
||||
|
||||
fn intro_story(ctx: &mut EventCtx, app: &App) -> Box<dyn State<App>> {
|
||||
fn intro_story(ctx: &mut EventCtx) -> Box<dyn State<App>> {
|
||||
CutsceneBuilder::new("Introduction")
|
||||
.boss(
|
||||
"Argh, the mayor's on my case again about the West Seattle bridge. This day couldn't \
|
||||
@ -1399,7 +1399,6 @@ fn intro_story(ctx: &mut EventCtx, app: &App) -> Box<dyn State<App>> {
|
||||
)
|
||||
.build(
|
||||
ctx,
|
||||
app,
|
||||
Box::new(|ctx| {
|
||||
Text::from(Line("Use the tutorial to learn the basic controls.").fg(Color::BLACK))
|
||||
.draw(ctx)
|
||||
|
@ -7,13 +7,12 @@ use map_gui::colors::ColorSchemeChoice;
|
||||
use map_gui::load::{FileLoader, MapLoader};
|
||||
use map_gui::options::OptionsPanel;
|
||||
use map_gui::render::{unzoomed_agent_radius, UnzoomedAgents};
|
||||
use map_gui::theme::StyledButtons;
|
||||
use map_gui::tools::{ChooseSomething, Minimap, PopupMsg, TurnExplorer};
|
||||
use map_gui::{AppLike, ID};
|
||||
use sim::{Analytics, Scenario};
|
||||
use widgetry::{
|
||||
lctrl, Choice, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome,
|
||||
Panel, State, Text, TextExt, UpdateType, VerticalAlignment, Widget,
|
||||
Panel, State, StyledButtons, Text, TextExt, UpdateType, VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
pub use self::gameplay::{spawn_agents_around, GameplayMode, TutorialPointer, TutorialState};
|
||||
@ -135,7 +134,7 @@ impl State<App> for SandboxMode {
|
||||
|
||||
// Order here is pretty arbitrary
|
||||
if app.opts.dev && ctx.input.pressed(lctrl(Key::D)) {
|
||||
return Transition::Push(DebugMode::new(ctx, app));
|
||||
return Transition::Push(DebugMode::new(ctx));
|
||||
}
|
||||
|
||||
if let Some(ref mut m) = self.controls.minimap {
|
||||
@ -295,7 +294,7 @@ struct BackToMainMenu;
|
||||
impl State<App> for BackToMainMenu {
|
||||
fn event(&mut self, ctx: &mut EventCtx, app: &mut App) -> Transition {
|
||||
app.clear_everything(ctx);
|
||||
Transition::Clear(vec![MainMenu::new(ctx, app)])
|
||||
Transition::Clear(vec![MainMenu::new(ctx)])
|
||||
}
|
||||
|
||||
fn draw(&self, _: &mut GfxCtx, _: &App) {}
|
||||
@ -432,7 +431,7 @@ impl AgentMeter {
|
||||
} else {
|
||||
Widget::nothing()
|
||||
},
|
||||
app.cs
|
||||
ctx.style()
|
||||
.btn_primary_light_icon("system/assets/meters/trip_histogram.svg")
|
||||
.hotkey(Key::Q)
|
||||
.build_widget(ctx, "more data")
|
||||
@ -901,7 +900,7 @@ impl SandboxControls {
|
||||
None
|
||||
},
|
||||
tool_panel: if gameplay.has_tool_panel() {
|
||||
Some(tool_panel(ctx, app))
|
||||
Some(tool_panel(ctx))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
@ -930,7 +929,7 @@ impl SandboxControls {
|
||||
|
||||
fn recreate_panels(&mut self, ctx: &mut EventCtx, app: &App) {
|
||||
if self.tool_panel.is_some() {
|
||||
self.tool_panel = Some(tool_panel(ctx, app));
|
||||
self.tool_panel = Some(tool_panel(ctx));
|
||||
}
|
||||
if let Some(ref mut speed) = self.speed {
|
||||
speed.recreate_panel(ctx, app);
|
||||
|
@ -1,11 +1,11 @@
|
||||
use geom::{Duration, Polygon, Time};
|
||||
use map_gui::theme::StyledButtons;
|
||||
use map_gui::tools::PopupMsg;
|
||||
use map_gui::ID;
|
||||
use sim::AlertLocation;
|
||||
use widgetry::{
|
||||
Choice, Color, ControlState, EdgeInsets, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key,
|
||||
Line, Outcome, Panel, PersistentSplit, ScreenDims, Text, VerticalAlignment, Widget,
|
||||
Line, Outcome, Panel, PersistentSplit, ScreenDims, StyledButtons, Text, VerticalAlignment,
|
||||
Widget,
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
@ -46,8 +46,8 @@ impl SpeedControls {
|
||||
pub fn recreate_panel(&mut self, ctx: &mut EventCtx, app: &App) {
|
||||
let mut row = Vec::new();
|
||||
row.push({
|
||||
let button = app
|
||||
.cs
|
||||
let button = ctx
|
||||
.style()
|
||||
.btn_primary_light_icon("system/assets/speed/triangle.svg")
|
||||
.hotkey(Key::Space);
|
||||
|
||||
@ -75,13 +75,13 @@ impl SpeedControls {
|
||||
txt.extend(Text::tooltip(ctx, Key::LeftArrow, "slow down"));
|
||||
txt.extend(Text::tooltip(ctx, Key::RightArrow, "speed up"));
|
||||
|
||||
let mut triangle_btn = app
|
||||
.cs
|
||||
let mut triangle_btn = ctx
|
||||
.style()
|
||||
.btn_plain_light()
|
||||
.image_path("system/assets/speed/triangle.svg")
|
||||
.image_dims(ScreenDims::new(16.0, 26.0))
|
||||
.bg_color(
|
||||
app.cs.gui_style.btn_primary_light.bg_hover,
|
||||
ctx.style().btn_primary_light.bg_hover,
|
||||
ControlState::Hovered,
|
||||
)
|
||||
.tooltip(txt)
|
||||
@ -101,7 +101,7 @@ impl SpeedControls {
|
||||
|
||||
if self.setting < s {
|
||||
triangle_btn = triangle_btn.image_color(
|
||||
app.cs.gui_style.btn_secondary_light.fg_disabled,
|
||||
ctx.style().btn_secondary_light.fg_disabled,
|
||||
ControlState::Default,
|
||||
)
|
||||
}
|
||||
@ -111,8 +111,8 @@ impl SpeedControls {
|
||||
.collect(),
|
||||
)
|
||||
// Inner buttons, styled as one composite button w/ background/border
|
||||
.bg(app.cs.gui_style.btn_primary_light.bg)
|
||||
.outline(2.0, app.cs.gui_style.btn_primary_light.outline)
|
||||
.bg(ctx.style().btn_primary_light.bg)
|
||||
.outline(2.0, ctx.style().btn_primary_light.outline)
|
||||
.margin_right(16),
|
||||
);
|
||||
|
||||
@ -134,11 +134,11 @@ impl SpeedControls {
|
||||
|
||||
row.push(
|
||||
{
|
||||
let buttons = app
|
||||
.cs
|
||||
let buttons = ctx
|
||||
.style()
|
||||
.btn_plain_light()
|
||||
.bg_color(
|
||||
app.cs.gui_style.btn_primary_light.bg_hover,
|
||||
ctx.style().btn_primary_light.bg_hover,
|
||||
ControlState::Hovered,
|
||||
)
|
||||
.image_dims(ScreenDims::square(20.0));
|
||||
@ -157,8 +157,8 @@ impl SpeedControls {
|
||||
])
|
||||
}
|
||||
// Inner buttons, styled as one composite button w/ background/border
|
||||
.bg(app.cs.gui_style.btn_primary_light.bg)
|
||||
.outline(2.0, app.cs.gui_style.btn_primary_light.outline),
|
||||
.bg(ctx.style().btn_primary_light.bg)
|
||||
.outline(2.0, ctx.style().btn_primary_light.outline),
|
||||
);
|
||||
|
||||
self.panel = Panel::new(Widget::custom_row(row))
|
||||
|
@ -69,7 +69,7 @@ pub struct ColorScheme {
|
||||
pub bottom_bar_id: Color,
|
||||
pub bottom_bar_name: Color,
|
||||
pub fade_map_dark: Color,
|
||||
pub gui_style: Style,
|
||||
gui_style: Style,
|
||||
pub dialog_bg: Color,
|
||||
pub minimap_cursor_border: Color,
|
||||
pub minimap_cursor_bg: Option<Color>,
|
||||
|
@ -22,7 +22,6 @@ pub mod load;
|
||||
pub mod options;
|
||||
pub mod render;
|
||||
mod simple_app;
|
||||
pub mod theme;
|
||||
pub mod tools;
|
||||
|
||||
/// An application wishing to use the tools in this crate has to implement this on the struct that
|
||||
|
@ -1,46 +0,0 @@
|
||||
pub use widgetry::StyledButtons;
|
||||
use widgetry::{ButtonBuilder, Key};
|
||||
|
||||
// This impl just delegates to the underlying impl on self.gui_style so we can more succinctly write
|
||||
// `app.cs.btn_primary_dark()` rather than `app.cs.gui_style.btn_primary_dark()`
|
||||
impl<'a> StyledButtons<'a> for crate::ColorScheme {
|
||||
fn btn_primary_dark(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_primary_dark()
|
||||
}
|
||||
|
||||
fn btn_secondary_dark(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_secondary_dark()
|
||||
}
|
||||
|
||||
fn btn_primary_light(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_primary_light()
|
||||
}
|
||||
|
||||
fn btn_secondary_light(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_secondary_light()
|
||||
}
|
||||
|
||||
fn btn_plain_dark(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_plain_dark()
|
||||
}
|
||||
|
||||
fn btn_plain_light(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_plain_light()
|
||||
}
|
||||
|
||||
fn btn_plain_destructive(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_plain_destructive()
|
||||
}
|
||||
|
||||
fn btn_primary_destructive(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_primary_destructive()
|
||||
}
|
||||
|
||||
fn btn_secondary_destructive(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_secondary_destructive()
|
||||
}
|
||||
|
||||
fn btn_hotkey_light(&self, label: &str, key: Key) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_hotkey_light(label, key)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user