fix: change slider metric ui & help text

This commit is contained in:
mostafaei2002 2024-06-12 21:58:36 +03:30
parent 277dd840bd
commit a83600a6e0
3 changed files with 42 additions and 19 deletions

View file

@ -172,6 +172,12 @@ impl crate::disk::state::Xvb {
ui.add_space(space_h);
let default_xmrig_hashrate = match self.manual_donation_metric {
ManualDonationMetric::Hash => 1_000.0,
ManualDonationMetric::Kilo => 1_000_000.0,
ManualDonationMetric::Mega => 1_000_000_000.0
};
let mut hashrate_xmrig = {
if lock!(gui_api_xmrig).hashrate_raw_15m > 0.0 {
lock!(gui_api_xmrig).hashrate_raw_15m
@ -180,7 +186,7 @@ impl crate::disk::state::Xvb {
} else if lock!(gui_api_xmrig).hashrate_raw > 0.0 {
lock!(gui_api_xmrig).hashrate_raw
} else {
1000.0
default_xmrig_hashrate
}
};
// Adjust maximum slider amount based on slider metric
@ -198,24 +204,28 @@ impl crate::disk::state::Xvb {
};
ui.horizontal(|ui| {
ui.spacing_mut().slider_width = width * 0.5;
ui.add_sized(
[width, text_edit],
egui::Slider::new(&mut self.manual_slider_amount, 0.0..=(hashrate_xmrig as f64)).max_decimals(3)
).on_hover_text(slider_help_text);
if ui.add(egui::SelectableLabel::new(self.manual_donation_metric == ManualDonationMetric::Hash, "H/s")).clicked() {
if ui.add(egui::SelectableLabel::new(self.manual_donation_metric == ManualDonationMetric::Hash, "Hash")).clicked() {
self.manual_donation_metric = ManualDonationMetric::Hash;
self.manual_slider_amount = self.manual_amount_raw;
}
if ui.add(egui::SelectableLabel::new(self.manual_donation_metric == ManualDonationMetric::Kilo, "KH/s")).clicked() {
if ui.add(egui::SelectableLabel::new(self.manual_donation_metric == ManualDonationMetric::Kilo, "Kilo")).clicked() {
self.manual_donation_metric = ManualDonationMetric::Kilo;
self.manual_slider_amount = self.manual_amount_raw / 1000.0;
};
if ui.add(egui::SelectableLabel::new(self.manual_donation_metric == ManualDonationMetric::Mega, "MH/s")).clicked() {
if ui.add(egui::SelectableLabel::new(self.manual_donation_metric == ManualDonationMetric::Mega, "Mega")).clicked() {
self.manual_donation_metric = ManualDonationMetric::Mega;
self.manual_slider_amount = self.manual_amount_raw / 1_000_000.0;
};
ui.spacing_mut().slider_width = width * 0.5;
ui.add_sized(
[width, text_edit],
egui::Slider::new(&mut self.manual_slider_amount, 0.0..=(hashrate_xmrig as f64))
.text(self.manual_donation_metric.to_string())
.max_decimals(3)
).on_hover_text(slider_help_text);
});
}

View file

@ -309,6 +309,19 @@ pub enum ManualDonationMetric {
Mega,
}
impl Display for ManualDonationMetric {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let text = match self {
Self::Hash => "H/s",
Self::Kilo => "KH/s",
Self::Mega => "MH/s"
};
write!(f, "{}", text)
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Version {
pub gupax: String,
@ -430,13 +443,13 @@ impl Default for Xvb {
fn default() -> Self {
Self {
simple: true,
token: "".to_string(),
simple_hero_mode: false,
mode: XvbMode::default(),
manual_amount_raw: 0.0,
manual_slider_amount: 0.0,
manual_donation_level: ManualDonationLevel::default(),
manual_donation_metric: ManualDonationMetric::default(),
token: String::with_capacity(9),
simple_hero_mode: Default::default(),
mode: Default::default(),
manual_amount_raw: Default::default(),
manual_slider_amount: Default::default(),
manual_donation_level: Default::default(),
manual_donation_metric: Default::default(),
}
}
}

View file

@ -412,8 +412,8 @@ pub const XMRIG_PATH_EMPTY: &str = "XMRig PATH is empty! To fix: goto the [G
// XvB
pub const XVB_HELP: &str = "You need to register an account by clicking on the link above to get your token with the same p2pool XMR address you use for payment.";
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";
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";
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";
pub const XVB_URL_PUBLIC_API: &str = "https://xmrvsbeast.com/p2pool/stats";