Removed unused Fonts functions

Fixed bug on city creation caused by 750ca0c
This commit is contained in:
Yair Morgenstern
2019-10-31 09:46:33 +02:00
parent dbbfd13486
commit 18ffe9b67f
2 changed files with 6 additions and 40 deletions

View File

@ -75,14 +75,15 @@ class CityExpansionManager {
for(tile in cityInfo.getTiles())
relinquishOwnership(tile)
cityInfo.getCenterTile().getTilesInDistance(1)
.filter { it.getCity()==null } // can't take ownership of owned tiles (by other cities)
.forEach { takeOwnership(it) }
// The only way to create a city inside an owned tile is if it's in your territory
// In this case, if you don't assign control of the central tile to the city,
// It becomes an invisible city and weird shit starts happening
takeOwnership(cityInfo.getCenterTile())
cityInfo.getCenterTile().getTilesInDistance(1)
.filter { it.getCity()==null } // can't take ownership of owned tiles (by other cities)
.forEach { takeOwnership(it) }
}
private fun addNewTileWithCulture() {

View File

@ -6,48 +6,13 @@ import com.unciv.UnCivGame
import com.unciv.models.gamebasics.GameBasics
import core.java.nativefont.NativeFont
import core.java.nativefont.NativeFontPaint
import java.io.FileInputStream
import java.io.FileOutputStream
import java.net.URL
import java.security.MessageDigest
class Fonts {
// caches for memory and time saving
companion object {
val characterSetCache = HashMap<String, String>()
val fontCache = HashMap<String, BitmapFont>()
}
fun download(link: String,fontForLanguage: String) {
if (!Gdx.files.local("fonts").exists())
Gdx.files.local("fonts").mkdirs()
val input = URL(link).openStream()
val output = FileOutputStream(Gdx.files.local("fonts/$fontForLanguage.ttf").file())
input.use {
output.use {
input.copyTo(output)
}
}
}
fun getMD5(fontForLanguage: String):String {
val sb = StringBuffer("")
val md = MessageDigest.getInstance("MD5")
if (Gdx.files.local("fonts/$fontForLanguage.ttf").exists()) {
md.update(FileInputStream(Gdx.files.local("fonts/$fontForLanguage.ttf").file()).readBytes())
val b = md.digest()
for (i in b) {
var d = i.toInt()
if (d < 0) d = i + 256
if (d < 16) sb.append("0")
sb.append(Integer.toHexString(d))
}
return sb.toString()
}
return ""
}
fun containsFont(): Boolean {
if (Gdx.files.local("fonts/WenQuanYiMicroHei.ttf").exists())
return true
return false
}
fun getCharactersForFont(language:String=""): String {
if (characterSetCache.containsKey(language)) return characterSetCache[language]!!