feat(pgr): compatibility fixes
Moved mfc140 to the core library, updated wincompatlib to resolve fonts installation issue
This commit is contained in:
parent
b22a1b242e
commit
a2f4ee924b
4 changed files with 27 additions and 74 deletions
|
@ -9,7 +9,7 @@ edition = "2021"
|
|||
|
||||
[dependencies.anime-game-core]
|
||||
git = "https://github.com/an-anime-team/anime-game-core"
|
||||
tag = "1.12.3"
|
||||
tag = "1.12.4"
|
||||
features = ["all"]
|
||||
|
||||
# path = "../anime-game-core" # ! for dev purposes only
|
||||
|
@ -24,7 +24,7 @@ serde_json = { version = "1.0", optional = true }
|
|||
cached = { version = "0.44", features = ["proc_macro"] }
|
||||
enum-ordinalize = { version = "3.1", optional = true }
|
||||
|
||||
wincompatlib = { version = "0.7.2", features = ["all"], optional = true }
|
||||
wincompatlib = { version = "0.7.3", features = ["all"], optional = true }
|
||||
lazy_static = { version = "1.4", optional = true }
|
||||
md-5 = { version = "0.10", features = ["asm"], optional = true }
|
||||
discord-rich-presence = { version = "0.2.3", optional = true }
|
||||
|
@ -41,6 +41,7 @@ honkai-patch = [
|
|||
"anime-game-core/patch-jadeite",
|
||||
"anime-game-core/patch-mfplat"
|
||||
]
|
||||
pgr-patch = ["anime-game-core/patch-mfc140"]
|
||||
|
||||
# Common features
|
||||
states = []
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use anime_game_core::installer::downloader::Downloader;
|
||||
|
||||
// Source: https://github.com/Winetricks/winetricks/blob/e9454179686b3659ad3f47a5d49e6e4e82862cd5/src/winetricks#L13206
|
||||
|
||||
const URL: &str = "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe";
|
||||
|
||||
const LIBRARIES: &[&str] = &[
|
||||
"mfc140.dll",
|
||||
"mfc140u.dll",
|
||||
"mfcm140.dll",
|
||||
"mfcm140u.dll"
|
||||
];
|
||||
|
||||
pub fn is_installed(wine_prefix: impl AsRef<Path>) -> bool {
|
||||
wine_prefix.as_ref().join("drive_c/windows/system32/mfc140.dll").exists()
|
||||
}
|
||||
|
||||
pub fn install(wine_prefix: impl AsRef<Path>) -> anyhow::Result<()> {
|
||||
let vcredist = std::env::temp_dir().join("vcredist/vc_redist.x86.exe");
|
||||
let vcredist_extracted = std::env::temp_dir().join("vcredist/extracted");
|
||||
|
||||
Downloader::new(URL)?
|
||||
.with_continue_downloading(false)
|
||||
.download(&vcredist, |_, _| {})?;
|
||||
|
||||
// w_try_cabextract --directory="${W_TMP}/win64" "${W_CACHE}"/vcrun2015/vc_redist.x64.exe -F 'a11'
|
||||
let output = Command::new("cabextract")
|
||||
.arg("-d")
|
||||
.arg(&vcredist_extracted)
|
||||
.arg(vcredist)
|
||||
.arg("-F")
|
||||
.arg("a11")
|
||||
.spawn()?
|
||||
.wait_with_output()?;
|
||||
|
||||
if !output.status.success() {
|
||||
anyhow::bail!("Failed to extract vcrun2015 (1): {}", String::from_utf8_lossy(&output.stderr));
|
||||
}
|
||||
|
||||
// w_try_cabextract --directory="${W_TMP}/win64" "${W_TMP}/win64/a11"
|
||||
let output = Command::new("cabextract")
|
||||
.arg("-d")
|
||||
.arg(&vcredist_extracted)
|
||||
.arg(vcredist_extracted.join("a11"))
|
||||
.spawn()?
|
||||
.wait_with_output()?;
|
||||
|
||||
if !output.status.success() {
|
||||
anyhow::bail!("Failed to extract vcrun2015 (2): {}", String::from_utf8_lossy(&output.stderr));
|
||||
}
|
||||
|
||||
// w_try_cp_dll "${W_TMP}/win64"/mfc140.dll "${W_SYSTEM64_DLLS}"/mfc140.dll
|
||||
for lib in LIBRARIES {
|
||||
let dest = wine_prefix.as_ref().join("drive_c/windows/system32").join(lib);
|
||||
|
||||
std::fs::copy(vcredist_extracted.join(lib), dest)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
pub mod loader;
|
||||
pub mod wine;
|
||||
pub mod dxvk;
|
||||
pub mod mfc140;
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use wincompatlib::wine::ext::Corefont;
|
||||
use wincompatlib::wine::ext::Font;
|
||||
|
||||
use anime_game_core::prelude::*;
|
||||
use anime_game_core::pgr::prelude::*;
|
||||
|
||||
use crate::config::ConfigExt;
|
||||
use crate::components::mfc140;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum LauncherState {
|
||||
|
@ -18,7 +17,7 @@ pub enum LauncherState {
|
|||
PrefixNotExists,
|
||||
|
||||
Mfc140NotInstalled,
|
||||
CorefontsNotInstalled(Vec<Corefont>),
|
||||
FontsNotInstalled(Vec<Font>),
|
||||
|
||||
// Always contains `VersionDiff::Diff`
|
||||
GameUpdateAvailable(VersionDiff),
|
||||
|
@ -57,16 +56,33 @@ impl LauncherState {
|
|||
return Ok(Self::Mfc140NotInstalled);
|
||||
}
|
||||
|
||||
let mut corefonts = Vec::new();
|
||||
let mut fonts = Vec::new();
|
||||
|
||||
for font in Corefont::iterator() {
|
||||
// In future, wincompatlib's Font might contain fonts that won't be actually needed
|
||||
// That's why I listed only needed fonts here
|
||||
const COREFONTS: &[Font] = &[
|
||||
Font::Andale,
|
||||
Font::Arial,
|
||||
Font::Courier,
|
||||
Font::Georgia,
|
||||
Font::Impact,
|
||||
Font::Times,
|
||||
Font::Trebuchet,
|
||||
Font::Verdana,
|
||||
Font::Webdings,
|
||||
|
||||
// Who even needs it?
|
||||
Font::ComicSans
|
||||
];
|
||||
|
||||
for font in COREFONTS.iter().copied() {
|
||||
if !font.is_installed(¶ms.wine_prefix) {
|
||||
corefonts.push(font);
|
||||
fonts.push(font);
|
||||
}
|
||||
}
|
||||
|
||||
if !corefonts.is_empty() {
|
||||
return Ok(Self::CorefontsNotInstalled(corefonts));
|
||||
if !fonts.is_empty() {
|
||||
return Ok(Self::FontsNotInstalled(fonts));
|
||||
}
|
||||
|
||||
// Check game installation status
|
||||
|
|
Loading…
Reference in a new issue