diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 700eb9c..90a533f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: env: CARGO_TERM_COLOR: always jobs: - build1: + build_linux: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -25,7 +25,7 @@ jobs: name: game_cheetah_linux path: target/release/bundle/deb/game_cheetah_*.deb - build2: + build_osx: runs-on: macos-latest steps: - uses: actions/checkout@v3 @@ -40,7 +40,7 @@ jobs: name: game_cheetah_osx path: target/release/game_cheetah - build3: + build_windows: runs-on: windows-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 7f1c274..1c6de73 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -8,15 +8,21 @@ on: env: CARGO_TERM_COLOR: always jobs: - build: + run_checks: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Rustfmt + - name: Check formatting uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check + - run: rustup component add clippy + - name: Check clippy + uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features - name: Run tests uses: actions-rs/cargo@v1 with: diff --git a/i18n/de/game_cheetah.ftl b/i18n/de/game_cheetah.ftl index 73c8d31..00bc084 100644 --- a/i18n/de/game_cheetah.ftl +++ b/i18n/de/game_cheetah.ftl @@ -1,7 +1,8 @@ -process-label = Prozesse: +process-label = Prozess: no-processes-label = filter-processes-hint = Prozesse filtern -default-label = Standard +first-search-label = Erste Suche +search-label = Suche { $search } name-label = Name: value-label = Wert: search-description-label = Suchbeschreibung @@ -19,6 +20,7 @@ clear-button = Löschen close-button = Schließen hide-results-button = Ergebnisse verstecken show-results-button = Ergebnisse zeigen +rename-button = Umbenennen generic-error-label = invalid-input-error = Eingabe ungültig @@ -50,3 +52,7 @@ command-heading = Kommando update-numbers-progress = Aktualisiere { $current }/{ $total }… search-memory-progress = Suche { $current }/{ $total }… + +tab-hover-text=Doppelklick zum Umbenennen +close-tab-hover-text=Schließe aktive Suche +open-tab-hover-text=Neue Suche diff --git a/i18n/en/game_cheetah.ftl b/i18n/en/game_cheetah.ftl index 1c0dbe4..5c198a1 100644 --- a/i18n/en/game_cheetah.ftl +++ b/i18n/en/game_cheetah.ftl @@ -1,7 +1,8 @@ -process-label = Processes: +process-label = Process: no-processes-label = filter-processes-hint = Filter processes -default-label = default +first-search-label = First search +search-label = Search { $search } name-label = Name: value-label = Value: search-description-label = Search description @@ -19,6 +20,7 @@ clear-button = Clear close-button = Close hide-results-button = Hide Results show-results-button = Show Results +rename-button = Rename generic-error-label = invalid-input-error = Invalid input @@ -50,3 +52,7 @@ command-heading = Command update-numbers-progress = Update { $current }/{ $total }… search-memory-progress = Search { $current }/{ $total }… + +tab-hover-text=Double click for rename +close-tab-hover-text=Close active search +open-tab-hover-text=Open new search diff --git a/src/app.rs b/src/app.rs index a640913..c2b46f5 100644 --- a/src/app.rs +++ b/src/app.rs @@ -85,10 +85,8 @@ impl GameCheetahEngine { let row_height = 17.0; body.row(row_height, |mut row| { row.col(|ui| { - if ui - .selectable_label(false, process.pid.to_string()) - .clicked() - { + let r = ui.selectable_label(false, process.pid.to_string()); + if r.clicked() { self.pid = process.pid; self.freeze_sender .send(Message::from_addr( @@ -155,7 +153,7 @@ impl eframe::App for GameCheetahEngine { self.searches.clear(); self.searches.push(Box::new(SearchContext::new(fl!( crate::LANGUAGE_LOADER, - "default-label" + "first-search-label" )))); self.process_filter.clear(); } @@ -170,24 +168,38 @@ impl eframe::App for GameCheetahEngine { ui.spacing_mut().item_spacing = egui::Vec2::splat(8.0); for i in 0..self.searches.len() { - if ui + let r = ui .selectable_label( self.current_search == i, self.searches[i].description.clone(), ) - .clicked() - { + .on_hover_text(fl!(crate::LANGUAGE_LOADER, "tab-hover-text")); + + if r.clicked() { self.current_search = i; } + + if r.double_clicked() { + self.searches[i].rename_mode = true; + } } - if self.current_search < self.searches.len() && ui.button("-").clicked() { + if self.current_search < self.searches.len() + && ui + .button("-") + .on_hover_text(fl!(crate::LANGUAGE_LOADER, "close-tab-hover-text")) + .clicked() + { self.remove_freezes(self.current_search); self.searches.remove(self.current_search); if self.current_search > 0 { self.current_search -= 1; } } - if ui.button("+").clicked() { + if ui + .button("+") + .on_hover_text(fl!(crate::LANGUAGE_LOADER, "open-tab-hover-text")) + .clicked() + { self.new_search(); } }); @@ -209,17 +221,26 @@ impl eframe::App for GameCheetahEngine { impl GameCheetahEngine { fn render_content(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, search_index: usize) { if self.searches.len() > 1 { - ui.horizontal(|ui| { - ui.spacing_mut().item_spacing = egui::Vec2::splat(5.0); - ui.label(fl!(crate::LANGUAGE_LOADER, "name-label")); - if let Some(search_context) = self.searches.get_mut(search_index) { - ui.add( - egui::TextEdit::singleline(&mut search_context.description) - .hint_text(fl!(crate::LANGUAGE_LOADER, "search-description-label")) - .interactive(matches!(search_context.searching, SearchMode::None)), - ); + if let Some(search_context) = self.searches.get_mut(search_index) { + if search_context.rename_mode { + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing = egui::Vec2::splat(5.0); + ui.label(fl!(crate::LANGUAGE_LOADER, "name-label")); + ui.add( + egui::TextEdit::singleline(&mut search_context.description) + .hint_text(fl!(crate::LANGUAGE_LOADER, "search-description-label")) + .interactive(matches!(search_context.searching, SearchMode::None)), + ); + + if ui + .button(fl!(crate::LANGUAGE_LOADER, "rename-button")) + .clicked() + { + search_context.rename_mode = false; + } + }); } - }); + } } ui.horizontal(|ui| { @@ -308,7 +329,12 @@ impl GameCheetahEngine { ui.memory_mut(|m| m.request_focus(re.id)); } - if self.searches.len() <= 1 && ui.button("+").clicked() { + if self.searches.len() <= 1 + && ui + .button("+") + .on_hover_text(fl!(crate::LANGUAGE_LOADER, "open-tab-hover-text")) + .clicked() + { self.new_search(); } } diff --git a/src/search_context.rs b/src/search_context.rs index e621889..44286fc 100644 --- a/src/search_context.rs +++ b/src/search_context.rs @@ -13,6 +13,7 @@ pub enum SearchMode { pub struct SearchContext { pub description: String, + pub rename_mode: bool, pub search_value_text: String, pub search_type: SearchType, @@ -31,6 +32,7 @@ impl SearchContext { pub fn new(description: String) -> Self { Self { description, + rename_mode: false, search_value_text: "".to_owned(), searching: SearchMode::None, results: Arc::new(Mutex::new(Vec::new())), diff --git a/src/state.rs b/src/state.rs index 3a0942a..cb3fea1 100644 --- a/src/state.rs +++ b/src/state.rs @@ -11,6 +11,7 @@ use crate::{ Message, MessageCommand, SearchContext, SearchMode, SearchResult, SearchType, SearchValue, }; use boyer_moore_magiclen::BMByte; +use i18n_embed_fl::fl; use proc_maps::get_process_maps; use process_memory::{copy_address, PutAddress, TryIntoProcessHandle}; use sysinfo::*; @@ -82,7 +83,10 @@ impl Default for GameCheetahEngine { process_filter: "".to_owned(), processes: Vec::new(), current_search: 0, - searches: vec![Box::new(SearchContext::new("Search 1".to_string()))], + searches: vec![Box::new(SearchContext::new(fl!( + crate::LANGUAGE_LOADER, + "first-search-label" + )))], search_threads: ThreadPool::new(16), freeze_sender: tx, show_results: false, @@ -92,7 +96,11 @@ impl Default for GameCheetahEngine { impl GameCheetahEngine { pub fn new_search(&mut self) { - let ctx = SearchContext::new(format!("Search {}", 1 + self.searches.len())); + let ctx = SearchContext::new(fl!( + crate::LANGUAGE_LOADER, + "search-label", + search = (1 + self.searches.len()).to_string() + )); self.current_search = self.searches.len(); self.searches.push(Box::new(ctx)); }