Skip to content

Commit

Permalink
Don't discard crossedline colour which is now used
Browse files Browse the repository at this point in the history
Also don't crash if nightColours isn't long enough
  • Loading branch information
chrisboyle committed Nov 15, 2023
1 parent c5ef70f commit b89a31a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions app/src/main/kotlin/name/boyle/chris/sgtpuzzles/GameView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,12 @@ class GameView(context: Context, attrs: AttributeSet?) : View(context, attrs), V
@ColorRes val nightColours = whichBackend.nightColours // doesn't include background
for (i in 1 until colours.size) {
//Log.d("GameView", "\t<color name=\"" + resourceName + "\">" + String.format("#%06x", (0xFFFFFF & colours[i])) + "</color>");
@ColorRes val nightRes = nightColours[i - 1]
if (nightRes != 0) {
colours[i] = ContextCompat.getColor(context, nightRes)
}
if (nightColours.size >= i) {
@ColorRes val nightRes = nightColours[i - 1]
if (nightRes != 0) {
colours[i] = ContextCompat.getColor(context, nightRes)
}
} // else GenerateBackendsTask is broken, but don't crash
}
}
if (colours.isNotEmpty()) {
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/GenerateBackendsTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ abstract class GenerateBackendsTask: DefaultTask() {
definedKeyIcons: Set<String>
): String {
val sourceText = jniDir.file("${puz}.c").get().asFile.readText()
// skip first colour which is usually COL_BACKGROUND, except in Untangle
val colourNames = (Regex("""enum\s+\{\s*COL_[^,]+,\s*(COL_[^}]+)}""").find(sourceText)
?.run { parseEnumMembers(puz, groupValues[1]) } ?: listOf())
.map { "${puz}_night_colour_${it}" }
Expand Down Expand Up @@ -108,7 +109,7 @@ abstract class GenerateBackendsTask: DefaultTask() {
.replace(Regex("""#[^\n]*\n"""), "")
.trim().split(",").map { it.trim().removePrefix("COL_").lowercase(Locale.ROOT) }
.filter { Regex("""^[^=]+$""").containsMatchIn(it) }
.minus(setOf("ncolours", "crossedline"))
.minus(setOf("ncolours"))
.plus(if (puz == "signpost") ("bmdx".flatMap { c -> (0..15).map { "$c$it" } }
.drop(1)) else setOf()))
.map { it.apply { if (contains(Regex("""[^a-z\d_]"""))) {
Expand Down

0 comments on commit b89a31a

Please sign in to comment.