From f8f75fb7b61effd8a1e210b2f91d945c0498e966 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 14 Aug 2023 03:53:25 +0900 Subject: [PATCH] options to change atlas texture size --- assets/locales/en/terrarum.json | 1 + assets/locales/koKR/terrarum.json | 1 + assets/mods/basegame/locales/en/calendar.json | 5 +- .../mods/basegame/locales/koKR/calendar.json | 4 +- .../terrarum/gameactors/ActorWithBody.kt | 62 +++++++++++-------- src/net/torvald/terrarum/gameactors/Hitbox.kt | 3 + .../torvald/terrarum/gameworld/WorldTime.kt | 23 +++---- src/net/torvald/terrarum/langpack/Lang.kt | 9 +++ .../gameactors/FixtureWallCalendar.kt | 7 ++- .../serialise/QuickSaveThread.kt | 2 +- .../modulebasegame/ui/ControlPanelCommon.kt | 21 +++++-- .../ui/UIGraphicsControlPanel.kt | 20 +++--- .../ui/UIPerformanceControlPanel.kt | 5 +- src/net/torvald/terrarum/ui/UIItemSpinner.kt | 18 +++--- .../torvald/terrarum/ui/UIItemTextSelector.kt | 22 ++++--- .../fixtures/electronics_workbench.kra | 3 + 16 files changed, 133 insertions(+), 73 deletions(-) create mode 100644 work_files/graphics/sprites/fixtures/electronics_workbench.kra diff --git a/assets/locales/en/terrarum.json b/assets/locales/en/terrarum.json index 5d9b16a83..edb97085c 100644 --- a/assets/locales/en/terrarum.json +++ b/assets/locales/en/terrarum.json @@ -23,6 +23,7 @@ "MENU_LABEL_STREAMING": "Livestreaming", "MENU_LABEL_SYSTEM_INFO": "System Info", "MENU_MODULES" : "Modules", + "MENU_OPTIONS_ATLAS_TEXTURE_SIZE": "Atlas Texture Size", "MENU_OPTIONS_AUTOSAVE": "Autosave", "MENU_OPTIONS_BLUR": "Blur", "MENU_OPTIONS_DEBUG_CONSOLE": "Debug Console", diff --git a/assets/locales/koKR/terrarum.json b/assets/locales/koKR/terrarum.json index bd294af1b..095e13e74 100644 --- a/assets/locales/koKR/terrarum.json +++ b/assets/locales/koKR/terrarum.json @@ -23,6 +23,7 @@ "MENU_LABEL_STREAMING": "실시간 방송", "MENU_LABEL_SYSTEM_INFO": "시스템 정보", "MENU_MODULES" : "모듈", + "MENU_OPTIONS_ATLAS_TEXTURE_SIZE": "아틀라스 텍스처 크기", "MENU_OPTIONS_AUTOSAVE": "자동 저장", "MENU_OPTIONS_BLUR": "흐림", "MENU_OPTIONS_DEBUG_CONSOLE": "디버그 콘솔", diff --git a/assets/mods/basegame/locales/en/calendar.json b/assets/mods/basegame/locales/en/calendar.json index eaf0f4ef8..69a0fb6b8 100644 --- a/assets/mods/basegame/locales/en/calendar.json +++ b/assets/mods/basegame/locales/en/calendar.json @@ -10,6 +10,8 @@ "CONTEXT_CALENDAR_SEASON_SUMM": "Summ", "CONTEXT_CALENDAR_SEASON_AUTM": "Autm", "CONTEXT_CALENDAR_SEASON_WINT": "Wint", + "CONTEXT_CALENDAR_DATE_FORMAT_YMD": "Year {0} {1} {2}", + "CONTEXT_CALENDAR_DATE_FORMAT_YMD_DDD": "Year {0} {1} {2} {3}", "CONTEXT_CALENDAR_DAY_MONDAG_DNT": "Mondag", "CONTEXT_CALENDAR_DAY_TYSDAG_DNT": "Tysdag", @@ -26,5 +28,6 @@ "CONTEXT_CALENDAR_DAY_FRE_DNT": "Fre", "CONTEXT_CALENDAR_DAY_LAU_DNT": "Lau", "CONTEXT_CALENDAR_DAY_SUN_DNT": "Sun", - "CONTEXT_CALENDAR_DAY_VER_DNT": "Ver" + "CONTEXT_CALENDAR_DAY_VER_DNT": "Ver", + "CONTEXT_CALENDAR_DATE_FORMAT_YMD_SHORT_DNT": "ɣ{0}-{1}-{2}" } \ No newline at end of file diff --git a/assets/mods/basegame/locales/koKR/calendar.json b/assets/mods/basegame/locales/koKR/calendar.json index d6fc30f0a..d32a4bac3 100644 --- a/assets/mods/basegame/locales/koKR/calendar.json +++ b/assets/mods/basegame/locales/koKR/calendar.json @@ -9,5 +9,7 @@ "CONTEXT_CALENDAR_SEASON_SPRI": "봄", "CONTEXT_CALENDAR_SEASON_SUMM": "여름", "CONTEXT_CALENDAR_SEASON_AUTM": "가을", - "CONTEXT_CALENDAR_SEASON_WINT": "겨울" + "CONTEXT_CALENDAR_SEASON_WINT": "겨울", + "CONTEXT_CALENDAR_DATE_FORMAT_YMD": "{0}년 {1} {2}일", + "CONTEXT_CALENDAR_DATE_FORMAT_YMD_DDD": "{0}년 {1} {2}일 {3}" } \ No newline at end of file diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index 13c50aaeb..c07c68e76 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -18,6 +18,7 @@ import net.torvald.terrarum.gameitems.ItemID import net.torvald.terrarum.gameworld.BlockAddress import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid +import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer import net.torvald.terrarum.realestate.LandUtil import net.torvald.terrarum.worlddrawer.WorldCamera import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack @@ -698,7 +699,7 @@ open class ActorWithBody : Actor { } private fun displaceHitbox() { - val printdbg1 = false && App.IS_DEVELOPMENT_BUILD + val printdbg1 = true && App.IS_DEVELOPMENT_BUILD // // HOW IT SHOULD WORK // // // //////////////////////// // combineVeloToMoveDelta now @@ -772,14 +773,14 @@ open class ActorWithBody : Actor { fun debug2(wut: Any?) { // vvvvv set it true to make debug print work - if (false && printdbg1 && vectorSum.magnitudeSquared != 0.0) printdbg(this, wut) + if (true && printdbg1 && vectorSum.magnitudeSquared != 0.0) printdbg(this, wut) } if (printdbg1 && vectorSum.magnitudeSquared != 0.0) println("") debug1("Update Frame: ${INGAME.WORLD_UPDATE_TIMER}") debug1("Hitbox: ${hitbox}") - debug1("vec dir: ${Math.toDegrees(vectorSum.direction)}°, value: $vectorSum, magnitude: ${vectorSum.magnitude}") + debug1("vec dir: ${if (vectorSum.isZero) "." else Math.toDegrees(vectorSum.direction)} deg, value: $vectorSum, magnitude: ${vectorSum.magnitude}") // * NEW idea: wall pushes the actors (ref. SM64 explained by dutch pancake) * @@ -802,11 +803,13 @@ open class ActorWithBody : Actor { for (step in 0..ccdSteps) { val stepBox = sixteenStep[step] - val goingDown = (vectorSum.y > PHYS_EPSILON_DIST) || (vectorSum.y >= 0.0 && !isWalled(stepBox, COLLIDING_BOTTOM)) // TODO reverse gravity adaptation? - debug2("stepbox[$step]=$stepBox; goingDown=$goingDown, downDown=$downDown") + val goingDownwardDirection = true//Math.toDegrees(vectorSum.direction).let { it > 0.0 && it < 180.0 } // commenting out: weird better bounce off than making players stuck :/ + val goingDown = (vectorSum.y >= PHYS_EPSILON_VELO || (vectorSum.y.absoluteValue < PHYS_EPSILON_VELO && !isWalled(stepBox, COLLIDING_BOTTOM))) // TODO reverse gravity adaptation? - if (collidingStep == null && isColliding(stepBox, goingDown && !downDown)) { + debug2("stepbox[$step]=$stepBox; goingDown=$goingDown, downDown=$downDown, goingDownwardDirection=$goingDownwardDirection") + + if (collidingStep == null && isColliding(stepBox, goingDown && !downDown && goingDownwardDirection)) { collidingStep = step } @@ -823,20 +826,17 @@ open class ActorWithBody : Actor { var stairHeightLeft = 0.0 var stairHeightRight = 0.0 val selfCollisionStatus = if (newHitbox == null) 0 else { - val goingDown = (vectorSum.y > PHYS_EPSILON_DIST) || (vectorSum.y >= 0.0 && !isWalled(newHitbox, COLLIDING_BOTTOM)) // TODO reverse gravity adaptation? - intArrayOf(1, 2, 4, 8).fold(0) { acc, state -> + val (isWalled, stairHeight) = isWalledStairs(newHitbox, state) // also update staircaseStatus while we're iterating if (state and COLLIDING_LR != 0) { - isWalledStairs(newHitbox, state).let { - staircaseStatus = staircaseStatus or (state * (it.first == 1).toInt()) - if (state == COLLIDING_LEFT) - stairHeightLeft = it.second.toDouble() - else - stairHeightRight = it.second.toDouble() - } + staircaseStatus = staircaseStatus or (state * (isWalled == 1).toInt()) + if (state == COLLIDING_LEFT) + stairHeightLeft = stairHeight.toDouble() + else + stairHeightRight = stairHeight.toDouble() } - acc or (state * isWalledStairs(newHitbox, state).first.coerceAtMost(1)) // TODO reverse gravity adaptation? + acc or (state * isWalled.coerceAtMost(1)) // TODO reverse gravity adaptation? } } @@ -875,19 +875,28 @@ open class ActorWithBody : Actor { } /* 15 */ COLLIDING_ALLSIDE -> { newHitbox.reassign(sixteenStep[0]); zeroX = true; zeroY = true + debug1("reassining hitbox to ${sixteenStep[0]}") } // one-side collision /* 1, 11 */ COLLIDING_LEFT, COLLIDING_LEFT or COLLIDING_UD -> { - newHitbox.translatePosX(TILE_SIZE - newHitbox.startX.modTileDelta()); bounceX = true + val t = TILE_SIZE - newHitbox.startX.modTileDelta() + newHitbox.translatePosX(t); bounceX = true + debug1("translate x by $t") } /* 4, 14 */ COLLIDING_RIGHT, COLLIDING_RIGHT or COLLIDING_UD -> { - newHitbox.translatePosX(-newHitbox.endX.modTileDelta()); bounceX = true + val t = -newHitbox.endX.modTileDelta() + newHitbox.translatePosX(t); bounceX = true + debug1("translate x by $t") } /* 8, 13 */ COLLIDING_TOP, COLLIDING_TOP or COLLIDING_LR -> { - newHitbox.translatePosY(TILE_SIZE - newHitbox.startY.modTileDelta()); bounceY = true + val t = TILE_SIZE - newHitbox.startY.modTileDelta() + newHitbox.translatePosY(t); bounceY = true + debug1("translate y by $t") } /* 2, 7 */ COLLIDING_BOTTOM, COLLIDING_BOTTOM or COLLIDING_LR -> { - newHitbox.translatePosY(-newHitbox.endY.modTileDelta()); bounceY = true + val t = -newHitbox.endY.modTileDelta() + newHitbox.translatePosY(t); bounceY = true + debug1("translate y by $t") } } @@ -1316,16 +1325,18 @@ open class ActorWithBody : Actor { // if (ys.last != ys.first && feet) throw InternalError("Feet mode collision but pyStart != pyEnd ($pyStart .. $pyEnd)") - val feetY = (pyEnd / TILE_SIZE) - (if (pyEnd < 0) 1 else 0) // round down toward negative infinity // TODO reverse gravity adaptation? + val feetY = (pyEnd / TILE_SIZED).floorToInt() // round down toward negative infinity // TODO reverse gravity adaptation? + +// if (feet && this is IngamePlayer) printdbg(this, "feetY=$feetY") for (y in ys) { - val ty = (y / TILE_SIZE) - (if (y < 0) 1 else 0) // round down toward negative infinity + val ty = (y / TILE_SIZED).floorToInt() // round down toward negative infinity val isFeetTileHeight = (ty == feetY) var hasFloor = false for (x in pxStart..pxEnd) { - val tx = (x / TILE_SIZE) - (if (x < 0) 1 else 0) // round down toward negative infinity + val tx = (x / TILE_SIZED).floorToInt() // round down toward negative infinity val tile = world!!.getTileFromTerrain(tx, ty) if (feet && isFeetTileHeight) { @@ -1741,7 +1752,7 @@ open class ActorWithBody : Actor { val blockMark = CommonResourcePool.getAsTextureRegionPack("blockmarkings_common").get(0, 0) for (y in 0..intTilewiseHitbox.height.toInt() + 1) { - batch.color = if (y == intTilewiseHitbox.height.toInt() + 1) Color.LIME else HITBOX_COLOURS0 + batch.color = if (y == intTilewiseHitbox.height.toInt() + 1) HITBOX_COLOURS1 else HITBOX_COLOURS0 for (x in 0..intTilewiseHitbox.width.toInt()) { batch.draw(blockMark, (intTilewiseHitbox.startX.toFloat() + x) * TILE_SIZEF, @@ -1964,7 +1975,7 @@ open class ActorWithBody : Actor { @Transient const val GAME_TO_SI_ACC = (Terrarum.PHYS_TIME_FRAME * Terrarum.PHYS_TIME_FRAME) / METER @Transient const val PHYS_EPSILON_DIST = 1.0 / 65536.0 -// @Transient const val PHYS_EPSILON_VELO = 1.0 / 8192.0 + @Transient const val PHYS_EPSILON_VELO = 1.0 / 8192.0 /** @@ -2005,6 +2016,7 @@ open class ActorWithBody : Actor { @Transient private val HITBOX_COLOURS0 = Color(0xFF00FF88.toInt()) @Transient private val HITBOX_COLOURS1 = Color(0xFFFF0088.toInt()) + fun isCloseEnough(a: Double, b: Double) = ((a / b).let { if (it.isNaN()) 0.0 else it } - 1).absoluteValue < PHYS_EPSILON_DIST } diff --git a/src/net/torvald/terrarum/gameactors/Hitbox.kt b/src/net/torvald/terrarum/gameactors/Hitbox.kt index 66e42fe6c..9a9583bef 100644 --- a/src/net/torvald/terrarum/gameactors/Hitbox.kt +++ b/src/net/torvald/terrarum/gameactors/Hitbox.kt @@ -145,6 +145,9 @@ class Hitbox { return this } + /** + * Resize the hitbox centred around the "canonical" point. + */ fun canonicalResize(w: Double, h: Double): Hitbox { // sx_1 + 0.5w_1 = sx_2 + 0.5w_2 // equals because the final point must not move. sx_1: old start-x, sx_2: new start-x which is what we want // sx_2 = sx_1 + 0.5w_1 - 0.5w_2 // move variables to right-hand side to derive final value sx_2 diff --git a/src/net/torvald/terrarum/gameworld/WorldTime.kt b/src/net/torvald/terrarum/gameworld/WorldTime.kt index fb5e11a14..f7411ef2b 100644 --- a/src/net/torvald/terrarum/gameworld/WorldTime.kt +++ b/src/net/torvald/terrarum/gameworld/WorldTime.kt @@ -1,8 +1,7 @@ package net.torvald.terrarum.gameworld -import net.torvald.terrarum.modulebasegame.worldgenerator.TWO_PI +import net.torvald.terrarum.langpack.Lang import kotlin.math.cos -import kotlin.math.sin /** @@ -57,6 +56,8 @@ import kotlin.math.sin */ class WorldTime(initTime: Long = 0L) { + @Transient private val TWO_PI = Math.PI * 2.0 + /** It is not recommended to directly modify the TIME_T. Use provided methods instead. */ var TIME_T = 0L // Epoch: Year 1 Spring 1st, 0h00:00 (Mondag) // 0001-01-01 @@ -152,10 +153,10 @@ class WorldTime(initTime: Long = 0L) { // NOTE: ingame calendars (the fixture with GUI) should use symbols AND fullnames; the watch already uses shot daynames val DAY_NAMES = arrayOf(//daynames are taken from Nynorsk (å -> o) - "Mondag", "Tysdag", "Midtveke" //middle-week - , "Torsdag", "Fredag", "Laurdag", "Sundag", "Verddag" //From Norsk word 'verd' + "MONDAG", "TYSDAG", "MIDTVEKE" //middle-week + , "TORSDAG", "FREDAG", "LAURDAG", "SUNDAG", "VERDDAG" //From Norsk word 'verd' ) - val DAY_NAMES_SHORT = arrayOf("Mon", "Tys", "Mid", "Tor", "Fre", "Lau", "Sun", "Ver") + val DAY_NAMES_SHORT = arrayOf("MON", "TYS", "MID", "TOR", "FRE", "LAU", "SUN", "VER") // dwarven calendar of 12 monthes /*val MONTH_NAMES = arrayOf( @@ -164,8 +165,8 @@ class WorldTime(initTime: Long = 0L) { ) val MONTH_NAMES_SHORT = arrayOf("Opal", "Obsi", "Gran", "Slat", "Fels", "Hema", "Mala", "Gale", "Lime", "Sand", "Timb", "Moon")*/ - val MONTH_NAMES = arrayOf("Spring", "Summer", "Autumn", "Winter") - val MONTH_NAMES_SHORT = arrayOf("Spri", "Summ", "Autm", "Wint") + val MONTH_NAMES = arrayOf("SPRING", "SUMMER", "AUTUMN", "WINTER") + val MONTH_NAMES_SHORT = arrayOf("SPRI", "SUMM", "AUTM", "WINT") companion object { /** Each day is displayed as 24 hours, but in real-life clock it's 22 mins long */ @@ -251,10 +252,10 @@ class WorldTime(initTime: Long = 0L) { fun getShortTime() = "${years.toString().padStart(4, '0')}-${getMonthNameShort()}-${calendarDay.toString().padStart(2, '0')}" fun getFilenameTime() = "${years.toString().padStart(4, '0')}${calendarMonth.toString().padStart(2, '0')}${calendarDay.toString().padStart(2, '0')}" - fun getDayNameFull() = DAY_NAMES[dayOfWeek] - fun getDayNameShort() = DAY_NAMES_SHORT[dayOfWeek] - fun getMonthNameFull() = MONTH_NAMES[calendarMonth - 1] - fun getMonthNameShort() = MONTH_NAMES_SHORT[calendarMonth - 1] + fun getDayNameFull() = Lang["CONTEXT_CALENDAR_DAY_${DAY_NAMES[dayOfWeek]}_DNT"] + fun getDayNameShort() = Lang["CONTEXT_CALENDAR_DAY_${DAY_NAMES_SHORT[dayOfWeek]}_DNT"] + fun getMonthNameFull() = Lang["CONTEXT_CALENDAR_SEASON_${MONTH_NAMES[calendarMonth - 1]}"] + fun getMonthNameShort() = Lang["CONTEXT_CALENDAR_SEASON_${MONTH_NAMES_SHORT[calendarMonth - 1]}"] override fun toString() = getFormattedTime() } \ No newline at end of file diff --git a/src/net/torvald/terrarum/langpack/Lang.kt b/src/net/torvald/terrarum/langpack/Lang.kt index 9c03ad1db..100d551fb 100644 --- a/src/net/torvald/terrarum/langpack/Lang.kt +++ b/src/net/torvald/terrarum/langpack/Lang.kt @@ -152,6 +152,15 @@ object Lang { return sb.toString() } + fun getAndUseTemplate(key: String, capitalise: Boolean = true, vararg arguments: Any?): String { + var raw = get(key, capitalise) + arguments.forEachIndexed { index, it0 -> + val it = if (capitalise) it0.toString().capitalize() else it0.toString() + raw = raw.replace("{${index}}", it) + } + return raw + } + /** * Does NOT parse the operators */ diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureWallCalendar.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureWallCalendar.kt index 6311317f1..174439b24 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureWallCalendar.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureWallCalendar.kt @@ -29,6 +29,11 @@ class FixtureWallCalendar : FixtureBase { } override var tooltipText: String? - get() = INGAME.world.worldTime.getFormattedCalendarDay() + get() = Lang.getAndUseTemplate("CONTEXT_CALENDAR_DATE_FORMAT_YMD_DDD", false, + world!!.worldTime.years, + world!!.worldTime.getMonthNameFull(), + world!!.worldTime.calendarDay, + world!!.worldTime.getDayNameFull() + )//INGAME.world.worldTime.getFormattedCalendarDay() set(value) {} } \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/serialise/QuickSaveThread.kt b/src/net/torvald/terrarum/modulebasegame/serialise/QuickSaveThread.kt index cdb88a8c6..563850e07 100644 --- a/src/net/torvald/terrarum/modulebasegame/serialise/QuickSaveThread.kt +++ b/src/net/torvald/terrarum/modulebasegame/serialise/QuickSaveThread.kt @@ -133,7 +133,7 @@ class QuickSingleplayerWorldSavingThread( // Write Actors // actorsList.forEachIndexed { count, it -> - printdbg(this, "Writing actors... ${count+1}/${actorsList.size}") + printdbg(this, "Writing actors... ${count+1}/${actorsList.size} (${it.javaClass.canonicalName})") val actorContent = EntryFile(WriteActor.encodeToByteArray64(it)) val actor = DiskEntry(it.referenceID.toLong(), ROOT, creation_t, time_t, actorContent) diff --git a/src/net/torvald/terrarum/modulebasegame/ui/ControlPanelCommon.kt b/src/net/torvald/terrarum/modulebasegame/ui/ControlPanelCommon.kt index 1bc349e9a..df79f886d 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/ControlPanelCommon.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/ControlPanelCommon.kt @@ -56,10 +56,10 @@ object ControlPanelCommon { val initialSel = optionsList.indexOf(App.getConfigString(optionName)) - println("labelFuns = ${labelFuns.map { it.invoke() }}") - println("optionsList = $optionsList") - println("optionName = $optionName; value = ${App.getConfigString(optionName)}") - println("initialSel = $initialSel") +// println("labelFuns = ${labelFuns.map { it.invoke() }}") +// println("optionsList = $optionsList") +// println("optionName = $optionName; value = ${App.getConfigString(optionName)}") +// println("initialSel = $initialSel") if (initialSel < 0) throw IllegalArgumentException("config value '${App.getConfigString(optionName)}' for option '$optionName' is not found on the options list") @@ -69,6 +69,19 @@ object ControlPanelCommon { } } } + else if (args.startsWith("spinnersel,")) { + val labelFuns = arg.subList(1, arg.size).map { { it } } + val optionsList = arg.subList(1, arg.size).map { it.toInt() } + + val initialSel = optionsList.indexOf(App.getConfigInt(optionName)) + if (initialSel < 0) throw IllegalArgumentException("config value '${App.getConfigString(optionName)}' for option '$optionName' is not found on the options list") + + UIItemTextSelector(parent, x, y, labelFuns, initialSel, CONFIG_SPINNER_WIDTH, clickToShowPalette = false, useSpinnerButtons = true) to { it: UIItem, optionStr: String -> + (it as UIItemTextSelector).selectionChangeListener = { + App.setConfig(optionStr, optionsList[it]) + } + } + } else if (args.startsWith("spinner,")) { UIItemSpinner(parent, x, y, App.getConfigInt(optionName), arg[1].toInt(), arg[2].toInt(), arg[3].toInt(), CONFIG_SPINNER_WIDTH, numberToTextFunction = { "${it.toLong()}" }) to { it: UIItem, optionStr: String -> (it as UIItemSpinner).selectionChangeListener = { diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIGraphicsControlPanel.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIGraphicsControlPanel.kt index 8bdc77aec..b0e4fcd48 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIGraphicsControlPanel.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIGraphicsControlPanel.kt @@ -24,18 +24,18 @@ class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() { init { ControlPanelCommon.register(this, width, "basegame.graphicscontrolpanel", arrayOf( arrayOf("", { Lang["CREDITS_VFX"] }, "h1"), - arrayOf("fx_dither", { Lang["MENU_OPTIONS_DITHER"] }, "toggle"), - arrayOf("fx_backgroundblur", { Lang["MENU_OPTIONS_BLUR"] }, "toggle"), - arrayOf("maxparticles", { Lang["MENU_OPTIONS_PARTICLES"] }, "spinner,256,1024,256"), + arrayOf("fx_dither", { Lang["MENU_OPTIONS_DITHER"] }, "toggle"), + arrayOf("fx_backgroundblur", { Lang["MENU_OPTIONS_BLUR"] }, "toggle"), + arrayOf("maxparticles", { Lang["MENU_OPTIONS_PARTICLES"] }, "spinner,256,1024,256"), arrayOf("", { Lang["MENU_OPTIONS_DISPLAY"] }, "h1"), - arrayOf("screenwidth,screenheight", { Lang["MENU_OPTIONS_RESOLUTION"] }, "typeinres"), - arrayOf("screenmagnifying", { Lang["GAME_ACTION_ZOOM"] }, "spinnerd,1.0,2.0,0.05"), - arrayOf("screenmagnifyingfilter", { Lang["MENU_OPTIONS_FILTERING_MODE"] }, "textsel,none=MENU_OPTIONS_NONE,bilinear=MENU_OPTIONS_FILTERING_BILINEAR,hq2x=MENU_OPTIONS_FILTERING_HQ2X_DNT"), - arrayOf("displayfps", { Lang["MENU_LABEL_FRAMESPERSEC"] }, "spinner,0,300,2"), - arrayOf("usevsync", { Lang["MENU_OPTIONS_VSYNC"] }, "toggle"), - arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"), + arrayOf("screenwidth,screenheight", { Lang["MENU_OPTIONS_RESOLUTION"] }, "typeinres"), + arrayOf("screenmagnifying", { Lang["GAME_ACTION_ZOOM"] }, "spinnerd,1.0,2.0,0.05"), + arrayOf("screenmagnifyingfilter", { Lang["MENU_OPTIONS_FILTERING_MODE"] }, "textsel,none=MENU_OPTIONS_NONE,bilinear=MENU_OPTIONS_FILTERING_BILINEAR,hq2x=MENU_OPTIONS_FILTERING_HQ2X_DNT"), + arrayOf("displayfps", { Lang["MENU_LABEL_FRAMESPERSEC"] }, "spinner,0,300,2"), + arrayOf("usevsync", { Lang["MENU_OPTIONS_VSYNC"] }, "toggle"), + arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"), arrayOf("", { Lang["MENU_LABEL_STREAMING"] }, "h1"), - arrayOf("fx_streamerslayout", { Lang["MENU_OPTIONS_STREAMERS_LAYOUT"] }, "toggle"), + arrayOf("fx_streamerslayout", { Lang["MENU_OPTIONS_STREAMERS_LAYOUT"] }, "toggle"), )) } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIPerformanceControlPanel.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIPerformanceControlPanel.kt index aeec25a2a..bb3d2b80d 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIPerformanceControlPanel.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIPerformanceControlPanel.kt @@ -26,11 +26,14 @@ class UIPerformanceControlPanel(remoCon: UIRemoCon?) : UICanvas() { 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("", { Lang["MENU_LABEL_GRAPHICS"] }, "h1"), + arrayOf("atlastexsize", { Lang["MENU_OPTIONS_ATLAS_TEXTURE_SIZE"] }, "spinnersel,2048,4096,8192"), 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") diff --git a/src/net/torvald/terrarum/ui/UIItemSpinner.kt b/src/net/torvald/terrarum/ui/UIItemSpinner.kt index 91983606a..5b9d26f67 100644 --- a/src/net/torvald/terrarum/ui/UIItemSpinner.kt +++ b/src/net/torvald/terrarum/ui/UIItemSpinner.kt @@ -17,15 +17,15 @@ import kotlin.math.roundToInt */ class UIItemSpinner( - parentUI: UICanvas, - initialX: Int, initialY: Int, - private var initialValue: Number, - val min: Number, - val max: Number, - val step: Number, - override val width: Int, - private val drawBorder: Boolean = true, - private val numberToTextFunction: (Number) -> String = { "$it" } + parentUI: UICanvas, + initialX: Int, initialY: Int, + private var initialValue: Number, + val min: Number, + val max: Number, + val step: Number, + override val width: Int, + private val drawBorder: Boolean = true, + private val numberToTextFunction: (Number) -> String = { "$it" } ) : UIItem(parentUI, initialX, initialY) { // to alleviate floating point errors adding up as the spinner is being used diff --git a/src/net/torvald/terrarum/ui/UIItemTextSelector.kt b/src/net/torvald/terrarum/ui/UIItemTextSelector.kt index 34cb8501b..bcbe9f5b1 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextSelector.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextSelector.kt @@ -17,13 +17,14 @@ import net.torvald.terrarum.gameworld.fmod * Created by minjaesong on 2021-10-21. */ class UIItemTextSelector( - parentUI: UICanvas, - initialX: Int, initialY: Int, - val labelfuns: List<() -> String>, - initialSelection: Int, - override val width: Int, - private val drawBorder: Boolean = true, - private val clickToShowPalette: Boolean = true + parentUI: UICanvas, + initialX: Int, initialY: Int, + val labelfuns: List<() -> String>, + initialSelection: Int, + override val width: Int, + private val drawBorder: Boolean = true, + private val clickToShowPalette: Boolean = true, + private val useSpinnerButtons: Boolean = false, ) : UIItem(parentUI, initialX, initialY) { init { @@ -127,6 +128,9 @@ class UIItemTextSelector( else if (!Terrarum.mouseDown) mouseLatched = false } + private val leftIcon = if (useSpinnerButtons) labels.get(9,2) else labels.get(16,0) + private val rightIcon = if (useSpinnerButtons) labels.get(10,2) else labels.get(17,0) + override fun render(batch: SpriteBatch, camera: Camera) { labelCache = labelfuns.map { it() } @@ -184,12 +188,12 @@ class UIItemTextSelector( // left button icon batch.color = if (mouseOnButton == 1 && mousePushed) Toolkit.Theme.COL_SELECTED else if (mouseOnButton == 1) Toolkit.Theme.COL_MOUSE_UP else UIItemTextLineInput.TEXTINPUT_COL_TEXT - batch.draw(labels.get(16,0), posX + (buttonW - labels.tileW) / 2f, posY + (height - labels.tileH) / 2f) + batch.draw(leftIcon, posX + (buttonW - labels.tileW) / 2f, posY + (height - labels.tileH) / 2f) // right button icon batch.color = if (mouseOnButton == 2 && mousePushed) Toolkit.Theme.COL_SELECTED else if (mouseOnButton == 2) Toolkit.Theme.COL_MOUSE_UP else UIItemTextLineInput.TEXTINPUT_COL_TEXT - batch.draw(labels.get(17,0), posX + width - buttonW + (buttonW - labels.tileW) / 2f, posY + (height - labels.tileH) / 2f) + batch.draw(rightIcon, posX + width - buttonW + (buttonW - labels.tileW) / 2f, posY + (height - labels.tileH) / 2f) // draw text if (!paletteShowing) { diff --git a/work_files/graphics/sprites/fixtures/electronics_workbench.kra b/work_files/graphics/sprites/fixtures/electronics_workbench.kra new file mode 100644 index 000000000..f088c6b37 --- /dev/null +++ b/work_files/graphics/sprites/fixtures/electronics_workbench.kra @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06f409bc6b17551fa501422def41fd41353ffb6081980a209425a80c1378e4df +size 73588