Auto-commit after successful build: update app gameplay/UI, improve build setup, update docs/config
Changed files:\nREADME.md app/build.gradle.kts app/src/main/java/com/kawomi/githugandroid/GameModels.kt app/src/main/java/com/kawomi/githugandroid/GitHugApp.kt app/src/main/java/com/kawomi/githugandroid/GitRuntime.kt
This commit is contained in:
@@ -32,6 +32,7 @@ import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.text.TextRange
|
||||
@@ -73,15 +74,17 @@ private val GitHugColorScheme = darkColorScheme(
|
||||
@Composable
|
||||
fun GitHugApp() {
|
||||
MaterialTheme(colorScheme = GitHugColorScheme) {
|
||||
val context = LocalContext.current
|
||||
val levels = remember { sampleLevels() }
|
||||
val runtime = remember(context) { GitRepositoryRuntime(context.applicationContext) }
|
||||
val screenScrollState = rememberScrollState()
|
||||
var currentLevelIndex by remember { mutableStateOf(0) }
|
||||
var mode by remember { mutableStateOf(PlayMode.CLI_ONLY) }
|
||||
var repo by remember { mutableStateOf(levels.first().setup()) }
|
||||
var repo by remember { mutableStateOf(runtime.prepareLevel(levels.first())) }
|
||||
var commandInput by remember { mutableStateOf(TextFieldValue("")) }
|
||||
var inputFieldVersion by remember { mutableStateOf(0) }
|
||||
var suppressedImeEcho by remember { mutableStateOf<String?>(null) }
|
||||
var output by remember { mutableStateOf(listOf("Welcome to GitHug Android.")) }
|
||||
var output by remember { mutableStateOf(listOf(runtime.startupBanner())) }
|
||||
var hintIndex by remember { mutableStateOf(0) }
|
||||
var completedLevels by remember { mutableStateOf(setOf<String>()) }
|
||||
var commandHistory by remember { mutableStateOf(listOf<String>()) }
|
||||
@@ -101,7 +104,7 @@ fun GitHugApp() {
|
||||
}
|
||||
|
||||
fun resetCurrentLevel(message: String = "Level reset.") {
|
||||
repo = currentLevel.setup()
|
||||
repo = runtime.prepareLevel(currentLevel)
|
||||
clearCommandInput()
|
||||
suppressedImeEcho = null
|
||||
output = listOf(message)
|
||||
@@ -176,7 +179,7 @@ fun GitHugApp() {
|
||||
historyIndex = -1
|
||||
historyDraft = ""
|
||||
|
||||
val (newRepo, lines) = GitSandboxEngine.execute(repo, raw)
|
||||
val (newRepo, lines) = runtime.execute(currentLevel, repo, raw)
|
||||
val solvedAfterCommand = currentLevel.validator(newRepo)
|
||||
val wasAlreadyCompleted = currentLevel.id in completedLevels
|
||||
val newOutput = buildList {
|
||||
@@ -194,7 +197,7 @@ fun GitHugApp() {
|
||||
val nextLevelIndex = currentLevelIndex + 1
|
||||
val nextLevel = levels[nextLevelIndex]
|
||||
currentLevelIndex = nextLevelIndex
|
||||
repo = nextLevel.setup()
|
||||
repo = runtime.prepareLevel(nextLevel)
|
||||
output = listOf("Loaded level: ${nextLevel.title}")
|
||||
clearCommandInput()
|
||||
suppressedImeEcho = null
|
||||
@@ -212,7 +215,7 @@ fun GitHugApp() {
|
||||
}
|
||||
|
||||
fun showCommandHelp() {
|
||||
output = output + GitSandboxEngine.commandReferenceLines()
|
||||
output = output + runtime.commandReferenceLines()
|
||||
}
|
||||
|
||||
Scaffold { padding ->
|
||||
@@ -231,7 +234,7 @@ fun GitHugApp() {
|
||||
) {
|
||||
Header(levels, currentLevelIndex, completedLevels) { index ->
|
||||
currentLevelIndex = index
|
||||
repo = levels[index].setup()
|
||||
repo = runtime.prepareLevel(levels[index])
|
||||
output = listOf("Loaded level: ${levels[index].title}")
|
||||
clearCommandInput()
|
||||
suppressedImeEcho = null
|
||||
|
||||
Reference in New Issue
Block a user