Add downloading mod manager

This commit is contained in:
Lncvrt committed 2026-03-13 18:31:52 -07:00
1 parent e8dec1a1b2
commit 874f0627f7
4 files changed
+53 -19

No files matched your search

+15 -11
View File
@@ -38,7 +38,6 @@ fn is_cancelled(name: &str) -> bool {
cancel_map().get(name).map(|v| *v).unwrap_or(false) cancel_map().get(name).map(|v| *v).unwrap_or(false)
} }
#[allow(unused)]
fn is_running_by_path(path: &Path) -> bool { fn is_running_by_path(path: &Path) -> bool {
let sys = System::new_all(); let sys = System::new_all();
let target = match path.canonicalize() { let target = match path.canonicalize() {
@@ -143,14 +142,13 @@ fn folder_size(app: AppHandle, version: String) -> String {
} }
} }
#[allow(unused_variables)]
#[tauri::command] #[tauri::command]
async fn download( async fn download(
app: AppHandle, app: AppHandle,
url: String, url: String,
name: String, name: String,
executable: String,
hash: String, hash: String,
download_type: i8
) -> String { ) -> String {
println!("[download] Starting download for '{}' from '{}'", name, url); println!("[download] Starting download for '{}' from '{}'", name, url);
let _ = app.emit("download-start", format!("{}", name)); let _ = app.emit("download-start", format!("{}", name));
@@ -267,14 +265,16 @@ async fn download(
} }
} }
} else { } else {
if let Ok(true) = tokio::fs::try_exists(&game_path.join(&name)).await { if download_type == 0 {
println!( if let Ok(true) = tokio::fs::try_exists(&game_path.join(&name)).await {
"[download] Existing game dir found, removing: {:?}", println!(
game_path.join(&name) "[download] Existing game dir found, removing: {:?}",
); game_path.join(&name)
let _ = tokio::fs::remove_dir_all(&game_path.join(&name)).await; );
let _ = tokio::fs::remove_dir_all(&game_path.join(&name)).await;
}
let _ = tokio::fs::create_dir_all(&game_path.join(&name)).await;
} }
let _ = tokio::fs::create_dir_all(&game_path.join(&name)).await;
match tokio::fs::File::create(&download_part_path).await { match tokio::fs::File::create(&download_part_path).await {
Ok(f) => { Ok(f) => {
@@ -463,7 +463,11 @@ async fn download(
let unzip_res = unzip_to_dir( let unzip_res = unzip_to_dir(
app.clone(), app.clone(),
download_zip_path.clone(), download_zip_path.clone(),
game_path.join(&name), if download_type == 2 {
game_path.join(&name).join("BepInEx").join("plugins")
} else {
game_path.join(&name)
},
name.clone(), name.clone(),
) )
.await; .await;
+26 -1
View File
@@ -360,7 +360,32 @@ export default function Installs () {
<button <button
className='absolute right-0 bottom-0 button' className='absolute right-0 bottom-0 button'
title='Click to manage mods for this game!' title='Click to manage mods for this game!'
onClick={e => e.stopPropagation()} onClick={async e => {
e.stopPropagation()
if (
!(await exists('game/' + entry + '/BepInEx', {
baseDir: BaseDirectory.AppLocalData
}))
) {
if (
await ask(
"You don't have BepInEx (the mod loader for Unity Games), would you like to install it now? It is about 1MB in size. If you choose yes, it will download the recommended BepInEx version for " +
getVersionInfo(entry)?.displayName +
'.',
{ title: 'BepInEx not found!', kind: 'error' }
)
) {
downloadVersions([
{
id: entry,
type: 1
}
])
}
return
}
}}
hidden={!getVersionInfo(entry)?.modSupportDownload} hidden={!getVersionInfo(entry)?.modSupportDownload}
> >
Mod Manager Mod Manager
+11 -7
View File
@@ -411,6 +411,8 @@ export default function RootLayout ({
setIsProcessingQueue(true) setIsProcessingQueue(true)
const versionId = downloadQueue[0] const versionId = downloadQueue[0]
const downloadInfo = downloadProgress.find(d => d.version == versionId)
if (!downloadInfo) return
const info = getVersionInfo(versionId) const info = getVersionInfo(versionId)
if (!info) { if (!info) {
@@ -433,10 +435,11 @@ export default function RootLayout ({
) )
const downloadInfoRequest = await fetch( const downloadInfoRequest = await fetch(
'https://games.lncvrt.xyz/api/launcher/download?gameId=' + 'https://games.lncvrt.xyz/api/launcher/download' +
info.id + (downloadInfo.type == 0
'&downloadId=' + ? '?gameId=' + info.id + '&downloadId=' + info.download
info.download : '?downloadId=' +
(downloadInfo.type == 1 ? info.modSupportDownload : ''))
) )
const signature = downloadInfoRequest.headers.get('x-signature') ?? '' const signature = downloadInfoRequest.headers.get('x-signature') ?? ''
const data = await downloadInfoRequest.json() const data = await downloadInfoRequest.json()
@@ -468,7 +471,7 @@ export default function RootLayout ({
? { ? {
...d, ...d,
url: data.data.url, url: data.data.url,
executable: info.executable, executable: downloadInfo.type == 0 ? info.executable : null,
hash: data.data.hash hash: data.data.hash
} }
: d : d
@@ -478,8 +481,8 @@ export default function RootLayout ({
const res = await invoke<string>('download', { const res = await invoke<string>('download', {
url: data.data.url, url: data.data.url,
name: info.id, name: info.id,
executable: info.executable, hash: data.data.hash,
hash: data.data.hash downloadType: downloadInfo.type
}) })
if (res === '1') { if (res === '1') {
@@ -542,6 +545,7 @@ export default function RootLayout ({
isProcessingQueue, isProcessingQueue,
getVersionInfo, getVersionInfo,
getGameInfo, getGameInfo,
downloadProgress,
normalConfig normalConfig
]) ])
+1
View File
@@ -171,6 +171,7 @@ export default function DownloadsPopup () {
</div> </div>
</div> </div>
<p className='text-2xl text-center'> <p className='text-2xl text-center'>
{v.type == 1 ? 'Mod Manager for ' : null}{' '}
{getVersionInfo(v.version)?.displayName} {getVersionInfo(v.version)?.displayName}
</p> </p>
<div className='mt-6.25 flex items-center justify-between'> <div className='mt-6.25 flex items-center justify-between'>