mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
weatherbox is now owned by the world
This commit is contained in:
@@ -302,7 +302,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
IngameRenderer.setRenderedWorld(gameWorld)
|
||||
WeatherMixer.internalReset()
|
||||
WeatherMixer.internalReset(this)
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
|
||||
@@ -332,8 +332,8 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
else {
|
||||
printdbg(this, "Ingame setting things up from the savegame")
|
||||
|
||||
RoguelikeRandomiser.loadFromSave(codices.world.randSeeds[0], codices.world.randSeeds[1])
|
||||
WeatherMixer.loadFromSave(codices.world.randSeeds[2], codices.world.randSeeds[3])
|
||||
RoguelikeRandomiser.loadFromSave(this, codices.world.randSeeds[0], codices.world.randSeeds[1])
|
||||
WeatherMixer.loadFromSave(this, codices.world.randSeeds[2], codices.world.randSeeds[3])
|
||||
|
||||
// Terrarum.itemCodex.loadFromSave(codices.item)
|
||||
// Terrarum.apocryphas = HashMap(codices.apocryphas)
|
||||
@@ -503,7 +503,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
actorGamer = player
|
||||
forceAddActor(player)
|
||||
|
||||
WeatherMixer.internalReset()
|
||||
WeatherMixer.internalReset(this)
|
||||
|
||||
UILoadGovernor.worldUUID = world.worldIndex
|
||||
}
|
||||
|
||||
@@ -212,8 +212,8 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
IngameRenderer.setRenderedWorld(demoWorld)
|
||||
WeatherMixer.internalReset()
|
||||
WeatherMixer.titleScreenInitWeather()
|
||||
WeatherMixer.internalReset(this)
|
||||
WeatherMixer.titleScreenInitWeather(this.world.weatherbox)
|
||||
|
||||
|
||||
// load a half-gradient texture that would be used throughout the titlescreen and its sub UIs
|
||||
|
||||
@@ -30,11 +30,12 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
override var height: Int = App.scr.height
|
||||
|
||||
private val gameMenu = arrayOf(
|
||||
"MENU_IO_SAVE_GAME",
|
||||
"MENU_OPTIONS_CONTROLS",
|
||||
"MENU_LABEL_IME",
|
||||
"MENU_LABEL_LANGUAGE",
|
||||
"MENU_LABEL_QUIT",
|
||||
"MENU_IO_SAVE_GAME",
|
||||
"MENU_OPTIONS_CONTROLS",
|
||||
"MENU_LABEL_IME",
|
||||
"MENU_LABEL_LANGUAGE",
|
||||
"MENU_LABEL_SHARE",
|
||||
"MENU_LABEL_QUIT",
|
||||
)
|
||||
private val gameMenuListHeight = DEFAULT_LINE_HEIGHT * gameMenu.size
|
||||
private val gameMenuListWidth = 400
|
||||
@@ -83,6 +84,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
private val keyConfigUI = UIKeyboardControlPanel(null)
|
||||
private val languageUI = UITitleLanguage(null)
|
||||
private val keyboardSetupUI = UIIMEConfig(null)
|
||||
private val shareUI = UIShare()
|
||||
|
||||
private var oldScreen = 0
|
||||
private var screen = 0
|
||||
@@ -155,6 +157,9 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
screen = 5; gameMenuButtons.deselect()
|
||||
}
|
||||
4 -> {
|
||||
screen = 6; gameMenuButtons.deselect()
|
||||
}
|
||||
5 -> {
|
||||
screen = 2; gameMenuButtons.deselect()
|
||||
}
|
||||
}
|
||||
@@ -172,82 +177,92 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
}
|
||||
}
|
||||
|
||||
private val controlHintX = ((width - 480) / 2).toFloat()
|
||||
|
||||
// Completely unrelated to the gameMenuButtons order
|
||||
private val screens = arrayOf(
|
||||
gameMenuButtons, keyboardSetupUI, areYouSureMainMenuButtons, savingUI, keyConfigUI, languageUI
|
||||
gameMenuButtons, keyboardSetupUI, areYouSureMainMenuButtons, savingUI, keyConfigUI, languageUI, shareUI
|
||||
)
|
||||
|
||||
// `screens` order
|
||||
private val screenRenders = arrayOf(
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
// text buttons
|
||||
gameMenuButtons.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
keyboardSetupUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
areYouSureMainMenuButtons.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
savingUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
keyConfigUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
languageUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, controlHintX, full.yEnd - 20)
|
||||
// text buttons
|
||||
gameMenuButtons.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, controlHintX, full.yEnd - 20)
|
||||
keyboardSetupUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, controlHintX, full.yEnd - 20)
|
||||
areYouSureMainMenuButtons.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
savingUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, controlHintX, full.yEnd - 20)
|
||||
keyConfigUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, controlHintX, full.yEnd - 20)
|
||||
languageUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: OrthographicCamera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, controlHintX, full.yEnd - 20)
|
||||
shareUI.render(batch, camera)
|
||||
},
|
||||
)
|
||||
|
||||
// `screens` order
|
||||
private val screenTouchDowns = arrayOf(
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int ->
|
||||
keyboardSetupUI.touchDown(screenX, screenY, pointer, button)
|
||||
},
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int ->
|
||||
keyConfigUI.touchDown(screenX, screenY, pointer, button)
|
||||
},
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
)
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int ->
|
||||
keyboardSetupUI.touchDown(screenX, screenY, pointer, button)
|
||||
},
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int ->
|
||||
keyConfigUI.touchDown(screenX, screenY, pointer, button)
|
||||
},
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
)
|
||||
|
||||
// `screens` order
|
||||
private val screenTouchUps = arrayOf(
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int ->
|
||||
keyboardSetupUI.touchUp(screenX, screenY, pointer, button)
|
||||
},
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int ->
|
||||
keyConfigUI.touchUp(screenX, screenY, pointer, button)
|
||||
},
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
)
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int ->
|
||||
keyboardSetupUI.touchUp(screenX, screenY, pointer, button)
|
||||
},
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int ->
|
||||
keyConfigUI.touchUp(screenX, screenY, pointer, button)
|
||||
},
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
|
||||
)
|
||||
|
||||
// `screens` order
|
||||
private val screenScrolls = arrayOf(
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float ->
|
||||
keyboardSetupUI.scrolled(amountX, amountY)
|
||||
},
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float ->
|
||||
keyboardSetupUI.scrolled(amountX, amountY)
|
||||
},
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
{ amountX: Float, amountY: Float -> },
|
||||
)
|
||||
|
||||
override fun show() {
|
||||
|
||||
79
src/net/torvald/terrarum/modulebasegame/ui/UIShare.kt
Normal file
79
src/net/torvald/terrarum/modulebasegame/ui/UIShare.kt
Normal file
@@ -0,0 +1,79 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.imagefont.BigAlphNum
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.serialise.toBig64
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.utils.PasswordBase32
|
||||
|
||||
class UIShare : UICanvas() {
|
||||
|
||||
override var width = 434
|
||||
override var height = 480
|
||||
|
||||
private val drawX = (Toolkit.drawWidth - width) / 2
|
||||
private val drawY = (App.scr.height - height) / 2
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
uiItems.forEach { it.update(delta) }
|
||||
}
|
||||
|
||||
private var shareCode = ""
|
||||
private var dash = ' '
|
||||
|
||||
override fun show() {
|
||||
shareCode = PasswordBase32.encode(
|
||||
INGAME.world.worldIndex.mostSignificantBits.toBig64() +
|
||||
INGAME.world.worldIndex.mostSignificantBits.toBig64()
|
||||
).let { it.substring(0, it.indexOf('=')) }.let {
|
||||
"${it.substring(0..3)}$dash${it.substring(4..5)}$dash${it.substring(6..10)}$dash${it.substring(11..15)}$dash${it.substring(16..20)}$dash${it.substring(21)}"
|
||||
}
|
||||
|
||||
App.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 - 2
|
||||
val codeY = textY + App.fontGame.lineHeight.toInt() * 5
|
||||
|
||||
// share code background
|
||||
batch.color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER
|
||||
Toolkit.drawBoxBorder(batch, drawX - 1, codeY - 1, width + 2, BigAlphNum.H + 12)
|
||||
batch.color = Toolkit.Theme.COL_CELL_FILL
|
||||
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, 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)
|
||||
}
|
||||
|
||||
|
||||
uiItems.forEach { it.render(batch, camera) }
|
||||
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
private val listHeight = UIItemWorldCellsSimple.height + (listCount - 1) * (UIItemWorldCellsSimple.height + gridGap)
|
||||
|
||||
private val memoryGaugeWidth = textAreaW
|
||||
private val buttonWidth = (UIItemWorldCellsSimple.width + thumbw - 3 * gridGap) / 5 // thumbw + cellw + gridgap = 4*gridgap + 5x
|
||||
private val buttonWidth = (UIItemWorldCellsSimple.width + thumbw - 2 * gridGap) / 4 // thumbw + cellw + gridgap = 4*gridgap + 5x
|
||||
private val buttonsY = y + listHeight + gridGap
|
||||
|
||||
private val screencapX = hx - thumbw - gridGap/2
|
||||
@@ -109,7 +109,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
}
|
||||
}
|
||||
}
|
||||
private val buttonShare = UIItemTextButton(this,
|
||||
/*private val buttonShare = UIItemTextButton(this,
|
||||
{ Lang["MENU_LABEL_SHARE"] },
|
||||
screencapX + (buttonWidth + gridGap) * 3,
|
||||
buttonsY,
|
||||
@@ -121,10 +121,10 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
full.queueUpShareScr()
|
||||
full.changePanelTo(1)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
private val buttonDelete = UIItemTextButton(this,
|
||||
{ Lang["MENU_LABEL_DELETE_WORLD"] },
|
||||
screencapX + (buttonWidth + gridGap) * 4,
|
||||
screencapX + (buttonWidth + gridGap) * 3,
|
||||
buttonsY,
|
||||
buttonWidth,
|
||||
hasBorder = true,
|
||||
@@ -159,7 +159,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
buttonRename.isEnabled = false
|
||||
buttonDelete.isEnabled = false
|
||||
buttonTeleport.isEnabled = false
|
||||
buttonShare.isEnabled = false
|
||||
// buttonShare.isEnabled = false
|
||||
currentWorldSelected = false
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
buttonRename.isEnabled = true
|
||||
buttonDelete.isEnabled = info.uuid != INGAME.world.worldIndex
|
||||
buttonTeleport.isEnabled = info.uuid != INGAME.world.worldIndex
|
||||
buttonShare.isEnabled = true
|
||||
// buttonShare.isEnabled = true
|
||||
currentWorldSelected = info.uuid == INGAME.world.worldIndex
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
addUIitem(buttonRename)
|
||||
addUIitem(buttonTeleport)
|
||||
addUIitem(buttonSearch)
|
||||
addUIitem(buttonShare)
|
||||
// addUIitem(buttonShare)
|
||||
addUIitem(navRemoCon)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import net.torvald.terrarum.utils.PasswordBase32
|
||||
class UIWorldPortalShare(private val full: UIWorldPortal) : UICanvas() {
|
||||
|
||||
override var width = 434
|
||||
override var height = 400
|
||||
override var height = 480
|
||||
|
||||
private val drawX = (Toolkit.drawWidth - width) / 2
|
||||
private val drawY = (App.scr.height - height) / 2
|
||||
|
||||
Reference in New Issue
Block a user