Skip to content

Commit

Permalink
Load datapacks from Modrinth & add url configuration (#62)
Browse files Browse the repository at this point in the history
* store zip datapacks in opfs

* remove some logging

* implement open from modrinth

* add type icons to recents, handle not found

* allow mods from modrinth, fix modal

* cache some modrinth api requests + small fixes

* url parameters and other changes, completes #11

* prevent vanilla datapack removing

* remove dev_mode url param

* update mc-datapack-loader
  • Loading branch information
jacobsjo authored Nov 23, 2024
1 parent a162abd commit 9de54bc
Show file tree
Hide file tree
Showing 26 changed files with 811 additions and 174 deletions.
14 changes: 14 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"dropdown.add.picker.pack": "Packs (*.zip)",
"dropdown.add.picker.mod": "Mods (*.jar)",
"dropdown.add.folder": "Open Folder",
"dropdown.add.modrinth": "Open from Modrinth",
"dropdown.add.built_in.update_1_20": "Update 1.20",
"dropdown.add.built_in.update_1_21": "Update 1.21",
"dropdown.add.built_in.winter_drop": "Winter Drop",
Expand All @@ -76,8 +77,21 @@
"dropdown.add.recents.enable.note": "(accept local storage)",
"dropdown.add.recents.empty": "Empty",
"dropdown.add.recents.unavailable": "Unsupported in this browser",
"dropdown.add.recents.type.zip": "zip file stored in browser",
"dropdown.add.recents.type.folder": "folder datapack directly opened from disk",
"dropdown.add.recents.type.modrinth": "newest version from modrinth",
"dropdown.add.recents.wrong_version": "unavailable for this version ",
"dropdown.search_biome.placeholder": "Search Biome",
"dropdown.structure_positions.placeholder": "Search Structure",
"modrinth.title": "Open from Modrinth",
"modrinth.search.aria-label": "Searchbar for datapacks on Modrinth",
"modrinth.search.placeholder": "Search Modrinth...",
"modrinth.include-mods": "include mods",
"modrinth.include-mods.aria-label": "include mods in search",
"modrinth.include-mods.notice": "Not all mods are supported by this map",
"modrinth.ignore-version": "ignore minecraft version",
"modrinth.ignore-version.aria-label": "ignore minecraft version in search",
"modrinth.ignore-version.notice": "Datapacks for other versions might not work as expected",
"toggle_sidebar.title": "Toggle Sidebar",
"map.info.structures_hidden": "Some structures are hidden. Zoom in to see more.",
"map.info.teleport_command_copied": "Teleport Command Copied",
Expand Down
66 changes: 40 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"deepslate": "^0.22.4",
"idb-keyval": "^6.2.1",
"leaflet": "^1.9.4",
"mc-datapack-loader": "0.4.1",
"mc-datapack-loader": "0.5.0",
"pinia": "^2.1.4",
"vue": "^3.3.4",
"vue-i18n": "^9.2.2",
Expand Down
4 changes: 4 additions & 0 deletions public/images/modrinth.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import Collapsable from './components/Collapsable.vue';
import MainMap from './components/MainMap.vue';
import Sidebar from './components/Sidebar.vue';
import { useLoadedDimensionStore } from './stores/useLoadedDimensionStore';
import { useUiStore } from './stores/useUiStore';
import Popup from './components/Popup.vue';
import ModrinthMenu from './components/modrinth/ModrinthMenu.vue';
const loaded = ref(false)
const uiStore = useUiStore()
onBeforeMount(async () => {
const loadedDimensionStore = useLoadedDimensionStore()
await loadedDimensionStore.reload()
loaded.value = true
})
</script>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Collapsable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const open = ref(true)
}
.toggle.open {
left: 15.8rem
left: 15.8rem;
border-radius: 1rem;
}
.icon {
Expand Down
5 changes: 3 additions & 2 deletions src/components/DatapackEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { versionMetadata } from '../util';
import { computed } from 'vue';
const props = defineProps({
datapack: Object
datapack: Object,
removable: Boolean
})
const settings = useSettingsStore()
Expand All @@ -29,7 +30,7 @@ import { computed } from 'vue';
<div class="description">
<MinecraftText :component="desciption" />
</div>
<font-awesome-icon icon="fa-xmark" class="close_button" tabindex="0" :title="$t('datapack_list.remove_datapack.title')" @click="$emit('close')" @keypress.enter="$emit('close')" />
<font-awesome-icon v-if="removable" icon="fa-xmark" class="close_button" tabindex="0" :title="$t('datapack_list.remove_datapack.title')" @click="$emit('close')" @keypress.enter="$emit('close')" />
</div>
</template>

Expand Down
2 changes: 1 addition & 1 deletion src/components/DatapackList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const store = useDatapackStore();
<template>
<div class="datapack_list">
<Suspense>
<DatapackEntry v-for="(datapack, index) in store.datapacks" :datapack="datapack.datapack" :key="datapack.key" @close="store.removeDatapack(index)"/>
<DatapackEntry v-for="(datapack, index) in store.datapacks" :datapack="datapack.datapack" :key="datapack.key" :removable="index > 0" @close="store.removeDatapack(index)"/>
</Suspense>

</div>
Expand Down
56 changes: 56 additions & 0 deletions src/components/Faq.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@



<template>
<span class="faq" tabindex="0">
<font-awesome-icon class="icon" icon="fa-circle-question" />
<div class="popup">
<slot></slot>
</div>
</span>

</template>

<style scoped>
.faq {
position: relative;
}
.icon {
cursor: pointer;
}
.popup {
display: none;
position: absolute;
left: 50%;
top: calc(100% + 0.5rem);
transform: translate(-50%, 0);
background-color: rgba(0, 0, 0, 0.75);
padding: 0.2rem 0.6rem;
border-radius: 0.5rem;
max-width: 15rem;
width: max-content;
text-align: center;
}
.popup::after {
content: '';
position: absolute;
top: 0;
left: 50%;
width: 0;
height: 0;
border: 0.5rem solid transparent;
border-bottom-color: rgba(0, 0, 0, 0.75);;
border-top: 0;
margin-left: -0.5rem;
margin-top: -0.5rem;
}
.faq:hover .popup,.faq:focus .popup{
display: block;
}
</style>
6 changes: 2 additions & 4 deletions src/components/LocaleChanger.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<script setup lang="ts">
import { useSettingsStore } from '../stores/useSettingsStore';
import { EventTracker } from '../util/EventTracker';
import { updateUrlParam } from '../util';
const settingsStore = useSettingsStore()
function updateUrlSearch(locale: string) {
const uri = window.location.search.substring(1)
const params = new URLSearchParams(uri)
params.set('lang', locale)
history.replaceState({}, "", "?" + params.toString())
updateUrlParam('lang', locale)
EventTracker.track(`change_locale/${locale}`)
}
Expand Down
Loading

0 comments on commit 9de54bc

Please sign in to comment.