share code ui wall of text

This commit is contained in:
minjaesong
2023-09-03 20:30:23 +09:00
parent 65b610ce01
commit da7ecaa75b
5 changed files with 77 additions and 47 deletions

View File

@@ -3,5 +3,9 @@
"CONTEXT_IMPORT_AVATAR_INSTRUCTION_1": "1. Place the Avatar file into the following directory:",
"CONTEXT_IMPORT_AVATAR_INSTRUCTION_2": "",
"CONTEXT_IMPORT_AVATAR_INSTRUCTION_3": "2. Enter the name of the file below, then press Import",
"ERROR_AVATAR_ALREADY_EXISTS": "The Avatar already exists."
"ERROR_AVATAR_ALREADY_EXISTS": "The Avatar already exists.",
"CONTEXT_WORLD_CODE_SHARE_1": "Other people sharing the device can play on this",
"CONTEXT_WORLD_CODE_SHARE_2": "world when you are away.",
"CONTEXT_WORLD_CODE_SHARE_3": "",
"CONTEXT_WORLD_CODE_SHARE_4": "Share the code below so the other people can join!"
}

View File

@@ -111,8 +111,6 @@ class UIImportAvatar(val remoCon: UIRemoCon) : Advanceable() {
}
private val textboxIndices = (1..3)
private val errorMessages = listOf(
Lang["ERROR_GENERIC_TEXT"], // -1
"", // 0
@@ -120,13 +118,19 @@ class UIImportAvatar(val remoCon: UIRemoCon) : Advanceable() {
Lang["ERROR_AVATAR_ALREADY_EXISTS"], // 2
)
override fun show() {
super.show()
wotKeys = (1..3).map { Lang["CONTEXT_IMPORT_AVATAR_INSTRUCTION_$it", false] }
}
private lateinit var wotKeys: List<String>
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = Color.WHITE
val textboxWidth = textboxIndices.maxOf { App.fontGame.getWidth(Lang["CONTEXT_IMPORT_AVATAR_INSTRUCTION_$it"]) }
val textboxWidth = wotKeys.maxOf { App.fontGame.getWidth(it) }
val textX = (Toolkit.drawWidth - textboxWidth) / 2
// draw texts
for (i in textboxIndices) {
App.fontGame.draw(batch, Lang["CONTEXT_IMPORT_AVATAR_INSTRUCTION_$i"], textX, (App.scr.height - height) / 2 + descStartY + (i - 1) * lh)
wotKeys.forEachIndexed { i, s ->
App.fontGame.draw(batch, s, textX, (App.scr.height - height) / 2 + descStartY + i * lh)
}
// draw path
batch.color = if (mouseOnLink) Toolkit.Theme.COL_SELECTED else Toolkit.Theme.COL_MOUSE_UP

View File

@@ -78,9 +78,22 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
full.requestTransition(1)
}
}
private val buttonRename = UIItemTextButton(this,
{ Lang["MENU_LABEL_RENAME"] },
screencapX + buttonWidth + gridGap,
buttonsY,
buttonWidth,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE
).also {
it.clickOnceListener = { _,_ ->
full.queueUpRenameScr()
full.changePanelTo(1)
}
}
private val buttonTeleport = UIItemTextButton(this,
{ Lang["GAME_ACTION_TELEPORT"] },
screencapX + buttonWidth + gridGap,
screencapX + (buttonWidth + gridGap) * 2,
buttonsY,
buttonWidth,
hasBorder = true,
@@ -96,22 +109,22 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
}
}
}
private val buttonRename = UIItemTextButton(this,
{ Lang["MENU_LABEL_RENAME"] },
screencapX + (buttonWidth + gridGap) * 2,
private val buttonShare = UIItemTextButton(this,
{ Lang["MENU_LABEL_SHARE"] },
screencapX + (buttonWidth + gridGap) * 3,
buttonsY,
buttonWidth,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE
alignment = UIItemTextButton.Companion.Alignment.CENTRE,
).also {
it.clickOnceListener = { _,_ ->
full.queueUpRenameScr()
full.queueUpShareScr()
full.changePanelTo(1)
}
}
private val buttonDelete = UIItemTextButton(this,
{ Lang["MENU_LABEL_DELETE_WORLD"] },
screencapX + (buttonWidth + gridGap) * 3,
screencapX + (buttonWidth + gridGap) * 4,
buttonsY,
buttonWidth,
hasBorder = true,
@@ -123,19 +136,6 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
full.changePanelTo(1)
}
}
private val buttonShare = UIItemTextButton(this,
{ Lang["MENU_LABEL_SHARE"] },
screencapX + (buttonWidth + gridGap) * 4,
buttonsY,
buttonWidth,
hasBorder = true,
alignment = UIItemTextButton.Companion.Alignment.CENTRE,
).also {
it.clickOnceListener = { _,_ ->
full.queueUpShareScr()
full.changePanelTo(1)
}
}
private val navRemoCon = UIItemListNavBarVertical(full, hx + 6 + UIItemWorldCellsSimple.width, y + 7, listHeight + 2, false)

View File

@@ -74,17 +74,36 @@ class UIWorldPortalSearch(val full: UIWorldPortal) : UICanvas() {
private val radioX = (width - (radioCellWidth * tex.size + 9)) / 2
private var selectedSizeChunks = 0
private val gridGap = 10
private val buttonBaseX = (Toolkit.drawWidth - 3 * goButtonWidth - 2 * gridGap) / 2
private val backButton = UIItemTextButton(this,
{ Lang["MENU_LABEL_BACK"] }, drawX + (width/2 - goButtonWidth) / 2, buttonY, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
{ Lang["MENU_LABEL_BACK"] }, buttonBaseX, buttonY, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
it.clickOnceListener = { _, _ ->
full.requestTransition(0)
}
}
private val goButton = UIItemTextButton(this,
{ Lang["MENU_LABEL_CONFIRM_BUTTON"] }, drawX + width/2 + (width/2 - goButtonWidth) / 2, buttonY, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
private val useInvitationButton = UIItemTextButton(this,
{ Lang["MENU_LABEL_USE_CODE"] }, buttonBaseX + goButtonWidth + gridGap, buttonY, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
}
private val goButton: UIItemTextButton = UIItemTextButton(this,
{ Lang["MENU_LABEL_CONFIRM_BUTTON"] }, buttonBaseX + (goButtonWidth + gridGap) * 2, buttonY, goButtonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
it.clickOnceListener = { _, _ ->
val seed = try {
seedInput.getTextOrPlaceholder().toLong()
}
catch (e: NumberFormatException) {
XXHash64.hash(seedInput.getTextOrPlaceholder().toByteArray(Charsets.UTF_8), 10000)
}
val (wx, wy) = TerrarumIngame.WORLDPORTAL_NEW_WORLD_SIZE[sizeSelector.selection]
val worldParam = TerrarumIngame.NewWorldParameters(wx, wy, seed, nameInput.getTextOrPlaceholder())
full.host.teleportRequest = FixtureWorldPortal.TeleportRequest(null, worldParam)
full.setAsClose()
}
}
private val sizeSelector = UIItemInlineRadioButtons(this,
@@ -108,22 +127,9 @@ class UIWorldPortalSearch(val full: UIWorldPortal) : UICanvas() {
selectedSizeChunks = (wx / LandUtil.CHUNK_W) * (wy / LandUtil.CHUNK_H)
goButton.isEnabled = (full.chunksUsed + selectedSizeChunks) <= full.chunksMax
goButton.clickOnceListener = { _, _ ->
val seed = try {
seedInput.getTextOrPlaceholder().toLong()
}
catch (e: NumberFormatException) {
XXHash64.hash(seedInput.getTextOrPlaceholder().toByteArray(Charsets.UTF_8), 10000)
}
val (wx, wy) = TerrarumIngame.WORLDPORTAL_NEW_WORLD_SIZE[sizeSelector.selection]
val worldParam = TerrarumIngame.NewWorldParameters(wx, wy, seed, nameInput.getTextOrPlaceholder())
full.host.teleportRequest = FixtureWorldPortal.TeleportRequest(null, worldParam)
full.setAsClose()
}
addUIitem(sizeSelector)
addUIitem(goButton)
addUIitem(useInvitationButton)
addUIitem(backButton)
addUIitem(seedInput) // order is important
addUIitem(nameInput) // because of the IME candidates overlay

View File

@@ -54,23 +54,39 @@ class UIWorldPortalShare(private val full: UIWorldPortal) : UICanvas() {
}
printdbg(this, shareCode)
wotKeys = (1..4).map { Lang["CONTEXT_WORLD_CODE_SHARE_$it", false] }
}
private lateinit var wotKeys: List<String>
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = Color.WHITE
val textY = drawY + (height/2) - App.fontGame.lineHeight.toInt() * 4
val codeY = textY + App.fontGame.lineHeight.toInt() * 5
// share code background
batch.color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER
Toolkit.drawBoxBorder(batch, drawX - 1, drawY + (height / 2) - 6, width + 2, BigAlphNum.H + 12)
Toolkit.drawBoxBorder(batch, drawX - 1, codeY - 1, width + 2, BigAlphNum.H + 12)
batch.color = Toolkit.Theme.COL_CELL_FILL
Toolkit.fillArea(batch, drawX, drawY + (height / 2) - 5, width, BigAlphNum.H + 10)
Toolkit.fillArea(batch, drawX, codeY, width, BigAlphNum.H + 10)
// share code
batch.color = Toolkit.Theme.COL_MOUSE_UP
Toolkit.drawTextCentered(batch, App.fontBigNumbers, shareCode, width, drawX, drawY + (height / 2))
Toolkit.drawTextCentered(batch, App.fontBigNumbers, shareCode, width, drawX, codeY + 5)
// texts
batch.color = Color.WHITE
val textboxWidth = wotKeys.maxOf { App.fontGame.getWidth(it) }
val tx = drawX + (width - textboxWidth) / 2
wotKeys.forEachIndexed { i, s ->
App.fontGame.draw(batch, s, tx, textY + App.fontGame.lineHeight.toInt() * i)
}
// ui title
batch.color = Color.WHITE
val titlestr = Lang["MENU_LABEL_SHARE"]
App.fontUITitle.draw(batch, titlestr, drawX + (width - App.fontUITitle.getWidth(titlestr)).div(2).toFloat(), UIInventoryFull.INVENTORY_CELLS_OFFSET_Y() - 36f)