Skip to content

Commit

Permalink
config: add opt-out for auto-proceeding after successful operation
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser committed Oct 18, 2024
1 parent ec7977b commit 0abd716
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src-tauri/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,3 +620,15 @@ pub async fn set_rip_streamed_audio_enabled(
})?;
Ok(())
}

#[tauri::command]
pub async fn get_proceed_after_successful_operation(
config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
) -> Result<bool, CommandError> {
let config_lock = config.lock().await;
Ok(
config_lock
.proceed_after_successful_operation
.unwrap_or(true),
)
}
2 changes: 2 additions & 0 deletions src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ pub struct LauncherConfig {
pub mod_sources: Option<Vec<String>>,
pub decompiler_settings: Option<DecompilerSettings>,
pub check_for_latest_mod_version: Option<bool>,
pub proceed_after_successful_operation: Option<bool>,
}

fn default_version() -> Option<String> {
Expand All @@ -224,6 +225,7 @@ impl LauncherConfig {
mod_sources: None,
decompiler_settings: Some(DecompilerSettings::default()),
check_for_latest_mod_version: Some(true),
proceed_after_successful_operation: Some(true),
}
}

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 @@ -166,6 +166,7 @@ fn main() {
commands::config::does_active_tooling_version_meet_minimum,
commands::config::does_active_tooling_version_support_game,
commands::config::finalize_installation,
commands::config::get_proceed_after_successful_operation,
commands::config::get_active_tooling_version_folder,
commands::config::get_active_tooling_version,
commands::config::get_bypass_requirements,
Expand Down
25 changes: 23 additions & 2 deletions src/components/games/job/GameJob.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
} from "$lib/rpc/binaries";
import {
finalizeInstallation,
getProceedAfterSuccessfulOperation,
setEnabledTexturePacks,
} from "$lib/rpc/config";
import { generateSupportPackage } from "$lib/rpc/support";
Expand Down Expand Up @@ -44,8 +45,18 @@
const dispatch = createEventDispatcher();
let installationError: string | undefined | null = undefined;
let proceedAfterSuccessfulOperation = true;
$: if ($progressTracker.overallStatus === "success") {
onMount(async () => {
proceedAfterSuccessfulOperation =
await getProceedAfterSuccessfulOperation();
console.log(proceedAfterSuccessfulOperation);
});
$: if (
$progressTracker.overallStatus === "success" &&
proceedAfterSuccessfulOperation
) {
dispatch("jobFinished");
}
Expand Down Expand Up @@ -480,7 +491,17 @@
<Progress />
<LogViewer />
</div>
{#if $progressTracker.overallStatus === "failed"}
{#if $progressTracker.overallStatus === "success" && !proceedAfterSuccessfulOperation}
<div class="flex flex-col justify-end items-end mt-auto">
<div class="flex flex-row gap-2">
<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"
on:click={async () => dispatch("jobFinished")}
>{$_("setup_button_continue")}</Button
>
</div>
</div>
{:else if $progressTracker.overallStatus === "failed"}
<div class="flex flex-col mt-auto">
<div class="flex flex-row gap-2">
<Alert color="red" class="dark:bg-slate-900 flex-grow">
Expand Down
21 changes: 19 additions & 2 deletions src/components/games/setup/GameSetup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
isDiskSpaceRequirementMet,
isOpenGLRequirementMet,
isMinimumVCCRuntimeInstalled,
getProceedAfterSuccessfulOperation,
} from "$lib/rpc/config";
import { progressTracker } from "$lib/stores/ProgressStore";
import { generateSupportPackage } from "$lib/rpc/support";
Expand All @@ -30,10 +31,13 @@
let requirementsMet = true;
let installing = false;
let installationError = undefined;
let proceedAfterSuccessfulOperation = true;
onMount(async () => {
// Check requirements
await checkRequirements();
proceedAfterSuccessfulOperation =
await getProceedAfterSuccessfulOperation();
});
async function checkRequirements() {
Expand Down Expand Up @@ -117,7 +121,10 @@
}
}
$: if ($progressTracker.overallStatus === "success") {
$: if (
$progressTracker.overallStatus === "success" &&
proceedAfterSuccessfulOperation
) {
dispatch("change");
}
</script>
Expand All @@ -129,7 +136,17 @@
<Progress />
<LogViewer />
</div>
{#if $progressTracker.overallStatus === "failed"}
{#if $progressTracker.overallStatus === "success" && !proceedAfterSuccessfulOperation}
<div class="flex flex-col justify-end items-end mt-auto">
<div class="flex flex-row gap-2">
<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"
on:click={async () => dispatch("change")}
>{$_("setup_button_continue")}</Button
>
</div>
</div>
{:else if $progressTracker.overallStatus === "failed"}
<div class="flex flex-col mt-auto">
<div class="flex flex-row gap-2">
<Alert
Expand Down
8 changes: 8 additions & 0 deletions src/lib/rpc/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ export async function isRipStreamedAudioEnabled(): Promise<boolean> {
return await invoke_rpc("is_rip_streamed_audio_enabled", {}, () => false);
}

export async function getProceedAfterSuccessfulOperation(): Promise<boolean> {
return await invoke_rpc(
"get_proceed_after_successful_operation",
{},
() => true,
);
}

export async function setRipStreamedAudioEnabled(
enabled: boolean,
): Promise<void> {
Expand Down

0 comments on commit 0abd716

Please sign in to comment.