improve debug experience
This commit is contained in:
@@ -6,6 +6,7 @@ use windows::Win32::UI::Input::KeyboardAndMouse::{
|
|||||||
pub const INTERVAL: Duration = Duration::from_secs(60);
|
pub const INTERVAL: Duration = Duration::from_secs(60);
|
||||||
const VK_SHIFT: u8 = 16;
|
const VK_SHIFT: u8 = 16;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct AntiAfk {
|
pub struct AntiAfk {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub interval: Instant,
|
pub interval: Instant,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ pub const INTERVAL: Duration = Duration::from_secs(8);
|
|||||||
const ENHANCED: &str = "GTA5_Enhanced.exe";
|
const ENHANCED: &str = "GTA5_Enhanced.exe";
|
||||||
const LEGACY: &str = "GTA5.exe";
|
const LEGACY: &str = "GTA5.exe";
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EmptySession {
|
pub struct EmptySession {
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
pub interval: Instant,
|
pub interval: Instant,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use crate::util::consts::{ENHANCED, LEGACY};
|
|||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use sysinfo::System;
|
use sysinfo::System;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ForceClose {
|
pub struct ForceClose {
|
||||||
pub button_text: String,
|
pub button_text: String,
|
||||||
pub prompting: bool,
|
pub prompting: bool,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ impl Display for Platform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Launch {
|
pub struct Launch {
|
||||||
pub selected: Platform,
|
pub selected: Platform,
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-19
@@ -18,15 +18,15 @@ use windows::Win32::Foundation::HANDLE;
|
|||||||
|
|
||||||
const THEME: catppuccin_egui::Theme = catppuccin_egui::MOCHA;
|
const THEME: catppuccin_egui::Theme = catppuccin_egui::MOCHA;
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Eq)]
|
#[derive(Debug, Default, PartialEq, Eq)]
|
||||||
pub enum Stage {
|
pub enum Stage {
|
||||||
#[default]
|
#[default]
|
||||||
Main,
|
Main,
|
||||||
About,
|
About,
|
||||||
Debug,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct App {
|
pub struct App {
|
||||||
stage: Stage,
|
stage: Stage,
|
||||||
debug: bool,
|
debug: bool,
|
||||||
@@ -66,23 +66,11 @@ impl eframe::App for App {
|
|||||||
egui_extras::install_image_loaders(ctx);
|
egui_extras::install_image_loaders(ctx);
|
||||||
self.initialized = true;
|
self.initialized = true;
|
||||||
}
|
}
|
||||||
ctx.request_repaint_after(Duration::from_millis(100));
|
|
||||||
ctx.input(|i| {
|
|
||||||
if i.modifiers.all() && i.key_pressed(egui::Key::D) {
|
|
||||||
self.debug = !self.debug;
|
|
||||||
if !self.debug && self.stage == Stage::Debug {
|
|
||||||
self.stage = Stage::Main;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
self.run_timers();
|
self.run_timers();
|
||||||
egui::TopBottomPanel::bottom("bottom_panel").show(ctx, |ui| {
|
egui::TopBottomPanel::bottom("bottom_panel").show(ctx, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.selectable_value(&mut self.stage, Stage::Main, "Main");
|
ui.selectable_value(&mut self.stage, Stage::Main, "Main");
|
||||||
ui.selectable_value(&mut self.stage, Stage::About, "About");
|
ui.selectable_value(&mut self.stage, Stage::About, "About");
|
||||||
if self.debug {
|
|
||||||
ui.selectable_value(&mut self.stage, Stage::Debug, "Debug");
|
|
||||||
}
|
|
||||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||||
let button = ui
|
let button = ui
|
||||||
.add_enabled(!self.elevated, egui::Button::new("Elevate"))
|
.add_enabled(!self.elevated, egui::Button::new("Elevate"))
|
||||||
@@ -109,15 +97,59 @@ impl eframe::App for App {
|
|||||||
Stage::About => {
|
Stage::About => {
|
||||||
self.show_about(ctx, ui);
|
self.show_about(ctx, ui);
|
||||||
}
|
}
|
||||||
Stage::Debug => {
|
});
|
||||||
self.show_debug(ctx, ui);
|
});
|
||||||
|
if self.check_debug_keycombo_pressed(ctx) {
|
||||||
|
self.debug = !self.debug;
|
||||||
}
|
}
|
||||||
|
if self.check_debug_viewport_close_button_pressed(ctx) {
|
||||||
|
self.debug = false;
|
||||||
|
}
|
||||||
|
if self.debug {
|
||||||
|
let main_rect = ctx.input(|i| i.viewport().clone().outer_rect.unwrap());
|
||||||
|
let position = [main_rect.right(), main_rect.min.y];
|
||||||
|
ctx.show_viewport_immediate(
|
||||||
|
egui::ViewportId::from_hash_of("debug_viewport"),
|
||||||
|
egui::ViewportBuilder::default()
|
||||||
|
.with_title("GTA Tools Debug")
|
||||||
|
.with_minimize_button(false)
|
||||||
|
.with_maximize_button(false)
|
||||||
|
.with_inner_size([256.0, 232.0])
|
||||||
|
.with_position(position)
|
||||||
|
.with_icon(load_icon()),
|
||||||
|
|ctx, _class| {
|
||||||
|
if self.check_debug_keycombo_pressed(ctx) {
|
||||||
|
self.debug = !self.debug;
|
||||||
|
}
|
||||||
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
|
egui::ScrollArea::both()
|
||||||
|
.auto_shrink([false, false])
|
||||||
|
.show(ui, |ui| {
|
||||||
|
self.show_debug(ctx, ui);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
ctx.request_repaint_after(Duration::from_millis(100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
fn check_debug_keycombo_pressed(&self, ctx: &egui::Context) -> bool {
|
||||||
|
ctx.input(|i| i.modifiers.all() && i.key_pressed(egui::Key::D))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_debug_viewport_close_button_pressed(&self, ctx: &egui::Context) -> bool {
|
||||||
|
ctx.input(|i| {
|
||||||
|
i.raw
|
||||||
|
.viewports
|
||||||
|
.get(&egui::ViewportId::from_hash_of("debug_viewport"))
|
||||||
|
.filter(|vp| vp.close_requested())
|
||||||
|
.is_some()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::unused_self)]
|
#[allow(clippy::unused_self)]
|
||||||
fn header(&self, ui: &mut egui::Ui, text: &str) {
|
fn header(&self, ui: &mut egui::Ui, text: &str) {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
@@ -236,6 +268,10 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn show_debug(&mut self, _ctx: &egui::Context, ui: &mut egui::Ui) {
|
fn show_debug(&mut self, _ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||||
|
ui.collapsing("sysinfo", |ui| {
|
||||||
|
if ui.button("refresh all").clicked() {
|
||||||
|
self.sysinfo.refresh_all();
|
||||||
|
}
|
||||||
let pid = self
|
let pid = self
|
||||||
.sysinfo
|
.sysinfo
|
||||||
.processes()
|
.processes()
|
||||||
@@ -245,10 +281,9 @@ impl App {
|
|||||||
|| "no pid found!".to_string(),
|
|| "no pid found!".to_string(),
|
||||||
|(pid, _)| pid.as_u32().to_string(),
|
|(pid, _)| pid.as_u32().to_string(),
|
||||||
);
|
);
|
||||||
if ui.button("refresh sysinfo").clicked() {
|
|
||||||
self.sysinfo.refresh_all();
|
|
||||||
}
|
|
||||||
ui.label(format!("gta pid: {pid}"));
|
ui.label(format!("gta pid: {pid}"));
|
||||||
|
});
|
||||||
|
ui.collapsing("app state", |ui| ui.label(format!("{:#?}", self)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_timers(&mut self) {
|
fn run_timers(&mut self) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Countdown {
|
pub struct Countdown {
|
||||||
pub i: u64,
|
pub i: u64,
|
||||||
pub i_original: u64,
|
pub i_original: u64,
|
||||||
|
|||||||
Reference in New Issue
Block a user