Skip to content

Commit

Permalink
Improved rename feature.
Browse files Browse the repository at this point in the history
Rename is now optional/cleaner UI.
  • Loading branch information
mkrueger committed Aug 3, 2023
1 parent 7e4eb12 commit 19ed87a
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
env:
CARGO_TERM_COLOR: always
jobs:
build1:
build_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -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
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions i18n/de/game_cheetah.ftl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
process-label = Prozesse:
process-label = Prozess:
no-processes-label = <Prozess nicht gesetzt>
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
Expand All @@ -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 = <Fehler>
invalid-input-error = Eingabe ungültig
Expand Down Expand Up @@ -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
10 changes: 8 additions & 2 deletions i18n/en/game_cheetah.ftl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
process-label = Processes:
process-label = Process:
no-processes-label = <no process set>
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
Expand All @@ -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 = <error>
invalid-input-error = Invalid input
Expand Down Expand Up @@ -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
68 changes: 47 additions & 21 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
});
Expand All @@ -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| {
Expand Down Expand Up @@ -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();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/search_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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())),
Expand Down
12 changes: 10 additions & 2 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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,
Expand All @@ -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));
}
Expand Down

0 comments on commit 19ed87a

Please sign in to comment.