2022-10-01 16:58:22 +00:00
|
|
|
// Gupax - GUI Uniting P2Pool And XMRig
|
|
|
|
//
|
2023-02-26 16:45:58 +00:00
|
|
|
// Copyright (c) 2022-2023 hinto-janai
|
2022-10-01 16:58:22 +00:00
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2022-10-31 20:08:25 +00:00
|
|
|
// Hide console in Windows
|
2022-11-22 02:01:50 +00:00
|
|
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
2022-10-15 19:15:27 +00:00
|
|
|
|
2023-05-30 14:15:56 +00:00
|
|
|
// Only (windows|macos|linux) + (x64|arm64) are supported.
|
|
|
|
#[cfg(not(target_pointer_width = "64"))]
|
|
|
|
compile_error!("gupax is only compatible with 64-bit CPUs");
|
|
|
|
|
2024-02-26 07:01:53 +00:00
|
|
|
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux",)))]
|
2023-05-30 14:15:56 +00:00
|
|
|
compile_error!("gupax is only built for windows/macos/linux");
|
|
|
|
|
2024-03-03 07:31:22 +00:00
|
|
|
use crate::app::App;
|
2022-10-15 19:15:27 +00:00
|
|
|
//---------------------------------------------------------------------------------------------------- Imports
|
2024-03-03 07:31:22 +00:00
|
|
|
use crate::constants::*;
|
|
|
|
use crate::inits::init_auto;
|
|
|
|
use crate::inits::init_logger;
|
|
|
|
use crate::inits::init_options;
|
|
|
|
use crate::miscs::clean_dir;
|
|
|
|
use crate::utils::*;
|
|
|
|
use egui::Vec2;
|
|
|
|
use log::info;
|
|
|
|
use log::warn;
|
|
|
|
use std::time::Instant;
|
|
|
|
|
|
|
|
mod app;
|
|
|
|
mod components;
|
2022-11-14 02:56:25 +00:00
|
|
|
mod disk;
|
2022-11-30 03:38:01 +00:00
|
|
|
mod helper;
|
2024-03-03 07:31:22 +00:00
|
|
|
mod inits;
|
|
|
|
mod miscs;
|
|
|
|
mod utils;
|
2022-10-01 16:58:22 +00:00
|
|
|
|
2022-12-10 02:00:33 +00:00
|
|
|
// Sudo (dummy values for Windows)
|
2022-12-07 23:02:08 +00:00
|
|
|
#[cfg(target_family = "unix")]
|
2022-12-10 02:00:33 +00:00
|
|
|
extern crate sudo as sudo_check;
|
2022-12-07 23:02:08 +00:00
|
|
|
|
2022-10-15 19:15:27 +00:00
|
|
|
//---------------------------------------------------------------------------------------------------- Main [App] frame
|
|
|
|
fn main() {
|
2024-02-26 07:01:53 +00:00
|
|
|
let now = Instant::now();
|
|
|
|
|
|
|
|
// Set custom panic hook.
|
|
|
|
crate::panic::set_panic_hook(now);
|
|
|
|
|
|
|
|
// Init logger.
|
|
|
|
init_logger(now);
|
|
|
|
let mut app = App::new(now);
|
|
|
|
init_auto(&mut app);
|
|
|
|
|
|
|
|
// Init GUI stuff.
|
|
|
|
let selected_width = app.state.gupax.selected_width as f32;
|
|
|
|
let selected_height = app.state.gupax.selected_height as f32;
|
|
|
|
let initial_window_size = if selected_width > APP_MAX_WIDTH || selected_height > APP_MAX_HEIGHT
|
|
|
|
{
|
|
|
|
warn!("App | Set width or height was greater than the maximum! Starting with the default resolution...");
|
|
|
|
Some(Vec2::new(APP_DEFAULT_WIDTH, APP_DEFAULT_HEIGHT))
|
|
|
|
} else {
|
|
|
|
Some(Vec2::new(
|
|
|
|
app.state.gupax.selected_width as f32,
|
|
|
|
app.state.gupax.selected_height as f32,
|
|
|
|
))
|
|
|
|
};
|
|
|
|
let options = init_options(initial_window_size);
|
|
|
|
|
|
|
|
// Gupax folder cleanup.
|
|
|
|
match clean_dir() {
|
|
|
|
Ok(_) => info!("Temporary folder cleanup ... OK"),
|
|
|
|
Err(e) => warn!("Could not cleanup [gupax_tmp] folders: {}", e),
|
|
|
|
}
|
|
|
|
|
|
|
|
let resolution = Vec2::new(selected_width, selected_height);
|
|
|
|
|
|
|
|
// Run Gupax.
|
|
|
|
info!("/*************************************/ Init ... OK /*************************************/");
|
2024-03-03 07:31:22 +00:00
|
|
|
let _ = eframe::run_native(
|
2024-02-26 07:01:53 +00:00
|
|
|
&app.name_version.clone(),
|
|
|
|
options,
|
2024-03-03 07:31:22 +00:00
|
|
|
Box::new(move |cc| {
|
|
|
|
egui_extras::install_image_loaders(&cc.egui_ctx);
|
|
|
|
Box::new(App::cc(cc, resolution, app))
|
|
|
|
}),
|
2024-02-26 07:01:53 +00:00
|
|
|
);
|
2022-10-15 19:15:27 +00:00
|
|
|
}
|