diff --git a/crates/horizon-client/src/dialog.rs b/crates/horizon-client/src/dialog.rs new file mode 100644 index 000000000..7acd3e86a --- /dev/null +++ b/crates/horizon-client/src/dialog.rs @@ -0,0 +1,794 @@ +//! Server dialogs (`net.minecraft.server.dialog`): what `Dialog.DIRECT_CODEC` +//! decodes from a `show_dialog` packet, the values its inputs hold, and the +//! click event an action makes of them (`Action.createAction`). +use crate::text::Text; +use horizon_world::nbt::Tag; +use serde_json::{Value, json}; + +/// `CommonDialogData` and the type's own fields. +#[derive(Clone, Debug)] +pub struct Dialog { + pub kind: Kind, + pub title: Text, + pub external_title: Option, + pub can_close_with_escape: bool, + pub pause: bool, + pub after_action: AfterAction, + pub body: Vec, + pub inputs: Vec, +} + +/// The dialog types (`DialogTypes`). +#[derive(Clone, Debug)] +pub enum Kind { + /// `NoticeDialog`: one button, "OK" when the server names none. + Notice(Button), + Confirmation { + yes: Button, + no: Button, + }, + MultiAction { + actions: Vec