You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.6 KiB
Rust
87 lines
2.6 KiB
Rust
#![windows_subsystem = "windows"]
|
|
|
|
mod cli_args;
|
|
mod silent_uninstaller;
|
|
mod tui_uninstaller;
|
|
mod uninstall_form;
|
|
|
|
use cli_args::{UninstallerArgs, RunMode};
|
|
use clean_flash_ui::renderer::Renderer;
|
|
use minifb::{Key, MouseButton, MouseMode, Window, WindowOptions};
|
|
use uninstall_form::{UninstallForm, HEIGHT, WIDTH};
|
|
|
|
fn run_gui() {
|
|
let title = format!(
|
|
"Clean Flash Player {} Uninstaller",
|
|
clean_flash_common::update_checker::FLASH_VERSION
|
|
);
|
|
|
|
let scale = clean_flash_ui::get_dpi_scale();
|
|
let phys_w = (WIDTH as f32 * scale).round() as usize;
|
|
let phys_h = (HEIGHT as f32 * scale).round() as usize;
|
|
|
|
let mut window = Window::new(
|
|
&title,
|
|
phys_w,
|
|
phys_h,
|
|
WindowOptions {
|
|
resize: false,
|
|
..WindowOptions::default()
|
|
},
|
|
)
|
|
.expect("Failed to create window");
|
|
|
|
// Set window icon from the resource embedded by build.rs.
|
|
clean_flash_ui::set_window_icon(&window);
|
|
|
|
window.set_target_fps(60);
|
|
|
|
let mut renderer = Renderer::new(phys_w, phys_h);
|
|
let mut form = UninstallForm::new(scale);
|
|
|
|
while window.is_open() && !window.is_key_down(Key::Escape)
|
|
&& !(window.is_key_down(Key::F4)
|
|
&& (window.is_key_down(Key::LeftAlt) || window.is_key_down(Key::RightAlt)))
|
|
{
|
|
let (mx, my) = window
|
|
.get_mouse_pos(MouseMode::Clamp)
|
|
.unwrap_or((0.0, 0.0));
|
|
let mouse_down = window.get_mouse_down(MouseButton::Left);
|
|
|
|
form.update_and_draw(&mut renderer, mx as i32, my as i32, mouse_down);
|
|
|
|
window
|
|
.update_with_buffer(&renderer.buffer, phys_w, phys_h)
|
|
.expect("Failed to update window buffer");
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let args: UninstallerArgs = argh::from_env();
|
|
|
|
match args.determine_mode() {
|
|
RunMode::Silent => {
|
|
if let Err(e) = silent_uninstaller::run_silent_uninstall(&args) {
|
|
eprintln!("[!] Fatal error: {}", e);
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
RunMode::Tui => {
|
|
if let Err(e) = tui_uninstaller::run_tui_uninstaller() {
|
|
eprintln!("[!] TUI error: {}", e);
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
RunMode::Gui => {
|
|
let gui_result = std::panic::catch_unwind(run_gui);
|
|
if gui_result.is_err() {
|
|
eprintln!("GUI failed to initialize, falling back to terminal UI...");
|
|
if let Err(e) = tui_uninstaller::run_tui_uninstaller() {
|
|
eprintln!("[!] TUI error: {}", e);
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|