mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 05:41:11 +07:00
now you only need to create font once. (#1269)
* update * update * update * update * update * update * update * range extension * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update
This commit is contained in:

committed by
Yair Morgenstern

parent
39314a5543
commit
4d5ae8fa25
@ -16,6 +16,7 @@ import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
import java.util.*
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class UnCivGame(val version: String) : Game() {
|
||||
var gameInfo: GameInfo = GameInfo()
|
||||
@ -56,7 +57,7 @@ class UnCivGame(val version: String) : Game() {
|
||||
}
|
||||
else setScreen(LanguagePickerScreen())
|
||||
|
||||
startMusic()
|
||||
thread { startMusic() }
|
||||
}
|
||||
|
||||
fun startMusic(){
|
||||
|
@ -41,7 +41,7 @@ object GameBasics {
|
||||
val techColumns = getFromJson(Array<TechColumn>::class.java, "Techs")
|
||||
for (techColumn in techColumns) {
|
||||
for (tech in techColumn.techs) {
|
||||
tech.cost = techColumn.techCost
|
||||
if (tech.cost==0) tech.cost = techColumn.techCost
|
||||
tech.column = techColumn
|
||||
Technologies[tech.name] = tech
|
||||
}
|
||||
|
@ -62,15 +62,15 @@ open class CameraStageBaseScreen : Screen {
|
||||
}
|
||||
|
||||
fun resetFonts(){
|
||||
skin.get(TextButton.TextButtonStyle::class.java).font = Fonts().getFont(20)
|
||||
skin.get(CheckBox.CheckBoxStyle::class.java).font= Fonts().getFont(20)
|
||||
skin.get(TextButton.TextButtonStyle::class.java).font = Fonts().getFont(45).apply { data.setScale(20/45f) }
|
||||
skin.get(CheckBox.CheckBoxStyle::class.java).font= Fonts().getFont(45).apply { data.setScale(20/45f) }
|
||||
skin.get(Label.LabelStyle::class.java).apply {
|
||||
font = Fonts().getFont(18)
|
||||
font = Fonts().getFont(45).apply { data.setScale(18/45f) }
|
||||
fontColor= Color.WHITE
|
||||
}
|
||||
skin.get(TextField.TextFieldStyle::class.java).font = Fonts().getFont(18)
|
||||
skin.get(SelectBox.SelectBoxStyle::class.java).font = Fonts().getFont(20)
|
||||
skin.get(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts().getFont(20)
|
||||
skin.get(TextField.TextFieldStyle::class.java).font = Fonts().getFont(45).apply { data.setScale(18/45f) }
|
||||
skin.get(SelectBox.SelectBoxStyle::class.java).font = Fonts().getFont(45).apply { data.setScale(20/45f) }
|
||||
skin.get(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts().getFont(45).apply { data.setScale(20/45f) }
|
||||
skin.get(CheckBox.CheckBoxStyle::class.java).fontColor= Color.WHITE
|
||||
}
|
||||
internal var batch: Batch = SpriteBatch()
|
||||
@ -208,9 +208,9 @@ fun String.toLabel(fontColor:Color= Color.WHITE, fontSize:Int=18): Label {
|
||||
if(fontColor!= Color.WHITE || fontSize!=18) { // if we want the default we don't need to create another style
|
||||
labelStyle = Label.LabelStyle(labelStyle) // clone this to another
|
||||
labelStyle.fontColor = fontColor
|
||||
if (fontSize != 18) labelStyle.font = Fonts().getFont(fontSize)
|
||||
if (fontSize != 18) labelStyle.font = Fonts().getFont(45)
|
||||
}
|
||||
return Label(this.tr(),labelStyle)
|
||||
return Label(this.tr(),labelStyle).apply { setFontScale(fontSize/45f) }
|
||||
}
|
||||
|
||||
|
||||
@ -218,7 +218,7 @@ fun Label.setFontColor(color:Color): Label {style=Label.LabelStyle(style).apply
|
||||
|
||||
fun Label.setFontSize(size:Int): Label {
|
||||
style = Label.LabelStyle(style)
|
||||
style.font = Fonts().getFont(size)
|
||||
style.font = Fonts().getFont(45)
|
||||
style = style // because we need it to call the SetStyle function. Yuk, I know.
|
||||
return this // for chaining
|
||||
return this.apply { setFontScale(size/45f) } // for chaining
|
||||
}
|
||||
|
Reference in New Issue
Block a user