From 448e0aa9c5bd9303d8cc8cd38f5647a151cdb366 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sat, 16 Feb 2019 17:47:34 +0900 Subject: [PATCH] penmenu with icons (render only) --- .../mods/basegame/gui/basic_meter_atlas.tga | 3 -- .../basegame/gui/building_maker_toolbox.tga | 3 -- .../gui/buildingmaker/penmenu_icons.tga | 3 ++ .../basegame/gui/old_watchface2_atlas.tga | 3 -- .../mods/basegame/gui/old_watchface_atlas.tga | 3 -- .../gui/old_watchface_atlas_floatey.tga | 3 -- .../terrarum/modulebasegame/BuildingMaker.kt | 1 + .../modulebasegame/UIBuildingMakerPenMenu.kt | 30 +++++++++++++++---- 8 files changed, 28 insertions(+), 21 deletions(-) delete mode 100644 assets/mods/basegame/gui/basic_meter_atlas.tga delete mode 100644 assets/mods/basegame/gui/building_maker_toolbox.tga create mode 100644 assets/mods/basegame/gui/buildingmaker/penmenu_icons.tga delete mode 100644 assets/mods/basegame/gui/old_watchface2_atlas.tga delete mode 100644 assets/mods/basegame/gui/old_watchface_atlas.tga delete mode 100644 assets/mods/basegame/gui/old_watchface_atlas_floatey.tga diff --git a/assets/mods/basegame/gui/basic_meter_atlas.tga b/assets/mods/basegame/gui/basic_meter_atlas.tga deleted file mode 100644 index 1eed99584..000000000 --- a/assets/mods/basegame/gui/basic_meter_atlas.tga +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4a50f9d0f80b87256cdccc12f398cb9cd37fe2851608b5a2ece054cd6904c3f9 -size 44588 diff --git a/assets/mods/basegame/gui/building_maker_toolbox.tga b/assets/mods/basegame/gui/building_maker_toolbox.tga deleted file mode 100644 index f8c9c648e..000000000 --- a/assets/mods/basegame/gui/building_maker_toolbox.tga +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:50cb9bd6a929a73cfc83b299da5ef0dc3754ae40f4b9e6ca1ff097316cf56327 -size 8236 diff --git a/assets/mods/basegame/gui/buildingmaker/penmenu_icons.tga b/assets/mods/basegame/gui/buildingmaker/penmenu_icons.tga new file mode 100644 index 000000000..08800d4e5 --- /dev/null +++ b/assets/mods/basegame/gui/buildingmaker/penmenu_icons.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:132a29c6a13400cef531efa2a87eb340d88695df2a4c96fb3a8cb6682f5d6da7 +size 34700 diff --git a/assets/mods/basegame/gui/old_watchface2_atlas.tga b/assets/mods/basegame/gui/old_watchface2_atlas.tga deleted file mode 100644 index 966beb23f..000000000 --- a/assets/mods/basegame/gui/old_watchface2_atlas.tga +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b43034bbb6c094f6e4c93e85c7c8e5ea9fc48133c27718659f893ff3a0e1de64 -size 130636 diff --git a/assets/mods/basegame/gui/old_watchface_atlas.tga b/assets/mods/basegame/gui/old_watchface_atlas.tga deleted file mode 100644 index f8df668fe..000000000 --- a/assets/mods/basegame/gui/old_watchface_atlas.tga +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b389c17a1d6ae5bd9b9bccfbd6ef3dd351113bc92264ded60c2bb6e8b622ecc3 -size 70764 diff --git a/assets/mods/basegame/gui/old_watchface_atlas_floatey.tga b/assets/mods/basegame/gui/old_watchface_atlas_floatey.tga deleted file mode 100644 index a29dbd6a7..000000000 --- a/assets/mods/basegame/gui/old_watchface_atlas_floatey.tga +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:72827903ef9fa8a1c8d1d899cb6f1f2c6b8e8a35658613bb8685836da9cf70e2 -size 128044 diff --git a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt index 0f75669a2..2ee9a8e0e 100644 --- a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt +++ b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt @@ -288,6 +288,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) { override fun dispose() { blockPointingCursor.dispose() + uiPenMenu.dispose() } private fun makePenWork(x: Int, y: Int) { diff --git a/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerPenMenu.kt b/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerPenMenu.kt index ac9e6c2cc..fc36cdf31 100644 --- a/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerPenMenu.kt +++ b/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerPenMenu.kt @@ -3,13 +3,12 @@ package net.torvald.terrarum.modulebasegame import com.badlogic.gdx.Gdx import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Camera +import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.g2d.SpriteBatch -import net.torvald.terrarum.AppLoader -import net.torvald.terrarum.fillCircle +import net.torvald.terrarum.* 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.terrarumsansbitmap.gdx.TextureRegionPack import org.dyn4j.geometry.Vector2 /** @@ -22,17 +21,19 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() { const val RADIUS = SIZE / 2.0 const val RADIUSF = RADIUS.toFloat() - const val BLOCKS_ROW_RADIUS = 150 - const val TOOLS_ROW_RADIUS = 72 + const val BLOCKS_ROW_RADIUS = 150.0 + const val TOOLS_ROW_RADIUS = 72.0 const val BLOCK_BACK_SIZE = 72 const val BLOCK_BACK_RADIUS = BLOCK_BACK_SIZE / 2f const val ICON_SIZE = 38 + const val ICON_SIZEH = ICON_SIZE / 2f const val ICON_HITBOX_SIZE = 52 const val ICON_HITBOX_RADIUS = ICON_HITBOX_SIZE / 2f const val PALETTE_SIZE = 10 + const val TOOLS_SIZE = 5 } 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) newvec.rotate(Math.PI / 5.0 * it).plus(Vector2(RADIUS, RADIUS)) } + /** Centre pos. */ + private val toolsPos = Array(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 height = SIZE @@ -83,6 +91,15 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() { // draw close button 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) { @@ -98,5 +115,6 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() { } override fun dispose() { + menuIcons.dispose() } } \ No newline at end of file