changeset 96:04011a942e3b

painter: simplify API
author David Demelier <markand@malikania.fr>
date Mon, 30 Mar 2020 20:05:00 +0200
parents e82eca4f8606
children 58133933ea17
files src/adventure/mainmenu_state.c src/core/painter.c src/core/painter.h tests/test-map.c
diffstat 4 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/adventure/mainmenu_state.c	Mon Mar 30 14:07:21 2020 +0200
+++ b/src/adventure/mainmenu_state.c	Mon Mar 30 20:05:00 2020 +0200
@@ -20,13 +20,13 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <error.h>
 #include <event.h>
 #include <font.h>
 #include <game.h>
 #include <image.h>
 #include <map_state.h>
 #include <painter.h>
+#include <panic.h>
 #include <state.h>
 #include <sys.h>
 #include <texture.h>
@@ -186,7 +186,7 @@
 
 		/* TODO: a sword here. */
 		painter_set_color(0x000000ff);
-		painter_draw_rectangle(true, items[selection].x - 30,
+		painter_draw_rectangle(items[selection].x - 30,
 		    items[selection].y + 11, 15, 15);
 	}
 }
--- a/src/core/painter.c	Mon Mar 30 14:07:21 2020 +0200
+++ b/src/core/painter.c	Mon Mar 30 20:05:00 2020 +0200
@@ -71,7 +71,7 @@
 }
 
 void
-painter_draw_rectangle(bool fill, int x, int y, unsigned int width, unsigned int height)
+painter_draw_rectangle(int x, int y, unsigned int width, unsigned int height)
 {
 	const SDL_Rect rect = {
 		.w = width,
@@ -80,10 +80,7 @@
 		.y = y
 	};
 
-	if (fill)
-		SDL_RenderFillRect(win.renderer, &rect);
-	else
-		SDL_RenderDrawRect(win.renderer, &rect);
+	SDL_RenderFillRect(win.renderer, &rect);
 }
 
 void
--- a/src/core/painter.h	Mon Mar 30 14:07:21 2020 +0200
+++ b/src/core/painter.h	Mon Mar 30 20:05:00 2020 +0200
@@ -33,7 +33,7 @@
  * Give the current texture being used for rendering, maybe NULL if the
  * rendering is on root.
  *
- * \return texture or NULL
+ * \return Texture or NULL.
  */
 struct texture *
 painter_get_target(void);
@@ -93,14 +93,13 @@
 /**
  * Draw a rectangle
  *
- * \param fill set to true to fill the rectangle
  * \param x the X coordinate
  * \param y the Y coordinate
  * \param w the rectangle width
  * \param h the rectangle height
  */
 void
-painter_draw_rectangle(bool fill, int x, int y, unsigned int w, unsigned int h);
+painter_draw_rectangle(int x, int y, unsigned int w, unsigned int h);
 
 /**
  * Clear the window.
--- a/tests/test-map.c	Mon Mar 30 14:07:21 2020 +0200
+++ b/tests/test-map.c	Mon Mar 30 20:05:00 2020 +0200
@@ -20,6 +20,7 @@
 
 #include <error.h>
 #include <map.h>
+#include <panic.h>
 #include <sys.h>
 #include <window.h>