mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Resolved #9416 - failure to get preview image no longer causes crash
This commit is contained in:
parent
a91dca0930
commit
280025fa10
@ -252,15 +252,19 @@ object Github {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tryGetPreviewImage(modUrl:String, defaultBranch: String): Pixmap?{
|
fun tryGetPreviewImage(modUrl:String, defaultBranch: String): Pixmap? {
|
||||||
val fileLocation = "$modUrl/$defaultBranch/preview"
|
val fileLocation = "$modUrl/$defaultBranch/preview"
|
||||||
.replace("github.com", "raw.githubusercontent.com")
|
.replace("github.com", "raw.githubusercontent.com")
|
||||||
val file = download("$fileLocation.jpg")
|
try {
|
||||||
?: download("$fileLocation.png")
|
val file = download("$fileLocation.jpg")
|
||||||
?: return null
|
?: download("$fileLocation.png")
|
||||||
val byteArray = file.readBytes()
|
?: return null
|
||||||
val buffer = ByteBuffer.allocateDirect(byteArray.size).put(byteArray).position(0)
|
val byteArray = file.readBytes()
|
||||||
return Pixmap(buffer)
|
val buffer = ByteBuffer.allocateDirect(byteArray.size).put(byteArray).position(0)
|
||||||
|
return Pixmap(buffer)
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tree {
|
class Tree {
|
||||||
|
@ -192,7 +192,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!unit.isCivilian()) {
|
if (!unit.isCivilian()) {
|
||||||
unitDescriptionTable.add("XP".tr().toLabel().apply {
|
unitDescriptionTable.add("XP".toLabel().apply {
|
||||||
onClick {
|
onClick {
|
||||||
if (selectedUnit == null) return@onClick
|
if (selectedUnit == null) return@onClick
|
||||||
worldScreen.game.pushScreen(PromotionPickerScreen(unit))
|
worldScreen.game.pushScreen(PromotionPickerScreen(unit))
|
||||||
|
@ -1952,7 +1952,7 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
|||||||
|
|
||||||
Applicable to: TriggerCondition
|
Applicable to: TriggerCondition
|
||||||
|
|
||||||
??? example "<upon adopting [policy]>"
|
??? example "<upon adopting [policy/belief]>"
|
||||||
Example: "<upon adopting [Oligarchy]>"
|
Example: "<upon adopting [Oligarchy]>"
|
||||||
|
|
||||||
Applicable to: TriggerCondition
|
Applicable to: TriggerCondition
|
||||||
|
Loading…
x
Reference in New Issue
Block a user