DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

27de52eecf1313a32b14670c2d762856f15ef8b5 — Jonni Liljamo 1 year, 10 months ago fbd8438
feat(sdbclient): new play UI
2 files changed, 20 insertions(+), 108 deletions(-)

M sdbclient/src/plugins/menu/mod.rs
M sdbclient/src/plugins/menu/playscreen.rs
M sdbclient/src/plugins/menu/mod.rs => sdbclient/src/plugins/menu/mod.rs +1 -9
@@ 1,6 1,6 @@
/*
 * This file is part of sdbclient
 * Copyright (C) 2022 Jonni Liljamo <jonni@liljamo.com>
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.


@@ 124,8 124,6 @@ struct SelectedSettingsTab;
#[derive(Component)]
enum MenuButtonAction {
    Play,
    CreateGame,
    JoinGame,
    Settings,
    SettingsDisplay,
    SettingsAudio,


@@ 154,12 152,6 @@ fn menu_action(
            match menu_button_action {
                MenuButtonAction::Exit => app_exit_events.send(AppExit),
                MenuButtonAction::Play => commands.insert_resource(NextState(MenuState::Play)),
                MenuButtonAction::CreateGame => {
                    commands.insert_resource(NextState(MenuState::CreateGame))
                }
                MenuButtonAction::JoinGame => {
                    commands.insert_resource(NextState(MenuState::JoinGame))
                }
                MenuButtonAction::Settings => {
                    commands.insert_resource(NextState(MenuState::Settings))
                }

M sdbclient/src/plugins/menu/playscreen.rs => sdbclient/src/plugins/menu/playscreen.rs +19 -99
@@ 1,50 1,36 @@
/*
 * This file is part of sdbclient
 * Copyright (C) 2022 Jonni Liljamo <jonni@liljamo.com>
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use bevy::{
    prelude::*,
    ui::{JustifyContent, Size, Style, Val},
};
use bevy::prelude::*;
use iyes_loopless::prelude::*;

use belly::prelude::*;

use crate::constants::TEXT_COLOR;

use super::{MenuButtonAction, MenuState, NORMAL_BUTTON};

/// Tag component for tagging entities on the play screen
#[derive(Component)]
pub struct OnPlayScreen;

pub fn play_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    /*
    let font = asset_server.load("fonts/FiraMono-Regular.ttf");

    let button_style = Style {
        size: Size::new(Val::Px(200.0), Val::Px(65.0)),
        margin: UiRect::all(Val::Px(20.0)),
        justify_content: JustifyContent::Center,
        align_items: AlignItems::Center,
        ..default()
    };

    let button_text_style = TextStyle {
        font: font.clone(),
        font_size: 40.0,
        color: TEXT_COLOR,
    };
    */
use super::MenuState;

pub fn play_setup(mut commands: Commands) {
    commands.add(eml! {
        <body>
            <div>
                <button on:press=connect!(|ctx| {
            <div c:menu>
                <span c:menutitle>
                    "Play"
                </span>
                <button c:menubutton on:press=connect!(|ctx| {
                    ctx.commands().insert_resource(NextState(MenuState::CreateGame))
                })>
                    "Create"
                </button>
                <button c:menubutton on:press=connect!(|ctx| {
                    ctx.commands().insert_resource(NextState(MenuState::JoinGame))
                })>
                    "Join"
                </button>
                <button c:menubutton on:press=connect!(|ctx| {
                    ctx.commands().insert_resource(NextState(MenuState::Main))
                })>
                    "Back"


@@ 52,70 38,4 @@ pub fn play_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
            </div>
        </body>
    });

    /*
    commands
        .spawn((
            NodeBundle {
                style: Style {
                    size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
                    align_items: AlignItems::Center,
                    justify_content: JustifyContent::Center,
                    flex_direction: FlexDirection::Column,
                    ..default()
                },
                ..default()
            },
            OnPlayScreen,
        ))
        .with_children(|parent| {
            parent.spawn(
                TextBundle::from_section(
                    "Play",
                    TextStyle {
                        font: font.clone(),
                        font_size: 60.0,
                        color: TEXT_COLOR,
                    },
                )
                .with_style(Style {
                    margin: UiRect::all(Val::Px(50.)),
                    ..Default::default()
                }),
            );
            parent
                .spawn(NodeBundle {
                    style: Style {
                        flex_direction: FlexDirection::Column,
                        align_items: AlignItems::Center,
                        ..default()
                    },
                    background_color: Color::GRAY.into(),
                    ..default()
                })
                .with_children(|parent| {
                    for (action, text) in [
                        (MenuButtonAction::CreateGame, "Create"),
                        (MenuButtonAction::JoinGame, "Join"),
                        (MenuButtonAction::BackToMainMenu, "Back"),
                    ] {
                        parent
                            .spawn((
                                ButtonBundle {
                                    style: button_style.clone(),
                                    background_color: NORMAL_BUTTON.into(),
                                    ..default()
                                },
                                action,
                            ))
                            .with_children(|parent| {
                                parent.spawn(TextBundle::from_section(
                                    text,
                                    button_text_style.clone(),
                                ));
                            });
                    }
                });
        });
    */
}