From bfaae548907eafa63c15fb4d0a3507b65d867607 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 18 Feb 2023 19:25:07 +0200 Subject: [PATCH] Mod sizes larger than 2 MB are displayed in MB --- .../assets/jsons/translations/template.properties | 1 + .../unciv/ui/pickerscreens/ModManagementScreen.kt | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index bd7883bb6a..5b8c1fcaab 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1635,6 +1635,7 @@ No description provided = [stargazers]✯ = Author: [author] = Size: [size] kB = +Size: [size] MB = The mod you selected is incompatible with the defined ruleset! = Sort and Filter = Enter search text = diff --git a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt index 4d1d0acb3d..5eb15640b5 100644 --- a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt @@ -10,7 +10,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.badlogic.gdx.utils.Align -import com.badlogic.gdx.utils.Json import com.badlogic.gdx.utils.SerializationException import com.unciv.MainMenuScreen import com.unciv.UncivGame @@ -48,13 +47,9 @@ import com.unciv.ui.utils.extensions.toTextButton import com.unciv.utils.Log import com.unciv.utils.concurrency.Concurrency import com.unciv.utils.concurrency.launchOnGLThread -import com.unciv.utils.concurrency.withGLContext import kotlinx.coroutines.Job import kotlinx.coroutines.isActive import java.io.IOException -import java.net.HttpURLConnection -import java.net.URL -import java.net.URLConnection import kotlin.math.max /** @@ -364,10 +359,16 @@ class ModManagementScreen( // remember selected mod - for now needed only to display a background-fetched image while the user is watching // Display metadata + + if (author.isNotEmpty()) modActionTable.add("Author: [$author]".toLabel()).row() - if (modSize > 0) - modActionTable.add("Size: [$modSize] kB".toLabel()).padBottom(15f).row() + if (modSize > 0){ + if (modSize < 2048) + modActionTable.add("Size: [$modSize] kB".toLabel()).padBottom(15f).row() + else + modActionTable.add("Size: [${modSize/1024}] MB".toLabel()).padBottom(15f).row() + } // offer link to open the repo itself in a browser if (repoUrl != "") {