Skip to content

Commit 0781daf

Browse files
committed
feat: add configuration option to toggle updates
1 parent 06c0f60 commit 0781daf

8 files changed

Lines changed: 69 additions & 43 deletions

File tree

main/components/GameOptions/Launch.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class="block w-full rounded-md bg-zinc-800 px-3 py-1.5 text-base text-zinc-100 outline-1 -outline-offset-1 outline-zinc-800 placeholder:text-zinc-400 focus:outline-2 focus:-outline-offset-2 focus:outline-blue-600 sm:text-sm/6"
1212
placeholder="{}"
1313
aria-describedby="launch-description"
14-
v-model="model.launchString"
14+
v-model="model.launchTemplate"
1515
/>
1616
</div>
1717
<p class="mt-2 text-sm text-zinc-400" id="launch-description">
@@ -129,9 +129,9 @@
129129
</span>
130130
</li>
131131
</ListboxOption>
132-
<li v-else class="italic text-zinc-400 py-2 pr-9 pl-3"
133-
>No auto-discovered layers.</li
134-
>
132+
<li v-else class="italic text-zinc-400 py-2 pr-9 pl-3">
133+
No auto-discovered layers.
134+
</li>
135135
<h1 class="text-white text-sm font-semibold bg-zinc-900 py-2 px-2">
136136
Manually added
137137
</h1>
@@ -170,9 +170,9 @@
170170
</span>
171171
</li>
172172
</ListboxOption>
173-
<li v-else class="italic text-zinc-400 py-2 pr-9 pl-3"
174-
>No manually added layers.</li
175-
>
173+
<li v-else class="italic text-zinc-400 py-2 pr-9 pl-3">
174+
No manually added layers.
175+
</li>
176176
</ListboxOptions>
177177
</transition>
178178
</div>
@@ -190,7 +190,7 @@
190190

191191
<script setup lang="ts">
192192
import { invoke } from "@tauri-apps/api/core";
193-
import type { FrontendGameConfiguration, ProtonPath } from "~/composables/game";
193+
import type { ProtonPath } from "~/composables/game";
194194
import {
195195
Listbox,
196196
ListboxButton,
@@ -201,8 +201,9 @@ import {
201201
import { ChevronUpDownIcon } from "@heroicons/vue/16/solid";
202202
import { CheckIcon } from "@heroicons/vue/20/solid";
203203
import { WrenchIcon } from "@heroicons/vue/24/solid";
204+
import type { GameVersion } from "~/types";
204205
205-
const model = defineModel<FrontendGameConfiguration>({ required: true });
206+
const model = defineModel<GameVersion["userConfiguration"]>({ required: true });
206207
207208
const props = defineProps<{
208209
protonEnabled: boolean;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<div class="space-y-8">
3+
<div class="flex flex-row items-center justify-between">
4+
<div>
5+
<h3 class="text-sm font-medium leading-6 text-zinc-100">
6+
Enable update checks
7+
</h3>
8+
<p class="mt-1 text-sm leading-6 text-zinc-400">
9+
Drop will automatically check for updates from your server
10+
</p>
11+
</div>
12+
<Switch
13+
v-model="model.enableUpdates"
14+
:class="[
15+
model.enableUpdates ? 'bg-blue-600' : 'bg-zinc-700',
16+
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out',
17+
]"
18+
>
19+
<span
20+
:class="[
21+
model.enableUpdates ? 'translate-x-5' : 'translate-x-0',
22+
'pointer-events-none relative inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out',
23+
]"
24+
/>
25+
</Switch>
26+
</div>
27+
28+
</div>
29+
</template>
30+
31+
<script setup lang="ts">
32+
import { Switch } from "@headlessui/vue";
33+
import type { GameVersion } from '~/types';
34+
35+
const model = defineModel<GameVersion["userConfiguration"]>({ required: true });
36+
</script>

main/components/GameOptionsModal.vue

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<ModalTemplate size-class="max-w-4xl" v-model="open">
33
<template #default>
4-
<div class="flex flex-row gap-x-4">
4+
<div class="flex flex-row gap-x-4 h-96">
55
<nav class="flex flex-1 flex-col" aria-label="Sidebar">
66
<ul role="list" class="-mx-2 space-y-1">
77
<li v-for="(tab, tabIdx) in tabs" :key="tab.name">
@@ -29,8 +29,7 @@
2929
</li>
3030
</ul>
3131
</nav>
32-
<div class="border-l-2 border-zinc-800 w-full grow pl-4">
33-
<span class="font-mono text-zinc-100">{{ configuration }}</span>
32+
<div class="border-l-2 border-zinc-800 w-full grow pl-4 overflow-y-scroll">
3433
<component
3534
v-model="configuration"
3635
:is="tabs[currentTabIndex]?.page"
@@ -81,33 +80,39 @@ import {
8180
XCircleIcon,
8281
} from "@heroicons/vue/20/solid";
8382
import Launch from "./GameOptions/Launch.vue";
84-
import type { FrontendGameConfiguration } from "~/composables/game";
83+
import Updates from "./GameOptions/Updates.vue";
8584
import { invoke } from "@tauri-apps/api/core";
85+
import { ArrowPathIcon } from "@heroicons/vue/24/solid";
86+
import type { GameVersion } from "~/types";
8687
8788
const appState = useAppState();
8889
8990
const open = defineModel<boolean>();
9091
const props = defineProps<{ gameId: string }>();
9192
const game = await useGame(props.gameId);
9293
93-
const configuration: Ref<FrontendGameConfiguration> = ref({
94-
launchString: game.version.value!.userConfiguration.launchTemplate,
95-
overrideProtonPath: game.version.value!.userConfiguration.overrideProtonPath,
96-
});
94+
const configuration: Ref<GameVersion["userConfiguration"]> = ref(game.version.value!.userConfiguration);
9795
9896
const hasWindows = !!(
9997
game.version.value!.setups.find((v) => v.platform === "Windows") ??
10098
game.version.value!.launches.find((v) => v.platform === "Windows")
10199
);
102100
103-
const protonEnabled = !!(appState.value!.umuState !== "NotNeeded" && hasWindows);
101+
const protonEnabled = !!(
102+
appState.value!.umuState !== "NotNeeded" && hasWindows
103+
);
104104
105105
const tabs: Array<{ name: string; icon: Component; page: Component }> = [
106106
{
107107
name: "Launch",
108108
icon: RocketLaunchIcon,
109109
page: Launch,
110110
},
111+
{
112+
name: "Updates",
113+
icon: ArrowPathIcon,
114+
page: Updates,
115+
},
111116
{
112117
name: "Storage",
113118
icon: ServerIcon,

main/composables/game.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ export const useGame = async (gameId: string) => {
6363
return { ...game, status };
6464
};
6565

66-
export type FrontendGameConfiguration = {
67-
launchString: string;
68-
overrideProtonPath?: string;
69-
};
70-
7166
export type LaunchResult =
7267
| { result: "Success" }
7368
| { result: "InstallRequired"; data: [string, string] };

src-tauri/download_manager/src/depot_manager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
};
66

77
use futures_util::StreamExt;
8-
use log::warn;
8+
use log::{info, warn};
99
use remote::{
1010
error::RemoteAccessError,
1111
requests::{generate_url, make_authenticated_get},
@@ -108,6 +108,8 @@ impl DepotManager {
108108
})
109109
.collect::<Vec<Depot>>();
110110

111+
info!("syncing {} depots...", new_depots.len());
112+
111113
for depot in &mut new_depots {
112114
if let Err(sync_error) = self.sync_depot(depot).await {
113115
warn!("failed to sync depot {}: {:?}", depot.endpoint, sync_error);

src-tauri/games/src/downloads/download_agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl GameDownloadAgent {
311311
let filename = file.strip_prefix(base_path)?.to_string_lossy().to_string();
312312
let needed = file_list.contains_key(&filename) || filename == ".dropdata";
313313
if !needed {
314-
info!("deleted {}", file.display());
314+
debug!("deleted {}", file.display());
315315
remove_file(file)?;
316316
}
317317
}

src-tauri/games/src/library.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,4 @@ pub fn push_game_update(
288288
version,
289289
}
290290
);
291-
}
292-
293-
#[derive(Deserialize)]
294-
#[serde(rename_all = "camelCase")]
295-
pub struct FrontendGameOptions {
296-
pub launch_string: String,
297-
pub override_proton_path: Option<String>,
298-
}
291+
}

src-tauri/src/games.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use std::sync::nonpoison::Mutex;
33
use bitcode::{Decode, Encode};
44
use database::{
55
DownloadableMetadata, GameDownloadStatus, borrow_db_checked, borrow_db_mut_checked,
6-
models::data::InstalledGameType, platform::Platform,
6+
models::data::{InstalledGameType, UserConfiguration}, platform::Platform,
77
};
88
use games::{
99
collections::collection::Collection,
1010
downloads::error::LibraryError,
11-
library::{FetchGameStruct, FrontendGameOptions, Game, get_current_meta, uninstall_game_logic},
11+
library::{FetchGameStruct, Game, get_current_meta, uninstall_game_logic},
1212
state::{GameStatusManager, GameStatusWithTransient},
1313
};
1414
use log::warn;
@@ -391,7 +391,7 @@ pub async fn fetch_game_version_options(
391391
#[tauri::command]
392392
pub fn update_game_configuration(
393393
game_id: String,
394-
options: FrontendGameOptions,
394+
options: UserConfiguration,
395395
) -> Result<(), LibraryError> {
396396
let mut handle = borrow_db_mut_checked();
397397
let installed_version = handle
@@ -410,13 +410,7 @@ pub fn update_game_configuration(
410410
.unwrap()
411411
.clone();
412412

413-
// Add more options in here
414-
existing_configuration.user_configuration.launch_template = options.launch_string;
415-
existing_configuration
416-
.user_configuration
417-
.override_proton_path = options.override_proton_path;
418-
419-
// Add no more options past here
413+
existing_configuration.user_configuration = options;
420414

421415
handle
422416
.applications

0 commit comments

Comments
 (0)