mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
penmenu with icons (render only)
This commit is contained in:
Binary file not shown.
Binary file not shown.
BIN
assets/mods/basegame/gui/buildingmaker/penmenu_icons.tga
LFS
Normal file
BIN
assets/mods/basegame/gui/buildingmaker/penmenu_icons.tga
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -288,6 +288,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
blockPointingCursor.dispose()
|
blockPointingCursor.dispose()
|
||||||
|
uiPenMenu.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun makePenWork(x: Int, y: Int) {
|
private fun makePenWork(x: Int, y: Int) {
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ package net.torvald.terrarum.modulebasegame
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.fillCircle
|
|
||||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
|
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
|
||||||
import net.torvald.terrarum.roundInt
|
|
||||||
import net.torvald.terrarum.sqr
|
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,17 +21,19 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
|||||||
const val RADIUS = SIZE / 2.0
|
const val RADIUS = SIZE / 2.0
|
||||||
const val RADIUSF = RADIUS.toFloat()
|
const val RADIUSF = RADIUS.toFloat()
|
||||||
|
|
||||||
const val BLOCKS_ROW_RADIUS = 150
|
const val BLOCKS_ROW_RADIUS = 150.0
|
||||||
const val TOOLS_ROW_RADIUS = 72
|
const val TOOLS_ROW_RADIUS = 72.0
|
||||||
|
|
||||||
const val BLOCK_BACK_SIZE = 72
|
const val BLOCK_BACK_SIZE = 72
|
||||||
const val BLOCK_BACK_RADIUS = BLOCK_BACK_SIZE / 2f
|
const val BLOCK_BACK_RADIUS = BLOCK_BACK_SIZE / 2f
|
||||||
|
|
||||||
const val ICON_SIZE = 38
|
const val ICON_SIZE = 38
|
||||||
|
const val ICON_SIZEH = ICON_SIZE / 2f
|
||||||
const val ICON_HITBOX_SIZE = 52
|
const val ICON_HITBOX_SIZE = 52
|
||||||
const val ICON_HITBOX_RADIUS = ICON_HITBOX_SIZE / 2f
|
const val ICON_HITBOX_RADIUS = ICON_HITBOX_SIZE / 2f
|
||||||
|
|
||||||
const val PALETTE_SIZE = 10
|
const val PALETTE_SIZE = 10
|
||||||
|
const val TOOLS_SIZE = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
private val backCol = ItemSlotImageFactory.CELLCOLOUR_BLACK
|
private val backCol = ItemSlotImageFactory.CELLCOLOUR_BLACK
|
||||||
@@ -42,6 +43,13 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
|||||||
val newvec = Vector2(0.0, 0.0 - BLOCKS_ROW_RADIUS)
|
val newvec = Vector2(0.0, 0.0 - BLOCKS_ROW_RADIUS)
|
||||||
newvec.rotate(Math.PI / 5.0 * it).plus(Vector2(RADIUS, RADIUS))
|
newvec.rotate(Math.PI / 5.0 * it).plus(Vector2(RADIUS, RADIUS))
|
||||||
}
|
}
|
||||||
|
/** Centre pos. */
|
||||||
|
private val toolsPos = Array<Vector2>(TOOLS_SIZE) {
|
||||||
|
val newvec = Vector2(TOOLS_ROW_RADIUS, 0.0)
|
||||||
|
newvec.rotate(Math.PI / 2.5 * it).plus(Vector2(RADIUS, RADIUS))
|
||||||
|
}
|
||||||
|
|
||||||
|
private val menuIcons = TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/buildingmaker/penmenu_icons.tga"), 38, 38)
|
||||||
|
|
||||||
override var width = SIZE
|
override var width = SIZE
|
||||||
override var height = SIZE
|
override var height = SIZE
|
||||||
@@ -83,6 +91,15 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
|||||||
|
|
||||||
// draw close button
|
// draw close button
|
||||||
batch.fillCircle(RADIUSF - ICON_HITBOX_RADIUS, RADIUSF - ICON_HITBOX_RADIUS, ICON_HITBOX_SIZE.toFloat(), ICON_HITBOX_SIZE.toFloat())
|
batch.fillCircle(RADIUSF - ICON_HITBOX_RADIUS, RADIUSF - ICON_HITBOX_RADIUS, ICON_HITBOX_SIZE.toFloat(), ICON_HITBOX_SIZE.toFloat())
|
||||||
|
|
||||||
|
// draw icons
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
batch.draw(menuIcons.get(5, 0), RADIUSF - ICON_SIZEH, RADIUSF - ICON_SIZEH)
|
||||||
|
for (i in 0 until TOOLS_SIZE) {
|
||||||
|
val x = toolsPos[i].x.roundInt().toFloat() - ICON_SIZEH
|
||||||
|
val y = toolsPos[i].y.roundInt().toFloat() - ICON_SIZEH
|
||||||
|
batch.draw(menuIcons.get(i, 0), x, y)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
@@ -98,5 +115,6 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
menuIcons.dispose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user