Skip to content

Commit

Permalink
fix: Shader pack & resource pack does not linked
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Oct 27, 2023
1 parent 7fbf8af commit 6c67fc8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 8 additions & 2 deletions xmcl-keystone-ui/src/composables/instanceResourcePack.ts
Original file line number Diff line number Diff line change
@@ -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 {
/**
Expand Down Expand Up @@ -46,7 +47,12 @@ export const kInstanceResourcePacks: InjectionKey<ReturnType<typeof useInstanceR
/**
* The hook return a reactive resource pack array.
*/
export function useInstanceResourcePacks(gameOptions: Ref<GameOptions | undefined>) {
export function useInstanceResourcePacks(path: Ref<string>, gameOptions: Ref<GameOptions | undefined>) {
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)))
/**
Expand Down
11 changes: 11 additions & 0 deletions xmcl-keystone-ui/src/composables/instanceShaderPack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { InstanceShaderPacksServiceKey } from '@xmcl/runtime-api'
import { useService } from './service'
import { Ref } from 'vue'

export function useInstanceShaderPacks(instancePath: Ref<string>) {
const { link } = useService(InstanceShaderPacksServiceKey)

watch(instancePath, () => {
link(instancePath.value)
}, { immediate: true })
}
4 changes: 3 additions & 1 deletion xmcl-keystone-ui/src/windows/main/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6c67fc8

Please sign in to comment.