modmgr to actually check dependency WIP

This commit is contained in:
minjaesong
2022-01-01 23:38:30 +09:00
parent bc6a1c4463
commit caa9b84cb2
8 changed files with 70 additions and 41 deletions

View File

@@ -101,6 +101,12 @@ object ModMgr {
*/
fun getTitleScreen(batch: SpriteBatch): IngameInstance? = entryPointClasses.getOrNull(0)?.getTitleScreen(batch)
private fun List<String>.toVersionNumber() = 0L or
(this[0].replaceFirst('*','0').removeSuffix("+").toLong().shl(24)) or
(this.getOrElse(1) {"0"}.replaceFirst('*','0').removeSuffix("+").toLong().shl(16)) or
(this.getOrElse(2) {"0"}.replaceFirst('*','0').removeSuffix("+").toLong().coerceAtMost(65535))
init {
val loadOrderFile = FileSystems.getDefault().getPath("$modDir/LoadOrder.csv").toFile()
if (loadOrderFile.exists()) {
@@ -143,6 +149,25 @@ object ModMgr {
val jar = modMetadata.getProperty("jar")
val dependency = modMetadata.getProperty("dependency").split(Regex(""";[ ]*""")).toTypedArray()
val isDir = FileSystems.getDefault().getPath("$modDir/$moduleName").toFile().isDirectory
val versionNumeral = version.split('.')
val versionNumber = versionNumeral.toVersionNumber()
dependency.forEach {
val (moduleName, moduleVersionStr) = it.split(' ')
val numbers = moduleVersionStr.split('.')
val checkVersionNumber = numbers.toVersionNumber() // version number required
var operator = numbers.last().last() // can be '+', '*', or a number
val checkAgainst = moduleInfo[moduleName]?.version // version number of what's installed
?: throw ModuleDependencyNotSatisfied(it, "(module not installed)")
// TODO make version number check here (hint: use moduleInfo)
}
moduleInfo[moduleName] = ModuleMetadata(index, isDir, Gdx.files.internal("$modDir/$moduleName/icon.png"), properName, description, author, packageName, entryPoint, releaseDate, version, jar, dependency)
printdbg(this, moduleInfo[moduleName])
@@ -202,6 +227,9 @@ object ModMgr {
moduleInfo.remove(moduleName)?.let { moduleInfoErrored[moduleName] = it }
}
catch (e: Throwable) {
// TODO: Instead of skipping module with error, just display the error message onto the face?
printdbgerr(this, "There was an error while loading module $moduleName")
printdbgerr(this, "\t$e")
print(App.csiR); e.printStackTrace(System.out); print(App.csi0)
@@ -217,6 +245,9 @@ object ModMgr {
}
}
private class ModuleDependencyNotSatisfied(want: String, have: String) :
RuntimeException("Required: $want, Installed: $have")
operator fun invoke() { }
/*fun reloadModules() {

View File

@@ -47,7 +47,6 @@ class EntryPoint : ModuleEntryPoint() {
ModMgr.GameBlockLoader.invoke(moduleName)
ModMgr.GameLanguageLoader.invoke(moduleName)
/////////////////////////////////
// load customised item loader //
/////////////////////////////////
@@ -67,8 +66,6 @@ class EntryPoint : ModuleEntryPoint() {
}
}
println("[Basegame.EntryPoint] Welcome back!")
}

View File

@@ -822,27 +822,27 @@ object IngameRenderer : Disposable {
}
override fun dispose() {
blurWriteQuad.dispose()
blurWriteQuad2.dispose()
//blurWriteQuad4.dispose()
try { blurWriteQuad.dispose() } catch (e: UninitializedPropertyAccessException) {}
try { blurWriteQuad2.dispose() } catch (e: UninitializedPropertyAccessException) {}
//try { blurWriteQuad4.dispose() } catch (e: UninitializedPropertyAccessException) {}
fboRGB.dispose()
fboA.dispose()
fboRGB_lightMixed.dispose()
fboA_lightMixed.dispose()
fboMixedOut.dispose()
lightmapFbo.dispose()
try { fboRGB.dispose() } catch (e: UninitializedPropertyAccessException) {}
try { fboA.dispose() } catch (e: UninitializedPropertyAccessException) {}
try { fboRGB_lightMixed.dispose() } catch (e: UninitializedPropertyAccessException) {}
try { fboA_lightMixed.dispose() } catch (e: UninitializedPropertyAccessException) {}
try { fboMixedOut.dispose() } catch (e: UninitializedPropertyAccessException) {}
try { lightmapFbo.dispose() } catch (e: UninitializedPropertyAccessException) {}
try { blurtex0.dispose() } catch (e: GdxRuntimeException) {}
fboBlurHalf.dispose()
//fboBlurQuarter.dispose()
try { fboBlurHalf.dispose() } catch (e: UninitializedPropertyAccessException) {}
//try { fboBlurQuarter.dispose() } catch (e: UninitializedPropertyAccessException) {}
LightmapRenderer.dispose()
BlocksDrawer.dispose()
WeatherMixer.dispose()
batch.dispose()
try { batch.dispose() } catch (e: UninitializedPropertyAccessException) {}
shaderBlur.dispose()

View File

@@ -58,10 +58,11 @@ internal object WeatherMixer : RNGConsumer {
init {
weatherList = HashMap<String, ArrayList<BaseModularWeather>>()
// read weather descriptions from assets/weather (modular weather)
val weatherRawValidList = ArrayList<File>()
val weatherRaws = ModMgr.getFiles("basegame", "weathers")
weatherRaws.forEach {
val weatherRaws = ModMgr.getFilesFromEveryMod("weathers")
weatherRaws.forEach { (modname, it) ->
if (!it.isDirectory && it.name.endsWith(".json"))
weatherRawValidList.add(it)
}
@@ -79,8 +80,20 @@ internal object WeatherMixer : RNGConsumer {
// initialise
currentWeather = weatherList[WEATHER_GENERIC]!![0]
nextWeather = getRandomWeather(WEATHER_GENERIC)
try {
currentWeather = weatherList[WEATHER_GENERIC]!![0]
nextWeather = getRandomWeather(WEATHER_GENERIC)
}
catch (e: NullPointerException) {
val defaultWeather = BaseModularWeather(
GdxColorMap(Color(0x55aaffff), Color(0xaaffffff.toInt())),
"default",
ArrayList<Texture>()
)
currentWeather = defaultWeather
nextWeather = defaultWeather
}
}
/**

View File

@@ -721,7 +721,7 @@ internal object BlocksDrawer {
tilesFluid.dispose()
tilesBuffer.dispose()
_tilesBufferAsTex.dispose()
tilesQuad.dispose()
try { tilesQuad.dispose() } catch (e: UninitializedPropertyAccessException) {}
shader.dispose()
App.tileMaker.dispose()

View File

@@ -123,12 +123,6 @@ class CreateTileAtlas {
System.err.println("Couldn't load file $filehandle from $modname, skipping...")
}
}
// hard-coding shits
tags["basegame:4090"] = RenderTag(
tags["basegame:4090"]!!.tileNumber,
RenderTag.CONNECT_MUTUAL,
RenderTag.MASK_NA
)
// test print
//PixmapIO2.writeTGA(Gdx.files.absolute("${AppLoader.defaultDir}/atlas.tga"), atlas, false)