Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62efe3f411 | ||
|
|
4bb0f151a9 | ||
|
|
1aebc6b17c | ||
|
|
861ebe97d6 | ||
|
|
53b20a437a | ||
|
|
03ca861a09 | ||
|
|
a4ebfc515c | ||
|
|
52ffb34d83 | ||
|
|
6248e8379f | ||
|
|
99bc15b5ed | ||
|
|
e84d1347fd | ||
|
|
f49bb56398 | ||
|
|
99b6519ffb | ||
|
|
807cb5242f | ||
|
|
c1c1547e4d | ||
|
|
6e3aa70398 | ||
|
|
9331f79038 |
Generated
+66
-1
@@ -734,6 +734,27 @@ dependencies = [
|
|||||||
"crypto-common",
|
"crypto-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dirs"
|
||||||
|
version = "6.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
||||||
|
dependencies = [
|
||||||
|
"dirs-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dirs-sys"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"option-ext",
|
||||||
|
"redox_users",
|
||||||
|
"windows-sys 0.59.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch"
|
name = "dispatch"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -1345,13 +1366,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gta-tools"
|
name = "gta-tools"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"catppuccin-egui",
|
"catppuccin-egui",
|
||||||
|
"dirs",
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
"image",
|
"image",
|
||||||
"open",
|
"open",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"static_vcruntime",
|
"static_vcruntime",
|
||||||
"sysinfo",
|
"sysinfo",
|
||||||
"windows 0.61.1",
|
"windows 0.61.1",
|
||||||
@@ -1591,6 +1615,12 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jni"
|
name = "jni"
|
||||||
version = "0.21.1"
|
version = "0.21.1"
|
||||||
@@ -2212,6 +2242,12 @@ dependencies = [
|
|||||||
"pathdiff",
|
"pathdiff",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "option-ext"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbclient"
|
name = "orbclient"
|
||||||
version = "0.3.48"
|
version = "0.3.48"
|
||||||
@@ -2538,6 +2574,17 @@ dependencies = [
|
|||||||
"bitflags 2.9.0",
|
"bitflags 2.9.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_users"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom 0.2.15",
|
||||||
|
"libredox",
|
||||||
|
"thiserror 2.0.12",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "renderdoc-sys"
|
name = "renderdoc-sys"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@@ -2582,6 +2629,12 @@ version = "1.0.20"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
|
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "same-file"
|
name = "same-file"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
@@ -2636,6 +2689,18 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.140"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"memchr",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_repr"
|
name = "serde_repr"
|
||||||
version = "0.1.20"
|
version = "0.1.20"
|
||||||
|
|||||||
+4
-1
@@ -1,16 +1,19 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gta-tools"
|
name = "gta-tools"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
catppuccin-egui = { version = "5.5.0", default-features = false, features = [
|
catppuccin-egui = { version = "5.5.0", default-features = false, features = [
|
||||||
"egui31",
|
"egui31",
|
||||||
] }
|
] }
|
||||||
|
dirs = "6.0.0"
|
||||||
eframe = "0.31.1"
|
eframe = "0.31.1"
|
||||||
egui_extras = { version = "0.31.1", features = ["image"] }
|
egui_extras = { version = "0.31.1", features = ["image"] }
|
||||||
image = { version = "0.25.6", default-features = false, features = ["png"] }
|
image = { version = "0.25.6", default-features = false, features = ["png"] }
|
||||||
open = "5.3.2"
|
open = "5.3.2"
|
||||||
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
|
serde_json = "1.0.140"
|
||||||
sysinfo = "0.34.2"
|
sysinfo = "0.34.2"
|
||||||
windows = { version = "0.61.1", features = [
|
windows = { version = "0.61.1", features = [
|
||||||
"Win32_UI_Input_KeyboardAndMouse",
|
"Win32_UI_Input_KeyboardAndMouse",
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
set windows-shell := ["pwsh", "-NoLogo", "-NoProfileLoadTime", "-Command"]
|
set windows-shell := ["pwsh", "-NoLogo", "-NoProfileLoadTime", "-Command"]
|
||||||
|
|
||||||
install:
|
build:
|
||||||
cargo build --release
|
cargo build --release
|
||||||
upx .\target\release\gta-tools.exe --best
|
upx .\target\release\gta-tools.exe --best
|
||||||
cp .\target\release\gta-tools.exe ~\.cargo\bin\
|
|
||||||
|
install: build
|
||||||
|
cp .\target\release\gta-tools.exe ~\.cargo\bin
|
||||||
|
cp .\target\release\gta-tools.exe ~\Documents
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
|
use crate::util::{self, consts::GTA_WINDOW_TITLE};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use windows::Win32::UI::Input::KeyboardAndMouse::{
|
use windows::Win32::UI::Input::KeyboardAndMouse::{
|
||||||
KEYBD_EVENT_FLAGS, MAP_VIRTUAL_KEY_TYPE, MapVirtualKeyW, keybd_event,
|
KEYBD_EVENT_FLAGS, MAP_VIRTUAL_KEY_TYPE, MapVirtualKeyW, keybd_event,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const INTERVAL: Duration = Duration::from_secs(60);
|
pub const INTERVAL: Duration = Duration::from_secs(60);
|
||||||
const VK_SHIFT: u8 = 16;
|
const VK_NUMPAD4: u8 = 0x64;
|
||||||
|
const VK_NUMPAD6: u8 = 0x66;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct AntiAfk {
|
pub struct AntiAfk {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub interval: Instant,
|
pub interval: Instant,
|
||||||
@@ -20,6 +23,19 @@ impl Default for AntiAfk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AntiAfk {
|
||||||
|
pub fn activate(&mut self) {
|
||||||
|
if util::is_window_focused(GTA_WINDOW_TITLE)
|
||||||
|
&& !util::is_key_pressed(VK_NUMPAD4 as i32)
|
||||||
|
&& !util::is_key_pressed(VK_NUMPAD6 as i32)
|
||||||
|
{
|
||||||
|
send(VK_NUMPAD4);
|
||||||
|
send(VK_NUMPAD6);
|
||||||
|
}
|
||||||
|
self.interval = Instant::now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn send(vk_code: u8) {
|
pub fn send(vk_code: u8) {
|
||||||
unsafe {
|
unsafe {
|
||||||
keybd_event(
|
keybd_event(
|
||||||
@@ -36,7 +52,3 @@ pub fn send(vk_code: u8) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn activate() {
|
|
||||||
send(VK_SHIFT);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ use windows::Win32::{
|
|||||||
System::Threading::{OpenProcess, PROCESS_SUSPEND_RESUME},
|
System::Threading::{OpenProcess, PROCESS_SUSPEND_RESUME},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const INTERVAL: Duration = Duration::from_secs(8);
|
pub const INTERVAL: Duration = Duration::from_secs(10);
|
||||||
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,
|
||||||
@@ -57,7 +58,9 @@ pub fn activate(app: &mut App) {
|
|||||||
|
|
||||||
pub fn deactivate(app: &mut App) {
|
pub fn deactivate(app: &mut App) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let _ = NtResumeProcess(app.game_handle);
|
if !app.game_handle.is_invalid() {
|
||||||
let _ = CloseHandle(app.game_handle);
|
let _ = NtResumeProcess(app.game_handle);
|
||||||
|
let _ = CloseHandle(app.game_handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{fmt::Display, path::PathBuf, process::Command};
|
use std::{fmt::Display, path::PathBuf, process::Command};
|
||||||
use winreg::{RegKey, enums::HKEY_LOCAL_MACHINE};
|
use winreg::{RegKey, enums::HKEY_LOCAL_MACHINE};
|
||||||
|
|
||||||
#[derive(Default, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum Platform {
|
pub enum Platform {
|
||||||
#[default]
|
#[default]
|
||||||
Steam,
|
Steam,
|
||||||
@@ -20,7 +21,7 @@ impl Display for Platform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Launch {
|
pub struct Launch {
|
||||||
pub selected: Platform,
|
pub selected: Platform,
|
||||||
}
|
}
|
||||||
|
|||||||
+194
-83
@@ -7,28 +7,49 @@ use crate::{
|
|||||||
launch::{Launch, Platform},
|
launch::{Launch, Platform},
|
||||||
},
|
},
|
||||||
util::{
|
util::{
|
||||||
consts::{ENHANCED, LEGACY},
|
self,
|
||||||
|
consts::{ENHANCED, GTA_WINDOW_TITLE, LEGACY},
|
||||||
elevation,
|
elevation,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use std::time::{Duration, Instant};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::{
|
||||||
|
fs::{self, File},
|
||||||
|
io::Write,
|
||||||
|
path::PathBuf,
|
||||||
|
sync::LazyLock,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
use sysinfo::System;
|
use sysinfo::System;
|
||||||
use windows::Win32::Foundation::HANDLE;
|
use windows::Win32::Foundation::HANDLE;
|
||||||
|
|
||||||
const THEME: catppuccin_egui::Theme = catppuccin_egui::MOCHA;
|
const THEME: catppuccin_egui::Theme = catppuccin_egui::MOCHA;
|
||||||
|
const WINDOW_SIZE: [f32; 2] = [240.0, 240.0];
|
||||||
|
static CONFIG_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
|
||||||
|
dirs::config_local_dir()
|
||||||
|
.unwrap()
|
||||||
|
.join("GTA Tools")
|
||||||
|
.join("config.json")
|
||||||
|
});
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct PersistentState {
|
||||||
|
launcher: Platform,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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,
|
||||||
|
closing: bool,
|
||||||
debug: bool,
|
debug: bool,
|
||||||
initialized: bool,
|
initialized: bool,
|
||||||
elevated: bool,
|
elevated: bool,
|
||||||
@@ -45,6 +66,7 @@ impl Default for App {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
stage: Stage::default(),
|
stage: Stage::default(),
|
||||||
|
closing: false,
|
||||||
initialized: false,
|
initialized: false,
|
||||||
debug: false,
|
debug: false,
|
||||||
elevated: elevation::is_elevated(),
|
elevated: elevation::is_elevated(),
|
||||||
@@ -64,56 +86,84 @@ impl eframe::App for App {
|
|||||||
if !self.initialized {
|
if !self.initialized {
|
||||||
catppuccin_egui::set_theme(ctx, THEME);
|
catppuccin_egui::set_theme(ctx, THEME);
|
||||||
egui_extras::install_image_loaders(ctx);
|
egui_extras::install_image_loaders(ctx);
|
||||||
self.initialized = true;
|
if let Ok(config) = fs::read_to_string(CONFIG_PATH.as_path()) {
|
||||||
}
|
if let Ok(persistent_state) = serde_json::from_str::<PersistentState>(&config) {
|
||||||
ctx.request_repaint_after(Duration::from_millis(100));
|
self.launch.selected = persistent_state.launcher;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
ctx.style_mut(|style| style.spacing.item_spacing = egui::vec2(4.0, 4.0));
|
||||||
|
self.initialized = true;
|
||||||
|
}
|
||||||
self.run_timers();
|
self.run_timers();
|
||||||
egui::TopBottomPanel::bottom("bottom_panel").show(ctx, |ui| {
|
egui::TopBottomPanel::bottom("bottom_panel")
|
||||||
ui.horizontal(|ui| {
|
.exact_height(25.0)
|
||||||
ui.selectable_value(&mut self.stage, Stage::Main, "Main");
|
.show(ctx, |ui| {
|
||||||
ui.selectable_value(&mut self.stage, Stage::About, "About");
|
ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| {
|
||||||
if self.debug {
|
ui.selectable_value(&mut self.stage, Stage::Main, "Main");
|
||||||
ui.selectable_value(&mut self.stage, Stage::Debug, "Debug");
|
ui.selectable_value(&mut self.stage, Stage::About, "About");
|
||||||
}
|
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"))
|
.on_hover_text("Relaunch ourselves as administrator.")
|
||||||
.on_hover_text("Relaunch ourselves as administrator.")
|
.on_disabled_hover_text("We are already running elevated.");
|
||||||
.on_disabled_hover_text("We are already running elevated.");
|
if button.clicked() {
|
||||||
if button.clicked() {
|
elevation::elevate(&mut self.closing);
|
||||||
elevation::elevate();
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
egui::CentralPanel::default().show(ctx, |ui| match self.stage {
|
||||||
|
Stage::Main => {
|
||||||
|
self.header(ui, "Game");
|
||||||
|
self.show_game(ctx, ui);
|
||||||
|
self.header(ui, "Session");
|
||||||
|
self.show_session(ctx, ui);
|
||||||
|
self.header(ui, "Network");
|
||||||
|
self.show_network(ctx, ui);
|
||||||
|
}
|
||||||
|
Stage::About => self.show_about(ctx, ui),
|
||||||
});
|
});
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
if check_debug_keycombo_pressed(ctx) {
|
||||||
egui::ScrollArea::both()
|
self.debug = !self.debug;
|
||||||
.auto_shrink([false, false])
|
}
|
||||||
.show(ui, |ui| match self.stage {
|
if check_debug_viewport_close_button_pressed(ctx) {
|
||||||
Stage::Main => {
|
self.debug = false;
|
||||||
self.header(ui, "Game");
|
}
|
||||||
self.show_game(ctx, ui);
|
if self.debug {
|
||||||
self.header(ui, "Session");
|
let main_rect = ctx.input(|i| {
|
||||||
self.show_session(ctx, ui);
|
i.viewport()
|
||||||
self.header(ui, "Network");
|
.clone()
|
||||||
self.show_network(ctx, ui);
|
.outer_rect
|
||||||
|
.unwrap_or(egui::Rect::EVERYTHING)
|
||||||
|
});
|
||||||
|
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(WINDOW_SIZE)
|
||||||
|
.with_position(position)
|
||||||
|
.with_icon(load_icon()),
|
||||||
|
|ctx, _class| {
|
||||||
|
if check_debug_keycombo_pressed(ctx) {
|
||||||
|
self.debug = !self.debug;
|
||||||
}
|
}
|
||||||
Stage::About => {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
self.show_about(ctx, ui);
|
egui::ScrollArea::both()
|
||||||
}
|
.auto_shrink([false, false])
|
||||||
Stage::Debug => {
|
.show(ui, |ui| {
|
||||||
self.show_debug(ctx, ui);
|
self.show_debug(ctx, ui);
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
ctx.request_repaint_after(Duration::from_millis(100));
|
||||||
|
if self.closing {
|
||||||
|
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +202,10 @@ impl App {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
let force_close_button = ui.button(&self.force_close.button_text);
|
let force_close_button = ui.add_sized(
|
||||||
|
[104.0, 0.0],
|
||||||
|
egui::Button::new(&self.force_close.button_text),
|
||||||
|
);
|
||||||
if force_close_button.clicked() && !self.force_close.prompting {
|
if force_close_button.clicked() && !self.force_close.prompting {
|
||||||
self.force_close.prompting();
|
self.force_close.prompting();
|
||||||
self.current_frame = true;
|
self.current_frame = true;
|
||||||
@@ -183,12 +236,23 @@ impl App {
|
|||||||
ui.label(&self.empty_session.countdown.i_string);
|
ui.label(&self.empty_session.countdown.i_string);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ui.checkbox(&mut self.anti_afk.enabled, "Anti AFK")
|
ui.horizontal(|ui| {
|
||||||
.on_hover_text("You should be tabbed in\nwhile this is enabled.");
|
ui.checkbox(&mut self.anti_afk.enabled, "Anti AFK")
|
||||||
|
.on_hover_text("You should be tabbed in\nfor this to work.");
|
||||||
|
if self.anti_afk.enabled {
|
||||||
|
ui.add_space(8.0);
|
||||||
|
ui.add_enabled_ui(false, |ui| {
|
||||||
|
ui.label(if util::is_window_focused(GTA_WINDOW_TITLE) {
|
||||||
|
"GTA is focused."
|
||||||
|
} else {
|
||||||
|
"GTA is not focused!"
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
if self.anti_afk.enabled && self.anti_afk.interval.elapsed() >= features::anti_afk::INTERVAL
|
if self.anti_afk.enabled && self.anti_afk.interval.elapsed() >= features::anti_afk::INTERVAL
|
||||||
{
|
{
|
||||||
features::anti_afk::activate();
|
self.anti_afk.activate();
|
||||||
self.anti_afk.interval = Instant::now();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,19 +262,28 @@ impl App {
|
|||||||
.stroke(egui::Stroke::new(1.0, THEME.overlay1))
|
.stroke(egui::Stroke::new(1.0, THEME.overlay1))
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
let response = ui.add_enabled_ui(self.elevated, |ui| {
|
let response = ui.add_enabled_ui(self.elevated, |ui| {
|
||||||
ui.label("Game's network access");
|
let label = ui.label("Game's network access");
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if ui.button("Block").clicked() {
|
let available_width = label.rect.width();
|
||||||
|
let spacing = ui.spacing().item_spacing.x;
|
||||||
|
let button_width = (available_width - spacing) / 2.0;
|
||||||
|
if ui
|
||||||
|
.add_sized([button_width, 18.0], egui::Button::new("Block"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
features::game_networking::block_all(&mut self.sysinfo);
|
features::game_networking::block_all(&mut self.sysinfo);
|
||||||
};
|
};
|
||||||
if ui.button("Unblock").clicked() {
|
if ui
|
||||||
|
.add_sized([button_width, 18.0], egui::Button::new("Unblock"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
features::game_networking::unblock_all();
|
features::game_networking::unblock_all();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
response
|
response.response.on_disabled_hover_text(
|
||||||
.response
|
"This requires administrator.\nUse the Elevate button.",
|
||||||
.on_disabled_hover_text("This requires administrator.\nUse the Elevate button.")
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,24 +304,33 @@ impl App {
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ui.add(egui::Image::new(egui::include_image!("../assets/icon.png")))
|
ui.add(egui::Image::new(egui::include_image!("../assets/icon.png")));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_debug(&mut self, _ctx: &egui::Context, ui: &mut egui::Ui) {
|
fn show_debug(&mut self, _ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||||
let pid = self
|
ui.collapsing("times", |ui| {
|
||||||
.sysinfo
|
ui.label(format!(
|
||||||
.processes()
|
"anti afk timer: {}",
|
||||||
.iter()
|
self.anti_afk.interval.elapsed().as_secs()
|
||||||
.find(|(_, p)| p.name() == ENHANCED || p.name() == LEGACY)
|
))
|
||||||
.map_or_else(
|
});
|
||||||
|| "no pid found!".to_string(),
|
ui.collapsing("sysinfo", |ui| {
|
||||||
|(pid, _)| pid.as_u32().to_string(),
|
if ui.button("refresh all").clicked() {
|
||||||
);
|
self.sysinfo.refresh_all();
|
||||||
if ui.button("refresh sysinfo").clicked() {
|
}
|
||||||
self.sysinfo.refresh_all();
|
let pid = self
|
||||||
}
|
.sysinfo
|
||||||
ui.label(format!("gta pid: {pid}"));
|
.processes()
|
||||||
|
.iter()
|
||||||
|
.find(|(_, p)| p.name() == ENHANCED || p.name() == LEGACY)
|
||||||
|
.map_or_else(
|
||||||
|
|| "no pid found!".to_string(),
|
||||||
|
|(pid, _)| pid.as_u32().to_string(),
|
||||||
|
);
|
||||||
|
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) {
|
||||||
@@ -264,18 +346,47 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for App {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
// save any persistent state to config file
|
||||||
|
let persistent_state = PersistentState {
|
||||||
|
launcher: self.launch.selected,
|
||||||
|
};
|
||||||
|
let config_path = CONFIG_PATH.as_path();
|
||||||
|
let config_path_parent = config_path.parent().unwrap();
|
||||||
|
if !config_path_parent.exists() {
|
||||||
|
fs::create_dir(config_path_parent).unwrap();
|
||||||
|
}
|
||||||
|
let mut config_file = File::create(config_path).unwrap();
|
||||||
|
let json = serde_json::to_string_pretty(&persistent_state).unwrap();
|
||||||
|
config_file.write_all(json.as_bytes()).unwrap();
|
||||||
|
// make sure we are not suspending game
|
||||||
|
features::empty_session::deactivate(self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_debug_keycombo_pressed(ctx: &egui::Context) -> bool {
|
||||||
|
ctx.input(|i| i.modifiers.all() && i.key_pressed(egui::Key::D))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_debug_viewport_close_button_pressed(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()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn load_icon() -> eframe::egui::IconData {
|
fn load_icon() -> eframe::egui::IconData {
|
||||||
let (icon_rgba, icon_width, icon_height) = {
|
let icon = include_bytes!("../assets/icon.png");
|
||||||
let icon = include_bytes!("../assets/icon.png");
|
let image = image::load_from_memory(icon).unwrap().into_rgba8();
|
||||||
let image = image::load_from_memory(icon).unwrap().into_rgba8();
|
let (width, height) = image.dimensions();
|
||||||
let (width, height) = image.dimensions();
|
|
||||||
let rgba = image.into_raw();
|
|
||||||
(rgba, width, height)
|
|
||||||
};
|
|
||||||
eframe::egui::IconData {
|
eframe::egui::IconData {
|
||||||
rgba: icon_rgba,
|
rgba: image.into_raw(),
|
||||||
width: icon_width,
|
width,
|
||||||
height: icon_height,
|
height,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +395,7 @@ pub fn run() {
|
|||||||
viewport: egui::ViewportBuilder::default()
|
viewport: egui::ViewportBuilder::default()
|
||||||
.with_resizable(false)
|
.with_resizable(false)
|
||||||
.with_maximize_button(false)
|
.with_maximize_button(false)
|
||||||
.with_inner_size([256.0, 232.0])
|
.with_inner_size(WINDOW_SIZE)
|
||||||
.with_icon(load_icon()),
|
.with_icon(load_icon()),
|
||||||
centered: true,
|
centered: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
pub const ENHANCED: &str = "GTA5_Enhanced.exe";
|
pub const ENHANCED: &str = "GTA5_Enhanced.exe";
|
||||||
pub const LEGACY: &str = "GTA5.exe";
|
pub const LEGACY: &str = "GTA5.exe";
|
||||||
|
|
||||||
|
pub const GTA_WINDOW_TITLE: &str = "Grand Theft Auto V";
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use windows::{
|
|||||||
core::{HSTRING, PCWSTR},
|
core::{HSTRING, PCWSTR},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn elevate() {
|
pub fn elevate(closing: &mut bool) {
|
||||||
let exe = std::env::current_exe().unwrap();
|
let exe = std::env::current_exe().unwrap();
|
||||||
unsafe {
|
unsafe {
|
||||||
ShellExecuteW(
|
ShellExecuteW(
|
||||||
@@ -18,7 +18,7 @@ pub fn elevate() {
|
|||||||
SW_HIDE,
|
SW_HIDE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
std::process::exit(0);
|
*closing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_elevated() -> bool {
|
pub fn is_elevated() -> bool {
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
pub mod consts;
|
pub mod consts;
|
||||||
pub mod countdown;
|
pub mod countdown;
|
||||||
pub mod elevation;
|
pub mod elevation;
|
||||||
|
|
||||||
|
use windows::Win32::UI::{
|
||||||
|
Input::KeyboardAndMouse::GetAsyncKeyState,
|
||||||
|
WindowsAndMessaging::{GetForegroundWindow, GetWindowTextW},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn is_window_focused(target_title: &str) -> bool {
|
||||||
|
unsafe {
|
||||||
|
let hwnd = GetForegroundWindow();
|
||||||
|
let mut buffer: [u16; 512] = [0; 512];
|
||||||
|
let length = GetWindowTextW(hwnd, &mut buffer);
|
||||||
|
let current_title = String::from_utf16_lossy(&buffer[..length as usize]);
|
||||||
|
current_title == target_title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_key_pressed(key: i32) -> bool {
|
||||||
|
unsafe { (GetAsyncKeyState(key) as i32 & 0x8000) != 0 }
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user