Skip to content

Commit

Permalink
Tag descriptions directly while I'm at it
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisboyle committed Apr 30, 2022
1 parent ff81aae commit d51f726
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 45 deletions.
8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,25 @@ project.extensions.findByName("android").applicationVariants.all { variant ->
out.text = """package name.boyle.chris.sgtpuzzles;
|import java.util.Collections;
|import java.util.LinkedHashMap;
|import java.util.Locale;
|import java.util.Map;
|import androidx.annotation.DrawableRes;
|import androidx.annotation.StringRes;
|import androidx.annotation.NonNull;
|import androidx.annotation.Nullable;
|
|/** Names of all the backends. Automatically generated file, do not modify. */
|public enum BackendName {
| ${backends.collect {"${it[0].toUpperCase(Locale.ROOT)}(\"${it[1]}\", R.drawable.day_${it[0]}, R.drawable.night_${it[0]}, ${it[2]})"}.join(",\n ")};
| ${backends.collect {"${it[0].toUpperCase(Locale.ROOT)}(\"${it[1]}\", R.drawable.day_${it[0]}, R.drawable.night_${it[0]}, ${it[2]}, R.string.desc_${it[0]})"}.join(",\n ")};
| private final String _displayName;
| private final String[] _colours;
| @DrawableRes private final int _dayIcon, _nightIcon;
| private BackendName(@NonNull final String displayName, @DrawableRes final int dayIcon, @DrawableRes final int nightIcon, @NonNull final String[] colours) { _displayName = displayName; _dayIcon = dayIcon; _nightIcon = nightIcon; _colours = colours; }
| @StringRes private final int _description;
| private BackendName(@NonNull final String displayName, @DrawableRes final int dayIcon, @DrawableRes final int nightIcon, @NonNull final String[] colours, @StringRes final int description) { _displayName = displayName; _dayIcon = dayIcon; _nightIcon = nightIcon; _colours = colours; _description = description; }
| @NonNull public String getDisplayName() { return _displayName; }
| @DrawableRes public int getDayIcon() { return _dayIcon; }
| @DrawableRes public int getNightIcon() { return _nightIcon; }
| @StringRes public int getDescription() { return _description; }
| @NonNull public String[] getColours() { return _colours; }
| @NonNull public String toString() { return name().toLowerCase(Locale.ROOT); }
| private static final Map<String, BackendName> BY_DISPLAY_NAME, BY_LOWERCASE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,10 @@ private void buildViews()
R.layout.list_item, table, false);
final LayerDrawable starredIcon = mkStarryIcon(backend);
((ImageView)views[i].findViewById(R.id.icon)).setImageDrawable(starredIcon);
final int descId = getResources().getIdentifier("desc_"+backend, "string", getPackageName());
SpannableStringBuilder desc = new SpannableStringBuilder(backend.getDisplayName());
desc.setSpan(new TextAppearanceSpan(this, R.style.ChooserItemName),
0, desc.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
desc.append(": ").append(getString(descId > 0 ? descId : R.string.no_desc));
desc.append(": ").append(getString(backend.getDescription()));
final TextView textView = views[i].findViewById(R.id.text);
textView.setText(desc);
textView.setVisibility(useGrid ? View.GONE : View.VISIBLE);
Expand Down
81 changes: 40 additions & 41 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,47 +153,46 @@ Version %s"</string>
<!-- These are for the game chooser (detail mode) -->
<!-- Titles are mostly provided from CMake but we override this as "Train Tracks" is too wide for some screens -->
<string name="title_tracks">Tracks</string>
<string name="no_desc">(no summary available)</string>
<string tools:ignore="UnusedResources" name="desc_blackbox">Locate the balls inside the box by firing lasers and observing how they are deflected or absorbed.</string>
<string tools:ignore="UnusedResources" name="desc_bridges">Connect the islands with the given bridge counts so no bridges are crossing.</string>
<string tools:ignore="UnusedResources" name="desc_cube">Roll the cube to collect all the paint.</string>
<string tools:ignore="UnusedResources" name="desc_dominosa">Pair the numbers to form a complete and distinct set of dominoes.</string>
<string tools:ignore="UnusedResources" name="desc_fifteen">Slide tiles around to form a grid in numerical order.</string>
<string tools:ignore="UnusedResources" name="desc_filling">Number the squares to form regions with the same number, which is also the size of the region.</string>
<string tools:ignore="UnusedResources" name="desc_flip">Turn over squares until all are light side up, but flipping one flips its neighbours.</string>
<string tools:ignore="UnusedResources" name="desc_flood">Try to get the whole grid to be the same colour within the given number of moves, by repeatedly flood-filling the top left corner in different colours.</string>
<string tools:ignore="UnusedResources" name="desc_galaxies">Divide the grid into 180-degree rotationally symmetric regions each centred on a dot.</string>
<string tools:ignore="UnusedResources" name="desc_guess">Guess the hidden colour sequence: black is correct, white is the correct colour in the wrong place.</string>
<string tools:ignore="UnusedResources" name="desc_inertia">Move the ball around to collect all the gems without hitting a mine.</string>
<string tools:ignore="UnusedResources" name="desc_keen">Enter digits so every row and column contains exactly one of each digit and the arithmetic clues are satisfied.</string>
<string tools:ignore="UnusedResources" name="desc_lightup">Place lamps so all squares are lit, no lamp lights another and numbered squares have the given number of adjacent lamps.</string>
<string tools:ignore="UnusedResources" name="desc_loopy">Draw a single unbroken and uncrossing line such that numbered squares have the given number of edges filled.</string>
<string tools:ignore="UnusedResources" name="desc_magnets">Place magnets and blanks to satisfy the +/- counts and avoid magnets repelling.</string>
<string tools:ignore="UnusedResources" name="desc_map">Copy the 4 colours to colour the map with no regions of the same colour touching.</string>
<string tools:ignore="UnusedResources" name="desc_mines">Uncover all squares except the mines using the given counts of adjacent mines. *N.B.* Game is generated after first move; you may see “not responding” warnings.</string>
<string tools:ignore="UnusedResources" name="desc_mosaic">Colour squares black or white. Clues give the number of black squares in the 3x3 region around (and including) the clue square itself.</string>
<string tools:ignore="UnusedResources" name="desc_net">Rotate tiles to connect all tiles (not just endpoints) to the centre tile.</string>
<string tools:ignore="UnusedResources" name="desc_netslide">Slide rows and columns to connect all tiles (not just endpoints) to the centre tile.</string>
<string tools:ignore="UnusedResources" name="desc_palisade">Draw lines along the grid edges, in such a way that the grid is divided into connected regions, all of the size shown in the status line. Also, each square containing a number should have that many of its edges drawn in.</string>
<string tools:ignore="UnusedResources" name="desc_pattern">Fill the grid so that the numbers are the length of each stretch of black tiles in order.</string>
<string tools:ignore="UnusedResources" name="desc_pearl">Draw a single loop with corners on black, before/after white, and not vice versa.</string>
<string tools:ignore="UnusedResources" name="desc_pegs">Remove pegs by jumping others over them, until only one is left.</string>
<string tools:ignore="UnusedResources" name="desc_range">Place black squares to limit the visible distance from each numbered cell.</string>
<string tools:ignore="UnusedResources" name="desc_rect">Divide the grid into rectangles containing only one number, which is also the area of the rectangle.</string>
<string tools:ignore="UnusedResources" name="desc_samegame">Remove groups (2 or more) of the same colour to clear the grid, scoring more for larger groups.</string>
<string tools:ignore="UnusedResources" name="desc_signpost">Connect the squares into a path following the arrows.</string>
<string tools:ignore="UnusedResources" name="desc_singles">Remove numbers so no number appears twice in any row/column, no two black squares are adjacent and the white squares are all connected.</string>
<string tools:ignore="UnusedResources" name="desc_sixteen">Slide rows and columns around to form a grid in numerical order.</string>
<string tools:ignore="UnusedResources" name="desc_slant">Draw diagonal lines in every square such that circles have the given numbers of lines meeting at them and there are no loops.</string>
<string tools:ignore="UnusedResources" name="desc_solo">Fill the grid so each block, row and column contains exactly one of each digit.</string>
<string tools:ignore="UnusedResources" name="desc_tents">Place tents so each tree has a separate adjacent tent (not diagonally), no tents are next to each other (even diagonally) and the row and column counts are correct.</string>
<string tools:ignore="UnusedResources" name="desc_towers">Place towers so each row/column contains one of each height and each clue matches the number of towers visible looking into the grid from that point.</string>
<string tools:ignore="UnusedResources" name="desc_tracks">Complete the track from A to B so that the rows and columns contain the numbers of track segments indicated. The track may not cross itself.</string>
<string tools:ignore="UnusedResources" name="desc_twiddle">Rotate groups of 4 to form a grid in numerical order.</string>
<string tools:ignore="UnusedResources" name="desc_undead">Fill the grid with monsters so the correct numbers of them can be seen from each point, taking mirrors into account.</string>
<string tools:ignore="UnusedResources" name="desc_unequal">Enter digits so every row and column contains exactly one of each digit and the greater-than signs are satisfied.</string>
<string tools:ignore="UnusedResources" name="desc_unruly">Colour every square either black or white such that no three consecutive squares, horizontally or vertically, are the same colour, and each row and column contains the same number of black and white squares.</string>
<string tools:ignore="UnusedResources" name="desc_untangle">Move points around until no lines cross.</string>
<string name="desc_blackbox">Locate the balls inside the box by firing lasers and observing how they are deflected or absorbed.</string>
<string name="desc_bridges">Connect the islands with the given bridge counts so no bridges are crossing.</string>
<string name="desc_cube">Roll the cube to collect all the paint.</string>
<string name="desc_dominosa">Pair the numbers to form a complete and distinct set of dominoes.</string>
<string name="desc_fifteen">Slide tiles around to form a grid in numerical order.</string>
<string name="desc_filling">Number the squares to form regions with the same number, which is also the size of the region.</string>
<string name="desc_flip">Turn over squares until all are light side up, but flipping one flips its neighbours.</string>
<string name="desc_flood">Try to get the whole grid to be the same colour within the given number of moves, by repeatedly flood-filling the top left corner in different colours.</string>
<string name="desc_galaxies">Divide the grid into 180-degree rotationally symmetric regions each centred on a dot.</string>
<string name="desc_guess">Guess the hidden colour sequence: black is correct, white is the correct colour in the wrong place.</string>
<string name="desc_inertia">Move the ball around to collect all the gems without hitting a mine.</string>
<string name="desc_keen">Enter digits so every row and column contains exactly one of each digit and the arithmetic clues are satisfied.</string>
<string name="desc_lightup">Place lamps so all squares are lit, no lamp lights another and numbered squares have the given number of adjacent lamps.</string>
<string name="desc_loopy">Draw a single unbroken and uncrossing line such that numbered squares have the given number of edges filled.</string>
<string name="desc_magnets">Place magnets and blanks to satisfy the +/- counts and avoid magnets repelling.</string>
<string name="desc_map">Copy the 4 colours to colour the map with no regions of the same colour touching.</string>
<string name="desc_mines">Uncover all squares except the mines using the given counts of adjacent mines. *N.B.* Game is generated after first move; you may see “not responding” warnings.</string>
<string name="desc_mosaic">Colour squares black or white. Clues give the number of black squares in the 3x3 region around (and including) the clue square itself.</string>
<string name="desc_net">Rotate tiles to connect all tiles (not just endpoints) to the centre tile.</string>
<string name="desc_netslide">Slide rows and columns to connect all tiles (not just endpoints) to the centre tile.</string>
<string name="desc_palisade">Draw lines along the grid edges, in such a way that the grid is divided into connected regions, all of the size shown in the status line. Also, each square containing a number should have that many of its edges drawn in.</string>
<string name="desc_pattern">Fill the grid so that the numbers are the length of each stretch of black tiles in order.</string>
<string name="desc_pearl">Draw a single loop with corners on black, before/after white, and not vice versa.</string>
<string name="desc_pegs">Remove pegs by jumping others over them, until only one is left.</string>
<string name="desc_range">Place black squares to limit the visible distance from each numbered cell.</string>
<string name="desc_rect">Divide the grid into rectangles containing only one number, which is also the area of the rectangle.</string>
<string name="desc_samegame">Remove groups (2 or more) of the same colour to clear the grid, scoring more for larger groups.</string>
<string name="desc_signpost">Connect the squares into a path following the arrows.</string>
<string name="desc_singles">Remove numbers so no number appears twice in any row/column, no two black squares are adjacent and the white squares are all connected.</string>
<string name="desc_sixteen">Slide rows and columns around to form a grid in numerical order.</string>
<string name="desc_slant">Draw diagonal lines in every square such that circles have the given numbers of lines meeting at them and there are no loops.</string>
<string name="desc_solo">Fill the grid so each block, row and column contains exactly one of each digit.</string>
<string name="desc_tents">Place tents so each tree has a separate adjacent tent (not diagonally), no tents are next to each other (even diagonally) and the row and column counts are correct.</string>
<string name="desc_towers">Place towers so each row/column contains one of each height and each clue matches the number of towers visible looking into the grid from that point.</string>
<string name="desc_tracks">Complete the track from A to B so that the rows and columns contain the numbers of track segments indicated. The track may not cross itself.</string>
<string name="desc_twiddle">Rotate groups of 4 to form a grid in numerical order.</string>
<string name="desc_undead">Fill the grid with monsters so the correct numbers of them can be seen from each point, taking mirrors into account.</string>
<string name="desc_unequal">Enter digits so every row and column contains exactly one of each digit and the greater-than signs are satisfied.</string>
<string name="desc_unruly">Colour every square either black or white such that no three consecutive squares, horizontally or vertically, are the same colour, and each row and column contains the same number of black and white squares.</string>
<string name="desc_untangle">Move points around until no lines cross.</string>
<!-- Non-obvious controls generally -->
<string tools:ignore="UnusedResources" name="toast_flood">Tap a colour to flood fill from the top left</string>
<string tools:ignore="UnusedResources" name="toast_guess">Drag colours into place, then tap smaller pegs when done</string>
Expand Down

0 comments on commit d51f726

Please sign in to comment.