mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-17 01:24:36 +01:00
Compare commits
6 Commits
v1.0.6-alp
...
v1.0.7-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa38a22117 | ||
|
|
a7914406b4 | ||
|
|
57c1a7800c | ||
|
|
9426937a62 | ||
|
|
96d69d9ff6 | ||
|
|
defc1b43bd |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cultivation",
|
"name": "cultivation",
|
||||||
"version": "1.0.6",
|
"version": "1.0.7",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/api": "^1.0.0-rc.5",
|
"@tauri-apps/api": "^1.0.0-rc.5",
|
||||||
|
|||||||
41
src-tauri/Cargo.lock
generated
41
src-tauri/Cargo.lock
generated
@@ -26,6 +26,17 @@ dependencies = [
|
|||||||
"opaque-debug",
|
"opaque-debug",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ahash"
|
||||||
|
version = "0.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom 0.2.7",
|
||||||
|
"once_cell",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.18"
|
version = "0.7.18"
|
||||||
@@ -725,6 +736,7 @@ dependencies = [
|
|||||||
"regex",
|
"regex",
|
||||||
"registry",
|
"registry",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"rust-ini",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -888,6 +900,12 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dlv-list"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dtoa"
|
name = "dtoa"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
@@ -1481,6 +1499,9 @@ name = "hashbrown"
|
|||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
|
dependencies = [
|
||||||
|
"ahash",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
@@ -2451,6 +2472,16 @@ dependencies = [
|
|||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ordered-multimap"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a"
|
||||||
|
dependencies = [
|
||||||
|
"dlv-list",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "os_info"
|
name = "os_info"
|
||||||
version = "3.4.0"
|
version = "3.4.0"
|
||||||
@@ -3223,6 +3254,16 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rust-ini"
|
||||||
|
version = "0.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"ordered-multimap",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-serialize"
|
name = "rustc-serialize"
|
||||||
version = "0.3.24"
|
version = "0.3.24"
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ regex = "1"
|
|||||||
|
|
||||||
# other
|
# other
|
||||||
file_diff = "1.0.0"
|
file_diff = "1.0.0"
|
||||||
|
rust-ini = "0.18.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# by default Tauri runs in production mode
|
# by default Tauri runs in production mode
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ pub async fn get_download_links(mod_id: String) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn list_submissions(mode: String) -> String {
|
pub async fn list_submissions(mode: String, page: String) -> String {
|
||||||
let res = web::query(
|
let res = web::query(
|
||||||
format!(
|
format!(
|
||||||
"{}/apiv9/Util/Game/Submissions?_idGameRow=8552&_nPage=1&_nPerpage=50&_sMode={}",
|
"{}/apiv9/Util/Game/Submissions?_idGameRow=8552&_nPage={}&_nPerpage=50&_sMode={}",
|
||||||
SITE_URL, mode
|
SITE_URL, page, mode
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ fn main() {
|
|||||||
system_helpers::open_in_browser,
|
system_helpers::open_in_browser,
|
||||||
system_helpers::install_location,
|
system_helpers::install_location,
|
||||||
system_helpers::is_elevated,
|
system_helpers::is_elevated,
|
||||||
|
system_helpers::set_migoto_target,
|
||||||
proxy::set_proxy_addr,
|
proxy::set_proxy_addr,
|
||||||
proxy::generate_ca_files,
|
proxy::generate_ca_files,
|
||||||
unzip::unzip,
|
unzip::unzip,
|
||||||
@@ -94,7 +95,7 @@ fn enable_process_watcher(window: tauri::Window, process: String) {
|
|||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
// Initial sleep for 8 seconds, since running 20 different injectors or whatever can take a while
|
// Initial sleep for 8 seconds, since running 20 different injectors or whatever can take a while
|
||||||
std::thread::sleep(std::time::Duration::from_secs(8));
|
std::thread::sleep(std::time::Duration::from_secs(10));
|
||||||
|
|
||||||
let mut system = System::new_all();
|
let mut system = System::new_all();
|
||||||
|
|
||||||
@@ -197,7 +198,8 @@ async fn get_bg_file(bg_path: String, appdata: String) -> String {
|
|||||||
let response_data: APIQuery = match serde_json::from_str(&query) {
|
let response_data: APIQuery = match serde_json::from_str(&query) {
|
||||||
Ok(data) => data,
|
Ok(data) => data,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Failed to parse response: {}", e);
|
println!("Failed to get bg file response: {}", e);
|
||||||
|
println!("^ please stop reporting this as an error it's so annoying LMFAO");
|
||||||
return "".to_string();
|
return "".to_string();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
use duct::cmd;
|
use duct::cmd;
|
||||||
|
use ini::Ini;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn run_program(path: String, args: Option<String>) {
|
pub fn run_program(path: String, args: Option<String>) {
|
||||||
@@ -88,6 +90,43 @@ pub fn install_location() -> String {
|
|||||||
return exe_path.to_str().unwrap().to_string();
|
return exe_path.to_str().unwrap().to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn set_migoto_target(path: String, migoto_path: String) -> bool {
|
||||||
|
let pathbuf = PathBuf::from(path);
|
||||||
|
let mut migoto_pathbuf = PathBuf::from(migoto_path);
|
||||||
|
|
||||||
|
migoto_pathbuf.pop();
|
||||||
|
migoto_pathbuf.push("d3dx.ini");
|
||||||
|
|
||||||
|
let mut conf = match Ini::load_from_file(&migoto_pathbuf) {
|
||||||
|
Ok(c) => {
|
||||||
|
println!("Loaded migoto ini");
|
||||||
|
c
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("Error loading migoto config: {}", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set options
|
||||||
|
conf
|
||||||
|
.with_section(Some("Loader"))
|
||||||
|
.set("target", pathbuf.to_str().unwrap());
|
||||||
|
|
||||||
|
// Write file
|
||||||
|
match conf.write_to_file(&migoto_pathbuf) {
|
||||||
|
Ok(_) => {
|
||||||
|
println!("Wrote config!");
|
||||||
|
true
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("Error writing config: {}", e);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn is_elevated() -> bool {
|
pub fn is_elevated() -> bool {
|
||||||
|
|||||||
@@ -64,27 +64,16 @@ pub fn unzip(
|
|||||||
println!("Is rar file? {}", zipfile.ends_with(".rar"));
|
println!("Is rar file? {}", zipfile.ends_with(".rar"));
|
||||||
|
|
||||||
let name;
|
let name;
|
||||||
|
let success;
|
||||||
|
|
||||||
// If file ends in zip, OR is unknown, extract as zip, otherwise extract as rar
|
// If file ends in zip, OR is unknown, extract as zip, otherwise extract as rar
|
||||||
if zipfile.ends_with(".rar") {
|
if zipfile.ends_with(".rar") {
|
||||||
extract_rar(
|
success = extract_rar(&zipfile, &f, &full_path, top_level.unwrap_or(true));
|
||||||
&window,
|
|
||||||
&zipfile,
|
|
||||||
&f,
|
|
||||||
&full_path,
|
|
||||||
top_level.unwrap_or(false),
|
|
||||||
);
|
|
||||||
|
|
||||||
let archive = Archive::new(zipfile.clone());
|
let archive = Archive::new(zipfile.clone());
|
||||||
name = archive.list().unwrap().next().unwrap().unwrap().filename;
|
name = archive.list().unwrap().next().unwrap().unwrap().filename;
|
||||||
} else {
|
} else {
|
||||||
extract_zip(
|
success = extract_zip(&zipfile, &f, &full_path, top_level.unwrap_or(true));
|
||||||
&window,
|
|
||||||
&zipfile,
|
|
||||||
&f,
|
|
||||||
&full_path,
|
|
||||||
top_level.unwrap_or(false),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get the name of the inenr file in the zip file
|
// Get the name of the inenr file in the zip file
|
||||||
let mut zip = zip::ZipArchive::new(&f).unwrap();
|
let mut zip = zip::ZipArchive::new(&f).unwrap();
|
||||||
@@ -92,6 +81,14 @@ pub fn unzip(
|
|||||||
name = file.name().to_string().clone();
|
name = file.name().to_string().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !success {
|
||||||
|
let mut res_hash = std::collections::HashMap::new();
|
||||||
|
|
||||||
|
res_hash.insert("path".to_string(), zipfile.to_string());
|
||||||
|
|
||||||
|
window.emit("download_error", &res_hash).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
// If the contents is a jar file, emit that we have extracted a new jar file
|
// If the contents is a jar file, emit that we have extracted a new jar file
|
||||||
if name.ends_with(".jar") {
|
if name.ends_with(".jar") {
|
||||||
window
|
window
|
||||||
@@ -129,13 +126,7 @@ pub fn unzip(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_rar(
|
fn extract_rar(rarfile: &String, _f: &File, full_path: &path::PathBuf, _top_level: bool) -> bool {
|
||||||
window: &tauri::Window,
|
|
||||||
rarfile: &String,
|
|
||||||
_f: &File,
|
|
||||||
full_path: &path::PathBuf,
|
|
||||||
_top_level: bool,
|
|
||||||
) {
|
|
||||||
let archive = Archive::new(rarfile.clone());
|
let archive = Archive::new(rarfile.clone());
|
||||||
|
|
||||||
let mut open_archive = archive
|
let mut open_archive = archive
|
||||||
@@ -148,41 +139,29 @@ fn extract_rar(
|
|||||||
"Extracted rar file to: {}",
|
"Extracted rar file to: {}",
|
||||||
full_path.to_str().unwrap_or("Error")
|
full_path.to_str().unwrap_or("Error")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
true
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Failed to extract rar file: {}", e);
|
println!("Failed to extract rar file: {}", e);
|
||||||
let mut res_hash = std::collections::HashMap::new();
|
false
|
||||||
|
|
||||||
res_hash.insert("error".to_string(), e.to_string());
|
|
||||||
res_hash.insert("path".to_string(), rarfile.to_string());
|
|
||||||
|
|
||||||
window.emit("download_error", &res_hash).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_zip(
|
fn extract_zip(_zipfile: &String, f: &File, full_path: &path::PathBuf, top_level: bool) -> bool {
|
||||||
window: &tauri::Window,
|
|
||||||
zipfile: &String,
|
|
||||||
f: &File,
|
|
||||||
full_path: &path::PathBuf,
|
|
||||||
top_level: bool,
|
|
||||||
) {
|
|
||||||
match zip_extract::extract(f, full_path, top_level) {
|
match zip_extract::extract(f, full_path, top_level) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!(
|
println!(
|
||||||
"Extracted zip file to: {}",
|
"Extracted zip file to: {}",
|
||||||
full_path.to_str().unwrap_or("Error")
|
full_path.to_str().unwrap_or("Error")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
true
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Failed to extract zip file: {}", e);
|
println!("Failed to extract zip file: {}", e);
|
||||||
let mut res_hash = std::collections::HashMap::new();
|
false
|
||||||
|
|
||||||
res_hash.insert("error".to_string(), e.to_string());
|
|
||||||
res_hash.insert("path".to_string(), zipfile.to_string());
|
|
||||||
|
|
||||||
window.emit("download_error", &res_hash).unwrap();
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "Cultivation",
|
"productName": "Cultivation",
|
||||||
"version": "1.0.6"
|
"version": "1.0.7"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
|
|||||||
@@ -151,6 +151,12 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
this.setState({
|
this.setState({
|
||||||
migoto_path: value,
|
migoto_path: value,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Set game exe in Migoto ini
|
||||||
|
invoke('set_migoto_target', {
|
||||||
|
path: this.state.game_install_path,
|
||||||
|
migotoPath: value,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
setReshade(value: string) {
|
setReshade(value: string) {
|
||||||
|
|||||||
@@ -78,13 +78,16 @@ export default class DownloadHandler {
|
|||||||
// Extraction events
|
// Extraction events
|
||||||
listen('extract_start', ({ payload }) => {
|
listen('extract_start', ({ payload }) => {
|
||||||
// Find the download that is no extracting and set it's status as such
|
// Find the download that is no extracting and set it's status as such
|
||||||
const index = this.downloads.findIndex((download) => download.path === payload)
|
// @ts-expect-error Too lazy to make an interface for payloads rn
|
||||||
|
const index = this.downloads.findIndex((download) => download.path === payload.file)
|
||||||
this.downloads[index].status = 'extracting'
|
this.downloads[index].status = 'extracting'
|
||||||
})
|
})
|
||||||
|
|
||||||
listen('extract_end', ({ payload }) => {
|
listen('extract_end', ({ payload }) => {
|
||||||
|
console.log(payload)
|
||||||
// Find the download that is no extracting and set it's status as such
|
// Find the download that is no extracting and set it's status as such
|
||||||
const index = this.downloads.findIndex((download) => download.path === payload)
|
// @ts-expect-error Too lazy to make an interface for payloads rn
|
||||||
|
const index = this.downloads.findIndex((download) => download.path === payload.file)
|
||||||
this.downloads[index].status = 'finished'
|
this.downloads[index].status = 'finished'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,13 +118,30 @@ interface ModDownload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getMods(mode: string) {
|
export async function getMods(mode: string) {
|
||||||
const resp = JSON.parse(
|
let modList: GamebananaResponse[] = []
|
||||||
await invoke('list_submissions', {
|
let hadMods = true
|
||||||
mode,
|
let page = 1
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
return formatGamebananaData(resp)
|
while (hadMods) {
|
||||||
|
const resp = JSON.parse(
|
||||||
|
await invoke('list_submissions', {
|
||||||
|
mode,
|
||||||
|
page: '' + page,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
if (resp.length === 0) hadMods = false
|
||||||
|
|
||||||
|
modList = [...modList, ...resp]
|
||||||
|
page++
|
||||||
|
|
||||||
|
console.log(page)
|
||||||
|
console.log(resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(modList)
|
||||||
|
|
||||||
|
return formatGamebananaData(modList)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function formatGamebananaData(obj: GamebananaResponse[]) {
|
export async function formatGamebananaData(obj: GamebananaResponse[]) {
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ export function unzip(
|
|||||||
})
|
})
|
||||||
|
|
||||||
listen('extract_end', ({ payload }) => {
|
listen('extract_end', ({ payload }) => {
|
||||||
|
console.log(payload)
|
||||||
|
console.log(file)
|
||||||
|
|
||||||
// @ts-expect-error Payload is an object
|
// @ts-expect-error Payload is an object
|
||||||
if (payload?.file === file) {
|
if (payload?.file === file) {
|
||||||
resolve(payload as UnzipPayload)
|
resolve(payload as UnzipPayload)
|
||||||
|
|||||||
Reference in New Issue
Block a user