about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--freecell.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/freecell.c b/freecell.c
index d50b641..233a720 100644
--- a/freecell.c
+++ b/freecell.c
@@ -154,6 +154,7 @@ static const struct Style FanDown = { 1, 0, 0, 0, FanDownDeltaY };
 
 static struct SDL_Rect stackRects[StacksLen];
 static struct Layout layout;
+static struct List reveal;
 
 static void updateLayout(void) {
 	layoutClear(&layout);
@@ -193,6 +194,12 @@ static bool mouseButtonDown(SDL_MouseButtonEvent button) {
 	struct SDL_Point point = { button.x, button.y };
 	struct Item *item = listFind(&layout.main, &point);
 
+	if (button.button == SDL_BUTTON_RIGHT) {
+		if (!item) return false;
+		listPush(&reveal, &item->rect, item->card);
+		return true;
+	}
+
 	if (button.clicks % 2 == 0) {
 		Card card = layout.dragItem.card;
 		if (!card) {
@@ -223,6 +230,15 @@ 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_Window *window;
 static SDL_Renderer *render;
 
@@ -339,6 +355,7 @@ int main(void) {
 		renderOutlines();
 		renderList(textures, &layout.main);
 		renderList(inverted, &layout.drag);
+		renderList(textures, &reveal);
 		SDL_RenderPresent(render);
 
 		// TODO: Add more than a frame delay between automatic moves?
@@ -353,6 +370,8 @@ int main(void) {
 				if (keyDown(event.key)) break;
 			} else if (event.type == SDL_MOUSEBUTTONDOWN) {
 				if (mouseButtonDown(event.button)) break;
+			} else if (event.type == SDL_MOUSEBUTTONUP) {
+				if (mouseButtonUp(event.button)) break;
 			}
 		}
 	}