mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
automated menuwork for control panel
This commit is contained in:
@@ -12,7 +12,6 @@ object DefaultConfig {
|
|||||||
val hashMap = hashMapOf<String, Any>(
|
val hashMap = hashMapOf<String, Any>(
|
||||||
"jvm_xmx" to 4,
|
"jvm_xmx" to 4,
|
||||||
"jvm_extra_cmd" to "",
|
"jvm_extra_cmd" to "",
|
||||||
"testvalue" to 1,
|
|
||||||
|
|
||||||
"displayfps" to 0, // 0: no limit, non-zero: limit
|
"displayfps" to 0, // 0: no limit, non-zero: limit
|
||||||
"displayfpsidle" to 0, // 0: no limit, non-zero: limit
|
"displayfpsidle" to 0, // 0: no limit, non-zero: limit
|
||||||
@@ -120,6 +119,12 @@ object DefaultConfig {
|
|||||||
"debug_deltat_benchmark_sample_sizes" to 2048,
|
"debug_deltat_benchmark_sample_sizes" to 2048,
|
||||||
|
|
||||||
|
|
||||||
|
"mastervolume" to 1.0,
|
||||||
|
"musicvolume" to 1.0,
|
||||||
|
"bgmvolume" to 1.0,
|
||||||
|
"sfxvolume" to 1.0,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// settings regarding debugger
|
// settings regarding debugger
|
||||||
/*"buildingmakerfavs" to arrayOf(
|
/*"buildingmakerfavs" to arrayOf(
|
||||||
|
|||||||
@@ -1,20 +1,35 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.ui
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
|
import net.torvald.terrarum.CommonResourcePool
|
||||||
import net.torvald.terrarum.ui.*
|
import net.torvald.terrarum.ui.*
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
|
typealias ControlPanelOptions = Array<Array<Any>>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2023-07-14.
|
* Created by minjaesong on 2023-07-14.
|
||||||
*/
|
*/
|
||||||
object ControlPanelCommon {
|
object ControlPanelCommon {
|
||||||
|
|
||||||
|
init {
|
||||||
|
CommonResourcePool.addToLoadingList("gui_hrule") {
|
||||||
|
TextureRegionPack(Gdx.files.internal("assets/graphics/gui/hrule.tga"), 216, 20)
|
||||||
|
}
|
||||||
|
CommonResourcePool.loadAll()
|
||||||
|
}
|
||||||
|
|
||||||
var CONFIG_SPINNER_WIDTH = 140
|
var CONFIG_SPINNER_WIDTH = 140
|
||||||
var CONFIG_TYPEIN_WIDTH = 240
|
var CONFIG_TYPEIN_WIDTH = 240
|
||||||
|
var CONFIG_SLIDER_WIDTH = 240
|
||||||
|
|
||||||
// @return Pair of <UIItem, Init job for the item>
|
// @return Pair of <UIItem, Init job for the item>
|
||||||
fun makeButton(parent: UICanvas, args: String, x: Int, y: Int, optionName: String): Pair<UIItem, (UIItem, String) -> Unit> {
|
fun makeButton(parent: UICanvas, args: String, x: Int, y: Int, optionName: String): Pair<UIItem, (UIItem, String) -> Unit> {
|
||||||
return if (args.startsWith("h1") || args.startsWith("p")) {
|
return if (args.equals("h1") || args.equals("p")) {
|
||||||
(object : UIItem(parent, x, y) {
|
(object : UIItem(parent, x, y) {
|
||||||
override val width = 1
|
override val width = 1
|
||||||
override val height = 1
|
override val height = 1
|
||||||
@@ -47,7 +62,7 @@ object ControlPanelCommon {
|
|||||||
}
|
}
|
||||||
else if (args.startsWith("sliderd,")) {
|
else if (args.startsWith("sliderd,")) {
|
||||||
val arg = args.split(',')
|
val arg = args.split(',')
|
||||||
UIItemHorzSlider(parent, x, y, App.getConfigDouble(optionName), arg[1].toDouble(), arg[2].toDouble(), CONFIG_SPINNER_WIDTH) to { it: UIItem, optionStr: String ->
|
UIItemHorzSlider(parent, x, y, App.getConfigDouble(optionName), arg[1].toDouble(), arg[2].toDouble(), CONFIG_SLIDER_WIDTH) to { it: UIItem, optionStr: String ->
|
||||||
(it as UIItemHorzSlider).selectionChangeListener = {
|
(it as UIItemHorzSlider).selectionChangeListener = {
|
||||||
App.setConfig(optionStr, it)
|
App.setConfig(optionStr, it)
|
||||||
}
|
}
|
||||||
@@ -107,4 +122,91 @@ object ControlPanelCommon {
|
|||||||
else throw IllegalArgumentException(args)
|
else throw IllegalArgumentException(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val linegap = 14
|
||||||
|
private val panelgap = 20
|
||||||
|
|
||||||
|
private val rowheight = 20 + linegap
|
||||||
|
|
||||||
|
private val h1MarginTop = 16
|
||||||
|
private val h1MarginBottom = 4
|
||||||
|
|
||||||
|
private val optionsYposCache = HashMap<String, IntArray>()
|
||||||
|
private val optionsCache = HashMap<String, ControlPanelOptions>()
|
||||||
|
|
||||||
|
fun register(ui: UICanvas, width: Int, identifier: String, options: ControlPanelOptions) {
|
||||||
|
optionsCache[identifier] = options
|
||||||
|
val optionsYpos = IntArray(options.size + 1)
|
||||||
|
var akku = 0
|
||||||
|
options.forEachIndexed { index, row ->
|
||||||
|
val option = row[2]
|
||||||
|
|
||||||
|
if (index > 0 && option == "h1") {
|
||||||
|
akku += h1MarginTop
|
||||||
|
}
|
||||||
|
|
||||||
|
optionsYpos[index] = akku
|
||||||
|
|
||||||
|
akku += when (option) {
|
||||||
|
"h1" -> rowheight + h1MarginBottom
|
||||||
|
else -> rowheight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
optionsYpos[optionsYpos.lastIndex] = akku
|
||||||
|
optionsYposCache[identifier] = optionsYpos
|
||||||
|
|
||||||
|
val height = optionsYpos.last()
|
||||||
|
val drawX = (App.scr.width - width) / 2
|
||||||
|
val drawY = (App.scr.height - height) / 2
|
||||||
|
|
||||||
|
options.forEachIndexed { index, args ->
|
||||||
|
val (item, job) = makeButton(
|
||||||
|
ui, args[2] as String,
|
||||||
|
drawX + width / 2 + panelgap,
|
||||||
|
drawY - 2 + optionsYpos[index],
|
||||||
|
args[0] as String
|
||||||
|
)
|
||||||
|
job.invoke(item, args[0] as String)
|
||||||
|
ui.addUIitem(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val hrule = CommonResourcePool.getAsTextureRegionPack("gui_hrule")
|
||||||
|
|
||||||
|
fun getMenuHeight(identifier: String) = optionsYposCache[identifier]!!.last()
|
||||||
|
|
||||||
|
fun render(identifier: String, width: Int, batch: SpriteBatch) {
|
||||||
|
val height = optionsYposCache[identifier]!!.last()
|
||||||
|
val drawX = (App.scr.width - width) / 2
|
||||||
|
val drawY = (App.scr.height - height) / 2
|
||||||
|
|
||||||
|
val optionsYpos = optionsYposCache[identifier]!!
|
||||||
|
optionsCache[identifier]!!.forEachIndexed { index, args ->
|
||||||
|
val mode = args[2]
|
||||||
|
|
||||||
|
val font = if (mode == "h1") App.fontUITitle else App.fontGame
|
||||||
|
|
||||||
|
val label = (args[1] as () -> String).invoke()
|
||||||
|
val labelWidth = font.getWidth(label)
|
||||||
|
batch.color = when (mode) {
|
||||||
|
"h1" -> Toolkit.Theme.COL_MOUSE_UP
|
||||||
|
"p" -> Color.LIGHT_GRAY
|
||||||
|
else -> Color.WHITE
|
||||||
|
}
|
||||||
|
|
||||||
|
val xpos = if (mode == "p" || mode == "h1")
|
||||||
|
drawX + (width - labelWidth)/2 // centre-aligned
|
||||||
|
else
|
||||||
|
drawX + width/2 - panelgap - labelWidth // right aligned at the middle of the panel, offsetted by panelgap
|
||||||
|
|
||||||
|
font.draw(batch, label, xpos.toFloat(), drawY + optionsYpos[index] - 2f)
|
||||||
|
|
||||||
|
// draw hrule
|
||||||
|
if (mode == "h1") {
|
||||||
|
val ruleWidth = ((width - 24 - labelWidth) / 2).toFloat()
|
||||||
|
batch.draw(hrule.get(0,0), xpos - 24f - ruleWidth, drawY + optionsYpos[index].toFloat(), ruleWidth, hrule.tileH.toFloat())
|
||||||
|
batch.draw(hrule.get(0,1), xpos + 24f + labelWidth, drawY + optionsYpos[index].toFloat(), ruleWidth, hrule.tileH.toFloat())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,119 +19,33 @@ import net.torvald.unicode.TIMES
|
|||||||
*/
|
*/
|
||||||
class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||||
|
|
||||||
|
override var width = 560
|
||||||
|
|
||||||
private val linegap = 14
|
init {
|
||||||
private val panelgap = 20
|
ControlPanelCommon.register(this, width, "basegame.graphicscontrolpanel", arrayOf(
|
||||||
|
arrayOf("", { Lang["CREDITS_VFX"] }, "h1"),
|
||||||
private val rowheight = 20 + linegap
|
|
||||||
|
|
||||||
private val h1MarginTop = 16
|
|
||||||
private val h1MarginBottom = 4
|
|
||||||
|
|
||||||
private val options = arrayOf(
|
|
||||||
arrayOf("", { Lang["CREDITS_VFX"] }, "h1"),
|
|
||||||
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("maxparticles", { Lang["MENU_OPTIONS_PARTICLES"] }, "spinner,256,1024,256"),
|
arrayOf("maxparticles", { Lang["MENU_OPTIONS_PARTICLES"] }, "spinner,256,1024,256"),
|
||||||
arrayOf("", { Lang["MENU_OPTIONS_DISPLAY"] }, "h1"),
|
arrayOf("", { Lang["MENU_OPTIONS_DISPLAY"] }, "h1"),
|
||||||
arrayOf("screenwidth,screenheight", { Lang["MENU_OPTIONS_RESOLUTION"] }, "typeinres"),
|
arrayOf("screenwidth,screenheight", { Lang["MENU_OPTIONS_RESOLUTION"] }, "typeinres"),
|
||||||
arrayOf("screenmagnifying", { Lang["GAME_ACTION_ZOOM"] }, "spinnerd,1.0,2.0,0.05"),
|
arrayOf("screenmagnifying", { Lang["GAME_ACTION_ZOOM"] }, "spinnerd,1.0,2.0,0.05"),
|
||||||
arrayOf("displayfps", { Lang["MENU_LABEL_FRAMESPERSEC"] }, "spinner,0,300,2"),
|
arrayOf("displayfps", { Lang["MENU_LABEL_FRAMESPERSEC"] }, "spinner,0,300,2"),
|
||||||
arrayOf("usevsync", { Lang["MENU_OPTIONS_VSYNC"] }, "toggle"),
|
arrayOf("usevsync", { Lang["MENU_OPTIONS_VSYNC"] }, "toggle"),
|
||||||
arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"),
|
arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"),
|
||||||
arrayOf("", { Lang["MENU_LABEL_STREAMING"] }, "h1"),
|
arrayOf("", { Lang["MENU_LABEL_STREAMING"] }, "h1"),
|
||||||
arrayOf("fx_streamerslayout", { Lang["MENU_OPTIONS_STREAMERS_LAYOUT"] }, "toggle"),
|
arrayOf("fx_streamerslayout", { Lang["MENU_OPTIONS_STREAMERS_LAYOUT"] }, "toggle"),
|
||||||
)
|
))
|
||||||
|
|
||||||
private val optionsYpos = IntArray(options.size + 1)
|
|
||||||
|
|
||||||
init {
|
|
||||||
CommonResourcePool.addToLoadingList("gui_hrule") {
|
|
||||||
TextureRegionPack(Gdx.files.internal("assets/graphics/gui/hrule.tga"), 216, 20)
|
|
||||||
}
|
|
||||||
CommonResourcePool.loadAll()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var akku = 0
|
|
||||||
options.forEachIndexed { index, row ->
|
|
||||||
val option = row[2]
|
|
||||||
|
|
||||||
if (index > 0 && option == "h1") {
|
|
||||||
akku += h1MarginTop
|
|
||||||
}
|
|
||||||
|
|
||||||
optionsYpos[index] = akku
|
|
||||||
|
|
||||||
akku += when (option) {
|
|
||||||
"h1" -> rowheight + h1MarginBottom
|
|
||||||
else -> rowheight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
optionsYpos[optionsYpos.lastIndex] = akku
|
|
||||||
}
|
|
||||||
override var width = 560
|
|
||||||
override var height = optionsYpos.last()
|
|
||||||
|
|
||||||
private val hrule = CommonResourcePool.getAsTextureRegionPack("gui_hrule")
|
|
||||||
|
|
||||||
private val spinnerWidth = 140
|
|
||||||
private val drawX = (Toolkit.drawWidth - width) / 2
|
|
||||||
private val drawY = (App.scr.height - height) / 2
|
|
||||||
|
|
||||||
private val optionControllers: List<Pair<UIItem, (UIItem, String) -> Unit>> = options.mapIndexed { index, strings ->
|
|
||||||
makeButton(this, options[index][2] as String,
|
|
||||||
drawX + width / 2 + panelgap,
|
|
||||||
drawY - 2 + optionsYpos[index],
|
|
||||||
options[index][0] as String
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
override var height = ControlPanelCommon.getMenuHeight("basegame.graphicscontrolpanel")
|
||||||
optionControllers.forEachIndexed { i, it ->
|
|
||||||
it.second.invoke(it.first, options[i][0] as String)
|
|
||||||
addUIitem(it.first)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
override fun updateUI(delta: Float) {
|
||||||
uiItems.forEach { it.update(delta) }
|
uiItems.forEach { it.update(delta) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
/*batch.color = Toolkit.Theme.COL_INACTIVE
|
ControlPanelCommon.render("basegame.graphicscontrolpanel", width, batch)
|
||||||
Toolkit.drawBoxBorder(batch, drawX, drawY, width, height)
|
|
||||||
|
|
||||||
batch.color = CELL_COL
|
|
||||||
Toolkit.fillArea(batch, drawX, drawY, width, height)*/
|
|
||||||
|
|
||||||
options.forEachIndexed { index, strings ->
|
|
||||||
val mode = strings[2]
|
|
||||||
|
|
||||||
val font = if (mode == "h1") App.fontUITitle else App.fontGame
|
|
||||||
|
|
||||||
val label = (strings[1] as () -> String).invoke()
|
|
||||||
val labelWidth = font.getWidth(label)
|
|
||||||
batch.color = when (mode) {
|
|
||||||
"h1" -> Toolkit.Theme.COL_MOUSE_UP
|
|
||||||
"p" -> Color.LIGHT_GRAY
|
|
||||||
else -> Color.WHITE
|
|
||||||
}
|
|
||||||
|
|
||||||
val xpos = if (mode == "p" || mode == "h1")
|
|
||||||
drawX + (width - labelWidth)/2 // centre-aligned
|
|
||||||
else
|
|
||||||
drawX + width/2 - panelgap - labelWidth // right aligned at the middle of the panel, offsetted by panelgap
|
|
||||||
|
|
||||||
font.draw(batch, label, xpos.toFloat(), drawY + optionsYpos[index] - 2f)
|
|
||||||
|
|
||||||
// draw hrule
|
|
||||||
if (mode == "h1") {
|
|
||||||
val ruleWidth = ((width - 24 - labelWidth) / 2).toFloat()
|
|
||||||
batch.draw(hrule.get(0,0), xpos - 24f - ruleWidth, drawY + optionsYpos[index].toFloat(), ruleWidth, hrule.tileH.toFloat())
|
|
||||||
batch.draw(hrule.get(0,1), xpos + 24f + labelWidth, drawY + optionsYpos[index].toFloat(), ruleWidth, hrule.tileH.toFloat())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uiItems.forEach { it.render(batch, camera) }
|
uiItems.forEach { it.render(batch, camera) }
|
||||||
|
|
||||||
if (App.getConfigBoolean("fx_streamerslayout")) {
|
if (App.getConfigBoolean("fx_streamerslayout")) {
|
||||||
@@ -152,14 +66,6 @@ class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
|
||||||
return super.touchDown(screenX, screenY, pointer, button)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
|
||||||
return super.touchUp(screenX, screenY, pointer, button)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,134 +19,29 @@ import net.torvald.unicode.TIMES
|
|||||||
*/
|
*/
|
||||||
class UIPerformanceControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
class UIPerformanceControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||||
|
|
||||||
|
|
||||||
private val linegap = 14
|
|
||||||
private val panelgap = 20
|
|
||||||
|
|
||||||
private val rowheight = 20 + linegap
|
|
||||||
|
|
||||||
private val h1MarginTop = 16
|
|
||||||
private val h1MarginBottom = 4
|
|
||||||
|
|
||||||
private val options = arrayOf(
|
|
||||||
arrayOf("", { Lang["MENU_OPTIONS_GAMEPLAY"] }, "h1"),
|
|
||||||
arrayOf("autosaveinterval", { Lang["MENU_OPTIONS_AUTOSAVE"] + " (${Lang["CONTEXT_TIME_MINUTE_PLURAL"]})" }, "spinnerimul,1,120,1,60000"),
|
|
||||||
arrayOf("notificationshowuptime", { Lang["MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION"] + " (${Lang["CONTEXT_TIME_SECOND_PLURAL"]})" }, "spinnerimul,2,10,1,1000"),
|
|
||||||
// arrayOf("testvalue", { "TestValue" }, "sliderd,1,100,1"),
|
|
||||||
arrayOf("", { Lang["MENU_LABEL_JVM_DNT"] }, "h1"),
|
|
||||||
arrayOf("jvm_xmx", { Lang["MENU_OPTIONS_JVM_HEAP_MAX"] + " (GB)" }, "spinner,2,32,1"),
|
|
||||||
arrayOf("jvm_extra_cmd", { Lang["MENU_LABEL_EXTRA_JVM_ARGUMENTS"] }, "typein"),
|
|
||||||
arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"),
|
|
||||||
)
|
|
||||||
|
|
||||||
private val optionsYpos = IntArray(options.size + 1)
|
|
||||||
|
|
||||||
init {
|
|
||||||
CommonResourcePool.addToLoadingList("gui_hrule") {
|
|
||||||
TextureRegionPack(Gdx.files.internal("assets/graphics/gui/hrule.tga"), 216, 20)
|
|
||||||
}
|
|
||||||
CommonResourcePool.loadAll()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var akku = 0
|
|
||||||
options.forEachIndexed { index, row ->
|
|
||||||
val option = row[2]
|
|
||||||
|
|
||||||
if (index > 0 && option == "h1") {
|
|
||||||
akku += h1MarginTop
|
|
||||||
}
|
|
||||||
|
|
||||||
optionsYpos[index] = akku
|
|
||||||
|
|
||||||
akku += when (option) {
|
|
||||||
"h1" -> rowheight + h1MarginBottom
|
|
||||||
else -> rowheight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
optionsYpos[optionsYpos.lastIndex] = akku
|
|
||||||
}
|
|
||||||
override var width = 560
|
override var width = 560
|
||||||
override var height = optionsYpos.last()
|
|
||||||
|
|
||||||
private val hrule = CommonResourcePool.getAsTextureRegionPack("gui_hrule")
|
|
||||||
|
|
||||||
private val spinnerWidth = 140
|
|
||||||
private val typeinWidth = 240
|
|
||||||
private val drawX = (Toolkit.drawWidth - width) / 2
|
|
||||||
private val drawY = (App.scr.height - height) / 2
|
|
||||||
|
|
||||||
private val optionControllers: List<Pair<UIItem, (UIItem, String) -> Unit>> = options.mapIndexed { index, strings ->
|
|
||||||
makeButton(this, options[index][2] as String,
|
|
||||||
drawX + width / 2 + panelgap,
|
|
||||||
drawY - 2 + optionsYpos[index],
|
|
||||||
options[index][0] as String
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
optionControllers.forEachIndexed { i, it ->
|
ControlPanelCommon.register(this, width, "basegame.performancecontrolpanel", arrayOf(
|
||||||
it.second.invoke(it.first, options[i][0] as String)
|
arrayOf("", { Lang["MENU_OPTIONS_GAMEPLAY"] }, "h1"),
|
||||||
addUIitem(it.first)
|
arrayOf("autosaveinterval", { Lang["MENU_OPTIONS_AUTOSAVE"] + " (${Lang["CONTEXT_TIME_MINUTE_PLURAL"]})" }, "spinnerimul,1,120,1,60000"),
|
||||||
}
|
arrayOf("notificationshowuptime", { Lang["MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION"] + " (${Lang["CONTEXT_TIME_SECOND_PLURAL"]})" }, "spinnerimul,2,10,1,1000"),
|
||||||
|
arrayOf("", { Lang["MENU_LABEL_JVM_DNT"] }, "h1"),
|
||||||
|
arrayOf("jvm_xmx", { Lang["MENU_OPTIONS_JVM_HEAP_MAX"] + " (GB)" }, "spinner,2,32,1"),
|
||||||
|
arrayOf("jvm_extra_cmd", { Lang["MENU_LABEL_EXTRA_JVM_ARGUMENTS"] }, "typein"),
|
||||||
|
arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var height = ControlPanelCommon.getMenuHeight("basegame.performancecontrolpanel")
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
override fun updateUI(delta: Float) {
|
||||||
uiItems.forEach { it.update(delta) }
|
uiItems.forEach { it.update(delta) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
/*batch.color = Toolkit.Theme.COL_INACTIVE
|
ControlPanelCommon.render("basegame.performancecontrolpanel", width, batch)
|
||||||
Toolkit.drawBoxBorder(batch, drawX, drawY, width, height)
|
|
||||||
|
|
||||||
batch.color = CELL_COL
|
|
||||||
Toolkit.fillArea(batch, drawX, drawY, width, height)*/
|
|
||||||
|
|
||||||
options.forEachIndexed { index, strings ->
|
|
||||||
val mode = strings[2]
|
|
||||||
|
|
||||||
val font = if (mode == "h1") App.fontUITitle else App.fontGame
|
|
||||||
|
|
||||||
val label = (strings[1] as () -> String).invoke()
|
|
||||||
val labelWidth = font.getWidth(label)
|
|
||||||
batch.color = when (mode) {
|
|
||||||
"h1" -> Toolkit.Theme.COL_MOUSE_UP
|
|
||||||
"p" -> Color.LIGHT_GRAY
|
|
||||||
else -> Color.WHITE
|
|
||||||
}
|
|
||||||
|
|
||||||
val xpos = if (mode == "p" || mode == "h1")
|
|
||||||
drawX + (width - labelWidth)/2 // centre-aligned
|
|
||||||
else
|
|
||||||
drawX + width/2 - panelgap - labelWidth // right aligned at the middle of the panel, offsetted by panelgap
|
|
||||||
|
|
||||||
font.draw(batch, label, xpos.toFloat(), drawY + optionsYpos[index] - 2f)
|
|
||||||
|
|
||||||
// draw hrule
|
|
||||||
if (mode == "h1") {
|
|
||||||
val ruleWidth = ((width - 24 - labelWidth) / 2).toFloat()
|
|
||||||
batch.draw(hrule.get(0,0), xpos - 24f - ruleWidth, drawY + optionsYpos[index].toFloat(), ruleWidth, hrule.tileH.toFloat())
|
|
||||||
batch.draw(hrule.get(0,1), xpos + 24f + labelWidth, drawY + optionsYpos[index].toFloat(), ruleWidth, hrule.tileH.toFloat())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uiItems.forEach { it.render(batch, camera) }
|
uiItems.forEach { it.render(batch, camera) }
|
||||||
|
|
||||||
if (App.getConfigBoolean("fx_streamerslayout")) {
|
|
||||||
val xstart = App.scr.width - App.scr.chatWidth
|
|
||||||
|
|
||||||
batch.color = Color(0x00f8ff_40)
|
|
||||||
Toolkit.fillArea(batch, xstart + 1, 1, App.scr.chatWidth - 2, App.scr.height - 2)
|
|
||||||
|
|
||||||
batch.color = Toolkit.Theme.COL_MOUSE_UP
|
|
||||||
Toolkit.drawBoxBorder(batch, xstart + 1, 1, App.scr.chatWidth - 2, App.scr.height - 2)
|
|
||||||
|
|
||||||
val overlayResTxt = "${(App.scr.chatWidth * App.scr.magn).ceilToInt()}$TIMES${App.scr.windowH}"
|
|
||||||
|
|
||||||
App.fontGame.draw(batch, overlayResTxt,
|
|
||||||
(xstart + (App.scr.chatWidth - App.fontGame.getWidth(overlayResTxt)) / 2).toFloat(),
|
|
||||||
((App.scr.height - App.fontGame.lineHeight) / 2).toFloat()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2023-07-15.
|
||||||
|
*/
|
||||||
|
class UISoundControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||||
|
|
||||||
|
override var width = 560
|
||||||
|
|
||||||
|
init {
|
||||||
|
ControlPanelCommon.register(this, width, "basegame.soundcontrolpanel", arrayOf(
|
||||||
|
arrayOf("mastervolume", { Lang["MENU_OPTIONS_SOUND_VOLUME"] }, "sliderd,0,1"),
|
||||||
|
arrayOf("", { "" }, "p"),
|
||||||
|
arrayOf("bgmvolume", { Lang["MENU_LABEL_BACKGROUND_MUSIC"] }, "sliderd,0,1"),
|
||||||
|
arrayOf("", { "" }, "p"),
|
||||||
|
arrayOf("musicvolume", { Lang["MENU_LABEL_MUSIC"] }, "sliderd,0,1"),
|
||||||
|
arrayOf("", { "" }, "p"),
|
||||||
|
arrayOf("sfxvolume", { Lang["CREDITS_SFX"] }, "sliderd,0,1"),
|
||||||
|
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
override var height = ControlPanelCommon.getMenuHeight("basegame.soundcontrolpanel")
|
||||||
|
|
||||||
|
override fun updateUI(delta: Float) {
|
||||||
|
uiItems.forEach { it.update(delta) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
|
ControlPanelCommon.render("basegame.soundcontrolpanel", width, batch)
|
||||||
|
uiItems.forEach { it.render(batch, camera) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ object UITitleRemoConYaml {
|
|||||||
- MENU_LABEL_GRAPHICS : net.torvald.terrarum.modulebasegame.ui.UIGraphicsControlPanel
|
- 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_LABEL_IME : net.torvald.terrarum.modulebasegame.ui.UIIMEConfig
|
- MENU_LABEL_IME : net.torvald.terrarum.modulebasegame.ui.UIIMEConfig
|
||||||
|
- MENU_LABEL_SOUND : net.torvald.terrarum.modulebasegame.ui.UISoundControlPanel
|
||||||
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
|
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
|
||||||
- GAME_GENRE_MISC : net.torvald.terrarum.modulebasegame.ui.UIPerformanceControlPanel
|
- GAME_GENRE_MISC : net.torvald.terrarum.modulebasegame.ui.UIPerformanceControlPanel
|
||||||
- MENU_MODULES : net.torvald.terrarum.ModOptionsHost
|
- MENU_MODULES : net.torvald.terrarum.ModOptionsHost
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class UIItemHorzSlider(
|
|||||||
private var mouseOnHandle = false
|
private var mouseOnHandle = false
|
||||||
|
|
||||||
private val handleTravelDist = width - handleWidth
|
private val handleTravelDist = width - handleWidth
|
||||||
private var handlePos = 0.0
|
private var handlePos = (initialValue / max).times(handleTravelDist).coerceIn(0.0, handleTravelDist.toDouble())
|
||||||
|
|
||||||
var value: Double = initialValue; private set
|
var value: Double = initialValue; private set
|
||||||
var selectionChangeListener: (Double) -> Unit = {}
|
var selectionChangeListener: (Double) -> Unit = {}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
// println(parallax) // parallax value works as intended.
|
// println(parallax) // parallax value works as intended.
|
||||||
|
|
||||||
gdxBlendNormalStraightAlpha()
|
gdxBlendNormalStraightAlpha()
|
||||||
|
|
||||||
val degThis = solarElev.floorToDouble()
|
val degThis = solarElev.floorToDouble()
|
||||||
val degNext = degThis + if (timeNow < HALF_DAY) 1 else -1 // Skybox.get has internal coerceIn
|
val degNext = degThis + if (timeNow < HALF_DAY) 1 else -1 // Skybox.get has internal coerceIn
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user