mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -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
|
||||
}
|
||||
|
||||
fun tryGetPreviewImage(modUrl:String, defaultBranch: String): Pixmap?{
|
||||
fun tryGetPreviewImage(modUrl:String, defaultBranch: String): Pixmap? {
|
||||
val fileLocation = "$modUrl/$defaultBranch/preview"
|
||||
.replace("github.com", "raw.githubusercontent.com")
|
||||
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)
|
||||
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 {
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user