Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Show git sha in version
Browse files Browse the repository at this point in the history
  • Loading branch information
PieKing1215 committed Aug 15, 2024
1 parent b8a74a3 commit c375848
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub unsafe extern "stdcall" fn DllMain(
}

struct MainHud {
version_string: String,
show: bool,
tweaks: Vec<Box<dyn Tweak + Send + Sync>>,
errors: Vec<anyhow::Error>,
Expand All @@ -56,6 +57,7 @@ struct MainHud {
impl MainHud {
fn new() -> Self {
let mut this = Self {
version_string: format!("SWMod v{}{}", env!("CARGO_PKG_VERSION"), option_env!("SHA").map_or_else(|| "".to_string(), |sha| format!(" ({sha})"))),
show: true,
tweaks: vec![],
errors: vec![],
Expand Down Expand Up @@ -124,7 +126,7 @@ impl ImguiRenderLoop for MainHud {
.build(|| {
let text_color = ui.push_style_color(StyleColor::Text, [0.8, 0.8, 0.8, if self.show { 0.9 } else { 0.4 }]);
if self.show {
ui.text(format!("SWMod v{} [~]", env!("CARGO_PKG_VERSION")));
ui.text(format!("{} [~]", self.version_string));
} else {
ui.text(" [~]");
}
Expand Down Expand Up @@ -159,7 +161,7 @@ impl ImguiRenderLoop for MainHud {
.resizable(false)
.position([50., 50.], Condition::FirstUseEver)
.build(|| {
ui.text(format!("SWMod v{}", env!("CARGO_PKG_VERSION")));
ui.text(&self.version_string);
if ui.button("Eject") {
self.uninit();
}
Expand All @@ -169,7 +171,7 @@ impl ImguiRenderLoop for MainHud {
.no_nav()
.always_auto_resize(true)
.resizable(false)
.position([180., 50.], Condition::FirstUseEver)
.position([250., 50.], Condition::FirstUseEver)
.build(|| {
if ui.button("Reset to Default") {
for tw in &mut self.tweaks {
Expand All @@ -194,7 +196,7 @@ impl ImguiRenderLoop for MainHud {
ui.window("Errors")
.no_nav()
.size([300., 200.], Condition::FirstUseEver)
.position([50., 50.], Condition::FirstUseEver)
.position([50., 250.], Condition::FirstUseEver)
.build(|| {
for err in &self.errors {
ui.text(format!("{err:?}"));
Expand Down

0 comments on commit c375848

Please sign in to comment.