toast translations, empty set warning
This commit is contained in:
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, IntegerId, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, IntegerId, Serialize, Deserialize)]
|
||||||
pub enum ToastTopic {
|
pub enum ToastTopic {
|
||||||
System,
|
System,
|
||||||
|
Error,
|
||||||
DesktopNotification,
|
DesktopNotification,
|
||||||
XSNotification,
|
XSNotification,
|
||||||
IpdChange,
|
IpdChange,
|
||||||
|
|||||||
@@ -58,6 +58,17 @@
|
|||||||
"GRABBING_FLOATING": "This overlay is Floating and will stay in place, unless recentered.",
|
"GRABBING_FLOATING": "This overlay is Floating and will stay in place, unless recentered.",
|
||||||
"GRABBING_FOLLOW": "This overlay will follow the device it is attached to."
|
"GRABBING_FOLLOW": "This overlay will follow the device it is attached to."
|
||||||
},
|
},
|
||||||
|
"TOAST": {
|
||||||
|
"DEFAULT_TITLE": "Notification",
|
||||||
|
"ERROR": "Error",
|
||||||
|
"CANNOT_REMOVE_SET": "Cannot remove set!",
|
||||||
|
"NO_SET_SELECTED": "No set is selected.",
|
||||||
|
"LAST_EXISTING_SET": "This is the last existing set.",
|
||||||
|
"EMPTY_SET": "Empty set!",
|
||||||
|
"LETS_ADD_OVERLAYS": "Let's add some overlays from the watch!",
|
||||||
|
"FIXING_FLOOR": "Fixing floor in 5 seconds...",
|
||||||
|
"ONE_CONTROLLER_ON_FLOOR": "Place one controller on the floor!"
|
||||||
|
},
|
||||||
"WATCH": {
|
"WATCH": {
|
||||||
"ADD_NEW_SET": "Add a new set",
|
"ADD_NEW_SET": "Add a new set",
|
||||||
"CLEANUP_MIRRORS": "Remove mirrors that are\nnot currently visible",
|
"CLEANUP_MIRRORS": "Remove mirrors that are\nnot currently visible",
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ impl PlayspaceMover {
|
|||||||
|
|
||||||
let y1 = input.pointers[0].raw_pose.translation.y;
|
let y1 = input.pointers[0].raw_pose.translation.y;
|
||||||
let y2 = input.pointers[1].raw_pose.translation.y;
|
let y2 = input.pointers[1].raw_pose.translation.y;
|
||||||
let delta = y1.min(y2) - 0.03;
|
let delta = y1.min(y2) - 0.05;
|
||||||
|
|
||||||
pose.position.y += delta;
|
pose.position.y += delta;
|
||||||
|
|
||||||
|
|||||||
@@ -306,16 +306,15 @@ pub(super) fn setup_custom_button<S: 'static>(
|
|||||||
return Ok(EventResult::Pass);
|
return Ok(EventResult::Pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..5 {
|
|
||||||
Toast::new(
|
Toast::new(
|
||||||
ToastTopic::System,
|
ToastTopic::System,
|
||||||
format!("Fixing floor in {}", 5 - i),
|
"TOAST.FIXING_FLOOR".into(),
|
||||||
"Touch your controller to the floor!".into(),
|
"TOAST.ONE_CONTROLLER_ON_FLOOR".into(),
|
||||||
)
|
)
|
||||||
.with_timeout(1.)
|
.with_timeout(5.)
|
||||||
.with_sound(true)
|
.with_sound(true)
|
||||||
.submit_at(app, Instant::now() + Duration::from_secs(i));
|
.submit(app);
|
||||||
}
|
|
||||||
app.tasks.enqueue_at(
|
app.tasks.enqueue_at(
|
||||||
TaskType::Playspace(PlayspaceTask::FixFloor),
|
TaskType::Playspace(PlayspaceTask::FixFloor),
|
||||||
Instant::now() + Duration::from_secs(5),
|
Instant::now() + Duration::from_secs(5),
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ use wlx_common::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
backend::task::{OverlayTask, TaskType},
|
backend::task::{OverlayTask, TaskType},
|
||||||
gui::panel::{GuiPanel, NewGuiPanelParams, OnCustomIdFunc},
|
gui::panel::{GuiPanel, NewGuiPanelParams, OnCustomIdFunc},
|
||||||
overlays::watch::{WATCH_POS, WATCH_ROT},
|
|
||||||
state::AppState,
|
state::AppState,
|
||||||
windowing::{OverlaySelector, Z_ORDER_TOAST, window::OverlayWindowConfig},
|
windowing::{OverlaySelector, Z_ORDER_TOAST, window::OverlayWindowConfig},
|
||||||
};
|
};
|
||||||
@@ -121,35 +120,29 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
|
|||||||
Positioning::FollowHead { lerp: 0.1 },
|
Positioning::FollowHead { lerp: 0.1 },
|
||||||
),
|
),
|
||||||
ToastDisplayMethod::Watch => {
|
ToastDisplayMethod::Watch => {
|
||||||
//FIXME: properly follow watch
|
let relative_to = Positioning::FollowHand {
|
||||||
let watch_pos = WATCH_POS + vec3(-0.005, -0.05, 0.02);
|
|
||||||
let watch_rot = WATCH_ROT;
|
|
||||||
let relative_to = /*match app.session.config.watch_hand {
|
|
||||||
LeftRight::Left =>*/ Positioning::FollowHand {
|
|
||||||
hand: LeftRight::Left,
|
hand: LeftRight::Left,
|
||||||
lerp: 1.0,
|
lerp: 0.1,
|
||||||
align_to_hmd: true,
|
align_to_hmd: true,
|
||||||
/*
|
|
||||||
},
|
|
||||||
LeftRight::Right => {
|
|
||||||
watch_pos.x = -watch_pos.x;
|
|
||||||
watch_rot = watch_rot * Quat::from_rotation_x(PI) * Quat::from_rotation_z(PI);
|
|
||||||
Positioning::FollowHand {
|
|
||||||
hand: LeftRight::Right,
|
|
||||||
lerp: 1.0,
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
};
|
};
|
||||||
(watch_pos, watch_rot, relative_to)
|
(vec3(0., 0., 0.), Quat::IDENTITY, relative_to)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let title = if toast.title.is_empty() {
|
let title = if toast.title.is_empty() {
|
||||||
Translation::from_translation_key("TOAST.DEFAULT_TITLE")
|
Translation::from_translation_key("TOAST.DEFAULT_TITLE")
|
||||||
|
} else if matches!(toast.topic, ToastTopic::System | ToastTopic::Error) {
|
||||||
|
Translation::from_translation_key(&toast.title)
|
||||||
} else {
|
} else {
|
||||||
Translation::from_raw_text(&toast.title)
|
Translation::from_raw_text(&toast.title)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let body = if matches!(toast.topic, ToastTopic::System) {
|
||||||
|
Translation::from_translation_key(&toast.body)
|
||||||
|
} else {
|
||||||
|
Translation::from_raw_text(&toast.body)
|
||||||
|
};
|
||||||
|
|
||||||
let on_custom_id: OnCustomIdFunc<()> =
|
let on_custom_id: OnCustomIdFunc<()> =
|
||||||
Box::new(move |id, widget, _doc_params, layout, _parser_state, ()| {
|
Box::new(move |id, widget, _doc_params, layout, _parser_state, ()| {
|
||||||
if &*id == "toast_title" {
|
if &*id == "toast_title" {
|
||||||
@@ -168,7 +161,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
|
|||||||
.get_as::<WidgetLabel>(widget)
|
.get_as::<WidgetLabel>(widget)
|
||||||
.context("toast.xml: missing element with id: toast_body")?;
|
.context("toast.xml: missing element with id: toast_body")?;
|
||||||
let mut globals = layout.state.globals.get();
|
let mut globals = layout.state.globals.get();
|
||||||
label.set_text_simple(&mut globals, Translation::from_raw_text(&toast.body));
|
label.set_text_simple(&mut globals, body.clone());
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
@@ -206,7 +199,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn msg_err(app: &mut AppState, message: &str) {
|
fn msg_err(app: &mut AppState, message: &str) {
|
||||||
Toast::new(ToastTopic::System, "Error".into(), message.into())
|
Toast::new(ToastTopic::Error, "TOAST.ERROR".into(), message.into())
|
||||||
.with_timeout(3.)
|
.with_timeout(3.)
|
||||||
.submit(app);
|
.submit(app);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ impl AppSession {
|
|||||||
|
|
||||||
let mut toast_topics = IdMap::new();
|
let mut toast_topics = IdMap::new();
|
||||||
toast_topics.insert(ToastTopic::System, ToastDisplayMethod::Center);
|
toast_topics.insert(ToastTopic::System, ToastDisplayMethod::Center);
|
||||||
|
toast_topics.insert(ToastTopic::Error, ToastDisplayMethod::Center);
|
||||||
toast_topics.insert(ToastTopic::DesktopNotification, ToastDisplayMethod::Center);
|
toast_topics.insert(ToastTopic::DesktopNotification, ToastDisplayMethod::Center);
|
||||||
toast_topics.insert(ToastTopic::XSNotification, ToastDisplayMethod::Center);
|
toast_topics.insert(ToastTopic::XSNotification, ToastDisplayMethod::Center);
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ pub struct OverlayWindowManager<T> {
|
|||||||
watch_id: OverlayID,
|
watch_id: OverlayID,
|
||||||
edit_mode: bool,
|
edit_mode: bool,
|
||||||
dropped_overlays: VecDeque<OverlayWindowData<T>>,
|
dropped_overlays: VecDeque<OverlayWindowData<T>>,
|
||||||
|
initialized: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> OverlayWindowManager<T>
|
impl<T> OverlayWindowManager<T>
|
||||||
@@ -66,6 +67,7 @@ where
|
|||||||
watch_id: OverlayID::null(), // set down below
|
watch_id: OverlayID::null(), // set down below
|
||||||
edit_mode: false,
|
edit_mode: false,
|
||||||
dropped_overlays: VecDeque::with_capacity(8),
|
dropped_overlays: VecDeque::with_capacity(8),
|
||||||
|
initialized: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut wayland = false;
|
let mut wayland = false;
|
||||||
@@ -148,6 +150,8 @@ where
|
|||||||
.notify(app, ev)?;
|
.notify(app, ev)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
me.initialized = true;
|
||||||
|
|
||||||
Ok(me)
|
Ok(me)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,8 +203,8 @@ where
|
|||||||
let Some(set) = self.current_set else {
|
let Some(set) = self.current_set else {
|
||||||
Toast::new(
|
Toast::new(
|
||||||
ToastTopic::System,
|
ToastTopic::System,
|
||||||
"Can't remove set".into(),
|
"TOAST.CANNOT_REMOVE_SET".into(),
|
||||||
"No set is selected!".into(),
|
"TOAST.NO_SET_SELECTED".into(),
|
||||||
)
|
)
|
||||||
.with_timeout(5.)
|
.with_timeout(5.)
|
||||||
.with_sound(true)
|
.with_sound(true)
|
||||||
@@ -211,8 +215,8 @@ where
|
|||||||
if self.sets.len() <= 1 {
|
if self.sets.len() <= 1 {
|
||||||
Toast::new(
|
Toast::new(
|
||||||
ToastTopic::System,
|
ToastTopic::System,
|
||||||
"Can't remove set".into(),
|
"TOAST.CANNOT_REMOVE_SET".into(),
|
||||||
"This is the last existing set!".into(),
|
"TOAST.LAST_EXISTING_SET".into(),
|
||||||
)
|
)
|
||||||
.with_timeout(5.)
|
.with_timeout(5.)
|
||||||
.with_sound(true)
|
.with_sound(true)
|
||||||
@@ -658,6 +662,7 @@ impl<T> OverlayWindowManager<T> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut num_overlays = 0;
|
||||||
let ws = &mut self.sets[new_set];
|
let ws = &mut self.sets[new_set];
|
||||||
for (id, data) in self.overlays.iter_mut().filter(|(_, d)| !d.config.global) {
|
for (id, data) in self.overlays.iter_mut().filter(|(_, d)| !d.config.global) {
|
||||||
if let Some(state) = ws.overlays.remove(id) {
|
if let Some(state) = ws.overlays.remove(id) {
|
||||||
@@ -666,10 +671,28 @@ impl<T> OverlayWindowManager<T> {
|
|||||||
if !keep_transforms {
|
if !keep_transforms {
|
||||||
data.config.reset(app, false);
|
data.config.reset(app, false);
|
||||||
}
|
}
|
||||||
|
if !matches!(
|
||||||
|
data.config.category,
|
||||||
|
OverlayCategory::Internal
|
||||||
|
| OverlayCategory::Keyboard
|
||||||
|
| OverlayCategory::Dashboard
|
||||||
|
) {
|
||||||
|
num_overlays += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ws.overlays.clear();
|
ws.overlays.clear();
|
||||||
self.restore_set = new_set;
|
self.restore_set = new_set;
|
||||||
|
|
||||||
|
if !self.edit_mode && self.initialized && num_overlays < 1 {
|
||||||
|
Toast::new(
|
||||||
|
ToastTopic::System,
|
||||||
|
"TOAST.EMPTY_SET".into(),
|
||||||
|
"TOAST.LETS_ADD_OVERLAYS".into(),
|
||||||
|
)
|
||||||
|
.with_timeout(3.)
|
||||||
|
.submit(app);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.current_set = new_set;
|
self.current_set = new_set;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user