mirror of
https://github.com/meowarex/rl-mobile.git
synced 2026-08-27 14:37:45 +10:00
Kawarp Shader <3
This commit is contained in:
+3
@@ -37,6 +37,7 @@ import com.meowarex.rlmobile.ui.legacy.components.ResetToDefaultButton
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.OptionLock
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.OptionSpec
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.PatchOptionState
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.hiddenForVariant
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.optionLock
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.PatchSpec
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -109,6 +110,8 @@ fun PatchAdvancedOptionsSheet(
|
||||
when {
|
||||
option is OptionSpec.Toggle && option.inline -> false
|
||||
option is OptionSpec.Toggle && option.requiresOption in parentKeys -> false
|
||||
// Options belonging to another variant are hidden, not greyed out.
|
||||
option.hiddenForVariant(selectedVariant) -> false
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
||||
+27
-2
@@ -1,6 +1,7 @@
|
||||
package com.meowarex.rlmobile.ui.screens.patchopts
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.Stable
|
||||
import kotlinx.serialization.SerialName
|
||||
@@ -49,7 +50,13 @@ data class VariantSpec(
|
||||
val fileNames: List<String> = emptyList(),
|
||||
val extensionFiles: List<String> = emptyList(),
|
||||
val enabled: Boolean = true,
|
||||
)
|
||||
/**
|
||||
* Hidden from the picker on devices below this API level (AGSL needs 33)
|
||||
*/
|
||||
val minSdk: Int = 0,
|
||||
) {
|
||||
val supportedHere: Boolean get() = Build.VERSION.SDK_INT >= minSdk
|
||||
}
|
||||
|
||||
/** A single advanced option. Discriminated by `"type"` in JSON. */
|
||||
@Serializable
|
||||
@@ -101,6 +108,8 @@ sealed interface OptionSpec {
|
||||
val token: String? = null,
|
||||
/** How the chosen value becomes the smali literal that replaces the token. */
|
||||
val encode: SmaliEncode? = null,
|
||||
/** Hidden unless this variant index is the selected one. */
|
||||
val requiresVariant: Int? = null,
|
||||
) : OptionSpec {
|
||||
val valueRange: ClosedFloatingPointRange<Float> get() = min..max
|
||||
}
|
||||
@@ -187,7 +196,9 @@ fun PatchSpec.effectiveVariants(isOptionOn: (OptionSpec.Toggle) -> Boolean): Lis
|
||||
}
|
||||
}
|
||||
return variants.mapIndexedNotNull { index, variant ->
|
||||
if (index in hidden) null
|
||||
// Everything downstream (variantIndex -> resolveVariantIndex) picks from this list, so
|
||||
// dropping an unsupported variant here also keeps the patcher from ever applying it.
|
||||
if (index in hidden || !variant.supportedHere) null
|
||||
else EffectiveVariant(index, relabel[index] ?: variant.title, variant.enabled)
|
||||
}
|
||||
}
|
||||
@@ -206,6 +217,20 @@ fun PatchSpec.resolveVariantIndex(stored: Int, isOptionOn: (OptionSpec.Toggle) -
|
||||
?: visible.first().originalIndex
|
||||
}
|
||||
|
||||
/**
|
||||
* The variant this option belongs to
|
||||
*/
|
||||
val OptionSpec.variantGate: Int?
|
||||
get() = when (this) {
|
||||
is OptionSpec.Toggle -> requiresVariant
|
||||
is OptionSpec.Slider -> requiresVariant
|
||||
is OptionSpec.Choice -> null
|
||||
is OptionSpec.Color -> null
|
||||
}
|
||||
|
||||
fun OptionSpec.hiddenForVariant(selectedVariant: Int): Boolean =
|
||||
variantGate.let { it != null && it != selectedVariant }
|
||||
|
||||
sealed interface OptionLock {
|
||||
data object Free : OptionLock
|
||||
data class NeedsVariant(val title: String) : OptionLock
|
||||
|
||||
+3
@@ -43,6 +43,7 @@ import com.meowarex.rlmobile.ui.components.ResetToDefaultButton
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.OptionLock
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.OptionSpec
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.PatchOptionState
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.hiddenForVariant
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.optionLock
|
||||
import com.meowarex.rlmobile.ui.screens.patchopts.PatchSpec
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -115,6 +116,8 @@ fun PatchAdvancedOptionsSheet(
|
||||
when {
|
||||
option is OptionSpec.Toggle && option.inline -> false
|
||||
option is OptionSpec.Toggle && option.requiresOption in parentKeys -> false
|
||||
// Options belonging to another variant are hidden, not greyed out.
|
||||
option.hiddenForVariant(selectedVariant) -> false
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user