Skip to content

Commit

Permalink
Merge branch 'main' into barebones
Browse files Browse the repository at this point in the history
  • Loading branch information
CaspianA1 committed Sep 1, 2024
2 parents 23ed618 + cf6ec9e commit a2021ab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 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
27 changes: 21 additions & 6 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 @@ -241,14 +254,16 @@ pub fn make_dashboard(

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

let border_and_text_color = ColorSDL::RGB(255, 153, 153);
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.8, 0.97),
Vec2f::new(0.2, 0.03),
border_and_text_color,
border_and_text_color,
"By: Caspian Ahlberg"
Vec2f::new(0.8, 0.98),
Vec2f::new(0.2, 0.02),
ColorSDL::RED,
ColorSDL::RGB(210, 180, 140),
credit_message
);

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

0 comments on commit a2021ab

Please sign in to comment.