mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
modmgr to actually check dependency WIP
This commit is contained in:
Binary file not shown.
@@ -27,17 +27,11 @@ jar=
|
||||
|
||||
# Modules that must be pre-installed, separate multiple by semicolon (;)
|
||||
# Dependency syntax: "module's identification name (aka folder name) spaces allowed versionnumber"
|
||||
# Versionnumber: + means equal or higher, ! means this exact number, - denotes interval, * is wildcard
|
||||
# the default is equal or lower. When fields are omitted (e.g. 3, 1.65), those fields will be ignored
|
||||
# e.g. 1.4+ would allow any future versions including 1.4.0; PATCH versions are ignored: 1.6.0, 1.13.0, 1.42.0, 1.4.0, 1.4.4456
|
||||
# e.g. 4.2.25 would allow any future versions including 4.2.25; any older patches such as 4.2.17 will be disallowd
|
||||
# e.g. 10.4! is same as 10.4; would allow any PATCH versions as the numbers is ignored
|
||||
# e.g. 10.3-11.4 would allow any versions between and including stated versions; PATCH versions are ignored: 10.3.0, 10.7.0, 10.3.676, 11.0.0, 11.4.9999
|
||||
# e.g. 10.3.2-10.4.5 would allow any versions between and including stated versions; PATCH versions are checked
|
||||
# e.g. 3!.1+ would allow any future MINOR versions including 3.1; PATH versions are ignored: 3.1, 3.4.22, 3.6, 3.1415926
|
||||
# e.g. * would allow any version possible, as it won't check MINOR and PATCH versions
|
||||
# NOTE: it's your responsibility that your mod's version scheme would not be a total mess!
|
||||
# real world examples:
|
||||
# basegame 1.0.0+; command line refresh 2!.+; my_little_hack 0.*
|
||||
# Can you decode them? This is for hypothetical screen recorder mod.
|
||||
# Version number:
|
||||
# - a.b.c : the exact version a.b.c
|
||||
# - a.b.c+ : Any version between a.b.c and a.b.65535
|
||||
# - a.b.* : Any version between a.b.0 and a.b.65535
|
||||
# - a.b+ : Any version between a.b.0 and a.255.65535
|
||||
# - a.* : Any version between a.0.0 and a.255.65535
|
||||
# - * : Any version. Period.
|
||||
dependency=
|
||||
@@ -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() {
|
||||
|
||||
@@ -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!")
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user