working config panels on esc menu

This commit is contained in:
minjaesong
2022-01-28 12:52:48 +09:00
parent fe5a4bcfb0
commit 5d587dcc12
7 changed files with 98 additions and 55 deletions

View File

@@ -12,7 +12,7 @@ import net.torvald.terrarum.ui.*
/** /**
* Created by minjaesong on 2021-10-06. * Created by minjaesong on 2021-10-06.
*/ */
class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() { class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
override var width = 400 override var width = 400
override var height = 400 override var height = 400
@@ -27,11 +27,11 @@ class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() {
private val panelgap = 20 private val panelgap = 20
private val options = arrayOf( private val options = arrayOf(
arrayOf("fx_dither", Lang["MENU_OPTIONS_DITHER"], "toggle"), arrayOf("fx_dither", { Lang["MENU_OPTIONS_DITHER"] }, "toggle"),
arrayOf("fx_backgroundblur", Lang["MENU_OPTIONS_BLUR"], "toggle"), arrayOf("fx_backgroundblur", { Lang["MENU_OPTIONS_BLUR"] }, "toggle"),
arrayOf("fx_streamerslayout", Lang["MENU_OPTION_STREAMERS_LAYOUT"], "toggle"), arrayOf("fx_streamerslayout", { Lang["MENU_OPTION_STREAMERS_LAYOUT"] }, "toggle"),
arrayOf("usevsync", Lang["MENU_OPTIONS_VSYNC"]+"*", "toggle"), arrayOf("usevsync", { Lang["MENU_OPTIONS_VSYNC"]+"*" }, "toggle"),
arrayOf("maxparticles", Lang["MENU_OPTIONS_PARTICLES"], "spinner,256,1024,256") arrayOf("maxparticles", { Lang["MENU_OPTIONS_PARTICLES"] }, "spinner,256,1024,256")
) )
private fun makeButton(args: String, x: Int, y: Int, optionName: String): UIItem { 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 -> private val optionControllers = options.mapIndexed { index, strings ->
makeButton(options[index][2], makeButton(options[index][2] as String,
drawX + width - panelgap, drawX + width - panelgap,
drawY + panelgap - 2 + index * (20 + linegap), drawY + panelgap - 2 + index * (20 + linegap),
options[index][0] options[index][0] as String
) )
/*UIItemToggleButton(this, /*UIItemToggleButton(this,
drawX + width - panelgap - 75, drawX + width - panelgap - 75,
@@ -63,12 +63,12 @@ class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() {
if (it is UIItemToggleButton) { if (it is UIItemToggleButton) {
it.clickOnceListener = { _, _, _ -> it.clickOnceListener = { _, _, _ ->
it.toggle() it.toggle()
App.setConfig(options[i][0], it.getStatus()) App.setConfig(options[i][0] as String, it.getStatus())
} }
} }
else if (it is UIItemSpinner) { else if (it is UIItemSpinner) {
it.selectionChangeListener = { 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 batch.color = Color.WHITE
options.forEachIndexed { index, strings -> 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) } uiItems.forEach { it.render(batch, camera) }
App.fontGame.draw(batch, "* ${Lang["MENU_LABEL_RESTART_REQUIRED"]}", drawX + panelgap.toFloat(), drawY + height - panelgap - App.fontGame.lineHeight) App.fontGame.draw(batch, "* ${Lang["MENU_LABEL_RESTART_REQUIRED"]}", drawX + panelgap.toFloat(), drawY + height - panelgap - App.fontGame.lineHeight)

View File

@@ -10,6 +10,7 @@ import net.torvald.terrarum.Terrarum.getPlayerSaveFiledesc
import net.torvald.terrarum.Terrarum.getWorldSaveFiledesc import net.torvald.terrarum.Terrarum.getWorldSaveFiledesc
import net.torvald.terrarum.blendNormal import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.TitleScreen import net.torvald.terrarum.modulebasegame.TitleScreen
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
@@ -30,10 +31,10 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
private val gameMenu = arrayOf( private val gameMenu = arrayOf(
"MENU_IO_SAVE_GAME", "MENU_IO_SAVE_GAME",
"MENU_LABEL_GRAPHICS",
"MENU_OPTIONS_CONTROLS", "MENU_OPTIONS_CONTROLS",
"MENU_CONTROLS_KEYBOARD",
"MENU_LABEL_LANGUAGE",
"MENU_LABEL_MAINMENU", "MENU_LABEL_MAINMENU",
// "MENU_LABEL_QUIT",
) )
private val gameMenuListHeight = DEFAULT_LINE_HEIGHT * gameMenu.size private val gameMenuListHeight = DEFAULT_LINE_HEIGHT * gameMenu.size
private val gameMenuListWidth = 400 private val gameMenuListWidth = 400
@@ -74,8 +75,9 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
defaultSelection = null defaultSelection = null
)*/ )*/
private val savingUI = UIItemSaving(this, (width - UIItemSaving.WIDTH) / 2, (height - UIItemSaving.HEIGHT) / 2) private val savingUI = UIItemSaving(this, (width - UIItemSaving.WIDTH) / 2, (height - UIItemSaving.HEIGHT) / 2)
private val keyConfigUI = UIKeyboardControlPanel(null) private val keyConfigUI = UIKeyboardControlPanel(null)
private val languageUI = UITitleLanguage(null)
private val keyboardSetupUI = UIKeyboardInputConfig(null)
private var oldScreen = 0 private var oldScreen = 0
private var screen = 0 private var screen = 0
@@ -87,6 +89,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
init { init {
uiItems.add(gameMenuButtons) uiItems.add(gameMenuButtons)
// `gameMenu` order
gameMenuButtons.selectionChangeListener = { _, new -> gameMenuButtons.selectionChangeListener = { _, new ->
when (new) { when (new) {
0 -> { 0 -> {
@@ -130,15 +133,18 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
} }
} }
2 -> { 1 -> {
screen = 4; gameMenuButtons.deselect() screen = 4; gameMenuButtons.deselect()
} }
2 -> {
screen = 1; gameMenuButtons.deselect()
}
3 -> { 3 -> {
screen = 5; gameMenuButtons.deselect()
}
4 -> {
screen = 2; gameMenuButtons.deselect() screen = 2; gameMenuButtons.deselect()
} }
/*4 -> {
screen = 1; gameMenuButtons.deselect()
}*/
} }
} }
areYouSureMainMenuButtons.selectionChangeListener = { _, new -> 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( private val screens = arrayOf(
gameMenuButtons, null, areYouSureMainMenuButtons, savingUI, keyConfigUI gameMenuButtons, keyboardSetupUI, areYouSureMainMenuButtons, savingUI, keyConfigUI, languageUI
) )
// `screens` order
private val screenRenders = arrayOf( private val screenRenders = arrayOf(
{ batch: SpriteBatch, camera: Camera -> { batch: SpriteBatch, camera: Camera ->
// control hints // control hints
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20) App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
// text buttons // text buttons
gameMenuButtons.render(batch, camera) gameMenuButtons.render(batch, camera)
}, },
{ batch: SpriteBatch, camera: Camera -> { batch: SpriteBatch, camera: Camera ->
// control hints // control hints
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20) App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
keyboardSetupUI.render(batch, camera)
// areYouSureQuitButtons.render(batch, camera)
}, },
{ batch: SpriteBatch, camera: Camera -> { batch: SpriteBatch, camera: Camera ->
// control hints // control hints
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20) App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
areYouSureMainMenuButtons.render(batch, camera) areYouSureMainMenuButtons.render(batch, camera)
}, },
{ batch: SpriteBatch, camera: Camera -> { batch: SpriteBatch, camera: Camera ->
@@ -193,29 +189,53 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
{ batch: SpriteBatch, camera: Camera -> { batch: SpriteBatch, camera: Camera ->
// control hints // control hints
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20) App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
keyConfigUI.render(batch, camera) 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( 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 -> }, 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 ->
) keyConfigUI.touchDown(screenX, screenY, pointer, button)
},
{ screenX: Int, screenY: Int, pointer: Int, button: Int -> },
)
// `screens` order
private val screenTouchUps = arrayOf( 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 -> }, { 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 -> }, { 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) 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() { override fun show() {
@@ -237,7 +257,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
yeet.show() yeet.show()
else if (yeet is UICanvas) { else if (yeet is UICanvas) {
yeet.show() yeet.show()
yeet.setPosition(0,42) yeet.setPosition(0,0)
yeet.setAsOpen() yeet.setAsOpen()
} }
oldScreen = screen oldScreen = screen
@@ -266,6 +286,18 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
return true 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) { override fun doOpening(delta: Float) {
} }

View File

@@ -8,6 +8,7 @@ import net.torvald.ENDASH
import net.torvald.getKeycapPC import net.torvald.getKeycapPC
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.App.* import net.torvald.terrarum.App.*
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.ui.Toolkit import net.torvald.terrarum.ui.Toolkit
@@ -277,8 +278,6 @@ class UIInventoryFull(
transitionPanel.dispose() transitionPanel.dispose()
} }
override fun doOpening(delta: Float) { override fun doOpening(delta: Float) {
INGAME.pause() INGAME.pause()
INGAME.setTooltipMessage(null) INGAME.setTooltipMessage(null)

View File

@@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.DefaultConfig import net.torvald.terrarum.DefaultConfig
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.* import net.torvald.terrarum.ui.*

View File

@@ -8,10 +8,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.EMDASH import net.torvald.EMDASH
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.gamecontroller.IME import net.torvald.terrarum.gamecontroller.*
import net.torvald.terrarum.gamecontroller.KeyToggler
import net.torvald.terrarum.gamecontroller.TerrarumIME
import net.torvald.terrarum.gamecontroller.TerrarumKeyCapsMode
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.linearSearch import net.torvald.terrarum.linearSearch
import net.torvald.terrarum.ui.* import net.torvald.terrarum.ui.*

View File

@@ -5,12 +5,13 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.Toolkit import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemTextButtonList import net.torvald.terrarum.ui.UIItemTextButtonList
class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() { class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
val menuLabels = arrayOf( val menuLabels = arrayOf(
"MENU_LABEL_RETURN" "MENU_LABEL_RETURN"
@@ -55,6 +56,7 @@ class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() {
defaultSelection = null defaultSelection = null
) )
private var initialMouseBlock = true
init { init {
@@ -93,10 +95,14 @@ class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() {
} }
override fun updateUI(delta: Float) { override fun updateUI(delta: Float) {
textArea1.update(delta) if (initialMouseBlock && !Terrarum.mouseDown) {
textArea2.update(delta) initialMouseBlock = false
}
//AppLoader.printdbg(this, "should be printing indefinitely") if (!initialMouseBlock) {
textArea1.update(delta)
textArea2.update(delta)
}
} }
override fun renderUI(batch: SpriteBatch, camera: Camera) { override fun renderUI(batch: SpriteBatch, camera: Camera) {
@@ -106,6 +112,14 @@ class UITitleLanguage(val remoCon: UIRemoCon) : UICanvas() {
textArea2.render(batch, camera) textArea2.render(batch, camera)
} }
override fun show() {
initialMouseBlock = true
}
override fun hide() {
initialMouseBlock = true
}
override fun doOpening(delta: Float) { override fun doOpening(delta: Float) {
} }

View File

@@ -14,7 +14,7 @@ object UITitleRemoConYaml {
val menuBase = """ val menuBase = """
- MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UILoadDemoSavefiles - MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UILoadDemoSavefiles
- MENU_OPTIONS - 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_OPTIONS_CONTROLS : net.torvald.terrarum.modulebasegame.ui.UIKeyboardControlPanel
- MENU_CONTROLS_KEYBOARD : net.torvald.terrarum.modulebasegame.ui.UIKeyboardInputConfig - MENU_CONTROLS_KEYBOARD : net.torvald.terrarum.modulebasegame.ui.UIKeyboardInputConfig
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage - MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage