SAO UI dialog uses JSON config message
This commit is contained in:
parent
43474fe849
commit
be23fcc26e
|
@ -10,4 +10,6 @@ crate-type = ["cdylib"]
|
|||
glam = "^0.21"
|
||||
keyframe = "1"
|
||||
canary_script = { path = "../script" }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
wee_alloc = "^0.4"
|
||||
|
|
|
@ -26,16 +26,10 @@ pub struct ConfirmationDialogPanel {
|
|||
impl BindPanel for ConfirmationDialogPanel {
|
||||
fn bind(panel: Panel, msg: Message) -> Box<dyn PanelImpl> {
|
||||
let msg = msg.to_vec();
|
||||
let title = String::from_utf8(msg).unwrap();
|
||||
let info: DialogInfo = serde_json::from_slice(&msg).unwrap();
|
||||
|
||||
use widgets::dialog::*;
|
||||
let style = DialogStyle::default();
|
||||
let info = DialogInfo {
|
||||
title: &title,
|
||||
content: "lmao u wish",
|
||||
responses: &[DialogResponse::Yes, DialogResponse::No],
|
||||
};
|
||||
|
||||
let dialog = Dialog::new(style, &info);
|
||||
Box::new(Self { panel, dialog })
|
||||
}
|
||||
|
|
|
@ -272,9 +272,9 @@ impl Container for SettingsMenu {
|
|||
SlotMenuEvent::SubmenuOpen(5) => {
|
||||
let style = DialogStyle::default();
|
||||
let info = DialogInfo {
|
||||
title: "ha jk",
|
||||
content: "lmao u wish",
|
||||
responses: &[DialogResponse::Yes, DialogResponse::No],
|
||||
title: "ha jk".to_string(),
|
||||
content: "lmao u wish".to_string(),
|
||||
responses: [DialogResponse::Yes, DialogResponse::No].to_vec(),
|
||||
};
|
||||
let dialog = Dialog::new(style, &info);
|
||||
let dialog = Popup::new(dialog, Vec2::ZERO);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use super::prelude::*;
|
||||
use shell::Offset;
|
||||
use button::{RoundButton, RoundButtonStyle};
|
||||
use serde::Deserialize;
|
||||
use shell::Offset;
|
||||
use text::{HorizontalAlignment, Label, LabelText};
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug, Deserialize)]
|
||||
pub enum DialogResponse {
|
||||
Yes,
|
||||
No,
|
||||
|
@ -109,10 +110,11 @@ impl Default for DialogFooterStyle {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct DialogInfo<'a> {
|
||||
pub title: &'a str,
|
||||
pub content: &'a str,
|
||||
pub responses: &'a [DialogResponse],
|
||||
#[derive(Deserialize)]
|
||||
pub struct DialogInfo {
|
||||
pub title: String,
|
||||
pub content: String,
|
||||
pub responses: Vec<DialogResponse>,
|
||||
}
|
||||
|
||||
pub struct Dialog {
|
||||
|
@ -123,7 +125,7 @@ pub struct Dialog {
|
|||
}
|
||||
|
||||
impl Dialog {
|
||||
pub fn new(style: DialogStyle, info: &DialogInfo<'_>) -> Self {
|
||||
pub fn new(style: DialogStyle, info: &DialogInfo) -> Self {
|
||||
let width2 = style.width / 2.0;
|
||||
|
||||
let button_y = -(style.body.height + style.footer.height) / 2.0;
|
||||
|
|
Loading…
Reference in New Issue