mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-14 02:16:10 +00:00
Instructions for Version Update from v2.6 (#218)
* Do version check and remove overlay if it exists * Use format! instead of mutable string * Handle missing overlay * Use cargo package version instead of hardcoded str Co-authored-by: asimon-1 <asimon1@protonmail.com>
This commit is contained in:
parent
b57cf538f5
commit
427d6ee953
3 changed files with 46 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
pub mod consts;
|
||||
pub mod menu;
|
||||
pub mod release;
|
||||
|
||||
use crate::common::consts::*;
|
||||
use smash::app::{self, lua_bind::*};
|
||||
|
|
35
src/common/release.rs
Normal file
35
src/common/release.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use std::fs;
|
||||
use std::io::Write;
|
||||
use skyline_web::DialogOk;
|
||||
const CURRENT_VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||
const VERSION_FILE_PATH: &str = "sd:/TrainingModpack/version.txt";
|
||||
|
||||
fn is_current_version(fpath: &str) -> bool {
|
||||
// Create a blank version file if it doesn't exists
|
||||
if fs::metadata(fpath).is_err() {
|
||||
let _ = fs::File::create(fpath).expect("Could not create version file!");
|
||||
}
|
||||
let content = fs::read_to_string(fpath).unwrap_or("".to_string());
|
||||
content == CURRENT_VERSION
|
||||
}
|
||||
|
||||
fn record_current_version(fpath: &str) {
|
||||
// Write the current version to the version file
|
||||
let mut f = fs::File::create(fpath).unwrap();
|
||||
write!(f, "{}", CURRENT_VERSION.to_owned()).expect("Could not record current version!");
|
||||
}
|
||||
|
||||
pub fn version_check() {
|
||||
// Display dialog box on launch if changing versions
|
||||
if !is_current_version(VERSION_FILE_PATH) {
|
||||
DialogOk::ok(
|
||||
format!(
|
||||
"Thank you for installing version {} of the Training Modpack.\n\n\
|
||||
This version includes a change to the menu button combination, which is now SPECIAL+UPTAUNT.\n\
|
||||
Please refer to the Github page and the Discord server for a full list of recent changes.",
|
||||
CURRENT_VERSION
|
||||
)
|
||||
);
|
||||
record_current_version(VERSION_FILE_PATH);
|
||||
}
|
||||
}
|
10
src/lib.rs
10
src/lib.rs
|
@ -20,6 +20,7 @@ use crate::common::*;
|
|||
use training::combo::FRAME_ADVANTAGE;
|
||||
|
||||
use skyline::libc::{c_void, fclose, fopen, fwrite, mkdir};
|
||||
use std::fs;
|
||||
use skyline::nro::{self, NroInfo};
|
||||
|
||||
use owo_colors::OwoColorize;
|
||||
|
@ -99,4 +100,13 @@ pub fn main() {
|
|||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
let ovl_path = "sd:/switch/.overlays/ovlTrainingModpack.ovl";
|
||||
if !fs::metadata(ovl_path).is_err() {
|
||||
log!("Removing ovlTrainingModpack.ovl...");
|
||||
fs::remove_file(ovl_path).unwrap();
|
||||
}
|
||||
|
||||
log!("Performing version check...");
|
||||
release::version_check();
|
||||
}
|
Loading…
Add table
Reference in a new issue