changeset 134:197374e9f0b2

cmake: prefix assets with their directory
author David Demelier <markand@malikania.fr>
date Sun, 11 Oct 2020 14:54:27 +0200
parents c46f80820b42
children eadfed7674ac
files cmake/MolkoBuildAssets.cmake examples/example-drawable.c examples/example-inventory.c examples/example-sound.c libadventure/CMakeLists.txt libadventure/adventure/assets/sprites/john.png libadventure/adventure/mainmenu_state.c libadventure/adventure/panic_state.c libadventure/adventure/splashscreen_state.c libcore/CMakeLists.txt libcore/core/assets/sprites/test-walk.png libcore/core/theme.c tests/test-map.c
diffstat 13 files changed, 27 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/cmake/MolkoBuildAssets.cmake	Sun Oct 11 14:41:31 2020 +0200
+++ b/cmake/MolkoBuildAssets.cmake	Sun Oct 11 14:54:27 2020 +0200
@@ -25,12 +25,12 @@
 		set(output ${CMAKE_CURRENT_BINARY_DIR}/${output})
 		get_filename_component(outputdir ${output} DIRECTORY)
 		get_filename_component(name ${basename} NAME_WE)
-
+		get_filename_component(category ${outputdir} NAME)
 		file(MAKE_DIRECTORY ${outputdir})
 
 		add_custom_command(
 			OUTPUT ${output}
-			COMMAND $<TARGET_FILE:bcc> -s ${a} ${name} > ${output}
+			COMMAND $<TARGET_FILE:bcc> -s ${a} ${category}-${name} > ${output}
 			DEPENDS $<TARGET_FILE:bcc>
 			COMMENT "Generate header file for ${basename}"
 		)
--- a/examples/example-drawable.c	Sun Oct 11 14:41:31 2020 +0200
+++ b/examples/example-drawable.c	Sun Oct 11 14:54:27 2020 +0200
@@ -83,7 +83,7 @@
 		panic();
 
 	/* 0: Explosion animation. */
-	if (!image_openmem(&explosion_tex, explosion, sizeof (explosion)))
+	if (!image_openmem(&explosion_tex, sprites_explosion, sizeof (sprites_explosion)))
 		panic();
 
 	sprite_init(&explosion_sprite, &explosion_tex, 256, 256);
--- a/examples/example-inventory.c	Sun Oct 11 14:41:31 2020 +0200
+++ b/examples/example-inventory.c	Sun Oct 11 14:54:27 2020 +0200
@@ -45,8 +45,8 @@
 	struct item item;
 } items[] = {
 	{
-		.data = potion,
-		.datasz = sizeof (potion),
+		.data = images_potion,
+		.datasz = sizeof (images_potion),
 		.item = {
 			.name = "Potion",
 			.summary = "Recover 100 HP.",
@@ -54,8 +54,8 @@
 		}
 	},
 	{
-		.data = fish,
-		.datasz = sizeof (fish),
+		.data = images_fish,
+		.datasz = sizeof (images_fish),
 		.item = {
 			.name = "Fish",
 			.summary = "Recover 1000 HP.",
@@ -63,8 +63,8 @@
 		}
 	},
 	{
-		.data = sword,
-		.datasz = sizeof (sword),
+		.data = images_sword,
+		.datasz = sizeof (images_sword),
 		.item = {
 			.name = "Sword",
 			.summary = "A very basic sword.",
--- a/examples/example-sound.c	Sun Oct 11 14:41:31 2020 +0200
+++ b/examples/example-sound.c	Sun Oct 11 14:54:27 2020 +0200
@@ -51,7 +51,7 @@
 	    !theme_init())
 		panic();
 
-	if (!sound_openmem(&sound, vabsounds_romance, sizeof (vabsounds_romance)))
+	if (!sound_openmem(&sound, sounds_vabsounds_romance, sizeof (sounds_vabsounds_romance)))
 		panic();
 }
 
--- a/libadventure/CMakeLists.txt	Sun Oct 11 14:41:31 2020 +0200
+++ b/libadventure/CMakeLists.txt	Sun Oct 11 14:54:27 2020 +0200
@@ -34,6 +34,7 @@
 	${libadventure_SOURCE_DIR}/adventure/assets/fonts/teutonic.ttf
 	${libadventure_SOURCE_DIR}/adventure/assets/fonts/pirata-one.ttf
 	${libadventure_SOURCE_DIR}/adventure/assets/maps/overworld.map
+	${libadventure_SOURCE_DIR}/adventure/assets/sprites/john.png
 	${libadventure_SOURCE_DIR}/adventure/assets/tilesets/world.png
 )
 
Binary file libadventure/adventure/assets/sprites/john.png has changed
--- a/libadventure/adventure/mainmenu_state.c	Sun Oct 11 14:41:31 2020 +0200
+++ b/libadventure/adventure/mainmenu_state.c	Sun Oct 11 14:54:27 2020 +0200
@@ -37,6 +37,7 @@
 #include <adventure/assets/fonts/pirata-one.h>
 #include <adventure/assets/maps/overworld.h>
 #include <adventure/assets/tilesets/world.h>
+#include <adventure/assets/sprites/john.h>
 
 #include "mainmenu_state.h"
 #include "splashscreen_state.h"
@@ -67,9 +68,9 @@
 static void
 enter(void)
 {
-	struct font font = { 0 };
+	struct font font;
 
-	if (!font_openmem(&font, pirata_one, sizeof (pirata_one), 30))
+	if (!font_openmem(&font, fonts_pirata_one, sizeof (fonts_pirata_one), 30))
 		panic();
 
 	substate = SUBSTATE_MOVING;
@@ -97,18 +98,18 @@
 new(void)
 {
 	/* Prepare map. */
-	if (!map_data_openmem(&map_state_data.map.data, overworld, sizeof (overworld)))
+	if (!map_data_openmem(&map_state_data.map.data, maps_overworld, sizeof (maps_overworld)))
 		panicf("Unable to open map 'test'");
 
 	// TODO: this is temporary.
-	if (!image_openmem(&tileset, world, sizeof (world)))
+	if (!image_openmem(&tileset, tilesets_world, sizeof (tilesets_world)))
 		panic();
 	
 	if (!map_init(&map_state_data.map.map, &map_state_data.map.data, &tileset))
 		panic();
 
 	/* Prepare image and sprite. */
-	if (!(image_openmem(&image, test_walk, sizeof (test_walk))))
+	if (!(image_openmem(&image, sprites_john, sizeof (sprites_john))))
 		panic();
 
 	sprite_init(&map_state_data.player.sprite, &image, 48, 48);
--- a/libadventure/adventure/panic_state.c	Sun Oct 11 14:41:31 2020 +0200
+++ b/libadventure/adventure/panic_state.c	Sun Oct 11 14:54:27 2020 +0200
@@ -222,6 +222,6 @@
 	 * useful information to the screen so as last resort print them
 	 * on the console.
 	 */
-	if (!(font_openmem(&data.font, lato, sizeof (lato), SIZE)))
+	if (!(font_openmem(&data.font, fonts_lato, sizeof (fonts_lato), SIZE)))
 		die("%s", error());
 }
--- a/libadventure/adventure/splashscreen_state.c	Sun Oct 11 14:41:31 2020 +0200
+++ b/libadventure/adventure/splashscreen_state.c	Sun Oct 11 14:54:27 2020 +0200
@@ -44,7 +44,7 @@
 		.color = 0x000000ff
 	};
 
-	if (!(font_openmem(&font, teutonic, sizeof (teutonic), 130)))
+	if (!(font_openmem(&font, fonts_teutonic, sizeof (fonts_teutonic), 130)))
 		panic();
 	if (!(font_render(&font, &splashscreen_state_data.text, "Molko's Adventure")))
 		panic();
--- a/libcore/CMakeLists.txt	Sun Oct 11 14:41:31 2020 +0200
+++ b/libcore/CMakeLists.txt	Sun Oct 11 14:54:27 2020 +0200
@@ -23,7 +23,6 @@
 	${libcore_SOURCE_DIR}/core/assets/fonts/comic-neue.ttf
 	${libcore_SOURCE_DIR}/core/assets/fonts/f25-bank-printer.ttf
 	${libcore_SOURCE_DIR}/core/assets/images/message.png
-	${libcore_SOURCE_DIR}/core/assets/sprites/test-walk.png
 )
 
 set(
Binary file libcore/core/assets/sprites/test-walk.png has changed
--- a/libcore/core/theme.c	Sun Oct 11 14:41:31 2020 +0200
+++ b/libcore/core/theme.c	Sun Oct 11 14:54:27 2020 +0200
@@ -174,8 +174,8 @@
 	struct font **dest;
 	struct font font;
 } default_fonts[] = {
-	FONT(f25_bank_printer, 10, THEME_FONT_DEBUG),
-	FONT(comic_neue, 20, THEME_FONT_INTERFACE)
+	FONT(fonts_f25_bank_printer, 10, THEME_FONT_DEBUG),
+	FONT(fonts_comic_neue, 20, THEME_FONT_INTERFACE)
 };
 
 bool
--- a/tests/test-map.c	Sun Oct 11 14:41:31 2020 +0200
+++ b/tests/test-map.c	Sun Oct 11 14:54:27 2020 +0200
@@ -37,7 +37,7 @@
 {
 	struct map_data map;
 
-	GREATEST_ASSERT(map_data_openmem(&map, sample_map, sizeof (sample_map)));
+	GREATEST_ASSERT(map_data_openmem(&map, maps_sample_map, sizeof (maps_sample_map)));
 	GREATEST_ASSERT_STR_EQ("This is a test map", map.title);
 	GREATEST_ASSERT_EQ(2, map.w);
 	GREATEST_ASSERT_EQ(2, map.h);
@@ -59,7 +59,7 @@
 {
 	struct map_data map;
 
-	GREATEST_ASSERT(!map_data_openmem(&map, error_title, sizeof (error_title)));
+	GREATEST_ASSERT(!map_data_openmem(&map, maps_error_title, sizeof (maps_error_title)));
 	GREATEST_PASS();
 }
 
@@ -68,7 +68,7 @@
 {
 	struct map_data map;
 
-	GREATEST_ASSERT(!map_data_openmem(&map, error_width, sizeof (error_width)));
+	GREATEST_ASSERT(!map_data_openmem(&map, maps_error_width, sizeof (maps_error_width)));
 	GREATEST_PASS();
 }
 
@@ -77,7 +77,7 @@
 {
 	struct map_data map;
 
-	GREATEST_ASSERT(!map_data_openmem(&map, error_height, sizeof (error_height)));
+	GREATEST_ASSERT(!map_data_openmem(&map, maps_error_height, sizeof (maps_error_height)));
 	GREATEST_PASS();
 }
 
@@ -86,7 +86,7 @@
 {
 	struct map_data map;
 
-	GREATEST_ASSERT(!map_data_openmem(&map, error_tilewidth, sizeof (error_tilewidth)));
+	GREATEST_ASSERT(!map_data_openmem(&map, maps_error_tilewidth, sizeof (maps_error_tilewidth)));
 	GREATEST_PASS();
 }
 
@@ -95,7 +95,7 @@
 {
 	struct map_data map;
 
-	GREATEST_ASSERT(!map_data_openmem(&map, error_tileheight, sizeof (error_tileheight)));
+	GREATEST_ASSERT(!map_data_openmem(&map, maps_error_tileheight, sizeof (maps_error_tileheight)));
 	GREATEST_PASS();
 }