Polish launcher main and library flows
Some checks failed
Build / release (macos-latest) (push) Has been cancelled
Build / release (ubuntu-latest) (push) Has been cancelled
Build / release (windows-latest) (push) Has been cancelled
Windows Smoke Test / windows-smoke (push) Has been cancelled

This commit is contained in:
2026-05-04 15:10:36 +09:00
parent 27c1453aa8
commit bc6bef0c46
13 changed files with 255 additions and 291 deletions

View File

@@ -187,6 +187,19 @@ function refreshSelectedProfileButton(){
setLaunchEnabled(selectedProfile.configured !== false)
}
function isSelectedMapReady(profile){
if(profile == null || profile.kind !== 'map'){
return false
}
const assetState = ConfigManager.getLibraryProfileAssetState(profile.id)
return profile.launchReady && (
assetState.worldInstalledAt != null ||
assetState.prefetchedAt != null ||
profile.worldArchiveUrl == null
)
}
// Bind launch button
document.getElementById('launch_button').addEventListener('click', async e => {
loggerLanding.info('Launching game..')
@@ -253,20 +266,6 @@ document.getElementById('settingsMediaButton').onclick = async e => {
switchView(getCurrentView(), VIEWS.settings)
}
document.getElementById('landingLibraryButton').onclick = async () => {
if(typeof refreshLibraryView === 'function'){
await refreshLibraryView()
}
switchView(getCurrentView(), VIEWS.library)
}
document.getElementById('landingInstallButton').onclick = async () => {
if(typeof refreshInstallView === 'function'){
await refreshInstallView()
}
switchView(getCurrentView(), VIEWS.install)
}
avatarMenuButton.addEventListener('click', (e) => {
e.stopPropagation()
setAccountMenuOpen(accountMenu.hasAttribute('hidden'))
@@ -391,15 +390,56 @@ const refreshMojangStatuses = async function(){
const refreshServerStatus = async (fade = false) => {
loggerLanding.info('Refreshing Server Status')
const serv = (await DistroAPI.getDistribution()).getServerById(ConfigManager.getSelectedServer())
const selectedProfile = CatalogManager.getSelectedProfileSync()
let pLabel = Lang.queryJS('landing.serverStatus.server')
let pVal = Lang.queryJS('landing.serverStatus.offline')
let pLabel = Lang.queryJS('landing.profileStatus.label')
let pVal = Lang.queryJS('landing.selectedProfile.noSelection')
if(selectedProfile == null){
if(fade){
$('#server_status_wrapper').fadeOut(250, () => {
document.getElementById('landingPlayerLabel').innerHTML = pLabel
document.getElementById('player_count').innerHTML = pVal
$('#server_status_wrapper').fadeIn(500)
})
} else {
document.getElementById('landingPlayerLabel').innerHTML = pLabel
document.getElementById('player_count').innerHTML = pVal
}
return
}
if(selectedProfile.kind === 'map'){
pLabel = Lang.queryJS('landing.mapStatus.label')
pVal = isSelectedMapReady(selectedProfile)
? Lang.queryJS('landing.mapStatus.ready')
: Lang.queryJS('landing.mapStatus.notReady')
if(fade){
$('#server_status_wrapper').fadeOut(250, () => {
document.getElementById('landingPlayerLabel').innerHTML = pLabel
document.getElementById('player_count').innerHTML = pVal
$('#server_status_wrapper').fadeIn(500)
})
} else {
document.getElementById('landingPlayerLabel').innerHTML = pLabel
document.getElementById('player_count').innerHTML = pVal
}
return
}
pLabel = Lang.queryJS('landing.serverStatus.server')
pVal = Lang.queryJS('landing.serverStatus.offline')
try {
const distro = await DistroAPI.getDistribution()
const serv = distro?.getServerById(ConfigManager.getSelectedServer())
?? (typeof distro?.getMainServer === 'function' ? distro.getMainServer() : null)
if(serv == null){
throw new Error('No server available for selected profile.')
}
const servStat = await getServerStatus(47, serv.hostname, serv.port)
console.log(servStat)
pLabel = Lang.queryJS('landing.serverStatus.players')
pVal = servStat.players.online + '/' + servStat.players.max
@@ -857,24 +897,12 @@ function slide_(up){
}
}
// Bind news button.
// Bind install button on the landing footer.
document.getElementById('newsButton').onclick = () => {
// Toggle tabbing.
if(newsActive){
$('#landingContainer *').removeAttr('tabindex')
$('#newsContainer *').attr('tabindex', '-1')
} else {
$('#landingContainer *').attr('tabindex', '-1')
$('#newsContainer, #newsContainer *, #lower, #lower #center *').removeAttr('tabindex')
if(newsAlertShown){
$('#newsButtonAlert').fadeOut(2000)
newsAlertShown = false
ConfigManager.setNewsCacheDismissed(true)
ConfigManager.save()
}
if(typeof refreshInstallView === 'function'){
refreshInstallView()
}
slide_(!newsActive)
newsActive = !newsActive
switchView(getCurrentView(), VIEWS.install)
}
// Array to store article meta.
@@ -1073,12 +1101,6 @@ document.addEventListener('keydown', (e) => {
// if(e.key === 'ArrowDown'){
// document.getElementById('newsButton').click()
// }
} else {
if(getCurrentView() === VIEWS.landing){
if(e.key === 'ArrowUp'){
document.getElementById('newsButton').click()
}
}
}
})