mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
adding a spinner on the graphics control panel
This commit is contained in:
@@ -15,5 +15,8 @@
|
|||||||
"MENU_OPTION_STREAMERS_LAYOUT": "Chat Overlay Mode",
|
"MENU_OPTION_STREAMERS_LAYOUT": "Chat Overlay Mode",
|
||||||
"MENU_LABEL_RESTART_REQUIRED": "Restart Required",
|
"MENU_LABEL_RESTART_REQUIRED": "Restart Required",
|
||||||
"MENU_LABEL_KEYBOARD_LAYOUT": "Keyboard Layout",
|
"MENU_LABEL_KEYBOARD_LAYOUT": "Keyboard Layout",
|
||||||
"MENU_LABEL_IME": "IME"
|
"MENU_LABEL_IME": "IME",
|
||||||
|
"MENU_OPTIONS_DITHER": "Dither",
|
||||||
|
"MENU_OPTIONS_BLUR": "Blur",
|
||||||
|
"MENU_OPTIONS_PARTICLES": "Particles"
|
||||||
}
|
}
|
||||||
@@ -14,5 +14,8 @@
|
|||||||
"MENU_OPTION_STREAMERS_LAYOUT": "스트리머 채팅창 모드",
|
"MENU_OPTION_STREAMERS_LAYOUT": "스트리머 채팅창 모드",
|
||||||
"MENU_LABEL_RESTART_REQUIRED": "재시작 필요",
|
"MENU_LABEL_RESTART_REQUIRED": "재시작 필요",
|
||||||
"MENU_LABEL_KEYBOARD_LAYOUT": "자판 배열",
|
"MENU_LABEL_KEYBOARD_LAYOUT": "자판 배열",
|
||||||
"MENU_LABEL_IME": "입력기"
|
"MENU_LABEL_IME": "입력기",
|
||||||
|
"MENU_OPTIONS_DITHER": "디더링",
|
||||||
|
"MENU_OPTIONS_BLUR": "흐림",
|
||||||
|
"MENU_OPTIONS_PARTICLES": "입자 수"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ import net.torvald.TIMES
|
|||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELL_COL
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELL_COL
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
|
||||||
import net.torvald.terrarum.ui.UIItemTextButton
|
|
||||||
import net.torvald.terrarum.ui.UIItemToggleButton
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2021-10-06.
|
* Created by minjaesong on 2021-10-06.
|
||||||
@@ -21,6 +18,7 @@ class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
override var height = 400
|
override var height = 400
|
||||||
override var openCloseTime = 0f
|
override var openCloseTime = 0f
|
||||||
|
|
||||||
|
private val spinnerWidth = 136
|
||||||
private val drawX = (Toolkit.drawWidth - width) / 2
|
private val drawX = (Toolkit.drawWidth - width) / 2
|
||||||
private val drawY = (App.scr.height - height) / 2
|
private val drawY = (App.scr.height - height) / 2
|
||||||
|
|
||||||
@@ -29,25 +27,49 @@ 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", "Dither"),
|
arrayOf("fx_dither", Lang["MENU_OPTIONS_DITHER"], "toggle"),
|
||||||
arrayOf("fx_backgroundblur", "Blur"),
|
arrayOf("fx_backgroundblur", Lang["MENU_OPTIONS_BLUR"], "toggle"),
|
||||||
arrayOf("fx_streamerslayout", Lang["MENU_OPTION_STREAMERS_LAYOUT"]),
|
arrayOf("fx_streamerslayout", Lang["MENU_OPTION_STREAMERS_LAYOUT"], "toggle"),
|
||||||
arrayOf("usevsync", Lang["MENU_OPTIONS_VSYNC"]+"*")
|
arrayOf("usevsync", Lang["MENU_OPTIONS_VSYNC"]+"*", "toggle"),
|
||||||
|
arrayOf("maxparticles", Lang["MENU_OPTIONS_PARTICLES"], "spinner,256,1024,256")
|
||||||
)
|
)
|
||||||
|
|
||||||
private val togglers = options.mapIndexed { index, strings ->
|
private fun makeButton(args: String, x: Int, y: Int, optionName: String): UIItem {
|
||||||
UIItemToggleButton(this,
|
return if (args.startsWith("toggle")) {
|
||||||
|
UIItemToggleButton(this, x - 75, y, App.getConfigBoolean(optionName))
|
||||||
|
}
|
||||||
|
else if (args.startsWith("spinner,")) {
|
||||||
|
val arg = args.split(',')
|
||||||
|
UIItemSpinner(this, x - spinnerWidth, y, App.getConfigInt(optionName), arg[1].toInt(), arg[2].toInt(), arg[3].toInt(), spinnerWidth)
|
||||||
|
}
|
||||||
|
else throw IllegalArgumentException(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val optionControllers = options.mapIndexed { index, strings ->
|
||||||
|
makeButton(options[index][2],
|
||||||
|
drawX + width - panelgap,
|
||||||
|
drawY + panelgap - 2 + index * (20 + linegap),
|
||||||
|
options[index][0]
|
||||||
|
)
|
||||||
|
/*UIItemToggleButton(this,
|
||||||
drawX + width - panelgap - 75,
|
drawX + width - panelgap - 75,
|
||||||
drawY + panelgap - 2 + index * (20 + linegap),
|
drawY + panelgap - 2 + index * (20 + linegap),
|
||||||
App.getConfigBoolean(options[index][0])
|
App.getConfigBoolean(options[index][0])
|
||||||
)
|
)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
togglers.forEachIndexed { i, it ->
|
optionControllers.forEachIndexed { i, it ->
|
||||||
it.clickOnceListener = { _,_,_ ->
|
if (it is UIItemToggleButton) {
|
||||||
it.toggle()
|
it.clickOnceListener = { _, _, _ ->
|
||||||
App.setConfig(options[i][0], it.getStatus())
|
it.toggle()
|
||||||
|
App.setConfig(options[i][0], it.getStatus())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (it is UIItemSpinner) {
|
||||||
|
it.selectionChangeListener = {
|
||||||
|
App.setConfig(options[i][0], it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addUIitem(it)
|
addUIitem(it)
|
||||||
@@ -59,7 +81,7 @@ class GraphicsControlPanel(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
batch.color = Color.WHITE
|
batch.color = Toolkit.Theme.COL_INACTIVE
|
||||||
Toolkit.drawBoxBorder(batch, drawX, drawY, width, height)
|
Toolkit.drawBoxBorder(batch, drawX, drawY, width, height)
|
||||||
|
|
||||||
batch.color = CELL_COL
|
batch.color = CELL_COL
|
||||||
|
|||||||
Reference in New Issue
Block a user