mirror of
https://github.com/jlengrand/korge-samples.git
synced 2026-03-10 08:31:18 +00:00
UI - Let's use debug font for faster startup (instead of generating the font at runtime)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import com.soywiz.klock.*
|
||||
import com.soywiz.korge.*
|
||||
import com.soywiz.korge.html.*
|
||||
import com.soywiz.korge.input.*
|
||||
import com.soywiz.korge.newui.*
|
||||
import com.soywiz.korge.scene.*
|
||||
import com.soywiz.korge.tween.*
|
||||
import com.soywiz.korge.view.*
|
||||
import com.soywiz.korgw.*
|
||||
@@ -11,7 +13,7 @@ import com.soywiz.korio.async.*
|
||||
import com.soywiz.korma.interpolation.*
|
||||
|
||||
suspend fun main() = Korge(quality = GameWindow.Quality.PERFORMANCE, title = "UI") {
|
||||
uiSkin(OtherUISkin) {
|
||||
uiSkin(OtherUISkin()) {
|
||||
uiButton(256.0, 32.0) {
|
||||
label = "Disabled Button"
|
||||
position(128, 128)
|
||||
@@ -77,11 +79,12 @@ private val OTHER_UI_SKIN_IMG by lazy {
|
||||
DEFAULT_UI_SKIN_IMG.withColorTransform(otherColorTransform)
|
||||
}
|
||||
|
||||
val OtherUISkin by lazy {
|
||||
DefaultUISkin.copy(
|
||||
suspend fun OtherUISkin(): UISkin {
|
||||
return DefaultUISkin.copy(
|
||||
normal = OTHER_UI_SKIN_IMG.sliceWithSize(0, 0, 64, 64),
|
||||
hover = OTHER_UI_SKIN_IMG.sliceWithSize(64, 0, 64, 64),
|
||||
down = OTHER_UI_SKIN_IMG.sliceWithSize(127, 0, 64, 64),
|
||||
backColor = DefaultUISkin.backColor.transform(otherColorTransform)
|
||||
backColor = DefaultUISkin.backColor.transform(otherColorTransform),
|
||||
font = Html.FontFace.Bitmap(getDebugBmpFontOnce())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ open class UIButton(
|
||||
rect.tex = skin.normal
|
||||
}
|
||||
}
|
||||
text.format = Html.Format(align = Html.Alignment.MIDDLE_CENTER)
|
||||
text.format = Html.Format(face = skin.font, align = Html.Alignment.MIDDLE_CENTER, color = Colors.WHITE)
|
||||
text.setTextBounds(Rectangle(0, 0, width, height))
|
||||
text.setText(label)
|
||||
textShadow.format = Html.Format(face = skin.font, align = Html.Alignment.MIDDLE_CENTER, color = Colors.BLACK.withA(64))
|
||||
|
||||
@@ -21,7 +21,7 @@ open class UICheckBox(
|
||||
width: Double = 96.0,
|
||||
height: Double = 32.0,
|
||||
label: String = "CheckBox",
|
||||
skin: UISkin = DefaultUISkin
|
||||
private val skin: UISkin = DefaultUISkin
|
||||
) : UIView(width, height) {
|
||||
var checked by uiObservable(checked) { onPropsUpdate() }
|
||||
var label by uiObservable(label) { onPropsUpdate() }
|
||||
@@ -52,7 +52,7 @@ open class UICheckBox(
|
||||
}
|
||||
}
|
||||
text.position(height + 8.0, 0)
|
||||
.also { it.format = Html.Format(align = Html.Alignment.MIDDLE_LEFT) }
|
||||
.also { it.format = Html.Format(face = skin.font, align = Html.Alignment.MIDDLE_LEFT) }
|
||||
.also { it.setTextBounds(Rectangle(0, 0, width - height, height)) }
|
||||
.setText(label)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user