mirror of
https://github.com/open-goal/launcher.git
synced 2024-10-19 14:47:36 -04:00
support: put installed VCC runtime version in support package (#580)
This commit is contained in:
parent
9edab84c40
commit
17e28719d3
|
@ -1,5 +1,6 @@
|
|||
use std::path::Path;
|
||||
|
||||
use crate::util::os::get_installed_vcc_runtime;
|
||||
use crate::{config::LauncherConfig, util::file::delete_dir};
|
||||
use semver::Version;
|
||||
use sysinfo::Disks;
|
||||
|
@ -118,48 +119,15 @@ pub async fn is_diskspace_requirement_met(
|
|||
pub async fn is_minimum_vcc_runtime_installed(
|
||||
_config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
|
||||
) -> Result<bool, CommandError> {
|
||||
use log::info;
|
||||
use winreg::{
|
||||
enums::{HKEY_LOCAL_MACHINE, KEY_READ},
|
||||
RegKey,
|
||||
};
|
||||
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
|
||||
let path = r"SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64";
|
||||
|
||||
if let Ok(key) = hklm.open_subkey_with_flags(path, KEY_READ) {
|
||||
let installed_value: u32 = key.get_value("Installed").map_err(|err| {
|
||||
log::error!("Couldn't locate VCC runtime registry entry: {}", err);
|
||||
CommandError::Configuration("Unable to check if VCC runtime is installed".to_owned())
|
||||
})?;
|
||||
let is_installed = installed_value == 1;
|
||||
if !is_installed {
|
||||
return Ok(false);
|
||||
}
|
||||
let minimum_version = semver::Version::new(14, 40, 33810);
|
||||
let patch_version: u32 = key.get_value("Bld").map_err(|err| {
|
||||
log::error!("Couldn't locate VCC runtime registry entry: {}", err);
|
||||
CommandError::Configuration("Unable to check if VCC runtime is installed".to_owned())
|
||||
})?;
|
||||
let minor_version: u32 = key.get_value("Minor").map_err(|err| {
|
||||
log::error!("Couldn't locate VCC runtime registry entry: {}", err);
|
||||
CommandError::Configuration("Unable to check if VCC runtime is installed".to_owned())
|
||||
})?;
|
||||
let major_version: u32 = key.get_value("Major").map_err(|err| {
|
||||
log::error!("Couldn't locate VCC runtime registry entry: {}", err);
|
||||
CommandError::Configuration("Unable to check if VCC runtime is installed".to_owned())
|
||||
})?;
|
||||
let installed_version = semver::Version::new(
|
||||
major_version.into(),
|
||||
minor_version.into(),
|
||||
patch_version.into(),
|
||||
);
|
||||
info!("Detected VCC Runtime: {major_version}.{minor_version}.{patch_version}");
|
||||
return Ok(installed_version >= minimum_version);
|
||||
let minimum_version = semver::Version::new(14, 40, 33810);
|
||||
let installed_vcc_runtime_version = get_installed_vcc_runtime();
|
||||
if installed_vcc_runtime_version.is_none() {
|
||||
Err(CommandError::Configuration(
|
||||
"Unable to check if VCC runtime is installed".to_owned(),
|
||||
))
|
||||
} else {
|
||||
Ok(installed_vcc_runtime_version.unwrap() >= minimum_version)
|
||||
}
|
||||
|
||||
return Err(CommandError::Configuration(
|
||||
"Unable to check if minimum VCC runtime is installed".to_owned(),
|
||||
));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
|
|
|
@ -14,8 +14,9 @@ use tauri::api::path::config_dir;
|
|||
|
||||
use crate::{
|
||||
config::LauncherConfig,
|
||||
util::zip::{
|
||||
append_dir_contents_to_zip, append_file_to_zip, check_if_zip_contains_top_level_file,
|
||||
util::{
|
||||
os::get_installed_vcc_runtime,
|
||||
zip::{append_dir_contents_to_zip, append_file_to_zip, check_if_zip_contains_top_level_file},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -69,6 +70,7 @@ impl PerGameInfo {
|
|||
#[derive(Default, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SupportPackage {
|
||||
pub installed_vcc_runtime: Option<String>,
|
||||
pub total_memory_megabytes: u64,
|
||||
pub cpu_name: String,
|
||||
pub cpu_vendor: String,
|
||||
|
@ -283,6 +285,12 @@ pub async fn generate_support_package(
|
|||
// System Information
|
||||
let mut system_info = System::new_all();
|
||||
system_info.refresh_all();
|
||||
let installed_vcc_runtime_version = get_installed_vcc_runtime();
|
||||
if installed_vcc_runtime_version.is_none() {
|
||||
package.installed_vcc_runtime = None;
|
||||
} else {
|
||||
package.installed_vcc_runtime = Some(installed_vcc_runtime_version.unwrap().to_string());
|
||||
}
|
||||
package.total_memory_megabytes = system_info.total_memory() / 1024 / 1024;
|
||||
package.cpu_name = system_info.cpus()[0].name().to_string();
|
||||
package.cpu_vendor = system_info.cpus()[0].vendor_id().to_string();
|
||||
|
|
|
@ -11,3 +11,71 @@ pub fn open_dir_in_os(dir: String) -> Result<(), std::io::Error> {
|
|||
Command::new(FILE_OPENING_PROGRAM).arg(dir).spawn()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub fn get_installed_vcc_runtime() -> Option<semver::Version> {
|
||||
return None;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn get_installed_vcc_runtime() -> Option<semver::Version> {
|
||||
use winreg::{
|
||||
enums::{HKEY_LOCAL_MACHINE, KEY_READ},
|
||||
RegKey,
|
||||
};
|
||||
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
|
||||
let path = r"SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64";
|
||||
|
||||
if let Ok(key) = hklm.open_subkey_with_flags(path, KEY_READ) {
|
||||
match key.get_value::<u32, _>("Installed") {
|
||||
Ok(val) => {
|
||||
if val != 1 {
|
||||
log::error!("VCC runtime exists in the registry but is not marked as installed");
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("Couldn't determine if VCC runtime was installed: {}", err);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let patch_version: u32 = match key.get_value("Bld") {
|
||||
Ok(val) => val,
|
||||
Err(err) => {
|
||||
log::error!(
|
||||
"Couldn't determine installed VCC runtime patch version: {}",
|
||||
err
|
||||
);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let minor_version: u32 = match key.get_value("Minor") {
|
||||
Ok(val) => val,
|
||||
Err(err) => {
|
||||
log::error!(
|
||||
"Couldn't determine installed VCC runtime minor version: {}",
|
||||
err
|
||||
);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let major_version: u32 = match key.get_value("Major") {
|
||||
Ok(val) => val,
|
||||
Err(err) => {
|
||||
log::error!(
|
||||
"Couldn't determine installed VCC runtime major version: {}",
|
||||
err
|
||||
);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let installed_version = semver::Version::new(
|
||||
major_version.into(),
|
||||
minor_version.into(),
|
||||
patch_version.into(),
|
||||
);
|
||||
log::info!("Detected VCC Runtime: {major_version}.{minor_version}.{patch_version}");
|
||||
return Some(installed_version);
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@
|
|||
{$_("gameControls_beta_bugReport_linkPreText")}
|
||||
<a
|
||||
class="text-blue-400"
|
||||
href="https://github.com/open-goal/jak-project/issues/new?assignees=&labels=bug%2Cjak2&projects=&template=jak2-bug-report.yml"
|
||||
href="https://github.com/open-goal/jak-project/issues/new?template=jak2-bug-report.yml"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>{$_("gameControls_beta_bugReport_linkText")}</a
|
||||
|
|
Loading…
Reference in a new issue