mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 20:44:05 +09:00
text input pane wip
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.ItemCodex
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.fillRect
|
||||
import net.torvald.terrarum.modulebasegame.BuildingMaker
|
||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_WHITE
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItemImageButton
|
||||
import net.torvald.terrarum.ui.UIItemTextButtonList
|
||||
import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_BACKGROUNDCOL
|
||||
import kotlin.math.roundToInt
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2019-02-14.
|
||||
@@ -132,15 +132,15 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
|
||||
|
||||
// gaps between tabs and close button
|
||||
batch.color = DEFAULT_BACKGROUNDCOL
|
||||
batch.fillRect(0f, tabs.height.toFloat(), MENUBAR_SIZE.toFloat(), height.toFloat() - (tabs.height + closeButton.height))
|
||||
Toolkit.fillArea(batch, 0f, tabs.height.toFloat(), MENUBAR_SIZE.toFloat(), height.toFloat() - (tabs.height + closeButton.height))
|
||||
// scrollbar back
|
||||
batch.color = DEFAULT_BACKGROUNDCOL
|
||||
batch.fillRect(width - SCROLLBAR_SIZE.toFloat(), 0f, SCROLLBAR_SIZE.toFloat(), height.toFloat())
|
||||
Toolkit.fillArea(batch, width - SCROLLBAR_SIZE.toFloat(), 0f, SCROLLBAR_SIZE.toFloat(), height.toFloat())
|
||||
batch.color = scrollbarBackCol
|
||||
batch.fillRect(width - SCROLLBAR_SIZE.toFloat(), 0f, SCROLLBAR_SIZE.toFloat(), height.toFloat())
|
||||
Toolkit.fillArea(batch, width - SCROLLBAR_SIZE.toFloat(), 0f, SCROLLBAR_SIZE.toFloat(), height.toFloat())
|
||||
// scrollbar
|
||||
batch.color = CELLCOLOUR_WHITE
|
||||
batch.fillRect(width - SCROLLBAR_SIZE.toFloat(), scrollBarPos.toFloat(), SCROLLBAR_SIZE.toFloat(), scrollBarHeight)
|
||||
Toolkit.fillArea(batch, width - SCROLLBAR_SIZE.toFloat(), scrollBarPos.toFloat(), SCROLLBAR_SIZE.toFloat(), scrollBarHeight)
|
||||
|
||||
// the actual buttons
|
||||
tabs.render(batch, camera)
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.modulebasegame.BuildingMaker
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItemImageButton
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -22,18 +23,19 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
||||
companion object {
|
||||
const val SIZE = 330
|
||||
const val RADIUS = SIZE / 2.0
|
||||
const val RADIUSI = RADIUS.toInt()
|
||||
const val RADIUSF = RADIUS.toFloat()
|
||||
|
||||
const val BLOCKS_ROW_RADIUS = 120.0
|
||||
const val TOOLS_ROW_RADIUS = 56.0
|
||||
|
||||
const val BLOCK_BACK_SIZE = 72
|
||||
const val BLOCK_BACK_RADIUS = BLOCK_BACK_SIZE / 2f
|
||||
const val BLOCK_BACK_RADIUS = BLOCK_BACK_SIZE / 2
|
||||
|
||||
const val ICON_SIZE = 38
|
||||
const val ICON_SIZEH = ICON_SIZE / 2f
|
||||
const val CLOSE_BUTTON_SIZE = 48
|
||||
const val CLOSE_BUTTON_RADIUS = CLOSE_BUTTON_SIZE / 2f
|
||||
const val CLOSE_BUTTON_RADIUS = CLOSE_BUTTON_SIZE / 2
|
||||
|
||||
const val PALETTE_SIZE = 10
|
||||
const val TOOLS_SIZE = 5
|
||||
@@ -135,7 +137,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
||||
// primary click
|
||||
if (Terrarum.mouseDown) {
|
||||
// close by clicking close button or out-of-boud
|
||||
if (mouseVec.distanceSquared(RADIUS, RADIUS) !in CLOSE_BUTTON_RADIUS.sqr()..RADIUSF.sqr()) {
|
||||
if (mouseVec.distanceSquared(RADIUS, RADIUS) !in CLOSE_BUTTON_RADIUS.toFloat().sqr()..RADIUSF.sqr()) {
|
||||
closeGracefully()
|
||||
}
|
||||
}
|
||||
@@ -149,7 +151,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
// draw back
|
||||
batch.color = backCol
|
||||
batch.fillCircle(0f, 0f, SIZE.toFloat(), SIZE.toFloat())
|
||||
Toolkit.fillCircle(batch,0, 0, SIZE, SIZE)
|
||||
|
||||
// draw blocks slot
|
||||
batch.color = blockCellCol
|
||||
@@ -167,12 +169,12 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
||||
"wall@" + Block.GLASS_CRUDE
|
||||
)//AppLoader.getConfigStringArray("buildingmakerfavs")
|
||||
for (i in 0 until PALETTE_SIZE) {
|
||||
val x = blockCellPos[i].x.roundToInt().toFloat()
|
||||
val y = blockCellPos[i].y.roundToInt().toFloat()
|
||||
val x = blockCellPos[i].x.roundToInt()
|
||||
val y = blockCellPos[i].y.roundToInt()
|
||||
batch.color = blockCellCol
|
||||
repeat((i == mouseOnBlocksSlot).toInt() + 1) { batch.fillCircle(x - BLOCK_BACK_RADIUS, y - BLOCK_BACK_RADIUS, BLOCK_BACK_SIZE.toFloat(), BLOCK_BACK_SIZE.toFloat()) }
|
||||
repeat((i == mouseOnBlocksSlot).toInt() + 1) { Toolkit.fillCircle(batch, x - BLOCK_BACK_RADIUS, y - BLOCK_BACK_RADIUS, BLOCK_BACK_SIZE, BLOCK_BACK_SIZE) }
|
||||
batch.color = Color.WHITE
|
||||
batch.draw(ItemCodex.getItemImage(slotConfig[i]), x - 16, y - 16, 32f, 32f)
|
||||
batch.draw(ItemCodex.getItemImage(slotConfig[i]), x - 16f, y - 16f, 32f, 32f)
|
||||
|
||||
// update as well while looping
|
||||
if (i == mouseOnBlocksSlot && Terrarum.mouseDown) {
|
||||
@@ -183,7 +185,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
||||
|
||||
// draw close button
|
||||
batch.color = blockCellCol
|
||||
repeat(mouseOnCloseButton.toInt() + 1) { batch.fillCircle(RADIUSF - CLOSE_BUTTON_RADIUS, RADIUSF - CLOSE_BUTTON_RADIUS, CLOSE_BUTTON_SIZE.toFloat(), CLOSE_BUTTON_SIZE.toFloat()) }
|
||||
repeat(mouseOnCloseButton.toInt() + 1) { Toolkit.fillCircle(batch, RADIUSI - CLOSE_BUTTON_RADIUS, RADIUSI - CLOSE_BUTTON_RADIUS, CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE) }
|
||||
|
||||
batch.color = if (mouseOnCloseButton) toolButtons[0].activeCol else toolButtons[0].inactiveCol
|
||||
batch.draw(toolIcons.get(5, 0), RADIUSF - ICON_SIZEH, RADIUSF - ICON_SIZEH)
|
||||
|
||||
@@ -34,7 +34,7 @@ class UICheatDetected : UICanvas() {
|
||||
|
||||
Toolkit.blurEntireScreen(batch, camera as OrthographicCamera, 2f, 0, 0, width, height)
|
||||
batch.color = backgroundCol
|
||||
batch.fillRect(0f, 0f, width.toFloat(), height.toFloat())
|
||||
Toolkit.fillArea(batch, 0f, 0f, width.toFloat(), height.toFloat())
|
||||
|
||||
batch.color = Color.WHITE
|
||||
val txt = Lang["ERROR_GENERIC_CHEATING"]
|
||||
|
||||
@@ -217,13 +217,13 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
// background
|
||||
blendNormal()
|
||||
batch.color = backgroundColour
|
||||
batch.fillRect(0f, 0f, width.toFloat(), height.toFloat())
|
||||
Toolkit.fillArea(batch, 0f, 0f, width.toFloat(), height.toFloat())
|
||||
|
||||
|
||||
// cat bar background
|
||||
blendMul()
|
||||
batch.color = Color(0xcccccc_ff.toInt())
|
||||
batch.fillRect(0f, 0f, catButtons.width.toFloat(), height.toFloat())
|
||||
Toolkit.fillArea(batch, 0f, 0f, catButtons.width.toFloat(), height.toFloat())
|
||||
|
||||
catButtons.render(batch, camera)
|
||||
|
||||
@@ -255,7 +255,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
// encumbrance bar background
|
||||
blendMul()
|
||||
batch.color = Color(0xa0a0a0_ff.toInt())
|
||||
batch.fillRect(
|
||||
Toolkit.fillArea(batch,
|
||||
width - 3 - weightBarWidth,
|
||||
height - controlHelpHeight + 3f,
|
||||
weightBarWidth,
|
||||
@@ -264,7 +264,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
// encumbrance bar
|
||||
blendNormal()
|
||||
batch.color = if (isEncumbered) Color(0xff0000_cc.toInt()) else Color(0x00ff00_cc.toInt())
|
||||
batch.fillRect(
|
||||
Toolkit.fillArea(batch,
|
||||
width - 3 - weightBarWidth,
|
||||
height - controlHelpHeight + 3f,
|
||||
if (actor?.inventory?.capacityMode == CAPACITY_MODE_NO_ENCUMBER)
|
||||
|
||||
@@ -120,13 +120,13 @@ internal class UIInventoryCells(
|
||||
val encumbCol = UIItemInventoryCellCommonRes.getHealthMeterColour(1f - encumbrancePerc, 0f, 1f)
|
||||
val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening
|
||||
batch.color = encumbBack
|
||||
batch.fillRect(
|
||||
Toolkit.fillArea(batch,
|
||||
encumbBarXPos, encumbBarYPos,
|
||||
weightBarWidth, controlHelpHeight - 6f
|
||||
)
|
||||
// encumbrance bar
|
||||
batch.color = encumbCol
|
||||
batch.fillRect(
|
||||
Toolkit.fillArea(batch,
|
||||
encumbBarXPos, encumbBarYPos,
|
||||
if (full.actor.inventory.capacityMode == FixtureInventory.CAPACITY_MODE_NO_ENCUMBER)
|
||||
1f
|
||||
|
||||
@@ -108,7 +108,7 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
||||
|
||||
// sky background
|
||||
batch.color = MINIMAP_SKYCOL
|
||||
batch.fillRect(0f, 0f, MINIMAP_WIDTH, MINIMAP_HEIGHT)
|
||||
Toolkit.fillArea(batch, 0f, 0f, MINIMAP_WIDTH, MINIMAP_HEIGHT)
|
||||
// the actual image
|
||||
batch.color = Color.WHITE
|
||||
batch.draw(MinimapComposer.tempTex, tx, ty + MinimapComposer.totalHeight * minimapZoom, MinimapComposer.totalWidth * minimapZoom, -MinimapComposer.totalHeight * minimapZoom)
|
||||
@@ -124,10 +124,10 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
||||
batch.projectionMatrix = camera.combined
|
||||
// 1px stroke
|
||||
batch.color = Color.WHITE
|
||||
batch.fillRect((width - MINIMAP_WIDTH) / 2, -1 + cellOffY.toFloat(), MINIMAP_WIDTH, 1f)
|
||||
batch.fillRect((width - MINIMAP_WIDTH) / 2, cellOffY + MINIMAP_HEIGHT, MINIMAP_WIDTH, 1f)
|
||||
batch.fillRect(-1 + (width - MINIMAP_WIDTH) / 2, cellOffY.toFloat(), 1f, MINIMAP_HEIGHT)
|
||||
batch.fillRect((width - MINIMAP_WIDTH) / 2 + MINIMAP_WIDTH, cellOffY.toFloat(), 1f, MINIMAP_HEIGHT)
|
||||
Toolkit.fillArea(batch, (width - MINIMAP_WIDTH) / 2, -1 + cellOffY.toFloat(), MINIMAP_WIDTH, 1f)
|
||||
Toolkit.fillArea(batch, (width - MINIMAP_WIDTH) / 2, cellOffY + MINIMAP_HEIGHT, MINIMAP_WIDTH, 1f)
|
||||
Toolkit.fillArea(batch, -1 + (width - MINIMAP_WIDTH) / 2, cellOffY.toFloat(), 1f, MINIMAP_HEIGHT)
|
||||
Toolkit.fillArea(batch, (width - MINIMAP_WIDTH) / 2 + MINIMAP_WIDTH, cellOffY.toFloat(), 1f, MINIMAP_HEIGHT)
|
||||
|
||||
// control hints
|
||||
batch.color = Color.WHITE
|
||||
|
||||
@@ -130,6 +130,8 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||
|
||||
private val controlPalette = UIItemControlPaletteBaloon(this, (Toolkit.drawWidth - 480) / 2, kby + 219)
|
||||
|
||||
private val textInputPanel = UIItemTextLineInput(this, drawX, 360, width)
|
||||
|
||||
init {
|
||||
keycaps.values.forEach { addUIitem(it) }
|
||||
updateKeycaps()
|
||||
@@ -139,6 +141,8 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||
resetKeyConfig()
|
||||
updateKeycaps()
|
||||
}
|
||||
|
||||
addUIitem(textInputPanel)
|
||||
}
|
||||
|
||||
private fun resetKeyConfig() {
|
||||
|
||||
@@ -6,15 +6,15 @@ import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.ItemCodex
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.fillRect
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.BuildingMaker
|
||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UINSMenu
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2019-02-03.
|
||||
@@ -75,7 +75,7 @@ class UIPaletteSelector(val parent: BuildingMaker) : UICanvas() {
|
||||
// draw title bar
|
||||
batch.color = UINSMenu.DEFAULT_TITLEBACKCOL
|
||||
blendNormal(batch)
|
||||
batch.fillRect(0f, 0f, width.toFloat(), LINE_HEIGHT.toFloat())
|
||||
Toolkit.fillArea(batch, 0, 0, width, LINE_HEIGHT)
|
||||
|
||||
// draw "Pal."
|
||||
batch.color = UINSMenu.DEFAULT_TITLETEXTCOL
|
||||
@@ -83,7 +83,7 @@ class UIPaletteSelector(val parent: BuildingMaker) : UICanvas() {
|
||||
|
||||
// draw background
|
||||
batch.color = CELLCOLOUR_BLACK
|
||||
batch.fillRect(0f, LINE_HEIGHT.toFloat(), 36f, 48f)
|
||||
Toolkit.fillArea(batch, 0, LINE_HEIGHT, 36, 48)
|
||||
|
||||
// draw back and fore selection
|
||||
batch.color = Color.WHITE
|
||||
|
||||
Reference in New Issue
Block a user