NativeFont has proved itself well enough - got rid of old WenQuanYiMicroHei font and corresponding setting
This commit is contained in:
parent
232896665e
commit
8151476806
4 changed files with 2 additions and 100 deletions
|
@ -21,8 +21,8 @@ android {
|
|||
applicationId "com.unciv.app"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 29
|
||||
versionCode 314
|
||||
versionName "3.1.9"
|
||||
versionCode 315
|
||||
versionName "3.1.10"
|
||||
}
|
||||
|
||||
// Had to add this crap for Travis to build, it wanted to sign the app
|
||||
|
|
|
@ -7,7 +7,6 @@ class GameSettings {
|
|||
var showResourcesAndImprovements: Boolean = true
|
||||
var checkForDueUnits: Boolean = true
|
||||
var singleTapMove: Boolean = false
|
||||
var fontSet:String = "NativeFont(Recommended)"
|
||||
var language: String = "English"
|
||||
var resolution: String = "1050x700"
|
||||
var tutorialsShown = ArrayList<String>()
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
package com.unciv.ui.utils
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
||||
import core.java.nativefont.NativeFont
|
||||
import core.java.nativefont.NativeFontPaint
|
||||
import java.io.FileInputStream
|
||||
|
@ -87,36 +82,6 @@ class Fonts {
|
|||
}
|
||||
|
||||
fun getFont(size: Int): BitmapFont {
|
||||
|
||||
if(UnCivGame.Current.settings.fontSet=="WenQuanYiMicroHei"){
|
||||
val fontForLanguage="WenQuanYiMicroHei"
|
||||
val keyForFont = "$fontForLanguage $size"
|
||||
if (fontCache.containsKey(keyForFont))
|
||||
return fontCache[keyForFont]!!
|
||||
if (getMD5(fontForLanguage)!="96574d6f2f2bbd4a3ce56979623b1952"){
|
||||
Gdx.files.local("fonts/$fontForLanguage.ttf").delete()
|
||||
UnCivGame.Current.settings.fontSet="NativeFont(Recommended)"
|
||||
Gdx.app.postRunnable {
|
||||
val checksumFailed = PopupTable(UnCivGame.Current.worldScreen)
|
||||
checksumFailed.add("Checksum error!\nIf you want to use the font \"WenQuanYiMicroHei\", please download again.".toLabel().setFontColor(Color.RED)).row()
|
||||
checksumFailed.addButton("Close".tr()) { checksumFailed.remove() }.row()
|
||||
checksumFailed.open()
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
val generator = FreeTypeFontGenerator(Gdx.files.local("fonts/WenQuanYiMicroHei.ttf"))
|
||||
val parameter = FreeTypeFontGenerator.FreeTypeFontParameter()
|
||||
parameter.size = size
|
||||
parameter.minFilter = Texture.TextureFilter.Linear
|
||||
parameter.magFilter = Texture.TextureFilter.Linear
|
||||
parameter.characters = getCharactersForFont(UnCivGame.Current.settings.language)
|
||||
val font = generator.generateFont(parameter)
|
||||
fontCache[keyForFont] = font
|
||||
return font
|
||||
}
|
||||
}
|
||||
|
||||
val language = UnCivGame.Current.settings.language
|
||||
val fontForLanguage ="Nativefont"
|
||||
val isUniqueFont = language.contains("Chinese") || language == "Korean"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.unciv.ui.worldscreen.optionstable
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||
|
@ -14,8 +12,6 @@ import com.unciv.models.gamebasics.GameBasics
|
|||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
import java.io.IOException
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class Language(val language:String){
|
||||
val percentComplete:Int
|
||||
|
@ -110,8 +106,6 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
|||
|
||||
addLanguageSelectBox(innerTable)
|
||||
|
||||
addFontSelectBox(innerTable)
|
||||
|
||||
addResolutionSelectBox(innerTable)
|
||||
|
||||
addAutosaveTurnsSelectBox(innerTable)
|
||||
|
@ -230,62 +224,6 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
|||
})
|
||||
}
|
||||
|
||||
private fun addFontSelectBox(innerTable: PopupTable) {
|
||||
innerTable.add("Fontset".toLabel())
|
||||
val FontSetSelectBox = SelectBox<String>(skin)
|
||||
val FontSetArray = Array<String>()
|
||||
FontSetArray.add("NativeFont(Recommended)")
|
||||
FontSetArray.add("WenQuanYiMicroHei")
|
||||
FontSetSelectBox.items = FontSetArray
|
||||
FontSetSelectBox.selected = UnCivGame.Current.settings.fontSet
|
||||
innerTable.add(FontSetSelectBox).pad(10f).row()
|
||||
|
||||
FontSetSelectBox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
UnCivGame.Current.settings.fontSet = FontSetSelectBox.selected
|
||||
if (FontSetSelectBox.selected == "NativeFont(Recommended)"||Fonts().containsFont()) {
|
||||
selectFont()
|
||||
}
|
||||
else {
|
||||
YesNoPopupTable("This Font requires you to download fonts.\n" +
|
||||
"Do you want to download fonts(about 4.2MB)?",
|
||||
{
|
||||
val downloadingFontPopup = PopupTable(screen)
|
||||
downloadingFontPopup.add("Downloading...\n".toLabel()).row()
|
||||
downloadingFontPopup.add("Warning:Don't switch this game to background until download finished.".toLabel().setFontColor(Color.RED)).row()
|
||||
downloadingFontPopup.open()
|
||||
Gdx.input.inputProcessor = null
|
||||
thread {
|
||||
try {
|
||||
Fonts().download("https://github.com/layerssss/wqy/raw/gh-pages/fonts/WenQuanYiMicroHei.ttf", "WenQuanYiMicroHei")//This font is licensed under Apache2.0 or GPLv3
|
||||
Gdx.app.postRunnable {
|
||||
selectFont()
|
||||
}
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Gdx.app.postRunnable {
|
||||
FontSetSelectBox.selected = "NativeFont(Recommended)"
|
||||
val downloadFailedPopup = PopupTable(UnCivGame.Current.worldScreen)
|
||||
downloadFailedPopup.add("Download failed!\nPlease check your internet connection.".toLabel().setFontColor(Color.RED)).row()
|
||||
downloadFailedPopup.addCloseButton()
|
||||
downloadFailedPopup.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
}, UnCivGame.Current.worldScreen, {FontSetSelectBox.selected = "NativeFont(Recommended)"})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun selectFont(){
|
||||
UnCivGame.Current.settings.save()
|
||||
CameraStageBaseScreen.resetFonts()
|
||||
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.viewingCiv)
|
||||
UnCivGame.Current.setWorldScreen()
|
||||
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
||||
}
|
||||
|
||||
private fun addLanguageSelectBox(innerTable: PopupTable) {
|
||||
innerTable.add("Language".toLabel())
|
||||
val languageSelectBox = SelectBox<Language>(skin)
|
||||
|
|
Loading…
Reference in a new issue