get rid of set_mode_with_extra; legend plugin is gone

This commit is contained in:
Dustin Carlino 2019-05-01 11:26:24 -07:00
parent b42bba799d
commit c904e9cdcf
2 changed files with 19 additions and 38 deletions

View File

@ -242,13 +242,26 @@ impl UserInput {
// Returns the bottom left of the modal menu.
// TODO It'd be nice to scope the return value to the next draw()s only.
pub fn set_mode_with_extra(
pub fn set_mode(&mut self, mode: &str, canvas: &Canvas) -> ScreenPt {
self.set_mode_with_prompt(mode, mode.to_string(), canvas)
}
pub fn set_mode_with_prompt(
&mut self,
mode: &str,
prompt: String,
canvas: &Canvas,
) -> ScreenPt {
let mut txt = Text::new();
txt.add_styled_line(prompt, None, Some(text::PROMPT_COLOR), None);
self.set_mode_with_new_prompt(mode, txt, canvas)
}
pub fn set_mode_with_new_prompt(
&mut self,
mode: &str,
prompt: Text,
canvas: &Canvas,
extra_width: f64,
_extra_height: f64,
) -> ScreenPt {
self.set_mode_called.insert(mode.to_string());
self.current_mode = Some(mode.to_string());
@ -266,7 +279,7 @@ impl UserInput {
.collect(),
false,
true,
Position::TopRightOfScreen(extra_width),
Position::TopRightOfScreen,
canvas,
);
menu.mark_all_inactive();
@ -279,30 +292,6 @@ impl UserInput {
}
}
pub fn set_mode_with_prompt(
&mut self,
mode: &str,
prompt: String,
canvas: &Canvas,
) -> ScreenPt {
let mut txt = Text::new();
txt.add_styled_line(prompt, None, Some(text::PROMPT_COLOR), None);
self.set_mode_with_extra(mode, txt, canvas, 0.0, 0.0)
}
pub fn set_mode_with_new_prompt(
&mut self,
mode: &str,
prompt: Text,
canvas: &Canvas,
) -> ScreenPt {
self.set_mode_with_extra(mode, prompt, canvas, 0.0, 0.0)
}
pub fn set_mode(&mut self, mode: &str, canvas: &Canvas) -> ScreenPt {
self.set_mode_with_prompt(mode, mode.to_string(), canvas)
}
pub fn modal_action(&mut self, action: &str) -> bool {
if let Some(ref mode) = self.current_mode {
if self.chosen_action == Some(action.to_string()) {

View File

@ -24,8 +24,7 @@ pub struct Menu<T: Clone> {
pub enum Position {
ScreenCenter,
TopLeftAt(ScreenPt),
// Extra width needed -- if more than the natural menu length, this'll pad the menu.
TopRightOfScreen(f64),
TopRightOfScreen,
}
impl<T: Clone> Menu<T> {
@ -63,14 +62,7 @@ impl<T: Clone> Menu<T> {
pt.y -= total_height / 2.0;
pt
}
Position::TopRightOfScreen(extra_width) => {
let w = if extra_width > total_width {
extra_width
} else {
total_width
};
ScreenPt::new(canvas.window_width - w, 0.0)
}
Position::TopRightOfScreen => ScreenPt::new(canvas.window_width - total_width, 0.0),
};
Menu {