mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-13 23:26:07 +09:00
world portal: world search is now new world
This commit is contained in:
@@ -39,10 +39,12 @@ class SimpleGameWorld : GameWorld() {
|
||||
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 width: Int = 999; private set
|
||||
var height: Int = 999; private set
|
||||
|
||||
@@ -208,7 +208,7 @@ class UIItemWorldPortalTopBar(
|
||||
|
||||
private val genericIcons: TextureRegionPack = CommonResourcePool.getAsTextureRegionPack("inventory_category")
|
||||
private val icons = CommonResourcePool.getAsTextureRegionPack("terrarum-basegame-worldportalicons")
|
||||
private val catIconImages = listOf(
|
||||
/*private val catIconImages = listOf(
|
||||
icons.get(0, 0),
|
||||
genericIcons.get(16,0),
|
||||
icons.get(1, 0),
|
||||
@@ -221,7 +221,7 @@ class UIItemWorldPortalTopBar(
|
||||
"CONTEXT_WORLD_LIST",
|
||||
"",
|
||||
"GAME_INVENTORY",
|
||||
)
|
||||
)*/
|
||||
private val buttonGapSize = 120
|
||||
private val highlighterYPos = icons.tileH + 4
|
||||
|
||||
@@ -233,7 +233,7 @@ class UIItemWorldPortalTopBar(
|
||||
|
||||
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
|
||||
UIItemImageButton(
|
||||
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) {
|
||||
super.update(delta)
|
||||
|
||||
|
||||
workingButtons.forEach { buttons[it].update(delta) }
|
||||
/*workingButtons.forEach { buttons[it].update(delta) }
|
||||
|
||||
// transition stuffs
|
||||
workingButtons.filter { buttons[it].mousePushed }.firstOrNull()?.let { pushedButton ->
|
||||
@@ -266,7 +266,7 @@ class UIItemWorldPortalTopBar(
|
||||
workingButtons.forEach { i ->
|
||||
buttons[i].highlighted = i == pushedButton
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (transitionFired) {
|
||||
transitionFired = false
|
||||
@@ -278,13 +278,13 @@ class UIItemWorldPortalTopBar(
|
||||
super.render(batch, camera)
|
||||
|
||||
// button
|
||||
buttons.forEach { it.render(batch, camera) }
|
||||
/*buttons.forEach { it.render(batch, camera) }
|
||||
|
||||
// label
|
||||
batch.color = Color.WHITE
|
||||
val text = Lang[catIconLabels[selectedPanel]]
|
||||
App.fontGame.draw(batch, text, buttons[selectedPanel].posX + 10 - (App.fontGame.getWidth(text) / 2), posY + highlighterYPos + 4)
|
||||
|
||||
*/
|
||||
|
||||
blendNormalStraightAlpha(batch)
|
||||
|
||||
|
||||
@@ -32,6 +32,13 @@ import java.util.zip.GZIPInputStream
|
||||
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.
|
||||
*/
|
||||
class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
@@ -59,7 +66,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
private val buttonsY = y + listHeight + gridGap
|
||||
|
||||
private val buttonSearch = UIItemTextButton(this,
|
||||
"CONTEXT_WORLD_SEARCH",
|
||||
"CONTEXT_WORLD_NEW",
|
||||
hx - gridGap/2 - 2*deleteButtonWidth - gridGap,
|
||||
buttonsY,
|
||||
deleteButtonWidth,
|
||||
@@ -116,10 +123,21 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun highlightListEditButtons(state: Boolean) {
|
||||
buttonRename.isActive = state
|
||||
buttonDelete.isActive = state
|
||||
buttonTeleport.isActive = state
|
||||
private fun disableListEditButtons() {
|
||||
buttonRename.isActive = false
|
||||
buttonDelete.isActive = false
|
||||
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 {
|
||||
@@ -220,7 +238,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
button.clickOnceListener = { _, _ ->
|
||||
selected = button
|
||||
selectedIndex = it
|
||||
highlightListEditButtons(it in worldList.indices)
|
||||
highlightListEditButtons(worldList.getOrNull(it))
|
||||
updateUIbyButtonSelection()
|
||||
}
|
||||
}
|
||||
@@ -238,7 +256,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
worldCells.forEach { it.show() }
|
||||
selected = null
|
||||
|
||||
highlightListEditButtons(false)
|
||||
disableListEditButtons()
|
||||
updateUIbyButtonSelection()
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ class UIWorldPortalSearch(val full: UIWorldPortal) : UICanvas() {
|
||||
|
||||
batch.color = Color.WHITE
|
||||
// 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)
|
||||
|
||||
// draw size previews
|
||||
|
||||
Reference in New Issue
Block a user