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