diff --git a/simple/x11/shisen/shisen.c b/simple/x11/shisen/shisen.c index a7605d7..da2c8ce 100644 --- a/simple/x11/shisen/shisen.c +++ b/simple/x11/shisen/shisen.c @@ -63,7 +63,7 @@ Track tracks[COUNT]; int tracksCount; int glyphsMask = 0; int mode; -int showhint; +Letter *hintLetter; int back; int mute; int ox, oy, cw, ch; @@ -127,6 +127,7 @@ void clearBoard() { if (mute != 1) mute = 0; mode = 0; back = 0; + hintLetter = NULL; memset(tracks, 0, sizeof(tracks)); memset(board, 0, sizeof(board)); tracksCount = 0; @@ -458,9 +459,17 @@ void mouseDown(int x, int y) { return; } else back = 0; + hover.r = hover.c = -1; + hintLetter = NULL; + tracksCount = 0; + for(int r = 0; r < ROWS; ++r) + for(int c = 0; c < COLS; ++c) + if (!board[r][c].l) board[r][c].g = NULL; + if (mc >= COLS && mr >= ROWS) { - if (get(selected)) showhint = 1; - else hint(); + hintLetter = get(selected); + if (!hintLetter) hint(); + selected.r = selected.c = -1; } else if (mc >= COLS && mr < 0) { mute = mute == 1 ? 2 : 1; @@ -495,13 +504,12 @@ void mouseDown(int x, int y) { void mouseUp() { - if (mode) { - showhint = 0; - tracksCount = 0; - for(int r = 0; r < ROWS; ++r) - for(int c = 0; c < COLS; ++c) - if (!board[r][c].l) board[r][c].g = NULL; - } + int cnt = 0; + for(int r = 0; r < ROWS; ++r) + for(int c = 0; c < COLS; ++c) + if (!board[r][c].l && board[r][c].g) + { ++cnt; board[r][c].g = NULL; } + if (cnt) tracksCount = 0; } @@ -549,14 +557,13 @@ void draw() { for(int i = 0; i < 3; ++i) imgExResample(&sndtex[i], cw, ch); // draw cells - Letter *hl = showhint ? get(selected) : NULL; for(int r = 0; r < ROWS; ++r) for(int c = 0; c < COLS; ++c) { Cell *cell = &board[r][c]; if (!cell->g) continue; int hilight = (r == hover.r && c == hover.c) || (r == selected.r && c == selected.c) - || (hl && hl == cell->l); + || (hintLetter && hintLetter == cell->l); imgPairDraw(cell->g, hilight, ox + c*cw, oy + r*ch, cw, ch); }