accounts are now real

This commit is contained in:
2025-12-03 22:51:57 -05:00
parent 4aa22de61b
commit 24bb65bf7b
15 changed files with 679 additions and 163 deletions

51
src/bin/client/state.rs Normal file
View File

@@ -0,0 +1,51 @@
use iris::prelude::*;
use openworm::net::NetServerMsg;
use std::thread::JoinHandle;
use crate::net::NetHandle;
#[derive(Default)]
pub struct Connect {
pub handle: Option<JoinHandle<()>>,
}
pub struct Login {
pub handle: NetHandle,
}
pub struct LoggedIn {
pub network: NetHandle,
pub msgs: Vec<NetServerMsg>,
pub channel: Option<WidgetId<Span>>,
pub username: String,
}
pub enum ClientState {
Connect(Connect),
Login(Login),
LoggedIn(LoggedIn),
}
impl Default for ClientState {
fn default() -> Self {
Self::Connect(Default::default())
}
}
impl ClientState {
pub fn take(&mut self) -> Self {
std::mem::take(self)
}
pub fn exit(&mut self) {
let s = self.take();
match s {
ClientState::Connect(_) => (),
ClientState::Login(Login { handle }) => {
handle.exit();
}
ClientState::LoggedIn(state) => {
state.network.exit();
}
}
}
}