Resolved #9416 - failure to get preview image no longer causes crash

This commit is contained in:
Yair Morgenstern 2023-05-21 12:35:57 +03:00
parent a91dca0930
commit 280025fa10
3 changed files with 13 additions and 9 deletions

View File

@ -255,12 +255,16 @@ object Github {
fun tryGetPreviewImage(modUrl:String, defaultBranch: String): Pixmap? {
val fileLocation = "$modUrl/$defaultBranch/preview"
.replace("github.com", "raw.githubusercontent.com")
try {
val file = download("$fileLocation.jpg")
?: download("$fileLocation.png")
?: return null
val byteArray = file.readBytes()
val buffer = ByteBuffer.allocateDirect(byteArray.size).put(byteArray).position(0)
return Pixmap(buffer)
} catch (ex: Exception) {
return null
}
}
class Tree {

View File

@ -192,7 +192,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {
}
if (!unit.isCivilian()) {
unitDescriptionTable.add("XP".tr().toLabel().apply {
unitDescriptionTable.add("XP".toLabel().apply {
onClick {
if (selectedUnit == null) return@onClick
worldScreen.game.pushScreen(PromotionPickerScreen(unit))

View File

@ -1952,7 +1952,7 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: TriggerCondition
??? example "<upon adopting [policy]>"
??? example "<upon adopting [policy/belief]>"
Example: "<upon adopting [Oligarchy]>"
Applicable to: TriggerCondition