From 3d1bee87b6d02f711e97f65d7d2e03c2612c24d8 Mon Sep 17 00:00:00 2001 From: Djkato Date: Sun, 29 Jan 2023 17:17:04 +0100 Subject: [PATCH] added HIDE_PORTFOLIO_ROW setting --- .drp_config | 4 ++++ Cargo.lock | 2 +- Cargo.toml | 4 ++-- src/config.rs | 21 ++++++++++++++++++++- src/main.rs | 10 +++++++--- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.drp_config b/.drp_config index 5f88253..c5ff67c 100644 --- a/.drp_config +++ b/.drp_config @@ -8,4 +8,8 @@ djkato.net EXCLUDE_CHARACTERS_LIST:{ no_drp +} + +HIDE_PORTFOLIO_ROW:{ +no } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index aef5332..e1f402c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "DRP_Creative" -version = "0.1.2" +version = "0.1.3" dependencies = [ "discord-rich-presence", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index ece9a3e..3341a04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "DRP_Creative" -version = "0.1.2" +version = "0.1.3" edition = "2021" author = "https://djkato.net" @@ -23,4 +23,4 @@ features = [ ] [target.'cfg(windows)'.build-dependencies] -windres = "0.2.2" \ No newline at end of file +windres = "0.2.2" \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index f1d9d83..23a0ff2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,6 +5,7 @@ pub struct Config { pub exclude_keywords_list: Vec, pub should_exclude_be_invisible: bool, pub portfolio_link: String, + pub hide_portfolio_row: bool, } impl Config { @@ -36,7 +37,7 @@ fn parse_config_file(config_file: &String) -> Config { let mut exclude_keywords_list: Vec = Vec::new(); let mut should_exclude_be_invisible = false; let mut portfolio_link = String::new(); - + let mut hide_portfolio_row = false; for (i, line) in config_file.lines().enumerate() { if line.contains("SHOULD_EXCLUDE_BE_ANONYMOUS:") { match config_file @@ -45,6 +46,7 @@ fn parse_config_file(config_file: &String) -> Config { .expect("index out of bounds") .to_lowercase() .as_str() + .trim() { "n" => should_exclude_be_invisible = false, "no" => should_exclude_be_invisible = false, @@ -69,11 +71,28 @@ fn parse_config_file(config_file: &String) -> Config { portfolio_link = arg_line.to_string(); } } + if line.contains("HIDE_PORTFOLIO_ROW:") { + match config_file + .lines() + .nth(i + 1) + .expect("index out of bounds") + .to_lowercase() + .as_str() + .trim() + { + "n" => hide_portfolio_row = false, + "no" => hide_portfolio_row = false, + "y" => hide_portfolio_row = true, + "yes" => hide_portfolio_row = true, + _ => hide_portfolio_row = false, + } + } } Config { exclude_keywords_list, should_exclude_be_invisible, portfolio_link, + hide_portfolio_row, } } diff --git a/src/main.rs b/src/main.rs index 5a74dbc..8f35d61 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,14 +61,18 @@ fn main() { prev_project_name = project_name.clone(); let details = format!("Working on {}", &project_name.clone()); //update activity - let state = format!("Portfolio: {}", &config.portfolio_link); - let activity = activity::Activity::new() - .state(state.as_str()) + + let mut activity = activity::Activity::new() .details(&details.as_str()) .assets( activity::Assets::new().large_image(current_app.drp_client_id.as_str()), ) .timestamps(activity::Timestamps::new().start(start_time as i64)); + let state; + if !config.hide_portfolio_row { + state = format!("Portfolio: {}", &config.portfolio_link); + activity = activity.state(state.as_str()); + } //if discord client exists, update status if let Some(dc) = discord_client.as_mut() { match dc.set_activity(activity) {