Game version in the menu: VERSION holds vYYYYMM-NNNNN, shown on the title screen and in the pause menu, tools/bump_version.py raises it with every change
This commit is contained in:
1 parent
1ec7492189
commit
dd4bb75b24
9 files changed
+86
-1
No files matched your search
+27
@@ -231,6 +231,14 @@ enum Btn {
|
||||
pub const REPO_URL: &str = "https://git.familie-zink.org/zink/dungeoncraft";
|
||||
pub const CLAUDE_CODE_URL: &str = "https://claude.com/claude-code";
|
||||
|
||||
// the game version (file VERSION, "vYYYYMM-NNNNN"): tools/bump_version.py raises it with every
|
||||
// change, and the title screen and the pause menu show it
|
||||
const VERSION_FILE: &str = include_str!("../VERSION");
|
||||
|
||||
pub fn version() -> &'static str {
|
||||
VERSION_FILE.trim()
|
||||
}
|
||||
|
||||
// the Claude Code mark as pixel art (drawn next to the "made with" note)
|
||||
const CLAUDE_MARK: [&str; 5] = [
|
||||
"...############...",
|
||||
@@ -683,6 +691,9 @@ impl Menu {
|
||||
self.buttons.push((r, Btn::ClaudeCode));
|
||||
let lic = tr("menu.license");
|
||||
gfx.text(&lic, grid_center(sw, gfx.measure(&lic, SMALL())), sh - CH() * 2.5, SMALL(), DIM);
|
||||
let ver = tr("menu.version");
|
||||
let line = format!("{} {}", ver, version());
|
||||
gfx.text(&line, grid_center(sw, gfx.measure(&line, SMALL())), sh - CH() * 5.5, SMALL(), DIM);
|
||||
let url = REPO_URL.trim_start_matches("https://");
|
||||
let w = gfx.measure(url, SMALL());
|
||||
let r = Rect::new(grid_center(sw, w), sh - CH() * 1.5, w, GH * SMALL() + 2.0);
|
||||
@@ -760,6 +771,9 @@ impl Menu {
|
||||
gfx.window_titled(x, y, cols, rows, S(), true, FRAME_HI, Color::new(0.05, 0.03, 0.04, 0.97), &tr("menu.paused"), FRAME_HI);
|
||||
let w = (cols - 6) as f32 * CW();
|
||||
self.column(gfx, x + CW() * 3.0, y + CH() * 2.0, w, &items);
|
||||
let ver = tr("menu.version");
|
||||
let line = format!("{} {}", ver, version());
|
||||
gfx.text(&line, x + (cols as f32 * CW() - gfx.measure(&line, SMALL())) * 0.5, y + (rows as f32 - 1.7) * CH(), SMALL(), DIM);
|
||||
}
|
||||
|
||||
fn draw_settings(&mut self, gfx: &Gfx, s: &Settings, tab: usize) {
|
||||
@@ -1241,3 +1255,16 @@ pub fn goal_text(g: Goal) -> String {
|
||||
Goal::Freed(n) => trf("goal.freed", &[n.to_string()]),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn the_version_follows_the_scheme() {
|
||||
let rest = super::version().strip_prefix('v').expect("the version starts with v");
|
||||
let (month, number) = rest.split_once('-').expect("the version is vYYYYMM-NNNNN");
|
||||
assert_eq!(month.len(), 6);
|
||||
assert!(month.chars().all(|c| c.is_ascii_digit()));
|
||||
assert_eq!(number.len(), 5);
|
||||
assert!(number.parse::<u32>().expect("a number") >= 1);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user