mirror of
https://github.com/jlengrand/korge-samples.git
synced 2026-03-10 08:31:18 +00:00
Show how to close the window
This commit is contained in:
@@ -6,7 +6,7 @@ plugins {
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url "https://dl.bintray.com/soywiz/soywiz" }
|
||||
maven { url "https://dl.bintray.com/korlibs/korlibs" }
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
|
||||
@@ -15,10 +15,13 @@ import com.soywiz.korim.format.*
|
||||
import com.soywiz.korio.async.*
|
||||
import com.soywiz.korio.file.*
|
||||
import com.soywiz.korio.file.std.*
|
||||
import com.soywiz.korio.net.*
|
||||
import com.soywiz.korio.util.*
|
||||
import com.soywiz.korma.interpolation.*
|
||||
|
||||
suspend fun main() = Korge(quality = GameWindow.Quality.PERFORMANCE, title = "UI") {
|
||||
val nativeProcess = NativeProcess(views)
|
||||
|
||||
uiSkin(OtherUISkin()) {
|
||||
uiButton(256.0, 32.0) {
|
||||
label = "Disabled Button"
|
||||
@@ -33,6 +36,9 @@ suspend fun main() = Korge(quality = GameWindow.Quality.PERFORMANCE, title = "UI
|
||||
position(128, 128 + 32)
|
||||
onClick {
|
||||
println("CLICKED!")
|
||||
launchImmediately {
|
||||
nativeProcess.close()
|
||||
}
|
||||
}
|
||||
enable()
|
||||
}
|
||||
@@ -103,3 +109,16 @@ suspend fun OtherUISkin(): UISkin = OtherUISkinOnce {
|
||||
|
||||
private suspend fun VfsFile.readBitmapFontWithMipmaps(imageFormat: ImageFormat = RegisteredImageFormats, mipmaps: Boolean = true): BitmapFont =
|
||||
readBitmapFont(imageFormat).also { it.atlas.mipmaps(mipmaps) }
|
||||
|
||||
|
||||
private class NativeProcess(views: Views) : NativeProcessBase(views) {
|
||||
}
|
||||
|
||||
private open class NativeProcessBase(val views: Views) {
|
||||
open suspend fun alert(message: String) = views.gameWindow.alert(message)
|
||||
open suspend fun confirm(message: String): Boolean = views.gameWindow.confirm(message)
|
||||
open suspend fun openFileDialog(filter: String? = null, write: Boolean = false, multi: Boolean = false) = views.gameWindow.openFileDialog(filter, write, multi)
|
||||
open suspend fun browse(url: URL) = views.gameWindow.browse(url)
|
||||
open suspend fun close() = views.gameWindow.close()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user