Switch launch selection to library profiles
This commit is contained in:
@@ -117,16 +117,19 @@ function renderDetailPanel(profile){
|
|||||||
installDetailBody.textContent = buildDetailText(profile)
|
installDetailBody.textContent = buildDetailText(profile)
|
||||||
installDetailAddButton.disabled = installed || !profile.launchReady
|
installDetailAddButton.disabled = installed || !profile.launchReady
|
||||||
installDetailAddButton.textContent = installed ? '이미 라이브러리에 있음' : '라이브러리에 추가'
|
installDetailAddButton.textContent = installed ? '이미 라이브러리에 있음' : '라이브러리에 추가'
|
||||||
installDetailAddButton.onclick = async () => {
|
installDetailAddButton.onclick = async () => {
|
||||||
try {
|
try {
|
||||||
const installedProfile = await CatalogManager.installProfile(profile.id)
|
const installedProfile = await CatalogManager.installProfile(profile.id)
|
||||||
await ProfileAssetManager.prefetchProfileAssets(installedProfile)
|
await ProfileAssetManager.prefetchProfileAssets(installedProfile)
|
||||||
if(installedProfile.kind === 'server-pack' && installedProfile.hostReady){
|
if(installedProfile.kind === 'server-pack' && installedProfile.hostReady){
|
||||||
await ProfileAssetManager.ensureServerBundleInstalled(installedProfile)
|
await ProfileAssetManager.ensureServerBundleInstalled(installedProfile)
|
||||||
}
|
}
|
||||||
renderDetailPanel(profile)
|
if(typeof refreshSelectedProfileButton === 'function'){
|
||||||
await renderInstallView()
|
refreshSelectedProfileButton()
|
||||||
if(typeof refreshLibraryView === 'function'){
|
}
|
||||||
|
renderDetailPanel(profile)
|
||||||
|
await renderInstallView()
|
||||||
|
if(typeof refreshLibraryView === 'function'){
|
||||||
await refreshLibraryView()
|
await refreshLibraryView()
|
||||||
}
|
}
|
||||||
showInstallMessage('추가 완료', `${profile.name} 프로필을 라이브러리에 추가했습니다.`)
|
showInstallMessage('추가 완료', `${profile.name} 프로필을 라이브러리에 추가했습니다.`)
|
||||||
@@ -242,6 +245,9 @@ async function renderInstallView(){
|
|||||||
if(installedProfile.kind === 'server-pack' && installedProfile.hostReady){
|
if(installedProfile.kind === 'server-pack' && installedProfile.hostReady){
|
||||||
await ProfileAssetManager.ensureServerBundleInstalled(installedProfile)
|
await ProfileAssetManager.ensureServerBundleInstalled(installedProfile)
|
||||||
}
|
}
|
||||||
|
if(typeof refreshSelectedProfileButton === 'function'){
|
||||||
|
refreshSelectedProfileButton()
|
||||||
|
}
|
||||||
selectProfile(profile.id)
|
selectProfile(profile.id)
|
||||||
await renderInstallView()
|
await renderInstallView()
|
||||||
if(typeof refreshLibraryView === 'function'){
|
if(typeof refreshLibraryView === 'function'){
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const {
|
|||||||
|
|
||||||
// Internal Requirements
|
// Internal Requirements
|
||||||
const AuthManager = require('./assets/js/authmanager')
|
const AuthManager = require('./assets/js/authmanager')
|
||||||
|
const CatalogManager = require('./assets/js/catalogmanager')
|
||||||
const DiscordWrapper = require('./assets/js/discordwrapper')
|
const DiscordWrapper = require('./assets/js/discordwrapper')
|
||||||
const ProcessBuilder = require('./assets/js/processbuilder')
|
const ProcessBuilder = require('./assets/js/processbuilder')
|
||||||
|
|
||||||
@@ -170,11 +171,58 @@ function setLaunchEnabled(val){
|
|||||||
document.getElementById('launch_button').disabled = !val
|
document.getElementById('launch_button').disabled = !val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshSelectedProfileButton(){
|
||||||
|
const selectedProfile = CatalogManager.getSelectedProfileSync()
|
||||||
|
if(selectedProfile == null){
|
||||||
|
server_selection_button.innerHTML = '• ' + Lang.queryJS('landing.selectedProfile.noSelection')
|
||||||
|
setLaunchEnabled(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const label = selectedProfile.name?.trim().length > 0
|
||||||
|
? selectedProfile.name.trim()
|
||||||
|
: selectedProfile.id
|
||||||
|
|
||||||
|
server_selection_button.innerHTML = '• ' + label
|
||||||
|
setLaunchEnabled(selectedProfile.configured !== false)
|
||||||
|
}
|
||||||
|
|
||||||
// Bind launch button
|
// Bind launch button
|
||||||
document.getElementById('launch_button').addEventListener('click', async e => {
|
document.getElementById('launch_button').addEventListener('click', async e => {
|
||||||
loggerLanding.info('Launching game..')
|
loggerLanding.info('Launching game..')
|
||||||
try {
|
try {
|
||||||
const server = (await DistroAPI.getDistribution()).getServerById(ConfigManager.getSelectedServer())
|
const selectedProfile = CatalogManager.getSelectedProfileSync()
|
||||||
|
if(selectedProfile == null){
|
||||||
|
if(typeof refreshLibraryView === 'function'){
|
||||||
|
await refreshLibraryView()
|
||||||
|
}
|
||||||
|
switchView(getCurrentView(), VIEWS.library)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
CatalogManager.applyConfiguredProfile()
|
||||||
|
const distro = await DistroAPI.refreshDistributionOrFallback()
|
||||||
|
if(distro == null){
|
||||||
|
throw new Error('Distribution refresh returned null.')
|
||||||
|
}
|
||||||
|
|
||||||
|
let server = distro.getServerById(ConfigManager.getSelectedServer())
|
||||||
|
if(server == null && typeof distro.getMainServer === 'function'){
|
||||||
|
const mainServer = distro.getMainServer()
|
||||||
|
if(mainServer != null){
|
||||||
|
ConfigManager.setSelectedServer(mainServer.rawServer.id)
|
||||||
|
ConfigManager.save()
|
||||||
|
server = mainServer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onDistroRefresh(distro)
|
||||||
|
refreshSelectedProfileButton()
|
||||||
|
|
||||||
|
if(server == null){
|
||||||
|
throw new Error('No server available for selected profile.')
|
||||||
|
}
|
||||||
|
|
||||||
const jExe = ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer())
|
const jExe = ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer())
|
||||||
if(jExe == null){
|
if(jExe == null){
|
||||||
await asyncSystemScan(server.effectiveJavaOptions)
|
await asyncSystemScan(server.effectiveJavaOptions)
|
||||||
@@ -267,17 +315,19 @@ function updateSelectedServer(serv){
|
|||||||
}
|
}
|
||||||
ConfigManager.setSelectedServer(serv != null ? serv.rawServer.id : null)
|
ConfigManager.setSelectedServer(serv != null ? serv.rawServer.id : null)
|
||||||
ConfigManager.save()
|
ConfigManager.save()
|
||||||
server_selection_button.innerHTML = '• ' + (serv != null ? serv.rawServer.name : Lang.queryJS('landing.noSelection'))
|
|
||||||
if(getCurrentView() === VIEWS.settings){
|
if(getCurrentView() === VIEWS.settings){
|
||||||
animateSettingsTabRefresh()
|
animateSettingsTabRefresh()
|
||||||
}
|
}
|
||||||
setLaunchEnabled(serv != null)
|
refreshSelectedProfileButton()
|
||||||
}
|
}
|
||||||
// Real text is set in uibinder.js on distributionIndexDone.
|
// Real text is set based on the selected library profile.
|
||||||
server_selection_button.innerHTML = '• ' + Lang.queryJS('landing.selectedServer.loading')
|
server_selection_button.innerHTML = '• ' + Lang.queryJS('landing.selectedProfile.loading')
|
||||||
server_selection_button.onclick = async e => {
|
server_selection_button.onclick = async e => {
|
||||||
e.target.blur()
|
e.target.blur()
|
||||||
await toggleServerSelection(true)
|
if(typeof refreshLibraryView === 'function'){
|
||||||
|
await refreshLibraryView()
|
||||||
|
}
|
||||||
|
switchView(getCurrentView(), VIEWS.library)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Mojang Status Color
|
// Update Mojang Status Color
|
||||||
@@ -1133,4 +1183,5 @@ window.updateSelectedAccount = updateSelectedAccount
|
|||||||
window.updateSelectedServer = updateSelectedServer
|
window.updateSelectedServer = updateSelectedServer
|
||||||
window.refreshServerStatus = refreshServerStatus
|
window.refreshServerStatus = refreshServerStatus
|
||||||
window.initNews = initNews
|
window.initNews = initNews
|
||||||
|
window.refreshSelectedProfileButton = refreshSelectedProfileButton
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ async function activateProfile(profile, launchNow = false){
|
|||||||
|
|
||||||
CatalogManager.selectProfile(profile.id)
|
CatalogManager.selectProfile(profile.id)
|
||||||
CatalogManager.applyConfiguredProfile()
|
CatalogManager.applyConfiguredProfile()
|
||||||
|
if(typeof refreshSelectedProfileButton === 'function'){
|
||||||
|
refreshSelectedProfileButton()
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const distro = await DistroAPI.refreshDistributionOrFallback()
|
const distro = await DistroAPI.refreshDistributionOrFallback()
|
||||||
@@ -302,6 +305,9 @@ async function renderLibraryView(){
|
|||||||
selectButton.addEventListener('click', async () => {
|
selectButton.addEventListener('click', async () => {
|
||||||
CatalogManager.selectProfile(profile.id)
|
CatalogManager.selectProfile(profile.id)
|
||||||
CatalogManager.applyConfiguredProfile()
|
CatalogManager.applyConfiguredProfile()
|
||||||
|
if(typeof refreshSelectedProfileButton === 'function'){
|
||||||
|
refreshSelectedProfileButton()
|
||||||
|
}
|
||||||
await renderLibraryView()
|
await renderLibraryView()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -360,6 +366,9 @@ async function renderLibraryView(){
|
|||||||
removeButton.addEventListener('click', async () => {
|
removeButton.addEventListener('click', async () => {
|
||||||
ServerRuntime.stopHostedProfile(profile.id)
|
ServerRuntime.stopHostedProfile(profile.id)
|
||||||
CatalogManager.removeProfile(profile.id)
|
CatalogManager.removeProfile(profile.id)
|
||||||
|
if(typeof refreshSelectedProfileButton === 'function'){
|
||||||
|
refreshSelectedProfileButton()
|
||||||
|
}
|
||||||
await renderLibraryView()
|
await renderLibraryView()
|
||||||
if(typeof refreshInstallView === 'function'){
|
if(typeof refreshInstallView === 'function'){
|
||||||
await refreshInstallView()
|
await refreshInstallView()
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ mediaDiscordURL = "https://discord.gg/Z8j6ahF4MJ"
|
|||||||
accountPreviewLabel = "계정"
|
accountPreviewLabel = "계정"
|
||||||
libraryButton = "라이브러리"
|
libraryButton = "라이브러리"
|
||||||
installButton = "설치"
|
installButton = "설치"
|
||||||
|
launchButtonPlaceholder = "• 라이브러리에서 선택"
|
||||||
|
|
||||||
[ejs.settings]
|
[ejs.settings]
|
||||||
backButton = "메인으로"
|
backButton = "메인으로"
|
||||||
|
|||||||
@@ -164,6 +164,10 @@ okay = "Okay"
|
|||||||
noAccountSelected = "No Account Selected"
|
noAccountSelected = "No Account Selected"
|
||||||
logoutFailed = "Failed to log out of the selected account. Please try again."
|
logoutFailed = "Failed to log out of the selected account. Please try again."
|
||||||
|
|
||||||
|
[js.landing.selectedProfile]
|
||||||
|
noSelection = "Select from Library"
|
||||||
|
loading = "Loading profile.."
|
||||||
|
|
||||||
[js.landing.selectedServer]
|
[js.landing.selectedServer]
|
||||||
noSelection = "No Server Selected"
|
noSelection = "No Server Selected"
|
||||||
loading = "Loading.."
|
loading = "Loading.."
|
||||||
|
|||||||
@@ -164,6 +164,10 @@ okay = "확인"
|
|||||||
noAccountSelected = "선택된 계정 없음"
|
noAccountSelected = "선택된 계정 없음"
|
||||||
logoutFailed = "계정을 로그아웃하지 못했습니다. 다시 시도해 주세요."
|
logoutFailed = "계정을 로그아웃하지 못했습니다. 다시 시도해 주세요."
|
||||||
|
|
||||||
|
[js.landing.selectedProfile]
|
||||||
|
noSelection = "라이브러리에서 선택"
|
||||||
|
loading = "프로필 불러오는 중.."
|
||||||
|
|
||||||
[js.landing.selectedServer]
|
[js.landing.selectedServer]
|
||||||
noSelection = "선택된 서버 없음"
|
noSelection = "선택된 서버 없음"
|
||||||
loading = "로딩 중.."
|
loading = "로딩 중.."
|
||||||
|
|||||||
Reference in New Issue
Block a user