diff examples/example-notify/example-notify.c @ 486:d6757c30658e

core: rework errors
author David Demelier <markand@malikania.fr>
date Tue, 28 Feb 2023 13:04:13 +0100
parents 3ff1fe64d0cd
children fce3b3c4b496
line wrap: on
line diff
--- a/examples/example-notify/example-notify.c	Tue Feb 28 08:40:35 2023 +0100
+++ b/examples/example-notify/example-notify.c	Tue Feb 28 13:04:13 2023 +0100
@@ -33,11 +33,8 @@
 #include <mlk/ui/label.h>
 #include <mlk/ui/ui.h>
 
-/* Sword by Icongeek26 (https://www.flaticon.com). */
-#include <assets/images/sword.h>
-
-#define W       1280
-#define H       720
+#include <mlk/example/example.h>
+#include <mlk/example/registry.h>
 
 static struct label help = {
 	.text = "Keys: <Space> to generate a notification.",
@@ -45,18 +42,18 @@
 	.y = 10,
 	.flags = LABEL_FLAGS_SHADOW
 };
-static struct mlk_texture icon;
+static struct mlk_texture *icon;
 static struct mlk_state *states[1];
 
 static void
 init(void)
 {
-	if (mlk_core_init("fr.malikania", "example-notify") < 0 || ui_init() < 0)
-		mlk_panic();
-	if (mlk_window_open("Example - Notify", W, H) < 0)
-		mlk_panic();
-	if (mlk_image_openmem(&icon, assets_images_sword, sizeof (assets_images_sword)) < 0)
-		mlk_panic();
+	int err;
+
+	if ((err = mlk_example_init("example-notify")) < 0)
+		mlk_panicf("mlk_example_init: %s", mlk_err_string(err));
+
+	icon = &registry_textures[REGISTRY_TEXTURE_SWORD];
 }
 
 static void
@@ -70,7 +67,7 @@
 		break;
 	case MLK_EVENT_KEYDOWN:
 		if (ev->key.key == MLK_KEY_SPACE)
-			notify(&icon, "Quest", "Quest finished.");
+			notify(icon, "Quest", "Quest finished.");
 		break;
 	default:
 		break;