Android: fixes after the second test (trainer on its side, a game put aside is asked about, offer and take-back, late offers, Maia's failure, the report after a rematch)
- The trainer lays out beside the board when the phone lies on its side. - A new game while one is put aside asks «Continue it / Start a new one»; the card of a game just put aside is scrolled into sight. - Take back during Maia's offer removes only the user's move and the offer; her judge's answer is waited for up to 2 s, so the offer comes on time. - Maia not starting: a card «Download Maia again / Abort», no raw error. - A rematch drops the report of the game before; «Analyse» puts the result card away; the card goes at the first change after the end. - Back from the trainer returns to its move; an empty game is not put aside; the first sound is loaded at start; «Viewing: …», «Ещё раз». Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
179f92144e
commit
a3eac74491
15 changed files with 204 additions and 16 deletions
|
|
@ -48,6 +48,8 @@ class ChessPenguinApp : Application() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
// The opening trainer's runs (android-play.md §32.3).
|
// The opening trainer's runs (android-play.md §32.3).
|
||||||
uniffi.mobile_api.trainerSetFile(java.io.File(filesDir, "training.json").path)
|
uniffi.mobile_api.trainerSetFile(java.io.File(filesDir, "training.json").path)
|
||||||
|
// Loaded now: the first move's sound is ready when it is played.
|
||||||
|
sounds
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The games shown on the list of each database (after a search), for paging
|
/// The games shown on the list of each database (after a search), for paging
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,17 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett
|
||||||
val adjourned by theApp.maiaGames.current.collectAsState()
|
val adjourned by theApp.maiaGames.current.collectAsState()
|
||||||
val playRemovedText = stringResource(R.string.play_removed)
|
val playRemovedText = stringResource(R.string.play_removed)
|
||||||
var playing by remember { mutableStateOf(false) }
|
var playing by remember { mutableStateOf(false) }
|
||||||
|
// A game put aside: asked about before a new one replaces it.
|
||||||
|
var askingAdjourned by remember { mutableStateOf(false) }
|
||||||
|
adjourned?.takeIf { askingAdjourned && !it.over }?.let { m ->
|
||||||
|
AdjournedQuestion(m, onContinue = {
|
||||||
|
askingAdjourned = false
|
||||||
|
onPlay()
|
||||||
|
}, onNew = {
|
||||||
|
askingAdjourned = false
|
||||||
|
playing = true
|
||||||
|
}, onDismiss = { askingAdjourned = false })
|
||||||
|
}
|
||||||
val eventText = stringResource(R.string.play_event)
|
val eventText = stringResource(R.string.play_event)
|
||||||
if (playing) {
|
if (playing) {
|
||||||
PlaySheet(null, onPlay = { strength, white, name ->
|
PlaySheet(null, onPlay = { strength, white, name ->
|
||||||
|
|
@ -189,6 +200,10 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett
|
||||||
}
|
}
|
||||||
val files = entries.filter { it.source != Source.Own }
|
val files = entries.filter { it.source != Source.Own }
|
||||||
val list = rememberLazyListState()
|
val list = rememberLazyListState()
|
||||||
|
// The card of a game just put aside is brought into sight.
|
||||||
|
LaunchedEffect(adjourned) {
|
||||||
|
if (adjourned?.over == false) list.animateScrollToItem(0)
|
||||||
|
}
|
||||||
// The card comes when GitHub answers, after the list is drawn: a list at its top then
|
// The card comes when GitHub answers, after the list is drawn: a list at its top then
|
||||||
// keeps its first database in place and the card lands above the screen. It is
|
// keeps its first database in place and the card lands above the screen. It is
|
||||||
// brought into sight; a list scrolled down by the user stays where it is.
|
// brought into sight; a list scrolled down by the user stays where it is.
|
||||||
|
|
@ -275,7 +290,7 @@ fun DatabasesScreen(onOpen: (String) -> Unit, onAdded: (DbEntry) -> Unit, onSett
|
||||||
}
|
}
|
||||||
item(key = "actions") {
|
item(key = "actions") {
|
||||||
Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
Row(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
FilledTonalButton(onClick = { playing = true }, modifier = Modifier.height(48.dp)) {
|
FilledTonalButton(onClick = { if (adjourned?.over == false) askingAdjourned = true else playing = true }, modifier = Modifier.height(48.dp)) {
|
||||||
Icon(Icons.Rounded.SmartToy, null)
|
Icon(Icons.Rounded.SmartToy, null)
|
||||||
Spacer(Modifier.size(8.dp))
|
Spacer(Modifier.size(8.dp))
|
||||||
Text(stringResource(R.string.play_with_maia))
|
Text(stringResource(R.string.play_with_maia))
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,11 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
}
|
}
|
||||||
var failed by remember { mutableStateOf(false) }
|
var failed by remember { mutableStateOf(false) }
|
||||||
var current by rememberSaveable(place) { mutableIntStateOf(0) }
|
var current by rememberSaveable(place) { mutableIntStateOf(0) }
|
||||||
|
// Back from the trainer: the move it was opened from, the board as it was.
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
held.trainReturn?.let { current = it }
|
||||||
|
held.trainReturn = null
|
||||||
|
}
|
||||||
var flipped by rememberSaveable { mutableStateOf(false) }
|
var flipped by rememberSaveable { mutableStateOf(false) }
|
||||||
var preview by remember { mutableStateOf<Preview?>(null) }
|
var preview by remember { mutableStateOf<Preview?>(null) }
|
||||||
// The game report (§21): its own engine job; the live engine rests while it runs.
|
// The game report (§21): its own engine job; the live engine rests while it runs.
|
||||||
|
|
@ -421,6 +426,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
var moveSheet by remember { mutableStateOf<Int?>(null) }
|
var moveSheet by remember { mutableStateOf<Int?>(null) }
|
||||||
// «Play on from here» asked for at this move.
|
// «Play on from here» asked for at this move.
|
||||||
var playFrom by remember { mutableStateOf<Int?>(null) }
|
var playFrom by remember { mutableStateOf<Int?>(null) }
|
||||||
|
var askFrom by remember { mutableStateOf<Int?>(null) }
|
||||||
val deletedText = stringResource(R.string.moves_deleted)
|
val deletedText = stringResource(R.string.moves_deleted)
|
||||||
val mainText = stringResource(R.string.made_main)
|
val mainText = stringResource(R.string.made_main)
|
||||||
val undoText = stringResource(R.string.undo_action)
|
val undoText = stringResource(R.string.undo_action)
|
||||||
|
|
@ -490,7 +496,19 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
val wait = uniffi.mobile_api.maiaPauseMs(depth(gg, end).toUInt(), only).toLong() - (System.currentTimeMillis() - started)
|
val wait = uniffi.mobile_api.maiaPauseMs(depth(gg, end).toUInt(), only).toLong() - (System.currentTimeMillis() - started)
|
||||||
if (wait > 0) delay(wait)
|
if (wait > 0) delay(wait)
|
||||||
if (gen != r.generation) return@LaunchedEffect
|
if (gen != r.generation) return@LaunchedEffect
|
||||||
r.judge?.hopeless()?.let { if (it) r.hopeless++ else r.hopeless = 0u }
|
// The judge's answer, given up to two seconds more (a slow phone, an engine
|
||||||
|
// just started): an offer comes when it is due, not turns later.
|
||||||
|
r.judge?.let { j ->
|
||||||
|
var verdict = j.hopeless()
|
||||||
|
var waited = 0
|
||||||
|
while (verdict == null && waited < 2000) {
|
||||||
|
delay(100)
|
||||||
|
waited += 100
|
||||||
|
verdict = j.hopeless()
|
||||||
|
}
|
||||||
|
if (gen != r.generation) return@LaunchedEffect
|
||||||
|
verdict?.let { if (it) r.hopeless++ else r.hopeless = 0u }
|
||||||
|
}
|
||||||
if (!r.playOn && r.hopeless >= uniffi.mobile_api.hopelessTurns()) {
|
if (!r.playOn && r.hopeless >= uniffi.mobile_api.hopelessTurns()) {
|
||||||
r.offer.value = true
|
r.offer.value = true
|
||||||
app.sounds.play(io.github.vrubelroman.chesspenguin.data.Sound.Defeat)
|
app.sounds.play(io.github.vrubelroman.chesspenguin.data.Sound.Defeat)
|
||||||
|
|
@ -508,6 +526,21 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
var resigning by remember { mutableStateOf(false) }
|
var resigning by remember { mutableStateOf(false) }
|
||||||
// The result card closed with ×: until the next game.
|
// The result card closed with ×: until the next game.
|
||||||
var resultClosed by remember(run) { mutableStateOf(false) }
|
var resultClosed by remember(run) { mutableStateOf(false) }
|
||||||
|
// A change after the end (a variation, an undo): the card's result may not hold.
|
||||||
|
val atEnd = remember(runOver) { g?.let { lineEnd(it) } }
|
||||||
|
LaunchedEffect(g) {
|
||||||
|
if (runOver != null && atEnd != null && g != null && lineEnd(g) != atEnd) resultClosed = true
|
||||||
|
}
|
||||||
|
var maiaRetry by remember { mutableStateOf(false) }
|
||||||
|
val maiaState by app.maiaFiles.download.state.collectAsState()
|
||||||
|
LaunchedEffect(maiaState, maiaRetry) {
|
||||||
|
if (maiaRetry && maiaState == NetState.Ready) {
|
||||||
|
maiaRetry = false
|
||||||
|
run?.player?.close()
|
||||||
|
run?.player = null
|
||||||
|
run?.failure?.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
val eventText = stringResource(R.string.play_event)
|
val eventText = stringResource(R.string.play_event)
|
||||||
val noteText = stringResource(R.string.play_note_from, (run?.meta?.strength ?: 0).toString())
|
val noteText = stringResource(R.string.play_note_from, (run?.meta?.strength ?: 0).toString())
|
||||||
// The same strength again, colours swapped; from a position: the same one and colour.
|
// The same strength again, colours swapped; from a position: the same one and colour.
|
||||||
|
|
@ -525,6 +558,9 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
}
|
}
|
||||||
beginMaiaGame(app, base, m.strength, if (m.floor > 0) m.userWhite else !m.userWhite, m.name, m.floor, eventText, noteText)
|
beginMaiaGame(app, base, m.strength, if (m.floor > 0) m.userWhite else !m.userWhite, m.name, m.floor, eventText, noteText)
|
||||||
base.close()
|
base.close()
|
||||||
|
// The report of the game before is not this one's.
|
||||||
|
review.close()
|
||||||
|
reviewHidden = true
|
||||||
held.key = null
|
held.key = null
|
||||||
held.reloads.intValue++
|
held.reloads.intValue++
|
||||||
}
|
}
|
||||||
|
|
@ -533,11 +569,14 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
val gg = g ?: return
|
val gg = g ?: return
|
||||||
val e = edit ?: return
|
val e = edit ?: return
|
||||||
val end = lineEnd(gg)
|
val end = lineEnd(gg)
|
||||||
// While Maia thinks the last move is the user's; else hers, and the user's before.
|
// While Maia thinks or offers to resign, the last move is the user's; else hers, and
|
||||||
val from = if (r.thinking.value) end else gg.nodes[end].parent?.toInt() ?: return
|
// the user's before.
|
||||||
|
val userLast = r.thinking.value || r.offer.value
|
||||||
|
val from = if (userLast) end else gg.nodes[end].parent?.toInt() ?: return
|
||||||
if (depth(gg, from) <= r.meta.floor) return
|
if (depth(gg, from) <= r.meta.floor) return
|
||||||
r.generation++
|
r.generation++
|
||||||
r.thinking.value = false
|
r.thinking.value = false
|
||||||
|
r.offer.value = false
|
||||||
r.judge?.forget()
|
r.judge?.forget()
|
||||||
r.hopeless = 0u
|
r.hopeless = 0u
|
||||||
runCatching { e.deleteFrom(from.toUInt()) }.getOrNull()?.let {
|
runCatching { e.deleteFrom(from.toUInt()) }.getOrNull()?.let {
|
||||||
|
|
@ -605,7 +644,11 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
// A copy saved into an own database is that database's game from then on.
|
// A copy saved into an own database is that database's game from then on.
|
||||||
val asksOnLeave = modified && (ownGame || newGame || held.savedTo != null || (playGame && runOver != null))
|
val asksOnLeave = modified && (ownGame || newGame || held.savedTo != null || (playGame && runOver != null))
|
||||||
val exit: () -> Unit = {
|
val exit: () -> Unit = {
|
||||||
if (playGame && held.play.value?.over?.value != null) app.maiaGames.clear()
|
val r = held.play.value
|
||||||
|
val gg = game
|
||||||
|
// Over, or no move made yet: nothing to put aside.
|
||||||
|
val empty = r != null && gg != null && depth(gg, lineEnd(gg)) <= r.meta.floor
|
||||||
|
if (playGame && (r?.over?.value != null || empty)) app.maiaGames.clear()
|
||||||
onBack()
|
onBack()
|
||||||
}
|
}
|
||||||
// What leaving's question leads to (back, or a rematch).
|
// What leaving's question leads to (back, or a rematch).
|
||||||
|
|
@ -691,7 +734,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
}
|
}
|
||||||
PlayControls(
|
PlayControls(
|
||||||
// While Maia thinks the last move is the user's; else hers and the user's before.
|
// While Maia thinks the last move is the user's; else hers and the user's before.
|
||||||
canTakeBack = if (runThinking) endDepth > floor else endDepth - 1 > floor,
|
canTakeBack = if (runThinking || runOffer) endDepth > floor else endDepth - 1 > floor,
|
||||||
started = endDepth - floor >= 2,
|
started = endDepth - floor >= 2,
|
||||||
canBack = canBack,
|
canBack = canBack,
|
||||||
canForward = canForward,
|
canForward = canForward,
|
||||||
|
|
@ -859,16 +902,25 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
run.offer.value = false
|
run.offer.value = false
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
runFailure != null -> Text(
|
runFailure != null -> FailureCard(
|
||||||
stringResource(R.string.play_maia_failed, runFailure),
|
onRetry = {
|
||||||
Modifier.padding(16.dp),
|
// A missing or damaged file is fetched again, then she starts.
|
||||||
color = MaterialTheme.colorScheme.error,
|
app.maiaFiles.download.delete()
|
||||||
|
app.maiaFiles.download.download()
|
||||||
|
maiaRetry = true
|
||||||
|
},
|
||||||
|
onAbort = {
|
||||||
|
app.maiaGames.clear()
|
||||||
|
onBack()
|
||||||
|
},
|
||||||
)
|
)
|
||||||
runOver != null && !resultClosed -> ResultCard(
|
runOver != null && !resultClosed -> ResultCard(
|
||||||
runOver,
|
runOver,
|
||||||
saved = held.savedTo != null && !modified,
|
saved = held.savedTo != null && !modified,
|
||||||
onAnalyse = {
|
onAnalyse = {
|
||||||
val e = edit
|
val e = edit
|
||||||
|
// The report takes the place: the card would be squeezed.
|
||||||
|
resultClosed = true
|
||||||
if (e != null) scope.launch {
|
if (e != null) scope.launch {
|
||||||
review.openSession("${held.key}/${System.nanoTime()}", e)
|
review.openSession("${held.key}/${System.nanoTime()}", e)
|
||||||
reviewHidden = false
|
reviewHidden = false
|
||||||
|
|
@ -1222,6 +1274,17 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val askAt = askFrom
|
||||||
|
val adjournedMeta = app.maiaGames.current.collectAsState().value
|
||||||
|
if (askAt != null && adjournedMeta != null) {
|
||||||
|
AdjournedQuestion(adjournedMeta, onContinue = {
|
||||||
|
askFrom = null
|
||||||
|
onPlayGame()
|
||||||
|
}, onNew = {
|
||||||
|
askFrom = null
|
||||||
|
playFrom = askAt
|
||||||
|
}, onDismiss = { askFrom = null })
|
||||||
|
}
|
||||||
if (resigning) {
|
if (resigning) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { resigning = false },
|
onDismissRequest = { resigning = false },
|
||||||
|
|
@ -1250,7 +1313,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
canPlay = !n.nullMove && n.end.isEmpty() && !gameOn,
|
canPlay = !n.nullMove && n.end.isEmpty() && !gameOn,
|
||||||
onPlay = {
|
onPlay = {
|
||||||
moveSheet = null
|
moveSheet = null
|
||||||
playFrom = sheetMove
|
if (app.maiaGames.current.value?.over == false) askFrom = sheetMove else playFrom = sheetMove
|
||||||
},
|
},
|
||||||
onTrain = {
|
onTrain = {
|
||||||
moveSheet = null
|
moveSheet = null
|
||||||
|
|
@ -1258,6 +1321,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
||||||
preview = null
|
preview = null
|
||||||
held.trainPly = 0
|
held.trainPly = 0
|
||||||
held.trainFlipped = flipped
|
held.trainFlipped = flipped
|
||||||
|
held.trainReturn = sheetMove
|
||||||
held.trainer.value = t
|
held.trainer.value = t
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -218,3 +218,28 @@ fun beginMaiaGame(
|
||||||
session.markSaved()
|
session.markSaved()
|
||||||
app.maiaGames.begin(session.pgn(), PlayMeta(strength, userWhite, name, floor))
|
app.maiaGames.begin(session.pgn(), PlayMeta(strength, userWhite, name, floor))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Maia did not start (§31.3): her file again, or leave the game.
|
||||||
|
@Composable
|
||||||
|
fun FailureCard(onRetry: () -> Unit, onAbort: () -> Unit) {
|
||||||
|
Card {
|
||||||
|
Text(stringResource(R.string.play_maia_stopped), style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.error)
|
||||||
|
Row(Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
|
Button(onClick = onRetry, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_maia_reload), maxLines = 1, overflow = TextOverflow.Ellipsis) }
|
||||||
|
OutlinedButton(onClick = onAbort, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_abort), maxLines = 1) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A new game while one is put aside (§31.7): go on with that one, or begin anew (it is
|
||||||
|
/// replaced).
|
||||||
|
@Composable
|
||||||
|
fun AdjournedQuestion(meta: PlayMeta, onContinue: () -> Unit, onNew: () -> Unit, onDismiss: () -> Unit) {
|
||||||
|
androidx.compose.material3.AlertDialog(
|
||||||
|
onDismissRequest = onDismiss,
|
||||||
|
title = { Text(stringResource(R.string.play_adjourned_q, meta.strength.toString())) },
|
||||||
|
text = { Text(stringResource(R.string.play_adjourned_new_text)) },
|
||||||
|
confirmButton = { androidx.compose.material3.TextButton(onClick = onContinue) { Text(stringResource(R.string.play_continue_it)) } },
|
||||||
|
dismissButton = { androidx.compose.material3.TextButton(onClick = onNew) { Text(stringResource(R.string.play_start_new)) } },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ class GameEdit : ViewModel() {
|
||||||
val reloads = androidx.compose.runtime.mutableIntStateOf(0)
|
val reloads = androidx.compose.runtime.mutableIntStateOf(0)
|
||||||
var trainPly = 0
|
var trainPly = 0
|
||||||
var trainFlipped = false
|
var trainFlipped = false
|
||||||
|
/// The move the trainer was opened from: the game shows it again after.
|
||||||
|
var trainReturn: Int? = null
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
trainer.value?.close()
|
trainer.value?.close()
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
|
|
@ -147,7 +148,8 @@ fun TrainScreen(trainer: Trainer, ply0: Int, startFlipped: Boolean, onPly: (Int)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
) { padding ->
|
) { padding ->
|
||||||
Column(Modifier.fillMaxSize().padding(padding)) {
|
val landscape = androidx.compose.ui.platform.LocalConfiguration.current.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE
|
||||||
|
val task: @Composable () -> Unit = {
|
||||||
if (!st.done) {
|
if (!st.done) {
|
||||||
// The task: which move, whose turn, how far.
|
// The task: which move, whose turn, how far.
|
||||||
val whiteToMove = st.fen.substringAfter(' ').startsWith("w")
|
val whiteToMove = st.fen.substringAfter(' ').startsWith("w")
|
||||||
|
|
@ -159,6 +161,8 @@ fun TrainScreen(trainer: Trainer, ply0: Int, startFlipped: Boolean, onPly: (Int)
|
||||||
LinearProgressIndicator(progress = { ply.toFloat() / st.length.toInt().coerceAtLeast(1) }, modifier = Modifier.fillMaxWidth().padding(top = 4.dp))
|
LinearProgressIndicator(progress = { ply.toFloat() / st.length.toInt().coerceAtLeast(1) }, modifier = Modifier.fillMaxWidth().padding(top = 4.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
val boardBox: @Composable (Modifier) -> Unit = { m ->
|
||||||
val w = wrong
|
val w = wrong
|
||||||
Board(
|
Board(
|
||||||
fen = w?.fen ?: st.fen,
|
fen = w?.fen ?: st.fen,
|
||||||
|
|
@ -171,7 +175,7 @@ fun TrainScreen(trainer: Trainer, ply0: Int, startFlipped: Boolean, onPly: (Int)
|
||||||
description = stringResource(R.string.train_title),
|
description = stringResource(R.string.train_title),
|
||||||
arrows = st.hint?.let { listOf(BoardArrow(it[0], it[1], EngineArrow)) } ?: emptyList(),
|
arrows = st.hint?.let { listOf(BoardArrow(it[0], it[1], EngineArrow)) } ?: emptyList(),
|
||||||
animated = prefs.animation,
|
animated = prefs.animation,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = m,
|
||||||
input = if (st.done || w != null) null else BoardInput(
|
input = if (st.done || w != null) null else BoardInput(
|
||||||
remember(ply, changes) { trainer.legalMoves(ply.toUInt()) },
|
remember(ply, changes) { trainer.legalMoves(ply.toUInt()) },
|
||||||
onMove = ::move,
|
onMove = ::move,
|
||||||
|
|
@ -180,6 +184,8 @@ fun TrainScreen(trainer: Trainer, ply0: Int, startFlipped: Boolean, onPly: (Int)
|
||||||
),
|
),
|
||||||
alert = w?.let { it.from to it.to },
|
alert = w?.let { it.from to it.to },
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
val you: @Composable () -> Unit = {
|
||||||
if (!st.done) {
|
if (!st.done) {
|
||||||
// You: the mistakes of this run, or before the first move what was before.
|
// You: the mistakes of this run, or before the first move what was before.
|
||||||
Row(Modifier.fillMaxWidth().height(48.dp).padding(start = 16.dp, end = 4.dp), verticalAlignment = Alignment.CenterVertically) {
|
Row(Modifier.fillMaxWidth().height(48.dp).padding(start = 16.dp, end = 4.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
|
@ -213,6 +219,8 @@ fun TrainScreen(trainer: Trainer, ply0: Int, startFlipped: Boolean, onPly: (Int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
val notes: @Composable androidx.compose.foundation.layout.ColumnScope.() -> Unit = {
|
||||||
Column(Modifier.weight(1f).fillMaxWidth().verticalScroll(rememberScrollState())) {
|
Column(Modifier.weight(1f).fillMaxWidth().verticalScroll(rememberScrollState())) {
|
||||||
if (st.done) Result(st, onAgain = {
|
if (st.done) Result(st, onAgain = {
|
||||||
trainer.again()
|
trainer.again()
|
||||||
|
|
@ -231,6 +239,24 @@ fun TrainScreen(trainer: Trainer, ply0: Int, startFlipped: Boolean, onPly: (Int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// A phone on its side: the board at full height, the rest beside it.
|
||||||
|
if (landscape) {
|
||||||
|
Row(Modifier.fillMaxSize().padding(padding)) {
|
||||||
|
boardBox(Modifier.fillMaxHeight())
|
||||||
|
Column(Modifier.weight(1f).fillMaxHeight()) {
|
||||||
|
task()
|
||||||
|
you()
|
||||||
|
notes()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Column(Modifier.fillMaxSize().padding(padding)) {
|
||||||
|
task()
|
||||||
|
boardBox(Modifier.fillMaxWidth())
|
||||||
|
you()
|
||||||
|
notes()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -521,4 +521,10 @@
|
||||||
<string name="play_on_short">Weiterspielen</string>
|
<string name="play_on_short">Weiterspielen</string>
|
||||||
<string name="play_viewing">Ansicht %1$s · zurück zur Partie ›</string>
|
<string name="play_viewing">Ansicht %1$s · zurück zur Partie ›</string>
|
||||||
<string name="start_position">die Ausgangsstellung</string>
|
<string name="start_position">die Ausgangsstellung</string>
|
||||||
|
<string name="play_maia_stopped">Maia ist nicht gestartet.</string>
|
||||||
|
<string name="play_maia_reload">Maia neu herunterladen</string>
|
||||||
|
<string name="play_adjourned_q">Eine Partie gegen Maia %1$s ist zurückgestellt</string>
|
||||||
|
<string name="play_continue_it">Fortsetzen</string>
|
||||||
|
<string name="play_start_new">Neue beginnen</string>
|
||||||
|
<string name="play_adjourned_new_text">Eine neue Partie ersetzt sie.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -529,4 +529,10 @@
|
||||||
<string name="play_on_short">Seguir</string>
|
<string name="play_on_short">Seguir</string>
|
||||||
<string name="play_viewing">Viendo %1$s · volver a la partida ›</string>
|
<string name="play_viewing">Viendo %1$s · volver a la partida ›</string>
|
||||||
<string name="start_position">la posición inicial</string>
|
<string name="start_position">la posición inicial</string>
|
||||||
|
<string name="play_maia_stopped">Maia no se inició.</string>
|
||||||
|
<string name="play_maia_reload">Volver a descargar Maia</string>
|
||||||
|
<string name="play_adjourned_q">Hay una partida aplazada contra Maia %1$s</string>
|
||||||
|
<string name="play_continue_it">Continuarla</string>
|
||||||
|
<string name="play_start_new">Empezar una nueva</string>
|
||||||
|
<string name="play_adjourned_new_text">Una partida nueva la sustituye.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -529,4 +529,10 @@
|
||||||
<string name="play_on_short">Continuer</string>
|
<string name="play_on_short">Continuer</string>
|
||||||
<string name="play_viewing">Consultation %1$s · retour à la partie ›</string>
|
<string name="play_viewing">Consultation %1$s · retour à la partie ›</string>
|
||||||
<string name="start_position">la position initiale</string>
|
<string name="start_position">la position initiale</string>
|
||||||
|
<string name="play_maia_stopped">Maia n’a pas démarré.</string>
|
||||||
|
<string name="play_maia_reload">Retélécharger Maia</string>
|
||||||
|
<string name="play_adjourned_q">Une partie contre Maia %1$s est en attente</string>
|
||||||
|
<string name="play_continue_it">La continuer</string>
|
||||||
|
<string name="play_start_new">En commencer une nouvelle</string>
|
||||||
|
<string name="play_adjourned_new_text">Une nouvelle partie la remplace.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -529,4 +529,10 @@
|
||||||
<string name="play_on_short">Continua</string>
|
<string name="play_on_short">Continua</string>
|
||||||
<string name="play_viewing">Visione %1$s · torna alla partita ›</string>
|
<string name="play_viewing">Visione %1$s · torna alla partita ›</string>
|
||||||
<string name="start_position">la posizione iniziale</string>
|
<string name="start_position">la posizione iniziale</string>
|
||||||
|
<string name="play_maia_stopped">Maia non si è avviata.</string>
|
||||||
|
<string name="play_maia_reload">Riscarica Maia</string>
|
||||||
|
<string name="play_adjourned_q">C’è una partita sospesa contro Maia %1$s</string>
|
||||||
|
<string name="play_continue_it">Continuala</string>
|
||||||
|
<string name="play_start_new">Iniziarne una nuova</string>
|
||||||
|
<string name="play_adjourned_new_text">Una nuova partita la sostituisce.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -522,4 +522,10 @@
|
||||||
<string name="play_on_short">Жалғастыру</string>
|
<string name="play_on_short">Жалғастыру</string>
|
||||||
<string name="play_viewing">Қарау %1$s · ойынға оралу ›</string>
|
<string name="play_viewing">Қарау %1$s · ойынға оралу ›</string>
|
||||||
<string name="start_position">бастапқы позиция</string>
|
<string name="start_position">бастапқы позиция</string>
|
||||||
|
<string name="play_maia_stopped">Maia іске қосылмады.</string>
|
||||||
|
<string name="play_maia_reload">Maia-ны қайта жүктеу</string>
|
||||||
|
<string name="play_adjourned_q">Maia %1$s-мен кейінге қалдырылған ойын бар</string>
|
||||||
|
<string name="play_continue_it">Жалғастыру</string>
|
||||||
|
<string name="play_start_new">Жаңасын бастау</string>
|
||||||
|
<string name="play_adjourned_new_text">Жаңа ойын оның орнын басады.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -530,4 +530,10 @@
|
||||||
<string name="play_on_short">Continuar</string>
|
<string name="play_on_short">Continuar</string>
|
||||||
<string name="play_viewing">Vendo %1$s · voltar à partida ›</string>
|
<string name="play_viewing">Vendo %1$s · voltar à partida ›</string>
|
||||||
<string name="start_position">a posição inicial</string>
|
<string name="start_position">a posição inicial</string>
|
||||||
|
<string name="play_maia_stopped">A Maia não iniciou.</string>
|
||||||
|
<string name="play_maia_reload">Baixar a Maia de novo</string>
|
||||||
|
<string name="play_adjourned_q">Há uma partida adiada contra a Maia %1$s</string>
|
||||||
|
<string name="play_continue_it">Continuá-la</string>
|
||||||
|
<string name="play_start_new">Começar uma nova</string>
|
||||||
|
<string name="play_adjourned_new_text">Uma nova partida a substitui.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -467,7 +467,7 @@
|
||||||
<string name="train_streak">без ошибок подряд: %1$s</string>
|
<string name="train_streak">без ошибок подряд: %1$s</string>
|
||||||
<string name="train_recent">Последние: %1$s</string>
|
<string name="train_recent">Последние: %1$s</string>
|
||||||
<string name="train_arrow">Сделайте ход со стрелки</string>
|
<string name="train_arrow">Сделайте ход со стрелки</string>
|
||||||
<string name="train_again">↻ Повторить</string>
|
<string name="train_again">↻ Ещё раз</string>
|
||||||
<string name="train_back">⬅ К партии</string>
|
<string name="train_back">⬅ К партии</string>
|
||||||
<string name="train_restart">Сначала</string>
|
<string name="train_restart">Сначала</string>
|
||||||
<plurals name="train_runs">
|
<plurals name="train_runs">
|
||||||
|
|
@ -535,6 +535,12 @@
|
||||||
<string name="elo">Эло</string>
|
<string name="elo">Эло</string>
|
||||||
<string name="play_analyse_short">Анализ</string>
|
<string name="play_analyse_short">Анализ</string>
|
||||||
<string name="play_on_short">Доиграть</string>
|
<string name="play_on_short">Доиграть</string>
|
||||||
<string name="play_viewing">Просмотр %1$s · к игре ›</string>
|
<string name="play_viewing">Просмотр: %1$s · к игре ›</string>
|
||||||
<string name="start_position">начальная позиция</string>
|
<string name="start_position">начальная позиция</string>
|
||||||
|
<string name="play_maia_stopped">Maia не запустилась.</string>
|
||||||
|
<string name="play_maia_reload">Скачать Maia заново</string>
|
||||||
|
<string name="play_adjourned_q">Есть отложенная партия с Maia %1$s</string>
|
||||||
|
<string name="play_continue_it">Продолжить её</string>
|
||||||
|
<string name="play_start_new">Начать новую</string>
|
||||||
|
<string name="play_adjourned_new_text">Новая партия заменит её.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -520,4 +520,10 @@
|
||||||
<string name="play_on_short">Davom etish</string>
|
<string name="play_on_short">Davom etish</string>
|
||||||
<string name="play_viewing">Ko‘rish %1$s · o‘yinga qaytish ›</string>
|
<string name="play_viewing">Ko‘rish %1$s · o‘yinga qaytish ›</string>
|
||||||
<string name="start_position">boshlang‘ich pozitsiya</string>
|
<string name="start_position">boshlang‘ich pozitsiya</string>
|
||||||
|
<string name="play_maia_stopped">Maia ishga tushmadi.</string>
|
||||||
|
<string name="play_maia_reload">Maia’ni qayta yuklab olish</string>
|
||||||
|
<string name="play_adjourned_q">Maia %1$s bilan to‘xtatilgan o‘yin bor</string>
|
||||||
|
<string name="play_continue_it">Davom ettirish</string>
|
||||||
|
<string name="play_start_new">Yangisini boshlash</string>
|
||||||
|
<string name="play_adjourned_new_text">Yangi o‘yin uning o‘rnini oladi.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -523,6 +523,12 @@
|
||||||
<string name="elo">Elo</string>
|
<string name="elo">Elo</string>
|
||||||
<string name="play_analyse_short">Analyse</string>
|
<string name="play_analyse_short">Analyse</string>
|
||||||
<string name="play_on_short">Play on</string>
|
<string name="play_on_short">Play on</string>
|
||||||
<string name="play_viewing">Viewing %1$s · back to the game ›</string>
|
<string name="play_viewing">Viewing: %1$s · back to the game ›</string>
|
||||||
<string name="start_position">the starting position</string>
|
<string name="start_position">the starting position</string>
|
||||||
|
<string name="play_maia_stopped">Maia did not start.</string>
|
||||||
|
<string name="play_maia_reload">Download Maia again</string>
|
||||||
|
<string name="play_adjourned_q">There is a game put aside against Maia %1$s</string>
|
||||||
|
<string name="play_continue_it">Continue it</string>
|
||||||
|
<string name="play_start_new">Start a new one</string>
|
||||||
|
<string name="play_adjourned_new_text">A new game replaces it.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue