A native webfishing installer for macos
at master 39 lines 1.7 kB view raw
1use godot_pck::structs::PckFile; 2use async_std::fs::File; 3use async_std::io::{ReadExt, WriteExt}; 4use godot_pck::structs::PCK; 5 6const RESOURCE_PATH: &str = "res://Scenes/Singletons/SteamNetwork.gdc"; 7const FILE_PATH: &str = "build/webfishing-export/SteamNetwork.gdc"; 8const SCRIPT_PATH: &str = "build/webfishing-decomp/SteamNetwork.gd"; 9const COMPILED_PATH: &str = "build/webfishing-recomp/SteamNetwork.gdc"; 10 11pub(crate) async fn patch(pck: &mut PCK) { 12 println!("Patching {} files...", RESOURCE_PATH); 13 let pck_file: &mut PckFile = pck.get_file_by_path_mut(RESOURCE_PATH).expect("Couldn't find options_menu.gdc file"); 14 15 let content = pck_file.get_content(); 16 let mut exported_file = File::create(FILE_PATH).await.expect("Couldn't create file"); 17 exported_file.write_all(content).await.expect("Couldn't write file"); 18 drop(exported_file); 19 20 crate::utils::gd_utils::decomp_script(FILE_PATH); 21 22 let mut script = File::open(SCRIPT_PATH).await.expect("Cannot open script"); 23 let mut script_txt = String::new(); 24 script.read_to_string(&mut script_txt).await.expect("Cannot read script"); 25 drop(script); 26 27 let patched_script = script_txt.replace(".LOBBY_COMPARISON_EQUAL_TO_GREATER_THAN", ".OBBY_COMPARISON_EQUAL_TO_GREATER_THAN"); 28 let mut script = File::create(SCRIPT_PATH).await.expect("Cannot open script"); 29 script.write_all(patched_script.as_bytes()).await.expect("Cannot write"); 30 drop(script); 31 32 crate::utils::gd_utils::recomp_file(SCRIPT_PATH); 33 34 let mut file = File::open(COMPILED_PATH).await.expect("Cannot open compiled script"); 35 let mut new_content = vec![]; 36 file.read_to_end(&mut new_content).await.unwrap(); 37 38 pck_file.set_content(new_content); 39}