desktop: Use MessageDialog for messages
This commit replaces rfd's MessageDialog with our custom MessageDialog written using egui.
This commit is contained in:
parent
fc13643cc8
commit
6d577f50e4
|
@ -1,3 +1,6 @@
|
||||||
|
use crate::custom_event::RuffleEvent;
|
||||||
|
use crate::gui::dialogs::message_dialog::MessageDialogConfiguration;
|
||||||
|
use crate::gui::{DialogDescriptor, LocalizableText};
|
||||||
use crate::preferences::GlobalPreferences;
|
use crate::preferences::GlobalPreferences;
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
@ -15,6 +18,7 @@ use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
use winit::event_loop::EventLoopProxy;
|
||||||
use winit::raw_window_handle::HasDisplayHandle;
|
use winit::raw_window_handle::HasDisplayHandle;
|
||||||
use winit::window::{Fullscreen, Window};
|
use winit::window::{Fullscreen, Window};
|
||||||
|
|
||||||
|
@ -114,6 +118,7 @@ impl FileDialogResult for DesktopFileDialogResult {
|
||||||
|
|
||||||
pub struct DesktopUiBackend {
|
pub struct DesktopUiBackend {
|
||||||
window: Arc<Window>,
|
window: Arc<Window>,
|
||||||
|
event_loop: EventLoopProxy<RuffleEvent>,
|
||||||
cursor_visible: bool,
|
cursor_visible: bool,
|
||||||
clipboard: Clipboard,
|
clipboard: Clipboard,
|
||||||
preferences: GlobalPreferences,
|
preferences: GlobalPreferences,
|
||||||
|
@ -127,6 +132,7 @@ pub struct DesktopUiBackend {
|
||||||
impl DesktopUiBackend {
|
impl DesktopUiBackend {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
window: Arc<Window>,
|
window: Arc<Window>,
|
||||||
|
event_loop: EventLoopProxy<RuffleEvent>,
|
||||||
open_url_mode: OpenURLMode,
|
open_url_mode: OpenURLMode,
|
||||||
font_database: Rc<fontdb::Database>,
|
font_database: Rc<fontdb::Database>,
|
||||||
preferences: GlobalPreferences,
|
preferences: GlobalPreferences,
|
||||||
|
@ -142,6 +148,7 @@ impl DesktopUiBackend {
|
||||||
);
|
);
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
window,
|
window,
|
||||||
|
event_loop,
|
||||||
cursor_visible: true,
|
cursor_visible: true,
|
||||||
clipboard,
|
clipboard,
|
||||||
preferences,
|
preferences,
|
||||||
|
@ -166,8 +173,6 @@ impl DesktopUiBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const DOWNLOAD_FAILED_MESSAGE: &str = "Ruffle failed to open or download this file.";
|
|
||||||
|
|
||||||
impl UiBackend for DesktopUiBackend {
|
impl UiBackend for DesktopUiBackend {
|
||||||
fn mouse_visible(&self) -> bool {
|
fn mouse_visible(&self) -> bool {
|
||||||
self.cursor_visible
|
self.cursor_visible
|
||||||
|
@ -199,21 +204,27 @@ impl UiBackend for DesktopUiBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_root_movie_download_failed_message(&self, _invalid_swf: bool) {
|
fn display_root_movie_download_failed_message(&self, _invalid_swf: bool) {
|
||||||
let dialog = MessageDialog::new()
|
let _ = self
|
||||||
.set_level(MessageLevel::Warning)
|
.event_loop
|
||||||
.set_title("Ruffle - Load failed")
|
.send_event(RuffleEvent::OpenDialog(DialogDescriptor::ShowMessage(
|
||||||
.set_description(DOWNLOAD_FAILED_MESSAGE)
|
MessageDialogConfiguration::new(
|
||||||
.set_buttons(MessageButtons::Ok);
|
LocalizableText::LocalizedText("message-dialog-root-movie-load-error-title"),
|
||||||
dialog.show();
|
LocalizableText::LocalizedText(
|
||||||
|
"message-dialog-root-movie-load-error-description",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn message(&self, message: &str) {
|
fn message(&self, message: &str) {
|
||||||
let dialog = MessageDialog::new()
|
let _ = self
|
||||||
.set_level(MessageLevel::Info)
|
.event_loop
|
||||||
.set_title("Ruffle")
|
.send_event(RuffleEvent::OpenDialog(DialogDescriptor::ShowMessage(
|
||||||
.set_description(message)
|
MessageDialogConfiguration::new(
|
||||||
.set_buttons(MessageButtons::Ok);
|
LocalizableText::NonLocalizedText("Ruffle".into()),
|
||||||
dialog.show();
|
LocalizableText::NonLocalizedText(message.to_string().into()),
|
||||||
|
),
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_unsupported_video(&self, url: Url) {
|
fn display_unsupported_video(&self, url: Url) {
|
||||||
|
|
|
@ -79,7 +79,6 @@ pub fn text_with_args<'a, T: AsRef<str>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum LocalizableText {
|
pub enum LocalizableText {
|
||||||
#[allow(dead_code)]
|
|
||||||
NonLocalizedText(Cow<'static, str>),
|
NonLocalizedText(Cow<'static, str>),
|
||||||
LocalizedText(&'static str),
|
LocalizedText(&'static str),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue