From 7391d5e43a0e686f637d8006686660962bff29a2 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 14 Nov 2023 13:07:43 +0900 Subject: [PATCH] module option window title to match the y-pos of others --- src/net/torvald/terrarum/ModOptionsHost.kt | 4 ++-- src/net/torvald/terrarum/ui/UIItemTextSelector.kt | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/net/torvald/terrarum/ModOptionsHost.kt b/src/net/torvald/terrarum/ModOptionsHost.kt index 677b1b635..a0443573f 100644 --- a/src/net/torvald/terrarum/ModOptionsHost.kt +++ b/src/net/torvald/terrarum/ModOptionsHost.kt @@ -23,7 +23,7 @@ class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() { private val moduleAreaBorder = 8 override var width = 560 - override var height = App.scr.height - moduleAreaHMargin * 2 + override var height = 600//App.scr.height - moduleAreaHMargin * 2 private val drawX = (Toolkit.drawWidth - width) / 2 private val drawY = (App.scr.height - height) / 2 @@ -35,7 +35,7 @@ class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() { private val modSelectorWidth = 360 private val modSelector = UIItemTextSelector(this, drawX + (width - modSelectorWidth) / 2, drawY, - configurableMods.map { { it.first } }, 0, modSelectorWidth, false + configurableMods.map { { it.first } }, 0, modSelectorWidth, false, font = App.fontUITitle ).also { item -> item.selectionChangeListener = { currentlySelectedModule = configurableMods[it].second diff --git a/src/net/torvald/terrarum/ui/UIItemTextSelector.kt b/src/net/torvald/terrarum/ui/UIItemTextSelector.kt index 03135c625..71f4a24a1 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextSelector.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextSelector.kt @@ -4,11 +4,13 @@ import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.graphics.Pixmap +import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.glutils.FrameBuffer import net.torvald.terrarum.* import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.gameworld.fmod +import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap /** * @param width width of the text input where the text gets drawn, not the entire item @@ -25,6 +27,7 @@ class UIItemTextSelector( private val drawBorder: Boolean = true, private val clickToShowPalette: Boolean = true, private val useSpinnerButtons: Boolean = false, + private val font: TerrarumSansBitmap = App.fontGame ) : UIItem(parentUI, initialX, initialY) { init { @@ -143,7 +146,7 @@ class UIItemTextSelector( it.color = Color.WHITE val t = labelCache[selection] - val tw = App.fontGame.getWidth(t) + val tw = font.getWidth(t) printdbg(this, "Drawing text: $t") @@ -199,9 +202,9 @@ class UIItemTextSelector( if (!paletteShowing) { batch.color = UIItemTextLineInput.TEXTINPUT_COL_TEXT val t = labelCache[selection] - val tw = App.fontGame.getWidth(t) + val tw = font.getWidth(t) // batch.draw(fbo.colorBufferTexture, posX + buttonW + 3f, posY + 2f, fbo.width.toFloat(), fbo.height.toFloat()) - App.fontGame.draw(batch, t, posX + buttonW + 3 + (fboWidth - tw) / 2, posY) + font.draw(batch, t, posX + buttonW + 3 + (fboWidth - tw) / 2, posY) } // palette else { @@ -227,8 +230,8 @@ class UIItemTextSelector( else if (index == mouseOnPaletteItem) Toolkit.Theme.COL_MOUSE_UP else UIItemTextLineInput.TEXTINPUT_COL_TEXT val t = labelCache[index] - val tw = App.fontGame.getWidth(t) - App.fontGame.draw(batch, t, + val tw = font.getWidth(t) + font.draw(batch, t, palX + (palW - tw) / 2, getPalItemPosY(index) - 2 )