mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-01-20 20:54:30 +00:00
fix: fix simple & advanced tab UI & modify tests
This commit is contained in:
parent
dbbbcc3d15
commit
8a8904083e
4 changed files with 79 additions and 68 deletions
|
@ -510,6 +510,32 @@ impl crate::app::App {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn xvb_submenu(&mut self, ui: &mut Ui, size: Vec2) {
|
||||||
|
ui.group(|ui| {
|
||||||
|
let width = size.x / 1.5;
|
||||||
|
let size = vec2(width, size.y);
|
||||||
|
if ui
|
||||||
|
.add_sized(
|
||||||
|
size,
|
||||||
|
SelectableLabel::new(!self.state.xvb.simple, "Advanced"),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
self.state.xvb.simple = false;
|
||||||
|
}
|
||||||
|
ui.separator();
|
||||||
|
if ui
|
||||||
|
.add_sized(
|
||||||
|
size,
|
||||||
|
SelectableLabel::new(self.state.xvb.simple, "Simple"),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
self.state.xvb.simple = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
fn xvb_run_actions(
|
fn xvb_run_actions(
|
||||||
&mut self,
|
&mut self,
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
|
@ -588,31 +614,6 @@ impl crate::app::App {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn xvb_submenu(&mut self, ui: &mut Ui, size: Vec2) {
|
|
||||||
ui.group(|ui| {
|
|
||||||
let width = size.x / 1.5;
|
|
||||||
let size = vec2(width, size.y);
|
|
||||||
if ui
|
|
||||||
.add_sized(
|
|
||||||
size,
|
|
||||||
SelectableLabel::new(!self.state.xvb.simple, "Advanced"),
|
|
||||||
)
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
self.state.xvb.simple = false;
|
|
||||||
}
|
|
||||||
ui.separator();
|
|
||||||
if ui
|
|
||||||
.add_sized(
|
|
||||||
size,
|
|
||||||
SelectableLabel::new(self.state.xvb.simple, "Simple"),
|
|
||||||
)
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
self.state.xvb.simple = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn status_p2pool(state: ProcessState, ui: &mut Ui, size: Vec2) {
|
fn status_p2pool(state: ProcessState, ui: &mut Ui, size: Vec2) {
|
||||||
|
|
|
@ -3,10 +3,12 @@ use std::sync::{Arc, Mutex};
|
||||||
use egui::TextStyle::{self, Name};
|
use egui::TextStyle::{self, Name};
|
||||||
use egui::{vec2, Image, RichText, TextEdit, Ui, Vec2};
|
use egui::{vec2, Image, RichText, TextEdit, Ui, Vec2};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
use log::error;
|
||||||
use readable::num::Float;
|
use readable::num::Float;
|
||||||
use readable::up::Uptime;
|
use readable::up::Uptime;
|
||||||
|
|
||||||
use crate::disk::state::XvbMode;
|
use crate::disk::state::XvbMode;
|
||||||
|
use crate::helper::xvb::priv_stats::RuntimeMode;
|
||||||
use crate::helper::xvb::PubXvbApi;
|
use crate::helper::xvb::PubXvbApi;
|
||||||
use crate::regex::num_lines;
|
use crate::regex::num_lines;
|
||||||
use crate::utils::constants::{
|
use crate::utils::constants::{
|
||||||
|
@ -37,19 +39,19 @@ impl crate::disk::state::Xvb {
|
||||||
let width = size.x;
|
let width = size.x;
|
||||||
let height = size.y;
|
let height = size.y;
|
||||||
let space_h = height / 48.0;
|
let space_h = height / 48.0;
|
||||||
// if self.simple {
|
|
||||||
// // logo and website link
|
// logo and website link
|
||||||
// ui.vertical_centered(|ui| {
|
ui.vertical_centered(|ui| {
|
||||||
// ui.add_sized(
|
ui.add_sized(
|
||||||
// [width, website_height],
|
[width, website_height],
|
||||||
// Image::from_bytes("bytes:/xvb.png", BYTES_XVB),
|
Image::from_bytes("bytes:/xvb.png", BYTES_XVB),
|
||||||
// );
|
);
|
||||||
// ui.style_mut().override_text_style = Some(TextStyle::Heading);
|
ui.style_mut().override_text_style = Some(TextStyle::Heading);
|
||||||
// ui.add_space(space_h);
|
ui.add_space(space_h);
|
||||||
// ui.hyperlink_to("XMRvsBeast", XVB_URL);
|
ui.hyperlink_to("XMRvsBeast", XVB_URL);
|
||||||
// ui.add_space(space_h);
|
ui.add_space(space_h);
|
||||||
// });
|
});
|
||||||
// }
|
|
||||||
// console output for log
|
// console output for log
|
||||||
debug!("XvB Tab | Rendering [Console]");
|
debug!("XvB Tab | Rendering [Console]");
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
|
@ -121,22 +123,18 @@ impl crate::disk::state::Xvb {
|
||||||
|
|
||||||
// --------------------------- XVB Simple -------------------------------------------
|
// --------------------------- XVB Simple -------------------------------------------
|
||||||
if self.simple {
|
if self.simple {
|
||||||
ui.group(|ui| {
|
|
||||||
ui.vertical_centered(|ui| {
|
if ui.checkbox(&mut self.simple_hero_mode, "Hero Mode").on_hover_text(XVB_HERO_SELECT).clicked() {
|
||||||
ui.horizontal(|ui| {
|
// also change hero mode of runtime.
|
||||||
egui::ComboBox::from_label("")
|
lock!(api).stats_priv.runtime_mode = RuntimeMode::Hero;
|
||||||
.selected_text(format!("{:?}", self.mode))
|
} else {
|
||||||
.show_ui(ui, |ui| {
|
lock!(api).stats_priv.runtime_mode = RuntimeMode::Auto;
|
||||||
ui.selectable_value(&mut self.mode, XvbMode::Auto, "Automatic");
|
}
|
||||||
ui.selectable_value(&mut self.mode, XvbMode::Hero, "Hero Mode");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------- XVB Advanced -----------------------------------------
|
// --------------------------- XVB Advanced -----------------------------------------
|
||||||
if !self.simple {
|
if !self.simple {
|
||||||
|
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
ui.vertical_centered(|ui| {
|
ui.vertical_centered(|ui| {
|
||||||
|
@ -178,13 +176,24 @@ impl crate::disk::state::Xvb {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set runtime_mode & runtime_manual_amount
|
||||||
|
lock!(api).stats_priv.runtime_mode = self.mode.clone().into();
|
||||||
|
lock!(api).stats_priv.runtime_manual_amount = match self.amount.parse() {
|
||||||
|
Ok(n) => n,
|
||||||
|
Err(e) => {
|
||||||
|
error!("Error parsing int {}", e);
|
||||||
|
lock!(api).stats_priv.runtime_mode = RuntimeMode::Auto;
|
||||||
|
0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// need to warn the user if no address is set in p2pool tab
|
// need to warn the user if no address is set in p2pool tab
|
||||||
if !Regexes::addr_ok(address) {
|
if !Regexes::addr_ok(address) {
|
||||||
ui.add_space(width / 16.0);
|
ui.add_space(width / 16.0);
|
||||||
debug!("XvB Tab | Rendering warning text");
|
debug!("XvB Tab | Rendering warning text");
|
||||||
|
|
|
@ -255,6 +255,7 @@ pub enum XvbMode {
|
||||||
pub struct Xvb {
|
pub struct Xvb {
|
||||||
pub simple: bool,
|
pub simple: bool,
|
||||||
pub token: String,
|
pub token: String,
|
||||||
|
pub simple_hero_mode: bool,
|
||||||
pub mode: XvbMode,
|
pub mode: XvbMode,
|
||||||
pub amount: String
|
pub amount: String
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ mod test {
|
||||||
|
|
||||||
use crate::helper::{
|
use crate::helper::{
|
||||||
p2pool::{PrivP2poolLocalApi, PrivP2poolNetworkApi},
|
p2pool::{PrivP2poolLocalApi, PrivP2poolNetworkApi},
|
||||||
xvb::{algorithm::calcul_donated_time, rounds::round_type},
|
xvb::{algorithm::calcul_donated_time, priv_stats::RuntimeMode, rounds::round_type},
|
||||||
Helper, Process, ProcessName, ProcessState,
|
Helper, Process, ProcessName, ProcessState,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ Uptime = 0h 2m 4s
|
||||||
// 15mn average HR of xmrig is 5kH/s
|
// 15mn average HR of xmrig is 5kH/s
|
||||||
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m = 5000.0;
|
lock!(gui_api_xmrig).hashrate_raw_15m = 5000.0;
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = false;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Auto;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -559,7 +559,7 @@ Uptime = 0h 2m 4s
|
||||||
/ 1000.0;
|
/ 1000.0;
|
||||||
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::Vip));
|
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::Vip));
|
||||||
// verify that hero mode will give x seconds
|
// verify that hero mode will give x seconds
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = true;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Hero;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -578,7 +578,7 @@ Uptime = 0h 2m 4s
|
||||||
// verify that if one share and not enough for donor vip round (should be in donor round), right amount of time will be given to xvb for default and hero mode
|
// verify that if one share and not enough for donor vip round (should be in donor round), right amount of time will be given to xvb for default and hero mode
|
||||||
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m = 8000.0;
|
lock!(gui_api_xmrig).hashrate_raw_15m = 8000.0;
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = false;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Auto;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -598,7 +598,7 @@ Uptime = 0h 2m 4s
|
||||||
/ 1000.0;
|
/ 1000.0;
|
||||||
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::Donor));
|
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::Donor));
|
||||||
// verify that hero mode will give x seconds
|
// verify that hero mode will give x seconds
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = true;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Hero;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -617,7 +617,7 @@ Uptime = 0h 2m 4s
|
||||||
// verify that if one share and not enough for donor whale round(should be in donor vip), right amount of time will be given to xvb for default and hero mode
|
// verify that if one share and not enough for donor whale round(should be in donor vip), right amount of time will be given to xvb for default and hero mode
|
||||||
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m = 19000.0;
|
lock!(gui_api_xmrig).hashrate_raw_15m = 19000.0;
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = false;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Auto;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -637,7 +637,7 @@ Uptime = 0h 2m 4s
|
||||||
/ 1000.0;
|
/ 1000.0;
|
||||||
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorVip));
|
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorVip));
|
||||||
// verify that hero mode will give x seconds
|
// verify that hero mode will give x seconds
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = true;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Hero;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -656,7 +656,7 @@ Uptime = 0h 2m 4s
|
||||||
// verify that if one share and not enough for donor mega round, right amount of time will be given to xvb for default and hero mode
|
// verify that if one share and not enough for donor mega round, right amount of time will be given to xvb for default and hero mode
|
||||||
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m = 105000.0;
|
lock!(gui_api_xmrig).hashrate_raw_15m = 105000.0;
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = false;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Auto;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -676,7 +676,7 @@ Uptime = 0h 2m 4s
|
||||||
/ 1000.0;
|
/ 1000.0;
|
||||||
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorWhale));
|
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorWhale));
|
||||||
// verify that hero mode will give x seconds
|
// verify that hero mode will give x seconds
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = true;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Hero;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -695,7 +695,7 @@ Uptime = 0h 2m 4s
|
||||||
// verify that if one share and enough for donor mega round, right amount of time will be given to xvb for default and hero mode
|
// verify that if one share and enough for donor mega round, right amount of time will be given to xvb for default and hero mode
|
||||||
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 0.0;
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m = 1205000.0;
|
lock!(gui_api_xmrig).hashrate_raw_15m = 1205000.0;
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = false;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Auto;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -715,7 +715,7 @@ Uptime = 0h 2m 4s
|
||||||
/ 1000.0;
|
/ 1000.0;
|
||||||
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorMega));
|
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorMega));
|
||||||
// verify that hero mode will give x seconds
|
// verify that hero mode will give x seconds
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = true;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Hero;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -735,7 +735,7 @@ Uptime = 0h 2m 4s
|
||||||
lock!(gui_api_xvb).output.clear();
|
lock!(gui_api_xvb).output.clear();
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m = 12500.0;
|
lock!(gui_api_xmrig).hashrate_raw_15m = 12500.0;
|
||||||
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 5.0;
|
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 5.0;
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = false;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Auto;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
@ -758,7 +758,7 @@ Uptime = 0h 2m 4s
|
||||||
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorVip));
|
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorVip));
|
||||||
// verify that hero mode will give x seconds
|
// verify that hero mode will give x seconds
|
||||||
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 5.0;
|
lock!(gui_api_xvb).stats_priv.donor_1hr_avg = 5.0;
|
||||||
lock!(gui_api_xvb).stats_priv.runtime_hero_mode = true;
|
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::Hero;
|
||||||
let given_time = calcul_donated_time(
|
let given_time = calcul_donated_time(
|
||||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||||
&gui_api_p2pool,
|
&gui_api_p2pool,
|
||||||
|
|
Loading…
Reference in a new issue