mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-07-18 00:07:09 +00:00
fix: remove tray till we find better way to implement it
This commit is contained in:
parent
c2c40e9160
commit
72070cd5d6
|
|
@ -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<bool>,
|
||||
pub custom_editions: Option<Vec<CustomEdition>>,
|
||||
pub profile: Option<String>,
|
||||
pub keep_launcher_open: Option<bool>,
|
||||
pub enable_tray_icon: Option<bool>,
|
||||
pub animations_enabled: Option<bool>,
|
||||
pub vfx_enabled: Option<bool>,
|
||||
pub rpc_enabled: Option<bool>,
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -14,16 +14,12 @@ const SetupView: React.FC<SetupViewProps> = ({ 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<SetupViewProps> = ({ 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<SetupViewProps> = ({ 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<SetupViewProps> = ({ 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<SetupViewProps> = ({ 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<SetupViewProps> = ({ 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<SetupViewProps> = ({ onComplete }) => {
|
|||
<p className="text-lg mb-8 text-white/80">Choose your preferred launcher settings</p>
|
||||
|
||||
<div className="space-y-4 max-w-md mx-auto">
|
||||
<div className="bg-black/50 border-2 border-white/20 p-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="text-left">
|
||||
<p className="text-white font-bold">System Tray Icon</p>
|
||||
<p className="text-xs text-white/60">Keep launcher accessible in system tray</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
playPressSound();
|
||||
setEnableTrayIcon(!enableTrayIcon);
|
||||
}}
|
||||
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" }}
|
||||
>
|
||||
<img
|
||||
src={enableTrayIcon ? "/images/Toggle_Switch_On.png" : "/images/Toggle_Switch_Off.png"}
|
||||
alt="Toggle"
|
||||
className="w-full h-full object-contain"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-black/50 border-2 border-white/20 p-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="text-left">
|
||||
|
|
@ -471,8 +437,8 @@ const SetupView: React.FC<SetupViewProps> = ({ 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" }}
|
||||
>
|
||||
<img
|
||||
|
|
@ -495,8 +461,8 @@ const SetupView: React.FC<SetupViewProps> = ({ 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" }}
|
||||
>
|
||||
<img
|
||||
|
|
@ -507,30 +473,6 @@ const SetupView: React.FC<SetupViewProps> = ({ onComplete }) => {
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-black/50 border-2 border-white/20 p-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="text-left">
|
||||
<p className="text-white font-bold">Keep Launcher Open</p>
|
||||
<p className="text-xs text-white/60">Keep launcher running after game launch</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
playPressSound();
|
||||
setKeepLauncherOpen(!keepLauncherOpen);
|
||||
}}
|
||||
onMouseEnter={() => setFocusIndex(3)}
|
||||
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 === 3 ? "scale-110 shadow-[0_0_8px_rgba(250,204,21,0.6)]" : ""}`}
|
||||
style={{ imageRendering: "pixelated" }}
|
||||
>
|
||||
<img
|
||||
src={keepLauncherOpen ? "/images/Toggle_Switch_On.png" : "/images/Toggle_Switch_Off.png"}
|
||||
alt="Toggle"
|
||||
className="w-full h-full object-contain"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="text-xs mt-6 text-white/60">You can change these later in settings</p>
|
||||
|
|
@ -559,10 +501,8 @@ const SetupView: React.FC<SetupViewProps> = ({ onComplete }) => {
|
|||
<div className="mt-2 pt-2 border-t border-white/20">
|
||||
<p className="text-white text-sm">Customization:</p>
|
||||
<div className="flex flex-wrap gap-2 mt-1">
|
||||
{enableTrayIcon && <span className="text-xs bg-green-600/30 px-2 py-1 border border-green-400">Tray Icon</span>}
|
||||
{enableVfx && <span className="text-xs bg-green-600/30 px-2 py-1 border border-green-400">Visual Effects</span>}
|
||||
{enableDiscordRPC && <span className="text-xs bg-green-600/30 px-2 py-1 border border-green-400">Discord RPC</span>}
|
||||
{keepLauncherOpen && <span className="text-xs bg-green-600/30 px-2 py-1 border border-green-400">Keep Open</span>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<string[]>([]);
|
||||
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]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
||||
return invoke("update_tray_icon", { visible });
|
||||
}
|
||||
|
||||
static onDownloadProgress(callback: (percent: number) => void) {
|
||||
return listen<number>("download-progress", (event) =>
|
||||
callback(event.payload),
|
||||
|
|
|
|||
Loading…
Reference in a new issue