mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
working config panels on esc menu
This commit is contained in:
@@ -12,7 +12,7 @@ import net.torvald.terrarum.ui.*
|
||||
/**
|
||||
* Created by minjaesong on 2021-10-06.
|
||||
*/
|
||||
class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() {
|
||||
class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||
|
||||
override var width = 400
|
||||
override var height = 400
|
||||
@@ -27,11 +27,11 @@ class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() {
|
||||
private val panelgap = 20
|
||||
|
||||
private val options = arrayOf(
|
||||
arrayOf("fx_dither", Lang["MENU_OPTIONS_DITHER"], "toggle"),
|
||||
arrayOf("fx_backgroundblur", Lang["MENU_OPTIONS_BLUR"], "toggle"),
|
||||
arrayOf("fx_streamerslayout", Lang["MENU_OPTION_STREAMERS_LAYOUT"], "toggle"),
|
||||
arrayOf("usevsync", Lang["MENU_OPTIONS_VSYNC"]+"*", "toggle"),
|
||||
arrayOf("maxparticles", Lang["MENU_OPTIONS_PARTICLES"], "spinner,256,1024,256")
|
||||
arrayOf("fx_dither", { Lang["MENU_OPTIONS_DITHER"] }, "toggle"),
|
||||
arrayOf("fx_backgroundblur", { Lang["MENU_OPTIONS_BLUR"] }, "toggle"),
|
||||
arrayOf("fx_streamerslayout", { Lang["MENU_OPTION_STREAMERS_LAYOUT"] }, "toggle"),
|
||||
arrayOf("usevsync", { Lang["MENU_OPTIONS_VSYNC"]+"*" }, "toggle"),
|
||||
arrayOf("maxparticles", { Lang["MENU_OPTIONS_PARTICLES"] }, "spinner,256,1024,256")
|
||||
)
|
||||
|
||||
private fun makeButton(args: String, x: Int, y: Int, optionName: String): UIItem {
|
||||
@@ -46,10 +46,10 @@ class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() {
|
||||
}
|
||||
|
||||
private val optionControllers = options.mapIndexed { index, strings ->
|
||||
makeButton(options[index][2],
|
||||
makeButton(options[index][2] as String,
|
||||
drawX + width - panelgap,
|
||||
drawY + panelgap - 2 + index * (20 + linegap),
|
||||
options[index][0]
|
||||
options[index][0] as String
|
||||
)
|
||||
/*UIItemToggleButton(this,
|
||||
drawX + width - panelgap - 75,
|
||||
@@ -63,12 +63,12 @@ class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() {
|
||||
if (it is UIItemToggleButton) {
|
||||
it.clickOnceListener = { _, _, _ ->
|
||||
it.toggle()
|
||||
App.setConfig(options[i][0], it.getStatus())
|
||||
App.setConfig(options[i][0] as String, it.getStatus())
|
||||
}
|
||||
}
|
||||
else if (it is UIItemSpinner) {
|
||||
it.selectionChangeListener = {
|
||||
App.setConfig(options[i][0], it)
|
||||
App.setConfig(options[i][0] as String, it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() {
|
||||
|
||||
batch.color = Color.WHITE
|
||||
options.forEachIndexed { index, strings ->
|
||||
App.fontGame.draw(batch, strings[1], drawX + panelgap.toFloat(), drawY + panelgap + index * (20f + linegap))
|
||||
App.fontGame.draw(batch, (strings[1] as () -> String).invoke(), drawX + panelgap.toFloat(), drawY + panelgap + index * (20f + linegap))
|
||||
}
|
||||
uiItems.forEach { it.render(batch, camera) }
|
||||
App.fontGame.draw(batch, "* ${Lang["MENU_LABEL_RESTART_REQUIRED"]}", drawX + panelgap.toFloat(), drawY + height - panelgap - App.fontGame.lineHeight)
|
||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.Terrarum.getPlayerSaveFiledesc
|
||||
import net.torvald.terrarum.Terrarum.getWorldSaveFiledesc
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.TitleScreen
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
|
||||
@@ -30,10 +31,10 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
|
||||
private val gameMenu = arrayOf(
|
||||
"MENU_IO_SAVE_GAME",
|
||||
"MENU_LABEL_GRAPHICS",
|
||||
"MENU_OPTIONS_CONTROLS",
|
||||
"MENU_CONTROLS_KEYBOARD",
|
||||
"MENU_LABEL_LANGUAGE",
|
||||
"MENU_LABEL_MAINMENU",
|
||||
// "MENU_LABEL_QUIT",
|
||||
)
|
||||
private val gameMenuListHeight = DEFAULT_LINE_HEIGHT * gameMenu.size
|
||||
private val gameMenuListWidth = 400
|
||||
@@ -74,8 +75,9 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
defaultSelection = null
|
||||
)*/
|
||||
private val savingUI = UIItemSaving(this, (width - UIItemSaving.WIDTH) / 2, (height - UIItemSaving.HEIGHT) / 2)
|
||||
|
||||
private val keyConfigUI = UIKeyboardControlPanel(null)
|
||||
private val languageUI = UITitleLanguage(null)
|
||||
private val keyboardSetupUI = UIKeyboardInputConfig(null)
|
||||
|
||||
private var oldScreen = 0
|
||||
private var screen = 0
|
||||
@@ -87,6 +89,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
init {
|
||||
uiItems.add(gameMenuButtons)
|
||||
|
||||
// `gameMenu` order
|
||||
gameMenuButtons.selectionChangeListener = { _, new ->
|
||||
when (new) {
|
||||
0 -> {
|
||||
@@ -130,15 +133,18 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
}
|
||||
|
||||
}
|
||||
2 -> {
|
||||
1 -> {
|
||||
screen = 4; gameMenuButtons.deselect()
|
||||
}
|
||||
2 -> {
|
||||
screen = 1; gameMenuButtons.deselect()
|
||||
}
|
||||
3 -> {
|
||||
screen = 5; gameMenuButtons.deselect()
|
||||
}
|
||||
4 -> {
|
||||
screen = 2; gameMenuButtons.deselect()
|
||||
}
|
||||
/*4 -> {
|
||||
screen = 1; gameMenuButtons.deselect()
|
||||
}*/
|
||||
}
|
||||
}
|
||||
areYouSureMainMenuButtons.selectionChangeListener = { _, new ->
|
||||
@@ -152,39 +158,29 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*areYouSureQuitButtons.selectionChangeListener = { _, new ->
|
||||
when (new) {
|
||||
2 -> Gdx.app.exit()
|
||||
3 -> {
|
||||
screen = 0; areYouSureQuitButtons.deselect()
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
// Completely unrelated to the gameMenuButtons order
|
||||
private val screens = arrayOf(
|
||||
gameMenuButtons, null, areYouSureMainMenuButtons, savingUI, keyConfigUI
|
||||
gameMenuButtons, keyboardSetupUI, areYouSureMainMenuButtons, savingUI, keyConfigUI, languageUI
|
||||
)
|
||||
|
||||
|
||||
// `screens` order
|
||||
private val screenRenders = arrayOf(
|
||||
{ batch: SpriteBatch, camera: Camera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
|
||||
// text buttons
|
||||
gameMenuButtons.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: Camera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
|
||||
// areYouSureQuitButtons.render(batch, camera)
|
||||
keyboardSetupUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: Camera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
|
||||
areYouSureMainMenuButtons.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: Camera ->
|
||||
@@ -193,29 +189,53 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
{ batch: SpriteBatch, camera: Camera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
|
||||
keyConfigUI.render(batch, camera)
|
||||
},
|
||||
{ batch: SpriteBatch, camera: Camera ->
|
||||
// control hints
|
||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||
languageUI.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 -> },
|
||||
{ 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 ->
|
||||
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 -> },
|
||||
)
|
||||
|
||||
// `screens` order
|
||||
private val screenTouchUps = arrayOf(
|
||||
{ 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 -> },
|
||||
)
|
||||
|
||||
// `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 -> },
|
||||
)
|
||||
|
||||
override fun show() {
|
||||
@@ -237,7 +257,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
yeet.show()
|
||||
else if (yeet is UICanvas) {
|
||||
yeet.show()
|
||||
yeet.setPosition(0,42)
|
||||
yeet.setPosition(0,0)
|
||||
yeet.setAsOpen()
|
||||
}
|
||||
oldScreen = screen
|
||||
@@ -266,6 +286,18 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
||||
super.scrolled(amountX, amountY)
|
||||
screenScrolls[screen](amountX, amountY)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun inputStrobed(e: TerrarumKeyboardEvent) {
|
||||
if (screens[screen] == keyboardSetupUI) {
|
||||
keyboardSetupUI.inputStrobed(e)
|
||||
}
|
||||
}
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.torvald.ENDASH
|
||||
import net.torvald.getKeycapPC
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.*
|
||||
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
@@ -277,8 +278,6 @@ class UIInventoryFull(
|
||||
transitionPanel.dispose()
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
INGAME.pause()
|
||||
INGAME.setTooltipMessage(null)
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.DefaultConfig
|
||||
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.ui.*
|
||||
|
||||
|
||||
@@ -8,10 +8,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.EMDASH
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.gamecontroller.IME
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gamecontroller.TerrarumIME
|
||||
import net.torvald.terrarum.gamecontroller.TerrarumKeyCapsMode
|
||||
import net.torvald.terrarum.gamecontroller.*
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.linearSearch
|
||||
import net.torvald.terrarum.ui.*
|
||||
|
||||
@@ -5,12 +5,13 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItemTextButtonList
|
||||
|
||||
class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() {
|
||||
class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
|
||||
|
||||
val menuLabels = arrayOf(
|
||||
"MENU_LABEL_RETURN"
|
||||
@@ -55,6 +56,7 @@ class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() {
|
||||
defaultSelection = null
|
||||
)
|
||||
|
||||
private var initialMouseBlock = true
|
||||
|
||||
init {
|
||||
|
||||
@@ -93,10 +95,14 @@ class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() {
|
||||
}
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
textArea1.update(delta)
|
||||
textArea2.update(delta)
|
||||
if (initialMouseBlock && !Terrarum.mouseDown) {
|
||||
initialMouseBlock = false
|
||||
}
|
||||
|
||||
//AppLoader.printdbg(this, "should be printing indefinitely")
|
||||
if (!initialMouseBlock) {
|
||||
textArea1.update(delta)
|
||||
textArea2.update(delta)
|
||||
}
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
@@ -106,6 +112,14 @@ class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() {
|
||||
textArea2.render(batch, camera)
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
initialMouseBlock = true
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
initialMouseBlock = true
|
||||
}
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ object UITitleRemoConYaml {
|
||||
val menuBase = """
|
||||
- MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UILoadDemoSavefiles
|
||||
- MENU_OPTIONS
|
||||
- MENU_LABEL_GRAPHICS : net.torvald.terrarum.modulebasegame.ui.GraphicsControlPanel
|
||||
- MENU_LABEL_GRAPHICS : net.torvald.terrarum.modulebasegame.ui.UIGraphicsControlPanel
|
||||
- MENU_OPTIONS_CONTROLS : net.torvald.terrarum.modulebasegame.ui.UIKeyboardControlPanel
|
||||
- MENU_CONTROLS_KEYBOARD : net.torvald.terrarum.modulebasegame.ui.UIKeyboardInputConfig
|
||||
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
|
||||
|
||||
Reference in New Issue
Block a user