mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
option and warning msg for loading script mods
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
"MENU_OPTIONS_BLUR": "Blur",
|
||||
"MENU_OPTIONS_DEBUG_CONSOLE": "Debug Console",
|
||||
"MENU_OPTIONS_DITHER": "Dithering",
|
||||
"MENU_OPTIONS_ENABLE_SCRIPT_MODS": "Enable Script Mods",
|
||||
"MENU_OPTIONS_JVM_HEAP_MAX": "Max Heap Memory",
|
||||
"MENU_OPTIONS_LIGHT_UPDATE_PASSES": "Light Calculation Depth",
|
||||
"MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION": "Show notification for",
|
||||
|
||||
@@ -21,4 +21,5 @@
|
||||
"MENU_LABEL_KEYCONFIG_HELP1": "Click On the Keycap to Assign Actions",
|
||||
"MENU_LABEL_SAVE_WILL_BE_DELETED": "The selected save file will be deleted.",
|
||||
"MENU_LABEL_UNSAVED_PROGRESS_WILL_BE_LOST": "Unsaved progress will be lost.",
|
||||
"MENU_LABEL_WARN_ACE": "Script mods may damage your game or result in other unexpected behaviour.\nOnly use the mods you know they can be trusted."
|
||||
}
|
||||
@@ -32,6 +32,7 @@
|
||||
"MENU_OPTIONS_BLUR": "흐림",
|
||||
"MENU_OPTIONS_DEBUG_CONSOLE": "디버그 콘솔",
|
||||
"MENU_OPTIONS_DITHER": "디더링",
|
||||
"MENU_OPTIONS_ENABLE_SCRIPT_MODS": "스크립트 모드 활성화",
|
||||
"MENU_OPTIONS_JVM_HEAP_MAX": "최대 힙 메모리",
|
||||
"MENU_OPTIONS_LIGHT_UPDATE_PASSES": "빛 계산 반복 횟수",
|
||||
"MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION": "알림 표시 시간",
|
||||
|
||||
@@ -8,11 +8,18 @@
|
||||
"GAME_APPLE_ROSETTA_WARNING2": "최적의 성능과 게임 경험을 위해 Apple Silicon용 빌드의 게임을 이용해 주십시오.",
|
||||
"APP_NOMODULE_1": "현재 불러와진 모듈이 없습니다.",
|
||||
"APP_NOMODULE_2": "다음의 파일에서 불러오기 순서를 설정하고 게임을 재시작하십시오.",
|
||||
"MENU_LABEL_KEYCONFIG_HELP1": "키캡을 클릭해 컨트롤을 배정하십시오",
|
||||
"GAME_PREV_SAVE_WAS_LOADED1": "가장 최근에 저장된 게임이 손상되었습니다.",
|
||||
"GAME_PREV_SAVE_WAS_LOADED2": "이전에 저장된 게임을 불러왔습니다.",
|
||||
"GAME_MORE_RECENT_AUTOSAVE1": "자동 저장된 게임이 수동으로 저장한 게임보다 더 최신입니다.",
|
||||
"GAME_MORE_RECENT_AUTOSAVE2": "불러올 게임을 선택해 주십시오.",
|
||||
"MENU_IO_LOAD_UPDATING_BLOCK_MAPPINGS": "Updating Block Mappings...",
|
||||
"MENU_IO_WORLDGEN_CARVING_EARTH": "Carving Earth...",
|
||||
"MENU_IO_WORLDGEN_PAINTING_GREEN": "Painting Green...",
|
||||
"MENU_IO_WORLDGEN_GROWING_MINERALS": "Growing Minerals...",
|
||||
"MENU_IO_WORLDGEN_POSITIONING_ROCKS": "Positioning Rocks...",
|
||||
"MENU_IO_WORLDGEN_RETICULATING_SPLINES": "Reticulating Splines...",
|
||||
"MENU_LABEL_KEYCONFIG_HELP1": "키캡을 클릭해 컨트롤을 배정하십시오",
|
||||
"MENU_LABEL_SAVE_WILL_BE_DELETED": "선택된 세이브가 삭제됩니다.",
|
||||
"MENU_LABEL_UNSAVED_PROGRESS_WILL_BE_LOST": "저장하지 않은 진행 상황을 잃게 됩니다."
|
||||
"MENU_LABEL_UNSAVED_PROGRESS_WILL_BE_LOST": "저장하지 않은 진행 상황을 잃게 됩니다.",
|
||||
"MENU_LABEL_WARN_ACE": "스크립트 모드는 게임을 손상시키거나 다른 예상치 못한 결과를 가져올 수 있습니다.\n신뢰할 수 있는 모드만을 사용하십시오."
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
->Lang:MENU_OPTIONS_GAMEPLAY->h1
|
||||
gameplay_max_crafting->Lang:MENU_OPTIONS_MAX_CRAFTING->spinner,100,1000,100
|
||||
showpickaxetooltip->Lang:MENU_OPTIONS_SHOW_ORES_TOOLTIP_WHEN_MINING->toggle
|
||||
|
@@ -47,7 +47,7 @@ entrypoint=net.torvald.terrarum.modulebasegame.EntryPoint
|
||||
releasedate=2023-10-06
|
||||
|
||||
# The version, must follow Semver 2.0.0 scheme (https://semver.org/)
|
||||
version=0.3.3
|
||||
version=0.4.0
|
||||
|
||||
# External JAR that the module is compiled. If your module requires yet another library, the JAR must be compiled as a "Fatjar";
|
||||
# Due to security reasons, loading an arbitrary JAR is not allowed.
|
||||
|
||||
@@ -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