update iris

This commit is contained in:
2025-12-06 20:48:19 -05:00
parent 09be172e36
commit a1928edb66
10 changed files with 467 additions and 308 deletions

View File

@@ -11,11 +11,11 @@ use openworm::net::{ClientMsg, NetClientMsg};
pub const SIZE: u32 = 20;
pub fn main_view(client: &mut Client) -> WidgetId {
pub fn main_view(client: &mut Client, ui: &mut Ui) -> WidgetId {
let ClientState::LoggedIn(state) = &mut client.state else {
panic!("we ain't logged in buh");
};
let msg_panel = msg_panel(&mut client.ui, state);
let msg_panel = msg_panel(ui, state);
let side_bar = rect(Color::BLACK.brighter(0.05)).width(80);
let bg = (
@@ -26,7 +26,7 @@ pub fn main_view(client: &mut Client) -> WidgetId {
(side_bar, msg_panel)
.span(Dir::RIGHT)
.background(bg)
.add(&mut client.ui)
.add(ui)
.any()
}
@@ -71,17 +71,17 @@ pub fn msg_panel(ui: &mut Ui, state: &mut LoggedIn) -> impl WidgetRet + use<> {
.height(rest(1)),
send_text
.clone()
.id_on(Submit, move |id, client: &mut Client, _| {
let ClientState::LoggedIn(state) = &mut client.state else {
.on(Submit, move |ctx| {
let ClientState::LoggedIn(state) = &mut ctx.state.state else {
panic!("we ain't logged in buh");
};
let content = client.ui.text(id).take();
let content = ctx.ui.text(ctx.id).take();
let msg = NetClientMsg {
content: content.clone(),
};
state.network.send(ClientMsg::SendMsg(msg.clone()));
let msg = msg_widget(&state.username, &content).add(&mut client.ui);
client.ui[&msg_area].children.push(msg.any());
let msg = msg_widget(&state.username, &content).add(ctx.ui);
ctx.ui[&msg_area].children.push(msg.any());
})
.pad(15)
.attr::<Selector>(send_text)