persistence + proper disconnect

This commit is contained in:
2025-11-28 17:29:33 -05:00
parent 029d62cb53
commit 7557507f27
16 changed files with 413 additions and 67 deletions
+5 -8
View File
@@ -1,3 +1,5 @@
use crate::net::NetState;
use super::*;
pub fn login_screen(client: &mut Client) -> WidgetId {
@@ -5,13 +7,7 @@ pub fn login_screen(client: &mut Client) -> WidgetId {
ui, handle, data, ..
} = client;
let mut field = |name, hint_| {
text(name)
.editable(true)
.size(20)
.hint(hint(hint_))
.add(ui)
};
let mut field = |name, hint_| text(name).editable(true).size(20).hint(hint(hint_)).add(ui);
let ip = field(&data.ip, "ip");
let username = field(&data.username, "username");
// let password = field("password");
@@ -35,7 +31,8 @@ pub fn login_screen(client: &mut Client) -> WidgetId {
client.ui[id].color = color.darker(0.3);
let ip = client.ui[&ip_].content();
let username = client.ui[&username_].content();
connect(handle.clone(), ConnectInfo { ip, username });
let th = connect(handle.clone(), ConnectInfo { ip, username });
client.net = NetState::Connecting(th);
})
.height(40);
let modal = (
+2 -2
View File
@@ -18,7 +18,7 @@ pub fn main_view(client: &mut Client, network: NetSender) -> WidgetId {
.any()
}
pub fn msg_widget(msg: Msg) -> impl WidgetLike<FnTag> {
pub fn msg_widget(msg: NetMsg) -> impl WidgetLike<FnTag> {
let content = text(msg.content)
.editable(false)
.size(SIZE)
@@ -61,7 +61,7 @@ pub fn msg_panel(client: &mut Client, network: NetSender) -> impl WidgetFn<Sized
.clone()
.id_on(Submit, move |id, client: &mut Client, _| {
let content = client.ui.text(id).take();
let msg = Msg {
let msg = NetMsg {
content: content.clone(),
user: client.username.clone(),
};
+1 -1
View File
@@ -5,7 +5,7 @@ use crate::{
};
use iris::prelude::*;
use len_fns::*;
use openworm::net::{ClientMsg, Msg};
use openworm::net::{ClientMsg, NetMsg};
use winit::dpi::{LogicalPosition, LogicalSize};
mod login;