From 392dd8cc20b04f4d3aed4219120d597cec00d8fc Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Tue, 2 Apr 2019 23:16:17 -0400 Subject: Select and move cards on mouse up --- freecell.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/freecell.c b/freecell.c index 2855219..bea3662 100644 --- a/freecell.c +++ b/freecell.c @@ -266,15 +266,24 @@ static bool keyUp(SDL_KeyboardEvent key) { } static bool mouseButtonDown(SDL_MouseButtonEvent button) { + if (button.button != SDL_BUTTON_RIGHT) return false; struct SDL_Point point = { button.x, button.y }; struct Item *item = listFind(&layout.main, &point); + if (!item) return false; + listPush(&reveal, &item->rect, item->card); + return true; +} +static bool mouseButtonUp(SDL_MouseButtonEvent button) { if (button.button == SDL_BUTTON_RIGHT) { - if (!item) return false; - listPush(&reveal, &item->rect, item->card); + if (!reveal.len) return false; + reveal.len = 0; return true; } + struct SDL_Point point = { button.x, button.y }; + struct Item *item = listFind(&layout.main, &point); + if (button.clicks % 2 == 0) { Card card = layout.dragItem.card; if (!card) { @@ -304,15 +313,6 @@ static bool mouseButtonDown(SDL_MouseButtonEvent button) { return true; } -static bool mouseButtonUp(SDL_MouseButtonEvent button) { - if (button.button == SDL_BUTTON_RIGHT) { - if (!reveal.len) return false; - reveal.len = 0; - return true; - } - return false; -} - static SDL_Renderer *render; static void renderOutline(SDL_Rect rect, bool out) { -- cgit 1.4.1