diff --git a/Cargo.toml b/Cargo.toml index f29fced..207a6c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wt_custom_lang" description = "A tool to create custom language files for the game War Thunder" -version = "0.2.1" +version = "1.0.0" edition = "2021" rust-version = "1.58" license = "Apache-2.0" diff --git a/README.md b/README.md new file mode 100644 index 0000000..8246284 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Installation guide + +* Download latest release for your fitting operating system from here +* Move binary to appropiate location -- or simply execute in place (such as the download folder) + - For windows ```C:\Program Files (x86)\wt_custom_lang``` + - For linux ```$HOME/.local/bin/wt_custom_lang``` + - Create the appropaite above mentioned (sub-)folder if it doesnt already exist + +Done! + +# For using the tool, please refer to here diff --git a/guide/how_to_use.md b/guide/how_to_use.md index 6d3f665..aeaa6e5 100644 --- a/guide/how_to_use.md +++ b/guide/how_to_use.md @@ -1 +1,14 @@ -WIP \ No newline at end of file +# Creating a new entry +- Select ``Add new entry`` +- Check which file to edit (using the wiki to figure out the proper path) +- Enter the current displayed name (turns green when it is found) +- Enter the replaced name + +# Removing an entry +- Click undo on the individual entry should return it to the original + +# Using/Creating backups +- Select ``Backups`` +- Enter name of backup and click create + +- Backups can be loaded or deleted via the ``Load`` or ``Delete`` option \ No newline at end of file diff --git a/src/app/basic_prompts.rs b/src/app/basic_prompts.rs index 748ec15..1061f5d 100644 --- a/src/app/basic_prompts.rs +++ b/src/app/basic_prompts.rs @@ -11,7 +11,7 @@ use crate::{CustomLang, REPO_URL}; impl CustomLang { pub fn prompt_for_status(&mut self, ctx: &CtxRef) { - Window::new("Config status").show(ctx, |ui| { + Window::new("Config status").anchor(Align2::CENTER_CENTER, Vec2::new(0.0,0.0)).show(ctx, |ui| { if self.config.is_wt_path_valid() { ui.add(Label::new(RichText::new(format!("WT path is defined and working ✅")).color(Color32::from_rgb(0, 255, 0)))); } @@ -31,7 +31,7 @@ impl CustomLang { }); } pub(crate) fn prompt_for_wt_path(&mut self, ctx: &CtxRef) { - Window::new("First time setup").show(ctx, |ui| { + Window::new("First time setup").anchor(Align2::CENTER_CENTER, Vec2::new(0.0,0.0)).show(ctx, |ui| { ui.add(Label::new("Select WarThunder installation folder")); let select_button = ui.add(Button::new(RichText::new("Choose path").text_style(TextStyle::Body))); ui.add(Hyperlink::from_label_and_url("Where the game might be installed", format!("{}/guide/install_folder.md", REPO_URL))); @@ -54,7 +54,7 @@ impl CustomLang { }); } pub fn prompt_for_config_blk(&mut self, ctx: &CtxRef) { - Window::new("Configuring the config.blk file").show(ctx, |ui| { + Window::new("Configuring the config.blk file").anchor(Align2::CENTER_CENTER, Vec2::new(0.0,0.0)).show(ctx, |ui| { if let Some(wt_path) = self.config.wt_path.as_ref() { let blk_path = format!("{}/config.blk", wt_path); match fs::read_to_string(&blk_path) { @@ -90,46 +90,50 @@ impl CustomLang { }); } pub fn prompt_for_lang_folder(&mut self, ctx: &CtxRef) { - Window::new("Steps for generating the lang folder").show(ctx, |ui| { - if ui.add(Button::new(RichText::new("Launch game").text_style(TextStyle::Heading))).clicked() { - // Cloning as the thread consumes the String entirely - if let Some(path) = self.config.wt_path.as_ref() { - #[cfg(target_os = "windows")] let format_path = format!("{}/launcher.exe", path); + Window::new("Launching the game").anchor(Align2::CENTER_CENTER, Vec2::new(0.0,0.0)).show(ctx, |ui| { + ui.horizontal(|ui|{ + if ui.add(Button::new(RichText::new("Launch game ⬈").text_style(TextStyle::Heading))).clicked() { + // Cloning as the thread consumes the String entirely + if let Some(path) = self.config.wt_path.as_ref() { + #[cfg(target_os = "windows")] let format_path = format!("{}/launcher.exe", path); - #[cfg(target_os = "linux")] let format_path = format!("{}/launcher", path); + #[cfg(target_os = "linux")] let format_path = format!("{}/launcher", path); - // Spawning loose thread as application completely stalls as long as launcher.exe lives - thread::spawn(move || { - // Not catching as the process will be orphaned - let _ = Command::new(format_path).execute(); - }); - } else { - self.prompt_error.err_value = Some("No WT path is set, but at this point in time it should be".to_owned()); - return; + // Spawning loose thread as application completely stalls as long as launcher.exe lives + thread::spawn(move || { + // Not catching as the process will be orphaned + let _ = Command::new(format_path).execute(); + }); + } else { + self.prompt_error.err_value = Some("No WT path is set, but at this point in time it should be".to_owned()); + return; + } } - } - ui.add_space(20.0); + ui.add_space(20.0); - if ui.add(Button::new(RichText::new("Check if it was created").text_style(TextStyle::Heading))).clicked() { - if let Some(path) = self.config.wt_path.as_ref() { - if fs::read_dir(format!("{}/lang", path)).is_ok() { - self.config.lang_folder_created = true; + if ui.add(Button::new(RichText::new("Verify folder").text_style(TextStyle::Heading))).clicked() { + if let Some(path) = self.config.wt_path.as_ref() { + if fs::read_dir(format!("{}/lang", path)).is_ok() { + self.config.lang_folder_created = true; + } + } else { + self.prompt_error.err_value = Some("No WT path is set, but at this point in time it should be".to_owned()); + return; } - } else { - self.prompt_error.err_value = Some("No WT path is set, but at this point in time it should be".to_owned()); - return; } - } + }); }); } #[cfg(windows)] pub fn prompt_lang_file_warn(&mut self, ctx: &CtxRef) { - Window::new("Setting lang folder permissions").show(ctx, |ui| { - if ui.add(Button::new(RichText::new("Done!").text_style(TextStyle::Heading))).clicked() { - self.config.prompted_about_lang_perm = true; - } - ui.add(Hyperlink::from_label_and_url("I dont know how to do that", "https://github.com/Warthunder-Open-Source-Foundation/wt_custom_lang/blob/master/guide/windows_lang_permission.md")); + Window::new("Setting up permissions").anchor(Align2::CENTER_CENTER, Vec2::new(0.0,0.0)).show(ctx, |ui| { + ui.horizontal(|ui|{ + ui.add(Hyperlink::from_label_and_url(RichText::new("How to set up proper permissions").text_style(TextStyle::Heading), "https://github.com/Warthunder-Open-Source-Foundation/wt_custom_lang/blob/master/guide/windows_lang_permission.md")); + if ui.add(Button::new(RichText::new("Done!").text_style(TextStyle::Heading))).clicked() { + self.config.prompted_about_lang_perm = true; + } + }); }); } } \ No newline at end of file diff --git a/src/app/prompts/prompt_for_entry.rs b/src/app/prompts/prompt_for_entry.rs index b2688d9..ae96dd3 100644 --- a/src/app/prompts/prompt_for_entry.rs +++ b/src/app/prompts/prompt_for_entry.rs @@ -55,7 +55,7 @@ impl CustomLang { Window::new("Adding a new entry").show(ctx, |ui| { let mut original = self.prompt_for_entry.before_after_entry.clone(); - let mut color= Color32::from_rgb(255,255,255);; + let mut color= Color32::from_rgb(255,255,255); let mut contains = |file_path: &str|{ if fs::read_to_string(format!("{}/lang/{}.csv", wt_raw, file_path)).unwrap_or("".to_owned()).contains(&format!(r#""{}""#, &original.0)) { @@ -66,11 +66,6 @@ impl CustomLang { } }; - contains(self.prompt_for_entry.toggle_dropdown.to_file_name()); - - ui.add(TextEdit::singleline (&mut original.0).hint_text("Old name").text_color(color)); - ui.add(TextEdit::singleline(&mut original.1).hint_text("New name")); - ui.horizontal(|ui| { ComboBox::from_label("").selected_text(format!("{:?}", self.prompt_for_entry.toggle_dropdown)).show_ui(ui, |ui| { ui.selectable_value(&mut self.prompt_for_entry.toggle_dropdown, LangType::Units, "Unit"); @@ -81,10 +76,16 @@ impl CustomLang { ui.add(Hyperlink::from_label_and_url("What these options mean", "https://github.com/Warthunder-Open-Source-Foundation/wt_custom_lang/wiki/Types-of-supported-language-files")); }); + + contains(self.prompt_for_entry.toggle_dropdown.to_file_name()); + + ui.add(TextEdit::singleline (&mut original.0).hint_text("Old name").text_color(color)); + ui.add(TextEdit::singleline(&mut original.1).hint_text("New name")); + self.prompt_for_entry.before_after_entry = original; ui.horizontal(|ui| { - if ui.add(Button::new(RichText::new("Create!").text_style(TextStyle::Heading))).clicked() { + if ui.add(Button::new(RichText::new("Create").text_style(TextStyle::Heading))).clicked() { let lang_type = self.prompt_for_entry.toggle_dropdown.to_file_name(); let path: String = format!("{}/lang/{}.csv", wt_raw, lang_type); diff --git a/src/lang_manipulation/primitive_lang.rs b/src/lang_manipulation/primitive_lang.rs index f4c5950..179c02e 100644 --- a/src/lang_manipulation/primitive_lang.rs +++ b/src/lang_manipulation/primitive_lang.rs @@ -67,11 +67,11 @@ impl PrimitiveEntry { } _ => { panic!("Custom files are currently not implemented"); - let mut file = file_to_string(custom_lang, wt_path, &entry.file); - file = file.replace(&format(&entry.original_english), &format(&entry.new_english)); - if let Err(error) = fs::write(string_to_path(&entry.file), file) { - custom_lang.prompt_error.err_value = Some(format!("{:?} {}:{} {}", error, line!(), column!(), file!())); - } + // let mut file = file_to_string(custom_lang, wt_path, &entry.file); + // file = file.replace(&format(&entry.original_english), &format(&entry.new_english)); + // if let Err(error) = fs::write(string_to_path(&entry.file), file) { + // custom_lang.prompt_error.err_value = Some(format!("{:?} {}:{} {}", error, line!(), column!(), file!())); + // } } } }