feat: rewriting of UI code, top bar, bottom bar, resizing

- use standard fonts
- immediate resizing
- top bar reworked
- bottom bar reworked
- simpler code for UI
- XvB add hover text simple/advanced button
This commit is contained in:
Cyrix126 2024-11-18 22:41:48 +01:00
parent 8c2b518bf3
commit ea6aa7d363
25 changed files with 857 additions and 1402 deletions

23
Cargo.lock generated
View file

@ -2102,6 +2102,7 @@ dependencies = [
"static_vcruntime",
"strip-ansi-escapes",
"strsim",
"strum",
"sudo",
"sysinfo",
"tar",
@ -4352,6 +4353,28 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
dependencies = [
"heck",
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.87",
]
[[package]]
name = "subtle"
version = "2.6.1"

View file

@ -71,7 +71,7 @@ walkdir = "2.5.0"
zeroize = "1.8.1"
strsim = "0.11.1"
strip-ansi-escapes = "0.2.0"
derive_more = {version="1.0.0", default-features=false, features=["display"]}
derive_more = {version="1.0.0", default-features=false, features=["display", "deref", "deref_mut"]}
serde-this-or-that = "0.4.2"
readable = "0.16"
chrono = {version="0.4.38", default-features=false, features=["clock", "std"]}
@ -80,6 +80,7 @@ bounded-vec-deque = {version="0.1.1", default-features=false}
cfg-if = "1.0"
flexi_logger = "0.29"
eframe = {version="0.29.1", features=["wgpu"]}
strum = {version="0.26", features=["derive"]}
# Unix dependencies
[target.'cfg(unix)'.dependencies]
tar = "0.4.42"

View file

@ -1,11 +1,14 @@
use std::sync::{Arc, Mutex};
use super::App;
#[cfg(target_os = "windows")]
use crate::errors::{process_running, ErrorButtons, ErrorFerris};
#[cfg(target_os = "windows")]
use crate::helper::ProcessName;
use crate::helper::ProcessState;
use crate::SECOND;
use egui::CentralPanel;
use crate::helper::{Helper, ProcessName, ProcessState};
use crate::inits::init_text_styles;
use crate::{NODE_MIDDLE, P2POOL_MIDDLE, SECOND, XMRIG_MIDDLE, XMRIG_PROXY_MIDDLE, XVB_MIDDLE};
use derive_more::derive::{Deref, DerefMut};
use log::debug;
impl eframe::App for App {
@ -27,52 +30,12 @@ impl eframe::App for App {
// These values are checked multiple times so
// might as well check only once here to save
// on a bunch of [.lock().unwrap()]s.
debug!("App | Locking and collecting Node state...");
let node = self.node.lock().unwrap();
let node_is_alive = node.is_alive();
let node_is_waiting = node.is_waiting();
let node_state = node.state;
drop(node);
debug!("App | Locking and collecting P2Pool state...");
let p2pool = self.p2pool.lock().unwrap();
let p2pool_is_alive = p2pool.is_alive();
let p2pool_is_waiting = p2pool.is_waiting();
let p2pool_state = p2pool.state;
drop(p2pool);
debug!("App | Locking and collecting XMRig state...");
let xmrig = self.xmrig.lock().unwrap();
let xmrig_is_alive = xmrig.is_alive();
let xmrig_is_waiting = xmrig.is_waiting();
let xmrig_state = xmrig.state;
drop(xmrig);
debug!("App | Locking and collecting XMRig-Proxy state...");
let xmrig_proxy = self.xmrig_proxy.lock().unwrap();
let xmrig_proxy_is_alive = xmrig_proxy.is_alive();
let xmrig_proxy_is_waiting = xmrig_proxy.is_waiting();
let xmrig_proxy_state = xmrig_proxy.state;
drop(xmrig_proxy);
debug!("App | Locking and collecting XvB state...");
let xvb = self.xvb.lock().unwrap();
let xvb_is_alive = xvb.is_alive();
let xvb_is_waiting = xvb.is_waiting();
let xvb_is_running = xvb.state == ProcessState::Alive;
let xvb_state = xvb.state;
drop(xvb);
// This sets the top level Ui dimensions.
// Used as a reference for other uis.
debug!("App | Setting width/height");
CentralPanel::default().show(ctx, |ui| {
let available_width = ui.available_width();
if self.size.x != available_width {
self.size.x = available_width;
if self.now.elapsed().as_secs() > 5 {
self.must_resize = true;
}
};
self.size.y = ui.available_height();
});
self.resize(ctx);
let mut process_states = ProcessStatesGui::new(self);
// resize window and fonts if button "set" has been clicked in Gupaxx tab
if self.must_resize {
init_text_styles(ctx, self.state.gupax.selected_scale);
self.must_resize = false;
}
// check for windows that a local instance of xmrig is not running outside of Gupaxx. Important because it could lead to crashes on this platform.
// Warn only once per restart of Gupaxx.
#[cfg(target_os = "windows")]
@ -86,7 +49,7 @@ impl eframe::App for App {
// If there's an error, display [ErrorState] on the whole screen until user responds
debug!("App | Checking if there is an error in [ErrorState]");
if self.error_state.error {
self.quit_error_panel(ctx, p2pool_is_alive, xmrig_is_alive, &key);
self.quit_error_panel(ctx, &process_states, &key);
return;
}
// Compare [og == state] & [node_vec/pool_vec] and enable diff if found.
@ -107,40 +70,80 @@ impl eframe::App for App {
drop(og);
self.top_panel(ctx);
self.bottom_panel(
ctx,
node_state,
p2pool_state,
xmrig_state,
xmrig_proxy_state,
xvb_state,
&key,
wants_input,
p2pool_is_waiting,
xmrig_is_waiting,
node_is_waiting,
xmrig_proxy_is_waiting,
xvb_is_waiting,
p2pool_is_alive,
xmrig_is_alive,
node_is_alive,
xmrig_proxy_is_alive,
xvb_is_alive,
);
self.bottom_panel(ctx, &key, wants_input, &process_states);
// xvb_is_alive is not the same for bottom and for middle.
// for status we don't want to enable the column when it is retrying request
// but for bottom we don't want the user to be able to start it in this case.
let xvb_is_alive = xvb_state != ProcessState::Dead;
self.middle_panel(
ctx,
frame,
key,
node_is_alive,
p2pool_is_alive,
xmrig_is_alive,
xmrig_proxy_is_alive,
xvb_is_alive,
xvb_is_running,
);
// for status we don't want to enable the column when it is retrying requests.
// but also we don't want the user to be able to start it in this case.
let p_xvb = process_states.find_mut(ProcessName::Xvb);
p_xvb.alive = p_xvb.state != ProcessState::Dead;
self.middle_panel(ctx, frame, key, &process_states);
}
}
#[derive(Debug)]
pub struct ProcessStateGui {
pub name: ProcessName,
pub state: ProcessState,
pub alive: bool,
pub waiting: bool,
}
impl ProcessStateGui {
pub fn run_middle_msg(&self) -> &str {
match self.name {
ProcessName::Node => NODE_MIDDLE,
ProcessName::P2pool => P2POOL_MIDDLE,
ProcessName::Xmrig => XMRIG_MIDDLE,
ProcessName::XmrigProxy => XMRIG_PROXY_MIDDLE,
ProcessName::Xvb => XVB_MIDDLE,
}
}
pub fn stop(&self, helper: &Arc<Mutex<Helper>>) {
match self.name {
ProcessName::Node => Helper::stop_node(helper),
ProcessName::P2pool => Helper::stop_p2pool(helper),
ProcessName::Xmrig => Helper::stop_xmrig(helper),
ProcessName::XmrigProxy => Helper::stop_xp(helper),
ProcessName::Xvb => Helper::stop_xvb(helper),
}
}
}
#[derive(Deref, DerefMut, Debug)]
pub struct ProcessStatesGui(Vec<ProcessStateGui>);
impl ProcessStatesGui {
// order is important for lock
pub fn new(app: &App) -> Self {
let mut process_states = ProcessStatesGui(vec![]);
for process in [&app.node,
&app.p2pool,
&app.xmrig,
&app.xmrig_proxy,
&app.xvb] {
let lock = process.lock().unwrap();
process_states.push(ProcessStateGui {
name: lock.name,
alive: lock.is_alive(),
waiting: lock.is_waiting(),
state: lock.state,
});
}
process_states
}
pub fn is_alive(&self, name: ProcessName) -> bool {
self.iter()
.find(|p| p.name == name)
.unwrap_or_else(|| panic!("This vec should always contains all Processes {:?}",
self))
.alive
}
pub fn find(&self, name: ProcessName) -> &ProcessStateGui {
self.iter().find(|p| p.name == name).unwrap_or_else(|| panic!("This vec should always contains all Processes {:?}",
self))
}
pub fn find_mut(&mut self, name: ProcessName) -> &mut ProcessStateGui {
self.iter_mut()
.find(|p| p.name == name)
.expect("This vec should always contains all Processes")
}
}

View file

@ -39,6 +39,7 @@ use crate::APP_DEFAULT_HEIGHT;
use crate::APP_DEFAULT_WIDTH;
use crate::GUPAX_VERSION;
use crate::OS;
use derive_more::derive::Display;
use eframe::CreationContext;
use egui::vec2;
use egui::Vec2;
@ -53,12 +54,13 @@ use std::process::exit;
use std::sync::Arc;
use std::sync::Mutex;
use std::time::Instant;
use strum::EnumCount;
use strum::EnumIter;
pub mod eframe_impl;
pub mod keys;
pub mod panels;
pub mod quit;
pub mod resize;
//---------------------------------------------------------------------------------------------------- Struct + Impl
// The state of the outer main [App].
// See the [State] struct in [state.rs] for the
@ -158,7 +160,6 @@ impl App {
pub fn cc(cc: &CreationContext<'_>, resolution: Vec2, app: Self) -> Self {
init_text_styles(
&cc.egui_ctx,
resolution[0],
crate::miscs::clamp_scale(app.state.gupax.selected_scale),
);
cc.egui_ctx.set_visuals(VISUALS.clone());
@ -195,7 +196,7 @@ impl App {
PathBuf::new()
));
let xmrig_proxy = arc_mut!(Process::new(
ProcessName::Xmrig,
ProcessName::XmrigProxy,
String::new(),
PathBuf::new()
));
@ -711,14 +712,18 @@ impl App {
}
//---------------------------------------------------------------------------------------------------- [Tab] Enum + Impl
// The tabs inside [App].
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[derive(
Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, Display, EnumIter, EnumCount,
)]
pub enum Tab {
About,
Status,
#[display("Gupaxx")]
Gupax,
Node,
P2pool,
Xmrig,
#[display("Proxy")]
XmrigProxy,
Xvb,
}
@ -728,6 +733,21 @@ impl Default for Tab {
Self::About
}
}
impl Tab {
pub fn linked_process(&self) -> Option<ProcessName> {
match self {
Tab::About => None,
Tab::Status => None,
Tab::Gupax => None,
Tab::Node => Some(ProcessName::Node),
Tab::P2pool => Some(ProcessName::P2pool),
Tab::Xmrig => Some(ProcessName::Xmrig),
Tab::XmrigProxy => Some(ProcessName::XmrigProxy),
Tab::Xvb => Some(ProcessName::Xvb),
}
}
}
//---------------------------------------------------------------------------------------------------- [Restart] Enum
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Restart {

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@ use crate::app::panels::middle::*;
use crate::app::ErrorState;
use crate::app::Restart;
use crate::components::gupax::*;
use crate::components::update::check_binary_path;
use crate::components::update::Update;
use crate::disk::state::*;
use log::debug;
@ -23,6 +24,7 @@ impl Gupax {
_frame: &mut eframe::Frame,
_ctx: &egui::Context,
ui: &mut egui::Ui,
must_resize: &mut bool,
) {
// Update button + Progress bar
debug!("Gupaxx Tab | Rendering [Update] button + progress bar");
@ -176,7 +178,7 @@ impl Gupax {
Label::new(RichText::new("Node Binary Path ❌").color(RED)),
)
.on_hover_text(NODE_PATH_NOT_FILE);
} else if !crate::components::update::check_node_path(&self.node_path) {
} else if !check_binary_path(&self.node_path, ProcessName::Node) {
ui.add_sized(
[text_edit, height],
Label::new(RichText::new("Node Binary Path ❌").color(RED)),
@ -214,7 +216,7 @@ impl Gupax {
Label::new(RichText::new("P2Pool Binary Path ❌").color(RED)),
)
.on_hover_text(P2POOL_PATH_NOT_FILE);
} else if !crate::components::update::check_p2pool_path(&self.p2pool_path) {
} else if !check_binary_path(&self.p2pool_path, ProcessName::P2pool) {
ui.add_sized(
[text_edit, height],
Label::new(RichText::new("P2Pool Binary Path ❌").color(RED)),
@ -252,7 +254,7 @@ impl Gupax {
Label::new(RichText::new("XMRig Binary Path ❌").color(RED)),
)
.on_hover_text(XMRIG_PATH_NOT_FILE);
} else if !crate::components::update::check_xmrig_path(&self.xmrig_path) {
} else if !check_binary_path(&self.xmrig_path, ProcessName::Xmrig) {
ui.add_sized(
[text_edit, height],
Label::new(RichText::new("XMRig Binary Path ❌").color(RED)),
@ -292,7 +294,10 @@ impl Gupax {
Label::new(RichText::new("XMRig-Proxy Binary Path ❌").color(RED)),
)
.on_hover_text(XMRIG_PROXY_PATH_NOT_FILE);
} else if !crate::components::update::check_xp_path(&self.xmrig_proxy_path) {
} else if !crate::components::update::check_binary_path(
&self.xmrig_proxy_path,
ProcessName::XmrigProxy,
) {
ui.add_sized(
[text_edit, height],
Label::new(RichText::new("XMRig-Proxy Binary Path ❌").color(RED)),
@ -542,6 +547,7 @@ impl Gupax {
Vec2::new(self.selected_width as f32, self.selected_height as f32);
ui.ctx()
.send_viewport_cmd(egui::viewport::ViewportCommand::InnerSize(size));
*must_resize = true;
}
})
});

View file

@ -1,5 +1,7 @@
use crate::app::eframe_impl::ProcessStatesGui;
use crate::app::keys::KeyPressed;
use crate::app::Tab;
use crate::helper::ProcessName;
use crate::utils::constants::*;
use crate::utils::errors::{ErrorButtons, ErrorFerris};
use egui::*;
@ -19,12 +21,7 @@ impl crate::app::App {
ctx: &egui::Context,
frame: &mut eframe::Frame,
key: KeyPressed,
node_is_alive: bool,
p2pool_is_alive: bool,
xmrig_is_alive: bool,
xmrig_proxy_is_alive: bool,
xvb_is_alive: bool,
xvb_is_running: bool,
states: &ProcessStatesGui,
) {
// Middle panel, contents of the [Tab]
debug!("App | Rendering CENTRAL_PANEL (tab contents)");
@ -160,11 +157,11 @@ path_xmr: {:#?}\n
}
Tab::Status => {
debug!("App | Entering [Status] Tab");
crate::disk::state::Status::show(&mut self.state.status, &self.pub_sys, &self.node_api, &self.p2pool_api, &self.xmrig_api,&self.xmrig_proxy_api, &self.xvb_api,&self.p2pool_img, &self.xmrig_img, node_is_alive, p2pool_is_alive, xmrig_is_alive, xmrig_proxy_is_alive,xvb_is_alive, self.max_threads, &self.gupax_p2pool_api, &self.benchmarks, self.size, ctx, ui);
crate::disk::state::Status::show(&mut self.state.status, &self.pub_sys, &self.node_api, &self.p2pool_api, &self.xmrig_api,&self.xmrig_proxy_api, &self.xvb_api,&self.p2pool_img, &self.xmrig_img, states, self.max_threads, &self.gupax_p2pool_api, &self.benchmarks, self.size, ctx, ui);
}
Tab::Gupax => {
debug!("App | Entering [Gupax] Tab");
crate::disk::state::Gupax::show(&mut self.state.gupax, &self.og, &self.state_path, &self.update, &self.file_window, &mut self.error_state, &self.restart, self.size, frame, ctx, ui);
crate::disk::state::Gupax::show(&mut self.state.gupax, &self.og, &self.state_path, &self.update, &self.file_window, &mut self.error_state, &self.restart, self.size, frame, ctx, ui, &mut self.must_resize);
}
Tab::Node=> {
debug!("App | Entering [Node] Tab");
@ -184,7 +181,7 @@ path_xmr: {:#?}\n
}
Tab::Xvb => {
debug!("App | Entering [XvB] Tab");
crate::disk::state::Xvb::show(&mut self.state.xvb, self.size, &self.state.p2pool.address, ctx, ui, &self.xvb_api, &self.xmrig_api, &self.xmrig_proxy_api, xvb_is_running);
crate::disk::state::Xvb::show(&mut self.state.xvb, self.size, &self.state.p2pool.address, ctx, ui, &self.xvb_api, &self.xmrig_api, &self.xmrig_proxy_api, states.is_alive(ProcessName::Xvb));
}
}
});

View file

@ -3,11 +3,10 @@ use crate::{
NODE_DNS_BLOCKLIST, NODE_DNS_CHECKPOINT, NODE_INPUT, NODE_PATH_OK, NODE_PRUNNING, NODE_URL,
NODE_ZMQ_BIND, NODE_ZMQ_PORT,
};
use egui::{Color32, Label, RichText, Slider, TextEdit, Ui, Vec2};
use egui::{Color32, Label, RichText, Slider, TextEdit, TextStyle, Ui, Vec2};
use regex::Regex;
use std::sync::{Arc, Mutex};
use egui::TextStyle::{self, Name};
use log::debug;
use crate::components::gupax::{FileType, FileWindow};
@ -51,7 +50,7 @@ impl Node {
let height = size.y / 2.8;
let width = (size.x - (space_h / 2.0)).max(0.0);
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
ui.style_mut().override_text_style = Some(TextStyle::Small);
egui::ScrollArea::vertical()
.stick_to_bottom(true)
.max_width(width)
@ -60,7 +59,7 @@ impl Node {
// .show_viewport(ui, |ui, _| {
.show_rows(
ui,
ui.text_style_height(&TextStyle::Name("MonospaceSmall".into())),
ui.text_style_height(&TextStyle::Small),
nb_lines,
|ui, row_range| {
for i in row_range {
@ -160,8 +159,7 @@ impl Node {
debug!("Node Tab | Rendering sliders elements");
ui.vertical(|ui| {
ui.group(|ui| {
ui.style_mut().override_text_style =
Some(Name("MonospaceSmall".into()));
ui.style_mut().override_text_style = Some(TextStyle::Small);
ui.horizontal(|ui| {
// ui.label("Out peers [10-450]:");
ui.add_sized(

View file

@ -5,7 +5,7 @@ use egui::Slider;
use egui::{Button, Vec2};
use crate::constants::*;
use egui::{Color32, ComboBox, Label, RichText, SelectableLabel, TextStyle::*, Ui};
use egui::{Color32, ComboBox, Label, RichText, SelectableLabel, Ui};
use log::*;
impl P2pool {
@ -275,7 +275,7 @@ impl P2pool {
let height = height / 3.0;
ui.style_mut().spacing.slider_width = width / 1.1;
ui.style_mut().spacing.interact_size.y = height;
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
ui.style_mut().override_text_style = Some(egui::TextStyle::Small);
ui.horizontal(|ui| {
ui.add_sized([text, height], Label::new("Out peers [10-450]:"));
ui.add_sized([width, height], Slider::new(&mut self.out_peers, 10..=450))

View file

@ -19,11 +19,7 @@ use crate::regex::num_lines;
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::{components::node::*, constants::*, helper::*, utils::regex::Regexes};
use egui::{
vec2, Color32, Label, RichText, TextEdit,
TextStyle::{self, *},
Vec2,
};
use egui::{vec2, Color32, Label, RichText, TextEdit, TextStyle, Vec2};
use log::*;
use std::sync::{Arc, Mutex};
@ -68,7 +64,7 @@ impl P2pool {
)
};
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
ui.style_mut().override_text_style = Some(egui::TextStyle::Small);
egui::ScrollArea::vertical()
.stick_to_bottom(true)
.max_width(width)
@ -77,7 +73,7 @@ impl P2pool {
// .show_viewport(ui, |ui, _| {
.show_rows(
ui,
ui.text_style_height(&TextStyle::Name("MonospaceSmall".into())),
ui.text_style_height(&TextStyle::Small),
nb_lines,
|ui, row_range| {
for i in row_range {

View file

@ -18,7 +18,7 @@
use egui::Vec2;
use crate::{
app::Benchmark,
app::{eframe_impl::ProcessStatesGui, Benchmark},
disk::{gupax_p2pool_api::GupaxP2poolApi, state::Status, status::*},
helper::{
node::PubNodeApi,
@ -28,7 +28,7 @@ use crate::{
xmrig_proxy::PubXmrigProxyApi,
},
xvb::PubXvbApi,
Sys,
ProcessName, Sys,
},
};
use std::sync::{Arc, Mutex};
@ -50,11 +50,7 @@ impl Status {
xvb_api: &Arc<Mutex<PubXvbApi>>,
p2pool_img: &Arc<Mutex<ImgP2pool>>,
xmrig_img: &Arc<Mutex<ImgXmrig>>,
node_alive: bool,
p2pool_alive: bool,
xmrig_alive: bool,
xmrig_proxy_alive: bool,
xvb_alive: bool,
states: &ProcessStatesGui,
max_threads: usize,
gupax_p2pool_api: &Arc<Mutex<GupaxP2poolApi>>,
benchmarks: &[Benchmark],
@ -68,26 +64,34 @@ impl Status {
sys,
size,
ui,
node_alive,
node_api,
p2pool_alive,
p2pool_api,
p2pool_img,
xmrig_alive,
xmrig_api,
xmrig_proxy_alive,
xmrig_proxy_api,
xmrig_img,
xvb_alive,
xvb_api,
max_threads,
states,
);
//---------------------------------------------------------------------------------------------------- [P2Pool]
} else if self.submenu == Submenu::P2pool {
self.p2pool(size, ui, gupax_p2pool_api, p2pool_alive, p2pool_api);
self.p2pool(
size,
ui,
gupax_p2pool_api,
states.is_alive(ProcessName::P2pool),
p2pool_api,
);
//---------------------------------------------------------------------------------------------------- [Benchmarks]
} else if self.submenu == Submenu::Benchmarks {
self.benchmarks(size, ui, benchmarks, xmrig_alive, xmrig_api)
self.benchmarks(
size,
ui,
benchmarks,
states.is_alive(ProcessName::Xmrig),
xmrig_api,
)
}
}
}

View file

@ -105,8 +105,7 @@ impl Status {
.max_height(log)
.auto_shrink([false; 2])
.show_viewport(ui, |ui, _| {
ui.style_mut().override_text_style =
Some(egui::TextStyle::Name("MonospaceLarge".into()));
ui.style_mut().override_text_style = Some(egui::TextStyle::Body);
match self.payout_view {
PayoutView::Latest => ui.add_sized(
[width, log],

View file

@ -2,17 +2,17 @@ use egui::{ScrollArea, Ui, Vec2};
use readable::up::UptimeFull;
use std::sync::{Arc, Mutex};
use crate::app::eframe_impl::ProcessStatesGui;
use crate::disk::state::Status;
use crate::helper::node::PubNodeApi;
use crate::helper::p2pool::{ImgP2pool, PubP2poolApi};
use crate::helper::xrig::xmrig::{ImgXmrig, PubXmrigApi};
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::xvb::{rounds::XvbRound, PubXvbApi};
use crate::helper::Sys;
use egui::TextStyle;
use crate::helper::{ProcessName, Sys};
use crate::constants::*;
use egui::{Label, RichText, TextStyle::*};
use egui::{Label, RichText, TextStyle};
use log::*;
impl Status {
#[allow(clippy::too_many_arguments)]
@ -21,19 +21,15 @@ impl Status {
sys: &Arc<Mutex<Sys>>,
size: Vec2,
ui: &mut egui::Ui,
node_alive: bool,
node_api: &Arc<Mutex<PubNodeApi>>,
p2pool_alive: bool,
p2pool_api: &Arc<Mutex<PubP2poolApi>>,
p2pool_img: &Arc<Mutex<ImgP2pool>>,
xmrig_alive: bool,
xmrig_api: &Arc<Mutex<PubXmrigApi>>,
xmrig_proxy_alive: bool,
xmrig_proxy_api: &Arc<Mutex<PubXmrigProxyApi>>,
xmrig_img: &Arc<Mutex<ImgXmrig>>,
xvb_alive: bool,
xvb_api: &Arc<Mutex<PubXvbApi>>,
max_threads: usize,
states: &ProcessStatesGui,
) {
// set fixed text size, temporary solution before refactoring text/widget size.
let width = ((size.x / 5.0) - (SPACE * 1.7500)).max(0.0);
@ -49,27 +45,45 @@ impl Status {
ui.horizontal(|ui| {
ScrollArea::horizontal().show(ui, |ui| {
ui.set_min_height(min_height * 34.2);
// [Gupax]
gupax(ui, min_size, size, sys);
// [Node]
node(ui, min_size, size, node_alive, node_api);
// [P2Pool]
p2pool(ui, min_size, size, p2pool_alive, p2pool_api, p2pool_img);
// [XMRig]
node(
ui,
min_size,
size,
states.is_alive(ProcessName::Node),
node_api,
);
p2pool(
ui,
min_size,
size,
states.is_alive(ProcessName::P2pool),
p2pool_api,
p2pool_img,
);
xmrig(
ui,
min_size,
size,
xmrig_alive,
states.is_alive(ProcessName::Xmrig),
xmrig_api,
xmrig_img,
max_threads,
);
//[XMRig-Proxy]
xmrig_proxy(ui, min_size, size, xmrig_proxy_alive, xmrig_proxy_api);
// [XvB]
xvb(ui, min_size, size, xvb_alive, xvb_api);
xmrig_proxy(
ui,
min_size,
size,
states.is_alive(ProcessName::XmrigProxy),
xmrig_proxy_api,
);
xvb(
ui,
min_size,
size,
states.is_alive(ProcessName::Xvb),
xvb_api,
);
})
});
}
@ -86,7 +100,7 @@ fn gupax(ui: &mut Ui, min_size: Vec2, size: Vec2, sys: &Arc<Mutex<Sys>>) {
Label::new(
RichText::new("[Gupaxx]")
.color(LIGHT_GRAY)
.text_style(TextStyle::Name("MonospaceLarge".into())),
.text_style(TextStyle::Heading),
),
)
.on_hover_text("Gupaxx is online");
@ -152,12 +166,12 @@ fn p2pool(
Label::new(
RichText::new("[P2Pool]")
.color(LIGHT_GRAY)
.text_style(TextStyle::Name("MonospaceLarge".into())),
.text_style(TextStyle::Heading),
),
)
.on_hover_text("P2Pool is online")
.on_disabled_hover_text("P2Pool is offline");
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
ui.style_mut().override_text_style = Some(TextStyle::Small);
let size = [size.x, size.y / 1.4];
let api = p2pool_api.lock().unwrap();
ui.add_sized(
@ -299,7 +313,7 @@ fn xmrig_proxy(
Label::new(
RichText::new("[XMRig-Proxy]")
.color(LIGHT_GRAY)
.text_style(TextStyle::Name("MonospaceLarge".into())),
.text_style(TextStyle::Heading),
),
)
.on_hover_text("XMRig-Proxy is online")
@ -372,7 +386,7 @@ fn xmrig(
Label::new(
RichText::new("[XMRig]")
.color(LIGHT_GRAY)
.text_style(TextStyle::Name("MonospaceLarge".into())),
.text_style(TextStyle::Heading),
),
)
.on_hover_text("XMRig is online")
@ -456,7 +470,7 @@ fn xvb(ui: &mut Ui, min_size: Vec2, size: Vec2, xvb_alive: bool, xvb_api: &Arc<M
Label::new(
RichText::new("[XvB Raffle]")
.color(LIGHT_GRAY)
.text_style(TextStyle::Name("MonospaceLarge".into())),
.text_style(TextStyle::Heading),
),
)
.on_hover_text("XvB API stats")
@ -581,7 +595,7 @@ fn node(
Label::new(
RichText::new("[Node]")
.color(LIGHT_GRAY)
.text_style(TextStyle::Name("MonospaceLarge".into())),
.text_style(TextStyle::Heading),
),
)
.on_hover_text("Node is online")

View file

@ -24,8 +24,7 @@ use crate::regex::{num_lines, REGEXES};
use crate::utils::regex::Regexes;
use egui::{
vec2, Button, Checkbox, ComboBox, Label, RichText, SelectableLabel, Slider, TextEdit,
TextStyle::{self, *},
Vec2,
TextStyle, Vec2,
};
use log::*;
@ -57,7 +56,7 @@ impl Xmrig {
(size.y / 2.8, size.x - SPACE)
};
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
ui.style_mut().override_text_style = Some(TextStyle::Small);
egui::ScrollArea::vertical()
.stick_to_bottom(true)
.max_width(width)
@ -66,7 +65,7 @@ impl Xmrig {
// .show_viewport(ui, |ui, _| {
.show_rows(
ui,
ui.text_style_height(&TextStyle::Name("MonospaceSmall".into())),
ui.text_style_height(&TextStyle::Small),
nb_lines,
|ui, row_range| {
for i in row_range {

View file

@ -1,7 +1,8 @@
use egui::{vec2, Button, Checkbox, ComboBox, Label, RichText, SelectableLabel, TextEdit, Vec2};
use egui::{
vec2, Button, Checkbox, ComboBox, Label, RichText, SelectableLabel, TextEdit, TextStyle, Vec2,
};
use std::sync::{Arc, Mutex};
use egui::TextStyle::{self, Name};
use log::{debug, info};
use crate::disk::pool::Pool;
@ -48,7 +49,8 @@ impl XmrigProxy {
let height = size.y / 2.8;
let width = size.x - (space_h / 2.0);
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
ui.style_mut().override_text_style = Some(egui::TextStyle::Small
);
egui::ScrollArea::vertical()
.stick_to_bottom(true)
.max_width(width)
@ -57,7 +59,7 @@ impl XmrigProxy {
// .show_viewport(ui, |ui, _| {
.show_rows(
ui,
ui.text_style_height(&TextStyle::Name("MonospaceSmall".into())),
ui.text_style_height(&TextStyle::Small),
nb_lines,
|ui, row_range| {
for i in row_range {

View file

@ -1,7 +1,6 @@
use std::sync::{Arc, Mutex};
use egui::TextStyle::{self, Name};
use egui::{vec2, Image, RichText, TextEdit, Ui, Vec2};
use egui::{vec2, Image, RichText, TextEdit, TextStyle, Ui, Vec2};
use log::debug;
use readable::num::Float;
use readable::up::Uptime;
@ -70,7 +69,7 @@ impl crate::disk::state::Xvb {
let height = size.y / 2.8;
let width = size.x - (space_h / 2.0);
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
ui.style_mut().override_text_style = Some(TextStyle::Small);
egui::ScrollArea::vertical()
.stick_to_bottom(true)
.max_width(width)
@ -79,7 +78,7 @@ impl crate::disk::state::Xvb {
// .show_viewport(ui, |ui, _| {
.show_rows(
ui,
ui.text_style_height(&TextStyle::Name("MonospaceSmall".into())),
ui.text_style_height(&TextStyle::Small),
nb_lines,
|ui, row_range| {
for i in row_range {

View file

@ -1,5 +1,6 @@
use std::process::exit;
use crate::app::eframe_impl::ProcessStateGui;
use crate::app::keys::KeyPressed;
use crate::disk::node::Node;
use crate::disk::state::State;
@ -9,15 +10,13 @@ use crate::utils::ferris::*;
use crate::utils::macros::{arc_mut, flip};
use crate::utils::resets::{reset_nodes, reset_state};
use crate::utils::sudo::SudoState;
use egui::TextStyle::Name;
use egui::*;
impl crate::app::App {
pub(in crate::app) fn quit_error_panel(
&mut self,
ctx: &egui::Context,
p2pool_is_alive: bool,
xmrig_is_alive: bool,
processes: &[ProcessStateGui],
key: &KeyPressed,
) {
CentralPanel::default().show(ctx, |ui| {
@ -25,7 +24,7 @@ impl crate::app::App {
// Set width/height/font
let width = self.size.x;
let height = self.size.y / 4.0;
ui.style_mut().override_text_style = Some(Name("MonospaceLarge".into()));
ui.style_mut().override_text_style = Some(TextStyle::Heading);
// Display ferris
use crate::utils::errors::ErrorButtons;
@ -59,11 +58,10 @@ impl crate::app::App {
text
);
}
if p2pool_is_alive {
text = format!("{}\nP2Pool is online...!", text);
}
if xmrig_is_alive {
text = format!("{}\nXMRig is online...!", text);
for process in processes {
if process.alive {
text = format!("{}\n{} is online...!", text, process.name);
}
}
ui.add_sized(
[width, height],
@ -107,7 +105,7 @@ impl crate::app::App {
&self.error_state.msg
)),
);
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
ui.style_mut().override_text_style = Some(TextStyle::Small);
ui.add_sized([width / 2.0, height], Label::new(text));
ui.add_sized(
[width, height],

View file

@ -1,101 +1,67 @@
use egui::TextStyle::Name;
use egui::{ScrollArea, SelectableLabel, TopBottomPanel};
use crate::app::Tab;
use egui::TextStyle;
use egui::{ScrollArea, SelectableLabel, Separator, TopBottomPanel, Ui};
use log::debug;
use crate::{app::Tab, utils::constants::SPACE};
use strum::{EnumCount, IntoEnumIterator};
impl crate::app::App {
pub fn top_panel(&mut self, ctx: &egui::Context) {
debug!("App | Rendering TOP tabs");
TopBottomPanel::top("top").show(ctx, |ui| {
let width = ((self.size.x - (SPACE * 18.0)) / 8.0).max(0.0);
let height = self.size.y / 15.0;
ui.add_space(4.0);
ui.horizontal(|ui| {
ScrollArea::horizontal().show(ui, |ui| {
ui.style_mut().override_text_style = Some(Name("Tab".into()));
if ui
.add_sized(
[width, height],
SelectableLabel::new(self.tab == Tab::About, "About"),
)
.clicked()
{
self.tab = Tab::About;
}
ui.separator();
if ui
.add_sized(
[width, height],
SelectableLabel::new(self.tab == Tab::Status, "Status"),
)
.clicked()
{
self.tab = Tab::Status;
}
ui.separator();
if ui
.add_sized(
[width, height],
SelectableLabel::new(self.tab == Tab::Gupax, "Gupaxx"),
)
.clicked()
{
self.tab = Tab::Gupax;
}
ui.separator();
if ui
.add_sized(
[width, height],
SelectableLabel::new(self.tab == Tab::Node, "Node"),
)
.clicked()
{
self.tab = Tab::Node;
}
ui.separator();
if ui
.add_sized(
[width, height],
SelectableLabel::new(self.tab == Tab::P2pool, "P2Pool"),
)
.clicked()
{
self.tab = Tab::P2pool;
}
ui.separator();
if ui
.add_sized(
[width, height],
SelectableLabel::new(self.tab == Tab::Xmrig, "XMRig"),
)
.clicked()
{
self.tab = Tab::Xmrig;
}
ui.separator();
if ui
.add_sized(
[width, height],
SelectableLabel::new(self.tab == Tab::XmrigProxy, "Proxy"),
)
.clicked()
{
self.tab = Tab::XmrigProxy;
}
ui.separator();
if ui
.add_sized(
[width, height],
SelectableLabel::new(self.tab == Tab::Xvb, "XvB"),
)
.clicked()
{
self.tab = Tab::Xvb;
}
});
ui.add_space(4.0);
// low spacing to shrink and be able to show all tabs on one line on 640x480
ui.style_mut().spacing.item_spacing.x = 4.0;
// spacing of separator, will reduce width size of the button. Low value so that tabs can be selected easily.
let spacing_separator = 2.0;
// TODO if screen smaller, go on two lines.
// TODO if screen really to small, go on tab per line.
ui.with_layout(egui::Layout::left_to_right(egui::Align::Min), |ui| {
ui.style_mut().override_text_style = Some(TextStyle::Heading);
let height = ui
.style()
.text_styles
.get(&TextStyle::Heading)
.unwrap()
.size
* 2.75;
// width = (width - / number of tab) - (space between widget * 2.0 + space of separator / 2.0)
let width = (((self.size.x) / Tab::COUNT as f32)
- ((ui.style().spacing.item_spacing.x * 2.0) + (spacing_separator / 2.0)))
.max(0.0);
// height of tab menu relative to size of text. coeff 2.75 is arbitrary but good enough to be easily clickable.
self.tabs(ui, [width, height], spacing_separator);
});
});
}
fn tabs(&mut self, ui: &mut Ui, size: [f32; 2], spacing_separator: f32) {
ScrollArea::horizontal()
.scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysHidden)
.show(ui, |ui| {
for (count, tab) in Tab::iter().enumerate() {
ui.horizontal(|ui| {
ui.vertical(|ui| {
// we don't want y item spacing to influence the added space
ui.style_mut().spacing.item_spacing.y = 0.0;
ui.add_space(spacing_separator);
ui.horizontal(|ui| {
if ui
.add_sized(
size,
SelectableLabel::new(self.tab == tab, tab.to_string()),
)
.clicked()
{
self.tab = tab
}
});
// add a space to prevent selectable button to be at the same line as the end of the top bar. Make it the same spacing as separators.
ui.add_space(spacing_separator);
});
if count + 1 != Tab::COUNT {
ui.add(Separator::default().spacing(spacing_separator).vertical());
}
});
}
});
}
}

View file

@ -1,77 +0,0 @@
use crate::inits::init_text_styles;
use crate::SPACE;
use egui::Color32;
use log::debug;
use log::info;
use super::App;
impl App {
pub fn resize(&mut self, ctx: &egui::Context) {
// This resizes fonts/buttons/etc globally depending on the width.
// This is separate from the [self.width != available_width] logic above
// because placing [init_text_styles()] above would mean calling it 60x a second
// while the user was readjusting the frame. It's a pretty heavy operation and looks
// buggy when calling it that many times. Looking for a [must_resize] in addition to
// checking if the user is hovering over the app means that we only have call it once.
debug!("App | Checking if we need to resize");
if self.must_resize && ctx.is_pointer_over_area() {
self.resizing = true;
self.must_resize = false;
}
// This (ab)uses [Area] and [TextEdit] to overlay a full black layer over whatever UI we had before.
// It incrementally becomes more opaque until [self.alpha] >= 250, when we just switch to pure black (no alpha).
// When black, we're safe to [init_text_styles()], and then incrementally go transparent, until we remove the layer.
if self.resizing {
egui::Area::new("resize_layer".into())
.order(egui::Order::Foreground)
.anchor(egui::Align2::CENTER_CENTER, (0.0, 0.0))
.show(ctx, |ui| {
if self.alpha < 250 {
egui::Frame::none()
.fill(Color32::from_rgba_premultiplied(0, 0, 0, self.alpha))
.show(ui, |ui| {
ui.add_sized(
[ui.available_width() + SPACE, ui.available_height() + SPACE],
egui::TextEdit::multiline(&mut ""),
);
});
ctx.request_repaint();
self.alpha += 10;
} else {
egui::Frame::none()
.fill(Color32::from_rgb(0, 0, 0))
.show(ui, |ui| {
ui.add_sized(
[ui.available_width() + SPACE, ui.available_height() + SPACE],
egui::TextEdit::multiline(&mut ""),
);
});
ctx.request_repaint();
info!(
"App | Resizing frame to match new internal resolution: [{}x{}]",
self.size.x, self.size.y
);
init_text_styles(ctx, self.size.x, self.state.gupax.selected_scale);
self.resizing = false;
}
});
} else if self.alpha != 0 {
egui::Area::new("resize_layer".into())
.order(egui::Order::Foreground)
.anchor(egui::Align2::CENTER_CENTER, (0.0, 0.0))
.show(ctx, |ui| {
egui::Frame::none()
.fill(Color32::from_rgba_premultiplied(0, 0, 0, self.alpha))
.show(ui, |ui| {
ui.add_sized(
[ui.available_width() + SPACE, ui.available_height() + SPACE],
egui::TextEdit::multiline(&mut ""),
);
})
});
self.alpha -= 10;
ctx.request_repaint();
}
}
}

View file

@ -28,6 +28,7 @@ use crate::{
app::Restart,
constants::GUPAX_VERSION,
disk::{state::State, *},
helper::ProcessName,
macros::*,
miscs::get_exe_dir,
utils::errors::{ErrorButtons, ErrorFerris, ErrorState},
@ -139,7 +140,7 @@ const EXTRACT: &str = "----------------- Extract ------------------";
const UPGRADE: &str = "----------------- Upgrade ------------------";
//---------------------------------------------------------------------------------------------------- General functions
pub fn check_p2pool_path(path: &str) -> bool {
pub fn check_binary_path(path: &str, process: ProcessName) -> bool {
let path = match crate::disk::into_absolute_path(path.to_string()) {
Ok(p) => p,
Err(_) => return false,
@ -147,57 +148,11 @@ pub fn check_p2pool_path(path: &str) -> bool {
let path = match path.file_name() {
Some(p) => p,
None => {
error!("Couldn't get P2Pool file name");
error!("Couldn't get {process} file name");
return false;
}
};
path == P2POOL_BINARY
}
pub fn check_node_path(path: &str) -> bool {
let path = match crate::disk::into_absolute_path(path.to_string()) {
Ok(p) => p,
Err(_) => return false,
};
let path = match path.file_name() {
Some(p) => p,
None => {
error!("Couldn't get Node file name");
return false;
}
};
path == NODE_BINARY
}
pub fn check_xmrig_path(path: &str) -> bool {
let path = match crate::disk::into_absolute_path(path.to_string()) {
Ok(p) => p,
Err(_) => return false,
};
let path = match path.file_name() {
Some(p) => p,
None => {
error!("Couldn't get XMRig file name");
return false;
}
};
path == XMRIG_BINARY
}
pub fn check_xp_path(path: &str) -> bool {
let path = match crate::disk::into_absolute_path(path.to_string()) {
Ok(p) => p,
Err(_) => return false,
};
let path = match path.file_name() {
Some(p) => p,
None => {
error!("Couldn't get XMRig-Proxy file name");
return false;
}
};
path == XMRIG_PROXY_BINARY
path == process.binary_name()
}
//---------------------------------------------------------------------------------------------------- Update struct/impl

View file

@ -73,10 +73,7 @@ impl State {
// Create
_ => {
Self::create_new(path)?;
match read_to_string(file, path) {
Ok(s) => s,
Err(e) => return Err(e),
}
read_to_string(file, path)?
}
};
// Deserialize, attempt merge if failed

View file

@ -33,6 +33,7 @@
// This also includes all things related to handling the child processes (P2Pool/XMRig):
// piping their stdout/stderr/stdin, accessing their APIs (HTTP + disk files), etc.
use crate::components::update::{NODE_BINARY, P2POOL_BINARY, XMRIG_BINARY, XMRIG_PROXY_BINARY};
//---------------------------------------------------------------------------------------------------- Import
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::{
@ -40,6 +41,7 @@ use crate::helper::{
xrig::{xmrig::ImgXmrig, xmrig::PubXmrigApi},
};
use crate::{constants::*, disk::gupax_p2pool_api::GupaxP2poolApi, human::*, macros::*};
use derive_more::derive::Display;
use log::*;
use node::PubNodeApi;
use portable_pty::Child;
@ -52,6 +54,7 @@ use std::{
thread,
time::*,
};
use strum::EnumIter;
use self::xvb::{nodes::XvbNode, PubXvbApi};
pub mod node;
@ -247,13 +250,26 @@ impl Default for ProcessSignal {
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Display, EnumIter)]
pub enum ProcessName {
Node,
P2pool,
Xmrig,
#[display("Proxy")]
XmrigProxy,
Xvb,
Node,
}
impl ProcessName {
pub fn binary_name(&self) -> &str {
match self {
ProcessName::Node => NODE_BINARY,
ProcessName::P2pool => P2POOL_BINARY,
ProcessName::Xmrig => XMRIG_BINARY,
ProcessName::XmrigProxy => XMRIG_PROXY_BINARY,
ProcessName::Xvb => "",
}
}
}
impl std::fmt::Display for ProcessState {
@ -266,17 +282,6 @@ impl std::fmt::Display for ProcessSignal {
write!(f, "{:#?}", self)
}
}
impl std::fmt::Display for ProcessName {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self {
ProcessName::P2pool => write!(f, "P2Pool"),
ProcessName::Xmrig => write!(f, "XMRig"),
ProcessName::XmrigProxy => write!(f, "XMRig-Proxy"),
ProcessName::Xvb => write!(f, "XvB"),
ProcessName::Node => write!(f, "Node"),
}
}
}
//---------------------------------------------------------------------------------------------------- [Helper]
impl Helper {

View file

@ -1,6 +1,6 @@
use crate::components::update::Update;
use crate::components::update::{check_binary_path, Update};
use crate::errors::process_running;
use crate::helper::{Helper, ProcessSignal};
use crate::helper::{Helper, ProcessName, ProcessSignal};
use crate::utils::constants::{
APP_MAX_HEIGHT, APP_MAX_WIDTH, APP_MIN_HEIGHT, APP_MIN_WIDTH, BYTES_ICON,
};
@ -13,7 +13,7 @@ use crate::{components::node::Ping, miscs::clamp_scale};
use crate::{info, warn};
use eframe::NativeOptions;
use egui::TextStyle::Small;
use egui::TextStyle::{Body, Button, Heading, Monospace, Name};
use egui::TextStyle::{Body, Button, Heading, Monospace};
use egui::*;
use env_logger::fmt::style::Style;
use env_logger::{Builder, WriteStyle};
@ -24,47 +24,21 @@ use std::time::Instant;
#[cold]
#[inline(never)]
pub fn init_text_styles(ctx: &egui::Context, width: f32, pixels_per_point: f32) {
let scale = width / 35.5;
pub fn init_text_styles(ctx: &egui::Context, pixels_per_point: f32) {
ctx.all_styles_mut(|style| {
style.text_styles = [
(Small, FontId::new(scale / 3.0, egui::FontFamily::Monospace)),
(Body, FontId::new(scale / 2.0, egui::FontFamily::Monospace)),
(
Button,
FontId::new(scale / 2.0, egui::FontFamily::Monospace),
),
(
Monospace,
FontId::new(scale / 2.0, egui::FontFamily::Monospace),
),
(
Heading,
FontId::new(scale / 1.5, egui::FontFamily::Monospace),
),
(
Name("Tab".into()),
FontId::new(scale * 1.05, egui::FontFamily::Monospace),
),
(
Name("Bottom".into()),
FontId::new(scale / 2.0, egui::FontFamily::Monospace),
),
(
Name("MonospaceSmall".into()),
FontId::new(scale / 2.5, egui::FontFamily::Monospace),
),
(
Name("MonospaceLarge".into()),
FontId::new(scale / 1.5, egui::FontFamily::Monospace),
),
(Small, FontId::new(14.0, egui::FontFamily::Monospace)),
(Monospace, FontId::new(15.0, egui::FontFamily::Monospace)),
(Body, FontId::new(16.0, egui::FontFamily::Monospace)),
(Button, FontId::new(17.0, egui::FontFamily::Monospace)),
(Heading, FontId::new(22.0, egui::FontFamily::Monospace)),
]
.into();
style.spacing.icon_width_inner = width / 35.0;
style.spacing.icon_width = width / 25.0;
style.spacing.icon_width_inner = 32.0;
style.spacing.icon_width = 64.0;
style.spacing.icon_spacing = 20.0;
style.spacing.scroll = egui::style::ScrollStyle {
bar_width: width / 150.0,
bar_width: 8.0,
..egui::style::ScrollStyle::solid()
};
});
@ -185,9 +159,9 @@ pub fn init_auto(app: &mut App) {
if app.state.gupax.auto_node {
if !Gupax::path_is_file(&app.state.gupax.node_path) {
warn!("Gupaxx | Node path is not a file! Skipping auto-node...");
} else if !crate::components::update::check_node_path(&app.state.gupax.node_path) {
} else if !check_binary_path(&app.state.gupax.node_path, ProcessName::Node) {
warn!("Gupaxx | Node path is not valid! Skipping auto-node...");
} else if process_running(crate::helper::ProcessName::Node) {
} else if process_running(ProcessName::Node) {
warn!("Gupaxx | Node instance is already running outside of Gupaxx ! Skipping auto-node...");
} else {
// enable hugepage on linux
@ -207,7 +181,7 @@ pub fn init_auto(app: &mut App) {
warn!("Gupaxx | P2Pool address is not valid! Skipping auto-p2pool...");
} else if !Gupax::path_is_file(&app.state.gupax.p2pool_path) {
warn!("Gupaxx | P2Pool path is not a file! Skipping auto-p2pool...");
} else if !crate::components::update::check_p2pool_path(&app.state.gupax.p2pool_path) {
} else if !check_binary_path(&app.state.gupax.p2pool_path, ProcessName::P2pool) {
warn!("Gupaxx | P2Pool path is not valid! Skipping auto-p2pool...");
} else if process_running(crate::helper::ProcessName::P2pool) {
warn!("Gupaxx | P2pool instance is already running outside of Gupaxx ! Skipping auto-node...");
@ -228,7 +202,7 @@ pub fn init_auto(app: &mut App) {
if app.state.gupax.auto_xmrig {
if !Gupax::path_is_file(&app.state.gupax.xmrig_path) {
warn!("Gupaxx | XMRig path is not an executable! Skipping auto-xmrig...");
} else if !crate::components::update::check_xmrig_path(&app.state.gupax.xmrig_path) {
} else if !check_binary_path(&app.state.gupax.xmrig_path, ProcessName::Xmrig) {
warn!("Gupaxx | XMRig path is not valid! Skipping auto-xmrig...");
} else if process_running(crate::helper::ProcessName::Xmrig) {
warn!("Gupaxx | Xmrig instance is already running outside of Gupaxx ! Skipping auto-node...");
@ -250,7 +224,7 @@ pub fn init_auto(app: &mut App) {
if app.state.gupax.auto_xp {
if !Gupax::path_is_file(&app.state.gupax.xmrig_proxy_path) {
warn!("Gupaxx | Xmrig-Proxy path is not a file! Skipping auto-xmrig_proxy...");
} else if !crate::components::update::check_xp_path(&app.state.gupax.xmrig_proxy_path) {
} else if !check_binary_path(&app.state.gupax.xmrig_proxy_path, ProcessName::XmrigProxy) {
warn!("Gupaxx | Xmrig-Proxy path is not valid! Skipping auto-xmrig_proxy...");
} else if process_running(crate::helper::ProcessName::XmrigProxy) {
warn!("Gupaxx | Xmrig-Proxy instance is already running outside of Gupaxx ! Skipping auto-node...");

View file

@ -505,7 +505,18 @@ pub const XVB_HELP: &str = "You need to register an account by clicking on the l
pub const XVB_MANUAL_SLIDER_MANUAL_XVB_HELP: &str = "Set the hashrate amount to donate to XvB manually, The remaining hashrate will be sent to p2pool. If the selected hashrate is more than your xmrig hashrate it will be overwritten";
pub const XVB_MANUAL_SLIDER_MANUAL_P2POOL_HELP: &str = "Set the hashrate amount to keep on p2pool manually, The remaining hasrate will be donated to xvb. If the selected hashrate is more than your xmrig hashrate it will be overwritten ";
pub const XVB_URL: &str = "https://xmrvsbeast.com";
// Simple/Advanced Submenu hover text
pub const XVB_SIMPLE: &str = r#"Use simple XvB settings:
- Auto mode by default
- Hero mode available"#;
pub const XVB_ADVANCED: &str = r#"Use advanced XvB settings:
- Selection of mode:
Auto,
Hero,
Manual XvB,
Manual P2pool,
Round
- P2Pool Buffer"#;
pub const XVB_URL_PUBLIC_API: &str = "https://xmrvsbeast.com/p2pool/stats";
pub const XVB_NODE_PORT: &str = "4247";
pub const XVB_NODE_EU: &str = "eu.xmrvsbeast.com";

View file

@ -105,7 +105,10 @@ pub fn process_running(process_name: ProcessName) -> bool {
ProcessName::P2pool => P2POOL_BINARY,
ProcessName::Xmrig => XMRIG_BINARY,
ProcessName::XmrigProxy => XMRIG_PROXY_BINARY,
ProcessName::Xvb => panic!("XvB does not exist as a process outside of Gupaxx"),
ProcessName::Xvb => {
// XvB does not exist as a process outside of Gupaxx (not yet anyway);
return false;
}
};
let s = System::new_all();
if s.processes_by_exact_name(name.as_ref()).next().is_some() {