You've already forked AstralRinth
forked from didirus/AstralRinth
Bug fixes (#406)
* skip duplicates * slash, exports * fullscreen, exports * more bugs * fixed mac title bar * filters should go to top of page when changed * mac err, loading bars * temporary comments * moving to mac * bug fixes, fmt, prettier * review fixes * rev fixes
This commit is contained in:
@@ -98,7 +98,13 @@ const confirmClose = async () => {
|
||||
}
|
||||
|
||||
const handleClose = async () => {
|
||||
const isSafe = await check_safe_loading_bars_complete()
|
||||
// State should respond immeiately if it's safe to close
|
||||
// If not, code is deadlocked or worse, so wait 2 seconds and then ask the user to confirm closing
|
||||
// (Exception: if the user is changing config directory, which takes control of the state, and it's taking a significant amount of time for some reason)
|
||||
const isSafe = await Promise.race([
|
||||
check_safe_loading_bars_complete(),
|
||||
new Promise((r) => setTimeout(r, 2000)),
|
||||
])
|
||||
if (!isSafe) {
|
||||
const response = await confirmClose()
|
||||
if (!response) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { export_profile_mrpack, get_potential_override_folders } from '@/helpers
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
import { sep } from '@tauri-apps/api/path'
|
||||
import { useTheming } from '@/store/theme'
|
||||
|
||||
const props = defineProps({
|
||||
instance: {
|
||||
@@ -27,6 +28,8 @@ const versionInput = ref('1.0.0')
|
||||
const files = ref([])
|
||||
const folders = ref([])
|
||||
|
||||
const themeStore = useTheming()
|
||||
|
||||
const initFiles = async () => {
|
||||
const newFolders = new Map()
|
||||
files.value = []
|
||||
@@ -88,7 +91,7 @@ const exportPack = async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal ref="exportModal" header="Export modpack">
|
||||
<Modal ref="exportModal" header="Export modpack" :noblur="!themeStore.advancedRendering">
|
||||
<div class="modal-body">
|
||||
<div class="labeled_input">
|
||||
<p>Modpack Name</p>
|
||||
|
||||
@@ -141,21 +141,17 @@ async function refreshSearch() {
|
||||
const base = 'https://api.modrinth.com/v2/'
|
||||
|
||||
const params = [`limit=${maxResults.value}`, `index=${sortType.value.name}`]
|
||||
|
||||
if (query.value.length > 0) {
|
||||
params.push(`query=${query.value.replace(/ /g, '+')}`)
|
||||
}
|
||||
|
||||
if (instanceContext.value) {
|
||||
if (!ignoreInstanceLoaders.value && projectType.value === 'mod') {
|
||||
orFacets.value = [`categories:${encodeURIComponent(instanceContext.value.metadata.loader)}`]
|
||||
}
|
||||
|
||||
if (!ignoreInstanceGameVersions.value) {
|
||||
selectedVersions.value = [instanceContext.value.metadata.game_version]
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
facets.value.length > 0 ||
|
||||
orFacets.value.length > 0 ||
|
||||
@@ -167,7 +163,6 @@ async function refreshSearch() {
|
||||
for (const facet of facets.value) {
|
||||
formattedFacets.push([facet])
|
||||
}
|
||||
|
||||
// loaders specifier
|
||||
if (orFacets.value.length > 0) {
|
||||
formattedFacets.push(orFacets.value)
|
||||
@@ -186,14 +181,12 @@ async function refreshSearch() {
|
||||
}
|
||||
formattedFacets.push(versionFacets)
|
||||
}
|
||||
|
||||
if (onlyOpenSource.value) {
|
||||
formattedFacets.push(['open_source:true'])
|
||||
}
|
||||
|
||||
if (selectedEnvironments.value.length > 0) {
|
||||
let environmentFacets = []
|
||||
|
||||
const includesClient = selectedEnvironments.value.includes('client')
|
||||
const includesServer = selectedEnvironments.value.includes('server')
|
||||
if (includesClient && includesServer) {
|
||||
@@ -224,14 +217,11 @@ async function refreshSearch() {
|
||||
|
||||
params.push(`facets=${JSON.stringify(formattedFacets)}`)
|
||||
}
|
||||
|
||||
const offset = (currentPage.value - 1) * maxResults.value
|
||||
if (currentPage.value !== 1) {
|
||||
params.push(`offset=${offset}`)
|
||||
}
|
||||
|
||||
let url = 'search'
|
||||
|
||||
if (params.length > 0) {
|
||||
for (let i = 0; i < params.length; i++) {
|
||||
url += i === 0 ? `?${params[i]}` : `&${params[i]}`
|
||||
@@ -257,12 +247,15 @@ async function onSearchChange(newPageNumber) {
|
||||
if (query.value === null) {
|
||||
return
|
||||
}
|
||||
|
||||
await refreshSearch()
|
||||
|
||||
const obj = getSearchUrl((currentPage.value - 1) * maxResults.value, true)
|
||||
await router.replace({ path: route.path, query: obj })
|
||||
breadcrumbs.setContext({ name: 'Browse', link: route.path, query: obj })
|
||||
|
||||
// Only replace in router if the query is different
|
||||
if (JSON.stringify(obj) != JSON.stringify(route.query)) {
|
||||
await router.replace({ path: route.path, query: obj })
|
||||
breadcrumbs.setContext({ name: 'Browse', link: route.path, query: obj })
|
||||
}
|
||||
}
|
||||
|
||||
const searchWrapper = ref(null)
|
||||
@@ -363,7 +356,6 @@ const sortedCategories = computed(() => {
|
||||
// Sorts alphabetically, but correctly identifies 8x, 128x, 256x, etc
|
||||
// identifier[0], then if it ties, identifier[1], etc
|
||||
async function sortByNameOrNumber(sortable, identifiers) {
|
||||
console.log(sortable)
|
||||
sortable.sort((a, b) => {
|
||||
for (let identifier of identifiers) {
|
||||
let aNum = parseFloat(a[identifier])
|
||||
@@ -394,11 +386,10 @@ async function clearFilters() {
|
||||
for (const facet of [...orFacets.value]) {
|
||||
await toggleOrFacet(facet, true)
|
||||
}
|
||||
|
||||
onlyOpenSource.value = false
|
||||
selectedVersions.value = []
|
||||
selectedEnvironments.value = []
|
||||
await onSearchChange(1)
|
||||
await onSearchChangeToTop(1)
|
||||
}
|
||||
|
||||
async function toggleFacet(elementName, doNotSendRequest = false) {
|
||||
@@ -411,7 +402,7 @@ async function toggleFacet(elementName, doNotSendRequest = false) {
|
||||
}
|
||||
|
||||
if (!doNotSendRequest) {
|
||||
await onSearchChange(1)
|
||||
await onSearchChangeToTop(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,7 +415,7 @@ async function toggleOrFacet(elementName, doNotSendRequest) {
|
||||
}
|
||||
|
||||
if (!doNotSendRequest) {
|
||||
await onSearchChange(1)
|
||||
await onSearchChangeToTop(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,14 +428,16 @@ function toggleEnv(environment, sendRequest) {
|
||||
}
|
||||
|
||||
if (!sendRequest) {
|
||||
onSearchChange(1)
|
||||
onSearchChangeToTop(1)
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.params.projectType,
|
||||
async (newType) => {
|
||||
if (!newType) return
|
||||
// Check if the newType is not the same as the current value
|
||||
if (!newType || newType === projectType.value) return
|
||||
|
||||
projectType.value = newType
|
||||
breadcrumbs.setContext({ name: 'Browse', link: `/browse/${projectType.value}` })
|
||||
|
||||
@@ -601,7 +594,7 @@ const showLoaders = computed(
|
||||
:clear-search-on-select="false"
|
||||
:show-labels="false"
|
||||
placeholder="Choose versions..."
|
||||
@update:model-value="onSearchChange(1)"
|
||||
@update:model-value="onSearchChangeToTop(1)"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
@@ -648,7 +641,7 @@ const showLoaders = computed(
|
||||
v-model="onlyOpenSource"
|
||||
label="Open source only"
|
||||
class="filter-checkbox"
|
||||
@update:model-value="onSearchChange(1)"
|
||||
@update:model-value="onSearchChangeToTop(1)"
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { Card, Slider, DropdownSelect, Toggle } from 'omorphia'
|
||||
import { Card, Slider, DropdownSelect, Checkbox, Toggle } from 'omorphia'
|
||||
import { handleError, useTheming } from '@/store/state'
|
||||
import { get, set } from '@/helpers/settings'
|
||||
import { get_max_memory } from '@/helpers/jre'
|
||||
@@ -333,10 +333,10 @@ watch(
|
||||
<label for="fullscreen">
|
||||
<span class="label__title">Fullscreen</span>
|
||||
<span class="label__description">
|
||||
Make the game start in full screen when launched.
|
||||
Overwrites the option.txt file to start in full screen when launched.
|
||||
</span>
|
||||
</label>
|
||||
<Toggle id="fullscreen" v-model="settings.fullscreen" />
|
||||
<Checkbox id="fullscreen" v-model="settings.force_fullscreen" />
|
||||
</div>
|
||||
<div class="adjacent-input">
|
||||
<label for="width">
|
||||
@@ -346,7 +346,7 @@ watch(
|
||||
<input
|
||||
id="width"
|
||||
v-model="settings.game_resolution[0]"
|
||||
:disabled="settings.fullscreen"
|
||||
:disabled="settings.force_fullscreen"
|
||||
autocomplete="off"
|
||||
type="number"
|
||||
placeholder="Enter width..."
|
||||
@@ -360,7 +360,7 @@ watch(
|
||||
<input
|
||||
id="height"
|
||||
v-model="settings.game_resolution[1]"
|
||||
:disabled="settings.fullscreen"
|
||||
:disabled="settings.force_fullscreen"
|
||||
autocomplete="off"
|
||||
type="number"
|
||||
class="input"
|
||||
|
||||
@@ -351,6 +351,7 @@ import { listen } from '@tauri-apps/api/event'
|
||||
import { convertFileSrc } from '@tauri-apps/api/tauri'
|
||||
import { showProfileInFolder } from '@/helpers/utils.js'
|
||||
import { MenuIcon, ToggleIcon, TextInputIcon, AddProjectImage } from '@/assets/icons'
|
||||
import { install_from_file } from '@/helpers/pack'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -769,10 +770,17 @@ watch(selectAll, () => {
|
||||
})
|
||||
|
||||
listen('tauri://file-drop', async (event) => {
|
||||
for (const file of event.payload) {
|
||||
await add_project_from_path(props.instance.path, file, 'mod').catch(handleError)
|
||||
if (event.payload && event.payload.length > 0 && event.payload[0].endsWith('.mrpack')) {
|
||||
await install_from_file(event.payload[0]).catch(handleError)
|
||||
} else {
|
||||
for (const file of event.payload) {
|
||||
await add_project_from_path(props.instance.path, file, 'mod').catch(handleError)
|
||||
}
|
||||
initProjects(await get(props.instance.path).catch(handleError))
|
||||
}
|
||||
initProjects(await get(props.instance.path).catch(handleError))
|
||||
mixpanel.track('InstanceCreate', {
|
||||
source: 'FileDrop',
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
<span class="label__title">Fullscreen</span>
|
||||
<span class="label__description"> Make the game start in full screen when launched. </span>
|
||||
</label>
|
||||
<Toggle id="fullscreen" v-model="fullscreen" :disabled="!overrideWindowSettings" />
|
||||
<Checkbox id="fullscreen" v-model="fullscreenSetting" :disabled="!overrideWindowSettings" />
|
||||
</div>
|
||||
<div class="adjacent-input">
|
||||
<label for="width">
|
||||
@@ -201,7 +201,7 @@
|
||||
id="width"
|
||||
v-model="resolution[0]"
|
||||
autocomplete="off"
|
||||
:disabled="!overrideWindowSettings || fullscreen"
|
||||
:disabled="!overrideWindowSettings || fullscreenSetting"
|
||||
type="number"
|
||||
placeholder="Enter width..."
|
||||
/>
|
||||
@@ -215,7 +215,7 @@
|
||||
id="height"
|
||||
v-model="resolution[1]"
|
||||
autocomplete="off"
|
||||
:disabled="!overrideWindowSettings || fullscreen"
|
||||
:disabled="!overrideWindowSettings || fullscreenSetting"
|
||||
type="number"
|
||||
class="input"
|
||||
placeholder="Enter height..."
|
||||
@@ -352,7 +352,6 @@ import {
|
||||
HammerIcon,
|
||||
DownloadIcon,
|
||||
ModalConfirm,
|
||||
Toggle,
|
||||
} from 'omorphia'
|
||||
import { Multiselect } from 'vue-multiselect'
|
||||
import { useRouter } from 'vue-router'
|
||||
@@ -446,12 +445,12 @@ const overrideMemorySettings = ref(!!props.instance.memory)
|
||||
const memory = ref(props.instance.memory ?? globalSettings.memory)
|
||||
const maxMemory = Math.floor((await get_max_memory().catch(handleError)) / 1024)
|
||||
|
||||
const overrideWindowSettings = ref(!!props.instance.resolution)
|
||||
const overrideWindowSettings = ref(!!props.instance.resolution || !!props.instance.fullscreen)
|
||||
const resolution = ref(props.instance.resolution ?? globalSettings.game_resolution)
|
||||
const overrideHooks = ref(!!props.instance.hooks)
|
||||
const hooks = ref(props.instance.hooks ?? globalSettings.hooks)
|
||||
|
||||
const fullscreen = ref(props.instance.fullscreen)
|
||||
const fullscreenSetting = ref(!!props.instance.fullscreen)
|
||||
|
||||
watch(
|
||||
[
|
||||
@@ -468,7 +467,7 @@ watch(
|
||||
memory,
|
||||
overrideWindowSettings,
|
||||
resolution,
|
||||
fullscreen,
|
||||
fullscreenSetting,
|
||||
overrideHooks,
|
||||
hooks,
|
||||
],
|
||||
@@ -514,9 +513,9 @@ watch(
|
||||
}
|
||||
|
||||
if (overrideWindowSettings.value) {
|
||||
editProfile.fullscreen = fullscreen.value
|
||||
editProfile.fullscreen = fullscreenSetting.value
|
||||
|
||||
if (!fullscreen.value) {
|
||||
if (!fullscreenSetting.value) {
|
||||
editProfile.resolution = resolution.value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user