From 203a4a1180eb75c7a079b44ff557e1406be1db26 Mon Sep 17 00:00:00 2001 From: Alula Date: Sun, 6 Dec 2020 16:41:12 +0100 Subject: [PATCH 1/2] Let CI override version displayed in menu --- .appveyor.yml | 1 + src/common.rs | 10 +++++++--- src/lib.rs | 1 - src/scene/title_scene.rs | 5 ++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 07f36cf..0bb3b58 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -35,6 +35,7 @@ cache: # - cargo test --verbose --all --no-fail-fast build_script: + - set DRS_BUILD_VERSION_OVERRIDE=%APPVEYOR_BUILD_VERSION% - cargo build --release --bin doukutsu-rs - mkdir release - copy target\release\doukutsu-rs.exe release diff --git a/src/common.rs b/src/common.rs index a5e017d..9cbae05 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,19 +1,23 @@ use std::cmp::Ordering; use std::fmt; -use ggez::GameError; -use ggez::GameError::InvalidValue; +use lazy_static::lazy_static; use num_traits::{AsPrimitive, Num}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use serde::de::{SeqAccess, Visitor}; use serde::ser::SerializeTupleStruct; use crate::bitfield; -use crate::macros::fmt::Formatter; /// Multiply cave story degrees (0-255, which corresponds to 0°-360°) with this to get /// respective value in radians. pub const CDEG_RAD: f64 = std::f64::consts::PI / 128.0; +lazy_static! { + pub static ref VERSION_BANNER: String = { + let version = option_env!("DRS_BUILD_VERSION_OVERRIDE").unwrap_or(env!("CARGO_PKG_VERSION")); + format!("doukutsu-rs {}", version) + }; +} bitfield! { #[derive(Clone, Copy)] diff --git a/src/lib.rs b/src/lib.rs index e972d87..4b8dd1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -163,7 +163,6 @@ impl Game { fn key_down_event(&mut self, key_code: KeyCode, _key_mod: KeyMods, repeat: bool) { if repeat { return; } - // todo: proper keymaps? let state = &mut self.state; match key_code { KeyCode::F7 => { state.set_speed(1.0) } diff --git a/src/scene/title_scene.rs b/src/scene/title_scene.rs index 999c826..e64123b 100644 --- a/src/scene/title_scene.rs +++ b/src/scene/title_scene.rs @@ -1,7 +1,7 @@ use ggez::{Context, GameResult, graphics}; use ggez::graphics::Color; -use crate::common::Rect; +use crate::common::{Rect, VERSION_BANNER}; use crate::menu::{Menu, MenuEntry, MenuSelectionResult}; use crate::scene::Scene; use crate::shared_game_state::{SharedGameState, TimingMode}; @@ -75,7 +75,6 @@ impl TitleScene { } } -static ENGINE_VERSION: &str = "doukutsu-rs 0.1.0"; // asset copyright for freeware version static COPYRIGHT_PIXEL: &str = "2004.12 Studio Pixel"; // asset copyright for Nicalis @@ -235,7 +234,7 @@ impl Scene for TitleScene { batch.draw(ctx)?; } - self.draw_text_centered(ENGINE_VERSION, state.canvas_size.1 - 15.0, state, ctx)?; + self.draw_text_centered(VERSION_BANNER.as_str(), state.canvas_size.1 - 15.0, state, ctx)?; if state.constants.is_switch { self.draw_text_centered(COPYRIGHT_NICALIS_SWITCH, state.canvas_size.1 - 30.0, state, ctx)?; From 20be51bb72ae1c0882164455c8361595d0d0ff3c Mon Sep 17 00:00:00 2001 From: Alula Date: Sun, 6 Dec 2020 16:42:05 +0100 Subject: [PATCH 2/2] no thx --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3ad7af2..2f020c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -authors = ["Alula "] +authors = ["Alula"] edition = "2018" name = "doukutsu-rs" version = "0.1.0"