mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-14 07:36:06 +09:00
option and warning msg for loading script mods
This commit is contained in:
@@ -5,7 +5,7 @@ package net.torvald.terrarum
|
||||
*/
|
||||
object AudioManager {
|
||||
|
||||
/** Returns a companded master volume */
|
||||
/** Returns a master volume */
|
||||
val masterVolume: Float
|
||||
get() = App.getConfigDouble("mastervolume").toFloat()
|
||||
|
||||
|
||||
@@ -130,6 +130,8 @@ object DefaultConfig {
|
||||
|
||||
"lightpasses" to 3,
|
||||
|
||||
"enablescriptmods" to false,
|
||||
|
||||
|
||||
|
||||
// settings regarding debugger
|
||||
|
||||
@@ -140,6 +140,10 @@ object ModMgr {
|
||||
|
||||
|
||||
loadOrder.forEachIndexed { index, it ->
|
||||
|
||||
val loadScriptMod = if (App.getConfigBoolean("enablescriptmods")) true else (index == 0)
|
||||
|
||||
|
||||
val moduleName = it[0]
|
||||
this.loadOrder.add(moduleName)
|
||||
printmsg(this, "Loading module $moduleName")
|
||||
@@ -250,6 +254,11 @@ object ModMgr {
|
||||
|
||||
// run entry script in entry point
|
||||
if (entryPoint.isNotBlank()) {
|
||||
if (!loadScriptMod) {
|
||||
throw ScriptModDisallowedException()
|
||||
}
|
||||
|
||||
|
||||
var newClass: Class<*>? = null
|
||||
try {
|
||||
// for modules that has JAR defined
|
||||
@@ -329,6 +338,14 @@ object ModMgr {
|
||||
moduleInfo.remove(moduleName)
|
||||
if (module != null) moduleInfoErrored[moduleName] = module
|
||||
}
|
||||
catch (noScriptModule: ScriptModDisallowedException) {
|
||||
printmsgerr(this, noScriptModule.message)
|
||||
|
||||
logError(LoadErrorType.MY_FAULT, moduleName, noScriptModule)
|
||||
|
||||
moduleInfo.remove(moduleName)
|
||||
if (module != null) moduleInfoErrored[moduleName] = module
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
// TODO: Instead of skipping module with error, just display the error message onto the face?
|
||||
|
||||
@@ -352,6 +369,8 @@ object ModMgr {
|
||||
private class ModuleDependencyNotSatisfied(want: String, have: String) :
|
||||
RuntimeException("Required: $want, Installed: $have")
|
||||
|
||||
private class ScriptModDisallowedException : RuntimeException("Script Mods disabled")
|
||||
|
||||
operator fun invoke() { }
|
||||
|
||||
/*fun reloadModules() {
|
||||
|
||||
@@ -22,7 +22,7 @@ class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() {
|
||||
private val moduleAreaHMargin = 48
|
||||
private val moduleAreaBorder = 8
|
||||
|
||||
override var width = App.scr.width - UIRemoCon.remoConWidth - moduleAreaHMargin
|
||||
override var width = 560
|
||||
override var height = App.scr.height - moduleAreaHMargin * 2
|
||||
|
||||
private val drawX = (Toolkit.drawWidth - width) / 2
|
||||
@@ -78,7 +78,10 @@ class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() {
|
||||
else {
|
||||
{ options[1] }
|
||||
}
|
||||
arrayOf("$modname:${options[0]}", labelfun, options[2])
|
||||
if (options[0].isBlank())
|
||||
arrayOf("", labelfun, options[2])
|
||||
else
|
||||
arrayOf("$modname:${options[0]}", labelfun, options[2])
|
||||
}.toTypedArray()
|
||||
|
||||
ControlPanelCommon.register(this, width, "basegame.modcontrolpanel.$modname", modOptions)
|
||||
|
||||
@@ -33,14 +33,14 @@ internal object Authenticator : ConsoleCommand {
|
||||
val pwd = args[1]
|
||||
val hashedPwd = DigestUtils.sha256Hex(pwd)
|
||||
|
||||
println("auth passwd: '$pwd'")
|
||||
println("hash: $hashedPwd")
|
||||
// println("auth passwd: '$pwd'")
|
||||
// println("hash: $hashedPwd")
|
||||
|
||||
if ("2d962f949f55906ac47f16095ded190c9e44d95920259b8f36c2e54bd75df173".equals(hashedPwd, ignoreCase = true)) {
|
||||
if ("c40232ae7b8020da3ab1449a015e7cc23f249a790856b63b1b69c6a5de019fed".equals(hashedPwd, ignoreCase = true)) {
|
||||
// beedle
|
||||
val msg = if (a) "Locked" else "Authenticated"
|
||||
Echo(msg)
|
||||
println("[Authenticator] " + msg)
|
||||
println("[Authenticator] $msg")
|
||||
a = !a
|
||||
INGAME.consoleHandler.reset()
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ object ControlPanelCommon {
|
||||
val optionName = optionNames.first()
|
||||
val arg = args.split(',')
|
||||
|
||||
return if (args.equals("h1") || args.equals("p")) {
|
||||
return if (args == "h1" || args == "p" || args == "emph") {
|
||||
(object : UIItem(parent, x, y) {
|
||||
override val width = 1
|
||||
override val height = 1
|
||||
@@ -201,10 +201,13 @@ object ControlPanelCommon {
|
||||
else throw IllegalArgumentException(args)
|
||||
}
|
||||
|
||||
private fun String.countLines() = this.count { it == '\n' } + 1
|
||||
|
||||
private val linegap = 14
|
||||
private val panelgap = 20
|
||||
|
||||
private val rowheight = 20 + linegap
|
||||
private val textLineHeight = App.fontGame.lineHeight.toInt()
|
||||
private val rowheightDiff = textLineHeight - panelgap
|
||||
|
||||
private val h1MarginTop = 16
|
||||
private val h1MarginBottom = 4
|
||||
@@ -225,9 +228,11 @@ object ControlPanelCommon {
|
||||
|
||||
optionsYpos[index] = akku
|
||||
|
||||
val realRowHeight = (row[1] as () -> String).invoke().countLines() * textLineHeight - rowheightDiff
|
||||
|
||||
akku += when (option) {
|
||||
"h1" -> rowheight + h1MarginBottom
|
||||
else -> rowheight
|
||||
"h1" -> realRowHeight + linegap + h1MarginBottom
|
||||
else -> realRowHeight + linegap
|
||||
}
|
||||
}
|
||||
optionsYpos[optionsYpos.lastIndex] = akku
|
||||
@@ -264,20 +269,23 @@ object ControlPanelCommon {
|
||||
|
||||
val font = if (mode == "h1") App.fontUITitle else App.fontGame
|
||||
|
||||
val label = (args[1] as () -> String).invoke()
|
||||
val labelWidth = font.getWidth(label)
|
||||
val label = (args[1] as () -> String).invoke().lines()
|
||||
val labelWidth = label.maxOf { font.getWidth(it) }
|
||||
batch.color = when (mode) {
|
||||
"h1" -> Toolkit.Theme.COL_MOUSE_UP
|
||||
"p" -> Color.LIGHT_GRAY
|
||||
"emph" -> Toolkit.Theme.COL_RED
|
||||
else -> Color.WHITE
|
||||
}
|
||||
|
||||
val xpos = if (mode == "p" || mode == "h1")
|
||||
val xpos = if (mode == "p" || mode == "h1" || mode == "emph")
|
||||
drawX + (width - labelWidth)/2 // centre-aligned
|
||||
else
|
||||
drawX + width/2 - panelgap - labelWidth // right aligned at the middle of the panel, offsetted by panelgap
|
||||
drawX + width/2 - panelgap - labelWidth // right aligned at the middle of the panel, offset by panelgap
|
||||
|
||||
font.draw(batch, label, xpos.toFloat(), drawY + optionsYpos[index] - 2f)
|
||||
label.forEachIndexed { rows, s ->
|
||||
font.draw(batch, s, xpos.toFloat(), drawY + optionsYpos[index] - 2f + textLineHeight * rows)
|
||||
}
|
||||
|
||||
// draw hrule
|
||||
if (mode == "h1") {
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
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.CommonResourcePool
|
||||
import net.torvald.terrarum.ceilToInt
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.ui.ControlPanelCommon.makeButton
|
||||
import net.torvald.terrarum.ui.*
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import net.torvald.unicode.TIMES
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2023-06-22.
|
||||
@@ -32,6 +22,10 @@ class UIPerformanceControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||
arrayOf("", { Lang["MENU_LABEL_GRAPHICS"] }, "h1"),
|
||||
arrayOf("atlastexsize", { Lang["MENU_OPTIONS_ATLAS_TEXTURE_SIZE"] }, "spinnersel,1024,2048,4096,8192"),
|
||||
arrayOf("lightpasses", { Lang["MENU_OPTIONS_LIGHT_UPDATE_PASSES"] }, "spinner,2,4,1"),
|
||||
arrayOf("", { Lang["MENU_MODULES"] }, "h1"),
|
||||
arrayOf("enablescriptmods", { Lang["MENU_OPTIONS_ENABLE_SCRIPT_MODS"] }, "toggle"),
|
||||
arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"),
|
||||
arrayOf("", { "${Lang["MENU_LABEL_WARN_ACE"]}" }, "emph"),
|
||||
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"),
|
||||
|
||||
Reference in New Issue
Block a user