hint gaming
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
use super::*;
|
||||
|
||||
pub fn login_screen(client: &mut Client) -> WidgetId {
|
||||
let Client {
|
||||
ui, handle, data, ..
|
||||
} = client;
|
||||
|
||||
let mut field = |name, hint_| {
|
||||
text(name)
|
||||
.editable()
|
||||
.size(20)
|
||||
.hint(hint(hint_))
|
||||
.add(ui)
|
||||
};
|
||||
let ip = field(&data.ip, "ip");
|
||||
let username = field(&data.username, "username");
|
||||
// let password = field("password");
|
||||
|
||||
let fbx = |field: WidgetId<TextEdit>| {
|
||||
field
|
||||
.clone()
|
||||
.pad(10)
|
||||
.background(rect(Color::BLACK.brighter(0.1)).radius(15))
|
||||
.on(CursorSense::click(), focus_other(field))
|
||||
};
|
||||
|
||||
// I LAV NOT HAVING ERGONOMIC CLONES
|
||||
let handle = handle.clone();
|
||||
let ip_ = ip.clone();
|
||||
let username_ = username.clone();
|
||||
let color = Color::GREEN;
|
||||
let submit = rect(color)
|
||||
.radius(15)
|
||||
.id_on(CursorSense::click(), move |id, client: &mut Client, _| {
|
||||
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 });
|
||||
})
|
||||
.height(40);
|
||||
let modal = (
|
||||
text("login").text_align(Align::CENTER).size(30),
|
||||
fbx(ip
|
||||
.id_on(Edited, |id, client: &mut Client, _| {
|
||||
client.data.ip = client.ui[id].content();
|
||||
})
|
||||
.add(ui)),
|
||||
fbx(username
|
||||
.id_on(Edited, |id, client: &mut Client, _| {
|
||||
client.data.username = client.ui[id].content();
|
||||
})
|
||||
.add(ui)),
|
||||
// fbx(password),
|
||||
submit,
|
||||
)
|
||||
.span(Dir::DOWN)
|
||||
.gap(10)
|
||||
.pad(15)
|
||||
.background(rect(Color::BLACK.brighter(0.2)).radius(15))
|
||||
.width(400)
|
||||
.align(Align::CENTER);
|
||||
|
||||
let err = WidgetPtr::default().add(ui);
|
||||
client.error = Some(err.clone());
|
||||
|
||||
(modal, err.align(Align::TOP_CENTER)).stack().add(ui).any()
|
||||
}
|
||||
Reference in New Issue
Block a user