test: overlay

This commit is contained in:
HorizonCode 2025-07-08 08:45:28 +02:00
parent 4fbce4cd0a
commit 33bd75eeee
2 changed files with 43 additions and 3 deletions

View File

@ -6,6 +6,7 @@ use std::path::PathBuf;
use sysinfo::System;
use tauri::AppHandle;
use tauri::Emitter;
use tauri::Manager;
use tokio::fs;
use tokio::io::AsyncWriteExt;
use tokio::process::Command;
@ -639,3 +640,40 @@ pub fn exit(app: AppHandle) {
pub fn get_platform() -> String {
std::env::consts::OS.to_string()
}
#[tauri::command]
pub fn show_overlay(app: tauri::AppHandle) -> Result<(), String> {
if !app.webview_windows().contains_key("overlay") {
tauri::WebviewWindowBuilder::new(
&app,
"overlay",
tauri::WebviewUrl::App("/overlay".into()),
)
.always_on_top(true)
.transparent(true)
.decorations(false)
.resizable(false)
.minimizable(false)
.fullscreen(true)
.skip_taskbar(true)
.visible(true)
.center()
.build()
.map_err(|e| e.to_string())?;
} else if let Some(overlay) = app.get_webview_window("overlay") {
overlay.show().map_err(|e| e.to_string())?;
}
Ok(())
}
#[tauri::command]
pub fn hide_overlay(app: tauri::AppHandle) -> Result<(), String> {
if app.webview_windows().contains_key("overlay")
&& let Some(overlay) = app.get_webview_window("overlay")
{
overlay.show().map_err(|e| e.to_string())?;
}
Ok(())
}

View File

@ -8,7 +8,7 @@ use crate::commands::{
get_ezpp_launcher_update_files, get_hwid, get_launcher_version, get_osu_release_stream,
get_osu_skin, get_osu_version, get_skins_count, is_osu_running, open_url_in_browser,
replace_ui_files, run_osu, run_osu_updater, set_osu_config_values, set_osu_user_config_values,
valid_osu_folder, get_platform
valid_osu_folder, get_platform, show_overlay, hide_overlay
};
#[cfg_attr(mobile, tauri::mobile_entry_point)]
@ -46,7 +46,9 @@ pub fn run() {
open_url_in_browser,
get_launcher_version,
exit,
get_platform
get_platform,
show_overlay,
hide_overlay
])
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_dialog::init())