no more prompt in some of the popups, adjust the menu coloring, cancel

popups by clicking on the map
This commit is contained in:
Dustin Carlino 2020-02-04 13:41:09 -08:00
parent 7f82241ed9
commit b0a56abb6e
4 changed files with 23 additions and 13 deletions

View File

@ -9,7 +9,7 @@ use textwrap;
const FG_COLOR: Color = Color::WHITE;
pub const BG_COLOR: Color = Color::grey(0.3);
pub const PROMPT_COLOR: Color = Color::BLUE;
pub const SELECTED_COLOR: Color = Color::RED;
pub const SELECTED_COLOR: Color = Color::grey(0.5);
pub const HOTKEY_COLOR: Color = Color::GREEN;
pub const INACTIVE_CHOICE_COLOR: Color = Color::grey(0.4);

View File

@ -74,6 +74,10 @@ impl<T: Clone> PopupMenu<T> {
self.state = InputResult::Done(choice.label.clone(), choice.data.clone());
return;
}
} else {
// Clicked on the map? Cancel out
self.state = InputResult::Canceled;
return;
}
}
}

View File

@ -234,7 +234,7 @@ impl<'a, 'b> WrappedWizard<'a, 'b> {
pub fn choose_exact<R: 'static + Clone + Cloneable, F: FnOnce() -> Vec<Choice<R>>>(
&mut self,
(horiz, vert): (HorizontalAlignment, VerticalAlignment),
query: &str,
query: Option<&str>,
choices_generator: F,
) -> Option<(String, R)> {
if !self.ready_results.is_empty() {
@ -268,20 +268,26 @@ impl<'a, 'b> WrappedWizard<'a, 'b> {
if self.wizard.menu_comp.is_none() {
let choices: Vec<Choice<R>> = choices_generator();
if choices.is_empty() {
let mut txt = Text::prompt(query);
let mut txt = if let Some(l) = query {
Text::prompt(l)
} else {
Text::new()
};
txt.add(Line("No choices, never mind"));
self.setup_ack(txt);
return None;
}
let mut col = Vec::new();
if let Some(l) = query {
col.push(ManagedWidget::draw_text(self.ctx, Text::prompt(l)));
}
col.push(ManagedWidget::menu("menu"));
self.wizard.menu_comp = Some(
Composite::new(
ManagedWidget::col(vec![
ManagedWidget::draw_text(self.ctx, Text::prompt(query)),
ManagedWidget::menu("menu"),
])
.bg(Color::grey(0.4))
.outline(10.0, Color::WHITE)
.padding(10),
ManagedWidget::col(col)
.bg(Color::grey(0.4))
.outline(5.0, Color::WHITE)
.padding(5),
)
.aligned(horiz, vert)
.menu(
@ -339,7 +345,7 @@ impl<'a, 'b> WrappedWizard<'a, 'b> {
) -> Option<(String, R)> {
self.choose_exact(
(HorizontalAlignment::Center, VerticalAlignment::Center),
query,
Some(query),
choices_generator,
)
}

View File

@ -158,7 +158,7 @@ fn make_load_map(btn: ScreenRectangle, gameplay: GameplayMode) -> Box<dyn State>
HorizontalAlignment::Centered(btn.center().x),
VerticalAlignment::Below(btn.y2 + 15.0),
),
"Load which map?",
None,
|| {
let current_map = ui.primary.map.get_name();
abstutil::list_all_objects(abstutil::path_all_maps())
@ -190,7 +190,7 @@ fn make_change_traffic(btn: ScreenRectangle) -> Box<dyn State> {
HorizontalAlignment::Centered(btn.center().x),
VerticalAlignment::Below(btn.y2 + 15.0),
),
"Run what type of traffic?",
None,
|| {
let mut list = Vec::new();
for name in abstutil::list_all_objects(abstutil::path_all_scenarios(