M Cargo.lock => Cargo.lock +3 -2
@@ 3454,9 3454,9 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.7.0"
+version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
+checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
dependencies = [
"aho-corasick",
"memchr",
@@ 3644,6 3644,7 @@ dependencies = [
"futures-lite",
"iyes_loopless",
"proc-macro2",
+ "regex",
"reqwest",
"serde",
"serde_json",
M sdbclient/Cargo.toml => sdbclient/Cargo.toml +3 -0
@@ 48,3 48,6 @@ futures-lite = "1.12.0"
# get dirs for saving data
directories = "4.0.1"
+
+# regex
+regex = "1.7.1"
M => +2 -7
@@ 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.
@@ 35,12 35,7 @@ impl Plugin for AccountLoginPlugin {
app.add_loopless_state(LoginState::None)
// UI system
.insert_resource(ui::InputsUserLogin::new())
.add_system_set(
ConditionSet::new()
.run_in_state(LoginState::Input)
.with_system(ui::account_login_ui)
.into(),
)
.add_enter_system(LoginState::Input, ui::account_login_setup)
// Login system, as in calling the API
.add_enter_system(LoginState::LoggingIn, start_login_call)
.add_system_set(
M => +44 -4
@@ 1,16 1,17 @@
/*
* 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::*;
use bevy_inspector_egui::bevy_egui::{egui, EguiContext};
use iyes_loopless::prelude::*;
use crate::util::eguipwd;
use belly::prelude::*;
use regex::Regex;
use crate::plugins::menu::MenuState;
@@ 18,9 19,10 @@ use super::LoginState;
/// Login inputs
#[derive(Resource, Debug, Component, PartialEq, Eq, Clone)]
pub struct InputsUserLogin {
pub(super) struct InputsUserLogin {
pub email: String,
pub password: String,
pub visible_pwd: String,
pub error: String,
}
@@ 29,11 31,48 @@ impl InputsUserLogin {
Self {
email: "".to_string(),
password: "".to_string(),
visible_pwd: "".to_string(),
error: "".to_string(),
}
}
}
pub(super) fn account_login_setup(mut commands: Commands /*, pwd: Res<Password>*/) {
let input_email = commands.spawn_empty().id();
let input_password = commands.spawn_empty().id();
//let visible_pwd = pwd.visible.clone();
commands.add(eml! {
<body>
<div c:menu>
<span c:menutitle>
"Login"
</span>
<span>"Email:"</span>
<textinput {input_email} bind:value=to!(input_email, Label:value | fmt.val("{val}"))/>
<span>"Password:"</span>
<textinput {input_password} bind:value=from!(InputsUserLogin:password | fmt.s("{s}"))/>
<button c:menubutton on:press=connect!(|ctx| {
//ctx.commands().insert_resource(NextState(LoginState::LoggingIn))
})>
"Login"
</button>
<button c:menubutton on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(LoginState::None));
ctx.commands().insert_resource(NextState(MenuState::AccountLoggedOut));
})>
"Cancel"
</button>
</div>
</body>
});
}
/*
pub fn account_login_ui(
mut commands: Commands,
mut egui_context: ResMut<EguiContext>,
@@ 72,3 111,4 @@ pub fn account_login_ui(
})
});
}
*/
M => +2 -1
@@ 53,7 53,8 @@ impl Plugin for MenuPlugin {
.add_enter_system(MenuState::Settings, settings_setup)
.add_exit_system(MenuState::Settings, remove_ui)
// Systems for account loggedout screen
.add_enter_system(MenuState::AccountLoggedOut, account_loggedout_setup)
.add_enter_system(MenuState::AccountLoggedOut, remove_ui.label("account_logged_out_enter_remove_ui"))
.add_enter_system(MenuState::AccountLoggedOut, account_loggedout_setup.after("account_logged_out_enter_remove_ui"))
.add_exit_system(MenuState::AccountLoggedOut, remove_ui)
// Systems for account loggedin screen
.add_enter_system(MenuState::AccountLoggedIn, account_loggedin_setup)