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)
}
#[allow(unused)]
fn is_running_by_path(path: &Path) -> bool {
let sys = System::new_all();
let target = match path.canonicalize() {
@@ -143,14 +142,13 @@ fn folder_size(app: AppHandle, version: String) -> String {
}
}
#[allow(unused_variables)]
#[tauri::command]
async fn download(
app: AppHandle,
url: String,
name: String,
executable: String,
hash: String,
download_type: i8
) -> String {
println!("[download] Starting download for '{}' from '{}'", name, url);
let _ = app.emit("download-start", format!("{}", name));
@@ -267,14 +265,16 @@ async fn download(
}
}
} else {
if let Ok(true) = tokio::fs::try_exists(&game_path.join(&name)).await {
println!(
"[download] Existing game dir found, removing: {:?}",
game_path.join(&name)
);
let _ = tokio::fs::remove_dir_all(&game_path.join(&name)).await;
if download_type == 0 {
if let Ok(true) = tokio::fs::try_exists(&game_path.join(&name)).await {
println!(
"[download] Existing game dir found, removing: {:?}",
game_path.join(&name)
);
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 {
Ok(f) => {
@@ -463,7 +463,11 @@ async fn download(
let unzip_res = unzip_to_dir(
app.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(),
)
.await;
+26 -1
View File
@@ -360,7 +360,32 @@ export default function Installs () {
<button
className='absolute right-0 bottom-0 button'
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}
>
Mod Manager
+11 -7
View File
@@ -411,6 +411,8 @@ export default function RootLayout ({
setIsProcessingQueue(true)
const versionId = downloadQueue[0]
const downloadInfo = downloadProgress.find(d => d.version == versionId)
if (!downloadInfo) return
const info = getVersionInfo(versionId)
if (!info) {
@@ -433,10 +435,11 @@ export default function RootLayout ({
)
const downloadInfoRequest = await fetch(
'https://games.lncvrt.xyz/api/launcher/download?gameId=' +
info.id +
'&downloadId=' +
info.download
'https://games.lncvrt.xyz/api/launcher/download' +
(downloadInfo.type == 0
? '?gameId=' + info.id + '&downloadId=' + info.download
: '?downloadId=' +
(downloadInfo.type == 1 ? info.modSupportDownload : ''))
)
const signature = downloadInfoRequest.headers.get('x-signature') ?? ''
const data = await downloadInfoRequest.json()
@@ -468,7 +471,7 @@ export default function RootLayout ({
? {
...d,
url: data.data.url,
executable: info.executable,
executable: downloadInfo.type == 0 ? info.executable : null,
hash: data.data.hash
}
: d
@@ -478,8 +481,8 @@ export default function RootLayout ({
const res = await invoke<string>('download', {
url: data.data.url,
name: info.id,
executable: info.executable,
hash: data.data.hash
hash: data.data.hash,
downloadType: downloadInfo.type
})
if (res === '1') {
@@ -542,6 +545,7 @@ export default function RootLayout ({
isProcessingQueue,
getVersionInfo,
getGameInfo,
downloadProgress,
normalConfig
])
+1
View File
@@ -171,6 +171,7 @@ export default function DownloadsPopup () {
</div>
</div>
<p className='text-2xl text-center'>
{v.type == 1 ? 'Mod Manager for ' : null}{' '}
{getVersionInfo(v.version)?.displayName}
</p>
<div className='mt-6.25 flex items-center justify-between'>