gveditor_core_api/extensions/modules/
popup.rs

1use crate::extensions::client::ExtensionClient;
2use crate::messaging::Messages;
3
4/// Dialog-like message
5#[allow(dead_code)]
6pub struct Popup {
7    id: String,
8    title: String,
9    content: String,
10    client: ExtensionClient,
11    state_id: u8,
12}
13
14impl Popup {
15    pub fn new(mut client: ExtensionClient, state_id: u8, title: &str, content: &str) -> Self {
16        Self {
17            id: client.get_id(),
18            client,
19            state_id,
20            title: title.to_string(),
21            content: content.to_string(),
22        }
23    }
24
25    pub async fn show(&self) {
26        self.client
27            .send(Messages::ShowPopup {
28                state_id: self.state_id,
29                popup_id: self.id.clone(),
30                title: self.title.clone(),
31                content: self.content.clone(),
32            })
33            .await
34            .unwrap();
35    }
36}