Skip to content

Commit

Permalink
Merge branch 'yairm210:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
metablaster authored Dec 18, 2024
2 parents 87321c0 + b0bf22e commit 8eee850
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
9 changes: 6 additions & 3 deletions android/src/com/unciv/app/AndroidLauncher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions core/src/com/unciv/ui/audio/MusicController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
22 changes: 13 additions & 9 deletions core/src/com/unciv/ui/screens/modmanager/ModManagementScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8eee850

Please sign in to comment.