mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +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 (;)
|
# Modules that must be pre-installed, separate multiple by semicolon (;)
|
||||||
# Dependency syntax: "module's identification name (aka folder name) spaces allowed versionnumber"
|
# 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
|
# Version number:
|
||||||
# the default is equal or lower. When fields are omitted (e.g. 3, 1.65), those fields will be ignored
|
# - a.b.c : the exact version a.b.c
|
||||||
# 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
|
# - a.b.c+ : Any version between a.b.c and a.b.65535
|
||||||
# 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
|
# - a.b.* : Any version between a.b.0 and a.b.65535
|
||||||
# e.g. 10.4! is same as 10.4; would allow any PATCH versions as the numbers is ignored
|
# - a.b+ : Any version between a.b.0 and a.255.65535
|
||||||
# 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
|
# - a.* : Any version between a.0.0 and a.255.65535
|
||||||
# e.g. 10.3.2-10.4.5 would allow any versions between and including stated versions; PATCH versions are checked
|
# - * : Any version. Period.
|
||||||
# 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.
|
|
||||||
dependency=
|
dependency=
|
||||||
@@ -101,6 +101,12 @@ object ModMgr {
|
|||||||
*/
|
*/
|
||||||
fun getTitleScreen(batch: SpriteBatch): IngameInstance? = entryPointClasses.getOrNull(0)?.getTitleScreen(batch)
|
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 {
|
init {
|
||||||
val loadOrderFile = FileSystems.getDefault().getPath("$modDir/LoadOrder.csv").toFile()
|
val loadOrderFile = FileSystems.getDefault().getPath("$modDir/LoadOrder.csv").toFile()
|
||||||
if (loadOrderFile.exists()) {
|
if (loadOrderFile.exists()) {
|
||||||
@@ -143,6 +149,25 @@ object ModMgr {
|
|||||||
val jar = modMetadata.getProperty("jar")
|
val jar = modMetadata.getProperty("jar")
|
||||||
val dependency = modMetadata.getProperty("dependency").split(Regex(""";[ ]*""")).toTypedArray()
|
val dependency = modMetadata.getProperty("dependency").split(Regex(""";[ ]*""")).toTypedArray()
|
||||||
val isDir = FileSystems.getDefault().getPath("$modDir/$moduleName").toFile().isDirectory
|
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)
|
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])
|
printdbg(this, moduleInfo[moduleName])
|
||||||
@@ -202,6 +227,9 @@ object ModMgr {
|
|||||||
moduleInfo.remove(moduleName)?.let { moduleInfoErrored[moduleName] = it }
|
moduleInfo.remove(moduleName)?.let { moduleInfoErrored[moduleName] = it }
|
||||||
}
|
}
|
||||||
catch (e: Throwable) {
|
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, "There was an error while loading module $moduleName")
|
||||||
printdbgerr(this, "\t$e")
|
printdbgerr(this, "\t$e")
|
||||||
print(App.csiR); e.printStackTrace(System.out); print(App.csi0)
|
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() { }
|
operator fun invoke() { }
|
||||||
|
|
||||||
/*fun reloadModules() {
|
/*fun reloadModules() {
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class EntryPoint : ModuleEntryPoint() {
|
|||||||
ModMgr.GameBlockLoader.invoke(moduleName)
|
ModMgr.GameBlockLoader.invoke(moduleName)
|
||||||
ModMgr.GameLanguageLoader.invoke(moduleName)
|
ModMgr.GameLanguageLoader.invoke(moduleName)
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// load customised item loader //
|
// load customised item loader //
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@@ -67,8 +66,6 @@ class EntryPoint : ModuleEntryPoint() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
println("[Basegame.EntryPoint] Welcome back!")
|
println("[Basegame.EntryPoint] Welcome back!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -822,27 +822,27 @@ object IngameRenderer : Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
blurWriteQuad.dispose()
|
try { blurWriteQuad.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
blurWriteQuad2.dispose()
|
try { blurWriteQuad2.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
//blurWriteQuad4.dispose()
|
//try { blurWriteQuad4.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
|
|
||||||
fboRGB.dispose()
|
try { fboRGB.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
fboA.dispose()
|
try { fboA.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
fboRGB_lightMixed.dispose()
|
try { fboRGB_lightMixed.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
fboA_lightMixed.dispose()
|
try { fboA_lightMixed.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
fboMixedOut.dispose()
|
try { fboMixedOut.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
lightmapFbo.dispose()
|
try { lightmapFbo.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
|
|
||||||
try { blurtex0.dispose() } catch (e: GdxRuntimeException) {}
|
try { blurtex0.dispose() } catch (e: GdxRuntimeException) {}
|
||||||
|
|
||||||
fboBlurHalf.dispose()
|
try { fboBlurHalf.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
//fboBlurQuarter.dispose()
|
//try { fboBlurQuarter.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
|
|
||||||
LightmapRenderer.dispose()
|
LightmapRenderer.dispose()
|
||||||
BlocksDrawer.dispose()
|
BlocksDrawer.dispose()
|
||||||
WeatherMixer.dispose()
|
WeatherMixer.dispose()
|
||||||
|
|
||||||
batch.dispose()
|
try { batch.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
|
|
||||||
|
|
||||||
shaderBlur.dispose()
|
shaderBlur.dispose()
|
||||||
|
|||||||
@@ -58,10 +58,11 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
init {
|
init {
|
||||||
weatherList = HashMap<String, ArrayList<BaseModularWeather>>()
|
weatherList = HashMap<String, ArrayList<BaseModularWeather>>()
|
||||||
|
|
||||||
|
|
||||||
// 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.getFiles("basegame", "weathers")
|
val weatherRaws = ModMgr.getFilesFromEveryMod("weathers")
|
||||||
weatherRaws.forEach {
|
weatherRaws.forEach { (modname, it) ->
|
||||||
if (!it.isDirectory && it.name.endsWith(".json"))
|
if (!it.isDirectory && it.name.endsWith(".json"))
|
||||||
weatherRawValidList.add(it)
|
weatherRawValidList.add(it)
|
||||||
}
|
}
|
||||||
@@ -79,8 +80,20 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
|
|
||||||
|
|
||||||
// initialise
|
// initialise
|
||||||
currentWeather = weatherList[WEATHER_GENERIC]!![0]
|
try {
|
||||||
nextWeather = getRandomWeather(WEATHER_GENERIC)
|
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()
|
tilesFluid.dispose()
|
||||||
tilesBuffer.dispose()
|
tilesBuffer.dispose()
|
||||||
_tilesBufferAsTex.dispose()
|
_tilesBufferAsTex.dispose()
|
||||||
tilesQuad.dispose()
|
try { tilesQuad.dispose() } catch (e: UninitializedPropertyAccessException) {}
|
||||||
shader.dispose()
|
shader.dispose()
|
||||||
|
|
||||||
App.tileMaker.dispose()
|
App.tileMaker.dispose()
|
||||||
|
|||||||
@@ -123,12 +123,6 @@ class CreateTileAtlas {
|
|||||||
System.err.println("Couldn't load file $filehandle from $modname, skipping...")
|
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
|
// test print
|
||||||
//PixmapIO2.writeTGA(Gdx.files.absolute("${AppLoader.defaultDir}/atlas.tga"), atlas, false)
|
//PixmapIO2.writeTGA(Gdx.files.absolute("${AppLoader.defaultDir}/atlas.tga"), atlas, false)
|
||||||
|
|||||||
Reference in New Issue
Block a user