-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
409 additions
and
25 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
app/desktop/src/jvmMain/kotlin/dev/datlag/burningseries/InitCEF.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package dev.datlag.burningseries | ||
|
||
import androidx.compose.runtime.* | ||
import dev.datlag.burningseries.common.LocalRestartRequired | ||
import dev.datlag.burningseries.common.withIOContext | ||
import dev.datlag.burningseries.other.CEFState | ||
import dev.datlag.burningseries.other.LocalCEFInitialization | ||
import dev.datlag.burningseries.window.ApplicationDisposer | ||
import dev.datlag.kcef.KCEF | ||
import dev.datlag.kcef.KCEFBuilder | ||
import java.io.File | ||
|
||
@Composable | ||
fun InitCEF(content: @Composable () -> Unit) { | ||
val restartRequiredInitial = LocalRestartRequired.current | ||
var restartRequired by remember { mutableStateOf(restartRequiredInitial) } | ||
val cefState = remember { mutableStateOf<CEFState>(CEFState.LOCATING) } | ||
|
||
LaunchedEffect(ApplicationDisposer.current) { | ||
withIOContext { | ||
KCEF.init( | ||
builder = { | ||
installDir(File(AppIO.getWriteableExecutableFolder(), "kcef-bundle")) | ||
progress { | ||
onLocating { | ||
cefState.value = CEFState.LOCATING | ||
} | ||
onDownloading { | ||
cefState.value = CEFState.Downloading(it) | ||
} | ||
onExtracting { | ||
cefState.value = CEFState.EXTRACTING | ||
} | ||
onInstall { | ||
cefState.value = CEFState.INSTALLING | ||
} | ||
onInitializing { | ||
cefState.value = CEFState.INITIALIZING | ||
} | ||
onInitialized { | ||
cefState.value = CEFState.INITIALIZED | ||
} | ||
} | ||
settings { | ||
logSeverity = KCEFBuilder.Settings.LogSeverity.Disable | ||
} | ||
}, | ||
onRestartRequired = { | ||
restartRequired = true | ||
} | ||
) | ||
} | ||
} | ||
|
||
CompositionLocalProvider( | ||
LocalRestartRequired provides restartRequired, | ||
LocalCEFInitialization provides cefState | ||
) { | ||
content() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/shared/src/desktopMain/kotlin/dev/datlag/burningseries/other/CEFState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dev.datlag.burningseries.other | ||
|
||
import androidx.compose.runtime.MutableState | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
|
||
val LocalCEFInitialization = staticCompositionLocalOf<MutableState<CEFState>> { error("No CEFInitialization state provided") } | ||
|
||
sealed interface CEFState { | ||
data object LOCATING : CEFState | ||
data class Downloading(val progress: Float) : CEFState | ||
data object EXTRACTING : CEFState | ||
data object INSTALLING : CEFState | ||
data object INITIALIZING : CEFState | ||
data object INITIALIZED : CEFState | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.