Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ fun battleLauncher(
if (selectedConfigIndex > -1) {
prefs.selectedBattleConfig = configs[selectedConfigIndex]
}

prefs.updateCompletedRuns()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
import io.github.fate_grand_automata.R
Expand All @@ -40,6 +42,8 @@ fun ScriptRunnerUI(
val hidePlayButton by prefsCore.hidePlayButton.remember()
val script by prefsCore.scriptMode.remember()

val completedRuns by prefsCore.completedRuns.remember()

FGATheme(
darkTheme = true,
background = Color.Transparent
Expand Down Expand Up @@ -87,19 +91,30 @@ fun ScriptRunnerUI(
enabled = enabled,
modifier = dragModifier
) {
Icon(
painter = when (state) {
ScriptRunnerUIState.Idle, is ScriptRunnerUIState.Paused -> painterResource(R.drawable.ic_play)
ScriptRunnerUIState.Running -> painterResource(R.drawable.ic_pause)
},
contentDescription = when (state) {
ScriptRunnerUIState.Idle -> "start"
is ScriptRunnerUIState.Paused -> "resume"
ScriptRunnerUIState.Running -> "pause"
},
modifier = Modifier
.padding(18.dp, 10.dp)
)
if (script == ScriptModeEnum.Battle && state == ScriptRunnerUIState.Running) {
Text(
text = "$completedRuns",
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.padding(18.dp, 10.dp),
textAlign = TextAlign.Center,
maxLines = 1
)
} else {
Icon(
painter = when (state) {
ScriptRunnerUIState.Idle, is ScriptRunnerUIState.Paused -> painterResource(R.drawable.ic_play)
ScriptRunnerUIState.Running -> painterResource(R.drawable.ic_pause)
},
contentDescription = when (state) {
ScriptRunnerUIState.Idle -> "start"
is ScriptRunnerUIState.Paused -> "resume"
ScriptRunnerUIState.Running -> "pause"
},
modifier = Modifier
.padding(18.dp, 10.dp)
)
}

}

AnimatedVisibility(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ class PreferencesImpl @Inject constructor(

override fun completedOnboarding() =
prefs.onboardingCompletedVersion.set(PrefsCore.CURRENT_ONBOARDING_VERSION)

override fun updateCompletedRuns(runs: Int) {
prefs.completedRuns.set(runs)
}

override val support = object :
ISupportPreferencesCommon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,5 @@ class PrefsCore @Inject constructor(

val servantEnhancement = ServantEnhancementPrefsCore(maker)

var completedRuns = maker.int("completed_runs", 0)
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Battle @Inject constructor(
state.nextRun()

servantTracker.nextRun()

prefs.updateCompletedRuns(state.runs)
}

if (prefs.stopAfterThisRun) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ interface IPreferences {
fun removeBattleConfig(id: String)
fun isOnboardingRequired(): Boolean
fun completedOnboarding()

fun updateCompletedRuns(runs: Int = 0)
}

val IPreferences.wantsMediaProjectionToken get() = !useRootForScreenshots