Skip to content

Commit

Permalink
colors!
Browse files Browse the repository at this point in the history
  • Loading branch information
SpiralP committed Apr 20, 2020
1 parent 8156f53 commit b10a297
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
13 changes: 6 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/cef_binary_updater.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{error::*, print_async};
use classicube_helpers::color;
use futures::stream::TryStreamExt;
use log::debug;
use std::{
Expand Down Expand Up @@ -62,7 +63,15 @@ pub async fn check() -> Result<bool> {
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?;
Expand All @@ -73,7 +82,7 @@ pub async fn check() -> Result<bool> {
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 {
Expand Down
28 changes: 23 additions & 5 deletions src/github_release_checker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{error::*, print_async};
use classicube_helpers::color;
use futures::stream::TryStreamExt;
use serde::Deserialize;
use std::{
Expand Down Expand Up @@ -76,8 +77,12 @@ impl GitHubReleaseChecker {

if &current_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;
Expand All @@ -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 {
Expand All @@ -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;

Expand Down Expand Up @@ -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(())
Expand Down
7 changes: 6 additions & 1 deletion src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/plugin_updater.rs
Original file line number Diff line number Diff line change
@@ -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"))]
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b10a297

Please sign in to comment.