Menu titles (#115)

This commit is contained in:
Daedliy 2022-04-17 21:21:57 -03:00 committed by GitHub
parent adfc768a8f
commit 90900f01e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 1 deletions

View File

@ -352,7 +352,7 @@ impl Scene for TitleScene {
fn draw(&self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
self.background.draw(state, ctx, &self.frame, &self.textures, &self.stage)?;
if self.current_menu != CurrentMenu::SaveSelectMenu {
if self.current_menu == CurrentMenu::MainMenu {
let batch = state.texture_set.get_or_load_batch(ctx, &state.constants, "Title")?;
batch.add_rect(
((state.canvas_size.0 - state.constants.title.logo_rect.width() as f32) / 2.0).floor(),
@ -361,6 +361,23 @@ impl Scene for TitleScene {
);
batch.draw(ctx)?;
} else {
let window_title = match self.current_menu {
CurrentMenu::ChallengesMenu => (state.t("menus.main_menu.challenges")),
CurrentMenu::ChallengeConfirmMenu | CurrentMenu::SaveSelectMenu => (state.t("menus.main_menu.start")),
CurrentMenu::OptionMenu => (state.t("menus.main_menu.options")),
_ => unreachable!(),
};
state.font.draw_colored_text_with_shadow_scaled(
window_title.chars(),
state.canvas_size.0 / 2.0 - state.font.text_width(window_title.chars(), &state.constants) / 2.0,
state.font.line_height(&state.constants), //im sure there is a better way to shift this into place
1.0,
(0xff, 0xff, 0xff, 0xff),
&state.constants,
&mut state.texture_set,
ctx,
)?;
}
self.draw_text_centered(&VERSION_BANNER, state.canvas_size.1 - 15.0, state, ctx)?;