mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 04:24:05 +09:00
more buildingmaker ui stuffs
This commit is contained in:
@@ -41,18 +41,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
- Load terrain…
|
- Load terrain…
|
||||||
-
|
-
|
||||||
- Exit to Title : net.torvald.terrarum.modulebasegame.YamlCommandExit
|
- Exit to Title : net.torvald.terrarum.modulebasegame.YamlCommandExit
|
||||||
- Tool
|
- Edit
|
||||||
- Pencil : net.torvald.terrarum.modulebasegame.YamlCommandToolPencil
|
|
||||||
- Eraser : net.torvald.terrarum.modulebasegame.YamlCommandToolPencilErase
|
|
||||||
- Wall Hammer : net.torvald.terrarum.modulebasegame.YamlCommandToolPencilEraseWall
|
|
||||||
- Eyedropper : net.torvald.terrarum.modulebasegame.YamlCommandToolEyedropper
|
|
||||||
- Add Selection : net.torvald.terrarum.modulebasegame.YamlCommandToolMarquee
|
|
||||||
- Remove Sel. : net.torvald.terrarum.modulebasegame.YamlCommandToolMarqueeErase
|
|
||||||
- Clear Sel. : net.torvald.terrarum.modulebasegame.YamlCommandToolMarqueeClear
|
|
||||||
- Move Selected
|
|
||||||
-
|
|
||||||
- Hide/Show Sel. : net.torvald.terrarum.modulebasegame.YamlCommandToolToggleMarqueeOverlay
|
|
||||||
-
|
|
||||||
- Undo
|
- Undo
|
||||||
- Redo
|
- Redo
|
||||||
- Time
|
- Time
|
||||||
@@ -288,7 +277,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
uiToolbox.isVisible = true
|
uiToolbox.isVisible = true
|
||||||
uiToolbox.invocationArgument = arrayOf(this)
|
uiToolbox.invocationArgument = arrayOf(this)
|
||||||
|
|
||||||
uiPaletteSelector.setPosition(App.scr.width - uiPaletteSelector.width, 0)
|
uiPaletteSelector.setPosition(0, App.scr.height - uiPaletteSelector.height)
|
||||||
uiPaletteSelector.isVisible = true
|
uiPaletteSelector.isVisible = true
|
||||||
|
|
||||||
notifier.setPosition(
|
notifier.setPosition(
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class UIPaletteSelector(val parent: BuildingMaker) : UICanvas() {
|
|||||||
0b00_00_00_00_00_00_00_01_11_11_11_01_01,
|
0b00_00_00_00_00_00_00_01_11_11_11_01_01,
|
||||||
0b00_00_00_00_00_00_00_00_01_11_01_01_00,
|
0b00_00_00_00_00_00_00_00_01_11_01_01_00,
|
||||||
0b00_00_00_00_00_00_00_00_00_01_01_00_00
|
0b00_00_00_00_00_00_00_00_00_01_01_00_00
|
||||||
).reversed().forEachIndexed { index, bits ->
|
).forEachIndexed { index, bits ->
|
||||||
for (shiftmask in 12 downTo 0) {
|
for (shiftmask in 12 downTo 0) {
|
||||||
val bit = bits.ushr(shiftmask * 2).and(3)
|
val bit = bits.ushr(shiftmask * 2).and(3)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
|
import net.torvald.terrarum.App.printdbg
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@@ -88,6 +89,13 @@ class UINSMenu(
|
|||||||
|
|
||||||
// FIXME mouseUp doesn't work here
|
// FIXME mouseUp doesn't work here
|
||||||
|
|
||||||
|
private fun popToTheList(list: UIItemTextButtonList) {
|
||||||
|
while (listStack.peek().ui != list) {
|
||||||
|
popSubMenu()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun addSubMenu(tree: QNDTreeNode<Pair<String, YamlInvokable?>>) {
|
private fun addSubMenu(tree: QNDTreeNode<Pair<String, YamlInvokable?>>) {
|
||||||
val menuTitle = tree.data?.first ?: title
|
val menuTitle = tree.data?.first ?: title
|
||||||
val stringsFromTree = Array<String>(tree.children.size) {
|
val stringsFromTree = Array<String>(tree.children.size) {
|
||||||
@@ -125,12 +133,13 @@ class UINSMenu(
|
|||||||
// 2. push the new menu
|
// 2. push the new menu
|
||||||
|
|
||||||
// 1. pop as far as possible
|
// 1. pop as far as possible
|
||||||
while (listStack.peek().ui != list) {
|
popToTheList(list)
|
||||||
popSubMenu()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. push the new menu
|
// 2. push the new menu
|
||||||
if (old != new) {
|
if (old != new) {
|
||||||
|
printdbg(this, "tree.children[new].children = ${tree.children[new].children}")
|
||||||
|
|
||||||
|
// push those new menus
|
||||||
if (tree.children[new].children.isNotEmpty()) {
|
if (tree.children[new].children.isNotEmpty()) {
|
||||||
addSubMenu(tree.children[new])
|
addSubMenu(tree.children[new])
|
||||||
}
|
}
|
||||||
@@ -175,12 +184,14 @@ class UINSMenu(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val borderCol = Color(1f, 1f, 1f, 0.35f)
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
|
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
|
||||||
listStack.forEach {
|
listStack.forEach {
|
||||||
// draw title bar
|
// draw title bar
|
||||||
batch.color = titleBackCol
|
batch.color = titleBackCol
|
||||||
BlendMode.resolve(titleBlendMode, batch)
|
BlendMode.resolve(titleBlendMode, batch)
|
||||||
Toolkit.fillArea(batch, it.ui.posX.toFloat(), it.ui.posY.toFloat() - LINE_HEIGHT, it.ui.width.toFloat(), LINE_HEIGHT.toFloat())
|
Toolkit.fillArea(batch, it.ui.posX, it.ui.posY - LINE_HEIGHT, it.ui.width, LINE_HEIGHT)
|
||||||
|
|
||||||
batch.color = titleTextCol
|
batch.color = titleTextCol
|
||||||
blendNormalStraightAlpha(batch)
|
blendNormalStraightAlpha(batch)
|
||||||
@@ -189,6 +200,12 @@ class UINSMenu(
|
|||||||
// draw the list
|
// draw the list
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
it.ui.render(batch, camera)
|
it.ui.render(batch, camera)
|
||||||
|
|
||||||
|
// draw border
|
||||||
|
batch.color = borderCol
|
||||||
|
blendNormalStraightAlpha(batch)
|
||||||
|
Toolkit.fillArea(batch, it.ui.posX + it.ui.width - 1, it.ui.posY - LINE_HEIGHT, 1, LINE_HEIGHT + it.ui.height)
|
||||||
|
Toolkit.fillArea(batch, it.ui.posX, it.ui.posY + it.ui.height - 1, it.ui.width - 1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user