mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-26 16:02:23 +03:00
use a modal menu for tutorial mode
This commit is contained in:
parent
c904e9cdcf
commit
b2b7d0767c
@ -16,7 +16,6 @@
|
||||
- big vertical road. some neighborhoods off to the side. everyone trying to go nrth or south. one driving, one parkign lane. a bus that makes a loop. some horizontal roads connected to borders that force the vertical road to not be fast. just make a dedicated bus lane! oops,except some of the bus stops are at narrow places, so traffic has to slow down anyway for the bus. maybe there's a bypass road through a neighborhood?
|
||||
- introduce elements gradually... fix a silly traffic signal with just cars, then add peds and bikes...
|
||||
|
||||
- use a modalish menu to display instructions and also give the 'escape' option
|
||||
- spawn cars somewhere
|
||||
- run sim, pause, change speed, reset
|
||||
|
||||
|
@ -207,6 +207,7 @@ impl GUI for GameState {
|
||||
"A/B Test Editor",
|
||||
vec![(Key::Escape, "quit"), (Key::R, "run A/B test")],
|
||||
),
|
||||
ModalMenu::new("Tutorial", vec![(Key::Escape, "quit")]),
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
use crate::game::{GameState, Mode};
|
||||
use crate::render::DrawOptions;
|
||||
use crate::ui::ShowEverything;
|
||||
use ezgui::{
|
||||
EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, Key, Text, VerticalAlignment, Wizard,
|
||||
};
|
||||
use ezgui::{Color, EventCtx, EventLoopMode, GfxCtx, Key, Text, Wizard};
|
||||
use geom::Pt2D;
|
||||
|
||||
// Does CommonState make sense?
|
||||
@ -16,24 +14,40 @@ impl TutorialMode {
|
||||
pub fn event(state: &mut GameState, ctx: &mut EventCtx) -> EventLoopMode {
|
||||
ctx.canvas.handle_event(ctx.input);
|
||||
|
||||
let mut txt = Text::new();
|
||||
txt.add_styled_line("Tutorial".to_string(), None, Some(Color::BLUE), None);
|
||||
match state.mode {
|
||||
Mode::Tutorial(TutorialMode::Part1(orig_center)) => {
|
||||
txt.add_line("Click and drag to pan around".to_string());
|
||||
|
||||
// TODO Zooming also changes this. :(
|
||||
if ctx.canvas.center_to_map_pt() != orig_center
|
||||
&& ctx.input.key_pressed(Key::Enter, "next step of tutorial")
|
||||
{
|
||||
state.mode = Mode::Tutorial(TutorialMode::Part2(ctx.canvas.cam_zoom));
|
||||
if ctx.canvas.center_to_map_pt() != orig_center {
|
||||
txt.add_line("".to_string());
|
||||
txt.add_line("Great! Press ENTER to continue.".to_string());
|
||||
if ctx.input.key_pressed(Key::Enter, "next step of tutorial") {
|
||||
state.mode = Mode::Tutorial(TutorialMode::Part2(ctx.canvas.cam_zoom));
|
||||
}
|
||||
}
|
||||
}
|
||||
Mode::Tutorial(TutorialMode::Part2(orig_cam_zoom)) => {
|
||||
if ctx.canvas.cam_zoom != orig_cam_zoom
|
||||
&& ctx.input.key_pressed(Key::Enter, "next step of tutorial")
|
||||
{
|
||||
state.mode = Mode::SplashScreen(Wizard::new(), None);
|
||||
txt.add_line("Use your mouse wheel or touchpad to zoom in and out".to_string());
|
||||
|
||||
if ctx.canvas.cam_zoom != orig_cam_zoom {
|
||||
txt.add_line("".to_string());
|
||||
txt.add_line("Great! Press ENTER to continue.".to_string());
|
||||
if ctx.input.key_pressed(Key::Enter, "next step of tutorial") {
|
||||
state.mode = Mode::SplashScreen(Wizard::new(), None);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
ctx.input
|
||||
.set_mode_with_new_prompt("Tutorial", txt, ctx.canvas);
|
||||
|
||||
if ctx.input.modal_action("quit") {
|
||||
state.mode = Mode::SplashScreen(Wizard::new(), None);
|
||||
}
|
||||
|
||||
EventLoopMode::InputOnly
|
||||
}
|
||||
@ -45,29 +59,5 @@ impl TutorialMode {
|
||||
&state.ui.primary.sim,
|
||||
&ShowEverything::new(),
|
||||
);
|
||||
|
||||
let mut txt = Text::new();
|
||||
match state.mode {
|
||||
Mode::Tutorial(TutorialMode::Part1(orig_center)) => {
|
||||
txt.add_line("Click and drag to pan around".to_string());
|
||||
if g.canvas.center_to_map_pt() != orig_center {
|
||||
txt.add_line("".to_string());
|
||||
txt.add_line("Great! Press ENTER to continue.".to_string());
|
||||
}
|
||||
}
|
||||
Mode::Tutorial(TutorialMode::Part2(orig_cam_zoom)) => {
|
||||
txt.add_line("Use your mouse wheel or touchpad to zoom in and out".to_string());
|
||||
if g.canvas.cam_zoom != orig_cam_zoom {
|
||||
txt.add_line("".to_string());
|
||||
txt.add_line("Great! Press ENTER to continue.".to_string());
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
// TODO Get rid of top menu and OSD and then put this somewhere more sensible. :)
|
||||
g.draw_blocking_text(
|
||||
&txt,
|
||||
(HorizontalAlignment::Right, VerticalAlignment::Center),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user