world portal: world search is now new world

This commit is contained in:
minjaesong
2023-06-19 00:50:55 +09:00
parent 138c6d22d2
commit 9e9064dd55
4 changed files with 39 additions and 19 deletions

View File

@@ -39,10 +39,12 @@ class SimpleGameWorld : GameWorld() {
override lateinit var layerTerrain: BlockLayer override lateinit var layerTerrain: BlockLayer
} }
open class GameWorld() : Disposable { open class GameWorld(
val worldIndex: UUID // should not be immutable as JSON loader will want to overwrite it
) : Disposable {
constructor() : this(UUID.randomUUID())
// var worldName: String = "New World"
var worldIndex: UUID = UUID.randomUUID() // should not be immutable as JSON loader will want to overwrite it
var worldCreator: UUID = UUID(0L,0L) // TODO record a value to this var worldCreator: UUID = UUID(0L,0L) // TODO record a value to this
var width: Int = 999; private set var width: Int = 999; private set
var height: Int = 999; private set var height: Int = 999; private set

View File

@@ -208,7 +208,7 @@ class UIItemWorldPortalTopBar(
private val genericIcons: TextureRegionPack = CommonResourcePool.getAsTextureRegionPack("inventory_category") private val genericIcons: TextureRegionPack = CommonResourcePool.getAsTextureRegionPack("inventory_category")
private val icons = CommonResourcePool.getAsTextureRegionPack("terrarum-basegame-worldportalicons") private val icons = CommonResourcePool.getAsTextureRegionPack("terrarum-basegame-worldportalicons")
private val catIconImages = listOf( /*private val catIconImages = listOf(
icons.get(0, 0), icons.get(0, 0),
genericIcons.get(16,0), genericIcons.get(16,0),
icons.get(1, 0), icons.get(1, 0),
@@ -221,7 +221,7 @@ class UIItemWorldPortalTopBar(
"CONTEXT_WORLD_LIST", "CONTEXT_WORLD_LIST",
"", "",
"GAME_INVENTORY", "GAME_INVENTORY",
) )*/
private val buttonGapSize = 120 private val buttonGapSize = 120
private val highlighterYPos = icons.tileH + 4 private val highlighterYPos = icons.tileH + 4
@@ -233,7 +233,7 @@ class UIItemWorldPortalTopBar(
private var transitionFired = false private var transitionFired = false
private val buttons = Array<UIItemImageButton>(5) { /*private val buttons = Array<UIItemImageButton>(5) {
val xoff = if (it == 1) -32 else if (it == 3) 32 else 0 val xoff = if (it == 1) -32 else if (it == 3) 32 else 0
UIItemImageButton( UIItemImageButton(
parentUI, parentUI,
@@ -250,13 +250,13 @@ class UIItemWorldPortalTopBar(
) )
} }
private val workingButtons = arrayOf(0,2,4) private val workingButtons = arrayOf(0,2,4)*/
override fun update(delta: Float) { override fun update(delta: Float) {
super.update(delta) super.update(delta)
workingButtons.forEach { buttons[it].update(delta) } /*workingButtons.forEach { buttons[it].update(delta) }
// transition stuffs // transition stuffs
workingButtons.filter { buttons[it].mousePushed }.firstOrNull()?.let { pushedButton -> workingButtons.filter { buttons[it].mousePushed }.firstOrNull()?.let { pushedButton ->
@@ -266,7 +266,7 @@ class UIItemWorldPortalTopBar(
workingButtons.forEach { i -> workingButtons.forEach { i ->
buttons[i].highlighted = i == pushedButton buttons[i].highlighted = i == pushedButton
} }
} }*/
if (transitionFired) { if (transitionFired) {
transitionFired = false transitionFired = false
@@ -278,13 +278,13 @@ class UIItemWorldPortalTopBar(
super.render(batch, camera) super.render(batch, camera)
// button // button
buttons.forEach { it.render(batch, camera) } /*buttons.forEach { it.render(batch, camera) }
// label // label
batch.color = Color.WHITE batch.color = Color.WHITE
val text = Lang[catIconLabels[selectedPanel]] val text = Lang[catIconLabels[selectedPanel]]
App.fontGame.draw(batch, text, buttons[selectedPanel].posX + 10 - (App.fontGame.getWidth(text) / 2), posY + highlighterYPos + 4) App.fontGame.draw(batch, text, buttons[selectedPanel].posX + 10 - (App.fontGame.getWidth(text) / 2), posY + highlighterYPos + 4)
*/
blendNormalStraightAlpha(batch) blendNormalStraightAlpha(batch)

View File

@@ -32,6 +32,13 @@ import java.util.zip.GZIPInputStream
import kotlin.math.ceil import kotlin.math.ceil
/** /**
*
* "Teleport" button sets the destination and makes the portal surface to 'glow' to indicate the teleportation is ready.
* Teleportation is initiated with a rising edge of a logic signal.
*
* "New World" sets the parameter of the new world, and make the new (not yet generated) world as the teleportation target.
* THe world generation will be done when the "teleportation" is on going.
*
* Created by minjaesong on 2023-05-19. * Created by minjaesong on 2023-05-19.
*/ */
class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() { class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
@@ -59,7 +66,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
private val buttonsY = y + listHeight + gridGap private val buttonsY = y + listHeight + gridGap
private val buttonSearch = UIItemTextButton(this, private val buttonSearch = UIItemTextButton(this,
"CONTEXT_WORLD_SEARCH", "CONTEXT_WORLD_NEW",
hx - gridGap/2 - 2*deleteButtonWidth - gridGap, hx - gridGap/2 - 2*deleteButtonWidth - gridGap,
buttonsY, buttonsY,
deleteButtonWidth, deleteButtonWidth,
@@ -116,10 +123,21 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
} }
} }
private fun highlightListEditButtons(state: Boolean) { private fun disableListEditButtons() {
buttonRename.isActive = state buttonRename.isActive = false
buttonDelete.isActive = state buttonDelete.isActive = false
buttonTeleport.isActive = state buttonTeleport.isActive = false
}
private fun highlightListEditButtons(info: WorldInfo?) {
// will disable the delete and teleport button if the world is equal to the currently playing world
if (info == null) disableListEditButtons()
else {
buttonRename.isActive = true
buttonDelete.isActive = info.uuid != INGAME.world.worldIndex
buttonTeleport.isActive = info.uuid != INGAME.world.worldIndex
}
} }
init { init {
@@ -220,7 +238,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
button.clickOnceListener = { _, _ -> button.clickOnceListener = { _, _ ->
selected = button selected = button
selectedIndex = it selectedIndex = it
highlightListEditButtons(it in worldList.indices) highlightListEditButtons(worldList.getOrNull(it))
updateUIbyButtonSelection() updateUIbyButtonSelection()
} }
} }
@@ -238,7 +256,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
worldCells.forEach { it.show() } worldCells.forEach { it.show() }
selected = null selected = null
highlightListEditButtons(false) disableListEditButtons()
updateUIbyButtonSelection() updateUIbyButtonSelection()
} }

View File

@@ -148,7 +148,7 @@ class UIWorldPortalSearch(val full: UIWorldPortal) : UICanvas() {
batch.color = Color.WHITE batch.color = Color.WHITE
// ui title // ui title
val titlestr = Lang["CONTEXT_WORLD_SEARCH"] val titlestr = Lang["CONTEXT_WORLD_NEW"]
App.fontUITitle.draw(batch, titlestr, drawX + (width - App.fontUITitle.getWidth(titlestr)).div(2).toFloat(), INVENTORY_CELLS_OFFSET_Y() - 72f) App.fontUITitle.draw(batch, titlestr, drawX + (width - App.fontUITitle.getWidth(titlestr)).div(2).toFloat(), INVENTORY_CELLS_OFFSET_Y() - 72f)
// draw size previews // draw size previews