Merge branch 'songtronix/QoL' into 'master'

Quality of Life

See merge request veloren/veloren!604
This commit is contained in:
Songtronix 2019-10-18 15:06:21 +00:00
commit 72e18d0edd
9 changed files with 38 additions and 11 deletions

View File

@ -79,9 +79,11 @@ impl Client {
// TODO: Voxygen should display this.
if server_info.git_hash != common::util::GIT_HASH.to_string() {
log::warn!(
"Git hash mismatch between client and server: {} vs {}",
"Server is running {}[{}], you are running {}[{}], versions might be incompatible!",
server_info.git_hash,
common::util::GIT_HASH
server_info.git_date,
common::util::GIT_HASH.to_string(),
common::util::GIT_DATE.to_string(),
);
}

View File

@ -9,7 +9,13 @@ use std::process::Command;
fn main() {
// Get the current githash
match Command::new("git")
.args(&["rev-parse", "--short", "HEAD"])
.args(&[
"log",
"-n",
"1",
"--pretty=format:%h/%cd",
"--date=format:%Y-%m-%d-%H:%M",
])
.output()
{
Ok(output) => match String::from_utf8(output.stdout) {

View File

@ -20,6 +20,7 @@ pub struct ServerInfo {
pub name: String,
pub description: String,
pub git_hash: String,
pub git_date: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]

View File

@ -1,4 +1,9 @@
pub const GIT_HASH: &str = include_str!(concat!(env!("OUT_DIR"), "/githash"));
pub const GIT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/githash"));
lazy_static::lazy_static! {
pub static ref GIT_HASH: &'static str = include_str!(concat!(env!("OUT_DIR"), "/githash")).split(" ").nth(0).unwrap();
pub static ref GIT_DATE: &'static str = include_str!(concat!(env!("OUT_DIR"), "/githash")).split(" ").nth(1).unwrap();
}
use vek::{Mat3, Rgb, Rgba, Vec3};

View File

@ -124,6 +124,7 @@ impl Server {
name: settings.server_name.clone(),
description: settings.server_description.clone(),
git_hash: common::util::GIT_HASH.to_string(),
git_date: common::util::GIT_DATE.to_string(),
},
metrics: ServerMetrics::new(settings.metrics_address),
accounts: AuthProvider::new(),

View File

@ -40,7 +40,7 @@ impl ServerMetrics {
);
let entity_count = IntGauge::with_opts(opts).unwrap();
let opts = Opts::new("veloren_build_info", "Build information")
.const_label("hash", common::util::GIT_HASH)
.const_label("hash", &common::util::GIT_HASH)
.const_label("version", "");
let build_info = IntGauge::with_opts(opts).unwrap();
let opts = Opts::new(

View File

@ -452,7 +452,11 @@ impl Hud {
let mut events = Vec::new();
let (ref mut ui_widgets, ref mut tooltip_manager) = self.ui.set_widgets();
let version = format!("{}-{}", env!("CARGO_PKG_VERSION"), common::util::GIT_HASH);
let version = format!(
"{}-{}",
env!("CARGO_PKG_VERSION"),
common::util::GIT_VERSION.to_string()
);
if self.show.ingame {
// Crosshair

View File

@ -288,7 +288,11 @@ impl CharSelectionUi {
fn update_layout(&mut self, client: &Client) -> Vec<Event> {
let mut events = Vec::new();
let (ref mut ui_widgets, ref mut tooltip_manager) = self.ui.set_widgets();
let version = env!("CARGO_PKG_VERSION");
let version = format!(
"{}-{}",
env!("CARGO_PKG_VERSION"),
common::util::GIT_VERSION.to_string()
);
// Tooltip
let tooltip_human = Tooltip::new({
// Edge images [t, b, r, l]
@ -469,7 +473,7 @@ impl CharSelectionUi {
}
// Alpha Version
Text::new(version)
Text::new(&version)
.top_right_with_margins_on(ui_widgets.window, 5.0, 5.0)
.font_size(14)
.font_id(self.fonts.cyri)

View File

@ -179,7 +179,11 @@ impl MainMenuUi {
fn update_layout(&mut self, global_state: &mut GlobalState) -> Vec<Event> {
let mut events = Vec::new();
let (ref mut ui_widgets, ref mut _tooltip_manager) = self.ui.set_widgets();
let version = env!("CARGO_PKG_VERSION");
let version = format!(
"{}-{}",
env!("CARGO_PKG_VERSION"),
common::util::GIT_VERSION.to_string()
);
const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
const TEXT_COLOR_2: Color = Color::Rgba(1.0, 1.0, 1.0, 0.2);
@ -224,8 +228,8 @@ impl MainMenuUi {
.mid_top_with_margin_on(self.ids.banner_top, 40.0)
.color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.95)))
.set(self.ids.v_logo, ui_widgets);
Text::new(version)
// Version displayed top right corner
Text::new(&version)
.top_right_with_margins_on(ui_widgets.window, 5.0, 5.0)
.font_size(14)
.font_id(self.fonts.cyri)