Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #51

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ edition = "2021"

[dependencies]
rand = "0.8"
device_query = "1.1"
eframe = "0.21" # Gives us egui, epi and web+native backends
device_query = "2.1.0"
eframe = "0.30.0" # Gives us egui, epi and web+native backends
image = "0.24"
rdev = "0.5"
sanitizer = { version = "0.1", features = ["derive"] }
Expand Down
33 changes: 19 additions & 14 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,38 +147,43 @@ impl RustyAutoClickerApp {
///
/// # Arguments
///
/// * `frame` - The frame to manipulate
pub fn enter_coordinate_setting(&mut self, frame: &mut eframe::Frame) {
/// * `ctx` - The ctx to manipulate
pub fn enter_coordinate_setting(&mut self, ctx: &egui::Context) {
self.is_setting_coord = true;
self.window_position = frame.info().window_info.position.unwrap();
frame.set_window_size(egui::vec2(400f32, 30f32));
frame.set_decorations(false);
self.window_position =
ctx.input(|input_state| input_state.viewport().outer_rect.unwrap().min);
ctx.send_viewport_cmd(egui::ViewportCommand::InnerSize(egui::vec2(400f32, 30f32)));
ctx.send_viewport_cmd(egui::ViewportCommand::Decorations(false));
}

/// Make frame follow cursor with an offset
///
/// # Arguments
///
/// * `frame` - The frame to set the window position on
pub fn follow_cursor(&mut self, frame: &mut eframe::Frame) {
/// * `ctx` - The ctx to set the window position on
pub fn follow_cursor(&mut self, ctx: &egui::Context) {
let offset = egui::Vec2 { x: 15f32, y: 15f32 };
frame.set_window_pos(
ctx.send_viewport_cmd(egui::ViewportCommand::OuterPosition(
egui::pos2(
self.click_x_str.parse().unwrap(),
self.click_y_str.parse().unwrap(),
) + offset,
);
));
}

/// Exit the coordinate setting mode
///
/// # Arguments
///
/// * `frame` - The frame to manipulate
pub fn exit_coordinate_setting(&mut self, frame: &mut eframe::Frame) {
frame.set_decorations(true);
frame.set_window_size(egui::vec2(WINDOW_WIDTH, WINDOW_HEIGHT));
frame.set_window_pos(self.window_position);
/// * `ctx` - The ctx to manipulate
pub fn exit_coordinate_setting(&mut self, ctx: &egui::Context) {
ctx.send_viewport_cmd(egui::ViewportCommand::Decorations(true));
ctx.send_viewport_cmd(egui::ViewportCommand::InnerSize(egui::vec2(
WINDOW_WIDTH,
WINDOW_HEIGHT,
)));
ctx.send_viewport_cmd(egui::ViewportCommand::OuterPosition(self.window_position));

self.is_setting_coord = false;
self.click_position = ClickPosition::Coord;
}
Expand Down
63 changes: 29 additions & 34 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl eframe::App for RustyAutoClickerApp {

/// Called each time the UI needs repainting, which may be many times per second.
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
// Print time to between start of old and new frames
#[cfg(debug_assertions)]
println!(
Expand Down Expand Up @@ -183,7 +183,7 @@ impl eframe::App for RustyAutoClickerApp {
if mouse.button_pressed[1]
|| (self.key_set_coord.is_some() && keys.contains(&self.key_set_coord.unwrap()))
{
Self::exit_coordinate_setting(self, frame);
Self::exit_coordinate_setting(self, ctx);
}
}

Expand All @@ -203,7 +203,7 @@ impl eframe::App for RustyAutoClickerApp {
ui.horizontal_wrapped(|ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.click_y_str)
Expand All @@ -212,7 +212,7 @@ impl eframe::App for RustyAutoClickerApp {
);
ui.label("Y");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.click_x_str)
Expand All @@ -229,7 +229,7 @@ impl eframe::App for RustyAutoClickerApp {
});
})
});
Self::follow_cursor(self, frame);
Self::follow_cursor(self, ctx);
} else {
// GUI
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
Expand All @@ -244,7 +244,7 @@ impl eframe::App for RustyAutoClickerApp {
};
} else {
if self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
}
let text: String = if self.key_autoclick.is_none() {
"🖱 START".to_string()
Expand All @@ -270,12 +270,12 @@ impl eframe::App for RustyAutoClickerApp {
ui.label("App Mode: ");

if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.selectable_value(&mut self.app_mode, AppMode::Bot, "🖥 Bot")
.on_hover_text("Autoclick as fast as possible");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.selectable_value(&mut self.app_mode, AppMode::Humanlike, "😆 Humanlike")
.on_hover_text("Autoclick emulating human clicking");
Expand All @@ -291,7 +291,7 @@ impl eframe::App for RustyAutoClickerApp {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
ui.label("ms");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.ms_str)
Expand All @@ -301,7 +301,7 @@ impl eframe::App for RustyAutoClickerApp {

ui.label("sec");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.sec_str)
Expand All @@ -311,7 +311,7 @@ impl eframe::App for RustyAutoClickerApp {

ui.label("min");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.min_str)
Expand All @@ -321,7 +321,7 @@ impl eframe::App for RustyAutoClickerApp {

ui.label("hr");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.hr_str)
Expand All @@ -337,7 +337,7 @@ impl eframe::App for RustyAutoClickerApp {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
ui.label("ms");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.movement_ms_str)
Expand All @@ -347,7 +347,7 @@ impl eframe::App for RustyAutoClickerApp {

ui.label("sec");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.movement_sec_str)
Expand All @@ -362,15 +362,15 @@ impl eframe::App for RustyAutoClickerApp {
ui.label("Mouse Button");
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.selectable_value(&mut self.click_btn, Button::Right, "Right");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.selectable_value(&mut self.click_btn, Button::Middle, "Middle");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.selectable_value(&mut self.click_btn, Button::Left, "Left");
});
Expand All @@ -382,11 +382,11 @@ impl eframe::App for RustyAutoClickerApp {
ui.label("Click Type");
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.selectable_value(&mut self.click_type, ClickType::Double, "Double");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.selectable_value(&mut self.click_type, ClickType::Single, "Single");
});
Expand All @@ -398,7 +398,7 @@ impl eframe::App for RustyAutoClickerApp {
ui.label("Click Amount (0 = forever)");
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.click_amount_str)
Expand All @@ -418,17 +418,17 @@ impl eframe::App for RustyAutoClickerApp {
ui.horizontal_wrapped(|ui| {
ui.label("Click Position");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
if ui
.add_sized([80.0f32, 16.0f32], egui::widgets::Button::new("Set Coords"))
.clicked()
{
Self::enter_coordinate_setting(self, frame);
Self::enter_coordinate_setting(self, ctx);
};
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.click_y_str)
Expand All @@ -437,7 +437,7 @@ impl eframe::App for RustyAutoClickerApp {
);
ui.label("Y");
if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
ui.add(
egui::TextEdit::singleline(&mut self.click_x_str)
Expand All @@ -447,7 +447,7 @@ impl eframe::App for RustyAutoClickerApp {
ui.label("X");

if self.is_autoclicking || self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
};
if ui
.selectable_value(
Expand Down Expand Up @@ -501,7 +501,7 @@ impl eframe::App for RustyAutoClickerApp {
ui.with_layout(egui::Layout::top_down(egui::Align::Center), |ui| {
if self.is_autoclicking {
if self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
}
if ui
.add_sized(
Expand All @@ -517,7 +517,7 @@ impl eframe::App for RustyAutoClickerApp {
};
} else {
if self.hotkey_window_open {
ui.set_enabled(false);
ui.disable();
}
let text: String = if self.key_autoclick.is_none() {
"🖱 START".to_string()
Expand Down Expand Up @@ -585,7 +585,7 @@ impl eframe::App for RustyAutoClickerApp {
}
};
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
ui.set_enabled(false);
ui.disable();
let text: String = if self.key_autoclick.is_none() {
"PRESS ANY KEY".to_string()
} else {
Expand Down Expand Up @@ -614,7 +614,7 @@ impl eframe::App for RustyAutoClickerApp {
}
};
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
ui.set_enabled(false);
ui.disable();
let text: String = if self.key_set_coord.is_none() {
"PRESS ANY KEY".to_string()
} else {
Expand All @@ -637,10 +637,5 @@ impl eframe::App for RustyAutoClickerApp {
.checked_duration_since(self.frame_start)
.unwrap()
);

// On web, the browser controls the gui zoom.
if !frame.is_web() {
egui::gui_zoom::zoom_with_keyboard_shortcuts(ctx, frame.info().native_pixels_per_point);
}
}
}
17 changes: 10 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ use crate::{
// When compiling natively
#[cfg(not(target_arch = "wasm32"))]
fn main() {
use eframe::egui::ViewportBuilder;

let native_options = eframe::NativeOptions {
always_on_top: true,
decorated: true,
initial_window_size: Some(egui::vec2(WINDOW_WIDTH, WINDOW_HEIGHT)),
resizable: false,
transparent: true,
icon_data: Some(load_icon()),
viewport: ViewportBuilder::default()
.with_always_on_top()
.with_decorations(true)
.with_inner_size(egui::vec2(WINDOW_WIDTH, WINDOW_HEIGHT))
.with_resizable(true)
.with_transparent(true)
.with_icon(load_icon()),
..Default::default()
};

Expand All @@ -35,7 +38,7 @@ fn main() {
native_options,
Box::new(|cc| {
cc.egui_ctx.set_visuals(egui::Visuals::dark());
Box::new(RustyAutoClickerApp::new(cc))
Ok(Box::new(RustyAutoClickerApp::new(cc)))
}),
)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
};

/// Load icon from memory and return it
pub fn load_icon() -> eframe::IconData {
pub fn load_icon() -> eframe::egui::IconData {
let (icon_rgba, icon_width, icon_height) = {
let image = image::load_from_memory(APP_ICON)
.expect("Failed to open icon path")
Expand All @@ -26,7 +26,7 @@ pub fn load_icon() -> eframe::IconData {
(rgba, width, height)
};

eframe::IconData {
eframe::egui::IconData {
rgba: icon_rgba,
width: icon_width,
height: icon_height,
Expand Down
Loading