You've already forked AstralRinth
forked from didirus/AstralRinth
381ea51cce
* fix: files.vue bugs before styling changes * feat: move files tab to shared layout structure * fix: qa * fix: qa * fix: bugs * fix: lint * fix: admonition cleanup with progress + actions * fix: cleanup * fix: modals * fix: admon title * fix: i18n standard * fix: lint + i18n pass * fix: remove transition * fix: type errors * feat: files tab in app * fix: qa * fix: backup item minmax * fix: use ContentPageHeader for server panel * fix: lint * fix: lint * fix: lint * feat: page leave safety * fix: lint * fix: cargo fmt fix * fix: blank in prod * fix: content card table stuff * Revert "fix: blank in prod" This reverts commit 74758fe185cf85a4a20355857f889cb091b97ace. * fix: import * feat: browse worlds/servers flow * fix: worlds tab parity with content tab * fix: perf bug + shader filter pill copy * feat: singleplayer filter * fix: ordering * fix: breadcrumbs * fix: lint * fix: qa * feat: store server proj id when adding to a non-linked instance * fix: lint * fix: i18n + qa * fix: conflict * qa: already installed modal + placeholders not server-specific * fix: qa * fix: add + edit server modals * fix: qa * fix: security * fix: devin flags * fix: lint * chore: change file to break build cache * fix: admon * fix: import path stuff * feat: qa * fix: fmt fmt idiot --------- Signed-off-by: Calum H. <calum@modrinth.com>
162 lines
4.2 KiB
Vue
162 lines
4.2 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
Checkbox,
|
|
defineMessages,
|
|
injectNotificationManager,
|
|
StyledInput,
|
|
Toggle,
|
|
useVIntl,
|
|
} from '@modrinth/ui'
|
|
import { computed, type Ref, ref, watch } from 'vue'
|
|
|
|
import { edit } from '@/helpers/profile'
|
|
import { get } from '@/helpers/settings.ts'
|
|
import { injectInstanceSettings } from '@/providers/instance-settings'
|
|
|
|
import type { AppSettings } from '../../../helpers/types'
|
|
|
|
const { handleError } = injectNotificationManager()
|
|
const { formatMessage } = useVIntl()
|
|
|
|
const { instance } = injectInstanceSettings()
|
|
|
|
const globalSettings = (await get().catch(handleError)) as AppSettings
|
|
|
|
const overrideWindowSettings = ref(
|
|
!!instance.value.game_resolution || !!instance.value.force_fullscreen,
|
|
)
|
|
const resolution: Ref<[number, number]> = ref(
|
|
instance.value.game_resolution ?? (globalSettings.game_resolution.slice() as [number, number]),
|
|
)
|
|
const fullscreenSetting: Ref<boolean> = ref(
|
|
instance.value.force_fullscreen ?? globalSettings.force_fullscreen,
|
|
)
|
|
|
|
const editProfileObject = computed(() => {
|
|
if (!overrideWindowSettings.value) {
|
|
return {
|
|
force_fullscreen: null,
|
|
game_resolution: null,
|
|
}
|
|
}
|
|
return {
|
|
force_fullscreen: fullscreenSetting.value,
|
|
game_resolution: fullscreenSetting.value ? null : resolution.value,
|
|
}
|
|
})
|
|
|
|
watch(
|
|
[overrideWindowSettings, resolution, fullscreenSetting],
|
|
async () => {
|
|
await edit(instance.value.path, editProfileObject.value)
|
|
},
|
|
{ deep: true },
|
|
)
|
|
|
|
const messages = defineMessages({
|
|
customWindowSettings: {
|
|
id: 'instance.settings.tabs.window.custom-window-settings',
|
|
defaultMessage: 'Custom window settings',
|
|
},
|
|
fullscreen: {
|
|
id: 'instance.settings.tabs.window.fullscreen',
|
|
defaultMessage: 'Fullscreen',
|
|
},
|
|
fullscreenDescription: {
|
|
id: 'instance.settings.tabs.window.fullscreen.description',
|
|
defaultMessage: 'Make the game start in full screen when launched (using options.txt).',
|
|
},
|
|
width: {
|
|
id: 'instance.settings.tabs.window.width',
|
|
defaultMessage: 'Width',
|
|
},
|
|
widthDescription: {
|
|
id: 'instance.settings.tabs.window.width.description',
|
|
defaultMessage: 'The width of the game window when launched.',
|
|
},
|
|
enterWidth: {
|
|
id: 'instance.settings.tabs.window.width.enter',
|
|
defaultMessage: 'Enter width...',
|
|
},
|
|
height: {
|
|
id: 'instance.settings.tabs.window.height',
|
|
defaultMessage: 'Height',
|
|
},
|
|
heightDescription: {
|
|
id: 'instance.settings.tabs.window.height.description',
|
|
defaultMessage: 'The height of the game window when launched.',
|
|
},
|
|
enterHeight: {
|
|
id: 'instance.settings.tabs.window.height.enter',
|
|
defaultMessage: 'Enter height...',
|
|
},
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<Checkbox
|
|
v-model="overrideWindowSettings"
|
|
:label="formatMessage(messages.customWindowSettings)"
|
|
/>
|
|
<div class="mt-2 flex items-center gap-4 justify-between">
|
|
<div>
|
|
<h2 class="m-0 mb-1 text-lg font-extrabold text-contrast">
|
|
{{ formatMessage(messages.fullscreen) }}
|
|
</h2>
|
|
<p class="m-0">
|
|
{{ formatMessage(messages.fullscreenDescription) }}
|
|
</p>
|
|
</div>
|
|
<Toggle
|
|
id="fullscreen"
|
|
:model-value="overrideWindowSettings ? fullscreenSetting : globalSettings.force_fullscreen"
|
|
:disabled="!overrideWindowSettings"
|
|
@update:model-value="
|
|
(e) => {
|
|
fullscreenSetting = e
|
|
}
|
|
"
|
|
/>
|
|
</div>
|
|
|
|
<div class="mt-4 flex items-center gap-4 justify-between">
|
|
<div>
|
|
<h2 class="m-0 mb-1 text-lg font-extrabold text-contrast">
|
|
{{ formatMessage(messages.width) }}
|
|
</h2>
|
|
<p class="m-0">
|
|
{{ formatMessage(messages.widthDescription) }}
|
|
</p>
|
|
</div>
|
|
<StyledInput
|
|
id="width"
|
|
v-model="resolution[0]"
|
|
autocomplete="off"
|
|
:disabled="!overrideWindowSettings || fullscreenSetting"
|
|
type="number"
|
|
:placeholder="formatMessage(messages.enterWidth)"
|
|
/>
|
|
</div>
|
|
|
|
<div class="mt-4 flex items-center gap-4 justify-between">
|
|
<div>
|
|
<h2 class="m-0 mb-1 text-lg font-extrabold text-contrast">
|
|
{{ formatMessage(messages.height) }}
|
|
</h2>
|
|
<p class="m-0">
|
|
{{ formatMessage(messages.heightDescription) }}
|
|
</p>
|
|
</div>
|
|
<StyledInput
|
|
id="height"
|
|
v-model="resolution[1]"
|
|
autocomplete="off"
|
|
:disabled="!overrideWindowSettings || fullscreenSetting"
|
|
type="number"
|
|
:placeholder="formatMessage(messages.enterHeight)"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|