Skip to content

Commit

Permalink
Draw pencils marks at numerical fixed position. Tweak solo/crossnum
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen committed Apr 2, 2022
1 parent 4cc0b53 commit 0847252
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 58 deletions.
4 changes: 3 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## ChangeLog

## 0.7.10 nightly
## 0.7.10 - 2022/04/02

### Added
* *Walls*: Place paths / walls by dragging (swipe across cells for paths, along edges for walls)
Expand All @@ -12,9 +12,11 @@
* *Walls*: Better error display (diagonal stripes)
* Cleaner screen layout by removing unnecessary 'force screen redraw' button from chooser and param screens
* Optimized screen update in game screen
* Games with pencil marks now arrange them in numerically fixed position.

### Fixed
* *Mosaic*: Fix preservation of 'aggressiveness' parameter
* *Solo*: Disallow certain corner-case parameters to avoid hang on game generation

## 0.7.9 - 2021/10/26

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Port of [Simon Tatham's Portable Puzzle Collection](http://www.chiark.greenend.o

[More screenshots](https://github.com/SteffenBauer/PocketPuzzles/blob/master/screenshots/screenshots.md)

[Download the app here](https://github.com/SteffenBauer/PocketPuzzles/blob/master/release/README.md)
[**Download the app here**](https://github.com/SteffenBauer/PocketPuzzles/blob/master/release/README.md)

Inspired by and building on the work of [Port to Android by Chris Boyle](https://github.com/chrisboyle/sgtpuzzles) and [Puzzles for pocketbook by mnk](https://github.com/svn2github/pocketbook-free/tree/master/puzzles)

Expand Down
18 changes: 9 additions & 9 deletions ToDo.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@

#### Fixed grid arrangement of pencil marks

- [ ] ABCD
- [ ] CrossNum
- [ ] Keen
- [ ] Mathrax
- [ ] Salad
- [ ] Solo
- [ ] Towers
- [ ] Undead
- [ ] Unequal
- [X] ABCD
- [X] CrossNum
- [X] Keen
- [X] Mathrax
- [X] Salad
- [X] Solo
- [X] Towers
- [X] Undead
- [X] Unequal

#### Game specific UI settings

Expand Down
8 changes: 4 additions & 4 deletions games/abcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1594,10 +1594,10 @@ static void abcd_draw_pencil(drawing *dr, game_drawstate *ds, const game_state *

/* Draw hints; steal ingenious algorithm (basically)
* from solo.c:draw_number() */
for (i = nhints = 0; i < n; i++) {
/* for (i = nhints = 0; i < n; i++) {
if (state->clues[CUBOID(x, y, i)]) nhints++;
}

} */
nhints = n;
for (hw = 1; hw * hw < nhints; hw++);

if (hw < 3) hw = 3;
Expand All @@ -1610,7 +1610,7 @@ static void abcd_draw_pencil(drawing *dr, game_drawstate *ds, const game_state *
{
if (state->clues[CUBOID(x, y, i)])
{
int hx = j % hw, hy = j / hw;
int hx = i % hw, hy = i / hw;

str[0] = 'A'+i;
str[1] = '\0';
Expand Down
35 changes: 18 additions & 17 deletions games/crossnum.c
Original file line number Diff line number Diff line change
Expand Up @@ -2260,7 +2260,7 @@ static game_state *execute_move(const game_state *from0, const char *move)
for (i = 0; i < a; i++) {
if (!from->clues->playable[i])
continue;
if (move[i+1] < '0' || move[i+1] > '0'+MAXNUM) {
if (move[i+1] < '0' || move[i+1] > '0'+9) {
free_game(ret);
return from;
}
Expand All @@ -2276,7 +2276,7 @@ static game_state *execute_move(const game_state *from0, const char *move)
return ret;
} else if ((move[0] == 'P' || move[0] == 'R') &&
sscanf(move+1, "%d,%d,%d", &x, &y, &n) == 3 &&
x >= 0 && x < sz && y >= 0 && y < sz && n >= -1 && n <= MAXNUM) {
x >= 0 && x < sz && y >= 0 && y < sz && n >= -1 && n <= 9) {
if (!from->clues->playable[y*sz+x])
return from;

Expand Down Expand Up @@ -2308,7 +2308,7 @@ static game_state *execute_move(const game_state *from0, const char *move)
if (ret->grid[y*sz+x] == -1)
ret->pencil[y*sz+x] = (
((from->clues->oddeven == 2 ? 0 : 1) + x + y)%2 ?
oddmask : evenmask);
evenmask : oddmask);
}
} else {
long mask = (2L<<from->par->max) - 2;
Expand Down Expand Up @@ -2352,11 +2352,11 @@ static float *game_colours(frontend *fe, int *ncolours)
ret[COL_BACKGROUND * 3 + i] = 1.0F;
ret[COL_GRID * 3 + i] = 0.0F;
ret[COL_USER * 3 + i] = 0.0F;
ret[COL_HIGHLIGHT * 3 + i] = 0.75F;
ret[COL_HIGHLIGHT * 3 + i] = 0.5F;
ret[COL_ERROR * 3 + i] = 0.25F;
ret[COL_ERROR_USER * 3 + i] = 0.75F;
ret[COL_PENCIL * 3 + i] = 0.0F;
ret[COL_EVENBG * 3 + i] = 0.9F;
ret[COL_PENCIL * 3 + i] = 0.25F;
ret[COL_EVENBG * 3 + i] = 0.75F;
ret[COL_ODDBG * 3 + i] = 1.0F;
}

Expand Down Expand Up @@ -2561,12 +2561,12 @@ static void draw_tile(drawing *dr, game_drawstate *ds, const game_params *par,
(tile & DF_HIGHLIGHT ? COL_ERROR :
COL_ERROR_USER) :
COL_USER), str);
} else if ((tile & DF_DIGIT_MASK) && !(tile & DF_HIGHLIGHT_PENCIL)) {
} /* else if ((tile & DF_DIGIT_MASK) && !(tile & DF_HIGHLIGHT_PENCIL)) {
sprintf(str, "%d_", (int)(tile & DF_DIGIT_MASK));
draw_text(dr, tx + cw/2, ty + ch/2,
FONT_VARIABLE, TILESIZE/2, ALIGN_VCENTRE | ALIGN_HCENTRE,
COL_USER, str);
} else {
} */ else {
long rev;
int i, j, npencil;
int pl, pr, pt, pb;
Expand All @@ -2578,11 +2578,12 @@ static void draw_tile(drawing *dr, game_drawstate *ds, const game_params *par,
rev = 1L << ((tile & DF_DIGIT_MASK) + DF_PENCIL_SHIFT);
} else
rev = 0;
for (i = 1, npencil = 0; i <= MAXNUM; i++)
/* for (i = 1, npencil = 0; i <= MAXNUM; i++)
if ((tile ^ rev) & (1L << (i + DF_PENCIL_SHIFT)))
npencil++;
if (tile & DF_DIGIT_MASK)
npencil++;
npencil++; */
npencil = 9;
if (npencil) {

minph = 2;
Expand Down Expand Up @@ -2623,9 +2624,9 @@ static void draw_tile(drawing *dr, game_drawstate *ds, const game_params *par,
/*
* Now actually draw the pencil marks.
*/
for (i = 1, j = 0; i <= MAXNUM; i++)
for (i = 1, j = 0; i <= 9; i++)
if ((tile ^ rev) & (1L << (i + DF_PENCIL_SHIFT))) {
int dx = j % pw, dy = j / pw;
int dx = (i-1) % pw, dy = (i-1) / pw;
sprintf(str, "%d", i);
draw_text(dr, pl + pgsizex * (2*dx+1) / 2,
pt + pgsizey * (2*dy+1) / 2,
Expand All @@ -2634,15 +2635,15 @@ static void draw_tile(drawing *dr, game_drawstate *ds, const game_params *par,
str);
j++;
}
if (tile & DF_DIGIT_MASK) {
/* if (tile & DF_DIGIT_MASK) {
int dx = j % pw, dy = j / pw;
sprintf(str, "%d_", (int)(tile & DF_DIGIT_MASK));
draw_text(dr, pl + pgsizex * (2*dx+1) / 2,
pt + pgsizey * (2*dy+1) / 2,
FONT_VARIABLE, fontsize,
ALIGN_VCENTRE | ALIGN_HCENTRE, COL_PENCIL,
str);
}
} */
}
}
}
Expand Down Expand Up @@ -2732,11 +2733,11 @@ static bool game_timing_state(const game_state *state, game_ui *ui)
#ifdef COMBINED
#define thegame crossnum
#endif
static const char rules[] = "Fill the grid with numbers like a crossword puzzle. The sum of each line must match the given horizontal / vertical clues. The same number cannot occur more than once in each sum.\n\n"
"These variations are available:\n"
static const char rules[] = "Fill the grid with numbers like a crossword puzzle. The sum of each line must match the given horizontal / vertical clues. The same number cannot occur more than once in each sum.\n\n\n"
"These variations are available:\n\n"
"- Odd/Even: White cells can only have an odd number, grey cells only an even number.\n"
"- Unique: No two sums can contain the same numbers.\n"
"\n\n\nThis puzzle was implemented by Anders Holst.";
"\n\nThis puzzle was implemented by Anders Holst.";

const struct game thegame = {
"CrossNum", "games.crossnum", "crossnum", rules,
Expand Down
10 changes: 6 additions & 4 deletions games/keen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2019,10 +2019,12 @@ static void draw_tile(drawing *dr, game_drawstate *ds, struct clues *clues,
int pw, ph, minph, pbest, fontsize;

/* Count the pencil marks required. */
for (i = 1, npencil = 0; i <= w; i++)
/* for (i = 1, npencil = 0; i <= w; i++)
if (tile & (1L << (i + DF_PENCIL_SHIFT)))
npencil++;
if (npencil) {
npencil++; */
npencil = w;

if (npencil) {

minph = 2;

Expand Down Expand Up @@ -2098,7 +2100,7 @@ static void draw_tile(drawing *dr, game_drawstate *ds, struct clues *clues,
*/
for (i = 1, j = 0; i <= w; i++)
if (tile & (1L << (i + DF_PENCIL_SHIFT))) {
int dx = j % pw, dy = j / pw;
int dx = (i-1) % pw, dy = (i-1) / pw;

str[1] = '\0';
str[0] = i + '0';
Expand Down
10 changes: 5 additions & 5 deletions games/mathrax.c
Original file line number Diff line number Diff line change
Expand Up @@ -1567,13 +1567,13 @@ static void game_redraw(drawing *dr, game_drawstate *ds,
else if(state->marks[y*o+x]) /* Draw pencil marks */
{
int nhints, i, j, hw, hh, hmax, fontsz;
for (i = nhints = 0; i < 9; i++) {
/* for (i = nhints = 0; i < o; i++) {
if (state->marks[y*o+x] & (1<<i)) nhints++;
}

} */
nhints = o;
for (hw = 1; hw * hw < nhints; hw++);

if (hw < 3) hw = 3;
if (hw < 3) hw = 3;
hh = (nhints + hw - 1) / hw;
if (hh < 2) hh = 2;
hmax = max(hw, hh);
Expand All @@ -1583,7 +1583,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds,
{
if (state->marks[y*o+x] & (1<<i))
{
int hx = j % hw, hy = j / hw;
int hx = i % hw, hy = i / hw;

buf[0] = i+'1';
buf[1] = '\0';
Expand Down
8 changes: 4 additions & 4 deletions games/salad.c
Original file line number Diff line number Diff line change
Expand Up @@ -1755,10 +1755,10 @@ static void salad_draw_pencil(drawing *dr, const game_state *state, int x, int y

/* Draw hints; steal ingenious algorithm (basically)
* from solo.c:draw_number() */
for (i = nhints = 0; i < mmx; i++) {
/*for (i = nhints = 0; i < mmx; i++) {
if (state->marks[y*o+x] & (1<<i)) nhints++;
}

} */
nhints = mmx;
for (hw = 1; hw * hw < nhints; hw++);

if (hw < 3) hw = 3;
Expand All @@ -1771,7 +1771,7 @@ static void salad_draw_pencil(drawing *dr, const game_state *state, int x, int y
{
if (state->marks[y*o+x] & (1<<i))
{
int hx = j % hw, hy = j / hw;
int hx = i % hw, hy = i / hw;

str[0] = base+i+1;
if(i == mmx - 1)
Expand Down
11 changes: 8 additions & 3 deletions games/solo.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ static const char *validate_params(const game_params *params, bool full)
return "Killer puzzle dimensions must be smaller than 10";
if (params->xtype && params->c * params->r < 4)
return "X-type puzzle dimensions must be larger than 3";
if (params->diff >= DIFF_SIMPLE && params->c == 3 && params->r == 1)
return "Too small for a Jigsaw puzzle of this difficulty";
if (params->diff >= DIFF_INTERSECT && params->c == 4 && params->r == 1)
return "Too small for a Jigsaw puzzle of this difficulty";
return NULL;
}

Expand Down Expand Up @@ -4538,9 +4542,10 @@ static void draw_number(drawing *dr, game_drawstate *ds,
int pw, ph, minph, pbest, fontsize;

/* Count the pencil marks required. */
for (i = npencil = 0; i < cr; i++)
/* for (i = npencil = 0; i < cr; i++)
if (state->pencil[(y*cr+x)*cr+i])
npencil++;
npencil++; */
npencil = cr;
if (npencil) {
minph = 2;

Expand Down Expand Up @@ -4625,7 +4630,7 @@ static void draw_number(drawing *dr, game_drawstate *ds,
*/
for (i = j = 0; i < cr; i++)
if (state->pencil[(y*cr+x)*cr+i]) {
int dx = j % pw, dy = j / pw;
int dx = i % pw, dy = i / pw;

str[1] = '\0';
str[0] = i + '1';
Expand Down
9 changes: 5 additions & 4 deletions games/towers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,10 +1663,11 @@ static void draw_tile(drawing *dr, game_drawstate *ds, struct clues *clues,
int pw, ph, minph, pbest, fontsize;

/* Count the pencil marks required. */
for (i = 1, npencil = 0; i <= w; i++)
/* for (i = 1, npencil = 0; i <= w; i++)
if (tile & (1L << (i + DF_PENCIL_SHIFT)))
npencil++;
if (npencil) {
npencil++; */
npencil = w;
if (npencil) {

minph = 2;

Expand Down Expand Up @@ -1727,7 +1728,7 @@ static void draw_tile(drawing *dr, game_drawstate *ds, struct clues *clues,
*/
for (i = 1, j = 0; i <= w; i++)
if (tile & (1L << (i + DF_PENCIL_SHIFT))) {
int dx = j % pw, dy = j / pw;
int dx = (i-1) % pw, dy = (i-1) / pw;

str[1] = '\0';
str[0] = i + '0';
Expand Down
20 changes: 20 additions & 0 deletions games/undead.c
Original file line number Diff line number Diff line change
Expand Up @@ -2881,6 +2881,7 @@ static void draw_big_monster(drawing *dr, game_drawstate *ds,
return;
}

/*
static void draw_pencils(drawing *dr, game_drawstate *ds,
const game_state *state, int x, int y, int pencil)
{
Expand All @@ -2907,6 +2908,25 @@ static void draw_pencils(drawing *dr, game_drawstate *ds,
return;
}
*/
static void draw_pencils(drawing *dr, game_drawstate *ds,
const game_state *state, int x, int y, int pencil)
{
int dx, dy;
dx = BORDER+(x* ds->tilesize)+(TILESIZE/4);
dy = BORDER+(y* ds->tilesize)+(TILESIZE/4)+TILESIZE;

if (pencil & 1)
draw_monster(dr, ds, dx, dy, TILESIZE/2, 1);
if (pencil & 2)
draw_monster(dr, ds, dx + TILESIZE/2, dy, TILESIZE/2, 2);
if (pencil & 4)
draw_monster(dr, ds, dx, dy + TILESIZE/2, TILESIZE/2, 4);

draw_update(dr,dx-(TILESIZE/4)+2,dy-(TILESIZE/4)+2,
(TILESIZE/2)-3,(TILESIZE/2)-3);
return;
}

static bool is_hint_stale(const game_drawstate *ds, const game_state *state, int index)
{
Expand Down
8 changes: 4 additions & 4 deletions games/unequal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1865,10 +1865,10 @@ static void draw_hints(drawing *dr, game_drawstate *ds, int x, int y)

/* Draw hints; steal ingenious algorithm (basically)
* from solo.c:draw_number() */
for (i = nhints = 0; i < ds->order; i++) {
/* for (i = nhints = 0; i < ds->order; i++) {
if (HINT(ds, x, y, i)) nhints++;
}

} */
nhints = ds->order;
for (hw = 1; hw * hw < nhints; hw++);
if (hw < 3) hw = 3;
hh = (nhints + hw - 1) / hw;
Expand All @@ -1878,7 +1878,7 @@ static void draw_hints(drawing *dr, game_drawstate *ds, int x, int y)

for (i = j = 0; i < ds->order; i++) {
if (HINT(ds,x,y,i)) {
int hx = j % hw, hy = j / hw;
int hx = i % hw, hy = i / hw;

str[0] = n2c(i+1, ds->order);
str[1] = '\0';
Expand Down
4 changes: 2 additions & 2 deletions release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ You can find pre-compiled binaries ready for installation here.

Choose between one of these build stages:

* [Stable release (0.7.9)](https://github.com/SteffenBauer/PocketPuzzles/blob/master/release/stable/SGTPuzzles.app) Compiled in sync with the latest tagged release. Recommended.
* [Previous release (0.7.8)](https://github.com/SteffenBauer/PocketPuzzles/blob/master/release/previous/SGTPuzzles.app) The app release tag just before the current stable one. Install this when you have problems with the stable release.
* [Stable release (0.7.10)](https://github.com/SteffenBauer/PocketPuzzles/blob/master/release/stable/SGTPuzzles.app) Compiled in sync with the latest tagged release. Recommended.
* [Previous release (0.7.9)](https://github.com/SteffenBauer/PocketPuzzles/blob/master/release/previous/SGTPuzzles.app) The app release tag just before the current stable one. Install this when you have problems with the stable release.
* [Nightly build](https://github.com/SteffenBauer/PocketPuzzles/blob/master/release/nightly/SGTPuzzles.app) This binary is kept in sync with the current master branch. Can contain untested code, so install only when you want the newest features.

### Installation
Expand Down
Binary file modified release/nightly/SGTPuzzles.app
Binary file not shown.
Binary file modified release/previous/SGTPuzzles.app
Binary file not shown.
Binary file modified release/stable/SGTPuzzles.app
Binary file not shown.

0 comments on commit 0847252

Please sign in to comment.