Compare commits

..

6 Commits

Author SHA1 Message Date
SpikeHD
fa38a22117 version bump 2022-08-25 20:19:44 -07:00
SpikeHD
a7914406b4 get ALL mods at once 2022-08-25 20:18:58 -07:00
SpikeHD
57c1a7800c write game path to migoto config autmatically 2022-08-25 20:08:44 -07:00
SpikeHD
9426937a62 cleanup 2022-08-25 19:05:51 -07:00
SpikeHD
96d69d9ff6 bump initial wait for game to 10 seconds 2022-08-25 19:04:08 -07:00
SpikeHD
defc1b43bd fix all sorts of zip stuff 2022-08-25 18:57:24 -07:00
12 changed files with 147 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "cultivation",
"version": "1.0.6",
"version": "1.0.7",
"private": true,
"dependencies": {
"@tauri-apps/api": "^1.0.0-rc.5",

41
src-tauri/Cargo.lock generated
View File

@@ -26,6 +26,17 @@ dependencies = [
"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]]
name = "aho-corasick"
version = "0.7.18"
@@ -725,6 +736,7 @@ dependencies = [
"regex",
"registry",
"reqwest",
"rust-ini",
"rustls-pemfile",
"serde",
"serde_json",
@@ -888,6 +900,12 @@ dependencies = [
"syn",
]
[[package]]
name = "dlv-list"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257"
[[package]]
name = "dtoa"
version = "0.4.8"
@@ -1481,6 +1499,9 @@ name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash",
]
[[package]]
name = "heck"
@@ -2451,6 +2472,16 @@ dependencies = [
"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]]
name = "os_info"
version = "3.4.0"
@@ -3223,6 +3254,16 @@ dependencies = [
"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]]
name = "rustc-serialize"
version = "0.3.24"

View File

@@ -61,6 +61,7 @@ regex = "1"
# other
file_diff = "1.0.0"
rust-ini = "0.18.0"
[features]
# by default Tauri runs in production mode

View File

@@ -15,11 +15,11 @@ pub async fn get_download_links(mod_id: String) -> String {
}
#[tauri::command]
pub async fn list_submissions(mode: String) -> String {
pub async fn list_submissions(mode: String, page: String) -> String {
let res = web::query(
format!(
"{}/apiv9/Util/Game/Submissions?_idGameRow=8552&_nPage=1&_nPerpage=50&_sMode={}",
SITE_URL, mode
"{}/apiv9/Util/Game/Submissions?_idGameRow=8552&_nPage={}&_nPerpage=50&_sMode={}",
SITE_URL, page, mode
)
.as_str(),
)

View File

@@ -45,6 +45,7 @@ fn main() {
system_helpers::open_in_browser,
system_helpers::install_location,
system_helpers::is_elevated,
system_helpers::set_migoto_target,
proxy::set_proxy_addr,
proxy::generate_ca_files,
unzip::unzip,
@@ -94,7 +95,7 @@ fn enable_process_watcher(window: tauri::Window, process: String) {
thread::spawn(move || {
// 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();
@@ -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) {
Ok(data) => data,
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();
}
};

View File

@@ -1,4 +1,6 @@
use duct::cmd;
use ini::Ini;
use std::path::PathBuf;
#[tauri::command]
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();
}
#[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)]
#[tauri::command]
pub fn is_elevated() -> bool {

View File

@@ -64,27 +64,16 @@ pub fn unzip(
println!("Is rar file? {}", zipfile.ends_with(".rar"));
let name;
let success;
// If file ends in zip, OR is unknown, extract as zip, otherwise extract as rar
if zipfile.ends_with(".rar") {
extract_rar(
&window,
&zipfile,
&f,
&full_path,
top_level.unwrap_or(false),
);
success = extract_rar(&zipfile, &f, &full_path, top_level.unwrap_or(true));
let archive = Archive::new(zipfile.clone());
name = archive.list().unwrap().next().unwrap().unwrap().filename;
} else {
extract_zip(
&window,
&zipfile,
&f,
&full_path,
top_level.unwrap_or(false),
);
success = extract_zip(&zipfile, &f, &full_path, top_level.unwrap_or(true));
// Get the name of the inenr file in the zip file
let mut zip = zip::ZipArchive::new(&f).unwrap();
@@ -92,6 +81,14 @@ pub fn unzip(
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 name.ends_with(".jar") {
window
@@ -129,13 +126,7 @@ pub fn unzip(
});
}
fn extract_rar(
window: &tauri::Window,
rarfile: &String,
_f: &File,
full_path: &path::PathBuf,
_top_level: bool,
) {
fn extract_rar(rarfile: &String, _f: &File, full_path: &path::PathBuf, _top_level: bool) -> bool {
let archive = Archive::new(rarfile.clone());
let mut open_archive = archive
@@ -148,41 +139,29 @@ fn extract_rar(
"Extracted rar file to: {}",
full_path.to_str().unwrap_or("Error")
);
true
}
Err(e) => {
println!("Failed to extract rar file: {}", e);
let mut res_hash = std::collections::HashMap::new();
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();
false
}
}
}
fn extract_zip(
window: &tauri::Window,
zipfile: &String,
f: &File,
full_path: &path::PathBuf,
top_level: bool,
) {
fn extract_zip(_zipfile: &String, f: &File, full_path: &path::PathBuf, top_level: bool) -> bool {
match zip_extract::extract(f, full_path, top_level) {
Ok(_) => {
println!(
"Extracted zip file to: {}",
full_path.to_str().unwrap_or("Error")
);
true
}
Err(e) => {
println!("Failed to extract zip file: {}", e);
let mut res_hash = std::collections::HashMap::new();
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();
false
}
}
};
}

View File

@@ -7,7 +7,7 @@
},
"package": {
"productName": "Cultivation",
"version": "1.0.6"
"version": "1.0.7"
},
"tauri": {
"allowlist": {

View File

@@ -151,6 +151,12 @@ export default class Options extends React.Component<IProps, IState> {
this.setState({
migoto_path: value,
})
// Set game exe in Migoto ini
invoke('set_migoto_target', {
path: this.state.game_install_path,
migotoPath: value,
})
}
setReshade(value: string) {

View File

@@ -78,13 +78,16 @@ export default class DownloadHandler {
// Extraction events
listen('extract_start', ({ payload }) => {
// 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'
})
listen('extract_end', ({ payload }) => {
console.log(payload)
// 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'
})
}

View File

@@ -118,13 +118,30 @@ interface ModDownload {
}
export async function getMods(mode: string) {
let modList: GamebananaResponse[] = []
let hadMods = true
let page = 1
while (hadMods) {
const resp = JSON.parse(
await invoke('list_submissions', {
mode,
page: '' + page,
})
)
return formatGamebananaData(resp)
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[]) {

View File

@@ -21,6 +21,9 @@ export function unzip(
})
listen('extract_end', ({ payload }) => {
console.log(payload)
console.log(file)
// @ts-expect-error Payload is an object
if (payload?.file === file) {
resolve(payload as UnzipPayload)