From 6c67fc8de29827839fb87e9eeb62d6c5bea742f6 Mon Sep 17 00:00:00 2001 From: CI010 Date: Sat, 28 Oct 2023 00:51:19 +0800 Subject: [PATCH] fix: Shader pack & resource pack does not linked --- .../src/composables/instanceResourcePack.ts | 10 ++++++++-- .../src/composables/instanceShaderPack.ts | 11 +++++++++++ xmcl-keystone-ui/src/windows/main/Context.ts | 4 +++- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 xmcl-keystone-ui/src/composables/instanceShaderPack.ts diff --git a/xmcl-keystone-ui/src/composables/instanceResourcePack.ts b/xmcl-keystone-ui/src/composables/instanceResourcePack.ts index 484800c68..b7c9fceef 100644 --- a/xmcl-keystone-ui/src/composables/instanceResourcePack.ts +++ b/xmcl-keystone-ui/src/composables/instanceResourcePack.ts @@ -1,9 +1,10 @@ import { PackMeta } from '@xmcl/resourcepack' -import { GameOptions, isPersistedResource, packFormatVersionRange, Resource, ResourceDomain } from '@xmcl/runtime-api' +import { GameOptions, InstanceResourcePacksServiceKey, isPersistedResource, packFormatVersionRange, Resource, ResourceDomain } from '@xmcl/runtime-api' import { computed, Ref, InjectionKey } from 'vue' import unknownPack from '@/assets/unknown_pack.png' import { useDomainResources } from './resources' +import { useService } from './service' export interface InstanceResourcePack extends PackMeta.Pack { /** @@ -46,7 +47,12 @@ export const kInstanceResourcePacks: InjectionKey) { +export function useInstanceResourcePacks(path: Ref, gameOptions: Ref) { + const { link } = useService(InstanceResourcePacksServiceKey) + watch(path, (v) => { + link(v) + }, { immediate: true }) + const { resources, refresh, refreshing } = useDomainResources(ResourceDomain.ResourcePacks) const allResourcePacks = computed(() => resources.value.map(r => getResourcePackItem(r))) /** diff --git a/xmcl-keystone-ui/src/composables/instanceShaderPack.ts b/xmcl-keystone-ui/src/composables/instanceShaderPack.ts new file mode 100644 index 000000000..7255b41c8 --- /dev/null +++ b/xmcl-keystone-ui/src/composables/instanceShaderPack.ts @@ -0,0 +1,11 @@ +import { InstanceShaderPacksServiceKey } from '@xmcl/runtime-api' +import { useService } from './service' +import { Ref } from 'vue' + +export function useInstanceShaderPacks(instancePath: Ref) { + const { link } = useService(InstanceShaderPacksServiceKey) + + watch(instancePath, () => { + link(instancePath.value) + }, { immediate: true }) +} diff --git a/xmcl-keystone-ui/src/windows/main/Context.ts b/xmcl-keystone-ui/src/windows/main/Context.ts index 4a3efadca..b14ae2e1d 100644 --- a/xmcl-keystone-ui/src/windows/main/Context.ts +++ b/xmcl-keystone-ui/src/windows/main/Context.ts @@ -14,6 +14,7 @@ import { kInstanceLaunch, useInstanceLaunch } from '@/composables/instanceLaunch import { kInstanceModsContext, useInstanceMods } from '@/composables/instanceMods' import { kInstanceOptions, useInstanceOptions } from '@/composables/instanceOptions' import { kInstanceResourcePacks, useInstanceResourcePacks } from '@/composables/instanceResourcePack' +import { useInstanceShaderPacks } from '@/composables/instanceShaderPack' import { kInstanceVersion, useInstanceVersion } from '@/composables/instanceVersion' import { kInstanceVersionDiagnose, useInstanceVersionDiagnose } from '@/composables/instanceVersionDiagnose' import { kInstances, useInstances } from '@/composables/instances' @@ -66,7 +67,8 @@ export default defineComponent({ const instanceDefaultSource = useInstanceDefaultSource(instance.path) const options = useInstanceOptions(instance.instance) const saves = useInstanceSaves(instance.instance) - const resourcePacks = useInstanceResourcePacks(options.gameOptions) + const resourcePacks = useInstanceResourcePacks(instance.path, options.gameOptions) + useInstanceShaderPacks(instance.path) const instanceMods = useInstanceMods(instance.path, instance.runtime, instanceJava.java) const files = useInstanceFiles(instance.path) const task = useLaunchTask(instance.path, instance.runtime, instanceVersion.versionHeader)