Fixed compile error
This commit is contained in:
24
HMCL/src/main/java/org/jackhuang/hmcl/setting/Settings.kt
Normal file
24
HMCL/src/main/java/org/jackhuang/hmcl/setting/Settings.kt
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* Copyright (C) 2017 huangyuhui <huanghongxun2008@126.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
|
*/
|
||||||
|
package org.jackhuang.hmcl.setting
|
||||||
|
|
||||||
|
object Settings {
|
||||||
|
init {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,12 +44,12 @@ import javafx.stage.StageStyle
|
|||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
class Decorator @JvmOverloads constructor(private val primaryStage: Stage, node: Node, max: Boolean = true, min: Boolean = true) : VBox() {
|
class Decorator @JvmOverloads constructor(private val primaryStage: Stage, node: Node, max: Boolean = true, min: Boolean = true) : VBox() {
|
||||||
private var xOffset: Double = 0.toDouble()
|
private var xOffset: Double = 0.0
|
||||||
private var yOffset: Double = 0.toDouble()
|
private var yOffset: Double = 0.0
|
||||||
private var newX: Double = 0.toDouble()
|
private var newX: Double = 0.0
|
||||||
private var newY: Double = 0.toDouble()
|
private var newY: Double = 0.0
|
||||||
private var initX: Double = 0.toDouble()
|
private var initX: Double = 0.0
|
||||||
private var initY: Double = 0.toDouble()
|
private var initY: Double = 0.0
|
||||||
private var allowMove: Boolean = false
|
private var allowMove: Boolean = false
|
||||||
private var isDragging: Boolean = false
|
private var isDragging: Boolean = false
|
||||||
private var windowDecoratorAnimation: Timeline? = null
|
private var windowDecoratorAnimation: Timeline? = null
|
||||||
@@ -189,12 +189,12 @@ class Decorator @JvmOverloads constructor(private val primaryStage: Stage, node:
|
|||||||
(node as Region).setMinSize(0.0, 0.0)
|
(node as Region).setMinSize(0.0, 0.0)
|
||||||
VBox.setVgrow(this.contentPlaceHolder, Priority.ALWAYS)
|
VBox.setVgrow(this.contentPlaceHolder, Priority.ALWAYS)
|
||||||
this.contentPlaceHolder.styleClass.add("resize-border")
|
this.contentPlaceHolder.styleClass.add("resize-border")
|
||||||
this.contentPlaceHolder.border = Border(*arrayOf(BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths(0.0, 4.0, 4.0, 4.0))))
|
this.contentPlaceHolder.border = Border(BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths(0.0, 4.0, 4.0, 4.0)))
|
||||||
val clip = Rectangle()
|
val clip = Rectangle()
|
||||||
clip.widthProperty().bind(node.widthProperty())
|
clip.widthProperty().bind(node.widthProperty())
|
||||||
clip.heightProperty().bind(node.heightProperty())
|
clip.heightProperty().bind(node.heightProperty())
|
||||||
node.setClip(clip)
|
node.setClip(clip)
|
||||||
this.children.addAll(*arrayOf<Node>(titleContainer, this.contentPlaceHolder))
|
this.children.addAll(titleContainer, this.contentPlaceHolder)
|
||||||
this.setOnMouseMoved { mouseEvent ->
|
this.setOnMouseMoved { mouseEvent ->
|
||||||
if (!this.primaryStage.isMaximized && !this.primaryStage.isFullScreen && !this.maximized) {
|
if (!this.primaryStage.isMaximized && !this.primaryStage.isFullScreen && !this.maximized) {
|
||||||
if (!this.primaryStage.isResizable) {
|
if (!this.primaryStage.isResizable) {
|
||||||
@@ -328,15 +328,13 @@ class Decorator @JvmOverloads constructor(private val primaryStage: Stage, node:
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun setStageWidth(width: Double): Boolean {
|
internal fun setStageWidth(width: Double): Boolean {
|
||||||
var width = width
|
|
||||||
if (width >= this.primaryStage.minWidth && width >= this.titleContainer.minWidth) {
|
if (width >= this.primaryStage.minWidth && width >= this.titleContainer.minWidth) {
|
||||||
this.primaryStage.width = width
|
this.primaryStage.width = width
|
||||||
this.initX = this.newX
|
this.initX = this.newX
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
if (width >= this.primaryStage.minWidth && width <= this.titleContainer.minWidth) {
|
if (width >= this.primaryStage.minWidth && width <= this.titleContainer.minWidth) {
|
||||||
width = this.titleContainer.minWidth
|
this.primaryStage.width = this.titleContainer.minWidth
|
||||||
this.primaryStage.width = width
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -344,15 +342,13 @@ class Decorator @JvmOverloads constructor(private val primaryStage: Stage, node:
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun setStageHeight(height: Double): Boolean {
|
internal fun setStageHeight(height: Double): Boolean {
|
||||||
var height = height
|
|
||||||
if (height >= this.primaryStage.minHeight && height >= this.titleContainer.height) {
|
if (height >= this.primaryStage.minHeight && height >= this.titleContainer.height) {
|
||||||
this.primaryStage.height = height
|
this.primaryStage.height = height
|
||||||
this.initY = this.newY
|
this.initY = this.newY
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
if (height >= this.primaryStage.minHeight && height <= this.titleContainer.height) {
|
if (height >= this.primaryStage.minHeight && height <= this.titleContainer.height) {
|
||||||
height = this.titleContainer.height
|
this.primaryStage.height = this.titleContainer.height
|
||||||
this.primaryStage.height = height
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -379,6 +375,6 @@ class Decorator @JvmOverloads constructor(private val primaryStage: Stage, node:
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setContent(content: Node) {
|
fun setContent(content: Node) {
|
||||||
this.contentPlaceHolder.children.setAll(*arrayOf(content))
|
this.contentPlaceHolder.children.setAll(content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
[13:06:53] [org.jackhuang.hmcl.util.task.Subscription.executeTask/FINER] Executing task: class org.jackhuang.hmcl.util.task.ParallelTask
|
|
||||||
[13:06:53] [org.jackhuang.hmcl.util.task.Subscription.executeTask/FINER] Executing task: class org.jackhuang.hmcl.download.game.GameAssetDownloadTask
|
|
||||||
[13:06:53] [org.jackhuang.hmcl.util.task.Subscription.executeTask/FINER] Executing task: class org.jackhuang.hmcl.download.game.GameLibrariesTask
|
|
||||||
[13:06:53] [org.jackhuang.hmcl.util.task.Subscription.executeTask/FINER] Executing task: class org.jackhuang.hmcl.download.game.GameLoggingDownloadTask
|
|
||||||
[13:06:53] [org.jackhuang.hmcl.util.task.Subscription.executeTask/FINEST] Task finished: class org.jackhuang.hmcl.download.game.GameAssetDownloadTask
|
|
||||||
[13:06:53] [org.jackhuang.hmcl.util.task.Subscription.executeTask/FINEST] Task finished: class org.jackhuang.hmcl.download.game.GameLoggingDownloadTask
|
|
||||||
[13:06:53] [org.jackhuang.hmcl.util.task.Subscription.executeTask/FINEST] Task finished: class org.jackhuang.hmcl.download.game.GameLibrariesTask
|
|
||||||
[13:06:53] [org.jackhuang.hmcl.util.task.Subscription.executeTask/FINEST] Task finished: class org.jackhuang.hmcl.util.task.ParallelTask
|
|
||||||
@@ -17,11 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.download
|
package org.jackhuang.hmcl.download
|
||||||
|
|
||||||
import org.jackhuang.hmcl.download.forge.ForgeVersionList
|
|
||||||
import org.jackhuang.hmcl.download.game.GameVersionList
|
|
||||||
import org.jackhuang.hmcl.download.liteloader.LiteLoaderVersionList
|
|
||||||
import org.jackhuang.hmcl.download.optifine.OptiFineBMCLVersionList
|
|
||||||
|
|
||||||
object BMCLAPIDownloadProvider : DownloadProvider() {
|
object BMCLAPIDownloadProvider : DownloadProvider() {
|
||||||
override val libraryBaseURL: String = "http://bmclapi2.bangbang93.com/libraries/"
|
override val libraryBaseURL: String = "http://bmclapi2.bangbang93.com/libraries/"
|
||||||
override val versionListURL: String = "http://bmclapi2.bangbang93.com/mc/game/version_manifest.json"
|
override val versionListURL: String = "http://bmclapi2.bangbang93.com/mc/game/version_manifest.json"
|
||||||
|
|||||||
@@ -17,11 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.download
|
package org.jackhuang.hmcl.download
|
||||||
|
|
||||||
import org.jackhuang.hmcl.download.game.GameAssetDownloadTask
|
|
||||||
import org.jackhuang.hmcl.download.game.GameLibrariesTask
|
|
||||||
import org.jackhuang.hmcl.download.game.GameLoggingDownloadTask
|
|
||||||
import org.jackhuang.hmcl.download.game.VersionJSONSaveTask
|
|
||||||
import org.jackhuang.hmcl.download.liteloader.LiteLoaderInstallTask
|
|
||||||
import org.jackhuang.hmcl.game.DefaultGameRepository
|
import org.jackhuang.hmcl.game.DefaultGameRepository
|
||||||
import org.jackhuang.hmcl.game.Version
|
import org.jackhuang.hmcl.game.Version
|
||||||
import org.jackhuang.hmcl.task.ParallelTask
|
import org.jackhuang.hmcl.task.ParallelTask
|
||||||
|
|||||||
@@ -17,10 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.download
|
package org.jackhuang.hmcl.download
|
||||||
|
|
||||||
import org.jackhuang.hmcl.download.game.GameAssetDownloadTask
|
|
||||||
import org.jackhuang.hmcl.download.game.GameLibrariesTask
|
|
||||||
import org.jackhuang.hmcl.download.game.GameLoggingDownloadTask
|
|
||||||
import org.jackhuang.hmcl.download.game.VersionJSONSaveTask
|
|
||||||
import org.jackhuang.hmcl.game.*
|
import org.jackhuang.hmcl.game.*
|
||||||
import org.jackhuang.hmcl.task.*
|
import org.jackhuang.hmcl.task.*
|
||||||
import org.jackhuang.hmcl.util.*
|
import org.jackhuang.hmcl.util.*
|
||||||
@@ -31,8 +27,8 @@ class DefaultGameBuilder(val dependencyManager: DefaultDependencyManager): GameB
|
|||||||
val downloadProvider = dependencyManager.downloadProvider
|
val downloadProvider = dependencyManager.downloadProvider
|
||||||
|
|
||||||
override fun buildAsync(): Task {
|
override fun buildAsync(): Task {
|
||||||
return VersionJSONDownloadTask(gameVersion = gameVersion) then { task ->
|
return VersionJSONDownloadTask(gameVersion = gameVersion) then a@{ task ->
|
||||||
var version = GSON.fromJson<Version>(task.result!!)
|
var version = GSON.fromJson<Version>(task.result!!) ?: return@a null
|
||||||
version = version.copy(jar = version.id, id = name)
|
version = version.copy(jar = version.id, id = name)
|
||||||
var result = ParallelTask(
|
var result = ParallelTask(
|
||||||
GameAssetDownloadTask(dependencyManager, version),
|
GameAssetDownloadTask(dependencyManager, version),
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.download
|
package org.jackhuang.hmcl.download
|
||||||
|
|
||||||
import org.jackhuang.hmcl.download.game.GameLibrariesTask
|
|
||||||
import org.jackhuang.hmcl.game.Library
|
import org.jackhuang.hmcl.game.Library
|
||||||
import org.jackhuang.hmcl.game.SimpleVersionProvider
|
import org.jackhuang.hmcl.game.SimpleVersionProvider
|
||||||
import org.jackhuang.hmcl.game.Version
|
import org.jackhuang.hmcl.game.Version
|
||||||
@@ -55,7 +54,7 @@ class ForgeInstallTask(private val dependencyManager: DefaultDependencyManager,
|
|||||||
|
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
ZipFile(installer).use { zipFile ->
|
ZipFile(installer).use { zipFile ->
|
||||||
val installProfile = GSON.fromJson<InstallProfile>(zipFile.getInputStream(zipFile.getEntry("install_profile.json")).readFullyAsString())
|
val installProfile = GSON.fromJson<InstallProfile>(zipFile.getInputStream(zipFile.getEntry("install_profile.json")).readFullyAsString()) ?: throw IOException("install_profile.json is not found.")
|
||||||
|
|
||||||
// unpack the universal jar in the installer file.
|
// unpack the universal jar in the installer file.
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ object GameVersionList : VersionList<GameRemoteVersionTag>() {
|
|||||||
val task = GetTask(provider.versionListURL.toURL())
|
val task = GetTask(provider.versionListURL.toURL())
|
||||||
override val dependents: Collection<Task> = listOf(task)
|
override val dependents: Collection<Task> = listOf(task)
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
versionMap.clear()
|
|
||||||
versions.clear()
|
versions.clear()
|
||||||
|
|
||||||
val root = GSON.fromJson<GameRemoteVersions>(task.result!!) ?: return
|
val root = GSON.fromJson<GameRemoteVersions>(task.result!!) ?: return
|
||||||
@@ -50,8 +49,7 @@ object GameVersionList : VersionList<GameRemoteVersionTag>() {
|
|||||||
time = remoteVersion.releaseTime
|
time = remoteVersion.releaseTime
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
versions.add(x)
|
versions.put(gg, x)
|
||||||
versionMap[gg] = listOf(x)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.download
|
package org.jackhuang.hmcl.download
|
||||||
|
|
||||||
import org.jackhuang.hmcl.download.game.GameLibrariesTask
|
|
||||||
import org.jackhuang.hmcl.game.LibrariesDownloadInfo
|
import org.jackhuang.hmcl.game.LibrariesDownloadInfo
|
||||||
import org.jackhuang.hmcl.game.Library
|
import org.jackhuang.hmcl.game.Library
|
||||||
import org.jackhuang.hmcl.game.LibraryDownloadInfo
|
import org.jackhuang.hmcl.game.LibraryDownloadInfo
|
||||||
|
|||||||
@@ -17,9 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.download
|
package org.jackhuang.hmcl.download
|
||||||
|
|
||||||
import org.jackhuang.hmcl.download.forge.ForgeVersionList
|
|
||||||
import org.jackhuang.hmcl.download.game.GameVersionList
|
|
||||||
import org.jackhuang.hmcl.download.liteloader.LiteLoaderVersionList
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object MojangDownloadProvider : DownloadProvider() {
|
object MojangDownloadProvider : DownloadProvider() {
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ object OptiFineBMCLVersionList : VersionList<Unit>() {
|
|||||||
val task = GetTask("http://bmclapi.bangbang93.com/optifine/versionlist".toURL())
|
val task = GetTask("http://bmclapi.bangbang93.com/optifine/versionlist".toURL())
|
||||||
override val dependents: Collection<Task> = listOf(task)
|
override val dependents: Collection<Task> = listOf(task)
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
versionMap.clear()
|
|
||||||
versions.clear()
|
versions.clear()
|
||||||
|
|
||||||
val duplicates = mutableSetOf<String>()
|
val duplicates = mutableSetOf<String>()
|
||||||
@@ -55,9 +54,7 @@ object OptiFineBMCLVersionList : VersionList<Unit>() {
|
|||||||
tag = Unit
|
tag = Unit
|
||||||
)
|
)
|
||||||
|
|
||||||
val set = versionMap.getOrPut(gameVersion, { TreeSet<RemoteVersion<Unit>>() }) as MutableCollection<RemoteVersion<Unit>>
|
versions.put(gameVersion, remoteVersion)
|
||||||
set.add(remoteVersion)
|
|
||||||
versions.add(remoteVersion)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.download
|
package org.jackhuang.hmcl.download
|
||||||
|
|
||||||
import org.jackhuang.hmcl.download.game.GameLibrariesTask
|
|
||||||
import org.jackhuang.hmcl.game.LibrariesDownloadInfo
|
import org.jackhuang.hmcl.game.LibrariesDownloadInfo
|
||||||
import org.jackhuang.hmcl.game.Library
|
import org.jackhuang.hmcl.game.Library
|
||||||
import org.jackhuang.hmcl.game.LibraryDownloadInfo
|
import org.jackhuang.hmcl.game.LibraryDownloadInfo
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ abstract class VersionList<T> {
|
|||||||
abstract fun refreshAsync(downloadProvider: DownloadProvider): Task
|
abstract fun refreshAsync(downloadProvider: DownloadProvider): Task
|
||||||
|
|
||||||
protected open fun getVersionsImpl(gameVersion: String): Collection<RemoteVersion<T>> {
|
protected open fun getVersionsImpl(gameVersion: String): Collection<RemoteVersion<T>> {
|
||||||
return versions[gameVersion] ?: versions.values
|
val ans = versions[gameVersion]
|
||||||
|
return if (ans.isEmpty()) versions.values else ans
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +45,7 @@ abstract class VersionList<T> {
|
|||||||
|
|
||||||
fun getVersion(gameVersion: String, remoteVersion: String): RemoteVersion<T>? {
|
fun getVersion(gameVersion: String, remoteVersion: String): RemoteVersion<T>? {
|
||||||
var result : RemoteVersion<T>? = null
|
var result : RemoteVersion<T>? = null
|
||||||
versions[gameVersion]?.forEach {
|
versions[gameVersion].forEach {
|
||||||
if (it.selfVersion == remoteVersion)
|
if (it.selfVersion == remoteVersion)
|
||||||
result = it
|
result = it
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ open class DefaultGameRepository(val baseDirectory: File): GameRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getAssetIndex(assetId: String): AssetIndex {
|
override fun getAssetIndex(assetId: String): AssetIndex {
|
||||||
return GSON.fromJson(getIndexFile(assetId).readText())
|
return GSON.fromJson(getIndexFile(assetId).readText())!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getActualAssetDirectory(assetId: String): File {
|
override fun getActualAssetDirectory(assetId: String): File {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class ModManager(private val repository: GameRepository) {
|
|||||||
fun getMods(id: String) : Collection<ModInfo> {
|
fun getMods(id: String) : Collection<ModInfo> {
|
||||||
if (!modCache.containsKey(id))
|
if (!modCache.containsKey(id))
|
||||||
refreshMods(id)
|
refreshMods(id)
|
||||||
return modCache[id] ?: emptyList()
|
return modCache[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addMod(id: String, file: File) {
|
fun addMod(id: String, file: File) {
|
||||||
|
|||||||
Reference in New Issue
Block a user