From 3eb8d61dd25266828ed1c30fad423ce4cdb5db60 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Sun, 19 Jan 2020 17:59:37 -0800 Subject: [PATCH] adjust title screen layouting [rebuild] --- game/src/pregame.rs | 171 +++++++++++++++++++++++--------------------- 1 file changed, 88 insertions(+), 83 deletions(-) diff --git a/game/src/pregame.rs b/game/src/pregame.rs index 0b9895a725..fb29483605 100644 --- a/game/src/pregame.rs +++ b/game/src/pregame.rs @@ -27,20 +27,23 @@ impl TitleScreen { let mut rng = ui.primary.current_flags.sim_flags.make_rng(); TitleScreen { composite: Composite::new( - ezgui::Composite::new(ManagedWidget::col(vec![ - ManagedWidget::just_draw(JustDraw::image("assets/pregame/logo.png", ctx)) - .bg(Color::GREEN.alpha(0.2)), - // TODO that nicer font - // TODO Any key - ManagedWidget::row(vec![ManagedWidget::btn(Button::text( - Text::from(Line("PLAY")), - Color::BLUE, - Color::ORANGE, - hotkey(Key::Space), - "start game", - ctx, - ))]), - ])) + ezgui::Composite::new( + ManagedWidget::col(vec![ + ManagedWidget::just_draw(JustDraw::image("assets/pregame/logo.png", ctx)) + .bg(Color::GREEN.alpha(0.2)), + // TODO that nicer font + // TODO Any key + ManagedWidget::btn(Button::text( + Text::from(Line("PLAY")), + Color::BLUE, + Color::ORANGE, + hotkey(Key::Space), + "start game", + ctx, + )), + ]) + .centered(), + ) .build(ctx), ) .cb( @@ -71,38 +74,34 @@ impl State for TitleScreen { } pub fn main_menu(ctx: &mut EventCtx, ui: &UI) -> Box { - let mut col = Vec::new(); - - col.push(ManagedWidget::row(vec![ - Composite::svg_button(ctx, "assets/pregame/quit.svg", "quit", hotkey(Key::Escape)), - ManagedWidget::draw_text(ctx, Text::from(Line("A/B STREET").size(50))), - ])); - - col.push(ManagedWidget::draw_text( - ctx, - Text::from(Line("Created by Dustin Carlino")), - )); - - col.push(ManagedWidget::row(vec![ - Composite::svg_button( - ctx, - "assets/pregame/tutorial.svg", - "Tutorial", - hotkey(Key::T), - ), - Composite::svg_button( - ctx, - "assets/pregame/sandbox.svg", - "Sandbox mode", - hotkey(Key::S), - ), - Composite::img_button( - ctx, - "assets/pregame/challenges.png", - hotkey(Key::C), - "Challenges", - ), - ])); + let mut col = vec![ + ManagedWidget::row(vec![{ + let mut txt = Text::from(Line("A/B STREET").size(50)); + txt.add(Line("Created by Dustin Carlino")); + ManagedWidget::draw_text(ctx, txt) + }]), + ManagedWidget::row(vec![ + Composite::svg_button( + ctx, + "assets/pregame/tutorial.svg", + "Tutorial", + hotkey(Key::T), + ), + Composite::svg_button( + ctx, + "assets/pregame/sandbox.svg", + "Sandbox mode", + hotkey(Key::S), + ), + Composite::img_button( + ctx, + "assets/pregame/challenges.png", + hotkey(Key::C), + "Challenges", + ), + ]) + .centered(), + ]; if ui.opts.dev { col.push(ManagedWidget::row(vec![ Composite::text_button(ctx, "INTERNAL DEV TOOLS", hotkey(Key::M)), @@ -111,44 +110,50 @@ pub fn main_menu(ctx: &mut EventCtx, ui: &UI) -> Box { } col.push(Composite::text_button(ctx, "About A/B Street", None)); - let mut c = Composite::new(ezgui::Composite::new(ManagedWidget::col(col)).build(ctx)) - .cb( - "quit", - Box::new(|_, _| { - // TODO before_quit? - std::process::exit(0); - }), - ) - .cb( - "Tutorial", - Box::new(|ctx, _| { - Some(Transition::Push(Box::new(TutorialMode::new( + let mut c = Composite::new( + ezgui::Composite::new(ManagedWidget::row(vec![ + Composite::svg_button(ctx, "assets/pregame/quit.svg", "quit", hotkey(Key::Escape)), + ManagedWidget::col(col).centered(), + ])) + .build(ctx), + ) + .cb( + "quit", + Box::new(|_, _| { + // TODO before_quit? + std::process::exit(0); + }), + ) + .cb( + "Tutorial", + Box::new(|ctx, _| { + Some(Transition::Push(Box::new(TutorialMode::new( + ctx, + Stage::CanvasControls, + )))) + }), + ) + .cb( + "Sandbox mode", + Box::new(|ctx, ui| { + Some(Transition::PushWithMode( + Box::new(SandboxMode::new( ctx, - Stage::CanvasControls, - )))) - }), - ) - .cb( - "Sandbox mode", - Box::new(|ctx, ui| { - Some(Transition::PushWithMode( - Box::new(SandboxMode::new( - ctx, - ui, - GameplayMode::PlayScenario("random".to_string()), - )), - EventLoopMode::Animation, - )) - }), - ) - .cb( - "Challenges", - Box::new(|ctx, _| Some(Transition::Push(challenges_picker(ctx)))), - ) - .cb( - "About A/B Street", - Box::new(|ctx, _| Some(Transition::Push(about(ctx)))), - ); + ui, + GameplayMode::PlayScenario("random".to_string()), + )), + EventLoopMode::Animation, + )) + }), + ) + .cb( + "Challenges", + Box::new(|ctx, _| Some(Transition::Push(challenges_picker(ctx)))), + ) + .cb( + "About A/B Street", + Box::new(|ctx, _| Some(Transition::Push(about(ctx)))), + ); if ui.opts.dev { c = c .cb(