DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

8e51e5963b11961792348ba523f33793e1aee22c — Jonni Liljamo 2 years ago 0f0e2d8
Register UI, input naming changes
M sdbclient/src/main.rs => sdbclient/src/main.rs +11 -2
@@ 49,9 49,12 @@ pub struct CfgHidden {
}

// Input structs
/// Login username inputs
/// Login inputs
#[derive(Resource, Debug, Component, PartialEq, Eq, Clone)]
pub struct InputsUserLogin(String, String);
/// Register inputs
#[derive(Resource, Debug, Component, PartialEq, Eq, Clone)]
pub struct InputsUserRegister(String, String, String, String);

fn main() {
    let mut app = App::new();


@@ 97,7 100,13 @@ fn main() {
        logged_in: false,
        user_token: "".to_string(),
    })
    .insert_resource(InputsUserLogin("".to_string(), "".to_string()));
    .insert_resource(InputsUserLogin("".to_string(), "".to_string()))
    .insert_resource(InputsUserRegister(
        "".to_string(),
        "".to_string(),
        "".to_string(),
        "".to_string(),
    ));

    app.add_startup_system(setup).add_state(GameState::Splash);


M sdbclient/src/menu/accountloginui.rs => sdbclient/src/menu/accountloginui.rs +1 -1
@@ 22,7 22,7 @@ pub fn account_login_ui(
        .collapsible(false)
        .show(egui_context.ctx_mut(), |ui| {
            ui.horizontal(|ui| {
                ui.label("Username: ");
                ui.label("Email: ");
                ui.text_edit_singleline(&mut inputs.0);
            });


A sdbclient/src/menu/accountregisterui.rs => sdbclient/src/menu/accountregisterui.rs +53 -0
@@ 0,0 1,53 @@
/*
 * This file is part of sdbclient
 * Copyright (C) 2022 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use bevy::prelude::*;
use bevy_egui::{egui, EguiContext};

use crate::{util::eguipwd, InputsUserRegister};

use super::MenuState;

pub fn account_register_ui(
    mut egui_context: ResMut<EguiContext>,
    mut menu_state: ResMut<State<MenuState>>,
    mut inputs: ResMut<InputsUserRegister>,
) {
    egui::Window::new("Register")
        .collapsible(false)
        .show(egui_context.ctx_mut(), |ui| {
            ui.horizontal(|ui| {
                ui.label("Username: ");
                ui.text_edit_singleline(&mut inputs.0);
            });

            ui.horizontal(|ui| {
                ui.label("Email: ");
                ui.text_edit_singleline(&mut inputs.1);
            });

            ui.horizontal(|ui| {
                ui.label("Password: ");
                ui.add(eguipwd::password(&mut inputs.2));
            });

            ui.horizontal(|ui| {
                ui.label("Confirm password: ");
                ui.add(eguipwd::password(&mut inputs.3));
            });

            ui.with_layout(egui::Layout::right_to_left(egui::Align::Min), |ui| {
                if ui.button("Cancel").clicked() {
                    menu_state.set(MenuState::Main).unwrap();
                }
                if ui.button("Register").clicked() {
                    info!("todo");
                }
            })
        });
}

M sdbclient/src/menu/mod.rs => sdbclient/src/menu/mod.rs +4 -0
@@ 36,6 36,9 @@ use accountscreenloggedin::*;
mod accountloginui;
use accountloginui::*;

mod accountregisterui;
use accountregisterui::*;

const TEXT_COLOR: Color = Color::rgb(0.9, 0.9, 0.9);

pub struct MenuPlugin;


@@ 69,6 72,7 @@ impl Plugin for MenuPlugin {
            .add_system_set(SystemSet::on_exit(MenuState::AccountLoggedIn).with_system(despawn_screen::<OnAccountLoggedInScreen>))
            // Account login and register systems
            .add_system_set(SystemSet::on_update(MenuState::AccountLogin).with_system(account_login_ui))
            .add_system_set(SystemSet::on_update(MenuState::AccountRegister).with_system(account_register_ui))
            // Common systems
            .add_system_set(SystemSet::on_update(GameState::MainMenu).with_system(menu_action).with_system(button_system));
    }