This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository elimine.
View the commit online.
commit 606008811012a9b331f7e80e722fe3027bb75e2e
Author: Vincent Torri <vto...@outlook.fr>
AuthorDate: Mon Jul 7 17:06:19 2025 +0200
Improve the code
Not perfect but i don't want to loose the code on my dying laptop
---
data/images/WinmineXP.png | Bin 0 -> 1073 bytes
data/images/countersmall.png | Bin 0 -> 1826 bytes
data/images/facesfixed.png | Bin 0 -> 2239 bytes
src/bin/elimine.c | 488 +++++++++----------------------------------
src/bin/icon.c | 189 +++++++++++++++++
src/bin/icon.h | 55 +++++
src/bin/meson.build | 2 +-
7 files changed, 340 insertions(+), 394 deletions(-)
diff --git a/data/images/WinmineXP.png b/data/images/WinmineXP.png
new file mode 100644
index 0000000..fb509da
Binary files /dev/null and b/data/images/WinmineXP.png differ
diff --git a/data/images/countersmall.png b/data/images/countersmall.png
new file mode 100644
index 0000000..ce23546
Binary files /dev/null and b/data/images/countersmall.png differ
diff --git a/data/images/facesfixed.png b/data/images/facesfixed.png
new file mode 100644
index 0000000..58c71ef
Binary files /dev/null and b/data/images/facesfixed.png differ
diff --git a/src/bin/elimine.c b/src/bin/elimine.c
index cb8f799..21240e5 100644
--- a/src/bin/elimine.c
+++ b/src/bin/elimine.c
@@ -1,27 +1,15 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <vincent.to...@gmail.com>
+ * SPDX-License-Identifier: MIT
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <Elementary.h>
-typedef enum
-{
- NOTHING,
- ONE,
- TWO,
- THREE,
- FOUR,
- FIVE,
- SIX,
- SEVEN,
- HEIGHT,
- UNKNOWN,
- FLAG,
- BOMB,
- BOMB_WRONG,
- BOMB_EXPLODED,
- TYPE_GUARD
-} Tile_Type;
+#include "icon.h"
/*
* Boards (width x height x mines):
@@ -53,292 +41,6 @@ typedef struct
Eina_Bool finished;
} Ctx;
-static unsigned int colors[] =
-{
- 0xffc1c1c1, /* LIGHT_GREY */
- 0xff1900fc, /* BLUE 1 */
- 0xff00810d, /* GREEN 2 */
- 0xffff171c, /* RED 3 */
- 0xff07007e, /* DARK_BLUE 4 */
- 0xff820608, /* PURPLE 5*/
- 0xff008080, /* PALE_GRREN 6 */
- 0xff000000, /* BLACK 7 */
- 0xff808080, /* DARK_GREY 8 */
- 0xffffffff, /* WHITE */
-};
-
-static int tiles[TYPE_GUARD][16][16] =
-{
- /* nothing0 */
- {
- { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 8, 0, 0, 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, 8, 8, 8, 8, 8, 8, 8 },
- { 8, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
- { 8, 3, 3, 3, 3, 3, 3, 3, 7, 3, 3, 3, 3, 3, 3, 3 },
- { 8, 3, 3, 3, 3, 3, 3, 3, 7, 3, 3, 3, 3, 3, 3, 3 },
- { 8, 3, 3, 3, 7, 3, 7, 7, 7, 7, 7, 3, 7, 3, 3, 3 },
- { 8, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3 },
- { 8, 3, 3, 3, 7, 7, 9, 9, 7, 7, 7, 7, 7, 3, 3, 3 },
- { 8, 3, 3, 3, 7, 7, 9, 9, 7, 7, 7, 7, 7, 3, 3, 3 },
- { 8, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3 },
- { 8, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3 },
- { 8, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3 },
- { 8, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3 },
- { 8, 3, 3, 3, 7, 3, 7, 7, 7, 7, 7, 3, 7, 3, 3, 3 },
- { 8, 3, 3, 3, 3, 3, 3, 3, 7, 3, 3, 3, 3, 3, 3, 3 },
- { 8, 3, 3, 3, 3, 3, 3, 3, 7, 3, 3, 3, 3, 3, 3, 3 },
- { 8, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }
- },
-};
-
-unsigned int *icons[TYPE_GUARD];
-
#define lookup(l, c) (l) * ctx->nc + (c)
static inline int in_board(Ctx *ctx, int l, int c)
@@ -357,30 +59,12 @@ void display_board(Ctx *ctx)
for (c = 0; c < ctx->nc; c++)
{
printf("%c ",
- ctx->state[lookup(l,c)] == BOMB ? '*' : '0' + ctx->state[lookup(l,c)]);
+ ctx->state[lookup(l,c)] == TILE_BOMB ? '*' : '0' + ctx->state[lookup(l,c)]);
}
printf("\n");
}
}
-Evas_Object *icon_new(Evas_Object *win, Tile_Type type, int sz)
-{
- Evas_Object *o;
- int size;
-
- size = 16 * sz;
-
- o = evas_object_image_add(evas_object_evas_get(win));
- evas_object_image_size_set(o, size, size);
- evas_object_image_fill_set(o, 0, 0, size, size);
- evas_object_image_data_set(o, icons[type]);
- evas_object_resize(o, size, size);
- evas_object_size_hint_min_set(o, size, size);
- evas_object_size_hint_max_set(o, size, size);
-
- return o;
-}
-
Ctx *ctx_new(Evas_Object *win, Difficulty d, int tile_sz)
{
Ctx *ctx;
@@ -439,9 +123,9 @@ Ctx *ctx_new(Evas_Object *win, Difficulty d, int tile_sz)
while (count < ctx->nm)
{
int pos = rand() % (ctx->nc * ctx->nl);
- if (ctx->state[pos] != BOMB)
+ if (ctx->state[pos] != TILE_BOMB)
{
- ctx->state[pos] = BOMB;
+ ctx->state[pos] = TILE_BOMB;
count++;
}
}
@@ -465,7 +149,7 @@ Ctx *ctx_new(Evas_Object *win, Difficulty d, int tile_sz)
{
if (in_board(ctx, l + j, c + i) && ! ((i == 0) && (j == 0)))
{
- if (ctx->state[lookup(l + j, c + i)] == BOMB)
+ if (ctx->state[lookup(l + j, c + i)] == TILE_BOMB)
n++;
}
}
@@ -483,34 +167,7 @@ Ctx *ctx_new(Evas_Object *win, Difficulty d, int tile_sz)
for (c = 0; c < ctx->nc; c++)
{
- ctx->known[lookup(l, c)] = UNKNOWN;
- }
- }
-
- /* icons */
- for (int t = 0; t < TYPE_GUARD; t++)
- {
- int size;
- int *data;
-
- size = 16 * ctx->tile_sz;
- icons[t] = calloc(size * size, sizeof(unsigned int));
- data = "" *)tiles[t];
-
- for (int l = 0; l < 16; l++)
- {
- for (int c = 0; c < 16; c++)
- {
- unsigned int color = colors[data[l * 16 + c]];
-
- for (int j = 0; j < ctx->tile_sz; j++)
- {
- for (int i = 0; i < ctx->tile_sz; i++)
- {
- icons[t][(ctx->tile_sz * l + j) * size + ctx->tile_sz * c + i] = color;
- }
- }
- }
+ ctx->known[lookup(l, c)] = TILE_UNKNOWN;
}
}
@@ -530,9 +187,21 @@ void ctx_del(Ctx *ctx)
#define TILE(t, l, c) \
do { \
- Evas_Object *o = icon_new(ctx->win, t, ctx->tile_sz); \
- elm_table_pack(ctx->tbl, o, c, l, 1, 1); \
- evas_object_show(o); \
+ Evas_Object*o; \
+ int icon_w; \
+ int icon_h; \
+ tile_size_get(&icon_w, &icon_h); \
+ icon_w *= ctx->tile_sz; \
+ icon_h *= ctx->tile_sz; \
+ o = evas_object_image_add(evas_object_evas_get(ctx->win)); \
+ evas_object_image_size_set(o, icon_w, icon_h); \
+ evas_object_image_fill_set(o, 0, 0, icon_w, icon_h); \
+ evas_object_image_data_set(o, tile_bmp_get(t)); \
+ evas_object_resize(o, icon_w, icon_h); \
+ evas_object_size_hint_min_set(o, icon_w, icon_h); \
+ evas_object_size_hint_max_set(o, icon_w, icon_h); \
+ elm_table_pack(ctx->tbl, o, c, l, 1, 1); \
+ evas_object_show(o); \
} while (0)
void ctx_draw(Ctx *ctx)
@@ -545,11 +214,7 @@ void ctx_draw(Ctx *ctx)
for (c = 0; c < ctx->nc; c++)
{
- Evas_Object *o;
-
- o = icon_new(ctx->win, ctx->known[lookup(l, c)], ctx->tile_sz);
- elm_table_pack(ctx->tbl, o, c, l, 1, 1);
- evas_object_show(o);
+ TILE(ctx->known[lookup(l, c)], l, c);
}
}
}
@@ -564,19 +229,19 @@ static void uncover(Ctx *ctx, int l, int c)
int x;
int y;
- if (ctx->state[lookup(l, c)] == BOMB)
+ if (ctx->state[lookup(l, c)] == TILE_BOMB)
return;
- if ((ctx->state[lookup(l, c)] >= ONE) &&
- (ctx->state[lookup(l, c)] <= HEIGHT))
+ if ((ctx->state[lookup(l, c)] >= TILE_ONE) &&
+ (ctx->state[lookup(l, c)] <= TILE_HEIGHT))
{
ctx->known[lookup(l, c)] = ctx->state[lookup(l, c)];
TILE(ctx->state[lookup(l, c)], l, c);
return;
}
- ctx->known[lookup(l, c)] = NOTHING;
- TILE(NOTHING, l, c);
+ ctx->known[lookup(l, c)] = TILE_NOTHING;
+ TILE(TILE_NOTHING, l, c);
for (y = -1; y <= 1; y++)
{
@@ -584,7 +249,7 @@ static void uncover(Ctx *ctx, int l, int c)
{
if (!((x == 0) && (y == 0)) &&
in_bounds(ctx, l + y, c + x) &&
- (ctx->known[lookup(l + y, c + x)] == UNKNOWN))
+ (ctx->known[lookup(l + y, c + x)] == TILE_UNKNOWN))
{
uncover(ctx, l + y, c + x);
}
@@ -606,29 +271,29 @@ _cb_mouse_up(void *ctx_, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, v
ev = (Evas_Event_Mouse_Up *)event_info;
c = ev->output.x / (16 * ctx->tile_sz);
- l = ev->output.y / (16 * ctx->tile_sz);
+ l = (ev->output.y - 32 * ctx->tile_sz) / (16 * ctx->tile_sz);
if ((ev->button == 3) ||
((ev->button == 1) &&
(evas_key_modifier_is_set(ev->modifiers, "Control"))))
{
- if (ctx->known[lookup(l, c)] == UNKNOWN)
+ if (ctx->known[lookup(l, c)] == TILE_UNKNOWN)
{
- ctx->known[lookup(l, c)] = FLAG;
- TILE(FLAG, l, c);
+ ctx->known[lookup(l, c)] = TILE_FLAG;
+ TILE(TILE_FLAG, l, c);
}
- else if (ctx->known[lookup(l, c)] == FLAG)
+ else if (ctx->known[lookup(l, c)] == TILE_FLAG)
{
- ctx->known[lookup(l, c)] = UNKNOWN;
- TILE(UNKNOWN, l, c);
+ ctx->known[lookup(l, c)] = TILE_UNKNOWN;
+ TILE(TILE_UNKNOWN, l, c);
}
return;
}
- if ((ev->button == 1) && (ctx->known[lookup(l, c)] == UNKNOWN))
+ if ((ev->button == 1) && (ctx->known[lookup(l, c)] == TILE_UNKNOWN))
{
- if (ctx->state[lookup(l, c)] == BOMB)
+ if (ctx->state[lookup(l, c)] == TILE_BOMB)
{
int y;
@@ -639,24 +304,24 @@ _cb_mouse_up(void *ctx_, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, v
for (x = 0; x < ctx->nc; x++)
{
/* wrongly flagged tile */
- if ((ctx->known[lookup(y, x)] == FLAG) &&
- (ctx->state[lookup(y, x)] != BOMB))
+ if ((ctx->known[lookup(y, x)] == TILE_FLAG) &&
+ (ctx->state[lookup(y, x)] != TILE_BOMB))
{
- ctx->known[lookup(y, x)] = BOMB_WRONG;
- TILE(BOMB_WRONG, y, x);
+ ctx->known[lookup(y, x)] = TILE_BOMB_WRONG;
+ TILE(TILE_BOMB_WRONG, y, x);
}
- if (ctx->state[lookup(y, x)] == BOMB)
+ if (ctx->state[lookup(y, x)] == TILE_BOMB)
{
if ((x == c) && (y == l))
{
- ctx->known[lookup(y, x)] = BOMB_EXPLODED;
- TILE(BOMB_EXPLODED, y, x);
+ ctx->known[lookup(y, x)] = TILE_BOMB_EXPLODED;
+ TILE(TILE_BOMB_EXPLODED, y, x);
}
else
{
- ctx->known[lookup(y, x)] = BOMB;
- TILE(BOMB, y, x);
+ ctx->known[lookup(y, x)] = TILE_BOMB;
+ TILE(TILE_BOMB, y, x);
}
}
}
@@ -664,7 +329,7 @@ _cb_mouse_up(void *ctx_, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, v
ctx->finished = EINA_TRUE;
}
- else if (ctx->state[lookup(l, c)] == NOTHING)
+ else if (ctx->state[lookup(l, c)] == TILE_NOTHING)
{
uncover(ctx, l, c);
}
@@ -683,6 +348,8 @@ elm_main(int argc, char **argv)
Evas_Object *win;
Evas_Object *tbl;
+ Evas_Object *vbox;
+ Evas_Object *hbox;
Evas_Object *o;
int win_w;
int win_h;
@@ -696,6 +363,8 @@ elm_main(int argc, char **argv)
ctx = ctx_new(win, INTERMEDIATE, 3);
+ icon_init(win, ctx->tile_sz);
+
/* background */
o = elm_bg_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -703,13 +372,46 @@ elm_main(int argc, char **argv)
elm_win_resize_object_add(win, o);
evas_object_show(o);
+ /* vbox */
+ o = elm_box_add(win);
+ evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_win_resize_object_add(win, o);
+ evas_object_show(o);
+ vbox = o;
+
+ /* hbox */
+ o = elm_box_add(win);
+ elm_box_horizontal_set(o, EINA_TRUE);
+ evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(vbox, o);
+ evas_object_show(o);
+ hbox = o;
+
+ o = evas_object_image_add(evas_object_evas_get(win));
+ int icon_w;
+ int icon_h;
+ cipher_size_get(&icon_w, &icon_h);
+ icon_w *= ctx->tile_sz;
+ icon_h *= ctx->tile_sz;
+ evas_object_image_size_set(o, icon_w, icon_h);
+ evas_object_image_fill_set(o, 0, 0, icon_w, icon_h);
+ evas_object_image_data_set(o, cipher_bmp_get(CIPHER_ZERO));
+ evas_object_resize(o, icon_w, icon_h);
+ evas_object_size_hint_min_set(o, icon_w, icon_h);
+ evas_object_size_hint_max_set(o, icon_w, icon_h);
+ elm_box_pack_end(hbox, o);
+ evas_object_show(o);
+
/* table */
- tbl = elm_table_add(win);
- elm_table_homogeneous_set(tbl, EINA_TRUE);
- evas_object_size_hint_weight_set(tbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_fill_set(tbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_win_resize_object_add(win, tbl);
- evas_object_show(tbl);
+ o = elm_table_add(win);
+ elm_table_homogeneous_set(o, EINA_TRUE);
+ evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(vbox, o);
+ evas_object_show(o);
+ tbl = o;
o = evas_object_rectangle_add(win);
evas_object_color_set(o, 0, 0, 0, 0);
diff --git a/src/bin/icon.c b/src/bin/icon.c
new file mode 100644
index 0000000..1dbf38d
--- /dev/null
+++ b/src/bin/icon.c
@@ -0,0 +1,189 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <vincent.to...@gmail.com>
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <stdlib.h>
+
+#include <Eina.h>
+#include <Evas.h>
+
+#include "icon.h"
+
+typedef struct
+{
+ int x;
+ int y;
+} Offset;
+
+static Offset cipher_offset[CIPHER_COUNT] =
+{
+ { 0, 0 }, /* 0 */
+ { 32, 64 }, /* 1 */
+ { 16, 64 }, /* 2 */
+ { 0, 64 }, /* 3 */
+ { 48, 32 }, /* 4 */
+ { 32, 32 }, /* 5 */
+ { 16, 32 }, /* 6 */
+ { 0, 32 }, /* 7 */
+ { 48, 0 }, /* 8 */
+ { 32, 0 }, /* 9 */
+ { 16, 0 }, /* - */
+};
+
+static Offset tile_offset[TILE_COUNT] =
+{
+ { 0, 32 }, /* nothing */
+ { 0, 0 }, /* 1 */
+ { 16, 0 }, /* 2 */
+ { 32, 0 }, /* 3 */
+ { 48, 0 }, /* 4 */
+ { 0, 16 }, /* 5 */
+ { 16, 16 }, /* 6 */
+ { 32, 16 }, /* 7 */
+ { 48, 16 }, /* 8 */
+ { 16, 32 }, /* unknown */
+ { 32, 32 }, /* flag */
+ { 32, 48 }, /* bomb */
+ { 48, 32 }, /* bomb wrong */
+ { 48, 48 }, /* bomb exploded */
+};
+
+static int cipher_size[2] = { 16, 32 };
+
+static int tile_size[2] = { 16, 16 };
+
+static unsigned int **cipher_bmp = { 0 };
+
+static unsigned int **tile_bmp = { 0 };
+
+typedef struct Icon Icon;
+
+struct Icon
+{
+ const char *filename;
+ Offset *offset;
+ unsigned int **data;
+ int w;
+ int h;
+ int nbr;
+ int tile_sz;
+};
+
+unsigned int ** icon_create(Evas_Object *win, const Icon *ic)
+{
+ Evas_Object *o;
+ const char *filename;
+ unsigned int *m;
+ unsigned int **data;
+ int img_w;
+ int img_h;
+ int idx;
+ Evas_Load_Error err;
+
+ filename = ic->filename;
+
+ o = evas_object_image_filled_add(evas_object_evas_get(win));
+ evas_object_image_file_set(o, filename, NULL);
+ err = evas_object_image_load_error_get(o);
+ if (err != EVAS_LOAD_ERROR_NONE)
+ {
+ fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
+ filename, evas_load_error_str(err));
+ return NULL;
+ }
+
+ evas_object_image_size_get(o, &img_w, &img_h);
+ evas_object_image_size_set(o, img_w, img_h);
+ m = evas_object_image_data_get(o, EINA_TRUE);
+
+ data = "" sizeof(unsigned int *));
+ if (!data)
+ goto del_o;
+
+ for (idx = 0; idx < ic->nbr; idx++)
+ {
+ unsigned int *bmp;
+
+ data[idx] = calloc(ic->w * ic->h * ic->tile_sz * ic->tile_sz, sizeof(unsigned int));
+ if (!data[idx])
+ {
+ goto del_data;
+ }
+
+ bmp = m + ic->offset[idx].y * img_w + ic->offset[idx].x;
+
+ for (int l = 0; l < ic->h; l++)
+ {
+ for (int c = 0; c < ic->w; c++)
+ {
+ unsigned int col = bmp[l * img_w + c];
+
+ for (int j = 0; j < ic->tile_sz; j++)
+ {
+ for (int i = 0; i < ic->tile_sz; i++)
+ {
+ data[idx][(ic->tile_sz * l + j) * ic->w * ic->tile_sz + ic->tile_sz * c + i] = col;
+ }
+ }
+ }
+ }
+ }
+
+ return data;
+
+ del_data:
+ for (idx = 0; idx < ic->nbr; idx++)
+ free(data[idx]);
+ free(data);
+ del_o:
+ evas_object_del(o);
+ return NULL;
+}
+
+void icon_init(Evas_Object *win, int tile_sz)
+{
+ Icon ic;
+
+ ic.filename = "C:/Documents/msys2_2/home/vincent.torri/gitroot/elimine/data/images/countersmall.png";
+ ic.offset = cipher_offset;
+ ic.data = ""
+ ic.w = cipher_size[0];
+ ic.h = cipher_size[1];
+ ic.nbr = CIPHER_COUNT;
+ ic.tile_sz = tile_sz;
+
+ cipher_bmp = icon_create(win, &ic);
+
+ ic.filename = "C:/Documents/msys2_2/home/vincent.torri/gitroot/elimine/data/images/WinmineXP.png";
+ ic.offset = tile_offset;
+ ic.data = ""
+ ic.w = tile_size[0];
+ ic.h = tile_size[1];
+ ic.nbr = TILE_COUNT;
+ ic.tile_sz = tile_sz;
+
+ tile_bmp = icon_create(win, &ic);
+}
+
+void cipher_size_get(int *w, int *h)
+{
+ if (w) *w = cipher_size[0];
+ if (h) *h = cipher_size[1];
+}
+
+unsigned int *cipher_bmp_get(Cipher_Type t)
+{
+ return cipher_bmp[t];
+}
+
+void tile_size_get(int *w, int *h)
+{
+ if (w) *w = tile_size[0];
+ if (h) *h = tile_size[1];
+}
+
+unsigned int *tile_bmp_get(Tile_Type t)
+{
+ return tile_bmp[t];
+}
diff --git a/src/bin/icon.h b/src/bin/icon.h
new file mode 100644
index 0000000..b9f7530
--- /dev/null
+++ b/src/bin/icon.h
@@ -0,0 +1,55 @@
+/*
+ * SPDX-FileCopyrightText: Vincent Torri <vincent.to...@gmail.com>
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef ICON_H
+#define ICON_H
+
+typedef enum
+{
+ CIPHER_ZERO,
+ CIPHER_ONE,
+ CIPHER_TWO,
+ CIPHER_THREE,
+ CIPHER_FOUR,
+ CIPHER_FIVE,
+ CIPHER_SIX,
+ CIPHER_SEVEN,
+ CIPHER_HEIGHT,
+ CIPHER_NINE,
+ CIPHER_DASH,
+ CIPHER_COUNT
+} Cipher_Type;
+
+typedef enum
+{
+ TILE_NOTHING,
+ TILE_ONE,
+ TILE_TWO,
+ TILE_THREE,
+ TILE_FOUR,
+ TILE_FIVE,
+ TILE_SIX,
+ TILE_SEVEN,
+ TILE_HEIGHT,
+ TILE_UNKNOWN,
+ TILE_FLAG,
+ TILE_BOMB,
+ TILE_BOMB_WRONG,
+ TILE_BOMB_EXPLODED,
+ TILE_COUNT
+} Tile_Type;
+
+void icon_init(Evas_Object *win, int tile_sz);
+
+void cipher_size_get(int *w, int *h);
+
+unsigned int *cipher_bmp_get(Cipher_Type t);
+
+void tile_size_get(int *w, int *h);
+
+unsigned int *tile_bmp_get(Tile_Type t);
+
+
+#endif /* ICON_H */
diff --git a/src/bin/meson.build b/src/bin/meson.build
index 38cd6f1..22e1894 100644
--- a/src/bin/meson.build
+++ b/src/bin/meson.build
@@ -3,7 +3,7 @@
elimine = executable('elimine',
- files('elimine.c'),
+ files(['elimine.c', 'icon.c']),
dependencies : [ elm_deps ],
install : true
)
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.