diff options
author | June McEnroe <june@causal.agency> | 2019-03-28 15:13:09 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-03-28 15:13:09 -0400 |
commit | 57b78efdbf185fb1f4deacdb98f4bf8bdf52aba3 (patch) | |
tree | 400e51a0ac2836222cc9a07701e4b0936e48fce3 | |
parent | Add "configure" script (diff) | |
download | cards-57b78efdbf185fb1f4deacdb98f4bf8bdf52aba3.tar.gz cards-57b78efdbf185fb1f4deacdb98f4bf8bdf52aba3.zip |
Fix double-click regardless of selection
-rw-r--r-- | freecell.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/freecell.c b/freecell.c index 487ef79..d50b641 100644 --- a/freecell.c +++ b/freecell.c @@ -191,16 +191,22 @@ static bool keyDown(SDL_KeyboardEvent key) { static bool mouseButtonDown(SDL_MouseButtonEvent button) { struct SDL_Point point = { button.x, button.y }; + struct Item *item = listFind(&layout.main, &point); - if (layout.dragItem.card) { - if (button.clicks % 2 == 0) { - for (uint dest = Cell1; dest <= Cell4; ++dest) { - if (gameMove(dest, layout.dragItem.card)) { - layout.dragItem.card = 0; - return true; - } - } + if (button.clicks % 2 == 0) { + Card card = layout.dragItem.card; + if (!card) { + if (!item) return false; + card = item->card; } + for (uint dest = Cell1; dest <= Cell4; ++dest) { + if (gameMove(dest, card)) break; + } + layout.dragItem.card = 0; + return true; + } + + if (layout.dragItem.card) { for (uint dest = 0; dest < StacksLen; ++dest) { if (SDL_PointInRect(&point, &stackRects[dest])) { if (gameMove(dest, layout.dragItem.card)) break; @@ -211,7 +217,6 @@ static bool mouseButtonDown(SDL_MouseButtonEvent button) { } // TODO: Right click to reveal? - struct Item *item = listFind(&layout.main, &point); if (!item) return false; if (!gameAvail(item->card)) return false; layout.dragItem = *item; |