print current version in the project manager window's title

This commit is contained in:
Dmitry Stepanov
2026-03-02 16:12:49 +03:00
parent 77d28013b2
commit 117fe4752c
4 changed files with 44 additions and 3 deletions
+4 -1
View File
@@ -7,7 +7,7 @@ license = "MIT"
description = "Project manager for Fyrox engine"
keywords = ["fyrox", "project", "manager"]
categories = ["game-development"]
include = ["/src/**/*", "/Cargo.toml", "/LICENSE", "/README.md", "/resources/**/*"]
include = ["/src/**/*", "/Cargo.toml", "/LICENSE", "/README.md", "/resources/**/*", "/pm.version"]
homepage = "https://fyrox.rs"
repository = "https://github.com/FyroxEngine/Fyrox"
rust-version = "1.87"
@@ -22,3 +22,6 @@ open = "5.0.1"
cargo_metadata = "0.22.0"
serde_json = "1.0.133"
directories = "5.0.1"
[build-dependencies]
toml_edit = "0.23.5"
+35
View File
@@ -0,0 +1,35 @@
use std::{
fs::File,
io::{Read, Write},
};
use toml_edit::DocumentMut;
fn write_version_file(manifest_path: &str, version_file: &str) {
let mut toml = String::new();
File::open(manifest_path)
.expect("Cargo.toml must exist!")
.read_to_string(&mut toml)
.expect("File must be readable");
let version = toml
.parse::<DocumentMut>()
.expect("must be valid toml")
.get("package")
.and_then(|i| i.as_table())
.expect("package section must exist!")
.get("version")
.expect("version must be set!")
.to_string()
.replace('\"', "")
.trim()
.to_string();
File::create(version_file)
.expect("version file must be accessible for writing!")
.write_all(version.as_bytes())
.expect("version file must be writable!");
}
fn main() {
write_version_file("./Cargo.toml", "./pm.version");
}
+1
View File
@@ -0,0 +1 @@
1.0.0
+3 -1
View File
@@ -28,6 +28,8 @@ mod settings;
mod upgrade;
mod utils;
static CURRENT_VERSION: &str = include_str!("../pm.version");
use crate::{manager::ProjectManager, settings::DATA_DIR, utils::make_button};
use fyrox::core::algebra::Vector2;
use fyrox::{
@@ -75,7 +77,7 @@ fn main() {
let mut window_attributes = WindowAttributes::default();
window_attributes.inner_size = Some(PhysicalSize::new(720, 520).into());
window_attributes.resizable = true;
window_attributes.title = "Fyrox Project Manager".to_string();
window_attributes.title = format!("Fyrox Project Manager - {}", CURRENT_VERSION);
let serialization_context = Arc::new(SerializationContext::new());
let task_pool = Arc::new(TaskPool::new());