mirror of
https://github.com/jlengrand/korge-samples.git
synced 2026-03-10 08:31:18 +00:00
Added sample ResourceProcessor plugin
This commit is contained in:
1
plugin/.gitignore
vendored
Normal file
1
plugin/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
7
plugin/build.gradle.kts
Normal file
7
plugin/build.gradle.kts
Normal file
@@ -0,0 +1,7 @@
|
||||
import com.soywiz.korge.gradle.*
|
||||
|
||||
apply<KorgeGradlePlugin>()
|
||||
|
||||
korge {
|
||||
id = "com.example.example"
|
||||
}
|
||||
10
plugin/src/commonMain/kotlin/main.kt
Normal file
10
plugin/src/commonMain/kotlin/main.kt
Normal 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]
|
||||
1
plugin/src/commonMain/resources/hello.demo
Normal file
1
plugin/src/commonMain/resources/hello.demo
Normal file
@@ -0,0 +1 @@
|
||||
world
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
com.soywiz.korge.samples.plugin.MyCustomResourceProcessor
|
||||
Reference in New Issue
Block a user