mirror of
https://github.com/processing/processing4.git
synced 2026-01-26 18:01:07 +01:00
Removed PlatformStart and create new file if doesn't exist
This commit is contained in:
@@ -16,9 +16,6 @@ import java.util.Properties
|
||||
const val PREFERENCES_FILE_NAME = "preferences.txt"
|
||||
const val DEFAULTS_FILE_NAME = "defaults.txt"
|
||||
|
||||
fun PlatformStart(){
|
||||
Platform.inst ?: Platform.init()
|
||||
}
|
||||
class ReactiveProperties: Properties() {
|
||||
val _stateMap = mutableStateMapOf<String, String>()
|
||||
|
||||
@@ -41,10 +38,15 @@ val LocalPreferences = compositionLocalOf<ReactiveProperties> { error("No prefer
|
||||
@OptIn(FlowPreview::class)
|
||||
@Composable
|
||||
fun PreferencesProvider(content: @Composable () -> Unit){
|
||||
PlatformStart()
|
||||
remember {
|
||||
Platform.init()
|
||||
}
|
||||
|
||||
val settingsFolder = Platform.getSettingsFolder()
|
||||
val preferencesFile = settingsFolder.resolve(PREFERENCES_FILE_NAME)
|
||||
if(!preferencesFile.exists()){
|
||||
preferencesFile.createNewFile()
|
||||
}
|
||||
|
||||
val update = watchFile(preferencesFile)
|
||||
val properties = remember(preferencesFile, update) { ReactiveProperties().apply {
|
||||
|
||||
@@ -38,7 +38,9 @@ class Locale(language: String = "", val setLocale: (java.util.Locale) -> Unit) :
|
||||
val LocalLocale = compositionLocalOf<Locale> { error("No Locale Set") }
|
||||
@Composable
|
||||
fun LocaleProvider(content: @Composable () -> Unit) {
|
||||
PlatformStart()
|
||||
remember {
|
||||
Platform.init()
|
||||
}
|
||||
|
||||
val settingsFolder = Platform.getSettingsFolder()
|
||||
val languageFile = File(settingsFolder, "language.txt")
|
||||
|
||||
Reference in New Issue
Block a user