Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend/frontend: add a check for the VCC Runtime on windows #437

Merged
merged 3 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ wgpu = "0.18.0"
zip = { version = "0.6.2" }
zip-extract = "0.1.3"

[target.'cfg(windows)'.dependencies]
winreg = "0.52.0"

[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
Expand Down
41 changes: 41 additions & 0 deletions src-tauri/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,47 @@ pub async fn is_diskspace_requirement_met(
));
}

#[cfg(target_os = "windows")]
#[tauri::command]
pub async fn is_vcc_runtime_installed(
_config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
) -> Result<bool, CommandError> {
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())
})?;
return Ok(installed_value == 1);
}

return Err(CommandError::Configuration(
"Unable to check if VCC runtime is installed".to_owned(),
));
}

#[cfg(target_os = "linux")]
#[tauri::command]
pub async fn is_vcc_runtime_installed(
_config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
) -> Result<bool, CommandError> {
return Ok(false);
}

#[cfg(target_os = "macos")]
#[tauri::command]
pub async fn is_vcc_runtime_installed(
_config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
) -> Result<bool, CommandError> {
return Ok(false);
}

#[tauri::command]
pub async fn is_avx_requirement_met(
config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ fn main() {
commands::config::is_diskspace_requirement_met,
commands::config::is_game_installed,
commands::config::is_opengl_requirement_met,
commands::config::is_vcc_runtime_installed,
commands::config::reset_to_defaults,
commands::config::save_active_version_change,
commands::config::set_bypass_requirements,
Expand Down
155 changes: 79 additions & 76 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,79 @@
{
"package": {
"productName": "OpenGOAL-Launcher",
"version": "2.4.1"
},
"build": {
"distDir": "../dist",
"devPath": "http://localhost:3000/",
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build"
},
"tauri": {
"bundle": {
"active": true,
"targets": [
"msi",
"appimage",
"app",
"dmg",
"updater"
],
"identifier": "OpenGOAL-Launcher",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"copyright": "",
"category": "DeveloperTool",
"shortDescription": "",
"longDescription": "",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"allowlist": {
"all": true,
"clipboard": {
"writeText": true
},
"fs": {
"scope": [
"$APP/",
"$APP/iso/*",
"$APP/*",
"$APP/**/*",
"$RESOURCE/**/*"
]
},
"protocol": {
"asset": true,
"assetScope": ["**"]
}
},
"windows": [
{
"title": "OpenGOAL Launcher - Splash",
"label": "splashscreen",
"width": 200,
"height": 300,
"center": true,
"decorations": false,
"transparent": true,
"resizable": false,
"fullscreen": false,
"url": "./src/splash/index.html",
"visible": true,
"focus": true
}
]
}
}
{
"package": {
"productName": "OpenGOAL-Launcher",
"version": "2.4.1"
},
"build": {
"distDir": "../dist",
"devPath": "http://localhost:3000/",
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build"
},
"tauri": {
"bundle": {
"active": true,
"targets": [
"msi",
"appimage",
"app",
"dmg",
"updater"
],
"identifier": "OpenGOAL-Launcher",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"copyright": "",
"category": "DeveloperTool",
"shortDescription": "",
"longDescription": "",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"allowlist": {
"all": true,
"clipboard": {
"writeText": true
},
"fs": {
"scope": [
"$APP/",
"$APP/iso/*",
"$APP/*",
"$APP/**/*",
"$RESOURCE/**/*"
]
},
"protocol": {
"asset": true,
"assetScope": ["**"]
},
"os": {
"all": true
}
},
"windows": [
{
"title": "OpenGOAL Launcher - Splash",
"label": "splashscreen",
"width": 200,
"height": 300,
"center": true,
"decorations": false,
"transparent": true,
"resizable": false,
"fullscreen": false,
"url": "./src/splash/index.html",
"visible": true,
"focus": true
}
]
}
}
5 changes: 5 additions & 0 deletions src/assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
"requirements_gpu_doesNotSupportOpenGL": "Your GPU does not support OpenGL 4.3",
"requirements_gpu_supportsOpenGL": "Your GPU supports OpenGL 4.3",
"requirements_gpu_unableToCheckOpenGL": "Unable to verify if your GPU supports OpenGL 4.3",
"requirements_windows_vccRuntimeInstalled": "Microsoft Visual C++ Runtime is installed",
"requirements_windows_cantCheckIfVccRuntimeInstalled": "Unable to check if Microsoft Visual C++ Runtime is installed",
"requirements_windows_vccRuntimeNotInstalled": "Microsoft Visual C++ Runtime is not installed or is out of date",
"requirements_windows_vccRuntimeExplanation": "A recent version of the Microsoft Visual C++ Runtime is required to run the game",
"requirements_windows_vccRuntimeExplanation_downloadLink": "Download the latest Microsoft Visual C++ Runtime here",
"requirements_notMet_header": "Unfortunately, your system does not meet all the minimum requirements or we were unable to check them",
"settings_folders_installationDir_prompt": "Pick an Installation Folder",
"settings_folders_installationDir": "Installation Directory",
Expand Down
11 changes: 10 additions & 1 deletion src/components/games/setup/GameSetup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
isAVXRequirementMet,
isDiskSpaceRequirementMet,
isOpenGLRequirementMet,
isVCCRuntimeInstalled,
} from "$lib/rpc/config";
import { progressTracker } from "$lib/stores/ProgressStore";
import { generateSupportPackage } from "$lib/rpc/support";
import { _ } from "svelte-i18n";
import { type } from "@tauri-apps/api/os";

export let activeGame: SupportedGame;

Expand All @@ -42,7 +44,14 @@
const isDiskSpaceMet = await isDiskSpaceRequirementMet(
getInternalName(activeGame),
);
requirementsMet = isAvxMet && isOpenGLMet && isDiskSpaceMet;
const osType = await type();
if (osType == "Windows_NT") {
const isVCCInstalled = await isVCCRuntimeInstalled();
requirementsMet =
isAvxMet && isOpenGLMet && isDiskSpaceMet && isVCCInstalled;
} else {
requirementsMet = isAvxMet && isOpenGLMet && isDiskSpaceMet;
}
}

async function install(viaFolder: boolean) {
Expand Down
44 changes: 44 additions & 0 deletions src/components/games/setup/Requirements.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@
isAVXRequirementMet,
isDiskSpaceRequirementMet,
isOpenGLRequirementMet,
isVCCRuntimeInstalled,
setBypassRequirements,
} from "$lib/rpc/config";
import { _ } from "svelte-i18n";
import { confirm } from "@tauri-apps/api/dialog";
import { getInternalName, type SupportedGame } from "$lib/constants";
import { type } from "@tauri-apps/api/os";

export let activeGame: SupportedGame;

let isAVXMet: boolean | undefined = false;
let isOpenGLMet: boolean | undefined = false;
let isDiskSpaceMet: boolean | undefined = false;
let isVCCRelevant = false;
let isVCCInstalled: boolean | undefined = false;

const dispatch = createEventDispatcher();

Expand All @@ -25,6 +29,11 @@
isDiskSpaceMet = await isDiskSpaceRequirementMet(
getInternalName(activeGame),
);
const osType = await type();
isVCCRelevant = osType == "Windows_NT";
if (isVCCRelevant) {
isVCCInstalled = await isVCCRuntimeInstalled();
}
});

function alertColor(val: boolean | undefined) {
Expand Down Expand Up @@ -120,6 +129,41 @@
>
{/if}
</Alert>
{#if isVCCRelevant}
<Alert
class="w-full text-start"
rounded={false}
color={alertColor(isVCCInstalled)}
>
{#if isVCCInstalled}
<span class="font-bold"
>{$_("requirements_windows_vccRuntimeInstalled")}</span
>
{:else if isVCCInstalled === undefined}
<span class="font-bold"
>{$_("requirements_windows_cantCheckIfVccRuntimeInstalled")}</span
>
{:else}
<span class="font-bold"
>{$_("requirements_windows_vccRuntimeNotInstalled")}</span
>
<ul class="font-medium list-disc list-inside">
<li>{$_("requirements_windows_vccRuntimeExplanation")}</li>
<li>
<a
class="font-bold text-blue-500"
target="_blank"
rel="noreferrer"
href="https://aka.ms/vs/17/release/vc_redist.x64.exe"
>{$_(
"requirements_windows_vccRuntimeExplanation_downloadLink",
)}</a
>
</li>
</ul>
{/if}
</Alert>
{/if}
<div>
<Button
class="border-solid border-2 border-slate-900 rounded bg-slate-900 hover:bg-slate-800 text-sm text-white font-semibold px-5 py-2"
Expand Down
4 changes: 4 additions & 0 deletions src/lib/rpc/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export async function isDiskSpaceRequirementMet(
);
}

export async function isVCCRuntimeInstalled(): Promise<boolean | undefined> {
return await invoke_rpc("is_vcc_runtime_installed", {}, () => undefined);
}

export async function finalizeInstallation(gameName: string): Promise<void> {
return await invoke_rpc("finalize_installation", { gameName }, () => {});
}
Expand Down
Loading