Claude: Add shortcut on desktop
This commit is contained in:
parent
466667f800
commit
f7cdbe494c
@ -3,7 +3,6 @@ use std::path::PathBuf;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use crate::installer::validator::*;
|
use crate::installer::validator::*;
|
||||||
use crate::installer::downloader::DownloadManager;
|
use crate::installer::downloader::DownloadManager;
|
||||||
use crate::installer::SevenZDearchiver;
|
|
||||||
use crate::ui::download_progress::download_progress;
|
use crate::ui::download_progress::download_progress;
|
||||||
use crate::ui::game_selection::game_selection;
|
use crate::ui::game_selection::game_selection;
|
||||||
use crate::ui::installation_progress::installation_progress;
|
use crate::ui::installation_progress::installation_progress;
|
||||||
@ -24,7 +23,6 @@ pub enum InstallerState {
|
|||||||
Complete,
|
Complete,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct DownloadState {
|
pub struct DownloadState {
|
||||||
pub progress: f32,
|
pub progress: f32,
|
||||||
@ -281,16 +279,7 @@ impl SinfarInstallerApp<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_installation(&mut self) {
|
pub fn start_installation(&mut self) {
|
||||||
// Use tokio runtime to handle the async installation
|
// Reset state
|
||||||
let install_path = self.install_path.clone().expect("Install path should be set");
|
|
||||||
let ee_exe_path = self.ee_exe_path.clone();
|
|
||||||
let download_state = self.download_state.clone();
|
|
||||||
let progress_state = self.download_state.clone();
|
|
||||||
let eframe_ctx = self.eframe_ctx.clone().expect("eframe context should be set");
|
|
||||||
let runtime = self.runtime.clone();
|
|
||||||
let game_type = self.game_type.clone().expect("Game type should be set");
|
|
||||||
|
|
||||||
// Reset the download state for installation progress
|
|
||||||
if let Ok(mut state) = self.download_state.lock() {
|
if let Ok(mut state) = self.download_state.lock() {
|
||||||
state.progress = 0.0;
|
state.progress = 0.0;
|
||||||
state.completed = false;
|
state.completed = false;
|
||||||
@ -298,6 +287,14 @@ impl SinfarInstallerApp<> {
|
|||||||
state.cancelled = false;
|
state.cancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let install_path = self.install_path.clone().expect("Install path should be set");
|
||||||
|
let ee_exe_path = self.ee_exe_path.clone();
|
||||||
|
let game_type = self.game_type.clone().expect("Game type should be set");
|
||||||
|
let download_state = self.download_state.clone();
|
||||||
|
let progress_state = self.download_state.clone();
|
||||||
|
let eframe_ctx = self.eframe_ctx.clone().expect("eframe context should be set");
|
||||||
|
let runtime = self.runtime.clone();
|
||||||
|
|
||||||
// Create extraction manager with progress callback
|
// Create extraction manager with progress callback
|
||||||
let extractor = crate::installer::extractor::ExtractionManager::new(move |progress: f32, _filename: &str, remaining: std::time::Duration| {
|
let extractor = crate::installer::extractor::ExtractionManager::new(move |progress: f32, _filename: &str, remaining: std::time::Duration| {
|
||||||
if let Ok(mut app_state) = progress_state.lock() {
|
if let Ok(mut app_state) = progress_state.lock() {
|
||||||
@ -315,7 +312,7 @@ impl SinfarInstallerApp<> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(files) = downloaded_files {
|
if let Some(files) = downloaded_files {
|
||||||
let download_state = download_state.clone(); // Clone again for the async block
|
let download_state = download_state.clone();
|
||||||
runtime.spawn(async move {
|
runtime.spawn(async move {
|
||||||
// Try to install the files
|
// Try to install the files
|
||||||
if let Err(e) = extractor.install_all_files(
|
if let Err(e) = extractor.install_all_files(
|
||||||
@ -327,6 +324,29 @@ impl SinfarInstallerApp<> {
|
|||||||
if let Ok(mut app_state) = download_state.lock() {
|
if let Ok(mut app_state) = download_state.lock() {
|
||||||
app_state.error = Some(format!("Installation failed: {}", e));
|
app_state.error = Some(format!("Installation failed: {}", e));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Create shortcut after successful installation
|
||||||
|
let shortcut_result = match game_type {
|
||||||
|
GameType::Diamond => {
|
||||||
|
// For Diamond, point to sinfarx.exe in install path
|
||||||
|
let target = install_path.join("sinfarx.exe");
|
||||||
|
crate::installer::shortcut::create_shortcut(&target, "Sinfar", None)
|
||||||
|
},
|
||||||
|
GameType::EnhancedEdition => {
|
||||||
|
// For EE, point to sinfarx_ee.exe in bin/win32_8181
|
||||||
|
if let Some(ee_path) = ee_exe_path {
|
||||||
|
let target = ee_path.join("bin").join("win32_8181").join("sinfarx_ee.exe");
|
||||||
|
crate::installer::shortcut::create_shortcut(&target, "Sinfar EE", None)
|
||||||
|
} else {
|
||||||
|
Ok(()) // Should never happen as we validate earlier
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(e) = shortcut_result {
|
||||||
|
if let Ok(mut app_state) = download_state.lock() {
|
||||||
|
app_state.error = Some(format!("Failed to create shortcut: {}", e));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Mark as complete on success
|
// Mark as complete on success
|
||||||
if let Ok(mut app_state) = download_state.lock() {
|
if let Ok(mut app_state) = download_state.lock() {
|
||||||
@ -334,6 +354,7 @@ impl SinfarInstallerApp<> {
|
|||||||
app_state.progress = 1.0;
|
app_state.progress = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ impl ExtractionManager {
|
|||||||
|
|
||||||
// Extract main content
|
// Extract main content
|
||||||
info!("Starting extraction of main content");
|
info!("Starting extraction of main content");
|
||||||
//self.extract_7z(content_archive, install_path).await?;
|
self.extract_7z(content_archive, install_path).await?;
|
||||||
|
|
||||||
// Handle game-specific files
|
// Handle game-specific files
|
||||||
info!("Processing game-specific files");
|
info!("Processing game-specific files");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
pub mod shortcut {
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::io::Write;
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
pub fn create_shortcut(
|
pub fn create_shortcut(
|
||||||
target_path: &Path,
|
target_path: &Path,
|
||||||
@ -61,4 +60,3 @@ pub mod shortcut {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user