Skip to content

Commit

Permalink
feat: add button to show mods/resourcepacks folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Dec 20, 2020
1 parent ab81f79 commit cc98d5b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/renderer/windows/main/pages/ModSettingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
<v-toolbar dark flat color="transparent" style="z-index: 10">
<v-toolbar-title>{{ $tc("mod.name", 2) }}</v-toolbar-title>
<v-spacer />
<!-- <v-tooltip bottom>
<template v-slot:activator="{ on }"> -->
<v-btn icon @click="showModsFolder()">
<v-icon>folder</v-icon>
</v-btn>
<!-- </template>
{{ $t(`curseforge.mc-mods.description`) }}
</v-tooltip> -->
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-btn icon v-on="on" @click="goToCurseforgeMods()">
Expand Down Expand Up @@ -125,6 +133,7 @@ import {
useDrop,
useInstanceBase,
useRouter,
useService,
} from '@/hooks';
import { useLocalStorageCacheBool } from '@/hooks/useCache';
import { filter } from 'fuzzy';
Expand Down Expand Up @@ -359,20 +368,18 @@ export default defineComponent({
const { toggle } = useSearchToggles();
const { text: filteredText } = useSearch();
const { path } = useInstanceBase();
const { openDirectory } = useService('BaseService');
function isCompatibleMod(mod: ModItem) {
if (data.filterInCompatible) {
return isCompatible(mod.acceptVersion, minecraft.value);
return isCompatible(mod.dependencies.minecraft, minecraft.value);
}
return true;
}
function group(list: ModItem[], mod: ModItem): ModItem[] {
if (list.find(v => v.hash === mod.hash)) return list;
const existed = list.findIndex(v => v.id === mod.id && v.type === mod.type);
if (existed !== -1) {
console.log('found existed:');
console.log(list[existed]);
console.log(mod);
list.splice(existed + 1, 0, mod);
mod.subsequence = true;
} else {
Expand All @@ -381,7 +388,7 @@ export default defineComponent({
}
return list;
}
const items = computed(() => filter(filteredText.value, mods.value, { extract: v => `${v.name} ${v.version} ${v.acceptVersion}` })
const items = computed(() => filter(filteredText.value, mods.value, { extract: v => `${v.name} ${v.version} ${v.dependencies.minecraft}` })
.map((r) => r.original)
.filter(isCompatibleMod)
.sort((a, b) => (a.enabled ? -1 : 1))
Expand Down Expand Up @@ -411,12 +418,16 @@ export default defineComponent({
function goToCurseforgeMods() {
replace(`/curseforge/mc-mods?from=${path.value}`);
}
function showModsFolder() {
openDirectory(path.value + '/mods');
}
return {
...toRefs(data),
...setupDragMod(items, selectedMods, isSelectionMode),
...setupEnable(items, isSelectionMode, selectedMods, isSelected, commit),
...setupDeletion(mods),
showModsFolder,
goToCurseforgeMods,
onVisible,
Expand Down
15 changes: 14 additions & 1 deletion src/renderer/windows/main/pages/ResourcePackSettingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@
hide-details
/>
</v-flex>
<v-btn
style="margin-top: 12px; margin-bottom: 0; margin-left: 15px"
icon
@click="showFolder()"
>
<v-icon>folder</v-icon>
</v-btn>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-btn
icon
style="margin-top: 12px; margin-bottom: 0; margin-left: 15px"
style="margin-top: 12px; margin-bottom: 0;"
v-on="on"
@click="goToCurseforge()"
>
Expand Down Expand Up @@ -206,6 +213,7 @@ import {
useDropImport,
ResourcePackItem,
useRouter,
useService,
useInstanceBase,
} from '@/hooks';
import ResourcePackCard from './ResourcePackSettingPageCard.vue';
Expand All @@ -223,6 +231,7 @@ export default defineComponent({
const { removeResource } = useResourceOperation();
const { replace } = useRouter();
const { path } = useInstanceBase();
const { openDirectory } = useService('BaseService');
const searchBar: Ref<any> = ref(null);
const data = reactive({
dragging: false,
Expand Down Expand Up @@ -269,6 +278,9 @@ export default defineComponent({
function goToCurseforge() {
replace(`/curseforge/texture-packs?from=${path.value}`);
}
function showFolder() {
openDirectory(path.value + '/resourcepacks');
}
return {
...toRefs(data),
unselectedItems,
Expand All @@ -281,6 +293,7 @@ export default defineComponent({
goPreview,
searchBar,
goToCurseforge,
showFolder,
};
},
// async mounted() {
Expand Down

0 comments on commit cc98d5b

Please sign in to comment.