diff options
| author | Olivier Gayot <olivier.gayot@sigexec.com> | 2023-02-12 00:18:03 +0100 | 
|---|---|---|
| committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2023-02-12 00:18:31 +0100 | 
| commit | 58adb09ef144beecfbb89b58c5735c0142c6f999 (patch) | |
| tree | fba6bd7cec0bc22603767af0c1629567a5194e46 | |
| parent | 34500f10c7a306103ef8e38fb29f64e90c9ab122 (diff) | |
Load images from their installation directory
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
| -rw-r--r-- | config.h.in | 1 | ||||
| -rw-r--r-- | meson.build | 8 | ||||
| -rw-r--r-- | src/init.c | 16 | 
3 files changed, 19 insertions, 6 deletions
| diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..d293f49 --- /dev/null +++ b/config.h.in @@ -0,0 +1 @@ +#define DATADIR  "@datadir@" diff --git a/meson.build b/meson.build index cc25b39..8ff2ca9 100644 --- a/meson.build +++ b/meson.build @@ -20,3 +20,11 @@ executable('camelsweeper', src_camelsweeper,    install: true)  install_subdir('img', install_dir: get_option('datadir') / 'camelsweeper') + + +conf_data = configuration_data() +conf_data.set('datadir', get_option('prefix') / get_option('datadir') / 'camelsweeper') + +configure_file(input: 'config.h.in', +  output: 'config.h', +  configuration: conf_data) @@ -8,11 +8,15 @@  ** Last update Sun Apr 22 16:09:49 2012 olivier gayot  */ +#include	"config.h" +  #include	<stdio.h>  #include	<sdl_digit.h>  #include	<strings.h>  #include	"minesweeper.h" +#define IMG_DIR  DATADIR "/img" +  static void		rand_bombs(bool bombs[BLOCK_H][BLOCK_W]);  static SDL_Surface	*xSDL_LoadBMP(const char *path); @@ -51,14 +55,14 @@ void		load_surfaces(void) {    char		str[256];    for (int i = 0; i < 9; ++i) { -    snprintf(str, 256, "img/%d.bmp", i); +    snprintf(str, 256, IMG_DIR "/%d.bmp", i);      surf_number[i] = xSDL_LoadBMP(str);    } -  bmb_surf = xSDL_LoadBMP("img/b.bmp"); -  hidden_surf = xSDL_LoadBMP("img/hidden.bmp"); -  flag_surf = xSDL_LoadBMP("img/flag.bmp"); -  wrong_flag = xSDL_LoadBMP("img/wrong_flag.bmp"); -  selection_surf = xSDL_LoadBMP("img/selection.bmp"); +  bmb_surf = xSDL_LoadBMP(IMG_DIR "/b.bmp"); +  hidden_surf = xSDL_LoadBMP(IMG_DIR "/hidden.bmp"); +  flag_surf = xSDL_LoadBMP(IMG_DIR "/flag.bmp"); +  wrong_flag = xSDL_LoadBMP(IMG_DIR "/wrong_flag.bmp"); +  selection_surf = xSDL_LoadBMP(IMG_DIR "/selection.bmp");    SDL_SetColorKey(selection_surf, SDL_SRCCOLORKEY, 0);  } | 
