feat: upgrade deps and adapt code to breaking changes

This commit is contained in:
Cyrix126 2024-08-20 12:31:07 +02:00
parent baa70cd458
commit 9057bd12ee
18 changed files with 1657 additions and 1541 deletions

1324
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -32,11 +32,11 @@ distro = []
clap = {version="4.5", features=["cargo", "derive"]} clap = {version="4.5", features=["cargo", "derive"]}
anyhow = "1.0.86" anyhow = "1.0.86"
benri = "0.1.12" benri = "0.1.12"
bytes = "1.6.1" bytes = "1.7.1"
dirs = "5.0.1" dirs = "5.0.1"
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
egui = "0.27.2" egui = {git="https://github.com/emilk/egui", rev="9a1e358"}
egui_extras = { version = "0.27.2", features = ["image"] } egui_extras = {git="https://github.com/emilk/egui", rev="9a1e358", features = ["image"] }
## 2023-12-28: https://github.com/hinto-janai/gupax/issues/68 ## 2023-12-28: https://github.com/hinto-janai/gupax/issues/68
## ##
## 2024-03-18: Both `glow` and `wgpu` seem to crash: ## 2024-03-18: Both `glow` and `wgpu` seem to crash:
@ -48,28 +48,28 @@ egui_extras = { version = "0.27.2", features = ["image"] }
## Using [wgpu] actually crashes macOS (fixed in 0.20.x though). ## Using [wgpu] actually crashes macOS (fixed in 0.20.x though).
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
env_logger = "0.11.4" env_logger = "0.11.5"
figment = { version = "0.10.19", features = ["toml"] } figment = { version = "0.10.19", features = ["toml"] }
reqwest = {version = "0.12.5", default-features=false, features=["json", "rustls-tls"]} reqwest = {version = "0.12.7", default-features=false, features=["json", "rustls-tls"]}
image = { version = "0.25.2", features = ["png"] } image = { version = "0.25.2", features = ["png"] }
log = "0.4.22" log = "0.4.22"
num-format = { version = "0.4.4", default-features = false } num-format = { version = "0.4.4", default-features = false }
once_cell = "1.19.0" once_cell = "1.19.0"
portable-pty = "0.8.1" portable-pty = "0.8.1"
rand = "0.8.5" rand = "0.8.5"
regex = { version = "1.10.5", default-features = false, features = ["perf"] } regex = { version = "1.10.6", default-features = false, features = ["perf"] }
rfd = "0.14.1" rfd = "0.14.1"
serde = { version = "1.0.204", features = ["rc", "derive"] } serde = { version = "1.0.208", features = ["rc", "derive"] }
serde_json = "1.0.120" serde_json = "1.0.125"
sysinfo = { version = "0.30.13", default-features = false } sysinfo = { version = "0.31.2", default-features = false, features=["system"] }
# tls-api = "0.9.0" # tls-api = "0.9.0"
tokio = { version = "1.39.1", features = ["rt", "time", "macros", "process", "rt-multi-thread"] } tokio = { version = "1.39.3", features = ["rt", "time", "macros", "process", "rt-multi-thread"] }
toml = { version = "0.8.15", features = ["preserve_order"] } toml = { version = "0.8.19", features = ["preserve_order"] }
walkdir = "2.5.0" walkdir = "2.5.0"
zeroize = "1.8.1" zeroize = "1.8.1"
strsim = "0.11.1" strsim = "0.11.1"
strip-ansi-escapes = "0.2.0" strip-ansi-escapes = "0.2.0"
derive_more = {version="0.99.18", default-features=false, features=["display"]} derive_more = {version="1.0.0", default-features=false, features=["display"]}
serde-this-or-that = "0.4.2" serde-this-or-that = "0.4.2"
readable = "0.16" readable = "0.16"
chrono = {version="0.4.38", default-features=false, features=["clock", "std"]} chrono = {version="0.4.38", default-features=false, features=["clock", "std"]}
@ -77,15 +77,15 @@ enclose = "1.2.0"
bounded-vec-deque = {version="0.1.1", default-features=false} bounded-vec-deque = {version="0.1.1", default-features=false}
cfg-if = "1.0" cfg-if = "1.0"
flexi_logger = "0.28" flexi_logger = "0.28"
# eframe = { version = "0.28.1", features = ["wgpu"] }
eframe = {git="https://github.com/emilk/egui", rev="9a1e358", features=["wgpu"]}
# Unix dependencies # Unix dependencies
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
eframe = { version = "0.27.2", features = ["wgpu"] }
tar = "0.4.41" tar = "0.4.41"
flate2 = "1.0" flate2 = "1.0"
sudo = "0.6.0" sudo = "0.6.0"
# macOS # macOS
[target.'cfg(target_os = "macos")'.dependencies] [target.'cfg(target_os = "macos")'.dependencies]
eframe = { version = "0.27.2", features = ["wgpu"] }
# On apple-darwin targets there is an issue with the native and rustls # On apple-darwin targets there is an issue with the native and rustls
# tls implementation so this makes it fall back to the openssl variant. # tls implementation so this makes it fall back to the openssl variant.
# #
@ -99,7 +99,7 @@ eframe = { version = "0.27.2", features = ["wgpu"] }
# linked as well which causes problems, so statically link it. # linked as well which causes problems, so statically link it.
lzma-sys = { version = "0.1", features = ["static"] } lzma-sys = { version = "0.1", features = ["static"] }
[dev-dependencies] [dev-dependencies]
egui = {version = "0.27.2", features=["callstack"]} egui = {git="https://github.com/emilk/egui", rev="9a1e358", features=["callstack"]}
# [target.'cfg(not(target_os = "macos"))'.dependencies] # [target.'cfg(not(target_os = "macos"))'.dependencies]
# tls-api-native-tls = "0.9.0" # tls-api-native-tls = "0.9.0"
@ -107,11 +107,10 @@ egui = {version = "0.27.2", features=["callstack"]}
# Windows dependencies # Windows dependencies
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
# glow start on windows but not wgpu # glow start on windows but not wgpu
eframe = { version = "0.27.2", features = ["wgpu"] }
# need the same version that eframe is using with egui_wgpu # need the same version that eframe is using with egui_wgpu
# feature angle to enable support for old cpu on Windows # feature angle to enable support for old cpu on Windows
wgpu = {version = "0.19.4", features=["angle"]} wgpu = {version = "22.1.0", features=["angle"]}
zip = "2.1.5" zip = "2.2.0"
is_elevated = "0.1.2" is_elevated = "0.1.2"
# For Windows build (icon) # For Windows build (icon)

View file

@ -147,66 +147,67 @@ impl crate::app::App {
} }
fn save_reset_ui(&mut self, ui: &mut Ui, size: Vec2, key: &KeyPressed, wants_input: bool) { fn save_reset_ui(&mut self, ui: &mut Ui, size: Vec2, key: &KeyPressed, wants_input: bool) {
ui.group(|ui| { ui.group(|ui| {
ui.set_enabled(self.diff); ui.add_enabled_ui(self.diff, |ui| {
let width = size.x / 2.0; let width = size.x / 2.0;
let size = vec2(width, size.y); let size = vec2(width, size.y);
if key.is_r() && !wants_input && self.diff if key.is_r() && !wants_input && self.diff
|| ui || ui
.add_sized(size, Button::new("Reset")) .add_sized(size, Button::new("Reset"))
.on_hover_text("Reset changes") .on_hover_text("Reset changes")
.clicked() .clicked()
{ {
let og = lock!(self.og).clone(); let og = lock!(self.og).clone();
self.state.status = og.status; self.state.status = og.status;
self.state.gupax = og.gupax; self.state.gupax = og.gupax;
self.state.p2pool = og.p2pool; self.state.p2pool = og.p2pool;
self.state.xmrig = og.xmrig; self.state.xmrig = og.xmrig;
self.state.xmrig_proxy = og.xmrig_proxy; self.state.xmrig_proxy = og.xmrig_proxy;
self.state.xvb = og.xvb; self.state.xvb = og.xvb;
self.node_vec.clone_from(&self.og_node_vec); self.node_vec.clone_from(&self.og_node_vec);
self.pool_vec.clone_from(&self.og_pool_vec); self.pool_vec.clone_from(&self.og_pool_vec);
} }
if key.is_s() && !wants_input && self.diff if key.is_s() && !wants_input && self.diff
|| ui || ui
.add_sized(size, Button::new("Save")) .add_sized(size, Button::new("Save"))
.on_hover_text("Save changes") .on_hover_text("Save changes")
.clicked() .clicked()
{ {
match State::save(&mut self.state, &self.state_path) { match State::save(&mut self.state, &self.state_path) {
Ok(_) => { Ok(_) => {
let mut og = lock!(self.og); let mut og = lock!(self.og);
og.status = self.state.status.clone(); og.status = self.state.status.clone();
og.gupax = self.state.gupax.clone(); og.gupax = self.state.gupax.clone();
og.p2pool = self.state.p2pool.clone(); og.p2pool = self.state.p2pool.clone();
og.xmrig = self.state.xmrig.clone(); og.xmrig = self.state.xmrig.clone();
og.xmrig_proxy = self.state.xmrig_proxy.clone(); og.xmrig_proxy = self.state.xmrig_proxy.clone();
og.xvb = self.state.xvb.clone(); og.xvb = self.state.xvb.clone();
} }
Err(e) => { Err(e) => {
self.error_state.set( self.error_state.set(
format!("State file: {}", e), format!("State file: {}", e),
ErrorFerris::Error,
ErrorButtons::Okay,
);
}
};
match Node::save(&self.node_vec, &self.node_path) {
Ok(_) => self.og_node_vec.clone_from(&self.node_vec),
Err(e) => self.error_state.set(
format!("Node list: {}", e),
ErrorFerris::Error, ErrorFerris::Error,
ErrorButtons::Okay, ErrorButtons::Okay,
); ),
} };
}; match Pool::save(&self.pool_vec, &self.pool_path) {
match Node::save(&self.node_vec, &self.node_path) { Ok(_) => self.og_pool_vec.clone_from(&self.pool_vec),
Ok(_) => self.og_node_vec.clone_from(&self.node_vec), Err(e) => self.error_state.set(
Err(e) => self.error_state.set( format!("Pool list: {}", e),
format!("Node list: {}", e), ErrorFerris::Error,
ErrorFerris::Error, ErrorButtons::Okay,
ErrorButtons::Okay, ),
), };
}; }
match Pool::save(&self.pool_vec, &self.pool_path) { })
Ok(_) => self.og_pool_vec.clone_from(&self.pool_vec),
Err(e) => self.error_state.set(
format!("Pool list: {}", e),
ErrorFerris::Error,
ErrorButtons::Okay,
),
};
}
}); });
} }
fn status_submenu(&mut self, ui: &mut Ui, height: f32) { fn status_submenu(&mut self, ui: &mut Ui, height: f32) {
@ -378,24 +379,25 @@ impl crate::app::App {
ui_enabled = false; ui_enabled = false;
text = format!("Error: {}", P2POOL_PATH_NOT_VALID); text = format!("Error: {}", P2POOL_PATH_NOT_VALID);
} }
ui.set_enabled(ui_enabled); ui.add_enabled_ui(ui_enabled, |ui| {
let color = if ui_enabled { GREEN } else { RED }; let color = if ui_enabled { GREEN } else { RED };
if (ui_enabled && key.is_up() && !wants_input) if (ui_enabled && key.is_up() && !wants_input)
|| ui || ui
.add_sized(size, Button::new(RichText::new("").color(color))) .add_sized(size, Button::new(RichText::new("").color(color)))
.on_hover_text("Start P2Pool") .on_hover_text("Start P2Pool")
.on_disabled_hover_text(text) .on_disabled_hover_text(text)
.clicked() .clicked()
{ {
let _ = lock!(self.og).update_absolute_path(); let _ = lock!(self.og).update_absolute_path();
let _ = self.state.update_absolute_path(); let _ = self.state.update_absolute_path();
Helper::start_p2pool( Helper::start_p2pool(
&self.helper, &self.helper,
&self.state.p2pool, &self.state.p2pool,
&self.state.gupax.absolute_p2pool_path, &self.state.gupax.absolute_p2pool_path,
self.gather_backup_hosts(), self.gather_backup_hosts(),
); );
} }
});
} }
}); });
} }
@ -529,29 +531,30 @@ impl crate::app::App {
ui_enabled = false; ui_enabled = false;
text = format!("Error: {}", XMRIG_PATH_NOT_VALID); text = format!("Error: {}", XMRIG_PATH_NOT_VALID);
} }
ui.set_enabled(ui_enabled); ui.add_enabled_ui(ui_enabled, |ui| {
let color = if ui_enabled { GREEN } else { RED }; let color = if ui_enabled { GREEN } else { RED };
if (ui_enabled && key.is_up() && !wants_input) if (ui_enabled && key.is_up() && !wants_input)
|| ui || ui
.add_sized(size, Button::new(RichText::new("").color(color))) .add_sized(size, Button::new(RichText::new("").color(color)))
.on_hover_text("Start XMRig") .on_hover_text("Start XMRig")
.on_disabled_hover_text(text) .on_disabled_hover_text(text)
.clicked() .clicked()
{ {
let _ = lock!(self.og).update_absolute_path(); let _ = lock!(self.og).update_absolute_path();
let _ = self.state.update_absolute_path(); let _ = self.state.update_absolute_path();
if cfg!(windows) { if cfg!(windows) {
Helper::start_xmrig( Helper::start_xmrig(
&self.helper, &self.helper,
&self.state.xmrig, &self.state.xmrig,
&self.state.gupax.absolute_xmrig_path, &self.state.gupax.absolute_xmrig_path,
Arc::clone(&self.sudo), Arc::clone(&self.sudo),
); );
} else if cfg!(unix) { } else if cfg!(unix) {
lock!(self.sudo).signal = ProcessSignal::Start; lock!(self.sudo).signal = ProcessSignal::Start;
self.error_state.ask_sudo(&self.sudo); self.error_state.ask_sudo(&self.sudo);
}
} }
} });
} }
}); });
} }
@ -637,23 +640,24 @@ impl crate::app::App {
let ui_enabled = Regexes::addr_ok(&self.state.p2pool.address) let ui_enabled = Regexes::addr_ok(&self.state.p2pool.address)
&& self.state.xvb.token.len() == 9 && self.state.xvb.token.len() == 9
&& self.state.xvb.token.parse::<u32>().is_ok(); && self.state.xvb.token.parse::<u32>().is_ok();
ui.set_enabled(ui_enabled); ui.add_enabled_ui(ui_enabled, |ui| {
let color = if ui_enabled { GREEN } else { RED }; let color = if ui_enabled { GREEN } else { RED };
if (ui_enabled && key.is_up() && !wants_input) if (ui_enabled && key.is_up() && !wants_input)
|| ui || ui
.add_sized(size, Button::new(RichText::new("").color(color))) .add_sized(size, Button::new(RichText::new("").color(color)))
.on_hover_text("Start Xvb") .on_hover_text("Start Xvb")
.on_disabled_hover_text(XVB_NOT_CONFIGURED) .on_disabled_hover_text(XVB_NOT_CONFIGURED)
.clicked() .clicked()
{ {
Helper::start_xvb( Helper::start_xvb(
&self.helper, &self.helper,
&self.state.xvb, &self.state.xvb,
&self.state.p2pool, &self.state.p2pool,
&self.state.xmrig, &self.state.xmrig,
&self.state.xmrig_proxy, &self.state.xmrig_proxy,
); );
} }
});
} }
}); });
} }
@ -726,24 +730,25 @@ impl crate::app::App {
ui_enabled = false; ui_enabled = false;
text = format!("Error: {}", XMRIG_PROXY_PATH_NOT_VALID); text = format!("Error: {}", XMRIG_PROXY_PATH_NOT_VALID);
} }
ui.set_enabled(ui_enabled); ui.add_enabled_ui(ui_enabled, |ui| {
let color = if ui_enabled { GREEN } else { RED }; let color = if ui_enabled { GREEN } else { RED };
if (ui_enabled && key.is_up() && !wants_input) if (ui_enabled && key.is_up() && !wants_input)
|| ui || ui
.add_sized(size, Button::new(RichText::new("").color(color))) .add_sized(size, Button::new(RichText::new("").color(color)))
.on_hover_text("Start XMRig-Proxy") .on_hover_text("Start XMRig-Proxy")
.on_disabled_hover_text(text) .on_disabled_hover_text(text)
.clicked() .clicked()
{ {
let _ = lock!(self.og).update_absolute_path(); let _ = lock!(self.og).update_absolute_path();
let _ = self.state.update_absolute_path(); let _ = self.state.update_absolute_path();
Helper::start_xp( Helper::start_xp(
&self.helper, &self.helper,
&self.state.xmrig_proxy, &self.state.xmrig_proxy,
&self.state.xmrig, &self.state.xmrig,
&self.state.gupax.absolute_xp_path, &self.state.gupax.absolute_xp_path,
); );
} }
});
} }
}); });
} }

View file

@ -45,34 +45,43 @@ impl Gupax {
// If [Gupax] is being built for a Linux distro, // If [Gupax] is being built for a Linux distro,
// disable built-in updating completely. // disable built-in updating completely.
#[cfg(feature = "distro")] #[cfg(feature = "distro")]
ui.set_enabled(false); ui.disable(true);
#[cfg(feature = "distro")] #[cfg(feature = "distro")]
ui.add_sized([width, button], Button::new("Updates are disabled")) ui.add_sized([width, button], Button::new("Updates are disabled"))
.on_disabled_hover_text(DISTRO_NO_UPDATE); .on_disabled_hover_text(DISTRO_NO_UPDATE);
#[cfg(not(feature = "distro"))] #[cfg(not(feature = "distro"))]
ui.set_enabled(!updating && *lock!(restart) == Restart::No); ui.add_enabled_ui(!updating && *lock!(restart) == Restart::No, |ui| {
#[cfg(not(feature = "distro"))] #[cfg(not(feature = "distro"))]
if ui if ui
.add_sized([width, button], Button::new("Check for updates")) .add_sized([width, button], Button::new("Check for updates"))
.on_hover_text(GUPAX_UPDATE) .on_hover_text(GUPAX_UPDATE)
.clicked() .clicked()
{ {
Update::spawn_thread(og, self, state_path, update, error_state, restart); Update::spawn_thread(
} og,
self,
state_path,
update,
error_state,
restart,
);
}
});
}); });
ui.vertical(|ui| { ui.vertical(|ui| {
ui.set_enabled(updating); ui.add_enabled_ui(updating, |ui| {
let prog = *lock2!(update, prog); let prog = *lock2!(update, prog);
let msg = format!("{}\n{}{}", *lock2!(update, msg), prog, "%"); let msg = format!("{}\n{}{}", *lock2!(update, msg), prog, "%");
ui.add_sized([width, height * 1.4], Label::new(RichText::new(msg))); ui.add_sized([width, height * 1.4], Label::new(RichText::new(msg)));
let height = height / 2.0; let height = height / 2.0;
let size = vec2(width, height); let size = vec2(width, height);
if updating { if updating {
ui.add_sized(size, Spinner::new().size(height)); ui.add_sized(size, Spinner::new().size(height));
} else { } else {
ui.add_sized(size, Label::new("...")); ui.add_sized(size, Label::new("..."));
} }
ui.add_sized(size, ProgressBar::new(lock2!(update, prog).round() / 100.0)); ui.add_sized(size, ProgressBar::new(lock2!(update, prog).round() / 100.0));
});
}); });
}); });
@ -165,15 +174,16 @@ impl Gupax {
.on_hover_text(P2POOL_PATH_OK); .on_hover_text(P2POOL_PATH_OK);
} }
ui.spacing_mut().text_edit_width = ui.available_width() - SPACE; ui.spacing_mut().text_edit_width = ui.available_width() - SPACE;
ui.set_enabled(!lock!(file_window).thread); ui.add_enabled_ui(!lock!(file_window).thread, |ui| {
if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() { if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() {
Self::spawn_file_window_thread(file_window, FileType::P2pool); Self::spawn_file_window_thread(file_window, FileType::P2pool);
} }
ui.add_sized( ui.add_sized(
[ui.available_width(), height], [ui.available_width(), height],
TextEdit::singleline(&mut self.p2pool_path), TextEdit::singleline(&mut self.p2pool_path),
) )
.on_hover_text(GUPAX_PATH_P2POOL); .on_hover_text(GUPAX_PATH_P2POOL);
});
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
if self.xmrig_path.is_empty() { if self.xmrig_path.is_empty() {
@ -202,15 +212,16 @@ impl Gupax {
.on_hover_text(XMRIG_PATH_OK); .on_hover_text(XMRIG_PATH_OK);
} }
ui.spacing_mut().text_edit_width = ui.available_width() - SPACE; ui.spacing_mut().text_edit_width = ui.available_width() - SPACE;
ui.set_enabled(!lock!(file_window).thread); ui.add_enabled_ui(!lock!(file_window).thread, |ui| {
if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() { if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() {
Self::spawn_file_window_thread(file_window, FileType::Xmrig); Self::spawn_file_window_thread(file_window, FileType::Xmrig);
} }
ui.add_sized( ui.add_sized(
[ui.available_width(), height], [ui.available_width(), height],
TextEdit::singleline(&mut self.xmrig_path), TextEdit::singleline(&mut self.xmrig_path),
) )
.on_hover_text(GUPAX_PATH_XMRIG); .on_hover_text(GUPAX_PATH_XMRIG);
});
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
if self.xmrig_proxy_path.is_empty() { if self.xmrig_proxy_path.is_empty() {
@ -241,15 +252,16 @@ impl Gupax {
.on_hover_text(XMRIG_PROXY_PATH_OK); .on_hover_text(XMRIG_PROXY_PATH_OK);
} }
ui.spacing_mut().text_edit_width = ui.available_width() - SPACE; ui.spacing_mut().text_edit_width = ui.available_width() - SPACE;
ui.set_enabled(!lock!(file_window).thread); ui.add_enabled_ui(!lock!(file_window).thread, |ui| {
if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() { if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() {
Self::spawn_file_window_thread(file_window, FileType::XmrigProxy); Self::spawn_file_window_thread(file_window, FileType::XmrigProxy);
} }
ui.add_sized( ui.add_sized(
[ui.available_width(), height], [ui.available_width(), height],
TextEdit::singleline(&mut self.xmrig_proxy_path), TextEdit::singleline(&mut self.xmrig_proxy_path),
) )
.on_hover_text(GUPAX_PATH_XMRIG_PROXY); .on_hover_text(GUPAX_PATH_XMRIG_PROXY);
});
}); });
}); });
let mut guard = lock!(file_window); let mut guard = lock!(file_window);
@ -365,40 +377,42 @@ impl Gupax {
let height = height / 3.5; let height = height / 3.5;
let size = vec2(width, height); let size = vec2(width, height);
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.set_enabled(self.ratio != Ratio::Height); ui.add_enabled_ui(self.ratio != Ratio::Height, |ui| {
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
" Width [{}-{}]:", " Width [{}-{}]:",
APP_MIN_WIDTH as u16, APP_MAX_WIDTH as u16 APP_MIN_WIDTH as u16, APP_MAX_WIDTH as u16
)), )),
); );
ui.add_sized( ui.add_sized(
size, size,
Slider::new( Slider::new(
&mut self.selected_width, &mut self.selected_width,
APP_MIN_WIDTH as u16..=APP_MAX_WIDTH as u16, APP_MIN_WIDTH as u16..=APP_MAX_WIDTH as u16,
), ),
) )
.on_hover_text(GUPAX_WIDTH); .on_hover_text(GUPAX_WIDTH);
});
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.set_enabled(self.ratio != Ratio::Width); ui.add_enabled_ui(self.ratio != Ratio::Width, |ui| {
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"Height [{}-{}]:", "Height [{}-{}]:",
APP_MIN_HEIGHT as u16, APP_MAX_HEIGHT as u16 APP_MIN_HEIGHT as u16, APP_MAX_HEIGHT as u16
)), )),
); );
ui.add_sized( ui.add_sized(
size, size,
Slider::new( Slider::new(
&mut self.selected_height, &mut self.selected_height,
APP_MIN_HEIGHT as u16..=APP_MAX_HEIGHT as u16, APP_MIN_HEIGHT as u16..=APP_MAX_HEIGHT as u16,
), ),
) )
.on_hover_text(GUPAX_HEIGHT); .on_hover_text(GUPAX_HEIGHT);
});
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.add_sized( ui.add_sized(

View file

@ -154,7 +154,7 @@ impl P2pool {
let text = format!("{}\n Currently selected node: {}. {}\n Current amount of nodes: {}/1000", text, self.selected_index+1, self.selected_name, node_vec_len); let text = format!("{}\n Currently selected node: {}. {}\n Current amount of nodes: {}/1000", text, self.selected_index+1, self.selected_name, node_vec_len);
// If the node already exists, show [Save] and mutate the already existing node // If the node already exists, show [Save] and mutate the already existing node
if exists { if exists {
ui.set_enabled(!incorrect_input && save_diff); ui.add_enabled_ui(!incorrect_input && save_diff, |ui|{
if ui.add_sized([width, text_edit], Button::new("Save")).on_hover_text(text).clicked() { if ui.add_sized([width, text_edit], Button::new("Save")).on_hover_text(text).clicked() {
let node = Node { let node = Node {
ip: self.ip.clone(), ip: self.ip.clone(),
@ -168,9 +168,10 @@ impl P2pool {
self.selected_zmq.clone_from(&self.zmq); self.selected_zmq.clone_from(&self.zmq);
info!("Node | S | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", existing_index+1, self.name, self.ip, self.rpc, self.zmq); info!("Node | S | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", existing_index+1, self.name, self.ip, self.rpc, self.zmq);
} }
});
// Else, add to the list // Else, add to the list
} else { } else {
ui.set_enabled(!incorrect_input && node_vec_len < 1000); ui.add_enabled_ui(!incorrect_input && node_vec_len < 1000, |ui| {
if ui.add_sized([width, text_edit], Button::new("Add")).on_hover_text(text).clicked() { if ui.add_sized([width, text_edit], Button::new("Add")).on_hover_text(text).clicked() {
let node = Node { let node = Node {
ip: self.ip.clone(), ip: self.ip.clone(),
@ -185,11 +186,12 @@ impl P2pool {
self.selected_zmq.clone_from(&self.zmq); self.selected_zmq.clone_from(&self.zmq);
info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", node_vec_len, self.name, self.ip, self.rpc, self.zmq); info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", node_vec_len, self.name, self.ip, self.rpc, self.zmq);
} }
});
} }
}); });
// [Delete] // [Delete]
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.set_enabled(node_vec_len > 1); ui.add_enabled_ui(node_vec_len > 1, |ui|{
let text = format!("{}\n Currently selected node: {}. {}\n Current amount of nodes: {}/1000", LIST_DELETE, self.selected_index+1, self.selected_name, node_vec_len); let text = format!("{}\n Currently selected node: {}. {}\n Current amount of nodes: {}/1000", LIST_DELETE, self.selected_index+1, self.selected_name, node_vec_len);
if ui.add_sized([width, text_edit], Button::new("Delete")).on_hover_text(text).clicked() { if ui.add_sized([width, text_edit], Button::new("Delete")).on_hover_text(text).clicked() {
let new_name; let new_name;
@ -217,15 +219,18 @@ impl P2pool {
self.zmq = new_node.zmq; self.zmq = new_node.zmq;
info!("Node | D | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", self.selected_index, self.selected_name, self.selected_ip, self.selected_rpc, self.selected_zmq); info!("Node | D | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", self.selected_index, self.selected_name, self.selected_ip, self.selected_rpc, self.selected_zmq);
} }
});
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.set_enabled(!self.name.is_empty() || !self.ip.is_empty() || !self.rpc.is_empty() || !self.zmq.is_empty()); ui.add_enabled_ui(!self.name.is_empty() || !self.ip.is_empty() || !self.rpc.is_empty() || !self.zmq.is_empty(), |ui|{
if ui.add_sized([width, text_edit], Button::new("Clear")).on_hover_text(LIST_CLEAR).clicked() { if ui.add_sized([width, text_edit], Button::new("Clear")).on_hover_text(LIST_CLEAR).clicked() {
self.name.clear(); self.name.clear();
self.ip.clear(); self.ip.clear();
self.rpc.clear(); self.rpc.clear();
self.zmq.clear(); self.zmq.clear();
} }
});
}); });
}); });
}); });

View file

@ -130,7 +130,9 @@ impl P2pool {
self.arguments.truncate(1024); self.arguments.truncate(1024);
}) })
}); });
ui.set_enabled(self.arguments.is_empty()); if !self.arguments.is_empty() {
ui.disable()
}
} }
//---------------------------------------------------------------------------------------------------- Address //---------------------------------------------------------------------------------------------------- Address

View file

@ -138,21 +138,22 @@ impl P2pool {
ui.vertical(|ui| { ui.vertical(|ui| {
let height = height / 2.0; let height = height / 2.0;
let pinging = lock!(ping).pinging; let pinging = lock!(ping).pinging;
ui.set_enabled(pinging); ui.add_enabled_ui(pinging, |ui| {
let prog = lock!(ping).prog.round(); let prog = lock!(ping).prog.round();
let msg = RichText::new(format!("{} ... {}%", lock!(ping).msg, prog)); let msg = RichText::new(format!("{} ... {}%", lock!(ping).msg, prog));
let height = height / 1.25; let height = height / 1.25;
let size = vec2(size.x, height); let size = vec2(size.x, height);
ui.add_space(space_h); ui.add_space(space_h);
ui.add_sized(size, Label::new(msg)); ui.add_sized(size, Label::new(msg));
ui.add_space(space_h); ui.add_space(space_h);
if pinging { if pinging {
ui.add_sized(size, Spinner::new().size(height)); ui.add_sized(size, Spinner::new().size(height));
} else { } else {
ui.add_sized(size, Label::new("...")); ui.add_sized(size, Label::new("..."));
} }
ui.add_sized(size, ProgressBar::new(prog.round() / 100.0)); ui.add_sized(size, ProgressBar::new(prog.round() / 100.0));
ui.add_space(space_h); ui.add_space(space_h);
});
}); });
}); });

View file

@ -120,12 +120,13 @@ impl Status {
ui.add_sized([width, text], ProgressBar::new(percent / 100.0)); ui.add_sized([width, text], ProgressBar::new(percent / 100.0));
} }
} else { } else {
ui.set_enabled(xmrig_alive); ui.add_enabled_ui(xmrig_alive, |ui| {
ui.add_sized( ui.add_sized(
[width, double], [width, double],
Label::new("XMRig is offline. Hashrate cannot be determined."), Label::new("XMRig is offline. Hashrate cannot be determined."),
); );
ui.add_sized([width, text], ProgressBar::new(0.0)); ui.add_sized([width, text], ProgressBar::new(0.0));
});
} }
}); });

View file

@ -156,274 +156,306 @@ impl Status {
self.manual_hash = true; self.manual_hash = true;
} }
ui.separator(); ui.separator();
ui.set_enabled(self.manual_hash); ui.add_enabled_ui(self.manual_hash, |ui| {
if ui if ui
.add_sized( .add_sized(
[button, text], [button, text],
SelectableLabel::new(self.hash_metric == Hash::Hash, "Hash"), SelectableLabel::new(self.hash_metric == Hash::Hash, "Hash"),
) )
.on_hover_text(STATUS_SUBMENU_HASH) .on_hover_text(STATUS_SUBMENU_HASH)
.clicked() .clicked()
{ {
self.hash_metric = Hash::Hash; self.hash_metric = Hash::Hash;
} }
ui.separator(); ui.separator();
if ui if ui
.add_sized( .add_sized(
[button, text], [button, text],
SelectableLabel::new(self.hash_metric == Hash::Kilo, "Kilo"), SelectableLabel::new(self.hash_metric == Hash::Kilo, "Kilo"),
) )
.on_hover_text(STATUS_SUBMENU_KILO) .on_hover_text(STATUS_SUBMENU_KILO)
.clicked() .clicked()
{ {
self.hash_metric = Hash::Kilo; self.hash_metric = Hash::Kilo;
} }
ui.separator(); ui.separator();
if ui if ui
.add_sized( .add_sized(
[button, text], [button, text],
SelectableLabel::new(self.hash_metric == Hash::Mega, "Mega"), SelectableLabel::new(self.hash_metric == Hash::Mega, "Mega"),
) )
.on_hover_text(STATUS_SUBMENU_MEGA) .on_hover_text(STATUS_SUBMENU_MEGA)
.clicked() .clicked()
{ {
self.hash_metric = Hash::Mega; self.hash_metric = Hash::Mega;
} }
ui.separator(); ui.separator();
if ui if ui
.add_sized( .add_sized(
[button, text], [button, text],
SelectableLabel::new(self.hash_metric == Hash::Giga, "Giga"), SelectableLabel::new(self.hash_metric == Hash::Giga, "Giga"),
) )
.on_hover_text(STATUS_SUBMENU_GIGA) .on_hover_text(STATUS_SUBMENU_GIGA)
.clicked() .clicked()
{ {
self.hash_metric = Hash::Giga; self.hash_metric = Hash::Giga;
} }
ui.separator(); ui.separator();
ui.spacing_mut().slider_width = button * 11.5; ui.spacing_mut().slider_width = button * 11.5;
ui.add_sized( ui.add_sized(
[button * 14.0, text], [button * 14.0, text],
Slider::new(&mut self.hashrate, 1.0..=1_000.0), Slider::new(&mut self.hashrate, 1.0..=1_000.0),
); );
});
}) })
}); });
// Actual stats // Actual stats
ui.set_enabled(p2pool_alive); ui.add_enabled_ui(p2pool_alive, |ui| {
let text = height / 25.0; let text = height / 25.0;
let width = (width / 3.0) - (SPACE * 1.666); let width = (width / 3.0) - (SPACE * 1.666);
let min_height = ui.available_height() / 1.3; let min_height = ui.available_height() / 1.3;
let api = lock!(p2pool_api); let api = lock!(p2pool_api);
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.group(|ui| { ui.group(|ui| {
ui.vertical(|ui| { ui.vertical(|ui| {
ui.set_min_height(min_height); ui.set_min_height(min_height);
ui.add_sized( ui.add_sized(
[width, text], [width, text],
Label::new(RichText::new("Monero Difficulty").underline().color(BONE)), Label::new(RichText::new("Monero Difficulty").underline().color(BONE)),
) )
.on_hover_text(STATUS_SUBMENU_MONERO_DIFFICULTY); .on_hover_text(STATUS_SUBMENU_MONERO_DIFFICULTY);
ui.add_sized([width, text], Label::new(api.monero_difficulty.as_str())); ui.add_sized([width, text], Label::new(api.monero_difficulty.as_str()));
ui.add_sized( ui.add_sized(
[width, text], [width, text],
Label::new(RichText::new("Monero Hashrate").underline().color(BONE)), Label::new(RichText::new("Monero Hashrate").underline().color(BONE)),
) )
.on_hover_text(STATUS_SUBMENU_MONERO_HASHRATE); .on_hover_text(STATUS_SUBMENU_MONERO_HASHRATE);
ui.add_sized([width, text], Label::new(api.monero_hashrate.as_str())); ui.add_sized([width, text], Label::new(api.monero_hashrate.as_str()));
ui.add_sized( ui.add_sized(
[width, text], [width, text],
Label::new(RichText::new("P2Pool Difficulty").underline().color(BONE)), Label::new(RichText::new("P2Pool Difficulty").underline().color(BONE)),
) )
.on_hover_text(STATUS_SUBMENU_P2POOL_DIFFICULTY); .on_hover_text(STATUS_SUBMENU_P2POOL_DIFFICULTY);
ui.add_sized([width, text], Label::new(api.p2pool_difficulty.as_str())); ui.add_sized([width, text], Label::new(api.p2pool_difficulty.as_str()));
ui.add_sized( ui.add_sized(
[width, text], [width, text],
Label::new(RichText::new("P2Pool Hashrate").underline().color(BONE)), Label::new(RichText::new("P2Pool Hashrate").underline().color(BONE)),
) )
.on_hover_text(STATUS_SUBMENU_P2POOL_HASHRATE); .on_hover_text(STATUS_SUBMENU_P2POOL_HASHRATE);
ui.add_sized([width, text], Label::new(api.p2pool_hashrate.as_str())); ui.add_sized([width, text], Label::new(api.p2pool_hashrate.as_str()));
}) })
}); });
ui.group(|ui| { ui.group(|ui| {
ui.vertical(|ui| { ui.vertical(|ui| {
ui.set_min_height(min_height); ui.set_min_height(min_height);
if self.manual_hash { if self.manual_hash {
let hashrate = let hashrate =
Hash::convert_to_hash(self.hashrate, self.hash_metric) as u64; Hash::convert_to_hash(self.hashrate, self.hash_metric) as u64;
let p2pool_share_mean = PubP2poolApi::calculate_share_or_block_time( let p2pool_share_mean = PubP2poolApi::calculate_share_or_block_time(
hashrate, hashrate,
api.p2pool_difficulty_u64, api.p2pool_difficulty_u64,
); );
let solo_block_mean = PubP2poolApi::calculate_share_or_block_time( let solo_block_mean = PubP2poolApi::calculate_share_or_block_time(
hashrate, hashrate,
api.monero_difficulty_u64, api.monero_difficulty_u64,
); );
ui.add_sized( ui.add_sized(
[width, text], [width, text],
Label::new( Label::new(
RichText::new("Manually Inputted Hashrate") RichText::new("Manually Inputted Hashrate")
.underline() .underline()
.color(BONE), .color(BONE),
), ),
); );
ui.add_sized( ui.add_sized(
[width, text], [width, text],
Label::new(format!("{} H/s", Unsigned::from(hashrate))), Label::new(format!("{} H/s", Unsigned::from(hashrate))),
); );
ui.add_sized( ui.add_sized(
[width, text], [width, text],
Label::new(RichText::new("P2Pool Block Mean").underline().color(BONE)), Label::new(
) RichText::new("P2Pool Block Mean").underline().color(BONE),
.on_hover_text(STATUS_SUBMENU_P2POOL_BLOCK_MEAN); ),
ui.add_sized([width, text], Label::new(api.p2pool_block_mean.to_string())); )
ui.add_sized( .on_hover_text(STATUS_SUBMENU_P2POOL_BLOCK_MEAN);
[width, text], ui.add_sized(
Label::new( [width, text],
RichText::new("Your P2Pool Share Mean") Label::new(api.p2pool_block_mean.to_string()),
.underline() );
.color(BONE), ui.add_sized(
), [width, text],
) Label::new(
.on_hover_text(STATUS_SUBMENU_P2POOL_SHARE_MEAN); RichText::new("Your P2Pool Share Mean")
ui.add_sized([width, text], Label::new(p2pool_share_mean.to_string())); .underline()
ui.add_sized( .color(BONE),
[width, text], ),
Label::new( )
RichText::new("Your Solo Block Mean") .on_hover_text(STATUS_SUBMENU_P2POOL_SHARE_MEAN);
.underline() ui.add_sized([width, text], Label::new(p2pool_share_mean.to_string()));
.color(BONE), ui.add_sized(
), [width, text],
) Label::new(
.on_hover_text(STATUS_SUBMENU_SOLO_BLOCK_MEAN); RichText::new("Your Solo Block Mean")
ui.add_sized([width, text], Label::new(solo_block_mean.to_string())); .underline()
} else { .color(BONE),
ui.add_sized( ),
[width, text], )
Label::new( .on_hover_text(STATUS_SUBMENU_SOLO_BLOCK_MEAN);
RichText::new("Your P2Pool Hashrate") ui.add_sized([width, text], Label::new(solo_block_mean.to_string()));
.underline() } else {
.color(BONE), ui.add_sized(
), [width, text],
) Label::new(
.on_hover_text(STATUS_SUBMENU_YOUR_P2POOL_HASHRATE); RichText::new("Your P2Pool Hashrate")
ui.add_sized( .underline()
[width, text], .color(BONE),
Label::new(format!("{} H/s", api.hashrate_1h)), ),
); )
ui.add_sized( .on_hover_text(STATUS_SUBMENU_YOUR_P2POOL_HASHRATE);
[width, text], ui.add_sized(
Label::new(RichText::new("P2Pool Block Mean").underline().color(BONE)), [width, text],
) Label::new(format!("{} H/s", api.hashrate_1h)),
.on_hover_text(STATUS_SUBMENU_P2POOL_BLOCK_MEAN); );
ui.add_sized([width, text], Label::new(api.p2pool_block_mean.to_string())); ui.add_sized(
ui.add_sized( [width, text],
[width, text], Label::new(
Label::new( RichText::new("P2Pool Block Mean").underline().color(BONE),
RichText::new("Your P2Pool Share Mean") ),
.underline() )
.color(BONE), .on_hover_text(STATUS_SUBMENU_P2POOL_BLOCK_MEAN);
), ui.add_sized(
) [width, text],
.on_hover_text(STATUS_SUBMENU_P2POOL_SHARE_MEAN); Label::new(api.p2pool_block_mean.to_string()),
ui.add_sized([width, text], Label::new(api.p2pool_share_mean.to_string())); );
ui.add_sized( ui.add_sized(
[width, text], [width, text],
Label::new( Label::new(
RichText::new("Your Solo Block Mean") RichText::new("Your P2Pool Share Mean")
.underline() .underline()
.color(BONE), .color(BONE),
), ),
) )
.on_hover_text(STATUS_SUBMENU_SOLO_BLOCK_MEAN); .on_hover_text(STATUS_SUBMENU_P2POOL_SHARE_MEAN);
ui.add_sized([width, text], Label::new(api.solo_block_mean.to_string())); ui.add_sized(
} [width, text],
}) Label::new(api.p2pool_share_mean.to_string()),
}); );
ui.group(|ui| { ui.add_sized(
ui.vertical(|ui| { [width, text],
ui.set_min_height(min_height); Label::new(
if self.manual_hash { RichText::new("Your Solo Block Mean")
let hashrate = .underline()
Hash::convert_to_hash(self.hashrate, self.hash_metric) as u64; .color(BONE),
let user_p2pool_percent = ),
PubP2poolApi::calculate_dominance(hashrate, api.p2pool_hashrate_u64); )
let user_monero_percent = .on_hover_text(STATUS_SUBMENU_SOLO_BLOCK_MEAN);
PubP2poolApi::calculate_dominance(hashrate, api.monero_hashrate_u64); ui.add_sized(
ui.add_sized( [width, text],
[width, text], Label::new(api.solo_block_mean.to_string()),
Label::new(RichText::new("P2Pool Miners").underline().color(BONE)), );
) }
.on_hover_text(STATUS_SUBMENU_P2POOL_MINERS); })
ui.add_sized([width, text], Label::new(api.miners.as_str())); });
ui.add_sized( ui.group(|ui| {
[width, text], ui.vertical(|ui| {
Label::new(RichText::new("P2Pool Dominance").underline().color(BONE)), ui.set_min_height(min_height);
) if self.manual_hash {
.on_hover_text(STATUS_SUBMENU_P2POOL_DOMINANCE); let hashrate =
ui.add_sized([width, text], Label::new(api.p2pool_percent.as_str())); Hash::convert_to_hash(self.hashrate, self.hash_metric) as u64;
ui.add_sized( let user_p2pool_percent = PubP2poolApi::calculate_dominance(
[width, text], hashrate,
Label::new( api.p2pool_hashrate_u64,
RichText::new("Your P2Pool Dominance") );
.underline() let user_monero_percent = PubP2poolApi::calculate_dominance(
.color(BONE), hashrate,
), api.monero_hashrate_u64,
) );
.on_hover_text(STATUS_SUBMENU_YOUR_P2POOL_DOMINANCE); ui.add_sized(
ui.add_sized([width, text], Label::new(user_p2pool_percent.as_str())); [width, text],
ui.add_sized( Label::new(RichText::new("P2Pool Miners").underline().color(BONE)),
[width, text], )
Label::new( .on_hover_text(STATUS_SUBMENU_P2POOL_MINERS);
RichText::new("Your Monero Dominance") ui.add_sized([width, text], Label::new(api.miners.as_str()));
.underline() ui.add_sized(
.color(BONE), [width, text],
), Label::new(
) RichText::new("P2Pool Dominance").underline().color(BONE),
.on_hover_text(STATUS_SUBMENU_YOUR_MONERO_DOMINANCE); ),
ui.add_sized([width, text], Label::new(user_monero_percent.as_str())); )
} else { .on_hover_text(STATUS_SUBMENU_P2POOL_DOMINANCE);
ui.add_sized( ui.add_sized([width, text], Label::new(api.p2pool_percent.as_str()));
[width, text], ui.add_sized(
Label::new(RichText::new("P2Pool Miners").underline().color(BONE)), [width, text],
) Label::new(
.on_hover_text(STATUS_SUBMENU_P2POOL_MINERS); RichText::new("Your P2Pool Dominance")
ui.add_sized([width, text], Label::new(api.miners.as_str())); .underline()
ui.add_sized( .color(BONE),
[width, text], ),
Label::new(RichText::new("P2Pool Dominance").underline().color(BONE)), )
) .on_hover_text(STATUS_SUBMENU_YOUR_P2POOL_DOMINANCE);
.on_hover_text(STATUS_SUBMENU_P2POOL_DOMINANCE); ui.add_sized([width, text], Label::new(user_p2pool_percent.as_str()));
ui.add_sized([width, text], Label::new(api.p2pool_percent.as_str())); ui.add_sized(
ui.add_sized( [width, text],
[width, text], Label::new(
Label::new( RichText::new("Your Monero Dominance")
RichText::new("Your P2Pool Dominance") .underline()
.underline() .color(BONE),
.color(BONE), ),
), )
) .on_hover_text(STATUS_SUBMENU_YOUR_MONERO_DOMINANCE);
.on_hover_text(STATUS_SUBMENU_YOUR_P2POOL_DOMINANCE); ui.add_sized([width, text], Label::new(user_monero_percent.as_str()));
ui.add_sized([width, text], Label::new(api.user_p2pool_percent.as_str())); } else {
ui.add_sized( ui.add_sized(
[width, text], [width, text],
Label::new( Label::new(RichText::new("P2Pool Miners").underline().color(BONE)),
RichText::new("Your Monero Dominance") )
.underline() .on_hover_text(STATUS_SUBMENU_P2POOL_MINERS);
.color(BONE), ui.add_sized([width, text], Label::new(api.miners.as_str()));
), ui.add_sized(
) [width, text],
.on_hover_text(STATUS_SUBMENU_YOUR_MONERO_DOMINANCE); Label::new(
ui.add_sized([width, text], Label::new(api.user_monero_percent.as_str())); RichText::new("P2Pool Dominance").underline().color(BONE),
} ),
}) )
.on_hover_text(STATUS_SUBMENU_P2POOL_DOMINANCE);
ui.add_sized([width, text], Label::new(api.p2pool_percent.as_str()));
ui.add_sized(
[width, text],
Label::new(
RichText::new("Your P2Pool Dominance")
.underline()
.color(BONE),
),
)
.on_hover_text(STATUS_SUBMENU_YOUR_P2POOL_DOMINANCE);
ui.add_sized(
[width, text],
Label::new(api.user_p2pool_percent.as_str()),
);
ui.add_sized(
[width, text],
Label::new(
RichText::new("Your Monero Dominance")
.underline()
.color(BONE),
),
)
.on_hover_text(STATUS_SUBMENU_YOUR_MONERO_DOMINANCE);
ui.add_sized(
[width, text],
Label::new(api.user_monero_percent.as_str()),
);
}
})
});
}); });
// Tick bar
ui.add_sized(
[ui.available_width(), text],
Label::new(api.calculate_tick_bar()),
)
.on_hover_text(STATUS_SUBMENU_PROGRESS_BAR);
drop(api);
}); });
// Tick bar
ui.add_sized(
[ui.available_width(), text],
Label::new(api.calculate_tick_bar()),
)
.on_hover_text(STATUS_SUBMENU_PROGRESS_BAR);
drop(api);
} }
} }

View file

@ -142,135 +142,136 @@ fn p2pool(
ui.set_min_height(min_size.y * 34.0); ui.set_min_height(min_size.y * 34.0);
ui.set_min_size(min_size); ui.set_min_size(min_size);
debug!("Status Tab | Rendering [P2Pool]"); debug!("Status Tab | Rendering [P2Pool]");
ui.set_enabled(p2pool_alive); ui.add_enabled_ui(p2pool_alive, |ui| {
ui.add_sized( ui.add_sized(
size, size,
Label::new( Label::new(
RichText::new("[P2Pool]") RichText::new("[P2Pool]")
.color(LIGHT_GRAY) .color(LIGHT_GRAY)
.text_style(TextStyle::Name("MonospaceLarge".into())), .text_style(TextStyle::Name("MonospaceLarge".into())),
), ),
) )
.on_hover_text("P2Pool is online") .on_hover_text("P2Pool is online")
.on_disabled_hover_text("P2Pool is offline"); .on_disabled_hover_text("P2Pool is offline");
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into())); ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
let size = [size.x, size.y / 1.4]; let size = [size.x, size.y / 1.4];
let api = lock!(p2pool_api); let api = lock!(p2pool_api);
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Uptime").underline().color(BONE)), Label::new(RichText::new("Uptime").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_UPTIME); .on_hover_text(STATUS_P2POOL_UPTIME);
ui.add_sized(size, Label::new(format!("{}", api.uptime))); ui.add_sized(size, Label::new(format!("{}", api.uptime)));
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Current Shares").underline().color(BONE)), Label::new(RichText::new("Current Shares").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_CURRENT_SHARES); .on_hover_text(STATUS_P2POOL_CURRENT_SHARES);
ui.add_sized(size, Label::new(api.sidechain_shares.to_string())); ui.add_sized(size, Label::new(api.sidechain_shares.to_string()));
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Shares Found").underline().color(BONE)), Label::new(RichText::new("Shares Found").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_SHARES); .on_hover_text(STATUS_P2POOL_SHARES);
ui.add_sized( ui.add_sized(
size, size,
Label::new( Label::new(
(if let Some(s) = api.shares_found { (if let Some(s) = api.shares_found {
s.to_string() s.to_string()
} else { } else {
UNKNOWN_DATA.to_string() UNKNOWN_DATA.to_string()
}) })
.to_string(), .to_string(),
), ),
); );
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Payouts").underline().color(BONE)), Label::new(RichText::new("Payouts").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_PAYOUTS); .on_hover_text(STATUS_P2POOL_PAYOUTS);
ui.add_sized(size, Label::new(format!("Total: {}", api.payouts))); ui.add_sized(size, Label::new(format!("Total: {}", api.payouts)));
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"[{:.7}/hour]\n[{:.7}/day]\n[{:.7}/month]", "[{:.7}/hour]\n[{:.7}/day]\n[{:.7}/month]",
api.payouts_hour, api.payouts_day, api.payouts_month api.payouts_hour, api.payouts_day, api.payouts_month
)), )),
); );
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("XMR Mined").underline().color(BONE)), Label::new(RichText::new("XMR Mined").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_XMR); .on_hover_text(STATUS_P2POOL_XMR);
ui.add_sized(size, Label::new(format!("Total: {:.13} XMR", api.xmr))); ui.add_sized(size, Label::new(format!("Total: {:.13} XMR", api.xmr)));
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"[{:.7}/hour]\n[{:.7}/day]\n[{:.7}/month]", "[{:.7}/hour]\n[{:.7}/day]\n[{:.7}/month]",
api.xmr_hour, api.xmr_day, api.xmr_month api.xmr_hour, api.xmr_day, api.xmr_month
)), )),
); );
ui.add_sized( ui.add_sized(
size, size,
Label::new( Label::new(
RichText::new("Hashrate (15m/1h/24h)") RichText::new("Hashrate (15m/1h/24h)")
.underline() .underline()
.color(BONE), .color(BONE),
), ),
) )
.on_hover_text(STATUS_P2POOL_HASHRATE); .on_hover_text(STATUS_P2POOL_HASHRATE);
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"[{} H/s] [{} H/s] [{} H/s]", "[{} H/s] [{} H/s] [{} H/s]",
api.hashrate_15m, api.hashrate_1h, api.hashrate_24h api.hashrate_15m, api.hashrate_1h, api.hashrate_24h
)), )),
); );
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Miners Connected").underline().color(BONE)), Label::new(RichText::new("Miners Connected").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_CONNECTIONS); .on_hover_text(STATUS_P2POOL_CONNECTIONS);
ui.add_sized(size, Label::new(format!("{}", api.connections))); ui.add_sized(size, Label::new(format!("{}", api.connections)));
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Effort").underline().color(BONE)), Label::new(RichText::new("Effort").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_EFFORT); .on_hover_text(STATUS_P2POOL_EFFORT);
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"[Average: {}] [Current: {}]", "[Average: {}] [Current: {}]",
api.average_effort, api.current_effort api.average_effort, api.current_effort
)), )),
); );
let img = lock!(p2pool_img); let img = lock!(p2pool_img);
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Monero Node").underline().color(BONE)), Label::new(RichText::new("Monero Node").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_MONERO_NODE); .on_hover_text(STATUS_P2POOL_MONERO_NODE);
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"[IP: {}]\n[RPC: {}] [ZMQ: {}]", "[IP: {}]\n[RPC: {}] [ZMQ: {}]",
&img.host, &img.rpc, &img.zmq &img.host, &img.rpc, &img.zmq
)), )),
); );
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Sidechain").underline().color(BONE)), Label::new(RichText::new("Sidechain").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_POOL); .on_hover_text(STATUS_P2POOL_POOL);
ui.add_sized(size, Label::new(&img.mini)); ui.add_sized(size, Label::new(&img.mini));
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Address").underline().color(BONE)), Label::new(RichText::new("Address").underline().color(BONE)),
) )
.on_hover_text(STATUS_P2POOL_ADDRESS); .on_hover_text(STATUS_P2POOL_ADDRESS);
ui.add_sized(size, Label::new(&img.address)); ui.add_sized(size, Label::new(&img.address));
drop(img); drop(img);
drop(api); drop(api);
});
}) })
}) })
}); });
@ -287,59 +288,60 @@ fn xmrig_proxy(
ui.vertical(|ui| { ui.vertical(|ui| {
ui.set_min_height(min_size.y * 34.0); ui.set_min_height(min_size.y * 34.0);
debug!("Status Tab | Rendering [XMRig-Proxy]"); debug!("Status Tab | Rendering [XMRig-Proxy]");
ui.set_enabled(xmrig_proxy_alive); ui.add_enabled_ui(xmrig_proxy_alive, |ui| {
ui.set_min_size(min_size); ui.set_min_size(min_size);
ui.add_sized( ui.add_sized(
size, size,
Label::new( Label::new(
RichText::new("[XMRig-Proxy]") RichText::new("[XMRig-Proxy]")
.color(LIGHT_GRAY) .color(LIGHT_GRAY)
.text_style(TextStyle::Name("MonospaceLarge".into())), .text_style(TextStyle::Name("MonospaceLarge".into())),
), ),
) )
.on_hover_text("XMRig-Proxy is online") .on_hover_text("XMRig-Proxy is online")
.on_disabled_hover_text("XMRig-Proxy is offline"); .on_disabled_hover_text("XMRig-Proxy is offline");
let api = lock!(xmrig_proxy_api); let api = lock!(xmrig_proxy_api);
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Uptime").underline().color(BONE)), Label::new(RichText::new("Uptime").underline().color(BONE)),
) )
.on_hover_text(STATUS_XMRIG_PROXY_UPTIME); .on_hover_text(STATUS_XMRIG_PROXY_UPTIME);
ui.add_sized(size, Label::new(UptimeFull::from(api.uptime).as_str())); ui.add_sized(size, Label::new(UptimeFull::from(api.uptime).as_str()));
ui.add_sized( ui.add_sized(
size, size,
Label::new( Label::new(
RichText::new("Hashrate\n(1m/10m/1h/12h/24h)") RichText::new("Hashrate\n(1m/10m/1h/12h/24h)")
.underline() .underline()
.color(BONE), .color(BONE),
), ),
) )
.on_hover_text(STATUS_XMRIG_PROXY_HASHRATE); .on_hover_text(STATUS_XMRIG_PROXY_HASHRATE);
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"[{} H/s] [{} H/s]\n[{} H/s] [{} H/s] [{} H/s]", "[{} H/s] [{} H/s]\n[{} H/s] [{} H/s] [{} H/s]",
api.hashrate_1m, api.hashrate_1m,
api.hashrate_10m, api.hashrate_10m,
api.hashrate_1h, api.hashrate_1h,
api.hashrate_12h, api.hashrate_12h,
api.hashrate_24h api.hashrate_24h
)), )),
); );
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"[Accepted: {}]\n[Rejected: {}]", "[Accepted: {}]\n[Rejected: {}]",
api.accepted, api.rejected api.accepted, api.rejected
)), )),
); );
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Pool").underline().color(BONE)), Label::new(RichText::new("Pool").underline().color(BONE)),
) )
.on_hover_text(STATUS_XMRIG_PROXY_POOL); .on_hover_text(STATUS_XMRIG_PROXY_POOL);
ui.add_sized(size, Label::new(api.node.to_string())); ui.add_sized(size, Label::new(api.node.to_string()));
drop(api); drop(api);
});
}) })
}); });
} }
@ -359,70 +361,71 @@ fn xmrig(
ui.set_min_height(min_size.y * 34.0); ui.set_min_height(min_size.y * 34.0);
ui.spacing_mut().item_spacing = Vec2::new(2.0, 2.0); ui.spacing_mut().item_spacing = Vec2::new(2.0, 2.0);
debug!("Status Tab | Rendering [XMRig]"); debug!("Status Tab | Rendering [XMRig]");
ui.set_enabled(xmrig_alive); ui.add_enabled_ui(xmrig_alive, |ui| {
// ui.set_min_size(min_size); // ui.set_min_size(min_size);
ui.add_sized( ui.add_sized(
size, size,
Label::new( Label::new(
RichText::new("[XMRig]") RichText::new("[XMRig]")
.color(LIGHT_GRAY) .color(LIGHT_GRAY)
.text_style(TextStyle::Name("MonospaceLarge".into())), .text_style(TextStyle::Name("MonospaceLarge".into())),
), ),
) )
.on_hover_text("XMRig is online") .on_hover_text("XMRig is online")
.on_disabled_hover_text("XMRig is offline"); .on_disabled_hover_text("XMRig is offline");
let api = lock!(xmrig_api); let api = lock!(xmrig_api);
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Uptime").underline().color(BONE)), Label::new(RichText::new("Uptime").underline().color(BONE)),
) )
.on_hover_text(STATUS_XMRIG_UPTIME); .on_hover_text(STATUS_XMRIG_UPTIME);
ui.add_sized(size, Label::new(UptimeFull::from(api.uptime).as_str())); ui.add_sized(size, Label::new(UptimeFull::from(api.uptime).as_str()));
ui.add_sized(size, Label::new(api.resources.to_string())); ui.add_sized(size, Label::new(api.resources.to_string()));
ui.add_sized( ui.add_sized(
size, size,
Label::new( Label::new(
RichText::new("Hashrate\n(10s/1m/15m)") RichText::new("Hashrate\n(10s/1m/15m)")
.underline() .underline()
.color(BONE), .color(BONE),
), ),
) )
.on_hover_text(STATUS_XMRIG_HASHRATE); .on_hover_text(STATUS_XMRIG_HASHRATE);
ui.add_sized(size, Label::new(api.hashrate.to_string())); ui.add_sized(size, Label::new(api.hashrate.to_string()));
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Difficulty").underline().color(BONE)), Label::new(RichText::new("Difficulty").underline().color(BONE)),
) )
.on_hover_text(STATUS_XMRIG_DIFFICULTY); .on_hover_text(STATUS_XMRIG_DIFFICULTY);
ui.add_sized(size, Label::new(api.diff.to_string())); ui.add_sized(size, Label::new(api.diff.to_string()));
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Shares").underline().color(BONE)), Label::new(RichText::new("Shares").underline().color(BONE)),
) )
.on_hover_text(STATUS_XMRIG_SHARES); .on_hover_text(STATUS_XMRIG_SHARES);
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"[Accepted: {}]\n[Rejected: {}]", "[Accepted: {}]\n[Rejected: {}]",
api.accepted, api.rejected api.accepted, api.rejected
)), )),
); );
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Pool").underline().color(BONE)), Label::new(RichText::new("Pool").underline().color(BONE)),
) )
.on_hover_text(STATUS_XMRIG_POOL); .on_hover_text(STATUS_XMRIG_POOL);
ui.add_sized(size, Label::new(api.node.to_string())); ui.add_sized(size, Label::new(api.node.to_string()));
ui.add_sized( ui.add_sized(
size, size,
Label::new(RichText::new("Threads").underline().color(BONE)), Label::new(RichText::new("Threads").underline().color(BONE)),
) )
.on_hover_text(STATUS_XMRIG_THREADS); .on_hover_text(STATUS_XMRIG_THREADS);
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!("{}/{}", &lock!(xmrig_img).threads, max_threads)), Label::new(format!("{}/{}", &lock!(xmrig_img).threads, max_threads)),
); );
drop(api); drop(api);
});
}) })
// }) // })
}); });
@ -437,113 +440,115 @@ fn xvb(ui: &mut Ui, min_size: Vec2, size: Vec2, xvb_alive: bool, xvb_api: &Arc<M
ui.set_min_height(min_size.y * 34.0); ui.set_min_height(min_size.y * 34.0);
ui.vertical(|ui| { ui.vertical(|ui| {
debug!("Status Tab | Rendering [XvB]"); debug!("Status Tab | Rendering [XvB]");
ui.set_enabled(enabled); // for now there is no API ping or /health, so we verify if the field reward_yearly is empty or not. ui.add_enabled_ui(enabled, |ui| {
// ui.set_min_size(min_size); // for now there is no API ping or /health, so we verify if the field reward_yearly is empty or not.
ui.add_sized( // ui.set_min_size(min_size);
size, ui.add_sized(
Label::new( size,
RichText::new("[XvB Raffle]") Label::new(
.color(LIGHT_GRAY) RichText::new("[XvB Raffle]")
.text_style(TextStyle::Name("MonospaceLarge".into())), .color(LIGHT_GRAY)
), .text_style(TextStyle::Name("MonospaceLarge".into())),
) ),
.on_hover_text("XvB API stats") )
.on_disabled_hover_text("No data received from XvB API"); .on_hover_text("XvB API stats")
// [Round Type] .on_disabled_hover_text("No data received from XvB API");
ui.add_sized( // [Round Type]
size, ui.add_sized(
Label::new(RichText::new("Round Type").underline().color(BONE)), size,
) Label::new(RichText::new("Round Type").underline().color(BONE)),
.on_hover_text(STATUS_XVB_ROUND_TYPE); )
ui.add_sized(size, Label::new(api.round_type.to_string())); .on_hover_text(STATUS_XVB_ROUND_TYPE);
// [Time Remaining] ui.add_sized(size, Label::new(api.round_type.to_string()));
ui.add_sized( // [Time Remaining]
size, ui.add_sized(
Label::new( size,
RichText::new("Round Time Remaining") Label::new(
.underline() RichText::new("Round Time Remaining")
.color(BONE), .underline()
), .color(BONE),
) ),
.on_hover_text(STATUS_XVB_TIME_REMAIN); )
ui.add_sized(size, Label::new(format!("{} minutes", api.time_remain))); .on_hover_text(STATUS_XVB_TIME_REMAIN);
// Donated Hashrate ui.add_sized(size, Label::new(format!("{} minutes", api.time_remain)));
ui.add_sized( // Donated Hashrate
size, ui.add_sized(
Label::new(RichText::new("Bonus Hashrate").underline().color(BONE)), size,
) Label::new(RichText::new("Bonus Hashrate").underline().color(BONE)),
.on_hover_text(STATUS_XVB_DONATED_HR); )
ui.add_sized( .on_hover_text(STATUS_XVB_DONATED_HR);
size,
Label::new(format!(
"{}kH/s\n+\n{}kH/s\ndonated by\n{} donors\n with\n{} miners",
api.bonus_hr, api.donate_hr, api.donate_miners, api.donate_workers
)),
);
// Players
ui.add_sized(
size,
Label::new(RichText::new("Players").underline().color(BONE)),
)
.on_hover_text(STATUS_XVB_PLAYERS);
ui.add_sized(
size,
Label::new(format!(
"[Registered: {}]\n[Playing: {}]",
api.players, api.players_round
)),
);
// Winner
ui.add_sized(
size,
Label::new(RichText::new("Winner").underline().color(BONE)),
)
.on_hover_text(STATUS_XVB_WINNER);
ui.add_sized(size, Label::new(&api.winner));
// Share effort
ui.add_sized(
size,
Label::new(RichText::new("Share Effort").underline().color(BONE)),
)
.on_hover_text(STATUS_XVB_SHARE);
ui.add_sized(size, Label::new(api.share_effort.to_string()));
// Block reward
ui.add_sized(
size,
Label::new(RichText::new("Block Reward").underline().color(BONE)),
)
.on_hover_text(STATUS_XVB_BLOCK_REWARD);
ui.add_sized(size, Label::new(api.block_reward.to_string()));
// reward yearly
ui.add_sized(
size,
Label::new(
RichText::new("Est. Reward (Yearly)")
.underline()
.color(BONE),
),
)
.on_hover_text(STATUS_XVB_YEARLY);
if api.reward_yearly.is_empty() {
ui.add_sized(size, Label::new("No information".to_string()));
} else {
ui.add_sized( ui.add_sized(
size, size,
Label::new(format!( Label::new(format!(
"{}: {} XMR\n{}: {} XMR\n{}: {} XMR\n{}: {} XMR\n{}: {} XMR", "{}kH/s\n+\n{}kH/s\ndonated by\n{} donors\n with\n{} miners",
XvbRound::Vip, api.bonus_hr, api.donate_hr, api.donate_miners, api.donate_workers
api.reward_yearly[0],
XvbRound::Donor,
api.reward_yearly[1],
XvbRound::DonorVip,
api.reward_yearly[2],
XvbRound::DonorWhale,
api.reward_yearly[3],
XvbRound::DonorMega,
api.reward_yearly[4]
)), )),
); );
} // Players
ui.add_sized(
size,
Label::new(RichText::new("Players").underline().color(BONE)),
)
.on_hover_text(STATUS_XVB_PLAYERS);
ui.add_sized(
size,
Label::new(format!(
"[Registered: {}]\n[Playing: {}]",
api.players, api.players_round
)),
);
// Winner
ui.add_sized(
size,
Label::new(RichText::new("Winner").underline().color(BONE)),
)
.on_hover_text(STATUS_XVB_WINNER);
ui.add_sized(size, Label::new(&api.winner));
// Share effort
ui.add_sized(
size,
Label::new(RichText::new("Share Effort").underline().color(BONE)),
)
.on_hover_text(STATUS_XVB_SHARE);
ui.add_sized(size, Label::new(api.share_effort.to_string()));
// Block reward
ui.add_sized(
size,
Label::new(RichText::new("Block Reward").underline().color(BONE)),
)
.on_hover_text(STATUS_XVB_BLOCK_REWARD);
ui.add_sized(size, Label::new(api.block_reward.to_string()));
// reward yearly
ui.add_sized(
size,
Label::new(
RichText::new("Est. Reward (Yearly)")
.underline()
.color(BONE),
),
)
.on_hover_text(STATUS_XVB_YEARLY);
if api.reward_yearly.is_empty() {
ui.add_sized(size, Label::new("No information".to_string()));
} else {
ui.add_sized(
size,
Label::new(format!(
"{}: {} XMR\n{}: {} XMR\n{}: {} XMR\n{}: {} XMR\n{}: {} XMR",
XvbRound::Vip,
api.reward_yearly[0],
XvbRound::Donor,
api.reward_yearly[1],
XvbRound::DonorVip,
api.reward_yearly[2],
XvbRound::DonorWhale,
api.reward_yearly[3],
XvbRound::DonorMega,
api.reward_yearly[4]
)),
);
}
});
}) })
// by round // by round
}); });

View file

@ -119,7 +119,8 @@ impl Xmrig {
self.arguments.truncate(1024); self.arguments.truncate(1024);
}) })
}); });
ui.set_enabled(self.arguments.is_empty()); ui.add_enabled_ui(self.arguments.is_empty(), |ui|{
//---------------------------------------------------------------------------------------------------- Address //---------------------------------------------------------------------------------------------------- Address
debug!("XMRig Tab | Rendering [Address]"); debug!("XMRig Tab | Rendering [Address]");
ui.group(|ui| { ui.group(|ui| {
@ -149,6 +150,7 @@ impl Xmrig {
.on_hover_text(XMRIG_ADDRESS); .on_hover_text(XMRIG_ADDRESS);
self.address.truncate(95); self.address.truncate(95);
}); });
});
} }
//---------------------------------------------------------------------------------------------------- Threads //---------------------------------------------------------------------------------------------------- Threads
@ -321,7 +323,7 @@ impl Xmrig {
let text = format!("{}\n Currently selected pool: {}. {}\n Current amount of pools: {}/1000", text, self.selected_index+1, self.selected_name, pool_vec_len); let text = format!("{}\n Currently selected pool: {}. {}\n Current amount of pools: {}/1000", text, self.selected_index+1, self.selected_name, pool_vec_len);
// If the pool already exists, show [Save] and mutate the already existing pool // If the pool already exists, show [Save] and mutate the already existing pool
if exists { if exists {
ui.set_enabled(!incorrect_input && save_diff); ui.add_enabled_ui(!incorrect_input && save_diff, |ui|{
if ui.add_sized([width, text_edit], Button::new("Save")).on_hover_text(text).clicked() { if ui.add_sized([width, text_edit], Button::new("Save")).on_hover_text(text).clicked() {
let pool = Pool { let pool = Pool {
rig: self.rig.clone(), rig: self.rig.clone(),
@ -335,9 +337,10 @@ impl Xmrig {
self.selected_port.clone_from(&self.port); self.selected_port.clone_from(&self.port);
info!("Node | S | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", existing_index+1, self.name, self.ip, self.port, self.rig); info!("Node | S | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", existing_index+1, self.name, self.ip, self.port, self.rig);
} }
});
// Else, add to the list // Else, add to the list
} else { } else {
ui.set_enabled(!incorrect_input && pool_vec_len < 1000); ui.add_enabled_ui(!incorrect_input && pool_vec_len < 1000, |ui|{
if ui.add_sized([width, text_edit], Button::new("Add")).on_hover_text(text).clicked() { if ui.add_sized([width, text_edit], Button::new("Add")).on_hover_text(text).clicked() {
let pool = Pool { let pool = Pool {
rig: self.rig.clone(), rig: self.rig.clone(),
@ -352,12 +355,13 @@ impl Xmrig {
self.selected_port.clone_from(&self.port); self.selected_port.clone_from(&self.port);
info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", pool_vec_len, self.name, self.ip, self.port, self.rig); info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", pool_vec_len, self.name, self.ip, self.port, self.rig);
} }
});
} }
}); });
// [Delete] // [Delete]
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.set_enabled(pool_vec_len > 1); ui.add_enabled_ui(pool_vec_len > 1, |ui|{
let text = format!("{}\n Currently selected pool: {}. {}\n Current amount of pools: {}/1000", LIST_DELETE, self.selected_index+1, self.selected_name, pool_vec_len); let text = format!("{}\n Currently selected pool: {}. {}\n Current amount of pools: {}/1000", LIST_DELETE, self.selected_index+1, self.selected_name, pool_vec_len);
if ui.add_sized([width, text_edit], Button::new("Delete")).on_hover_text(text).clicked() { if ui.add_sized([width, text_edit], Button::new("Delete")).on_hover_text(text).clicked() {
let new_name; let new_name;
let new_pool; let new_pool;
@ -383,16 +387,19 @@ impl Xmrig {
self.ip = new_pool.ip; self.ip = new_pool.ip;
self.port = new_pool.port; self.port = new_pool.port;
info!("Node | D | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig\"{}\"]", self.selected_index, self.selected_name, self.selected_ip, self.selected_port, self.selected_rig); info!("Node | D | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig\"{}\"]", self.selected_index, self.selected_name, self.selected_ip, self.selected_port, self.selected_rig);
} }
});
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.set_enabled(!self.name.is_empty() || !self.ip.is_empty() || !self.port.is_empty()); ui.add_enabled_ui(!self.name.is_empty() || !self.ip.is_empty() || !self.port.is_empty(), |ui|{
if ui.add_sized([width, text_edit], Button::new("Clear")).on_hover_text(LIST_CLEAR).clicked() { if ui.add_sized([width, text_edit], Button::new("Clear")).on_hover_text(LIST_CLEAR).clicked() {
self.name.clear(); self.name.clear();
self.rig.clear(); self.rig.clear();
self.ip.clear(); self.ip.clear();
self.port.clear(); self.port.clear();
} }
});
}); });
}); });
}); });

View file

@ -109,7 +109,9 @@ impl XmrigProxy {
self.arguments.truncate(1024); self.arguments.truncate(1024);
}) })
}); });
ui.set_enabled(self.arguments.is_empty()); if !self.arguments.is_empty() {
ui.disable();
}
ui.add_space(space_h); ui.add_space(space_h);
ui.style_mut().spacing.icon_width_inner = width / 45.0; ui.style_mut().spacing.icon_width_inner = width / 45.0;
ui.style_mut().spacing.icon_width = width / 35.0; ui.style_mut().spacing.icon_width = width / 35.0;
@ -262,7 +264,7 @@ impl XmrigProxy {
let text = format!("{}\n Currently selected pool: {}. {}\n Current amount of pools: {}/1000", text, self.selected_index+1, self.selected_name, pool_vec_len); let text = format!("{}\n Currently selected pool: {}. {}\n Current amount of pools: {}/1000", text, self.selected_index+1, self.selected_name, pool_vec_len);
// If the pool already exists, show [Save] and mutate the already existing pool // If the pool already exists, show [Save] and mutate the already existing pool
if exists { if exists {
ui.set_enabled(!incorrect_input && save_diff); ui.add_enabled_ui(!incorrect_input && save_diff, |ui|{
if ui.add_sized([width, text_edit], Button::new("Save")).on_hover_text(text).clicked() { if ui.add_sized([width, text_edit], Button::new("Save")).on_hover_text(text).clicked() {
let pool = Pool { let pool = Pool {
rig: self.rig.clone(), rig: self.rig.clone(),
@ -276,9 +278,11 @@ impl XmrigProxy {
self.selected_port.clone_from(&self.p2pool_port); self.selected_port.clone_from(&self.p2pool_port);
info!("Node | S | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", existing_index+1, self.name, self.p2pool_ip, self.p2pool_port, self.rig); info!("Node | S | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", existing_index+1, self.name, self.p2pool_ip, self.p2pool_port, self.rig);
} }
});
// Else, add to the list // Else, add to the list
} else { } else {
ui.set_enabled(!incorrect_input && pool_vec_len < 1000); ui.add_enabled_ui(!incorrect_input && pool_vec_len < 1000, |ui|{
if ui.add_sized([width, text_edit], Button::new("Add")).on_hover_text(text).clicked() { if ui.add_sized([width, text_edit], Button::new("Add")).on_hover_text(text).clicked() {
let pool = Pool { let pool = Pool {
rig: self.rig.clone(), rig: self.rig.clone(),
@ -293,11 +297,13 @@ impl XmrigProxy {
self.selected_port.clone_from(&self.p2pool_port); self.selected_port.clone_from(&self.p2pool_port);
info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", pool_vec_len, self.name, self.p2pool_ip, self.p2pool_port, self.rig); info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", pool_vec_len, self.name, self.p2pool_ip, self.p2pool_port, self.rig);
} }
});
} }
}); });
// [Delete] // [Delete]
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.set_enabled(pool_vec_len > 1); ui.add_enabled_ui(pool_vec_len > 1, |ui|{
let text = format!("{}\n Currently selected pool: {}. {}\n Current amount of pools: {}/1000", LIST_DELETE, self.selected_index+1, self.selected_name, pool_vec_len); let text = format!("{}\n Currently selected pool: {}. {}\n Current amount of pools: {}/1000", LIST_DELETE, self.selected_index+1, self.selected_name, pool_vec_len);
if ui.add_sized([width, text_edit], Button::new("Delete")).on_hover_text(text).clicked() { if ui.add_sized([width, text_edit], Button::new("Delete")).on_hover_text(text).clicked() {
let new_name; let new_name;
@ -325,15 +331,17 @@ impl XmrigProxy {
self.p2pool_port = new_pool.port; self.p2pool_port = new_pool.port;
info!("Node | D | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig\"{}\"]", self.selected_index, self.selected_name, self.selected_ip, self.selected_port, self.selected_rig); info!("Node | D | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig\"{}\"]", self.selected_index, self.selected_name, self.selected_ip, self.selected_port, self.selected_rig);
} }
});
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.set_enabled(!self.name.is_empty() || !self.p2pool_ip.is_empty() || !self.p2pool_port.is_empty()); ui.add_enabled_ui(!self.name.is_empty() || !self.p2pool_ip.is_empty() || !self.p2pool_port.is_empty(), |ui|{
if ui.add_sized([width, text_edit], Button::new("Clear")).on_hover_text(LIST_CLEAR).clicked() { if ui.add_sized([width, text_edit], Button::new("Clear")).on_hover_text(LIST_CLEAR).clicked() {
self.name.clear(); self.name.clear();
self.rig.clear(); self.rig.clear();
self.p2pool_ip.clear(); self.p2pool_ip.clear();
self.p2pool_port.clear(); self.p2pool_port.clear();
} }
});
}); });
}); });
}); });

View file

@ -281,7 +281,7 @@ impl crate::app::App {
let hide = sudo.hide; let hide = sudo.hide;
if sudo.testing { if sudo.testing {
ui.add_sized([width, height], Spinner::new().size(height)); ui.add_sized([width, height], Spinner::new().size(height));
ui.set_enabled(false); ui.disable()
} else { } else {
ui.add_sized([width, height], Label::new(&sudo.msg)); ui.add_sized([width, height], Label::new(&sudo.msg));
} }

View file

@ -512,7 +512,10 @@ impl Helper {
// 2. Selectively refresh [sysinfo] for only what we need (better performance). // 2. Selectively refresh [sysinfo] for only what we need (better performance).
sysinfo.refresh_cpu_specifics(sysinfo_cpu); sysinfo.refresh_cpu_specifics(sysinfo_cpu);
debug!("Helper | Sysinfo refresh (1/3) ... [cpu]"); debug!("Helper | Sysinfo refresh (1/3) ... [cpu]");
sysinfo.refresh_processes_specifics(sysinfo_processes); sysinfo.refresh_processes_specifics(
sysinfo::ProcessesToUpdate::All,
sysinfo_processes,
);
debug!("Helper | Sysinfo refresh (2/3) ... [processes]"); debug!("Helper | Sysinfo refresh (2/3) ... [processes]");
sysinfo.refresh_memory(); sysinfo.refresh_memory();
debug!("Helper | Sysinfo refresh (3/3) ... [memory]"); debug!("Helper | Sysinfo refresh (3/3) ... [memory]");

View file

@ -18,14 +18,14 @@ use crate::{
use super::PubXvbApi; use super::PubXvbApi;
#[derive(Copy, Clone, Debug, Default, PartialEq, Display)] #[derive(Copy, Clone, Debug, Default, PartialEq, Display)]
pub enum XvbNode { pub enum XvbNode {
#[display(fmt = "XvB North America Node")] #[display("XvB North America Node")]
NorthAmerica, NorthAmerica,
#[default] #[default]
#[display(fmt = "XvB European Node")] #[display("XvB European Node")]
Europe, Europe,
#[display(fmt = "Local P2pool")] #[display("Local P2pool")]
P2pool, P2pool,
#[display(fmt = "Xmrig Proxy")] #[display("Xmrig Proxy")]
XmrigProxy, XmrigProxy,
} }
impl XvbNode { impl XvbNode {

View file

@ -12,18 +12,18 @@ use super::PubXvbApi;
#[derive(Debug, Clone, Default, Display, Deserialize, PartialEq)] #[derive(Debug, Clone, Default, Display, Deserialize, PartialEq)]
pub enum XvbRound { pub enum XvbRound {
#[default] #[default]
#[display(fmt = "VIP")] #[display("VIP")]
#[serde(alias = "vip")] #[serde(alias = "vip")]
Vip, Vip,
#[serde(alias = "donor")] #[serde(alias = "donor")]
Donor, Donor,
#[display(fmt = "VIP Donor")] #[display("VIP Donor")]
#[serde(alias = "donor_vip")] #[serde(alias = "donor_vip")]
DonorVip, DonorVip,
#[display(fmt = "Whale Donor")] #[display("Whale Donor")]
#[serde(alias = "donor_whale")] #[serde(alias = "donor_whale")]
DonorWhale, DonorWhale,
#[display(fmt = "Mega Donor")] #[display("Mega Donor")]
#[serde(alias = "donor_mega")] #[serde(alias = "donor_mega")]
DonorMega, DonorMega,
} }

View file

@ -125,8 +125,6 @@ pub fn init_options(initial_window_size: Option<Vec2>) -> NativeOptions {
options.viewport.min_inner_size = Some(Vec2::new(APP_MIN_WIDTH, APP_MIN_HEIGHT)); options.viewport.min_inner_size = Some(Vec2::new(APP_MIN_WIDTH, APP_MIN_HEIGHT));
options.viewport.max_inner_size = Some(Vec2::new(APP_MAX_WIDTH, APP_MAX_HEIGHT)); options.viewport.max_inner_size = Some(Vec2::new(APP_MAX_WIDTH, APP_MAX_HEIGHT));
options.viewport.inner_size = initial_window_size; options.viewport.inner_size = initial_window_size;
options.follow_system_theme = false;
options.default_theme = eframe::Theme::Dark;
let icon = image::load_from_memory(BYTES_ICON) let icon = image::load_from_memory(BYTES_ICON)
.expect("Failed to read icon bytes") .expect("Failed to read icon bytes")
.to_rgba8(); .to_rgba8();

View file

@ -20,10 +20,10 @@
// Only (windows|macos|linux) + (x64|arm64) are supported. // Only (windows|macos|linux) + (x64|arm64) are supported.
#[cfg(not(target_pointer_width = "64"))] #[cfg(not(target_pointer_width = "64"))]
compile_error!("gupax is only compatible with 64-bit CPUs"); compile_error!("gupaxx is only compatible with 64-bit CPUs");
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux",)))] #[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux",)))]
compile_error!("gupax is only built for windows/macos/linux"); compile_error!("gupaxx is only built for windows/macos/linux");
use crate::app::App; use crate::app::App;
use crate::cli::Cli; use crate::cli::Cli;
@ -96,7 +96,7 @@ fn main() {
options, options,
Box::new(move |cc| { Box::new(move |cc| {
egui_extras::install_image_loaders(&cc.egui_ctx); egui_extras::install_image_loaders(&cc.egui_ctx);
Box::new(App::cc(cc, resolution, app)) Ok(Box::new(App::cc(cc, resolution, app)))
}), }),
) )
.unwrap(); .unwrap();