mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 22:59:27 +00:00
feat: add megahash option to slider
This commit is contained in:
parent
9759b5677c
commit
caf3c62227
3 changed files with 31 additions and 23 deletions
|
@ -527,7 +527,7 @@ impl App {
|
|||
// Set saved Hero mode to runtime.
|
||||
debug!("Setting runtime_mode & runtime_manual_amount");
|
||||
app.xvb_api.lock().unwrap().stats_priv.runtime_mode = app.state.xvb.mode.clone().into();
|
||||
app.xvb_api.lock().unwrap().stats_priv.runtime_manual_amount = app.state.xvb.amount;
|
||||
app.xvb_api.lock().unwrap().stats_priv.runtime_manual_amount = app.state.xvb.manual_amount_raw;
|
||||
// Check if [P2pool.node] exists
|
||||
info!("App Init | Checking if saved remote node still exists...");
|
||||
app.state.p2pool.node = RemoteNode::check_exists(&app.state.p2pool.node);
|
||||
|
|
|
@ -168,12 +168,12 @@ impl crate::disk::state::Xvb {
|
|||
ui.add_space(space_h);
|
||||
|
||||
let mut is_slider_enabled = true;
|
||||
let mut hashrate_xmrig = {
|
||||
let hashrate_xmrig = {
|
||||
if lock!(gui_api_xmrig).hashrate_raw_15m > 0.0 {
|
||||
lock!(gui_api_xmrig).hashrate_raw_15m
|
||||
} else if lock!(gui_api_xmrig).hashrate_raw_1m > 0.0 {
|
||||
lock!(gui_api_xmrig).hashrate_raw_1m
|
||||
} else if lock!(gui_api_xmrig).hashrate_raw {
|
||||
} else if lock!(gui_api_xmrig).hashrate_raw > 0.0 {
|
||||
lock!(gui_api_xmrig).hashrate_raw
|
||||
} else {
|
||||
is_slider_enabled = false;
|
||||
|
@ -181,9 +181,6 @@ impl crate::disk::state::Xvb {
|
|||
}
|
||||
};
|
||||
|
||||
if self.manual_donation_metric == ManualDonationMetric::Kilo {
|
||||
hashrate_xmrig /= 1000.0;
|
||||
}
|
||||
|
||||
let slider_help_text = if self.mode == XvbMode::ManualXvb {
|
||||
XVB_MANUAL_SLIDER_MANUAL_XVB_HELP
|
||||
|
@ -196,21 +193,22 @@ impl crate::disk::state::Xvb {
|
|||
ui.spacing_mut().slider_width = width * 0.5;
|
||||
ui.add_sized(
|
||||
[width, text_edit],
|
||||
egui::Slider::new(&mut self.amount, 0.0..=(hashrate_xmrig as f64))
|
||||
egui::Slider::new(&mut self.manual_slider_amount, 0.0..=(hashrate_xmrig as f64))
|
||||
).on_hover_text(slider_help_text);
|
||||
|
||||
if ui.add(egui::SelectableLabel::new(self.manual_donation_metric == ManualDonationMetric::Hash, "H/s")).clicked() &&
|
||||
self.manual_donation_metric != ManualDonationMetric::Hash
|
||||
{
|
||||
self.amount *= 1000.0;
|
||||
if ui.add(egui::SelectableLabel::new(self.manual_donation_metric == ManualDonationMetric::Hash, "H/s")).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() &&
|
||||
self.manual_donation_metric != ManualDonationMetric::Kilo
|
||||
{
|
||||
self.amount /= 1000.0;
|
||||
if ui.add(egui::SelectableLabel::new(self.manual_donation_metric == ManualDonationMetric::Kilo, "kH/s")).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() {
|
||||
self.manual_donation_metric = ManualDonationMetric::Mega;
|
||||
self.manual_slider_amount = self.manual_amount_raw / 1_000_000.0;
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -234,13 +232,21 @@ impl crate::disk::state::Xvb {
|
|||
});
|
||||
});
|
||||
|
||||
match self.manual_donation_metric {
|
||||
ManualDonationMetric::Hash => {
|
||||
self.manual_amount_raw = self.manual_slider_amount;
|
||||
},
|
||||
ManualDonationMetric::Kilo => {
|
||||
self.manual_amount_raw = self.manual_slider_amount * 1000.0;
|
||||
},
|
||||
ManualDonationMetric::Mega => {
|
||||
self.manual_amount_raw = self.manual_slider_amount * 1_000_000.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Set runtime_mode & runtime_manual_amount
|
||||
lock!(api).stats_priv.runtime_mode = self.mode.clone().into();
|
||||
if self.manual_donation_metric == ManualDonationMetric::Hash {
|
||||
lock!(api).stats_priv.runtime_manual_amount = self.amount;
|
||||
} else {
|
||||
lock!(api).stats_priv.runtime_manual_amount = self.amount * 1000.0;
|
||||
}
|
||||
lock!(api).stats_priv.runtime_manual_amount = self.manual_amount_raw;
|
||||
}
|
||||
|
||||
ui.add_space(space_h);
|
||||
|
|
|
@ -249,7 +249,8 @@ pub struct Xvb {
|
|||
pub token: String,
|
||||
pub simple_hero_mode: bool,
|
||||
pub mode: XvbMode,
|
||||
pub amount: f64,
|
||||
pub manual_amount_raw: f64,
|
||||
pub manual_slider_amount: f64,
|
||||
pub manual_donation_level: ManualDonationLevel,
|
||||
pub manual_donation_metric: ManualDonationMetric,
|
||||
}
|
||||
|
@ -258,9 +259,9 @@ pub struct Xvb {
|
|||
pub enum XvbMode {
|
||||
#[default]
|
||||
Auto,
|
||||
Hero,
|
||||
ManualXvb,
|
||||
ManualP2pool,
|
||||
Hero,
|
||||
ManualDonationLevel,
|
||||
}
|
||||
|
||||
|
@ -278,6 +279,7 @@ pub enum ManualDonationMetric {
|
|||
#[default]
|
||||
Hash,
|
||||
Kilo,
|
||||
Mega
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
|
|
Loading…
Reference in a new issue