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