Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f3ab9d79b | ||
|
|
037bff2db3 | ||
|
|
1406f7ded3 | ||
|
|
c54acd2e36 | ||
|
|
1b6534ad8c | ||
|
|
2477fc62ca | ||
|
|
3f6678ac2f | ||
|
|
e36329ff0e | ||
|
|
c718d75774 | ||
|
|
544611738d | ||
|
|
403a883e0b | ||
|
|
53c749aaea | ||
|
|
addc31c7c1 | ||
|
|
25978bcd8f | ||
|
|
117eaad9ff | ||
|
|
ae2992d7f8 |
No files matched your search
@@ -12,7 +12,7 @@ on:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
issues: write
|
issues: write
|
||||||
pull-requests: read
|
pull-requests: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
comment:
|
comment:
|
||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
issues: write
|
issues: write
|
||||||
pull-requests: read
|
pull-requests: write
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -22,5 +22,5 @@ jobs:
|
|||||||
node-version-file: .nvmrc
|
node-version-file: .nvmrc
|
||||||
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
|
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
|
||||||
- uses: cargo-bins/cargo-binstall@dc19f1e48450eefe5a29b8da6c6b00a87d730b37 # v1.18.1
|
- uses: cargo-bins/cargo-binstall@dc19f1e48450eefe5a29b8da6c6b00a87d730b37 # v1.18.1
|
||||||
- run: cargo binstall --no-confirm cargo-shear
|
- run: cargo binstall --no-confirm cargo-shear@1.13.4
|
||||||
- run: cargo shear
|
- run: cargo shear
|
||||||
@@ -95,6 +95,7 @@ import NavRail from '@/components/ui/NavRail.vue'
|
|||||||
import OnboardingOverlay from '@/components/ui/onboarding/OnboardingOverlay.vue'
|
import OnboardingOverlay from '@/components/ui/onboarding/OnboardingOverlay.vue'
|
||||||
import QuickInstanceSwitcher from '@/components/ui/QuickInstanceSwitcher.vue'
|
import QuickInstanceSwitcher from '@/components/ui/QuickInstanceSwitcher.vue'
|
||||||
import SkinSiteSessionFrame from '@/components/ui/SkinSiteSessionFrame.vue'
|
import SkinSiteSessionFrame from '@/components/ui/SkinSiteSessionFrame.vue'
|
||||||
|
import RemoteAnnouncements from '@/components/ui/RemoteAnnouncements.vue'
|
||||||
import StartupAnnouncementModal from '@/components/ui/StartupAnnouncementModal.vue'
|
import StartupAnnouncementModal from '@/components/ui/StartupAnnouncementModal.vue'
|
||||||
import SplashScreen from '@/components/ui/SplashScreen.vue'
|
import SplashScreen from '@/components/ui/SplashScreen.vue'
|
||||||
import WindowControls from '@/components/ui/WindowControls.vue'
|
import WindowControls from '@/components/ui/WindowControls.vue'
|
||||||
@@ -2227,6 +2228,7 @@ provideAppUpdateDownloadProgress(appUpdateDownload)
|
|||||||
<SkinSiteSessionFrame v-if="stateInitialized" />
|
<SkinSiteSessionFrame v-if="stateInitialized" />
|
||||||
<InstancePlayerModal v-if="stateInitialized" />
|
<InstancePlayerModal v-if="stateInitialized" />
|
||||||
<StartupAnnouncementModal ref="startupAnnouncementModal" />
|
<StartupAnnouncementModal ref="startupAnnouncementModal" />
|
||||||
|
<RemoteAnnouncements :ready="stateInitialized && !showOnboarding && !stateFailed" />
|
||||||
<div id="teleports"></div>
|
<div id="teleports"></div>
|
||||||
<div
|
<div
|
||||||
v-if="stateInitialized && themeStore.customBackgroundPath && !themeStore.transparentBackground"
|
v-if="stateInitialized && themeStore.customBackgroundPath && !themeStore.transparentBackground"
|
||||||
|
|||||||
@@ -41,6 +41,16 @@ export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
|
|||||||
'zh-CN': 'Starlight Launcher 1.0.2-beta4',
|
'zh-CN': 'Starlight Launcher 1.0.2-beta4',
|
||||||
},
|
},
|
||||||
changes: {
|
changes: {
|
||||||
|
added: [
|
||||||
|
{
|
||||||
|
'en-US': 'Added armor and armor-trim rendering to the skin preview, letting you try on armor pieces and trim patterns directly in the skin editor.',
|
||||||
|
'zh-CN': '皮肤预览新增盔甲与盔甲纹饰渲染,可在皮肤编辑器内直接试穿各部位盔甲并调整纹饰图案。',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'en-US': 'Armor preview selections in the skin editor are now saved locally, so they persist across sessions.',
|
||||||
|
'zh-CN': '皮肤编辑器中的盔甲预览选择现在会保存在本地,跨会话保留。',
|
||||||
|
},
|
||||||
|
],
|
||||||
changed: [
|
changed: [
|
||||||
{
|
{
|
||||||
'en-US': 'Improved download scheduling to reduce concurrency automatically when tasks are waiting for capacity, making large Minecraft installations more reliable on constrained connections.',
|
'en-US': 'Improved download scheduling to reduce concurrency automatically when tasks are waiting for capacity, making large Minecraft installations more reliable on constrained connections.',
|
||||||
|
|||||||
@@ -67,6 +67,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
<ButtonStyled
|
||||||
|
v-tooltip="formatMessage(messages.announcements)"
|
||||||
|
type="transparent"
|
||||||
|
circular
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
:aria-label="formatMessage(messages.announcements)"
|
||||||
|
class="relative"
|
||||||
|
@click="openAnnouncementCenter"
|
||||||
|
>
|
||||||
|
<NewspaperIcon />
|
||||||
|
<span
|
||||||
|
v-if="announcementUnreadCount"
|
||||||
|
class="absolute right-0 top-0 size-2 rounded-full bg-red ring-2 ring-bg-raised"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</ButtonStyled>
|
||||||
<ButtonStyled
|
<ButtonStyled
|
||||||
v-if="!isDownloadsPage && hasActiveDownloads && !hasVisibleActiveDownloadToasts"
|
v-if="!isDownloadsPage && hasActiveDownloads && !hasVisibleActiveDownloadToasts"
|
||||||
color="brand"
|
color="brand"
|
||||||
@@ -190,6 +207,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
BellIcon,
|
BellIcon,
|
||||||
|
NewspaperIcon,
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
DropdownIcon,
|
DropdownIcon,
|
||||||
OnlineIndicatorIcon,
|
OnlineIndicatorIcon,
|
||||||
@@ -211,7 +229,7 @@ import {
|
|||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||||
import { Dropdown } from 'floating-vue'
|
import { Dropdown } from 'floating-vue'
|
||||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
import AppUpdateButton from '@/components/ui/app-update-button/index.vue'
|
import AppUpdateButton from '@/components/ui/app-update-button/index.vue'
|
||||||
@@ -222,6 +240,10 @@ import { get_many as getInstances } from '@/helpers/instance'
|
|||||||
import { get_all as getRunningProcesses, kill as killProcess } from '@/helpers/process'
|
import { get_all as getRunningProcesses, kill as killProcess } from '@/helpers/process'
|
||||||
import type { LoadingBar } from '@/helpers/state'
|
import type { LoadingBar } from '@/helpers/state'
|
||||||
import { progress_bars_list } from '@/helpers/state'
|
import { progress_bars_list } from '@/helpers/state'
|
||||||
|
import {
|
||||||
|
OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT,
|
||||||
|
REMOTE_ANNOUNCEMENTS_UPDATED_EVENT,
|
||||||
|
} from '@/helpers/remote-announcements'
|
||||||
import type { GameInstance } from '@/helpers/types'
|
import type { GameInstance } from '@/helpers/types'
|
||||||
import { downloadBarTypes, injectDownloadManager } from '@/providers/download-manager'
|
import { downloadBarTypes, injectDownloadManager } from '@/providers/download-manager'
|
||||||
|
|
||||||
@@ -231,6 +253,25 @@ const popupNotificationManager = injectPopupNotificationManager()
|
|||||||
const downloadManager = injectDownloadManager()
|
const downloadManager = injectDownloadManager()
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|
||||||
|
const announcementUnreadCount = ref(0)
|
||||||
|
|
||||||
|
function openAnnouncementCenter() {
|
||||||
|
window.dispatchEvent(new CustomEvent(OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT))
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateAnnouncementCount(event: Event) {
|
||||||
|
const detail = (event as CustomEvent<{ unreadKeys?: string[] }>).detail
|
||||||
|
announcementUnreadCount.value = detail?.unreadKeys?.length ?? 0
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
window.addEventListener(REMOTE_ANNOUNCEMENTS_UPDATED_EVENT, updateAnnouncementCount)
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener(REMOTE_ANNOUNCEMENTS_UPDATED_EVENT, updateAnnouncementCount)
|
||||||
|
})
|
||||||
|
|
||||||
type NotificationHistoryItem = {
|
type NotificationHistoryItem = {
|
||||||
key: string
|
key: string
|
||||||
createdAt?: number
|
createdAt?: number
|
||||||
@@ -370,6 +411,10 @@ const messages = defineMessages({
|
|||||||
id: 'app.action-bar.notifications',
|
id: 'app.action-bar.notifications',
|
||||||
defaultMessage: 'Notifications',
|
defaultMessage: 'Notifications',
|
||||||
},
|
},
|
||||||
|
announcements: {
|
||||||
|
id: 'app.action-bar.announcements',
|
||||||
|
defaultMessage: 'Announcements',
|
||||||
|
},
|
||||||
clearNotifications: {
|
clearNotifications: {
|
||||||
id: 'app.action-bar.notifications.clear',
|
id: 'app.action-bar.notifications.clear',
|
||||||
defaultMessage: 'Clear all',
|
defaultMessage: 'Clear all',
|
||||||
|
|||||||
@@ -0,0 +1,388 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
commonMessages,
|
||||||
|
defineMessages,
|
||||||
|
NewModal,
|
||||||
|
useModalStack,
|
||||||
|
useVIntl,
|
||||||
|
} from '@modrinth/ui'
|
||||||
|
import { renderString } from '@modrinth/utils'
|
||||||
|
import { openUrl } from '@tauri-apps/plugin-opener'
|
||||||
|
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
||||||
|
|
||||||
|
import {
|
||||||
|
announcementKey,
|
||||||
|
isAnnouncementActive,
|
||||||
|
OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT,
|
||||||
|
parseAnnouncements,
|
||||||
|
REMOTE_ANNOUNCEMENTS_UPDATED_EVENT,
|
||||||
|
type RemoteAnnouncement,
|
||||||
|
safeAnnouncementUrl,
|
||||||
|
} from '@/helpers/remote-announcements'
|
||||||
|
|
||||||
|
const props = defineProps<{ ready: boolean; previewOnly?: boolean }>()
|
||||||
|
const { formatMessage } = useVIntl()
|
||||||
|
const { hasModal } = useModalStack()
|
||||||
|
const messages = defineMessages({
|
||||||
|
view: { id: 'app.remote-announcements.view', defaultMessage: 'View announcement' },
|
||||||
|
unread: { id: 'app.remote-announcements.unread', defaultMessage: 'Unread' },
|
||||||
|
readAll: {
|
||||||
|
id: 'app.remote-announcements.read-all',
|
||||||
|
defaultMessage: 'Mark all announcements as read',
|
||||||
|
},
|
||||||
|
centerTitle: { id: 'app.remote-announcements.center-title', defaultMessage: 'Announcements' },
|
||||||
|
empty: { id: 'app.remote-announcements.empty', defaultMessage: 'No announcements' },
|
||||||
|
previewTitle: {
|
||||||
|
id: 'app.remote-announcements.preview-title',
|
||||||
|
defaultMessage: 'Announcement style preview',
|
||||||
|
},
|
||||||
|
previewSummary: {
|
||||||
|
id: 'app.remote-announcements.preview-summary',
|
||||||
|
defaultMessage:
|
||||||
|
'This is a local preview. Select View announcement to preview the full Markdown content.',
|
||||||
|
},
|
||||||
|
previewContent: {
|
||||||
|
id: 'app.remote-announcements.preview-content',
|
||||||
|
defaultMessage:
|
||||||
|
'## Announcement preview\n\nThis is **sample content**, not a published announcement.\n\n- Supports headings, lists, and links\n- Close buttons are always available\n\n> Previewing does not change real announcement read status.\n\n| Type | Display |\n| --- | --- |\n| Modal | Full Markdown content |\n| Popup | Summary, then full content |\n\n[Visit the website](https://skin.starlight.cool/)',
|
||||||
|
},
|
||||||
|
previewAction: { id: 'app.remote-announcements.preview-action', defaultMessage: 'Visit website' },
|
||||||
|
})
|
||||||
|
const modal = ref<InstanceType<typeof NewModal>>()
|
||||||
|
const selected = ref<RemoteAnnouncement | null>(null)
|
||||||
|
const active = ref(false)
|
||||||
|
const centerOpen = ref(false)
|
||||||
|
const startupNotice = ref<RemoteAnnouncement | null>(null)
|
||||||
|
const html = computed(() => renderString(selected.value?.content ?? ''))
|
||||||
|
const stateKey = 'starlight-remote-announcements-v2'
|
||||||
|
const read = reactive(new Set<string>())
|
||||||
|
const queuedThisSession = new Set<string>()
|
||||||
|
const startupNotified = new Set<string>()
|
||||||
|
let items: RemoteAnnouncement[] = []
|
||||||
|
let pending: RemoteAnnouncement[] = []
|
||||||
|
let cacheKey = ''
|
||||||
|
let cacheLoaded = false
|
||||||
|
let disposed = false
|
||||||
|
let interval: ReturnType<typeof setInterval> | undefined
|
||||||
|
let advanceTimer: ReturnType<typeof setTimeout> | undefined
|
||||||
|
|
||||||
|
function persist() {
|
||||||
|
if (props.previewOnly) return
|
||||||
|
try {
|
||||||
|
localStorage.setItem(
|
||||||
|
stateKey,
|
||||||
|
JSON.stringify({
|
||||||
|
read: [...read].slice(-1000),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
// localStorage may be unavailable (private mode / quota)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function emitState() {
|
||||||
|
window.dispatchEvent(
|
||||||
|
new CustomEvent(REMOTE_ANNOUNCEMENTS_UPDATED_EVENT, {
|
||||||
|
detail: {
|
||||||
|
items,
|
||||||
|
unreadKeys: items.filter((item) => !read.has(announcementKey(item))).map(announcementKey),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
function openCenter(item?: RemoteAnnouncement) {
|
||||||
|
if (!props.ready || disposed) return
|
||||||
|
centerOpen.value = true
|
||||||
|
if (item) {
|
||||||
|
startupNotice.value = null
|
||||||
|
selectAnnouncement(item)
|
||||||
|
} else if (!selected.value && items.length) {
|
||||||
|
selectAnnouncement(items[0])
|
||||||
|
}
|
||||||
|
void nextTick(() => modal.value?.show())
|
||||||
|
}
|
||||||
|
function handleOpenCenter() {
|
||||||
|
if (props.previewOnly) return
|
||||||
|
openCenter()
|
||||||
|
}
|
||||||
|
async function show(item: RemoteAnnouncement) {
|
||||||
|
if (
|
||||||
|
disposed ||
|
||||||
|
!props.ready ||
|
||||||
|
!isAnnouncementActive(item) ||
|
||||||
|
(hasModal.value && !active.value && !centerOpen.value)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
centerOpen.value = true
|
||||||
|
active.value = true
|
||||||
|
selectAnnouncement(item)
|
||||||
|
await nextTick()
|
||||||
|
if (!disposed) modal.value?.show()
|
||||||
|
}
|
||||||
|
function selectAnnouncement(item: RemoteAnnouncement) {
|
||||||
|
selected.value = item
|
||||||
|
const key = announcementKey(item)
|
||||||
|
read.add(key)
|
||||||
|
pending = pending.filter((entry) => announcementKey(entry) !== key)
|
||||||
|
persist()
|
||||||
|
emitState()
|
||||||
|
}
|
||||||
|
function markAllRead() {
|
||||||
|
for (const item of items) {
|
||||||
|
read.add(announcementKey(item))
|
||||||
|
}
|
||||||
|
pending = []
|
||||||
|
persist()
|
||||||
|
emitState()
|
||||||
|
}
|
||||||
|
function advance() {
|
||||||
|
if (disposed || !props.ready || hasModal.value || active.value) return
|
||||||
|
const next = pending.shift()
|
||||||
|
if (next) {
|
||||||
|
void show(next)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for (const item of items) {
|
||||||
|
const key = announcementKey(item)
|
||||||
|
if (
|
||||||
|
item.type === 'notification' &&
|
||||||
|
!startupNotified.has(key) &&
|
||||||
|
!read.has(key) &&
|
||||||
|
isAnnouncementActive(item)
|
||||||
|
) {
|
||||||
|
startupNotice.value = item
|
||||||
|
startupNotified.add(key)
|
||||||
|
setTimeout(() => {
|
||||||
|
if (startupNotice.value === item) {
|
||||||
|
startupNotice.value = null
|
||||||
|
advance()
|
||||||
|
}
|
||||||
|
}, 8000)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function closed() {
|
||||||
|
active.value = false
|
||||||
|
centerOpen.value = false
|
||||||
|
if (advanceTimer) clearTimeout(advanceTimer)
|
||||||
|
advanceTimer = setTimeout(advance, 350)
|
||||||
|
}
|
||||||
|
function sync(next: RemoteAnnouncement[], fresh: boolean) {
|
||||||
|
items = next.filter((item) => isAnnouncementActive(item))
|
||||||
|
const keys = new Set(items.map(announcementKey))
|
||||||
|
pending = pending.filter((item) => keys.has(announcementKey(item)))
|
||||||
|
if (selected.value && !keys.has(announcementKey(selected.value))) selected.value = null
|
||||||
|
emitState()
|
||||||
|
if (fresh) {
|
||||||
|
for (const item of items) {
|
||||||
|
const key = announcementKey(item)
|
||||||
|
if (
|
||||||
|
item.type === 'modal' &&
|
||||||
|
!queuedThisSession.has(key) &&
|
||||||
|
(!read.has(key) || item.priority === 'critical')
|
||||||
|
) {
|
||||||
|
queuedThisSession.add(key)
|
||||||
|
pending.push(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
advance()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function loadCache() {
|
||||||
|
if (cacheLoaded || !cacheKey) return
|
||||||
|
cacheLoaded = true
|
||||||
|
try {
|
||||||
|
const cached = JSON.parse(localStorage.getItem(cacheKey) ?? 'null')
|
||||||
|
if (cached && typeof cached.savedAt === 'number' && Date.now() - cached.savedAt < 86400000) {
|
||||||
|
const parsed = parseAnnouncements(cached.items)
|
||||||
|
if (parsed) sync(parsed, false)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Ignore malformed or expired cache payloads
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function refresh() {
|
||||||
|
// Remote fetching is disabled until Starlight has its own announcements API.
|
||||||
|
// We still load any previously cached items so the center has content to show.
|
||||||
|
if (disposed) return
|
||||||
|
loadCache()
|
||||||
|
}
|
||||||
|
async function openLink(value: unknown) {
|
||||||
|
const url = safeAnnouncementUrl(value)
|
||||||
|
if (!url) return
|
||||||
|
try {
|
||||||
|
await openUrl(url)
|
||||||
|
} catch {
|
||||||
|
// Opener may reject unknown schemes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function contentClick(event: MouseEvent) {
|
||||||
|
const link = event.target instanceof Element ? event.target.closest('a') : null
|
||||||
|
if (!link) return
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
void openLink(link.getAttribute('href'))
|
||||||
|
}
|
||||||
|
function preview(type: RemoteAnnouncement['type'], withAction = false) {
|
||||||
|
if (!props.previewOnly || !props.ready || hasModal.value || disposed) return
|
||||||
|
const now = new Date().toISOString()
|
||||||
|
const item: RemoteAnnouncement = {
|
||||||
|
id: 'local-preview-' + type,
|
||||||
|
title: formatMessage(messages.previewTitle),
|
||||||
|
summary: formatMessage(messages.previewSummary),
|
||||||
|
content: formatMessage(messages.previewContent),
|
||||||
|
type,
|
||||||
|
priority: 'normal',
|
||||||
|
starts_at: now,
|
||||||
|
ends_at: null,
|
||||||
|
published_at: now,
|
||||||
|
action_label: withAction ? formatMessage(messages.previewAction) : null,
|
||||||
|
action_url: withAction ? 'https://skin.starlight.cool/' : null,
|
||||||
|
}
|
||||||
|
read.clear()
|
||||||
|
queuedThisSession.clear()
|
||||||
|
sync([item], true)
|
||||||
|
}
|
||||||
|
defineExpose({ preview })
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.previewOnly) return
|
||||||
|
try {
|
||||||
|
const saved = JSON.parse(localStorage.getItem(stateKey) ?? 'null')
|
||||||
|
if (saved && Array.isArray(saved.read))
|
||||||
|
for (const key of saved.read) if (typeof key === 'string') read.add(key)
|
||||||
|
} catch {
|
||||||
|
// Ignore malformed local read-state
|
||||||
|
}
|
||||||
|
window.addEventListener(OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT, handleOpenCenter)
|
||||||
|
const start = () => {
|
||||||
|
if (disposed) return
|
||||||
|
void refresh()
|
||||||
|
interval = setInterval(() => {
|
||||||
|
sync(items, false)
|
||||||
|
advance()
|
||||||
|
}, 15000)
|
||||||
|
}
|
||||||
|
// Defer the startup request until after first paint.
|
||||||
|
if (typeof requestIdleCallback === 'function') {
|
||||||
|
requestIdleCallback(start, { timeout: 2000 })
|
||||||
|
} else {
|
||||||
|
setTimeout(start, 500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
watch([() => props.ready, hasModal], () => {
|
||||||
|
if (advanceTimer) clearTimeout(advanceTimer)
|
||||||
|
advanceTimer = setTimeout(advance, 350)
|
||||||
|
})
|
||||||
|
onUnmounted(() => {
|
||||||
|
disposed = true
|
||||||
|
if (interval) clearInterval(interval)
|
||||||
|
if (advanceTimer) clearTimeout(advanceTimer)
|
||||||
|
window.removeEventListener(OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT, handleOpenCenter)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="startupNotice"
|
||||||
|
class="fixed right-4 top-16 z-50 w-[22rem] max-w-[calc(100vw-2rem)] rounded-xl border border-surface-5 bg-surface-3 p-3 shadow-lg"
|
||||||
|
>
|
||||||
|
<button class="w-full text-left" @click="startupNotice && openCenter(startupNotice)">
|
||||||
|
<div class="mb-1 text-xs font-semibold uppercase text-brand">
|
||||||
|
{{ formatMessage(messages.unread) }}
|
||||||
|
</div>
|
||||||
|
<div class="font-semibold text-[var(--color-text-primary)]">{{ startupNotice.title }}</div>
|
||||||
|
<div
|
||||||
|
v-if="startupNotice.summary"
|
||||||
|
class="mt-1 line-clamp-2 text-sm text-[var(--color-text-tertiary)]"
|
||||||
|
>
|
||||||
|
{{ startupNotice.summary }}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<NewModal
|
||||||
|
ref="modal"
|
||||||
|
:header="formatMessage(messages.centerTitle)"
|
||||||
|
:on-hide="closed"
|
||||||
|
max-width="80vw"
|
||||||
|
width="80vw"
|
||||||
|
max-content-height="calc(80vh - 8rem)"
|
||||||
|
scrollable
|
||||||
|
>
|
||||||
|
<div class="flex h-[calc(80vh-8rem)] min-h-0 gap-3">
|
||||||
|
<aside class="flex min-h-0 w-[32%] min-w-[14rem] flex-col border-r border-surface-5 pr-3">
|
||||||
|
<div class="mb-2 flex items-center justify-between">
|
||||||
|
<span class="font-semibold text-[var(--color-text-primary)]">{{
|
||||||
|
formatMessage(messages.centerTitle)
|
||||||
|
}}</span>
|
||||||
|
<Button
|
||||||
|
v-if="items.some((item) => !read.has(announcementKey(item)))"
|
||||||
|
@click="markAllRead"
|
||||||
|
>{{ formatMessage(messages.readAll) }}</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="!items.length"
|
||||||
|
class="py-8 text-center text-sm text-[var(--color-text-tertiary)]"
|
||||||
|
>
|
||||||
|
{{ formatMessage(messages.empty) }}
|
||||||
|
</div>
|
||||||
|
<div v-else class="flex min-h-0 flex-col gap-1 overflow-auto">
|
||||||
|
<button
|
||||||
|
v-for="item in items"
|
||||||
|
:key="announcementKey(item)"
|
||||||
|
class="flex items-start gap-2 rounded-lg p-2 text-left hover:bg-surface-4"
|
||||||
|
:class="{
|
||||||
|
'bg-surface-4': selected && announcementKey(selected) === announcementKey(item),
|
||||||
|
}"
|
||||||
|
@click="selectAnnouncement(item)"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="mt-1.5 size-2 shrink-0 rounded-full"
|
||||||
|
:class="read.has(announcementKey(item)) ? 'opacity-0' : 'bg-red'"
|
||||||
|
/>
|
||||||
|
<span class="min-w-0 flex-1">
|
||||||
|
<span class="block truncate font-medium text-[var(--color-text-primary)]">{{
|
||||||
|
item.title
|
||||||
|
}}</span>
|
||||||
|
<span class="block line-clamp-2 text-xs text-[var(--color-text-tertiary)]">{{
|
||||||
|
item.summary || item.content
|
||||||
|
}}</span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
<section v-if="selected" class="min-h-0 min-w-0 flex-1 overflow-auto px-1">
|
||||||
|
<h2 class="mb-4 text-xl font-semibold text-[var(--color-text-primary)]">
|
||||||
|
{{ selected.title }}
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
class="markdown-body break-words"
|
||||||
|
@click="contentClick"
|
||||||
|
@auxclick="contentClick"
|
||||||
|
v-html="html"
|
||||||
|
/>
|
||||||
|
<div class="mt-4 flex justify-end">
|
||||||
|
<Button
|
||||||
|
v-if="selected.action_url && selected.action_label"
|
||||||
|
type="colored"
|
||||||
|
color="brand"
|
||||||
|
@click="openLink(selected.action_url)"
|
||||||
|
>{{ selected.action_label }}</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="flex flex-1 items-center justify-center text-sm text-[var(--color-text-tertiary)]"
|
||||||
|
>
|
||||||
|
{{ formatMessage(messages.empty) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template #actions>
|
||||||
|
<div class="flex flex-wrap justify-end gap-2">
|
||||||
|
<Button @click="modal?.hide()">{{ formatMessage(commonMessages.closeButton) }} </Button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NewModal>
|
||||||
|
</template>
|
||||||
@@ -36,24 +36,29 @@ const fullscreenSetting: Ref<boolean> = ref(
|
|||||||
instance.value.force_fullscreen ?? globalSettings.force_fullscreen,
|
instance.value.force_fullscreen ?? globalSettings.force_fullscreen,
|
||||||
)
|
)
|
||||||
const maximizeWindowSetting = ref(instance.value.maximize_window ?? globalSettings.maximize_window)
|
const maximizeWindowSetting = ref(instance.value.maximize_window ?? globalSettings.maximize_window)
|
||||||
|
const windowTitle = ref(instance.value.window_title ?? '')
|
||||||
|
|
||||||
const editInstanceObject = computed(() => {
|
const editInstanceObject = computed(() => {
|
||||||
|
const title = windowTitle.value.trim() ? windowTitle.value.trim() : null
|
||||||
if (!overrideWindowSettings.value) {
|
if (!overrideWindowSettings.value) {
|
||||||
return {
|
return {
|
||||||
force_fullscreen: null,
|
force_fullscreen: null,
|
||||||
maximize_window: null,
|
maximize_window: null,
|
||||||
game_resolution: null,
|
game_resolution: null,
|
||||||
|
// The title is independent of the window-size override checkbox.
|
||||||
|
window_title: title,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
force_fullscreen: fullscreenSetting.value,
|
force_fullscreen: fullscreenSetting.value,
|
||||||
maximize_window: maximizeWindowSetting.value,
|
maximize_window: maximizeWindowSetting.value,
|
||||||
game_resolution: fullscreenSetting.value ? null : resolution.value,
|
game_resolution: fullscreenSetting.value ? null : resolution.value,
|
||||||
|
window_title: title,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[overrideWindowSettings, resolution, fullscreenSetting, maximizeWindowSetting],
|
[overrideWindowSettings, resolution, fullscreenSetting, maximizeWindowSetting, windowTitle],
|
||||||
async () => {
|
async () => {
|
||||||
await edit(instance.value.id, editInstanceObject.value)
|
await edit(instance.value.id, editInstanceObject.value)
|
||||||
},
|
},
|
||||||
@@ -109,6 +114,18 @@ const messages = defineMessages({
|
|||||||
id: 'instance.settings.tabs.window.height.enter',
|
id: 'instance.settings.tabs.window.height.enter',
|
||||||
defaultMessage: 'Enter height...',
|
defaultMessage: 'Enter height...',
|
||||||
},
|
},
|
||||||
|
windowTitle: {
|
||||||
|
id: 'instance.settings.tabs.window.window-title',
|
||||||
|
defaultMessage: 'Window title',
|
||||||
|
},
|
||||||
|
windowTitleDescription: {
|
||||||
|
id: 'instance.settings.tabs.window.window-title.description',
|
||||||
|
defaultMessage: 'Customize the Minecraft window title. Leave empty to keep the default.',
|
||||||
|
},
|
||||||
|
enterWindowTitle: {
|
||||||
|
id: 'instance.settings.tabs.window.window-title.enter',
|
||||||
|
defaultMessage: 'Enter window title...',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -200,5 +217,25 @@ const messages = defineMessages({
|
|||||||
:placeholder="formatMessage(messages.enterHeight)"
|
:placeholder="formatMessage(messages.enterHeight)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="globalSettings.custom_window_title_enabled"
|
||||||
|
class="flex items-center gap-4 justify-between"
|
||||||
|
>
|
||||||
|
<div class="flex flex-col gap-1">
|
||||||
|
<h2 class="m-0 inline-flex items-center gap-2 text-lg font-semibold text-contrast">
|
||||||
|
{{ formatMessage(messages.windowTitle) }}
|
||||||
|
</h2>
|
||||||
|
<p class="m-0">
|
||||||
|
{{ formatMessage(messages.windowTitleDescription) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<StyledInput
|
||||||
|
id="window-title"
|
||||||
|
v-model="windowTitle"
|
||||||
|
autocomplete="off"
|
||||||
|
type="text"
|
||||||
|
:placeholder="formatMessage(messages.enterWindowTitle)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -38,6 +38,26 @@ const messages = defineMessages({
|
|||||||
id: 'app.settings.defaults.maximize-window.unsupported',
|
id: 'app.settings.defaults.maximize-window.unsupported',
|
||||||
defaultMessage: 'Not supported on this operating system.',
|
defaultMessage: 'Not supported on this operating system.',
|
||||||
},
|
},
|
||||||
|
windowTitleEnabled: {
|
||||||
|
id: 'app.settings.defaults.window-title.enabled',
|
||||||
|
defaultMessage: 'Custom Minecraft window title',
|
||||||
|
},
|
||||||
|
windowTitleEnabledDescription: {
|
||||||
|
id: 'app.settings.defaults.window-title.enabled-description',
|
||||||
|
defaultMessage: 'Allow instances to customize the Minecraft window title.',
|
||||||
|
},
|
||||||
|
defaultWindowTitle: {
|
||||||
|
id: 'app.settings.defaults.window-title.default',
|
||||||
|
defaultMessage: 'Default window title',
|
||||||
|
},
|
||||||
|
defaultWindowTitleDescription: {
|
||||||
|
id: 'app.settings.defaults.window-title.default-description',
|
||||||
|
defaultMessage: 'Used when an instance leaves its window title empty.',
|
||||||
|
},
|
||||||
|
defaultWindowTitlePlaceholder: {
|
||||||
|
id: 'app.settings.defaults.window-title.default-placeholder',
|
||||||
|
defaultMessage: 'Enter default window title...',
|
||||||
|
},
|
||||||
width: { id: 'app.settings.defaults.width', defaultMessage: 'Width' },
|
width: { id: 'app.settings.defaults.width', defaultMessage: 'Width' },
|
||||||
widthDescription: {
|
widthDescription: {
|
||||||
id: 'app.settings.defaults.width-description',
|
id: 'app.settings.defaults.width-description',
|
||||||
@@ -212,6 +232,36 @@ watch(
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</SettingsRow>
|
</SettingsRow>
|
||||||
|
<SettingsRow>
|
||||||
|
<template #label>
|
||||||
|
<span id="settings-target-defaults-window-title" tabindex="-1">
|
||||||
|
{{ formatMessage(messages.windowTitleEnabled) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #description>{{
|
||||||
|
formatMessage(messages.windowTitleEnabledDescription)
|
||||||
|
}}</template>
|
||||||
|
<template #control>
|
||||||
|
<Toggle id="custom-window-title-enabled" v-model="settings.custom_window_title_enabled" />
|
||||||
|
</template>
|
||||||
|
</SettingsRow>
|
||||||
|
<SettingsRow stacked>
|
||||||
|
<template #label>{{ formatMessage(messages.defaultWindowTitle) }}</template>
|
||||||
|
<template #description>{{
|
||||||
|
formatMessage(messages.defaultWindowTitleDescription)
|
||||||
|
}}</template>
|
||||||
|
<template #control>
|
||||||
|
<StyledInput
|
||||||
|
id="default-window-title"
|
||||||
|
v-model="settings.default_window_title"
|
||||||
|
:disabled="!settings.custom_window_title_enabled"
|
||||||
|
autocomplete="off"
|
||||||
|
type="text"
|
||||||
|
:placeholder="formatMessage(messages.defaultWindowTitlePlaceholder)"
|
||||||
|
wrapper-class="w-full"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</SettingsRow>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
|
||||||
<SettingsSection>
|
<SettingsSection>
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { CheckIcon, RotateCounterClockwiseIcon, XIcon } from '@modrinth/assets'
|
||||||
|
import {
|
||||||
|
type ArmorPreviewConfig,
|
||||||
|
ArmorTrimPanel,
|
||||||
|
Button,
|
||||||
|
defineMessages,
|
||||||
|
useVIntl,
|
||||||
|
} from '@modrinth/ui'
|
||||||
|
import { computed, onMounted, onUnmounted } from 'vue'
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
title: { id: 'app.skins.armor.title', defaultMessage: 'Armour and trims' },
|
||||||
|
description: {
|
||||||
|
id: 'app.skins.armor.description',
|
||||||
|
defaultMessage: 'Try armour and trims on your skin. Nothing is stored until you save it.',
|
||||||
|
},
|
||||||
|
unsaved: { id: 'app.skins.armor.unsaved', defaultMessage: 'Unsaved changes' },
|
||||||
|
resetToSaved: { id: 'app.skins.armor.reset-to-saved', defaultMessage: 'Reset to saved' },
|
||||||
|
restoreDefaults: {
|
||||||
|
id: 'app.skins.armor.restore-defaults',
|
||||||
|
defaultMessage: 'Restore defaults',
|
||||||
|
},
|
||||||
|
save: { id: 'app.skins.armor.save', defaultMessage: 'Save' },
|
||||||
|
close: { id: 'app.skins.armor.close', defaultMessage: 'Close' },
|
||||||
|
})
|
||||||
|
|
||||||
|
const draft = defineModel<ArmorPreviewConfig>({ required: true })
|
||||||
|
const props = defineProps<{
|
||||||
|
saved: ArmorPreviewConfig
|
||||||
|
/** Stable id shared with the toggle so it can point `aria-controls` here. */
|
||||||
|
panelId: string
|
||||||
|
}>()
|
||||||
|
const emit = defineEmits<{
|
||||||
|
save: []
|
||||||
|
reset: []
|
||||||
|
defaults: []
|
||||||
|
close: []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const { formatMessage } = useVIntl()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tab is mounted only while it is showing, so this listens exactly for that
|
||||||
|
* window. It listens in the capture phase because the app's own global
|
||||||
|
* shortcuts listen on `window` the same way, and a bubble-phase listener here
|
||||||
|
* would be skipped as soon as anything closer stopped the event. A modal on top
|
||||||
|
* of the page owns Escape while it is up, and focus sits inside it, so the key
|
||||||
|
* is left to it.
|
||||||
|
*/
|
||||||
|
function handleKeydown(event: KeyboardEvent) {
|
||||||
|
if (event.key !== 'Escape') return
|
||||||
|
if (
|
||||||
|
event.target instanceof Element &&
|
||||||
|
event.target.closest('[role="dialog"], [role="alertdialog"], [aria-modal="true"]')
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => window.addEventListener('keydown', handleKeydown, true))
|
||||||
|
onUnmounted(() => window.removeEventListener('keydown', handleKeydown, true))
|
||||||
|
|
||||||
|
const isDirty = computed(() =>
|
||||||
|
Object.entries(draft.value).some(([slot, piece]) => {
|
||||||
|
const applied = props.saved[slot as keyof ArmorPreviewConfig]
|
||||||
|
return (
|
||||||
|
!applied ||
|
||||||
|
applied.material !== piece.material ||
|
||||||
|
applied.trimPattern !== piece.trimPattern ||
|
||||||
|
applied.trimMaterial !== piece.trimMaterial
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
:id="panelId"
|
||||||
|
role="region"
|
||||||
|
:aria-label="formatMessage(messages.title)"
|
||||||
|
class="flex min-h-[24rem] flex-col gap-4 rounded-2xl border border-solid border-surface-5 bg-surface-2 p-4"
|
||||||
|
>
|
||||||
|
<header class="flex flex-wrap items-start justify-between gap-3">
|
||||||
|
<div class="min-w-0">
|
||||||
|
<h2 class="m-0 text-lg font-bold text-[var(--color-text-primary)]">
|
||||||
|
{{ formatMessage(messages.title) }}
|
||||||
|
</h2>
|
||||||
|
<p class="m-0 mt-1 text-sm leading-6 text-[var(--color-text-tertiary)]">
|
||||||
|
{{ formatMessage(messages.description) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex shrink-0 flex-wrap items-center gap-2">
|
||||||
|
<span v-if="isDirty" class="text-sm font-semibold text-[var(--color-text-tertiary)]">
|
||||||
|
{{ formatMessage(messages.unsaved) }}
|
||||||
|
</span>
|
||||||
|
<Button type="outlined" @click="emit('close')"
|
||||||
|
><XIcon />{{ formatMessage(messages.close) }}</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<ArmorTrimPanel v-model="draft" />
|
||||||
|
|
||||||
|
<footer
|
||||||
|
class="mt-auto flex flex-wrap items-center justify-between gap-2 border-0 border-t border-solid border-surface-5 pt-3"
|
||||||
|
>
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<Button type="outlined" :disabled="!isDirty" @click="emit('reset')"
|
||||||
|
><RotateCounterClockwiseIcon />{{ formatMessage(messages.resetToSaved) }}</Button
|
||||||
|
>
|
||||||
|
<Button type="outlined" @click="emit('defaults')">{{
|
||||||
|
formatMessage(messages.restoreDefaults)
|
||||||
|
}}</Button>
|
||||||
|
</div>
|
||||||
|
<Button type="colored" color="brand" :disabled="!isDirty" @click="emit('save')"
|
||||||
|
><CheckIcon />{{ formatMessage(messages.save) }}</Button
|
||||||
|
>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const { sections = 2, cards = 12 } = defineProps<{
|
||||||
|
sections?: number
|
||||||
|
cards?: number
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<!--
|
||||||
|
Shaped after VirtualSkinSectionList: the same grid breakpoints and card
|
||||||
|
ratio, so the swap to real content does not move anything. Decorative, so
|
||||||
|
it stays out of the accessibility tree.
|
||||||
|
-->
|
||||||
|
<div class="flex flex-col gap-8" aria-hidden="true">
|
||||||
|
<div v-for="section in sections" :key="section" class="flex flex-col gap-4">
|
||||||
|
<div class="h-7 w-44 animate-pulse rounded-lg bg-surface-4" />
|
||||||
|
<div
|
||||||
|
class="grid w-full grid-cols-3 gap-3 min-[1300px]:grid-cols-4 min-[1750px]:grid-cols-5 min-[2050px]:grid-cols-6"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="card in cards"
|
||||||
|
:key="card"
|
||||||
|
class="aspect-[31/40] w-full animate-pulse rounded-[20px] bg-surface-4"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -64,3 +64,6 @@ export function isAnnouncementActive(item: RemoteAnnouncement, now = Date.now())
|
|||||||
export function announcementKey(item: RemoteAnnouncement) {
|
export function announcementKey(item: RemoteAnnouncement) {
|
||||||
return item.id + ':' + item.published_at
|
return item.id + ':' + item.published_at
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const REMOTE_ANNOUNCEMENTS_UPDATED_EVENT = 'starlight:remote-announcements-updated'
|
||||||
|
export const OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT = 'starlight:open-remote-announcement-center'
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import test from 'node:test'
|
||||||
|
|
||||||
|
import { loadSkinArmorPreview, saveSkinArmorPreview } from './skin-armor-preview.ts'
|
||||||
|
|
||||||
|
const originalStorage = Object.getOwnPropertyDescriptor(globalThis, 'localStorage')
|
||||||
|
|
||||||
|
function withStorage(run: (values: Map<string, string>) => void): void {
|
||||||
|
const values = new Map<string, string>()
|
||||||
|
Object.defineProperty(globalThis, 'localStorage', {
|
||||||
|
configurable: true,
|
||||||
|
value: {
|
||||||
|
getItem: (key: string) => values.get(key) ?? null,
|
||||||
|
setItem: (key: string, value: string) => values.set(key, value),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
run(values)
|
||||||
|
} finally {
|
||||||
|
if (originalStorage) Object.defineProperty(globalThis, 'localStorage', originalStorage)
|
||||||
|
else delete (globalThis as { localStorage?: Storage }).localStorage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test('armor preview selections survive storage round trips', () => {
|
||||||
|
withStorage(() => {
|
||||||
|
const config = loadSkinArmorPreview()
|
||||||
|
config.helmet.material = 'diamond'
|
||||||
|
config.helmet.trimPattern = 'sentry'
|
||||||
|
config.helmet.trimMaterial = 'gold'
|
||||||
|
saveSkinArmorPreview(config)
|
||||||
|
|
||||||
|
assert.deepEqual(loadSkinArmorPreview(), config)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test('invalid stored armor values fall back per slot and field', () => {
|
||||||
|
withStorage((values) => {
|
||||||
|
values.set(
|
||||||
|
'axolotl:skin-armor-preview',
|
||||||
|
JSON.stringify({
|
||||||
|
helmet: { material: 'diamond', trimPattern: 'invalid', trimMaterial: 'gold' },
|
||||||
|
boots: { material: 'turtle', trimPattern: 'sentry', trimMaterial: 'invalid' },
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
const config = loadSkinArmorPreview()
|
||||||
|
assert.deepEqual(config.helmet, {
|
||||||
|
material: 'diamond',
|
||||||
|
trimPattern: null,
|
||||||
|
trimMaterial: 'gold',
|
||||||
|
})
|
||||||
|
assert.deepEqual(config.boots, {
|
||||||
|
material: null,
|
||||||
|
trimPattern: 'sentry',
|
||||||
|
trimMaterial: 'iron',
|
||||||
|
})
|
||||||
|
assert.equal(config.chestplate.material, null)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import {
|
||||||
|
ARMOR_SLOTS,
|
||||||
|
ARMOR_TRIM_MATERIALS,
|
||||||
|
ARMOR_TRIM_PATTERNS,
|
||||||
|
armorMaterialsForSlot,
|
||||||
|
type ArmorPreviewConfig,
|
||||||
|
createDefaultArmorPreviewConfig,
|
||||||
|
} from '@modrinth/ui'
|
||||||
|
|
||||||
|
const STORAGE_KEY = 'axolotl:skin-armor-preview'
|
||||||
|
|
||||||
|
function includes<T extends string>(values: readonly T[], value: unknown): value is T {
|
||||||
|
return typeof value === 'string' && values.some((item) => item === value)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadSkinArmorPreview(): ArmorPreviewConfig {
|
||||||
|
const config = createDefaultArmorPreviewConfig()
|
||||||
|
try {
|
||||||
|
const saved = JSON.parse(globalThis.localStorage?.getItem(STORAGE_KEY) ?? 'null')
|
||||||
|
if (!saved || typeof saved !== 'object' || Array.isArray(saved)) return config
|
||||||
|
|
||||||
|
for (const slot of ARMOR_SLOTS) {
|
||||||
|
const piece = saved[slot]
|
||||||
|
if (!piece || typeof piece !== 'object' || Array.isArray(piece)) continue
|
||||||
|
if (piece.material === null || includes(armorMaterialsForSlot(slot), piece.material)) {
|
||||||
|
config[slot].material = piece.material
|
||||||
|
}
|
||||||
|
if (piece.trimPattern === null || includes(ARMOR_TRIM_PATTERNS, piece.trimPattern)) {
|
||||||
|
config[slot].trimPattern = piece.trimPattern
|
||||||
|
}
|
||||||
|
if (includes(ARMOR_TRIM_MATERIALS, piece.trimMaterial)) {
|
||||||
|
config[slot].trimMaterial = piece.trimMaterial
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Invalid or unavailable local storage falls back to a fresh preview.
|
||||||
|
}
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
export function saveSkinArmorPreview(config: ArmorPreviewConfig): void {
|
||||||
|
try {
|
||||||
|
globalThis.localStorage?.setItem(STORAGE_KEY, JSON.stringify(config))
|
||||||
|
} catch {
|
||||||
|
// The preview remains usable when local storage is unavailable.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,6 +55,7 @@ export type GameInstance = {
|
|||||||
force_fullscreen?: boolean
|
force_fullscreen?: boolean
|
||||||
maximize_window?: boolean
|
maximize_window?: boolean
|
||||||
game_resolution?: [number, number]
|
game_resolution?: [number, number]
|
||||||
|
window_title?: string | null
|
||||||
launch_preparation_timeout?: number | null
|
launch_preparation_timeout?: number | null
|
||||||
hooks: Hooks
|
hooks: Hooks
|
||||||
}
|
}
|
||||||
@@ -239,6 +240,8 @@ type AppSettings = {
|
|||||||
force_fullscreen: boolean
|
force_fullscreen: boolean
|
||||||
maximize_window: boolean
|
maximize_window: boolean
|
||||||
game_resolution: [number, number]
|
game_resolution: [number, number]
|
||||||
|
custom_window_title_enabled: boolean
|
||||||
|
default_window_title: string
|
||||||
hide_on_process_start: boolean
|
hide_on_process_start: boolean
|
||||||
enter_lightweight_mode_on_game_launch: boolean
|
enter_lightweight_mode_on_game_launch: boolean
|
||||||
auto_set_java_high_performance_mode: boolean
|
auto_set_java_high_performance_mode: boolean
|
||||||
|
|||||||
@@ -11431,5 +11431,59 @@
|
|||||||
},
|
},
|
||||||
"app.anniversary.banner": {
|
"app.anniversary.banner": {
|
||||||
"message": "Happy {ordinal} Anniversary, Starlight!"
|
"message": "Happy {ordinal} Anniversary, Starlight!"
|
||||||
|
},
|
||||||
|
"instance.settings.tabs.window.window-title": {
|
||||||
|
"message": "Window title"
|
||||||
|
},
|
||||||
|
"instance.settings.tabs.window.window-title.description": {
|
||||||
|
"message": "Customize the Minecraft window title. Leave empty to keep the default."
|
||||||
|
},
|
||||||
|
"instance.settings.tabs.window.window-title.enter": {
|
||||||
|
"message": "Enter window title..."
|
||||||
|
},
|
||||||
|
"app.settings.defaults.window-title.enabled": {
|
||||||
|
"message": "Custom Minecraft window title"
|
||||||
|
},
|
||||||
|
"app.settings.defaults.window-title.enabled-description": {
|
||||||
|
"message": "Allow instances to customize the Minecraft window title."
|
||||||
|
},
|
||||||
|
"app.settings.defaults.window-title.default": {
|
||||||
|
"message": "Default window title"
|
||||||
|
},
|
||||||
|
"app.settings.defaults.window-title.default-description": {
|
||||||
|
"message": "Used when an instance does not provide its own title."
|
||||||
|
},
|
||||||
|
"app.settings.defaults.window-title.default-placeholder": {
|
||||||
|
"message": "Enter the default window title..."
|
||||||
|
},
|
||||||
|
"app.action-bar.announcements": {
|
||||||
|
"message": "Announcements"
|
||||||
|
},
|
||||||
|
"app.remote-announcements.center-title": {
|
||||||
|
"message": "Announcements"
|
||||||
|
},
|
||||||
|
"app.remote-announcements.empty": {
|
||||||
|
"message": "No announcements"
|
||||||
|
},
|
||||||
|
"app.remote-announcements.view": {
|
||||||
|
"message": "View announcement"
|
||||||
|
},
|
||||||
|
"app.remote-announcements.unread": {
|
||||||
|
"message": "Unread"
|
||||||
|
},
|
||||||
|
"app.remote-announcements.read-all": {
|
||||||
|
"message": "Mark all announcements as read"
|
||||||
|
},
|
||||||
|
"app.remote-announcements.preview-title": {
|
||||||
|
"message": "Announcement style preview"
|
||||||
|
},
|
||||||
|
"app.remote-announcements.preview-summary": {
|
||||||
|
"message": "This is a local preview notification. Select View announcement to see the full Markdown content."
|
||||||
|
},
|
||||||
|
"app.remote-announcements.preview-content": {
|
||||||
|
"message": "## Announcement preview\n\nThis is **sample content**, not a published announcement.\n\n- Supports headings, lists, and links\n- Close buttons are always available\n\n> Previewing does not change real announcement read status.\n\n| Type | Display |\n| --- | --- |\n| Modal | Full Markdown content |\n| Popup | Summary, then full content |\n\n[Visit the website](https://skin.starlight.cool/)"
|
||||||
|
},
|
||||||
|
"app.remote-announcements.preview-action": {
|
||||||
|
"message": "Visit website"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11351,5 +11351,16 @@
|
|||||||
"app.settings.synced-options.game-settings.value-off": { "message": "关闭" },
|
"app.settings.synced-options.game-settings.value-off": { "message": "关闭" },
|
||||||
"app.settings.synced-options.game-settings.value-on": { "message": "开启" },
|
"app.settings.synced-options.game-settings.value-on": { "message": "开启" },
|
||||||
"app.settings.synced-options.game-settings.value-unset": { "message": "选择一个值" },
|
"app.settings.synced-options.game-settings.value-unset": { "message": "选择一个值" },
|
||||||
"app.anniversary.banner": { "message": "Starlight {ordinal} 周年快乐!" }
|
"app.anniversary.banner": { "message": "Starlight {ordinal} 周年快乐!" },
|
||||||
}
|
"instance.settings.tabs.window.window-title": { "message": "窗口标题" },
|
||||||
|
"instance.settings.tabs.window.window-title.description": { "message": "自定义 Minecraft 窗口标题。留空则使用默认标题。" },
|
||||||
|
"instance.settings.tabs.window.window-title.enter": { "message": "输入窗口标题..." },
|
||||||
|
"app.settings.defaults.window-title.enabled": { "message": "自定义 Minecraft 窗口标题" },
|
||||||
|
"app.settings.defaults.window-title.enabled-description": { "message": "允许实例自定义 Minecraft 窗口标题。" },
|
||||||
|
"app.settings.defaults.window-title.default": { "message": "默认窗口标题" },
|
||||||
|
"app.settings.defaults.window-title.default-description": { "message": "当实例未提供自己的标题时使用。" },
|
||||||
|
"app.settings.defaults.window-title.default-placeholder": { "message": "输入默认窗口标题..." },
|
||||||
|
"app.action-bar.announcements": { "message": "公告" },
|
||||||
|
"app.remote-announcements.center-title": { "message": "公告" },
|
||||||
|
"app.remote-announcements.empty": { "message": "暂无公告" }
|
||||||
|
}
|
||||||
@@ -9,9 +9,13 @@ import {
|
|||||||
SpinnerIcon,
|
SpinnerIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import {
|
import {
|
||||||
|
type ArmorPreviewConfig,
|
||||||
|
ArmorPreviewControls,
|
||||||
ButtonStyled,
|
ButtonStyled,
|
||||||
|
cloneArmorPreviewConfig,
|
||||||
commonMessages,
|
commonMessages,
|
||||||
ConfirmModal,
|
ConfirmModal,
|
||||||
|
createDefaultArmorPreviewConfig,
|
||||||
defineMessages,
|
defineMessages,
|
||||||
injectNotificationManager,
|
injectNotificationManager,
|
||||||
NavTabs,
|
NavTabs,
|
||||||
@@ -24,12 +28,14 @@ import { invoke } from '@tauri-apps/api/core'
|
|||||||
import type { DragDropEvent } from '@tauri-apps/api/webview'
|
import type { DragDropEvent } from '@tauri-apps/api/webview'
|
||||||
import { getCurrentWebview } from '@tauri-apps/api/webview'
|
import { getCurrentWebview } from '@tauri-apps/api/webview'
|
||||||
import { computedAsync } from '@vueuse/core'
|
import { computedAsync } from '@vueuse/core'
|
||||||
import type { Ref } from 'vue'
|
import type { ComponentPublicInstance, Ref } from 'vue'
|
||||||
import { computed, inject, onMounted, onUnmounted, ref, useTemplateRef, watch } from 'vue'
|
import { computed, inject, onMounted, onUnmounted, ref, useTemplateRef, watch } from 'vue'
|
||||||
import { onBeforeRouteLeave, useRouter } from 'vue-router'
|
import { onBeforeRouteLeave, useRouter } from 'vue-router'
|
||||||
|
|
||||||
import type AccountsCard from '@/components/ui/AccountsCard.vue'
|
import type AccountsCard from '@/components/ui/AccountsCard.vue'
|
||||||
|
import ArmorTrimTab from '@/components/ui/skin/ArmorTrimTab.vue'
|
||||||
import EditSkinModal from '@/components/ui/skin/EditSkinModal.vue'
|
import EditSkinModal from '@/components/ui/skin/EditSkinModal.vue'
|
||||||
|
import SkinListSkeleton from '@/components/ui/skin/SkinListSkeleton.vue'
|
||||||
import VirtualSkinSectionList from '@/components/ui/skin/VirtualSkinSectionList.vue'
|
import VirtualSkinSectionList from '@/components/ui/skin/VirtualSkinSectionList.vue'
|
||||||
import {
|
import {
|
||||||
openSkinSiteLogin,
|
openSkinSiteLogin,
|
||||||
@@ -45,6 +51,7 @@ import { useNetworkStatus } from '@/composables/useNetworkStatus'
|
|||||||
import { check_reachable, get_default_user, users } from '@/helpers/auth'
|
import { check_reachable, get_default_user, users } from '@/helpers/auth'
|
||||||
import type { RenderResult } from '@/helpers/rendering/batch-skin-renderer.ts'
|
import type { RenderResult } from '@/helpers/rendering/batch-skin-renderer.ts'
|
||||||
import { skinBlobUrlMap } from '@/helpers/rendering/batch-skin-renderer.ts'
|
import { skinBlobUrlMap } from '@/helpers/rendering/batch-skin-renderer.ts'
|
||||||
|
import { loadSkinArmorPreview, saveSkinArmorPreview } from '@/helpers/skin-armor-preview'
|
||||||
import type { Cape, Skin, SkinTextureUrl } from '@/helpers/skins.ts'
|
import type { Cape, Skin, SkinTextureUrl } from '@/helpers/skins.ts'
|
||||||
import {
|
import {
|
||||||
determineModelType,
|
determineModelType,
|
||||||
@@ -252,6 +259,8 @@ const editSkinModal = useTemplateRef('editSkinModal')
|
|||||||
const addSkinFileInput = useTemplateRef<HTMLInputElement>('addSkinFileInput')
|
const addSkinFileInput = useTemplateRef<HTMLInputElement>('addSkinFileInput')
|
||||||
const skinSectionList = useTemplateRef<VirtualSkinSectionListExpose>('skinSectionList')
|
const skinSectionList = useTemplateRef<VirtualSkinSectionListExpose>('skinSectionList')
|
||||||
const skinPreviewArea = useTemplateRef<HTMLElement>('skinPreviewArea')
|
const skinPreviewArea = useTemplateRef<HTMLElement>('skinPreviewArea')
|
||||||
|
const armorTrimTab = useTemplateRef<ComponentPublicInstance>('armorTrimTab')
|
||||||
|
const armorPreviewControls = useTemplateRef<ComponentPublicInstance>('armorPreviewControls')
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -391,7 +400,8 @@ const isAddSkinButtonDragActive = ref(false)
|
|||||||
|
|
||||||
const deleteSkinModal = ref()
|
const deleteSkinModal = ref()
|
||||||
const skinToDelete = ref<Skin | null>(null)
|
const skinToDelete = ref<Skin | null>(null)
|
||||||
const skinListTab = ref<'saved' | 'default'>('saved')
|
const lastSkinListTab = ref<'saved' | 'default'>('saved')
|
||||||
|
const skinListTab = ref<'saved' | 'default' | 'armor'>('saved')
|
||||||
|
|
||||||
const skinListTabLinks = computed(() => [
|
const skinListTabLinks = computed(() => [
|
||||||
{
|
{
|
||||||
@@ -403,6 +413,70 @@ const skinListTabLinks = computed(() => [
|
|||||||
label: formatMessage(messages.defaultTab),
|
label: formatMessage(messages.defaultTab),
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
const ARMOR_TRIM_PANEL_ID = 'skins-armor-trim-panel'
|
||||||
|
const savedArmorPreview = ref<ArmorPreviewConfig>(loadSkinArmorPreview())
|
||||||
|
const armorPreviewConfig = ref<ArmorPreviewConfig>(cloneArmorPreviewConfig(savedArmorPreview.value))
|
||||||
|
|
||||||
|
function saveArmorPreview() {
|
||||||
|
savedArmorPreview.value = cloneArmorPreviewConfig(armorPreviewConfig.value)
|
||||||
|
saveSkinArmorPreview(savedArmorPreview.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetArmorPreviewToSaved() {
|
||||||
|
armorPreviewConfig.value = cloneArmorPreviewConfig(savedArmorPreview.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreDefaultArmorPreview() {
|
||||||
|
armorPreviewConfig.value = createDefaultArmorPreviewConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A third tab behind the two list tabs, opened from the preview's action row. */
|
||||||
|
function openArmorTab() {
|
||||||
|
if (skinListTab.value !== 'armor') lastSkinListTab.value = skinListTab.value
|
||||||
|
|
||||||
|
skinListTab.value = 'armor'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether an element belongs to the armour surface: somewhere inside the open
|
||||||
|
* armour tab or the button that toggles it. Only those hold a focus ring that
|
||||||
|
* would be left behind when the tab closes.
|
||||||
|
*/
|
||||||
|
function isArmorPreviewElement(element: Element) {
|
||||||
|
const tabElement: unknown = armorTrimTab.value?.$el
|
||||||
|
const toggleElement: unknown = armorPreviewControls.value?.$el
|
||||||
|
|
||||||
|
return (
|
||||||
|
(tabElement instanceof Element && tabElement.contains(element)) ||
|
||||||
|
(toggleElement instanceof Element && toggleElement.contains(element))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeArmorTab() {
|
||||||
|
// Leaving the tab drops whatever was not saved on purpose.
|
||||||
|
resetArmorPreviewToSaved()
|
||||||
|
skinListTab.value = lastSkinListTab.value
|
||||||
|
|
||||||
|
// Escape and the toggle both leave the armour button holding focus, which
|
||||||
|
// keeps its focus ring drawn until something else is clicked. Only drop that
|
||||||
|
// ring when the focus sits on the armour surface, never on an unrelated
|
||||||
|
// control that happened to hold it when Escape was pressed.
|
||||||
|
const focused = document.activeElement
|
||||||
|
if (focused instanceof HTMLElement && isArmorPreviewElement(focused)) focused.blur()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tab bar keeps the last list tab highlighted while the armour tab shows, so
|
||||||
|
* picking one of them leaves the armour tab. That transition has to drop the
|
||||||
|
* draft exactly like the toggle and Escape paths do, or it lingers on the model
|
||||||
|
* while the panel is gone.
|
||||||
|
*/
|
||||||
|
function selectSkinListTab(index: number) {
|
||||||
|
if (skinListTab.value === 'armor') resetArmorPreviewToSaved()
|
||||||
|
|
||||||
|
lastSkinListTab.value = index === 0 ? 'saved' : 'default'
|
||||||
|
skinListTab.value = lastSkinListTab.value
|
||||||
|
}
|
||||||
|
|
||||||
function confirmDeleteSkin(skin: Skin) {
|
function confirmDeleteSkin(skin: Skin) {
|
||||||
if (isSkinManagementReadOnly.value) return
|
if (isSkinManagementReadOnly.value) return
|
||||||
@@ -1211,6 +1285,9 @@ await loadSkins()
|
|||||||
class="ml-5 mt-4 flex h-[calc(80vh-1rem)] items-center justify-center max-[700px]:h-[calc(50vh-1rem)]"
|
class="ml-5 mt-4 flex h-[calc(80vh-1rem)] items-center justify-center max-[700px]:h-[calc(50vh-1rem)]"
|
||||||
>
|
>
|
||||||
<SkinPreviewRenderer
|
<SkinPreviewRenderer
|
||||||
|
v-model:armor-config="armorPreviewConfig"
|
||||||
|
armor-preview
|
||||||
|
:armor-controls="false"
|
||||||
:cape-src="capeTexture"
|
:cape-src="capeTexture"
|
||||||
:texture-src="skinTexture || ''"
|
:texture-src="skinTexture || ''"
|
||||||
:variant="skinVariant"
|
:variant="skinVariant"
|
||||||
@@ -1257,6 +1334,16 @@ await loadSkins()
|
|||||||
<EditIcon />
|
<EditIcon />
|
||||||
{{ formatMessage(messages.editSkinButton) }}
|
{{ formatMessage(messages.editSkinButton) }}
|
||||||
</button>
|
</button>
|
||||||
|
<ArmorPreviewControls
|
||||||
|
v-if="!isSkinSiteProfile"
|
||||||
|
ref="armorPreviewControls"
|
||||||
|
v-model="armorPreviewConfig"
|
||||||
|
panel="external"
|
||||||
|
:panel-id="ARMOR_TRIM_PANEL_ID"
|
||||||
|
:open="skinListTab === 'armor'"
|
||||||
|
@open="openArmorTab"
|
||||||
|
@close="closeArmorTab"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</SkinPreviewRenderer>
|
</SkinPreviewRenderer>
|
||||||
</div>
|
</div>
|
||||||
@@ -1265,14 +1352,10 @@ await loadSkins()
|
|||||||
<div class="pt-2">
|
<div class="pt-2">
|
||||||
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||||
<NavTabs
|
<NavTabs
|
||||||
:active-index="skinListTab === 'saved' ? 0 : 1"
|
:active-index="lastSkinListTab === 'saved' ? 0 : 1"
|
||||||
:links="skinListTabLinks"
|
:links="skinListTabLinks"
|
||||||
mode="local"
|
mode="local"
|
||||||
@tab-click="
|
@tab-click="selectSkinListTab"
|
||||||
(index: number) => {
|
|
||||||
skinListTab = index === 0 ? 'saved' : 'default'
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
<ButtonStyled v-if="!isSkinSiteProfile" color="brand">
|
<ButtonStyled v-if="!isSkinSiteProfile" color="brand">
|
||||||
<button @click="router.push('/lab/skin-editor')">
|
<button @click="router.push('/lab/skin-editor')">
|
||||||
@@ -1281,27 +1364,45 @@ await loadSkins()
|
|||||||
</button>
|
</button>
|
||||||
</ButtonStyled>
|
</ButtonStyled>
|
||||||
</div>
|
</div>
|
||||||
<VirtualSkinSectionList
|
<Transition name="armor-tab" mode="out-in">
|
||||||
ref="skinSectionList"
|
<div v-if="skinListTab !== 'armor'" key="list">
|
||||||
:active-tab="skinListTab"
|
<SkinListSkeleton v-if="isSkinListBuffering" />
|
||||||
:saved-skins="savedSkins"
|
<VirtualSkinSectionList
|
||||||
:default-skin-sections="defaultSkinSections"
|
v-show="!isSkinListBuffering"
|
||||||
:get-baked-skin-textures="getBakedSkinTextures"
|
ref="skinSectionList"
|
||||||
:is-skin-selected="isSkinSelected"
|
:active-tab="skinListTab"
|
||||||
:is-skin-active="isSkinActive"
|
:saved-skins="savedSkins"
|
||||||
:is-add-skin-button-drag-active="isAddSkinButtonDragActive"
|
:default-skin-sections="defaultSkinSections"
|
||||||
:read-only="isSkinManagementReadOnly"
|
:get-baked-skin-textures="getBakedSkinTextures"
|
||||||
:manage-saved-skins="!isSkinSiteProfile"
|
:is-skin-selected="isSkinSelected"
|
||||||
@select="changeSkin"
|
:is-skin-active="isSkinActive"
|
||||||
@edit="(skin, event) => !isSkinSiteProfile && editSkinModal?.show(event, skin)"
|
:is-add-skin-button-drag-active="isAddSkinButtonDragActive"
|
||||||
@delete="confirmDeleteSkin"
|
:read-only="isSkinManagementReadOnly"
|
||||||
@reorder-saved-skins="reorderSavedSkins"
|
:manage-saved-skins="!isSkinSiteProfile"
|
||||||
@add-skin="openAddSkinFileBrowser"
|
@select="changeSkin"
|
||||||
@add-skin-dragenter="onAddSkinDragOver"
|
@edit="(skin, event) => !isSkinSiteProfile && editSkinModal?.show(event, skin)"
|
||||||
@add-skin-dragover="onAddSkinDragOver"
|
@delete="confirmDeleteSkin"
|
||||||
@add-skin-dragleave="onAddSkinDragLeave"
|
@reorder-saved-skins="reorderSavedSkins"
|
||||||
@add-skin-drop="onAddSkinDrop"
|
@add-skin="openAddSkinFileBrowser"
|
||||||
/>
|
@add-skin-dragenter="onAddSkinDragOver"
|
||||||
|
@add-skin-dragover="onAddSkinDragOver"
|
||||||
|
@add-skin-dragleave="onAddSkinDragLeave"
|
||||||
|
@add-skin-drop="onAddSkinDrop"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<ArmorTrimTab
|
||||||
|
v-else
|
||||||
|
ref="armorTrimTab"
|
||||||
|
key="armor"
|
||||||
|
v-model="armorPreviewConfig"
|
||||||
|
:panel-id="ARMOR_TRIM_PANEL_ID"
|
||||||
|
:saved="savedArmorPreview"
|
||||||
|
@save="saveArmorPreview"
|
||||||
|
@reset="resetArmorPreviewToSaved"
|
||||||
|
@defaults="restoreDefaultArmorPreview"
|
||||||
|
@close="closeArmorTab"
|
||||||
|
/>
|
||||||
|
</Transition>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1382,4 +1483,17 @@ await loadSkins()
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// The armour tab crossfades with the skin list it replaces.
|
||||||
|
.armor-tab-enter-active,
|
||||||
|
.armor-tab-leave-active {
|
||||||
|
transition:
|
||||||
|
opacity 180ms ease,
|
||||||
|
transform 180ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.armor-tab-enter-from,
|
||||||
|
.armor-tab-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(0.5rem);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -333,6 +333,12 @@ pub struct EditInstance {
|
|||||||
)]
|
)]
|
||||||
pub launch_preparation_timeout: Option<Option<u64>>,
|
pub launch_preparation_timeout: Option<Option<u64>>,
|
||||||
pub hooks: Option<Hooks>,
|
pub hooks: Option<Hooks>,
|
||||||
|
#[serde(
|
||||||
|
default,
|
||||||
|
skip_serializing_if = "Option::is_none",
|
||||||
|
with = "serde_with::rust::double_option"
|
||||||
|
)]
|
||||||
|
pub window_title: Option<Option<String>>,
|
||||||
|
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
@@ -531,7 +537,8 @@ fn edit_to_core(edit_instance: EditInstance) -> Result<CoreEditInstance> {
|
|||||||
|| edit_instance.maximize_window.is_some()
|
|| edit_instance.maximize_window.is_some()
|
||||||
|| edit_instance.game_resolution.is_some()
|
|| edit_instance.game_resolution.is_some()
|
||||||
|| edit_instance.launch_preparation_timeout.is_some()
|
|| edit_instance.launch_preparation_timeout.is_some()
|
||||||
|| edit_instance.hooks.is_some();
|
|| edit_instance.hooks.is_some()
|
||||||
|
|| edit_instance.window_title.is_some();
|
||||||
if has_launch_change {
|
if has_launch_change {
|
||||||
Some(InstanceLaunchOverridesPatch {
|
Some(InstanceLaunchOverridesPatch {
|
||||||
player: None,
|
player: None,
|
||||||
@@ -546,6 +553,7 @@ fn edit_to_core(edit_instance: EditInstance) -> Result<CoreEditInstance> {
|
|||||||
launch_preparation_timeout: edit_instance
|
launch_preparation_timeout: edit_instance
|
||||||
.launch_preparation_timeout,
|
.launch_preparation_timeout,
|
||||||
hooks: edit_instance.hooks,
|
hooks: edit_instance.hooks,
|
||||||
|
window_title: edit_instance.window_title,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -253,6 +253,14 @@ impl LightweightMode {
|
|||||||
if payload.maximize_window {
|
if payload.maximize_window {
|
||||||
maximize_minecraft_window(payload.pid).await;
|
maximize_minecraft_window(payload.pid).await;
|
||||||
}
|
}
|
||||||
|
if let Some(title) = payload
|
||||||
|
.window_title
|
||||||
|
.as_ref()
|
||||||
|
.map(|value| value.trim())
|
||||||
|
.filter(|value| !value.is_empty())
|
||||||
|
{
|
||||||
|
rename_minecraft_window(payload.pid, title).await;
|
||||||
|
}
|
||||||
let settings = match theseus::settings::get().await {
|
let settings = match theseus::settings::get().await {
|
||||||
Ok(settings) => settings,
|
Ok(settings) => settings,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
@@ -332,6 +340,8 @@ struct ProcessEventPayload {
|
|||||||
pid: u32,
|
pid: u32,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
maximize_window: bool,
|
maximize_window: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
window_title: Option<String>,
|
||||||
event: String,
|
event: String,
|
||||||
crashed: Option<bool>,
|
crashed: Option<bool>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -339,7 +349,7 @@ struct ProcessEventPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicU32, Ordering};
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
static MAXIMIZE_PROCESS_ID: AtomicU32 = AtomicU32::new(0);
|
static MAXIMIZE_PROCESS_ID: AtomicU32 = AtomicU32::new(0);
|
||||||
@@ -400,6 +410,74 @@ async fn maximize_minecraft_window(pid: u32) {
|
|||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
async fn maximize_minecraft_window(_pid: u32) {}
|
async fn maximize_minecraft_window(_pid: u32) {}
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
static RENAME_WINDOW_HANDLE: AtomicIsize = AtomicIsize::new(0);
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
unsafe extern "system" fn rename_if_owned_by_process(
|
||||||
|
hwnd: windows::Win32::Foundation::HWND,
|
||||||
|
_: windows::Win32::Foundation::LPARAM,
|
||||||
|
) -> windows::core::BOOL {
|
||||||
|
use windows::Win32::UI::WindowsAndMessaging::{
|
||||||
|
GetWindowThreadProcessId, IsWindowVisible,
|
||||||
|
};
|
||||||
|
use windows::core::BOOL;
|
||||||
|
|
||||||
|
let mut window_pid = 0;
|
||||||
|
unsafe { GetWindowThreadProcessId(hwnd, Some(&mut window_pid)) };
|
||||||
|
if window_pid == MAXIMIZE_PROCESS_ID.load(Ordering::Relaxed)
|
||||||
|
&& unsafe { IsWindowVisible(hwnd).as_bool() }
|
||||||
|
{
|
||||||
|
RENAME_WINDOW_HANDLE.store(hwnd.0 as isize, Ordering::Relaxed);
|
||||||
|
return BOOL(0);
|
||||||
|
}
|
||||||
|
BOOL(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
async fn rename_minecraft_window(pid: u32, title: &str) {
|
||||||
|
if pid == 0 || title.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PCL keeps re-applying the title: FML/Quilt and some mods reset it
|
||||||
|
// while the game boots, so a one-shot rename is not enough.
|
||||||
|
let deadline =
|
||||||
|
tokio::time::Instant::now() + std::time::Duration::from_secs(45);
|
||||||
|
let mut applied = false;
|
||||||
|
loop {
|
||||||
|
let found = {
|
||||||
|
let _guard = MAXIMIZE_WINDOW_ENUMERATION.lock();
|
||||||
|
MAXIMIZE_PROCESS_ID.store(pid, Ordering::Relaxed);
|
||||||
|
RENAME_WINDOW_HANDLE.store(0, Ordering::Relaxed);
|
||||||
|
unsafe {
|
||||||
|
use windows::Win32::Foundation::LPARAM;
|
||||||
|
use windows::Win32::UI::WindowsAndMessaging::EnumWindows;
|
||||||
|
let _ =
|
||||||
|
EnumWindows(Some(rename_if_owned_by_process), LPARAM(0));
|
||||||
|
}
|
||||||
|
RENAME_WINDOW_HANDLE.load(Ordering::Relaxed)
|
||||||
|
};
|
||||||
|
if found != 0 {
|
||||||
|
let hwnd = windows::Win32::Foundation::HWND(found as *mut _);
|
||||||
|
let wide: Vec<u16> = title.encode_utf16().chain(Some(0)).collect();
|
||||||
|
unsafe {
|
||||||
|
use windows::Win32::UI::WindowsAndMessaging::SetWindowTextW;
|
||||||
|
let _ =
|
||||||
|
SetWindowTextW(hwnd, windows::core::PCWSTR(wide.as_ptr()));
|
||||||
|
}
|
||||||
|
applied = true;
|
||||||
|
}
|
||||||
|
if tokio::time::Instant::now() >= deadline {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let _ = applied;
|
||||||
|
tokio::time::sleep(std::time::Duration::from_millis(400)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
async fn rename_minecraft_window(_pid: u32, _title: &str) {}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn lightweight_mode_frontend_ready(
|
pub fn lightweight_mode_frontend_ready(
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE settings ADD COLUMN custom_window_title_enabled INTEGER NOT NULL DEFAULT FALSE;
|
||||||
|
ALTER TABLE settings ADD COLUMN default_window_title TEXT NOT NULL DEFAULT 'Minecraft';
|
||||||
@@ -250,6 +250,17 @@ async fn run_credentials(
|
|||||||
.launch_overrides
|
.launch_overrides
|
||||||
.maximize_window
|
.maximize_window
|
||||||
.unwrap_or(settings.maximize_window);
|
.unwrap_or(settings.maximize_window);
|
||||||
|
let window_title = settings
|
||||||
|
.custom_window_title_enabled
|
||||||
|
.then(|| {
|
||||||
|
context
|
||||||
|
.launch_overrides
|
||||||
|
.window_title
|
||||||
|
.clone()
|
||||||
|
.filter(|value| !value.trim().is_empty())
|
||||||
|
.unwrap_or_else(|| settings.default_window_title.clone())
|
||||||
|
})
|
||||||
|
.filter(|value| !value.trim().is_empty());
|
||||||
let env_args = context
|
let env_args = context
|
||||||
.launch_overrides
|
.launch_overrides
|
||||||
.custom_env_vars
|
.custom_env_vars
|
||||||
@@ -319,6 +330,7 @@ async fn run_credentials(
|
|||||||
&memory,
|
&memory,
|
||||||
&resolution,
|
&resolution,
|
||||||
maximize_window,
|
maximize_window,
|
||||||
|
window_title,
|
||||||
credentials,
|
credentials,
|
||||||
post_exit_hook,
|
post_exit_hook,
|
||||||
&context,
|
&context,
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ pub(crate) async fn import_axolotl(
|
|||||||
),
|
),
|
||||||
maximize_window: Some(config.launch_overrides.maximize_window),
|
maximize_window: Some(config.launch_overrides.maximize_window),
|
||||||
game_resolution: Some(config.launch_overrides.game_resolution),
|
game_resolution: Some(config.launch_overrides.game_resolution),
|
||||||
|
window_title: None,
|
||||||
launch_preparation_timeout: Some(
|
launch_preparation_timeout: Some(
|
||||||
config.launch_overrides.launch_preparation_timeout,
|
config.launch_overrides.launch_preparation_timeout,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -400,6 +400,7 @@ pub async fn emit_process(
|
|||||||
uuid: Uuid,
|
uuid: Uuid,
|
||||||
pid: u32,
|
pid: u32,
|
||||||
maximize_window: bool,
|
maximize_window: bool,
|
||||||
|
window_title: Option<String>,
|
||||||
event: ProcessPayloadType,
|
event: ProcessPayloadType,
|
||||||
message: &str,
|
message: &str,
|
||||||
crashed: Option<bool>,
|
crashed: Option<bool>,
|
||||||
@@ -416,6 +417,7 @@ pub async fn emit_process(
|
|||||||
uuid,
|
uuid,
|
||||||
pid,
|
pid,
|
||||||
maximize_window,
|
maximize_window,
|
||||||
|
window_title,
|
||||||
event,
|
event,
|
||||||
message: message.to_string(),
|
message: message.to_string(),
|
||||||
crashed,
|
crashed,
|
||||||
|
|||||||
@@ -336,6 +336,8 @@ pub struct ProcessPayload {
|
|||||||
pub uuid: Uuid,
|
pub uuid: Uuid,
|
||||||
pub pid: u32,
|
pub pid: u32,
|
||||||
pub maximize_window: bool,
|
pub maximize_window: bool,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub window_title: Option<String>,
|
||||||
pub event: ProcessPayloadType,
|
pub event: ProcessPayloadType,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
|||||||
@@ -1520,6 +1520,7 @@ pub async fn launch_minecraft(
|
|||||||
memory: &MemorySettings,
|
memory: &MemorySettings,
|
||||||
resolution: &WindowSize,
|
resolution: &WindowSize,
|
||||||
maximize_window: bool,
|
maximize_window: bool,
|
||||||
|
window_title: Option<String>,
|
||||||
credentials: &Credentials,
|
credentials: &Credentials,
|
||||||
post_exit_hook: Option<String>,
|
post_exit_hook: Option<String>,
|
||||||
context: &InstanceLaunchContext,
|
context: &InstanceLaunchContext,
|
||||||
@@ -2391,6 +2392,7 @@ pub async fn launch_minecraft(
|
|||||||
command,
|
command,
|
||||||
post_exit_hook,
|
post_exit_hook,
|
||||||
maximize_window,
|
maximize_window,
|
||||||
|
window_title,
|
||||||
instance_path.clone(),
|
instance_path.clone(),
|
||||||
logs_folder,
|
logs_folder,
|
||||||
version_info.logging.is_some(),
|
version_info.logging.is_some(),
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::api::pack::import::{
|
use crate::api::pack::import::{
|
||||||
ImportLauncherType,
|
ImportLauncherType, direct_link::resolve_direct_link,
|
||||||
direct_link::resolve_direct_link,
|
|
||||||
};
|
};
|
||||||
use crate::launcher::ExternalGameDirMode;
|
use crate::launcher::ExternalGameDirMode;
|
||||||
use crate::state::instances::{
|
use crate::state::instances::{
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ pub struct InstanceLaunchOverridesPatch {
|
|||||||
skip_serializing_if = "Option::is_none",
|
skip_serializing_if = "Option::is_none",
|
||||||
with = "serde_with::rust::double_option"
|
with = "serde_with::rust::double_option"
|
||||||
)]
|
)]
|
||||||
|
pub window_title: Option<Option<String>>,
|
||||||
|
#[serde(
|
||||||
|
default,
|
||||||
|
skip_serializing_if = "Option::is_none",
|
||||||
|
with = "serde_with::rust::double_option"
|
||||||
|
)]
|
||||||
pub launch_preparation_timeout: Option<Option<u64>>,
|
pub launch_preparation_timeout: Option<Option<u64>>,
|
||||||
pub hooks: Option<Hooks>,
|
pub hooks: Option<Hooks>,
|
||||||
}
|
}
|
||||||
@@ -371,6 +377,10 @@ fn apply_launch_overrides_patch(
|
|||||||
if let Some(game_resolution) = patch.game_resolution {
|
if let Some(game_resolution) = patch.game_resolution {
|
||||||
overrides.game_resolution = game_resolution;
|
overrides.game_resolution = game_resolution;
|
||||||
}
|
}
|
||||||
|
if let Some(window_title) = patch.window_title {
|
||||||
|
overrides.window_title =
|
||||||
|
window_title.filter(|value| !value.trim().is_empty());
|
||||||
|
}
|
||||||
if let Some(mode) = patch.instance_mode {
|
if let Some(mode) = patch.instance_mode {
|
||||||
overrides.instance_mode = Some(mode);
|
overrides.instance_mode = Some(mode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use super::create_direct_link_instance::create_direct_link_instance;
|
use super::create_direct_link_instance::create_direct_link_instance;
|
||||||
use crate::api::pack::import::direct_link::{
|
use crate::api::pack::import::direct_link::{
|
||||||
detect_direct_link_source,
|
detect_direct_link_source, has_minecraft_version_manifest,
|
||||||
has_minecraft_version_manifest, resolve_direct_link,
|
resolve_direct_link,
|
||||||
};
|
};
|
||||||
use crate::event::{InstancePayloadType, emit::emit_instance};
|
use crate::event::{InstancePayloadType, emit::emit_instance};
|
||||||
use crate::launcher::ExternalGameDirMode;
|
use crate::launcher::ExternalGameDirMode;
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ pub struct InstanceLaunchOverrides {
|
|||||||
pub maximize_window: Option<bool>,
|
pub maximize_window: Option<bool>,
|
||||||
pub game_resolution: Option<WindowSize>,
|
pub game_resolution: Option<WindowSize>,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub window_title: Option<String>,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub launch_preparation_timeout: Option<u64>,
|
pub launch_preparation_timeout: Option<u64>,
|
||||||
pub hooks: Hooks,
|
pub hooks: Hooks,
|
||||||
}
|
}
|
||||||
@@ -55,6 +57,7 @@ impl InstanceLaunchOverrides {
|
|||||||
force_fullscreen: None,
|
force_fullscreen: None,
|
||||||
maximize_window: None,
|
maximize_window: None,
|
||||||
game_resolution: None,
|
game_resolution: None,
|
||||||
|
window_title: None,
|
||||||
launch_preparation_timeout: None,
|
launch_preparation_timeout: None,
|
||||||
hooks: Hooks {
|
hooks: Hooks {
|
||||||
pre_launch: None,
|
pre_launch: None,
|
||||||
@@ -86,6 +89,8 @@ pub(crate) struct InstanceLaunchOverridesData {
|
|||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub game_resolution: Option<WindowSize>,
|
pub game_resolution: Option<WindowSize>,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub window_title: Option<String>,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub launch_preparation_timeout: Option<u64>,
|
pub launch_preparation_timeout: Option<u64>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub hooks: Hooks,
|
pub hooks: Hooks,
|
||||||
@@ -107,6 +112,7 @@ impl InstanceLaunchOverridesData {
|
|||||||
force_fullscreen: self.force_fullscreen,
|
force_fullscreen: self.force_fullscreen,
|
||||||
maximize_window: self.maximize_window,
|
maximize_window: self.maximize_window,
|
||||||
game_resolution: self.game_resolution,
|
game_resolution: self.game_resolution,
|
||||||
|
window_title: self.window_title,
|
||||||
launch_preparation_timeout: self.launch_preparation_timeout,
|
launch_preparation_timeout: self.launch_preparation_timeout,
|
||||||
hooks: self.hooks,
|
hooks: self.hooks,
|
||||||
}
|
}
|
||||||
@@ -125,6 +131,7 @@ impl From<&InstanceLaunchOverrides> for InstanceLaunchOverridesData {
|
|||||||
force_fullscreen: overrides.force_fullscreen,
|
force_fullscreen: overrides.force_fullscreen,
|
||||||
maximize_window: overrides.maximize_window,
|
maximize_window: overrides.maximize_window,
|
||||||
game_resolution: overrides.game_resolution,
|
game_resolution: overrides.game_resolution,
|
||||||
|
window_title: overrides.window_title.clone(),
|
||||||
launch_preparation_timeout: overrides.launch_preparation_timeout,
|
launch_preparation_timeout: overrides.launch_preparation_timeout,
|
||||||
hooks: overrides.hooks.clone(),
|
hooks: overrides.hooks.clone(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -621,6 +621,7 @@ where
|
|||||||
force_fullscreen: input.force_fullscreen,
|
force_fullscreen: input.force_fullscreen,
|
||||||
maximize_window: None,
|
maximize_window: None,
|
||||||
game_resolution: input.game_resolution,
|
game_resolution: input.game_resolution,
|
||||||
|
window_title: None,
|
||||||
launch_preparation_timeout: None,
|
launch_preparation_timeout: None,
|
||||||
hooks: input.hooks,
|
hooks: input.hooks,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -312,6 +312,7 @@ impl ProcessManager {
|
|||||||
mut mc_command: Command,
|
mut mc_command: Command,
|
||||||
post_exit_command: Option<String>,
|
post_exit_command: Option<String>,
|
||||||
maximize_window: bool,
|
maximize_window: bool,
|
||||||
|
window_title: Option<String>,
|
||||||
game_dir: PathBuf,
|
game_dir: PathBuf,
|
||||||
logs_folder: PathBuf,
|
logs_folder: PathBuf,
|
||||||
xml_logging: bool,
|
xml_logging: bool,
|
||||||
@@ -336,6 +337,7 @@ impl ProcessManager {
|
|||||||
uuid: Uuid::new_v4(),
|
uuid: Uuid::new_v4(),
|
||||||
pid: mc_proc.id().unwrap_or_default(),
|
pid: mc_proc.id().unwrap_or_default(),
|
||||||
maximize_window,
|
maximize_window,
|
||||||
|
window_title: window_title.clone(),
|
||||||
start_time: Utc::now(),
|
start_time: Utc::now(),
|
||||||
instance_id: instance_id.to_string(),
|
instance_id: instance_id.to_string(),
|
||||||
instance_path: instance_path.to_string(),
|
instance_path: instance_path.to_string(),
|
||||||
@@ -509,6 +511,7 @@ impl ProcessManager {
|
|||||||
metadata.uuid,
|
metadata.uuid,
|
||||||
metadata.pid,
|
metadata.pid,
|
||||||
metadata.maximize_window,
|
metadata.maximize_window,
|
||||||
|
metadata.window_title.clone(),
|
||||||
ProcessPayloadType::Launched,
|
ProcessPayloadType::Launched,
|
||||||
"Launched Minecraft",
|
"Launched Minecraft",
|
||||||
None,
|
None,
|
||||||
@@ -586,6 +589,7 @@ pub struct ProcessMetadata {
|
|||||||
pub uuid: Uuid,
|
pub uuid: Uuid,
|
||||||
pub pid: u32,
|
pub pid: u32,
|
||||||
pub maximize_window: bool,
|
pub maximize_window: bool,
|
||||||
|
pub window_title: Option<String>,
|
||||||
pub instance_id: String,
|
pub instance_id: String,
|
||||||
pub instance_path: String,
|
pub instance_path: String,
|
||||||
pub instance_name: String,
|
pub instance_name: String,
|
||||||
@@ -1311,6 +1315,7 @@ impl Process {
|
|||||||
uuid,
|
uuid,
|
||||||
pid,
|
pid,
|
||||||
false,
|
false,
|
||||||
|
None,
|
||||||
ProcessPayloadType::Finished,
|
ProcessPayloadType::Finished,
|
||||||
"Exited process",
|
"Exited process",
|
||||||
Some(!mc_exit_status.success() && !manually_killed),
|
Some(!mc_exit_status.success() && !manually_killed),
|
||||||
@@ -1451,6 +1456,7 @@ mod post_upgrade_tests {
|
|||||||
uuid,
|
uuid,
|
||||||
pid: child.id().unwrap(),
|
pid: child.id().unwrap(),
|
||||||
maximize_window: false,
|
maximize_window: false,
|
||||||
|
window_title: None,
|
||||||
instance_id: "first".into(),
|
instance_id: "first".into(),
|
||||||
instance_path: "first".into(),
|
instance_path: "first".into(),
|
||||||
instance_name: "First".into(),
|
instance_name: "First".into(),
|
||||||
|
|||||||
@@ -176,6 +176,10 @@ pub struct Settings {
|
|||||||
pub force_fullscreen: bool,
|
pub force_fullscreen: bool,
|
||||||
pub maximize_window: bool,
|
pub maximize_window: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
pub custom_window_title_enabled: bool,
|
||||||
|
#[serde(default = "default_window_title")]
|
||||||
|
pub default_window_title: String,
|
||||||
|
#[serde(default)]
|
||||||
pub force_unicode_font: bool,
|
pub force_unicode_font: bool,
|
||||||
pub game_resolution: WindowSize,
|
pub game_resolution: WindowSize,
|
||||||
pub hide_on_process_start: bool,
|
pub hide_on_process_start: bool,
|
||||||
@@ -198,6 +202,10 @@ pub struct Settings {
|
|||||||
pub version: usize,
|
pub version: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_window_title() -> String {
|
||||||
|
"Minecraft".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
fn default_true() -> bool {
|
fn default_true() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -328,6 +336,16 @@ impl Settings {
|
|||||||
)
|
)
|
||||||
.fetch_one(exec)
|
.fetch_one(exec)
|
||||||
.await?;
|
.await?;
|
||||||
|
let custom_window_title_enabled: bool = sqlx::query_scalar(
|
||||||
|
"SELECT custom_window_title_enabled FROM settings WHERE id = 0",
|
||||||
|
)
|
||||||
|
.fetch_one(exec)
|
||||||
|
.await?;
|
||||||
|
let default_window_title: String = sqlx::query_scalar(
|
||||||
|
"SELECT default_window_title FROM settings WHERE id = 0",
|
||||||
|
)
|
||||||
|
.fetch_one(exec)
|
||||||
|
.await?;
|
||||||
let settings = Self {
|
let settings = Self {
|
||||||
max_concurrent_downloads: res.max_concurrent_downloads as usize,
|
max_concurrent_downloads: res.max_concurrent_downloads as usize,
|
||||||
max_concurrent_writes: res.max_concurrent_writes as usize,
|
max_concurrent_writes: res.max_concurrent_writes as usize,
|
||||||
@@ -415,6 +433,8 @@ impl Settings {
|
|||||||
},
|
},
|
||||||
force_fullscreen: res.mc_force_fullscreen == 1,
|
force_fullscreen: res.mc_force_fullscreen == 1,
|
||||||
maximize_window: res.mc_maximize_window == 1,
|
maximize_window: res.mc_maximize_window == 1,
|
||||||
|
custom_window_title_enabled,
|
||||||
|
default_window_title,
|
||||||
force_unicode_font: sqlx::query_scalar(
|
force_unicode_font: sqlx::query_scalar(
|
||||||
"SELECT mc_force_unicode_font FROM settings WHERE id = 0",
|
"SELECT mc_force_unicode_font FROM settings WHERE id = 0",
|
||||||
)
|
)
|
||||||
@@ -663,6 +683,18 @@ impl Settings {
|
|||||||
.bind(self.ignore_ssl_errors)
|
.bind(self.ignore_ssl_errors)
|
||||||
.execute(exec)
|
.execute(exec)
|
||||||
.await?;
|
.await?;
|
||||||
|
sqlx::query(
|
||||||
|
"UPDATE settings SET custom_window_title_enabled = ? WHERE id = 0",
|
||||||
|
)
|
||||||
|
.bind(self.custom_window_title_enabled)
|
||||||
|
.execute(exec)
|
||||||
|
.await?;
|
||||||
|
sqlx::query(
|
||||||
|
"UPDATE settings SET default_window_title = ? WHERE id = 0",
|
||||||
|
)
|
||||||
|
.bind(self.default_window_title.trim())
|
||||||
|
.execute(exec)
|
||||||
|
.await?;
|
||||||
sqlx::query("UPDATE settings SET mc_memory_optimize = ? WHERE id = 0")
|
sqlx::query("UPDATE settings SET mc_memory_optimize = ? WHERE id = 0")
|
||||||
.bind(self.memory.optimize_before_launch)
|
.bind(self.memory.optimize_before_launch)
|
||||||
.execute(exec)
|
.execute(exec)
|
||||||
|
|||||||
|
After Width: | Height: | Size: 251 B |
|
After Width: | Height: | Size: 423 B |
|
After Width: | Height: | Size: 438 B |
|
After Width: | Height: | Size: 434 B |
|
After Width: | Height: | Size: 424 B |
|
After Width: | Height: | Size: 413 B |
|
After Width: | Height: | Size: 170 B |
|
After Width: | Height: | Size: 467 B |
|
After Width: | Height: | Size: 253 B |
|
After Width: | Height: | Size: 167 B |
|
After Width: | Height: | Size: 258 B |
|
After Width: | Height: | Size: 272 B |
|
After Width: | Height: | Size: 261 B |
|
After Width: | Height: | Size: 243 B |
|
After Width: | Height: | Size: 254 B |
|
After Width: | Height: | Size: 180 B |
|
After Width: | Height: | Size: 258 B |
|
After Width: | Height: | Size: 183 B |
|
After Width: | Height: | Size: 225 B |
|
After Width: | Height: | Size: 149 B |
|
After Width: | Height: | Size: 165 B |
|
After Width: | Height: | Size: 135 B |
|
After Width: | Height: | Size: 148 B |
|
After Width: | Height: | Size: 267 B |
|
After Width: | Height: | Size: 171 B |
|
After Width: | Height: | Size: 189 B |
|
After Width: | Height: | Size: 160 B |
|
After Width: | Height: | Size: 196 B |
|
After Width: | Height: | Size: 177 B |
|
After Width: | Height: | Size: 207 B |
|
After Width: | Height: | Size: 175 B |
|
After Width: | Height: | Size: 189 B |
|
After Width: | Height: | Size: 165 B |
|
After Width: | Height: | Size: 177 B |
|
After Width: | Height: | Size: 224 B |
|
After Width: | Height: | Size: 182 B |
|
After Width: | Height: | Size: 211 B |
|
After Width: | Height: | Size: 210 B |
|
After Width: | Height: | Size: 187 B |
|
After Width: | Height: | Size: 169 B |
|
After Width: | Height: | Size: 189 B |
|
After Width: | Height: | Size: 158 B |
|
After Width: | Height: | Size: 174 B |
|
After Width: | Height: | Size: 203 B |
|
After Width: | Height: | Size: 143 B |
|
After Width: | Height: | Size: 161 B |
|
After Width: | Height: | Size: 134 B |
|
After Width: | Height: | Size: 157 B |
|
After Width: | Height: | Size: 151 B |
|
After Width: | Height: | Size: 181 B |
|
After Width: | Height: | Size: 200 B |
|
After Width: | Height: | Size: 245 B |
|
After Width: | Height: | Size: 202 B |
|
After Width: | Height: | Size: 209 B |
|
After Width: | Height: | Size: 171 B |
|
After Width: | Height: | Size: 216 B |
|
After Width: | Height: | Size: 161 B |
|
After Width: | Height: | Size: 208 B |
|
After Width: | Height: | Size: 176 B |
|
After Width: | Height: | Size: 223 B |
|
After Width: | Height: | Size: 215 B |
|
After Width: | Height: | Size: 179 B |
|
After Width: | Height: | Size: 198 B |
|
After Width: | Height: | Size: 227 B |
|
After Width: | Height: | Size: 207 B |
|
After Width: | Height: | Size: 208 B |
|
After Width: | Height: | Size: 254 B |
|
After Width: | Height: | Size: 208 B |