From b10a2978f6903d756104e19907f1b92389ed9204 Mon Sep 17 00:00:00 2001 From: SpiralP Date: Sun, 19 Apr 2020 17:04:26 -0700 Subject: [PATCH] colors! --- Cargo.lock | 13 ++++++------- src/cef_binary_updater.rs | 13 +++++++++++-- src/github_release_checker.rs | 28 +++++++++++++++++++++++----- src/loader.rs | 7 ++++++- src/plugin_updater.rs | 7 ++++++- 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 137d356..61eca2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -190,7 +190,7 @@ dependencies = [ [[package]] name = "classicube-cef-loader-plugin" -version = "0.3.2" +version = "0.4.0" dependencies = [ "async-dispatcher 0.1.0 (git+https://github.com/SpiralP/rust-async-dispatcher.git)", "bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -212,7 +212,7 @@ dependencies = [ [[package]] name = "classicube-helpers" version = "0.1.0" -source = "git+https://github.com/SpiralP/rust-classicube-helpers.git#ab040c4f1f76b27447613586829ceea774b084fd" +source = "git+https://github.com/SpiralP/rust-classicube-helpers.git#47c670c73af2f2aac36d1834a6ce1e6f9a46aa72" dependencies = [ "classicube-sys 0.1.0 (git+https://github.com/SpiralP/rust-classicube-sys.git)", "detour 0.7.1 (git+https://github.com/SpiralP/detour-rs.git)", @@ -540,7 +540,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1024,7 +1024,7 @@ dependencies = [ "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1223,11 +1223,10 @@ dependencies = [ [[package]] name = "time" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1666,7 +1665,7 @@ dependencies = [ "checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +"checksum time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" "checksum tokio 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "34ef16d072d2b6dc8b4a56c70f5c5ced1a37752116f8e7c1e80c659aa7cb6713" "checksum tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" "checksum tokio-macros 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" diff --git a/src/cef_binary_updater.rs b/src/cef_binary_updater.rs index 27cd552..06767bd 100644 --- a/src/cef_binary_updater.rs +++ b/src/cef_binary_updater.rs @@ -1,4 +1,5 @@ use crate::{error::*, print_async}; +use classicube_helpers::color; use futures::stream::TryStreamExt; use log::debug; use std::{ @@ -62,7 +63,15 @@ pub async fn check() -> Result { let current_version = get_current_version().unwrap_or_default(); if current_version != CEF_VERSION { - print_async(format!("Updating cef-binary to {}", CEF_VERSION)).await; + print_async(format!( + "{}Updating {}cef-binary {}to {}{}", + color::PINK, + color::LIME, + color::PINK, + color::GREEN, + CEF_VERSION + )) + .await; fs::create_dir_all(CEF_BINARY_PATH_NEW).unwrap(); download(CEF_VERSION).await?; @@ -73,7 +82,7 @@ pub async fn check() -> Result { write!(f, "{}", CEF_VERSION).unwrap(); } - print_async("cef-binary finished downloading").await; + print_async(format!("{}cef-binary finished downloading", color::LIME,)).await; Ok(true) } else { diff --git a/src/github_release_checker.rs b/src/github_release_checker.rs index 996e50e..9ae75da 100644 --- a/src/github_release_checker.rs +++ b/src/github_release_checker.rs @@ -1,4 +1,5 @@ use crate::{error::*, print_async}; +use classicube_helpers::color; use futures::stream::TryStreamExt; use serde::Deserialize; use std::{ @@ -76,8 +77,12 @@ impl GitHubReleaseChecker { if ¤t_version != release.published_at.as_ref().unwrap() { print_async(format!( - "New release update {} for {}!", + "{}New release update {}{} {}for {}{}!", + color::PINK, + color::GREEN, release.tag_name.as_ref().unwrap(), + color::PINK, + color::LIME, self.name )) .await; @@ -90,7 +95,7 @@ impl GitHubReleaseChecker { write!(f, "{}", release.published_at.as_ref().unwrap()).unwrap(); } - print_async(format!("{} finished downloading", self.name)).await; + print_async(format!("{}{} finished downloading", color::LIME, self.name)).await; Ok(true) } else { @@ -111,9 +116,16 @@ impl GitHubReleaseChecker { .chain_err(|| format!("couldn't find asset {}", asset_name))?; print_async(format!( - "Downloading {} ({}MB)", + "{}Downloading {}{} {}({}{}MB{})", + color::GOLD, + // + color::GREEN, asset.name, - (asset.size as f32 / 1024f32 / 1024f32).ceil() as u32 + color::GOLD, + // + color::GREEN, + (asset.size as f32 / 1024f32 / 1024f32).ceil() as u32, + color::GOLD, )) .await; @@ -146,7 +158,13 @@ impl GitHubReleaseChecker { // rename downloaded to wanted_path fs::rename(&new_path, &wanted_path)?; - print_async(format!("Finished downloading {}", asset.name)).await; + print_async(format!( + "{}Finished downloading {}{}", + color::GOLD, + color::GREEN, + asset.name, + )) + .await; } Ok(()) diff --git a/src/loader.rs b/src/loader.rs index 1d34800..561285e 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -72,7 +72,12 @@ fn try_init() -> Result<()> { pub fn init() { if let Err(e) = try_init() { - print(format!("Couldn't load cef plugin: {}", e)); + print(format!( + "{}Couldn't load cef plugin: {}{}", + classicube_helpers::color::RED, + classicube_helpers::color::WHITE, + e + )); } } diff --git a/src/plugin_updater.rs b/src/plugin_updater.rs index 1fac2fb..3c181f0 100644 --- a/src/plugin_updater.rs +++ b/src/plugin_updater.rs @@ -1,6 +1,7 @@ use crate::{ cef_binary_updater, github_release_checker::GitHubReleaseChecker, print_async, AsyncManager, }; +use classicube_helpers::color; use std::fs; #[cfg(all(target_os = "windows", target_pointer_width = "64"))] @@ -80,7 +81,11 @@ pub fn update_plugins() { } if had_updates { - print_async("Everything done, restart your game to finish the update!").await; + print_async(format!( + "{}Everything done, restart your game to finish the update!", + color::YELLOW + )) + .await; } // AsyncManager::spawn_on_main_thread(async {