mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2024-12-27 07:10:41 +08:00
Merge 'arguments'
This commit is contained in:
parent
b81b38f7e4
commit
d2529cfc23
@ -20,6 +20,7 @@ package org.jackhuang.hmcl.game
|
|||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
import org.jackhuang.hmcl.util.OS
|
import org.jackhuang.hmcl.util.OS
|
||||||
import org.jackhuang.hmcl.game.CompatibilityRule.*
|
import org.jackhuang.hmcl.game.CompatibilityRule.*
|
||||||
|
import org.jackhuang.hmcl.util.merge
|
||||||
|
|
||||||
class Arguments @JvmOverloads constructor(
|
class Arguments @JvmOverloads constructor(
|
||||||
@SerializedName("game")
|
@SerializedName("game")
|
||||||
@ -28,6 +29,16 @@ class Arguments @JvmOverloads constructor(
|
|||||||
val jvm: List<Argument>? = null
|
val jvm: List<Argument>? = null
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
|
fun mergeArguments(a: Arguments?, b: Arguments?): Arguments? {
|
||||||
|
if (a == null && b == null) return null
|
||||||
|
else if (a == null) return b
|
||||||
|
else if (b == null) return a
|
||||||
|
else return Arguments(
|
||||||
|
game = merge(a.game, b.game),
|
||||||
|
jvm = merge(a.jvm, b.jvm)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun parseStringArguments(arguments: List<String>, keys: Map<String, String>, features: Map<String, Boolean> = emptyMap()): List<String> {
|
fun parseStringArguments(arguments: List<String>, keys: Map<String, String>, features: Map<String, Boolean> = emptyMap()): List<String> {
|
||||||
return arguments.flatMap { StringArgument(it).toString(keys, features) }
|
return arguments.flatMap { StringArgument(it).toString(keys, features) }
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,7 @@ open class Version(
|
|||||||
libraries = merge(this.libraries, parent.libraries),
|
libraries = merge(this.libraries, parent.libraries),
|
||||||
downloads = this.downloads ?: parent.downloads,
|
downloads = this.downloads ?: parent.downloads,
|
||||||
assetIndex = this.assetIndex ?: parent.assetIndex,
|
assetIndex = this.assetIndex ?: parent.assetIndex,
|
||||||
|
arguments = Arguments.mergeArguments(parent.arguments, this.arguments),
|
||||||
releaseTime = this.releaseTime,
|
releaseTime = this.releaseTime,
|
||||||
inheritsFrom = null,
|
inheritsFrom = null,
|
||||||
minecraftArguments = this.minecraftArguments ?: parent.minecraftArguments,
|
minecraftArguments = this.minecraftArguments ?: parent.minecraftArguments,
|
||||||
|
@ -32,11 +32,10 @@ import org.jackhuang.hmcl.util.guessLogLineError
|
|||||||
internal class ExitWaiter(val process: ManagedProcess, val joins: Collection<Thread>, val watcher: (Int, ProcessListener.ExitType) -> Unit) : Runnable {
|
internal class ExitWaiter(val process: ManagedProcess, val joins: Collection<Thread>, val watcher: (Int, ProcessListener.ExitType) -> Unit) : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
try {
|
try {
|
||||||
process.process.waitFor()
|
val exitCode = process.process.waitFor()
|
||||||
|
|
||||||
joins.forEach { it.join() }
|
joins.forEach { it.join() }
|
||||||
|
|
||||||
val exitCode = process.exitCode
|
|
||||||
val errorLines = process.lines.filter(::guessLogLineError)
|
val errorLines = process.lines.filter(::guessLogLineError)
|
||||||
val exitType: ProcessListener.ExitType
|
val exitType: ProcessListener.ExitType
|
||||||
// LaunchWrapper will catch the exception logged and will exit normally.
|
// LaunchWrapper will catch the exception logged and will exit normally.
|
||||||
|
@ -50,9 +50,10 @@ fun <T> copyList(list: List<T>?): MutableList<T>? =
|
|||||||
if (list == null) null
|
if (list == null) null
|
||||||
else LinkedList(list)
|
else LinkedList(list)
|
||||||
|
|
||||||
fun <T> merge(vararg c: Collection<T>): List<T> = LinkedList<T>().apply {
|
fun <T> merge(vararg c: Collection<T>?): List<T> = LinkedList<T>().apply {
|
||||||
for (a in c)
|
for (a in c)
|
||||||
addAll(a)
|
if (a != null)
|
||||||
|
addAll(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isBlank(str: String?) = str?.isBlank() ?: true
|
fun isBlank(str: String?) = str?.isBlank() ?: true
|
||||||
|
Loading…
Reference in New Issue
Block a user