mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 04:24:05 +09:00
fixed a bug where WeatherMixer would not read weather json files
This commit is contained in:
Binary file not shown.
@@ -52,13 +52,13 @@ class GdxColorMap {
|
|||||||
is2D = false
|
is2D = false
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(gradStart: Color, gradEnd: Color) {
|
constructor(width: Int, height: Int, vararg colours: Color) {
|
||||||
dataRaw = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
|
dataRaw = colours.map { it.toIntBits() }.toIntArray()
|
||||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||||
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
|
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
|
||||||
width = 1
|
this.width = width
|
||||||
height = 2
|
this.height = height
|
||||||
is2D = true
|
is2D = (height > 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val dataRaw: IntArray
|
private val dataRaw: IntArray
|
||||||
|
|||||||
@@ -503,6 +503,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
|||||||
|
|
||||||
|
|
||||||
// TODO do something to the ActorWithBody.platformsToIgnore
|
// TODO do something to the ActorWithBody.platformsToIgnore
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun applyAccel(x: Int): Double {
|
private fun applyAccel(x: Int): Double {
|
||||||
@@ -527,6 +528,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
|||||||
private fun walkVStop() {
|
private fun walkVStop() {
|
||||||
walkCounterY = 0
|
walkCounterY = 0
|
||||||
isWalkingV = false
|
isWalkingV = false
|
||||||
|
platformsToIgnore = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getJumpAcc(pwr: Double, timedJumpCharge: Double): Double {
|
private fun getJumpAcc(pwr: Double, timedJumpCharge: Double): Double {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
"MENU_LABEL_GRAPHICS",
|
"MENU_LABEL_GRAPHICS",
|
||||||
"MENU_OPTIONS_CONTROLS",
|
"MENU_OPTIONS_CONTROLS",
|
||||||
"MENU_LABEL_MAINMENU",
|
"MENU_LABEL_MAINMENU",
|
||||||
"MENU_LABEL_QUIT",
|
// "MENU_LABEL_QUIT",
|
||||||
)
|
)
|
||||||
private val gameMenuListHeight = DEFAULT_LINE_HEIGHT * gameMenu.size
|
private val gameMenuListHeight = DEFAULT_LINE_HEIGHT * gameMenu.size
|
||||||
private val gameMenuListWidth = 400
|
private val gameMenuListWidth = 400
|
||||||
@@ -59,7 +59,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
inactiveCol = Color.WHITE,
|
inactiveCol = Color.WHITE,
|
||||||
defaultSelection = null
|
defaultSelection = null
|
||||||
)
|
)
|
||||||
private val areYouSureQuitButtons = UIItemTextButtonList(
|
/*private val areYouSureQuitButtons = UIItemTextButtonList(
|
||||||
this, DEFAULT_LINE_HEIGHT, arrayOf("MENU_LABEL_DESKTOP_QUESTION", "MENU_LABEL_DESKTOP", "MENU_LABEL_CANCEL"),
|
this, DEFAULT_LINE_HEIGHT, arrayOf("MENU_LABEL_DESKTOP_QUESTION", "MENU_LABEL_DESKTOP", "MENU_LABEL_CANCEL"),
|
||||||
(width - gameMenuListWidth) / 2,
|
(width - gameMenuListWidth) / 2,
|
||||||
INVENTORY_CELLS_OFFSET_Y() + (INVENTORY_CELLS_UI_HEIGHT - (DEFAULT_LINE_HEIGHT * 3)) / 2,
|
INVENTORY_CELLS_OFFSET_Y() + (INVENTORY_CELLS_UI_HEIGHT - (DEFAULT_LINE_HEIGHT * 3)) / 2,
|
||||||
@@ -70,7 +70,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
highlightBackCol = Color(0),
|
highlightBackCol = Color(0),
|
||||||
inactiveCol = Color.WHITE,
|
inactiveCol = Color.WHITE,
|
||||||
defaultSelection = null
|
defaultSelection = null
|
||||||
)
|
)*/
|
||||||
private val savingUI = UIItemSaving(this, (width - UIItemSaving.WIDTH) / 2, (height - UIItemSaving.HEIGHT) / 2)
|
private val savingUI = UIItemSaving(this, (width - UIItemSaving.WIDTH) / 2, (height - UIItemSaving.HEIGHT) / 2)
|
||||||
|
|
||||||
private val keyConfigUI = UIKeyboardControlPanel(null)
|
private val keyConfigUI = UIKeyboardControlPanel(null)
|
||||||
@@ -122,9 +122,9 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
3 -> {
|
3 -> {
|
||||||
screen = 2; gameMenuButtons.deselect()
|
screen = 2; gameMenuButtons.deselect()
|
||||||
}
|
}
|
||||||
4 -> {
|
/*4 -> {
|
||||||
screen = 1; gameMenuButtons.deselect()
|
screen = 1; gameMenuButtons.deselect()
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
areYouSureMainMenuButtons.selectionChangeListener = { _, new ->
|
areYouSureMainMenuButtons.selectionChangeListener = { _, new ->
|
||||||
@@ -138,18 +138,18 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
areYouSureQuitButtons.selectionChangeListener = { _, new ->
|
/*areYouSureQuitButtons.selectionChangeListener = { _, new ->
|
||||||
when (new) {
|
when (new) {
|
||||||
1 -> Gdx.app.exit()
|
2 -> Gdx.app.exit()
|
||||||
2 -> {
|
3 -> {
|
||||||
screen = 0; areYouSureQuitButtons.deselect()
|
screen = 0; areYouSureQuitButtons.deselect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private val screens = arrayOf(
|
private val screens = arrayOf(
|
||||||
gameMenuButtons, areYouSureQuitButtons, areYouSureMainMenuButtons, savingUI, keyConfigUI
|
gameMenuButtons, null, areYouSureMainMenuButtons, savingUI, keyConfigUI
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
// control hints
|
// control hints
|
||||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||||
|
|
||||||
areYouSureQuitButtons.render(batch, camera)
|
// areYouSureQuitButtons.render(batch, camera)
|
||||||
},
|
},
|
||||||
{ batch: SpriteBatch, camera: Camera ->
|
{ batch: SpriteBatch, camera: Camera ->
|
||||||
// control hints
|
// control hints
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.jme3.math.FastMath
|
|||||||
import net.torvald.gdx.graphics.Cvec
|
import net.torvald.gdx.graphics.Cvec
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||||
@@ -18,6 +19,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.ParticleMegaRain
|
|||||||
import net.torvald.terrarum.utils.JsonFetcher
|
import net.torvald.terrarum.utils.JsonFetcher
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileFilter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -61,10 +63,13 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
|
|
||||||
// read weather descriptions from assets/weather (modular weather)
|
// read weather descriptions from assets/weather (modular weather)
|
||||||
val weatherRawValidList = ArrayList<File>()
|
val weatherRawValidList = ArrayList<File>()
|
||||||
val weatherRaws = ModMgr.getFilesFromEveryMod("weathers")
|
val weatherRawsDir = ModMgr.getFilesFromEveryMod("weathers")
|
||||||
weatherRaws.forEach { (modname, it) ->
|
weatherRawsDir.forEach { (modname, parentdir) ->
|
||||||
if (!it.isDirectory && it.name.endsWith(".json"))
|
printdbg(this, "Scanning dir $parentdir")
|
||||||
|
parentdir.listFiles(FileFilter { !it.isDirectory && it.name.endsWith(".json") })?.forEach {
|
||||||
weatherRawValidList.add(it)
|
weatherRawValidList.add(it)
|
||||||
|
printdbg(this, "Registering weather '$it' from module $modname")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// --> read from directory and store file that looks like RAW
|
// --> read from directory and store file that looks like RAW
|
||||||
for (raw in weatherRawValidList) {
|
for (raw in weatherRawValidList) {
|
||||||
@@ -85,8 +90,10 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
nextWeather = getRandomWeather(WEATHER_GENERIC)
|
nextWeather = getRandomWeather(WEATHER_GENERIC)
|
||||||
}
|
}
|
||||||
catch (e: NullPointerException) {
|
catch (e: NullPointerException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
|
||||||
val defaultWeather = BaseModularWeather(
|
val defaultWeather = BaseModularWeather(
|
||||||
GdxColorMap(Color(0x55aaffff), Color(0xaaffffff.toInt())),
|
GdxColorMap(1, 3, Color(0x55aaffff), Color(0xaaffffff.toInt()), Color.WHITE),
|
||||||
"default",
|
"default",
|
||||||
ArrayList<Texture>()
|
ArrayList<Texture>()
|
||||||
)
|
)
|
||||||
@@ -102,7 +109,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
fun update(delta: Float, player: ActorWithBody?, world: GameWorld) {
|
fun update(delta: Float, player: ActorWithBody?, world: GameWorld) {
|
||||||
if (player == null) return
|
if (player == null) return
|
||||||
|
|
||||||
currentWeather = weatherList[WEATHER_GENERIC]!![0]
|
// currentWeather = weatherList[WEATHER_GENERIC]!![0] // force set weather
|
||||||
|
|
||||||
|
|
||||||
// test rain toggled by F2
|
// test rain toggled by F2
|
||||||
@@ -237,8 +244,8 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
val phaseThis: Int = timeInSec / dataPointDistance // x-coord in gradmap
|
val phaseThis: Int = timeInSec / dataPointDistance // x-coord in gradmap
|
||||||
val phaseNext: Int = (phaseThis + 1) % colorMap.width
|
val phaseNext: Int = (phaseThis + 1) % colorMap.width
|
||||||
|
|
||||||
val colourThis = colorMap.get(phaseThis, row)
|
val colourThis = colorMap.get(phaseThis % colorMap.width, row)
|
||||||
val colourNext = colorMap.get(phaseNext, row)
|
val colourNext = colorMap.get(phaseNext % colorMap.width, row)
|
||||||
|
|
||||||
// interpolate R, G, B and A
|
// interpolate R, G, B and A
|
||||||
val scale = (timeInSec % dataPointDistance).toFloat() / dataPointDistance // [0.0, 1.0]
|
val scale = (timeInSec % dataPointDistance).toFloat() / dataPointDistance // [0.0, 1.0]
|
||||||
|
|||||||
Reference in New Issue
Block a user