Added sample ResourceProcessor plugin

This commit is contained in:
soywiz
2020-11-11 14:42:28 +01:00
parent 336e0ab4ad
commit 7032bbb439
6 changed files with 33 additions and 0 deletions

1
plugin/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

7
plugin/build.gradle.kts Normal file
View File

@@ -0,0 +1,7 @@
import com.soywiz.korge.gradle.*
apply<KorgeGradlePlugin>()
korge {
id = "com.example.example"
}

View File

@@ -0,0 +1,10 @@
import com.soywiz.korge.*
import com.soywiz.korge.view.*
import com.soywiz.korio.file.std.*
suspend fun main() = Korge {
val text1 = text("hello.demo".resource.readString())
val text2 = text("hello.demo.uppercased".resource.readString()).alignTopToBottomOf(text1)
}
private val String.resource get() = resourcesVfs[this]

View File

@@ -0,0 +1 @@
world

View File

@@ -0,0 +1,13 @@
package com.soywiz.korge.samples.plugin
import com.soywiz.korge.resources.*
import com.soywiz.korio.file.*
class MyCustomResourceProcessor : ResourceProcessor("demo") {
override val outputExtension: String get() = "demo.uppercased"
override val version: Int = 1
override suspend fun processInternal(inputFile: VfsFile, outputFile: VfsFile) {
outputFile.writeString(inputFile.readString().toUpperCase())
}
}

View File

@@ -0,0 +1 @@
com.soywiz.korge.samples.plugin.MyCustomResourceProcessor