2 Commits

2 changed files with 46 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ use std::path::PathBuf;
use sysinfo::System; use sysinfo::System;
use tauri::AppHandle; use tauri::AppHandle;
use tauri::Emitter; use tauri::Emitter;
use tauri::Manager;
use tokio::fs; use tokio::fs;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use tokio::process::Command; use tokio::process::Command;
@@ -640,6 +641,43 @@ pub fn get_platform() -> String {
std::env::consts::OS.to_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(())
}
#[tauri::command] #[tauri::command]
pub async fn check_for_corruption(folder: String) -> Result<bool, String> { pub async fn check_for_corruption(folder: String) -> Result<bool, String> {
let osu_path = PathBuf::from(folder); let osu_path = PathBuf::from(folder);

View File

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