Added more convenient cooldown time formatting.
This commit is contained in:
+13
-2
@@ -423,13 +423,24 @@ fn action_create_domain(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>,
|
|||||||
let _ = web_view.eval("domainMiningUnavailable();");
|
let _ = web_view.eval("domainMiningUnavailable();");
|
||||||
}
|
}
|
||||||
MineResult::Cooldown { time } => {
|
MineResult::Cooldown { time } => {
|
||||||
event_info(web_view, &format!("You have cooldown, just {} more minutes!", time / 60));
|
event_info(web_view, &format!("You have cooldown {}!", format_cooldown(time)));
|
||||||
show_warning(web_view, &format!("You have cooldown, just {} more minutes!", time / 60));
|
show_warning(web_view, &format!("You have cooldown {}!", format_cooldown(time)));
|
||||||
let _ = web_view.eval("domainMiningUnavailable();");
|
let _ = web_view.eval("domainMiningUnavailable();");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn format_cooldown(time: i64) -> String {
|
||||||
|
if time <= 60 {
|
||||||
|
return format!("{} seconds", time);
|
||||||
|
}
|
||||||
|
let minutes = time / 60;
|
||||||
|
if minutes <= 60 {
|
||||||
|
return format!("{} minutes", minutes);
|
||||||
|
}
|
||||||
|
format!("{} hours", minutes / 60)
|
||||||
|
}
|
||||||
|
|
||||||
fn show_warning(web_view: &mut WebView<()>, text: &str) {
|
fn show_warning(web_view: &mut WebView<()>, text: &str) {
|
||||||
let str = text.replace('\'', "\\'");
|
let str = text.replace('\'', "\\'");
|
||||||
match web_view.eval(&format!("showWarning('{}');", &str)) {
|
match web_view.eval(&format!("showWarning('{}');", &str)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user