Merge branch 'master' of github.com:metablaster/Unciv

This commit is contained in:
metablaster 2024-12-18 18:15:05 +01:00
commit f7f11cb733
No known key found for this signature in database
GPG Key ID: 36C4D30896DF4C61
4 changed files with 29 additions and 20 deletions

View File

@ -11,6 +11,7 @@ import com.unciv.ui.components.fonts.Fonts
import com.unciv.utils.Display
import com.unciv.utils.Log
import java.io.File
import java.lang.Exception
open class AndroidLauncher : AndroidApplication() {
@ -65,9 +66,11 @@ open class AndroidLauncher : AndroidApplication() {
val externalPath = getExternalFilesDir(null)?.path ?: return
val externalModsDir = File("$externalPath/mods")
// Copy external mod directory (with data user put in it) to internal (where it can be read)
if (!externalModsDir.exists()) externalModsDir.mkdirs() // this can fail sometimes, which is why we check if it exists again in the next line
if (externalModsDir.exists()) externalModsDir.copyRecursively(internalModsDir, true)
try { // Rarely we get a kotlin.io.AccessDeniedException, if so - no biggie
// Copy external mod directory (with data user put in it) to internal (where it can be read)
if (!externalModsDir.exists()) externalModsDir.mkdirs() // this can fail sometimes, which is why we check if it exists again in the next line
if (externalModsDir.exists()) externalModsDir.copyRecursively(internalModsDir, true)
} catch (ex: Exception) {}
}
override fun onPause() {

View File

@ -630,8 +630,10 @@ class MusicController {
isLooping: Boolean = false,
fadeIn: Boolean = false
) {
val file = getMatchingFiles(folder, name).firstOrNull() ?: return
playOverlay(file, volume, isLooping, fadeIn)
Concurrency.run { // no reason for this to run on GL thread
val file = getMatchingFiles(folder, name).firstOrNull() ?: return@run
playOverlay(file, volume, isLooping, fadeIn)
}
}
/** Called for Leader Voices */

View File

@ -414,15 +414,19 @@ class ModManagementScreen private constructor(
actualDownloadButton.onClick {
actualDownloadButton.setText("Downloading...".tr())
actualDownloadButton.disable()
val repo = GithubAPI.Repo.parseUrl(textField.text)
if (repo == null) {
ToastPopup("«RED»{Invalid link!}«»", this@ModManagementScreen)
actualDownloadButton.setText("Download".tr())
actualDownloadButton.enable()
} else
downloadMod(repo, {
actualDownloadButton.setText("{Downloading...} ${it}%".tr())
}) { popup.close() }
Concurrency.run {
val repo = GithubAPI.Repo.parseUrl(textField.text)
if (repo == null) {
Concurrency.runOnGLThread {
ToastPopup("«RED»{Invalid link!}«»", this@ModManagementScreen)
actualDownloadButton.setText("Download".tr())
actualDownloadButton.enable()
}
} else
downloadMod(repo, {
actualDownloadButton.setText("{Downloading...} ${it}%".tr())
}) { popup.close() }
}
}
popup.add(actualDownloadButton).row()
popup.addCloseButton()

View File

@ -66,8 +66,8 @@ class GlobalPoliticsOverviewTable(
}
// Reusable sequences for the Civilizations to display
private var undefeatedCivs = sequenceOf<Civilization>()
private var defeatedCivs = sequenceOf<Civilization>()
private var undefeatedCivs = listOf<Civilization>()
private var defeatedCivs = listOf<Civilization>()
private var relevantCivsCount = "?" // includes unknown civs if player allowed to know
private var showDiplomacyGroup = false
@ -292,10 +292,10 @@ class GlobalPoliticsOverviewTable(
else gameInfo.civilizations.count {
!it.isSpectator() && !it.isBarbarian && (persistableData.includeCityStates || !it.isCityState)
}.tr()
undefeatedCivs = sequenceOf(viewingPlayer) +
undefeatedCivs = listOf(viewingPlayer) +
viewingPlayer.diplomacyFunctions.getKnownCivsSorted(persistableData.includeCityStates)
defeatedCivs = viewingPlayer.diplomacyFunctions.getKnownCivsSorted(persistableData.includeCityStates, true)
.filter { it.isDefeated() }
.filter { it.isDefeated() }.toList()
clear()
fixedContent.clear()
@ -373,7 +373,7 @@ class GlobalPoliticsOverviewTable(
add("Turns until the next\ndiplomacy victory vote: [$turnsTillNextDiplomaticVote]".toLabel()).colspan(columns).row()
}
private fun Table.addCivsCategory(columns: Int, aliveOrDefeated: String, civs: Sequence<Civilization>) {
private fun Table.addCivsCategory(columns: Int, aliveOrDefeated: String, civs: List<Civilization>) {
addSeparator()
val count = civs.count()
add("Known and $aliveOrDefeated ([$count])".toLabel())
@ -410,7 +410,7 @@ class GlobalPoliticsOverviewTable(
* @param freeSize Width and height this [Group] sizes itself to
*/
private class DiplomacyGroup(
undefeatedCivs: Sequence<Civilization>,
undefeatedCivs: List<Civilization>,
freeSize: Float
): Group() {
private fun onCivClicked(civLines: HashMap<String, MutableSet<Actor>>, name: String) {