From 72070cd5d6e5b5b431cc7d6cd57451c812b90f8c Mon Sep 17 00:00:00 2001 From: KayJann Date: Mon, 6 Apr 2026 14:52:04 +0200 Subject: [PATCH] fix: remove tray till we find better way to implement it --- src-tauri/src/lib.rs | 65 +--------------------- src/components/views/SettingsView.tsx | 58 +++++-------------- src/components/views/SetupView.tsx | 80 ++++----------------------- src/context/LauncherContext.tsx | 24 ++++++-- src/hooks/useAppConfig.ts | 48 ++++++---------- src/hooks/useGameManager.ts | 11 ---- src/services/TauriService.ts | 6 -- 7 files changed, 59 insertions(+), 233 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 41c4113..7843b7d 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -7,8 +7,6 @@ use std::process::Command; use std::process::Stdio; use tauri::{AppHandle, Emitter, State, Manager}; -use tauri::menu::{Menu, MenuItem, MenuEvent}; -use tauri::tray::{TrayIcon, TrayIconBuilder, TrayIconEvent}; use futures_util::StreamExt; use std::sync::Arc; use tokio::sync::Mutex; @@ -51,8 +49,6 @@ pub struct AppConfig { pub apple_silicon_performance_boost: Option, pub custom_editions: Option>, pub profile: Option, - pub keep_launcher_open: Option, - pub enable_tray_icon: Option, pub animations_enabled: Option, pub vfx_enabled: Option, pub rpc_enabled: Option, @@ -189,8 +185,6 @@ fn load_config(app: AppHandle) -> AppConfig { apple_silicon_performance_boost: None, custom_editions: None, profile: Some("legacy_evolved".into()), - keep_launcher_open: None, - enable_tray_icon: Some(true), animations_enabled: Some(true), vfx_enabled: Some(true), rpc_enabled: Some(true), @@ -1262,13 +1256,6 @@ async fn stop_game(#[allow(unused_variables)] app: AppHandle, #[allow(unused_var Ok(()) } -#[tauri::command] -fn update_tray_icon(app: AppHandle, visible: bool) { - if let Some(tray) = app.tray_by_id("main") { - let _ = tray.set_visible(visible); - } -} - #[tauri::command] async fn fetch_skin(username: String) -> Result<(String, String), String> { let client = reqwest::Client::new(); @@ -1305,57 +1292,7 @@ pub fn run() { .plugin(tauri_plugin_gamepad::init()) .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_drpc::init()) - .invoke_handler(tauri::generate_handler![setup_macos_runtime, launch_game, stop_game, check_game_installed, save_config, load_config, download_and_install, open_instance_folder, cancel_download, get_available_runners, get_external_palettes, import_theme, download_runner, delete_instance, update_tray_icon, sync_dlc, fetch_skin, workshop_install]) - .setup(|app| { - let config = load_config(app.handle().clone()); - let visible = config.enable_tray_icon.unwrap_or(true); - - let quit_i = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?; - let show_i = MenuItem::with_id(app, "show", "Show", true, None::<&str>)?; - let menu = Menu::with_items(app, &[&show_i, &quit_i])?; - - let tray = TrayIconBuilder::with_id("main") - .icon(tauri::image::Image::from_bytes(include_bytes!("../icons/32x32.png")).unwrap()) - .tooltip("Emerald Legacy Launcher") - .menu(&menu) - .on_menu_event(|app: &AppHandle, event: MenuEvent| { - match event.id.as_ref() { - "quit" => { - app.exit(0); - } - "show" => { - if let Some(window) = app.get_webview_window("main") { - let _ = window.show(); - let _ = window.set_focus(); - } - } - _ => {} - } - }) - .on_tray_icon_event(|tray: &TrayIcon, event: TrayIconEvent| { - if let TrayIconEvent::Click { button: tauri::tray::MouseButton::Left, .. } = event { - let app = tray.app_handle(); - if let Some(window) = app.get_webview_window("main") { - let _ = window.show(); - let _ = window.set_focus(); - } - } - }) - .build(app)?; - - let _ = tray.set_visible(visible); - - Ok(()) - }) - .on_window_event(|window, event| { - if let tauri::WindowEvent::CloseRequested { api, .. } = event { - let config = load_config(window.app_handle().clone()); - if config.enable_tray_icon.unwrap_or(true) { - api.prevent_close(); - let _ = window.hide(); - } - } - }) + .invoke_handler(tauri::generate_handler![setup_macos_runtime, launch_game, stop_game, check_game_installed, save_config, load_config, download_and_install, open_instance_folder, cancel_download, get_available_runners, get_external_palettes, import_theme, download_runner, delete_instance, sync_dlc, fetch_skin, workshop_install]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/src/components/views/SettingsView.tsx b/src/components/views/SettingsView.tsx index ee6f668..a604f2c 100644 --- a/src/components/views/SettingsView.tsx +++ b/src/components/views/SettingsView.tsx @@ -6,7 +6,7 @@ import { useUI, useConfig, useAudio, useGame } from "../../context/LauncherConte const SettingsView = memo(function SettingsView() { const { setActiveView } = useUI(); - const { vfxEnabled, setVfxEnabled, animationsEnabled, setAnimationsEnabled, musicVol: musicVolume, setMusicVol: setMusicVolume, sfxVol: sfxVolume, setSfxVol: setSfxVolume, layout, setLayout, linuxRunner, setLinuxRunner, perfBoost, setPerfBoost, rpcEnabled, setRpcEnabled, legacyMode, setLegacyMode, keepLauncherOpen, setKeepLauncherOpen, enableTrayIcon, setEnableTrayIcon } = useConfig(); + const { vfxEnabled, setVfxEnabled, animationsEnabled, setAnimationsEnabled, musicVol: musicVolume, setMusicVol: setMusicVolume, sfxVol: sfxVolume, setSfxVol: setSfxVolume, layout, setLayout, linuxRunner, setLinuxRunner, perfBoost, setPerfBoost, rpcEnabled, setRpcEnabled, legacyMode, setLegacyMode } = useConfig(); const { currentTrack, setCurrentTrack, tracks, playPressSound, playBackSound } = useAudio(); const { isGameRunning, stopGame, isRunnerDownloading, runnerDownloadProgress, downloadRunner } = useGame(); const { isLinux, isMac } = usePlatform(); @@ -53,16 +53,6 @@ const SettingsView = memo(function SettingsView() { setLegacyMode(!legacyMode); }; - const handleKeepOpenToggle = () => { - playPressSound(); - setKeepLauncherOpen(!keepLauncherOpen); - }; - - const handleTrayToggle = () => { - playPressSound(); - setEnableTrayIcon(!enableTrayIcon); - }; - const handleRunnerToggle = () => { playPressSound(); if (runners.length === 0) return; @@ -291,19 +281,6 @@ const SettingsView = memo(function SettingsView() { type: "button", onClick: handleLegacyToggle, }); - items.push({ - id: "keep_open", - label: `Keep Launcher Open: ${keepLauncherOpen ? "ON" : "OFF"}`, - type: "button", - onClick: handleKeepOpenToggle, - }); - items.push({ - id: "tray_icon", - label: `Tray Icon: ${enableTrayIcon ? "ON" : "OFF"}`, - type: "button", - onClick: handleTrayToggle, - }); - if (isLinux) { items.push({ id: "runner", @@ -311,22 +288,19 @@ const SettingsView = memo(function SettingsView() { type: "button", onClick: handleRunnerToggle, }); - - if (runners.length === 0 || runners.every(r => r.type !== 'proton')) { - items.push({ - id: "download_runner", - label: isRunnerDownloading - ? `Downloading Runner... ${Math.floor(runnerDownloadProgress || 0)}%` - : "Download GE-Proton (Recommended)", - type: "button", - onClick: () => { - if (!isRunnerDownloading) { - downloadRunner("GE-Proton9-25", "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton9-25/GE-Proton9-25.tar.gz"); - } - }, - small: true, - }); - } + items.push({ + id: "download_runner", + label: isRunnerDownloading + ? `Downloading Runner... ${Math.floor(runnerDownloadProgress || 0)}%` + : "Download GE-Proton (Recommended)", + type: "button", + onClick: () => { + if (!isRunnerDownloading) { + downloadRunner("GE-Proton9-25", "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton9-25/GE-Proton9-25.tar.gz"); + } + }, + small: true, + }); } items.push({ @@ -374,8 +348,6 @@ const SettingsView = memo(function SettingsView() { rpcEnabled, legacyMode, animationsEnabled, - keepLauncherOpen, - enableTrayIcon, layout, isLinux, selectedRunnerName, @@ -389,8 +361,6 @@ const SettingsView = memo(function SettingsView() { handleRpcToggle, handleLegacyToggle, handleAnimationsToggle, - handleKeepOpenToggle, - handleTrayToggle, handleLayoutToggle, handleRunnerToggle, handlePerfToggle, diff --git a/src/components/views/SetupView.tsx b/src/components/views/SetupView.tsx index 7e5b19c..88ce0dd 100644 --- a/src/components/views/SetupView.tsx +++ b/src/components/views/SetupView.tsx @@ -14,16 +14,12 @@ const SetupView: React.FC = ({ onComplete }) => { username, setUsername, setHasCompletedSetup, profile, - setEnableTrayIcon: setConfigTray, setVfxEnabled: setConfigVfx, setRpcEnabled: setConfigRpc, - setKeepLauncherOpen: setConfigKeepOpen, setLinuxRunner, linuxRunner: configLinuxRunner, vfxEnabled: configVfx, - enableTrayIcon: configTray, rpcEnabled: configRpc, - keepLauncherOpen: configKeepOpen } = useConfig(); const { playPressSound, playSfx } = useAudio(); @@ -39,10 +35,8 @@ const SetupView: React.FC = ({ onComplete }) => { const [setupProgress, setSetupProgress] = useState<{ stage: string; message: string; percent?: number } | null>(null); const [runtimeAlreadyInstalled, setRuntimeAlreadyInstalled] = useState(false); - const [enableTrayIcon, setEnableTrayIcon] = useState(configTray); const [enableVfx, setEnableVfx] = useState(configVfx); const [enableDiscordRPC, setEnableDiscordRPC] = useState(configRpc); - const [keepLauncherOpen, setKeepLauncherOpen] = useState(configKeepOpen); const totalSteps = isLinux ? 4 : 4; @@ -121,10 +115,8 @@ const SetupView: React.FC = ({ onComplete }) => { setCurrentStep(2); setFocusIndex(0); } else if (currentStep === 2) { - setConfigTray(enableTrayIcon); setConfigVfx(enableVfx); setConfigRpc(enableDiscordRPC); - setConfigKeepOpen(keepLauncherOpen); setCurrentStep(3); setFocusIndex(0); @@ -152,7 +144,7 @@ const SetupView: React.FC = ({ onComplete }) => { if (isLinux) count = runners.length + 2; // Runners, Back, Next else if (isMac) count = 3; // Install, Back, Next else count = 2; // Back, Next - } else if (currentStep === 2) count = 6; // 4 Toggles, Back, Next + } else if (currentStep === 2) count = 4; // 2 Toggles, Back, Next else if (currentStep === 3) count = 2; // Back, Finish if (e.key === "ArrowDown" || e.key === "Tab") { @@ -180,12 +172,10 @@ const SetupView: React.FC = ({ onComplete }) => { else if (focusIndex === 1) handleNext(); } } else if (currentStep === 2) { - if (focusIndex === 0) { setEnableTrayIcon(!enableTrayIcon); playPressSound(); } - else if (focusIndex === 1) { setEnableVfx(!enableVfx); playPressSound(); } - else if (focusIndex === 2) { setEnableDiscordRPC(!enableDiscordRPC); playPressSound(); } - else if (focusIndex === 3) { setKeepLauncherOpen(!keepLauncherOpen); playPressSound(); } - else if (focusIndex === 4) handleBack(); - else if (focusIndex === 5) handleNext(); + if (focusIndex === 0) { setEnableVfx(!enableVfx); playPressSound(); } + else if (focusIndex === 1) { setEnableDiscordRPC(!enableDiscordRPC); playPressSound(); } + else if (focusIndex === 2) handleBack(); + else if (focusIndex === 3) handleNext(); } else if (currentStep === 3) { if (focusIndex === 0) handleBack(); else if (focusIndex === 1) handleNext(); @@ -194,7 +184,7 @@ const SetupView: React.FC = ({ onComplete }) => { }; window.addEventListener("keydown", handleKey); return () => window.removeEventListener("keydown", handleKey); - }, [currentStep, focusIndex, runners, enableTrayIcon, enableVfx, enableDiscordRPC, keepLauncherOpen, isLinux, isMac, tempUsername]); + }, [currentStep, focusIndex, runners, enableVfx, enableDiscordRPC, isLinux, isMac, tempUsername]); const handleMacosSetup = async () => { playPressSound(); @@ -436,30 +426,6 @@ const SetupView: React.FC = ({ onComplete }) => {

Choose your preferred launcher settings

-
-
-
-

System Tray Icon

-

Keep launcher accessible in system tray

-
- -
-
-
@@ -471,8 +437,8 @@ const SetupView: React.FC = ({ onComplete }) => { playPressSound(); setEnableVfx(!enableVfx); }} - onMouseEnter={() => setFocusIndex(1)} - className={`w-12 h-6 outline-none border-none bg-transparent transition-all duration-200 hover:border-yellow-400 hover:shadow-[0_0_8px_rgba(250,204,21,0.3)] ${focusIndex === 1 ? "scale-110 shadow-[0_0_8px_rgba(250,204,21,0.6)]" : ""}`} + onMouseEnter={() => setFocusIndex(0)} + className={`w-12 h-6 outline-none border-none bg-transparent transition-all duration-200 hover:border-yellow-400 hover:shadow-[0_0_8px_rgba(250,204,21,0.3)] ${focusIndex === 0 ? "scale-110 shadow-[0_0_8px_rgba(250,204,21,0.6)]" : ""}`} style={{ imageRendering: "pixelated" }} > = ({ onComplete }) => { playPressSound(); setEnableDiscordRPC(!enableDiscordRPC); }} - onMouseEnter={() => setFocusIndex(2)} - className={`w-12 h-6 outline-none border-none bg-transparent transition-all duration-200 hover:border-yellow-400 hover:shadow-[0_0_8px_rgba(250,204,21,0.3)] ${focusIndex === 2 ? "scale-110 shadow-[0_0_8px_rgba(250,204,21,0.6)]" : ""}`} + onMouseEnter={() => setFocusIndex(1)} + className={`w-12 h-6 outline-none border-none bg-transparent transition-all duration-200 hover:border-yellow-400 hover:shadow-[0_0_8px_rgba(250,204,21,0.3)] ${focusIndex === 1 ? "scale-110 shadow-[0_0_8px_rgba(250,204,21,0.6)]" : ""}`} style={{ imageRendering: "pixelated" }} > = ({ onComplete }) => {
- -
-
-
-

Keep Launcher Open

-

Keep launcher running after game launch

-
- -
-

You can change these later in settings

@@ -559,10 +501,8 @@ const SetupView: React.FC = ({ onComplete }) => {

Customization:

- {enableTrayIcon && Tray Icon} {enableVfx && Visual Effects} {enableDiscordRPC && Discord RPC} - {keepLauncherOpen && Keep Open}
diff --git a/src/context/LauncherContext.tsx b/src/context/LauncherContext.tsx index 94c8544..11bcb81 100644 --- a/src/context/LauncherContext.tsx +++ b/src/context/LauncherContext.tsx @@ -52,7 +52,6 @@ export function LauncherProvider({ children }: { children: React.ReactNode }) { setProfile: configRaw.setProfile, customEditions: configRaw.customEditions, setCustomEditions: configRaw.setCustomEditions, - keepLauncherOpen: configRaw.keepLauncherOpen, }); const skinSync = useSkinSync({ profile: configRaw.profile, editions: gameRaw.editions }); const audioRaw = useAudioController({ @@ -67,8 +66,7 @@ export function LauncherProvider({ children }: { children: React.ReactNode }) { configRaw.username, configRaw.theme, configRaw.layout, configRaw.vfxEnabled, configRaw.rpcEnabled, configRaw.musicVol, configRaw.sfxVol, configRaw.isDayTime, configRaw.profile, configRaw.linuxRunner, configRaw.perfBoost, configRaw.customEditions, - configRaw.legacyMode, configRaw.keepLauncherOpen, configRaw.enableTrayIcon, - configRaw.animationsEnabled + configRaw.legacyMode, configRaw.animationsEnabled ]); const game = useMemo(() => gameRaw, [ @@ -113,12 +111,26 @@ export function LauncherProvider({ children }: { children: React.ReactNode }) { useEffect(() => { if (config.isLoaded) { - config.saveConfig(skinSync.skinBase64); + TauriService.saveConfig({ + username: config.username, + skinBase64: skinSync.skinBase64 || undefined, + themeStyleId: config.theme, + linuxRunner: config.linuxRunner, + appleSiliconPerformanceBoost: config.perfBoost, + profile: config.profile, + customEditions: config.customEditions, + animationsEnabled: config.animationsEnabled, + vfxEnabled: config.vfxEnabled, + rpcEnabled: config.rpcEnabled, + musicVol: config.musicVol, + sfxVol: config.sfxVol, + legacyMode: config.legacyMode, + }).catch(console.error); } }, [ config.username, skinSync.skinBase64, config.theme, config.linuxRunner, - config.perfBoost, config.customEditions, config.profile, config.keepLauncherOpen, - config.enableTrayIcon, config.vfxEnabled, config.animationsEnabled, + config.perfBoost, config.customEditions, config.profile, + config.vfxEnabled, config.animationsEnabled, config.rpcEnabled, config.musicVol, config.sfxVol, config.legacyMode, config.isLoaded ]); diff --git a/src/hooks/useAppConfig.ts b/src/hooks/useAppConfig.ts index 478d2a8..d698af3 100644 --- a/src/hooks/useAppConfig.ts +++ b/src/hooks/useAppConfig.ts @@ -1,4 +1,4 @@ -import { useState, useEffect, useCallback } from "react"; +import { useState, useEffect } from "react"; import { useLocalStorage } from "./useLocalStorage"; import { TauriService } from "../services/TauriService"; @@ -14,8 +14,6 @@ export function useAppConfig() { const [isDayTime, setIsDayTime] = useLocalStorage("lce-daytime", true); const [profile, setProfile] = useLocalStorage("lce-profile", "legacy_evolved"); const [legacyMode, setLegacyMode] = useLocalStorage("lce-legacy-mode", false); - const [keepLauncherOpen, setKeepLauncherOpen] = useLocalStorage("lce-keep-open", false); - const [enableTrayIcon, setEnableTrayIcon] = useLocalStorage("lce-tray-icon", true); const [hasCompletedSetup, setHasCompletedSetup] = useLocalStorage("lce-setup-completed", false); const [isLoaded, setIsLoaded] = useState(false); @@ -32,8 +30,6 @@ export function useAppConfig() { setPerfBoost(config.appleSiliconPerformanceBoost); if (config.customEditions) setCustomEditions(config.customEditions); if (config.profile) setProfile(config.profile); - if (config.keepLauncherOpen !== undefined) setKeepLauncherOpen(config.keepLauncherOpen); - if (config.enableTrayIcon !== undefined) setEnableTrayIcon(config.enableTrayIcon); if (config.vfxEnabled !== undefined) setVfxEnabled(config.vfxEnabled); if (config.animationsEnabled !== undefined) setAnimationsEnabled(config.animationsEnabled); if (config.rpcEnabled !== undefined) setRpcEnabled(config.rpcEnabled); @@ -46,29 +42,22 @@ export function useAppConfig() { useEffect(() => { if (isLoaded) { - TauriService.updateTrayIcon(enableTrayIcon); + TauriService.saveConfig({ + username, + themeStyleId: theme, + linuxRunner, + appleSiliconPerformanceBoost: perfBoost, + profile, + customEditions, + animationsEnabled, + vfxEnabled, + rpcEnabled, + musicVol, + sfxVol, + legacyMode, + }).catch(console.error); } - }, [enableTrayIcon, isLoaded]); - - const saveConfig = useCallback((skinBase64?: string | null) => { - TauriService.saveConfig({ - username, - skinBase64: skinBase64 || undefined, - themeStyleId: theme, - linuxRunner, - appleSiliconPerformanceBoost: perfBoost, - profile, - customEditions, - keepLauncherOpen, - enableTrayIcon, - animationsEnabled, - vfxEnabled, - rpcEnabled, - musicVol, - sfxVol, - legacyMode, - }).catch(console.error); - }, [username, theme, linuxRunner, perfBoost, profile, customEditions, keepLauncherOpen, enableTrayIcon, animationsEnabled, vfxEnabled, rpcEnabled, musicVol, sfxVol, legacyMode]); + }, [username, theme, linuxRunner, perfBoost, profile, customEditions, animationsEnabled, vfxEnabled, rpcEnabled, musicVol, sfxVol, legacyMode, isLoaded]); return { username, @@ -91,10 +80,6 @@ export function useAppConfig() { setIsDayTime, legacyMode, setLegacyMode, - keepLauncherOpen, - setKeepLauncherOpen, - enableTrayIcon, - setEnableTrayIcon, profile, setProfile, linuxRunner, @@ -106,6 +91,5 @@ export function useAppConfig() { isLoaded, hasCompletedSetup, setHasCompletedSetup, - saveConfig, }; } diff --git a/src/hooks/useGameManager.ts b/src/hooks/useGameManager.ts index 86a4475..abfc857 100644 --- a/src/hooks/useGameManager.ts +++ b/src/hooks/useGameManager.ts @@ -1,9 +1,6 @@ import { useState, useEffect, useCallback, useMemo } from "react"; -import { getCurrentWindow } from "@tauri-apps/api/window"; import { TauriService } from "../services/TauriService"; -const appWindow = getCurrentWindow(); - const BASE_EDITIONS = [ { id: "legacy_evolved", @@ -52,7 +49,6 @@ interface GameManagerProps { setProfile: (id: string) => void; customEditions: any[]; setCustomEditions: (editions: any[]) => void; - keepLauncherOpen: boolean; } export function useGameManager({ @@ -60,7 +56,6 @@ export function useGameManager({ setProfile, customEditions, setCustomEditions, - keepLauncherOpen, }: GameManagerProps) { const [installs, setInstalls] = useState([]); const [isGameRunning, setIsGameRunning] = useState(false); @@ -162,9 +157,6 @@ export function useGameManager({ setError(null); setIsGameRunning(true); try { - if (!keepLauncherOpen) { - await appWindow.hide(); - } await TauriService.launchGame(profile, PARTNERSHIP_SERVERS); } catch (e: any) { console.error(e); @@ -173,9 +165,6 @@ export function useGameManager({ ); } finally { setIsGameRunning(false); - await appWindow.show(); - await appWindow.unminimize(); - await appWindow.setFocus(); } }, [isGameRunning, profile]); diff --git a/src/services/TauriService.ts b/src/services/TauriService.ts index e922465..2856929 100644 --- a/src/services/TauriService.ts +++ b/src/services/TauriService.ts @@ -30,8 +30,6 @@ export interface AppConfig { appleSiliconPerformanceBoost?: boolean; customEditions?: CustomEdition[]; profile?: string; - keepLauncherOpen?: boolean; - enableTrayIcon?: boolean; animationsEnabled?: boolean; vfxEnabled?: boolean; rpcEnabled?: boolean; @@ -130,10 +128,6 @@ export class TauriService { return invoke("workshop_install", { request: { instanceId, packageId, zips } }); } - static async updateTrayIcon(visible: boolean): Promise { - return invoke("update_tray_icon", { visible }); - } - static onDownloadProgress(callback: (percent: number) => void) { return listen("download-progress", (event) => callback(event.payload),