Skip to content

Commit

Permalink
Now making a more elaborate credit message, listing the number of com…
Browse files Browse the repository at this point in the history
…mits and the branch name
  • Loading branch information
CaspianA1 committed Sep 1, 2024
1 parent 6d8d65c commit cf6ec9e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/dashboard_defs/credit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use crate::{
};

pub fn make_credit_window(top_left: Vec2f, size: Vec2f,
border_color: ColorSDL, text_color: ColorSDL, text: &'static str) -> Window {
border_color: ColorSDL, text_color: ColorSDL, text: String) -> Window {

type CreditWindowState = &'static str;
type CreditWindowState = String;

impl updatable_text_pattern::UpdatableTextWindowMethods for CreditWindowState {
fn should_skip_update(updater_params: &mut WindowUpdaterParams) -> bool {
Expand Down
23 changes: 20 additions & 3 deletions src/dashboard_defs/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ fn get_fallback_texture_creation_info() -> TextureCreationInfo<'static> {
TextureCreationInfo::Path(Cow::Borrowed(&FALLBACK_TEXTURE_PATHS[index]))
}

fn run_command(command: &str, args: &[&str]) -> GenericResult<String> {
let output = std::process::Command::new(command)
.args(args)
.output()?;

if !output.status.success() {
error_msg!("This command failed: {command} {}", args.join(" "))
}
else {
String::from_utf8(output.stdout).to_generic().and_then(|s| Ok(s.trim().to_owned()))
}
}

////////// TODO: maybe split `make_dashboard` into some smaller sub-functions

/* TODO:
Expand Down Expand Up @@ -238,12 +251,16 @@ pub fn make_dashboard(

////////// Making a credit window

let num_commits = run_command("git", &["rev-list", "--count", "HEAD"])?;
let branch_name = run_command("git", &["rev-parse", "--abbrev-ref", "HEAD"])?;
let credit_message = format!("By Caspian Ahlberg, release #{num_commits}, on branch '{branch_name}'");

let credit_window = make_credit_window(
Vec2f::new(0.85, 0.97),
Vec2f::new(0.15, 0.03),
Vec2f::new(0.8, 0.98),
Vec2f::new(0.2, 0.02),
ColorSDL::RED,
ColorSDL::RGB(210, 180, 140),
"By: Caspian Ahlberg"
credit_message
);

////////// Making a clock window
Expand Down

0 comments on commit cf6ec9e

Please sign in to comment.