changeset 364:570ab19bf268

misc: start removing adventure from library
author David Demelier <markand@malikania.fr>
date Sun, 24 Oct 2021 11:29:04 +0200
parents c74ab1bbedec
children 06badab52877
files CMakeLists.txt cmake/MlkExecutable.cmake examples/example-action/CMakeLists.txt examples/example-action/assets/sprites/chest.png examples/example-action/assets/sprites/people.png examples/example-action/main.c examples/example-animation/CMakeLists.txt examples/example-animation/assets/sprites/numbers.png examples/example-animation/main.c examples/example-audio/CMakeLists.txt examples/example-audio/assets/music/vabsounds-romance.ogg examples/example-audio/assets/sounds/fire.wav examples/example-audio/main.c examples/example-cursor/CMakeLists.txt examples/example-debug/CMakeLists.txt examples/example-drawable/CMakeLists.txt examples/example-drawable/assets/sprites/explosion.png examples/example-drawable/main.c examples/example-font/CMakeLists.txt examples/example-gridmenu/CMakeLists.txt examples/example-label/CMakeLists.txt examples/example-message/CMakeLists.txt examples/example-notify/CMakeLists.txt examples/example-sprite/CMakeLists.txt examples/example-sprite/assets/sprites/people.png examples/example-sprite/main.c examples/example-trace/CMakeLists.txt examples/example-trace/main.c examples/example-trace/trace_hud.c examples/example-trace/trace_hud.h examples/example-ui/CMakeLists.txt src/libmlk-adventure/CMakeLists.txt src/libmlk-adventure/adventure/action/chest.c src/libmlk-adventure/adventure/action/chest.h src/libmlk-adventure/adventure/action/spawner.c src/libmlk-adventure/adventure/action/spawner.h src/libmlk-adventure/adventure/action/teleport.c src/libmlk-adventure/adventure/action/teleport.h src/libmlk-adventure/adventure/adventure_p.h src/libmlk-adventure/adventure/assets.c src/libmlk-adventure/adventure/assets.h src/libmlk-adventure/adventure/character/black-cat.c src/libmlk-adventure/adventure/character/black-cat.h src/libmlk-adventure/adventure/character/neth.c src/libmlk-adventure/adventure/character/neth.h src/libmlk-adventure/adventure/dialog/save.c src/libmlk-adventure/adventure/dialog/save.h src/libmlk-adventure/adventure/item/potion.c src/libmlk-adventure/adventure/item/potion.h src/libmlk-adventure/adventure/mapscene/mapscene.c src/libmlk-adventure/adventure/mapscene/mapscene.h src/libmlk-adventure/adventure/molko.c src/libmlk-adventure/adventure/molko.h src/libmlk-adventure/adventure/spell/fire-minor.c src/libmlk-adventure/adventure/spell/fire-minor.h src/libmlk-adventure/adventure/state/battle.c src/libmlk-adventure/adventure/state/battle.h src/libmlk-adventure/adventure/state/continue.c src/libmlk-adventure/adventure/state/continue.h src/libmlk-adventure/adventure/state/mainmenu.c src/libmlk-adventure/adventure/state/mainmenu.h src/libmlk-adventure/adventure/state/map.c src/libmlk-adventure/adventure/state/map.h src/libmlk-adventure/adventure/state/panic.c src/libmlk-adventure/adventure/state/panic.h src/libmlk-adventure/adventure/state/splashscreen.c src/libmlk-adventure/adventure/state/splashscreen.h src/libmlk-adventure/adventure/trace_hud.c src/libmlk-adventure/adventure/trace_hud.h src/libmlk-adventure/nls/fr.po src/libmlk-adventure/nls/libmlk-adventure.pot tests/CMakeLists.txt
diffstat 72 files changed, 270 insertions(+), 3508 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -102,16 +102,12 @@
 add_subdirectory(src/libmlk-core)
 add_subdirectory(src/libmlk-ui)
 add_subdirectory(src/libmlk-rpg)
-add_subdirectory(src/libmlk-adventure)
-add_subdirectory(src/libmlk-data)
 
 if (MLK_WITH_JS)
 	add_subdirectory(src/libmlk-core-js)
 	add_subdirectory(src/mlk-run)
 endif ()
 
-add_subdirectory(src/mlk-adventure)
-
 if (MLK_WITH_TESTS)
 	enable_testing()
 	add_subdirectory(tests)
@@ -120,4 +116,3 @@
 if (MLK_WITH_EXAMPLES)
 	add_subdirectory(examples)
 endif ()
-
--- a/cmake/MlkExecutable.cmake	Sun Oct 24 09:55:12 2021 +0200
+++ b/cmake/MlkExecutable.cmake	Sun Oct 24 11:29:04 2021 +0200
@@ -33,12 +33,7 @@
 	endif ()
 
 	add_executable(${EXE_NAME} ${EXE_SOURCES} ${HEADERS})
-	set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
-
-	foreach (cfg ${CMAKE_CONFIGURATION_TYPES})
-		string(TOUPPER ${cfg} cfg)
-		set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${CFG} ${CMAKE_SOURCE_DIR})
-	endforeach ()
+	target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
 
 	if (EXE_FOLDER)
 		set_target_properties(${EXE_NAME} PROPERTIES FOLDER ${EXE_FOLDER})
--- a/examples/example-action/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-action/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -23,11 +23,18 @@
 	${example-action_SOURCE_DIR}/main.c
 )
 
+set(
+	ASSETS
+	${example-action_SOURCE_DIR}/assets/sprites/chest.png
+	${example-action_SOURCE_DIR}/assets/sprites/people.png
+)
+
 mlk_executable(
 	NAME example-action
 	FOLDER examples
 	LIBRARIES libmlk-rpg
-	SOURCES ${SOURCES}
+	SOURCES ${ASSETS} ${SOURCES}
+	ASSETS ${ASSETS}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-action_SOURCE_DIR} FILES ${ASSETS} ${SOURCES})
Binary file examples/example-action/assets/sprites/chest.png has changed
Binary file examples/example-action/assets/sprites/people.png has changed
--- a/examples/example-action/main.c	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-action/main.c	Sun Oct 24 11:29:04 2021 +0200
@@ -40,9 +40,11 @@
 #include <rpg/message.h>
 #include <rpg/rpg.h>
 
+#include <assets/sprites/chest.h>
+#include <assets/sprites/people.h>
+
 #define W       1280
 #define H       720
-#define PATH(r) util_pathf("%s/%s", sys_dir(SYS_DIR_DATA), r)
 
 #define MW      (W * 0.75)
 #define MX      ((W / 2) - (MW / 2))
@@ -252,7 +254,7 @@
 static void
 guide_init(void)
 {
-	if (image_open(&guide.image, PATH("sprites/people.png")) < 0)
+	if (image_openmem(&guide.image, assets_sprites_people, sizeof (assets_sprites_people)) < 0)
 		panic();
 
 	sprite_init(&guide.sprite, &guide.image, 48, 48);
@@ -300,7 +302,7 @@
 static void
 chest_init(void)
 {
-	if (image_open(&chest.image, PATH("sprites/chest.png")) < 0)
+	if (image_openmem(&chest.image, assets_sprites_chest, sizeof (assets_sprites_chest)) < 0)
 		panic();
 
 	sprite_init(&chest.sprite, &chest.image, 32, 32);
--- a/examples/example-animation/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-animation/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -23,11 +23,17 @@
 	${example-animation_SOURCE_DIR}/main.c
 )
 
+set(
+	ASSETS
+	${example-animation_SOURCE_DIR}/assets/sprites/numbers.png
+)
+
 mlk_executable(
 	NAME example-animation
 	FOLDER examples
 	LIBRARIES libmlk-ui
-	SOURCES ${SOURCES}
+	SOURCES ${ASSETS} ${SOURCES}
+	ASSETS ${ASSETS}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-animation_SOURCE_DIR} FILES ${ASSETS} ${SOURCES})
Binary file examples/example-animation/assets/sprites/numbers.png has changed
--- a/examples/example-animation/main.c	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-animation/main.c	Sun Oct 24 11:29:04 2021 +0200
@@ -33,9 +33,10 @@
 #include <ui/label.h>
 #include <ui/ui.h>
 
+#include <assets/sprites/numbers.h>
+
 #define W       1280
 #define H       720
-#define PATH(r) util_pathf("%s/%s", sys_dir(SYS_DIR_DATA), r)
 
 static struct label label = {
 	.text = "Keys: <Space> start or reset the animation.",
@@ -56,7 +57,7 @@
 		panic();
 	if (window_open("Example - Animation", W, H) < 0)
 		panic();
-	if (image_open(&numbers, PATH("sprites/numbers.png")) < 0)
+	if (image_openmem(&numbers, assets_sprites_numbers, sizeof (assets_sprites_numbers)) < 0)
 		panic();
 }
 
--- a/examples/example-audio/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-audio/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -23,11 +23,18 @@
 	${example-audio_SOURCE_DIR}/main.c
 )
 
+set(
+	ASSETS
+	${example-audio_SOURCE_DIR}/assets/music/vabsounds-romance.ogg
+	${example-audio_SOURCE_DIR}/assets/sounds/fire.wav
+)
+
 mlk_executable(
 	NAME example-audio
 	FOLDER examples
 	LIBRARIES libmlk-ui
-	SOURCES ${SOURCES}
+	SOURCES ${ASSETS} ${SOURCES}
+	ASSETS ${ASSETS}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-audio_SOURCE_DIR} FILES ${ASSETS} ${SOURCES})
Binary file examples/example-audio/assets/music/vabsounds-romance.ogg has changed
Binary file examples/example-audio/assets/sounds/fire.wav has changed
--- a/examples/example-audio/main.c	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-audio/main.c	Sun Oct 24 11:29:04 2021 +0200
@@ -32,9 +32,11 @@
 #include <ui/theme.h>
 #include <ui/ui.h>
 
+#include <assets/music/vabsounds-romance.h>
+#include <assets/sounds/fire.h>
+
 #define W       1280
 #define H       720
-#define PATH(r) util_pathf("%s/%s", sys_dir(SYS_DIR_DATA), r)
 
 static struct music music;
 static struct sound sound;
@@ -60,8 +62,8 @@
 		panic();
 	if (window_open("Example - Audio", W, H) < 0)
 		panic();
-	if (music_open(&music, PATH("music/vabsounds-romance.ogg")) < 0 ||
-	    sound_open(&sound, PATH("sounds/fire.wav")) < 0)
+	if (music_openmem(&music, assets_music_vabsounds_romance, sizeof (assets_music_vabsounds_romance)) < 0 ||
+	    sound_openmem(&sound, assets_sounds_fire, sizeof (assets_sounds_fire)) < 0)
 		panic();
 }
 
--- a/examples/example-cursor/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-cursor/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -30,4 +30,4 @@
 	SOURCES ${SOURCES}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-cursor_SOURCE_DIR} FILES ${SOURCES})
--- a/examples/example-debug/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-debug/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -30,4 +30,4 @@
 	SOURCES ${SOURCES}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-debug_SOURCE_DIR} FILES ${SOURCES})
--- a/examples/example-drawable/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-drawable/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -23,11 +23,17 @@
 	${example-drawable_SOURCE_DIR}/main.c
 )
 
+set(
+	ASSETS
+	${example-drawable_SOURCE_DIR}/assets/sprites/explosion.png
+)
+
 mlk_executable(
 	NAME example-drawable
 	FOLDER examples
 	LIBRARIES libmlk-ui
-	SOURCES ${SOURCES}
+	SOURCES ${ASSETS} ${SOURCES}
+	ASSETS ${ASSETS}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-drawable_SOURCE_DIR} FILES ${ASSETS} ${SOURCES})
Binary file examples/example-drawable/assets/sprites/explosion.png has changed
--- a/examples/example-drawable/main.c	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-drawable/main.c	Sun Oct 24 11:29:04 2021 +0200
@@ -40,9 +40,10 @@
 #include <ui/theme.h>
 #include <ui/ui.h>
 
+#include <assets/sprites/explosion.h>
+
 #define W       1280
 #define H       720
-#define PATH(r) util_pathf("%s/%s", sys_dir(SYS_DIR_DATA), r)
 
 static struct label help = {
 	.x = 10,
@@ -76,7 +77,7 @@
 		panic();
 
 	/* 0: Explosion animation. */
-	if (image_open(&explosion_tex, PATH("sprites/explosion.png")) < 0)
+	if (image_openmem(&explosion_tex, assets_sprites_explosion, sizeof (assets_sprites_explosion)) < 0)
 		panic();
 
 	sprite_init(&explosion_sprite, &explosion_tex, 256, 256);
--- a/examples/example-font/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-font/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -30,4 +30,4 @@
 	SOURCES ${SOURCES}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-font_SOURCE_DIR} FILES ${SOURCES})
--- a/examples/example-gridmenu/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-gridmenu/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -30,4 +30,4 @@
 	SOURCES ${SOURCES}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-gridmenu_SOURCE_DIR} FILES ${SOURCES})
--- a/examples/example-label/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-label/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -30,4 +30,4 @@
 	SOURCES ${SOURCES}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-label_SOURCE_DIR} FILES ${SOURCES})
--- a/examples/example-message/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-message/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -30,4 +30,4 @@
 	SOURCES ${SOURCES}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-message_SOURCE_DIR} FILES ${SOURCES})
--- a/examples/example-notify/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-notify/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -33,8 +33,7 @@
 	FOLDER examples
 	LIBRARIES libmlk-rpg
 	ASSETS ${ASSETS}
-	SOURCES ${SOURCES}
-	INCLUDES PRIVATE ${example-notify_BINARY_DIR}
+	SOURCES ${ASSETS} ${SOURCES}
 )
 
-source_group("" FILES ${SOURCES} ${ASSETS})
+source_group(TREE ${example-notify_SOURCE_DIR} FILES ${ASSETS} ${SOURCES})
--- a/examples/example-sprite/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-sprite/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -23,11 +23,17 @@
 	${example-sprite_SOURCE_DIR}/main.c
 )
 
+set(
+	ASSETS
+	${example-sprite_SOURCE_DIR}/assets/sprites/people.png
+)
+
 mlk_executable(
 	NAME example-sprite
 	FOLDER examples
 	LIBRARIES libmlk-ui
-	SOURCES ${SOURCES}
+	SOURCES ${ASSETS} ${SOURCES}
+	ASSETS ${ASSETS}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-sprite_SOURCE_DIR} FILES ${ASSETS} ${SOURCES})
Binary file examples/example-sprite/assets/sprites/people.png has changed
--- a/examples/example-sprite/main.c	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-sprite/main.c	Sun Oct 24 11:29:04 2021 +0200
@@ -37,9 +37,10 @@
 #include <ui/label.h>
 #include <ui/ui.h>
 
+#include <assets/sprites/people.h>
+
 #define W       1280
 #define H       720
-#define PATH(r) util_pathf("%s/%s", sys_dir(SYS_DIR_DATA), r)
 #define HEADER "Keys: <Left>/<Right> and <Up/Down> to select a column/row. Current: %u, %u (total %u/%u)"
 
 static char msg[512];
@@ -67,7 +68,7 @@
 		panic();
 	if (window_open("Example - Sprite", W, H) < 0)
 		panic();
-	if (image_open(&texture, PATH("sprites/people.png")) < 0)
+	if (image_openmem(&texture, assets_sprites_people, sizeof (assets_sprites_people)) < 0)
 		panic();
 
 	sprite_init(&sprite, &texture, 48, 48);
--- a/examples/example-trace/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-trace/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -21,13 +21,14 @@
 set(
 	SOURCES
 	${example-trace_SOURCE_DIR}/main.c
+	${example-trace_SOURCE_DIR}/trace_hud.c
 )
 
 mlk_executable(
 	NAME example-trace
 	FOLDER examples
-	LIBRARIES libmlk-adventure
+	LIBRARIES libmlk-rpg
 	SOURCES ${SOURCES}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-trace_SOURCE_DIR} FILES ${SOURCES})
--- a/examples/example-trace/main.c	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-trace/main.c	Sun Oct 24 11:29:04 2021 +0200
@@ -30,7 +30,7 @@
 #include <ui/theme.h>
 #include <ui/ui.h>
 
-#include <adventure/trace_hud.h>
+#include "trace_hud.h"
 
 #define W 1280
 #define H 720
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/example-trace/trace_hud.c	Sun Oct 24 11:29:04 2021 +0200
@@ -0,0 +1,145 @@
+/*
+ * trace_hud.c -- on screen hud
+ *
+ * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <core/action.h>
+#include <core/font.h>
+#include <core/trace.h>
+#include <core/window.h>
+
+#include <ui/label.h>
+#include <ui/theme.h>
+
+#include "trace_hud.h"
+
+#define LINES_MAX       (4)
+#define THEME(t)        ((t) ? (t) : theme_default())
+
+static struct {
+	char lines[LINES_MAX + 1][TRACE_LINE_MAX];
+	unsigned int elapsed;
+} data;
+
+struct trace_hud trace_hud = {
+	.timeout = TRACE_HUD_TIMEOUT_DEFAULT
+};
+
+void
+trace_hud_handler(const char *str)
+{
+	assert(str);
+
+	/* 1.Try to find an empty line. */
+	for (size_t i = 0; i < LINES_MAX; ++i) {
+		if (data.lines[i][0] == '\0') {
+			snprintf(data.lines[i], sizeof (data.lines[i]), "%s", str);
+			return;
+		}
+	}
+
+	/* 2. All lines are full, put in last one and move other. */
+	memmove(&data.lines[0], &data.lines[1], sizeof (data.lines[0]) * LINES_MAX - 1);
+	snprintf(data.lines[LINES_MAX - 1], sizeof (data.lines[0]), "%s", str);
+
+	/* 3. Reset elapsed time now. */
+	data.elapsed = 0;
+}
+
+void
+trace_hud_update(unsigned int ticks)
+{
+	data.elapsed += ticks;
+
+	/*
+	 * We have an empty line in the data.lines at LINES_MAX, so we simply so
+	 * to move the whole array.
+	 *
+	 * [0] = "abc"
+	 * [1] = "def"
+	 * [2] = "xyz"
+	 * [3] = "zef"
+	 * [n] = "ldkf"
+	 * [LINES_MAX + 1] = "\0"
+	 */
+	if (data.elapsed >= trace_hud.timeout) {
+		data.elapsed = 0;
+		memmove(&data.lines[0], &data.lines[1], sizeof (data.lines[0]) * LINES_MAX);
+	}
+}
+
+void
+trace_hud_draw(void)
+{
+	struct theme *th;
+	int x, y;
+
+	th = THEME(trace_hud.theme);
+	x = th->padding;
+	y = th->padding;
+
+	for (int i = 0; i < LINES_MAX && data.lines[i][0]; ++i) {
+		label_draw(&(struct label) {
+			.x = x,
+			.y = y,
+			.text = data.lines[i],
+			.theme = th,
+			.flags = LABEL_FLAGS_SHADOW
+		});
+
+		y += font_height(th->fonts[THEME_FONT_INTERFACE]);
+		y += th->padding;
+	}
+}
+
+void
+trace_hud_clear(void)
+{
+	memset(&data, 0, sizeof (data));
+}
+
+static int
+update(struct action *a, unsigned int ticks)
+{
+	(void)a;
+
+	trace_hud_update(ticks);
+
+	return 0;
+}
+
+static void
+draw(struct action *a)
+{
+	(void)a;
+
+	trace_hud_draw();
+}
+
+struct action *
+trace_hud_action(void)
+{
+	static struct action a = {
+		.update = update,
+		.draw = draw
+	};
+
+	return &a;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/example-trace/trace_hud.h	Sun Oct 24 11:29:04 2021 +0200
@@ -0,0 +1,49 @@
+/*
+ * trace_hud.h -- on screen hud
+ *
+ * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef EXAMPLES_TRACE_TRACE_HUD_H
+#define EXAMPLES_TRACE_TRACE_HUD_H
+
+#define TRACE_HUD_TIMEOUT_DEFAULT (3000)
+
+struct action;
+struct theme;
+
+struct trace_hud {
+	struct theme *theme;
+	unsigned int timeout;
+};
+
+extern struct trace_hud trace_hud;
+
+void
+trace_hud_handler(const char *);
+
+void
+trace_hud_update(unsigned int);
+
+void
+trace_hud_draw(void);
+
+void
+trace_hud_clear(void);
+
+struct action *
+trace_hud_action(void);
+
+#endif /* !EXAMPLES_TRACE_TRACE_HUD_H */
--- a/examples/example-ui/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/examples/example-ui/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -30,4 +30,4 @@
 	SOURCES ${SOURCES}
 )
 
-source_group("" FILES ${SOURCES})
+source_group(TREE ${example-ui_SOURCE_DIR} FILES ${SOURCES})
--- a/src/libmlk-adventure/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for Molko's Adventure
-#
-# Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-project(libmlk-adventure)
-
-set(
-	SOURCES
-	${libmlk-adventure_SOURCE_DIR}/adventure/action/chest.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/action/chest.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/action/spawner.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/action/spawner.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/action/teleport.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/action/teleport.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/adventure_p.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/assets.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/assets.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/character/black-cat.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/character/black-cat.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/character/neth.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/character/neth.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/dialog/save.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/dialog/save.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/item/potion.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/item/potion.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/mapscene/mapscene.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/mapscene/mapscene.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/molko.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/molko.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/spell/fire-minor.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/spell/fire-minor.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/battle.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/battle.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/continue.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/continue.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/mainmenu.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/mainmenu.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/map.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/map.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/panic.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/panic.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/splashscreen.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/state/splashscreen.h
-	${libmlk-adventure_SOURCE_DIR}/adventure/trace_hud.c
-	${libmlk-adventure_SOURCE_DIR}/adventure/trace_hud.h
-)
-
-set(
-	NLS
-	${libmlk-adventure_SOURCE_DIR}/nls/fr.po
-)
-
-mlk_library(
-	NAME libmlk-adventure
-	SOURCES ${SOURCES} ${NLS}
-	LANGS ${NLS}
-	LIBRARIES libmlk-rpg
-	INCLUDES
-		PUBLIC $<BUILD_INTERFACE:${libmlk-adventure_SOURCE_DIR}>
-)
-
-source_group(TREE ${libmlk-adventure_SOURCE_DIR} FILES ${SOURCES} ${NLS})
--- a/src/libmlk-adventure/adventure/action/chest.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
- * chest.c -- chest object
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <core/animation.h>
-#include <core/event.h>
-#include <core/maths.h>
-#include <core/panic.h>
-#include <core/sound.h>
-#include <core/sprite.h>
-
-#include <rpg/map.h>
-#include <rpg/save.h>
-#include <rpg/property.h>
-
-#include "chest.h"
-
-#define X(c)            ((c)->x - ((c)->map)->view_x)
-#define Y(c)            ((c)->y - ((c)->map)->view_y)
-#define W(c)            ((c)->animation.sprite->cellw)
-#define H(c)            ((c)->animation.sprite->cellh)
-#define TOLERANCE       (10)
-
-static int
-is_near(const struct chest *c)
-{
-	const int x          = c->x - c->map->player_sprite->cellw - TOLERANCE;
-	const int y          = c->y - c->map->player_sprite->cellh - TOLERANCE;
-	const unsigned int w = W(c) + c->map->player_sprite->cellw + (TOLERANCE * 2);
-	const unsigned int h = H(c) + c->map->player_sprite->cellh + (TOLERANCE * 2);
-
-	return maths_is_boxed(x, y, w, h, c->map->player_x, c->map->player_y);
-}
-
-static void
-invoke(struct chest *c)
-{
-	c->state = CHEST_STATE_ANIMATE;
-
-	animation_start(&c->animation);
-
-	if (c->sound)
-		sound_play(c->sound, -1, 0);
-}
-
-static void
-handle(struct action *act, const union event *ev)
-{
-	struct chest *c = act->data;
-
-	if (!is_near(c) || c->state != CHEST_STATE_CLOSED)
-		return;
-
-	switch (ev->type) {
-	case EVENT_KEYDOWN:
-		if (ev->key.key == KEY_ENTER)
-			invoke(c);
-		break;
-	case EVENT_CLICKDOWN:
-		if (maths_is_boxed(X(c), Y(c), W(c), H(c), ev->click.x, ev->click.y))
-			invoke(c);
-		break;
-	default:
-		break;
-	}
-}
-
-static int
-update(struct action *act, unsigned int ticks)
-{
-	struct chest *c = act->data;
-
-	if (c->state != CHEST_STATE_ANIMATE)
-		return 0;
-
-	if (animation_update(&c->animation, ticks)) {
-		c->state = CHEST_STATE_OPEN;
-
-		if (c->exec)
-			c->exec(c);
-	}
-
-	return 0;
-}
-
-static void
-draw(struct action *act)
-{
-	struct chest *c = act->data;
-
-	switch (c->state) {
-	case CHEST_STATE_OPEN:
-		sprite_draw(
-		    c->animation.sprite,
-		    c->animation.sprite->nrows - 1,
-		    c->animation.sprite->ncols - 1,
-		    X(c),
-		    Y(c)
-		);
-		break;
-	case CHEST_STATE_ANIMATE:
-		animation_draw(&c->animation, X(c), Y(c));
-		break;
-	default:
-		sprite_draw(c->animation.sprite, 0, 0, X(c), Y(c));
-		break;
-	}
-}
-
-void
-chest_init(struct chest *c)
-{
-	assert(c);
-
-	if (c->save && c->property) {
-		if (property_load(c->property, c->save) < 0)
-			panic();
-
-		/* TODO: add an utility. */
-		if (strcmp(c->property->value, "true") == 0)
-			c->state = CHEST_STATE_OPEN;
-	}
-}
-
-struct action *
-chest_action(struct chest *c)
-{
-	assert(c);
-
-	c->action.data = c;
-	c->action.handle = handle;
-	c->action.update = update;
-	c->action.draw = draw;
-
-	return &c->action;
-}
--- a/src/libmlk-adventure/adventure/action/chest.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * chest.h -- chest object
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_ACTION_CHEST_H
-#define MOLKO_ADVENTURE_ACTION_CHEST_H
-
-#include <core/action.h>
-#include <core/animation.h>
-#include <core/core.h>
-
-struct map;
-struct save;
-struct property;
-struct sound;
-
-enum chest_state {
-	CHEST_STATE_CLOSED,
-	CHEST_STATE_ANIMATE,
-	CHEST_STATE_OPEN
-};
-
-struct chest {
-	/* Mandatory. */
-	int x;
-	int y;
-	struct map *map;
-	struct animation animation;
-
-	/* Defaulted. */
-	enum chest_state state;
-	struct action action;
-
-	/* Optional. */
-	struct save *save;
-	struct property *property;
-	struct sound *sound;
-	void *data;
-	void (*exec)(struct chest *);
-};
-
-CORE_BEGIN_DECLS
-
-void
-chest_init(struct chest *c);
-
-struct action *
-chest_action(struct chest *c);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_ACTION_CHEST_H */
--- a/src/libmlk-adventure/adventure/action/spawner.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*
- * spawner.c -- spawn battle while moving
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <math.h>
-#include <stdlib.h>
-
-#include <core/alloc.h>
-#include <core/game.h>
-#include <core/util.h>
-
-#include <rpg/battle.h>
-#include <rpg/character.h>
-#include <rpg/map.h>
-
-#include <adventure/molko.h>
-
-#include <adventure/character/black-cat.h>
-
-#include "spawner.h"
-
-static inline unsigned int
-distance(const struct spawner *s)
-{
-	unsigned int gap_x = fmax(s->last_x, s->map->player_x) -
-	                     fmin(s->last_x, s->map->player_x);
-	unsigned int gap_y = fmax(s->last_y, s->map->player_y) -
-			     fmin(s->last_y, s->map->player_y);
-
-	return fmin(s->steps, gap_x + gap_y);
-}
-
-static void
-fight(struct spawner *s)
-{
-	(void)s;
-
-	struct battle *bt;
-
-	bt = alloc_new0(sizeof (*bt));
-
-	bt->enemies[0].ch = alloc_dup(&character_black_cat, sizeof (character_black_cat));
-	bt->enemies[0].x = 400;
-	bt->enemies[0].y = 50;
-	bt->enemies[1].ch = alloc_dup(&character_black_cat, sizeof (character_black_cat));
-	bt->enemies[1].x = 200;
-	bt->enemies[1].y = 100;
-
-	bt->inventory = &molko.inventory;
-
-	for (size_t i = 0; i < TEAM_MEMBER_MAX; ++i) {
-		if (molko.team.members[i]) {
-			bt->team[i].ch = alloc_dup(molko.team.members[i], sizeof (*molko.team.members[i]));
-			character_reset(bt->team[i].ch);
-			bt->team[i].ch->hp = bt->team[i].ch->hpmax;
-			bt->team[i].ch->mp = bt->team[i].ch->mpmax;
-		}
-	}
-
-	molko_fight(bt);
-}
-
-static int
-update(struct action *act, unsigned int ticks)
-{
-	(void)ticks;
-
-	struct spawner *s = act->data;
-
-	if (s->map->player_movement) {
-		s->steps -= distance(s);
-		s->last_x = s->map->player_x;
-		s->last_y = s->map->player_y;
-
-		if (s->steps == 0) {
-			spawner_init(s);
-			fight(s);
-		}
-	}
-
-	return 0;
-}
-
-void
-spawner_init(struct spawner *s)
-{
-	assert(s);
-
-	s->last_x = s->map->player_x;
-	s->last_y = s->map->player_y;
-	s->steps = util_nrand(s->low, s->high);
-}
-
-struct action *
-spawner_action(struct spawner *s)
-{
-	assert(s);
-
-	s->action.data = s;
-	s->action.update = update;
-
-	spawner_init(s);
-
-	return &s->action;
-}
--- a/src/libmlk-adventure/adventure/action/spawner.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * spawner.h -- spawn battle while moving
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_ACTION_SPAWNER_H
-#define MOLKO_ADVENTURE_ACTION_SPAWNER_H
-
-#include <core/action.h>
-#include <core/core.h>
-
-struct map;
-
-struct spawner {
-	struct map *map;
-	unsigned int low;
-	unsigned int high;
-	unsigned int steps;
-	struct action action;
-	int last_x;
-	int last_y;
-};
-
-CORE_BEGIN_DECLS
-
-void
-spawner_init(struct spawner *);
-
-struct action *
-spawner_action(struct spawner *);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_ACTION_SPAWNER_H */
--- a/src/libmlk-adventure/adventure/action/teleport.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
- * teleport.c -- teleport contact
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <core/action.h>
-#include <core/alloc.h>
-#include <core/maths.h>
-#include <core/painter.h>
-#include <core/panic.h>
-#include <core/texture.h>
-#include <core/window.h>
-
-#include <rpg/map.h>
-
-#include <adventure/molko.h>
-
-#include "teleport.h"
-
-static void
-draw(struct action *act)
-{
-	struct teleport *tp = act->data;
-
-	texture_set_blend_mode(&tp->overlay, TEXTURE_BLEND_BLEND);
-	texture_set_alpha_mod(&tp->overlay, tp->alpha);
-
-	PAINTER_BEGIN(&tp->overlay);
-	painter_set_color(0x000000ff);
-	painter_clear();
-	PAINTER_END();
-
-	texture_draw(&tp->overlay, 0, 0);
-}
-
-static int
-update_fadeout(struct action *act, unsigned int ticks)
-{
-	struct teleport *tp = act->data;
-
-	tp->elapsed += ticks;
-
-	if (tp->elapsed >= 10) {
-		if (tp->alpha >= 255) {
-			molko_teleport(tp->destination, tp->origin_x, tp->origin_y);
-			return 1;
-		}
-
-		tp->elapsed = 0;
-		tp->alpha += 5;
-	}
-
-	return 0;
-}
-
-static int
-update_touch(struct action *act, unsigned int ticks)
-{
-	(void)ticks;
-
-	struct teleport *tp  = act->data;
-	const int x          = tp->x - tp->map->player_sprite->cellw;
-	const int y          = tp->y - tp->map->player_sprite->cellh;
-	const unsigned int w = tp->w + tp->map->player_sprite->cellw;
-	const unsigned int h = tp->h + tp->map->player_sprite->cellh;
-
-	if (maths_is_boxed(x, y, w, h, tp->map->player_x, tp->map->player_y)) {
-		/* Stop movement and disable input. */
-		tp->map->player_movement = 0;
-		game.inhibit = INHIBIT_STATE_INPUT;
-
-		/*
-		 * We change our update function and add a draw function that
-		 * fade the screen out.
-		 */
-		if (texture_new(&tp->overlay, window.w, window.h) < 0)
-			panic();
-
-		act->update = update_fadeout;
-		act->draw = draw;
-	}
-
-	return 0;
-}
-
-static void
-finish(struct action *act)
-{
-	struct teleport *tp = act->data;
-
-	texture_finish(&tp->overlay);
-
-	free(act->data);
-}
-
-struct action *
-teleport_action(struct teleport *tp)
-{
-	assert(tp);
-
-	tp->action.data = tp;
-	tp->action.update = update_touch;
-	tp->action.finish = finish;
-
-	return &tp->action;
-}
--- a/src/libmlk-adventure/adventure/action/teleport.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * teleport.h -- teleport contact
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_ACTIONS_TELEPORT_H
-#define MOLKO_ADVENTURE_ACTIONS_TELEPORT_H
-
-#include <core/action.h>
-#include <core/core.h>
-#include <core/texture.h>
-
-struct map;
-
-struct teleport {
-	int x;
-	int y;
-	unsigned int w;
-	unsigned int h;
-	struct map *map;
-	char destination[256];
-	int origin_x;
-	int origin_y;
-	struct action action;
-	struct texture overlay;
-	unsigned int elapsed;
-	unsigned int alpha;
-};
-
-CORE_BEGIN_DECLS
-
-struct action *
-teleport_action(struct teleport *);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_ACTIONS_TELEPORT_H */
--- a/src/libmlk-adventure/adventure/adventure_p.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * adventure_p.h -- libmlk-adventure private definitions
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_ADVENTURE_P_H
-#define MOLKO_ADVENTURE_ADVENTURE_P_H
-
-#include "config.h"
-
-#if defined(MOLKO_WITH_NLS)
-#       include <libintl.h>
-#       define _(s)     dgettext("libmlk-adventure", s)
-#       define N_(s)    s
-#else
-#       define _(s)     s
-#       define N_(s)    s
-#endif
-
-#endif /* !MOLKO_ADVENTURE_ADVENTURE_P_H */
--- a/src/libmlk-adventure/adventure/assets.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
- * assets.c -- global atlas for every resources
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <core/image.h>
-#include <core/panic.h>
-#include <core/sound.h>
-#include <core/sprite.h>
-#include <core/texture.h>
-#include <core/util.h>
-
-#include <ui/theme.h>
-
-#include <adventure/molko.h>
-
-#include "assets.h"
-
-#define SPRITE(which, file, w, h)       { .index = which, .path = file, .cellw = w, .cellh = h }
-#define SOUND(which, file)              { .index = which, .path = file }
-
-static struct {
-	enum assets_sprite index;
-	const char *path;
-	unsigned int cellw;
-	unsigned int cellh;
-	struct texture texture;
-} table_sprites[] = {
-	SPRITE(ASSETS_SPRITE_UI_CURSOR, "sprites/ui-cursor.png", 24, 24),
-	SPRITE(ASSETS_SPRITE_CHEST, "sprites/chest.png", 32, 32),
-	SPRITE(ASSETS_SPRITE_CHARACTER_BLACK_CAT, "images/black-cat.png", 123, 161),
-	SPRITE(ASSETS_SPRITE_CHARACTER_NETH, "sprites/john-walk.png", 256, 256),
-	SPRITE(ASSETS_SPRITE_CHARACTER_NETH_SWORD, "sprites/john-sword.png", 256, 256),
-	SPRITE(ASSETS_SPRITE_FACES, "sprites/faces.png", 144, 144),
-	SPRITE(ASSETS_SPRITE_EXPLOSION, "sprites/explosion.png", 256, 256)
-};
-
-static struct {
-	enum assets_sound index;
-	const char *path;
-} table_sounds[] = {
-	SOUND(ASSETS_SOUND_ITEM_POTION, "sounds/potion.wav")
-};
-
-struct sprite assets_sprites[ASSETS_SPRITE_NUM];
-struct sound assets_sounds[ASSETS_SOUND_NUM];
-
-static void
-init_sprites(void)
-{
-	for (size_t i = 0; i < UTIL_SIZE(table_sprites); ++i) {
-		if (image_open(&table_sprites[i].texture, molko_path(table_sprites[i].path)) < 0)
-			panic();
-
-		sprite_init(&assets_sprites[table_sprites[i].index],
-		    &table_sprites[i].texture,
-		    table_sprites[i].cellw, table_sprites[i].cellh);
-	}
-}
-
-static void
-init_sounds(void)
-{
-	for (size_t i = 0; i < UTIL_SIZE(assets_sounds); ++i) {
-		if (sound_open(&assets_sounds[table_sounds[i].index], molko_path(table_sounds[i].path)) < 0)
-			panic();
-	}
-}
-
-void
-assets_init(void)
-{
-	init_sprites();
-	init_sounds();
-
-	/* Prepare the theme. */
-	theme_default()->sprites[THEME_SPRITE_CURSOR] = &assets_sprites[ASSETS_SPRITE_UI_CURSOR];
-}
-
-void
-assets_finish(void)
-{
-	for (size_t i = 0; i < UTIL_SIZE(table_sprites); ++i)
-		texture_finish(&table_sprites[i].texture);
-	for (size_t i = 0; i < UTIL_SIZE(table_sounds); ++i)
-		sound_finish(&assets_sounds[i]);
-}
--- a/src/libmlk-adventure/adventure/assets.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * assets.h -- global atlas for every resources
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_ASSETS_H
-#define MOLKO_ADVENTURE_ASSETS_H
-
-#include <core/core.h>
-#include <core/sound.h>
-#include <core/sprite.h>
-
-enum assets_sprite {
-	/* UI elements. */
-	ASSETS_SPRITE_UI_CURSOR,
-
-	/* Actions. */
-	ASSETS_SPRITE_CHEST,
-
-	/* Characters enemies. */
-	ASSETS_SPRITE_CHARACTER_BLACK_CAT,
-
-	/* Team assets. */
-	ASSETS_SPRITE_CHARACTER_NETH,
-	ASSETS_SPRITE_CHARACTER_NETH_SWORD,
-	ASSETS_SPRITE_FACES,
-
-	/* Animations. */
-	ASSETS_SPRITE_EXPLOSION,
-
-	ASSETS_SPRITE_NUM
-};
-
-enum assets_sound {
-	/* Items. */
-	ASSETS_SOUND_ITEM_POTION,
-
-	ASSETS_SOUND_NUM
-};
-
-CORE_BEGIN_DECLS
-
-extern struct sprite assets_sprites[ASSETS_SPRITE_NUM];
-extern struct sound assets_sounds[ASSETS_SOUND_NUM];
-
-void
-assets_init(void);
-
-void
-assets_finish(void);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_ASSETS_H */
--- a/src/libmlk-adventure/adventure/character/black-cat.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * black-cat.c -- Black Cat enemy
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <rpg/battle.h>
-#include <rpg/character.h>
-
-#include <adventure/adventure_p.h>
-#include <adventure/assets.h>
-
-#include "black-cat.h"
-
-static void
-reset(struct character *ch)
-{
-	ch->hpmax = ch->hp = 126;
-	ch->mpmax = ch->mp = 12;
-	ch->atk = 10;
-	ch->def = 8;
-	ch->agt = 13;
-}
-
-static void
-exec(struct character *ch, struct battle *bt)
-{
-	battle_attack(bt, ch, NULL);
-}
-
-struct character character_black_cat = {
-	.name = N_("Black Cat"),
-	.level = 4,
-	.sprites = {
-		[CHARACTER_SPRITE_NORMAL] = &assets_sprites[ASSETS_SPRITE_CHARACTER_BLACK_CAT]
-	},
-	.reset = reset,
-	.exec = exec
-};
--- a/src/libmlk-adventure/adventure/character/black-cat.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * black-cat.h -- Black Cat enemy
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_CHARACTER_BLACK_CAT_H
-#define MOLKO_ADVENTURE_CHARACTER_BLACK_CAT_H
-
-extern struct character character_black_cat;
-
-#endif /* !MOLKO_ADVENTURE_CHARACTER_BLACK_CAT_H */
--- a/src/libmlk-adventure/adventure/character/neth.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * neth.c -- Neth
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <rpg/character.h>
-
-#include <adventure/adventure_p.h>
-#include <adventure/assets.h>
-
-#include <adventure/spell/fire-minor.h>
-
-#include "neth.h"
-
-static void
-reset(struct character *ch)
-{
-	/* TODO: compute hpmax given the level. */
-	ch->hpmax = 570;
-	ch->mpmax = 50;
-	ch->atk = 22;
-	ch->def = 19;
-	ch->agt = 16;
-	ch->luck = 3;
-}
-
-struct character character_neth = {
-	.name = N_("Neth"),
-	.level = 1,
-	.sprites = {
-		[CHARACTER_SPRITE_NORMAL] = &assets_sprites[ASSETS_SPRITE_CHARACTER_NETH],
-		[CHARACTER_SPRITE_SWORD] = &assets_sprites[ASSETS_SPRITE_CHARACTER_NETH_SWORD]
-	},
-	.spells = {
-		&spell_fire_minor
-	},
-	.reset = reset
-};
--- a/src/libmlk-adventure/adventure/character/neth.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * neth.h -- Neth
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_CHARACTER_NETH_H
-#define MOLKO_ADVENTURE_CHARACTER_NETH_H
-
-extern struct character character_neth;
-
-#endif /* !MOLKO_ADVENTURE_CHARACTER_NETH_H */
--- a/src/libmlk-adventure/adventure/dialog/save.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,304 +0,0 @@
-/*
- * save.c -- select a save slot
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <port/port.h>
-
-#include <core/event.h>
-#include <core/font.h>
-#include <core/maths.h>
-#include <core/painter.h>
-#include <core/sprite.h>
-#include <core/window.h>
-
-#include <ui/align.h>
-#include <ui/label.h>
-#include <ui/frame.h>
-#include <ui/theme.h>
-
-#include <adventure/adventure_p.h>
-#include <adventure/assets.h>
-
-#include "save.h"
-
-#define THEME(s)        ((s)->theme ? (s)->theme : theme_default())
-#define LINES_MAX       (3)
-
-/* TODO: require a module for this*/
-#define TEAM_MAX        (4)
-
-struct geo {
-	int x, y;
-	unsigned int w, h;
-
-	/* Per line height/padding. */
-	unsigned int lh;
-	unsigned int lp;
-
-	struct {
-		int x, y;
-		unsigned int w, h;
-
-		/* Lines start positions. */
-		int lx, ly;
-
-		struct {
-			int x, y;
-			unsigned int w, h;
-		} faces[TEAM_MAX];
-	} saves[DIALOG_SAVE_MAX];
-};
-
-static struct geo
-geometry(const struct dialog_save *dlg)
-{
-	struct geo geo = {
-		.w = window.w - THEME(dlg)->padding * 40,
-		.h = window.h - THEME(dlg)->padding * 10,
-	};
-
-	align(ALIGN_CENTER, &geo.x, &geo.y, geo.w, geo.h, 0, 0, window.w, window.h);
-
-	for (size_t i = 0; i < DIALOG_SAVE_MAX; ++i) {
-		const unsigned int padding = THEME(dlg)->padding;
-
-		geo.saves[i].w  = (geo.w -  padding * 2);
-		geo.saves[i].h  = (geo.h - (padding * (DIALOG_SAVE_MAX + 1))) / DIALOG_SAVE_MAX;
-		geo.saves[i].x  = (geo.x +  padding);
-		geo.saves[i].y  = (geo.y +  padding) + i * (padding + geo.saves[i].h);
-		geo.saves[i].lx = (geo.saves[i].x + padding);
-
-		/* Compute lines padding (we draw LINES_MAX lines). */
-		geo.lh = font_height(THEME(dlg)->fonts[THEME_FONT_INTERFACE]);
-		geo.lp = (geo.saves[i].h - (geo.lh * LINES_MAX)) / (LINES_MAX + 1);
-
-		/* Compute faces position. */
-		for (size_t f = 0; f < TEAM_MAX; ++f) {
-			geo.saves[i].faces[f].h = geo.saves[i].h - padding * 2;
-			geo.saves[i].faces[f].w = geo.saves[i].faces[f].h;
-			geo.saves[i].faces[f].x = (geo.saves[i].x + padding) + (f * (padding + geo.saves[i].faces[f].w));
-			geo.saves[i].faces[f].y = (geo.saves[i].y + padding);
-			geo.saves[i].lx += geo.saves[i].faces[f].w + padding;
-		}
-
-		geo.saves[i].ly = geo.saves[i].y + geo.lp;
-	}
-
-	return geo;
-}
-
-static void
-draw_frame(const struct geo *geo)
-{
-	struct frame f = {
-		.x = geo->x,
-		.y = geo->y,
-		.w = geo->w,
-		.h = geo->h,
-	};
-
-	frame_draw(&f);
-}
-
-static void
-draw_save_box(const struct geo *geo, size_t i)
-{
-	/* TODO: change colors at some point. */
-	painter_set_color(0x884b2bff);
-	painter_draw_rectangle(geo->saves[i].x, geo->saves[i].y, geo->saves[i].w, geo->saves[i].h);
-}
-
-static void
-draw_save_faces(const struct dialog_save *dlg, const struct geo *geo, size_t i)
-{
-	(void)dlg;
-
-	/* TODO: determine face. */
-	for (size_t f = 0; f < TEAM_MAX; ++f) {
-		sprite_scale(&assets_sprites[ASSETS_SPRITE_FACES], 0, f,
-		    geo->saves[i].faces[f].x,
-		    geo->saves[i].faces[f].y,
-		    geo->saves[i].faces[f].w,
-		    geo->saves[i].faces[f].h
-		);
-	}
-}
-
-static void
-draw_save_times(const struct dialog_save *dlg, const struct geo *geo, size_t i)
-{
-	struct label label = {0};
-	char time[128], line[256];
-
-	label.theme = dlg->theme;
-	label.x = geo->saves[i].lx;
-	label.y = geo->saves[i].ly;
-	label.flags = LABEL_FLAGS_SHADOW;
-	label.text = line;
-
-	/* TODO: Get map position. */
-	port_strlcpy(line, "World", sizeof (line));
-	label_draw(&label);
-	
-	/* Last time. */
-	strftime(time, sizeof (time), "%c", localtime(&dlg->saves[i].updated));
-	snprintf(line, sizeof (line), _("Last played: %s"), time);
-
-	label.y += geo->lp + geo->lh;
-	label_draw(&label);
-
-	/* TODO: Time played. */
-	snprintf(line, sizeof (line), _("Time played: %s"), "100 hours");
-
-	label.y += geo->lp + geo->lh;
-	label_draw(&label);
-}
-
-static void
-draw_save(const struct dialog_save *dlg, const struct geo *geo, size_t i)
-{
-	draw_save_box(geo, i);
-
-	/* Do not draw the content if save is invalid. */
-	if (!save_ok(&dlg->saves[i]))
-		return;
-
-	draw_save_faces(dlg, geo, i);
-	draw_save_times(dlg, geo, i);
-}
-
-static void
-draw_saves(const struct dialog_save *dlg, const struct geo *geo)
-{
-	for (size_t i = 0; i < DIALOG_SAVE_MAX; ++i)
-		draw_save(dlg, geo, i);
-}
-
-static void
-draw_cursor(const struct dialog_save *dlg, const struct geo *geo)
-{
-	const struct sprite *sprite = &assets_sprites[ASSETS_SPRITE_UI_CURSOR];
-	const int x = geo->saves[dlg->selected].x - sprite->cellw;
-	const int y = geo->saves[dlg->selected].y;
-
-	sprite_draw(sprite, 1, 2, x, y + (geo->saves[dlg->selected].h / 2) - (sprite->cellh / 2));
-}
-
-static int
-handle_keydown(struct dialog_save *s, const struct event_key *key)
-{
-	assert(key->type == EVENT_KEYDOWN);
-
-	switch (key->key) {
-	case KEY_UP:
-		if (s->selected == 0)
-			s->selected = DIALOG_SAVE_MAX - 1;
-		else
-			s->selected --;
-		break;
-	case KEY_DOWN:
-		if (s->selected + 1 >= DIALOG_SAVE_MAX)
-			s->selected = 0;
-		else
-			s->selected ++;
-		break;
-	case KEY_ENTER:
-		return save_ok(&s->saves[s->selected]);
-	default:
-		break;
-	}
-
-	return 0;
-}
-
-static int
-handle_clickdown(struct dialog_save *s, const struct geo *geo, const struct event_click *clk)
-{
-	assert(clk->type == EVENT_CLICKDOWN);
-
-	for (size_t i = 0; i < DIALOG_SAVE_MAX; ++i) {
-		if (maths_is_boxed(geo->saves[i].x, geo->saves[i].y,
-		                   geo->saves[i].w, geo->saves[i].h,
-		                   clk->x, clk->y)) {
-			s->selected = i;
-			break;
-		}
-	}
-
-	return clk->clicks >= 2 && save_ok(&s->saves[s->selected]);
-}
-
-void
-dialog_save_init(struct dialog_save *s)
-{
-	assert(s);
-
-	for (size_t i = 0; i < DIALOG_SAVE_MAX; ++i)
-		save_open(&s->saves[i], i, SAVE_MODE_READ);
-}
-
-int
-dialog_save_handle(struct dialog_save *dlg, const union event *ev)
-{
-	assert(dlg);
-	assert(ev);
-
-	const struct geo geo = geometry(dlg);
-
-	switch (ev->type) {
-	case EVENT_KEYDOWN:
-		return handle_keydown(dlg, &ev->key);
-	case EVENT_CLICKDOWN:
-		return handle_clickdown(dlg, &geo, &ev->click);
-	default:
-		break;
-	}
-
-	return 0;
-}
-
-void
-dialog_save_update(struct dialog_save *dlg, unsigned int ticks)
-{
-	(void)ticks;
-	(void)dlg;
-}
-
-void
-dialog_save_draw(const struct dialog_save *dlg)
-{
-	assert(dlg);
-
-	const struct geo geo = geometry(dlg);
-
-	draw_frame(&geo);
-	draw_saves(dlg, &geo);
-	draw_cursor(dlg, &geo);
-}
-
-void
-dialog_save_finish(struct dialog_save *dlg)
-{
-	assert(dlg);
-
-	for (size_t i = 0; i < DIALOG_SAVE_MAX; ++i)
-		save_finish(&dlg->saves[i]);
-}
--- a/src/libmlk-adventure/adventure/dialog/save.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * save.h -- select a save slot
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_SAVE_H
-#define MOLKO_ADVENTURE_SAVE_H
-
-#include <core/core.h>
-
-#include <rpg/save.h>
-
-#define DIALOG_SAVE_MAX (6)
-
-union event;
-
-struct theme;
-
-struct dialog_save {
-	const struct theme *theme;
-	struct save saves[DIALOG_SAVE_MAX];
-	size_t selected;
-};
-
-CORE_BEGIN_DECLS
-
-void
-dialog_save_init(struct dialog_save *);
-
-int
-dialog_save_handle(struct dialog_save *, const union event *);
-
-void
-dialog_save_update(struct dialog_save *, unsigned int);
-
-void
-dialog_save_draw(const struct dialog_save *);
-
-void
-dialog_save_finish(struct dialog_save *);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_SAVE_H */
--- a/src/libmlk-adventure/adventure/item/potion.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * potion.h -- give some heal points
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-
-#include <core/sound.h>
-
-#include <rpg/battle.h>
-#include <rpg/character.h>
-#include <rpg/item.h>
-
-#include <adventure/adventure_p.h>
-#include <adventure/assets.h>
-
-#include "potion.h"
-
-static void
-heal(struct character *ch)
-{
-	ch->hp = fmin(ch->hp + 50, ch->hpmax);
-	sound_play(&assets_sounds[ASSETS_SOUND_ITEM_POTION], -1, 0);
-}
-
-static void
-exec_menu(const struct item *item, struct character *ch)
-{
-	(void)item;
-
-	heal(ch);
-}
-
-static void
-exec_battle(const struct item *item, struct battle *bt, struct character *src, struct character *tgt)
-{
-	(void)item;
-	(void)src;
-
-	heal(tgt);
-	battle_indicator_hp(bt, tgt, 50);
-}
-
-const struct item item_potion = {
-	.name = N_("Potion"),
-	.description = N_("Recover 50 HP."),
-	.exec_menu = exec_menu,
-	.exec_battle = exec_battle
-};
--- a/src/libmlk-adventure/adventure/item/potion.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * potion.h -- give some heal points
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_ITEM_POTION_H
-#define MOLKO_ADVENTURE_ITEM_POTION_H
-
-extern const struct item item_potion;
-
-#endif /* !MOLKO_ADVENTURE_ITEM_POTION_H */
--- a/src/libmlk-adventure/adventure/mapscene/mapscene.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/*
- * mapscene.c -- map scene loader with actions
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <core/alloc.h>
-#include <core/panic.h>
-#include <core/util.h>
-
-#include <rpg/map.h>
-
-#include <adventure/action/teleport.h>
-#include <adventure/action/spawner.h>
-
-#include <adventure/trace_hud.h>
-
-#include "mapscene.h"
-
-#define SEARCH(key, array, size, cmp) \
-	bsearch(key, array, UTIL_SIZE(array), size, (cmp_fn)cmp)
-
-typedef int (*cmp_fn)(const void *, const void *);
-
-struct action_loader {
-	const char *name;
-	void (*load)(struct map *, int, int, int, int, const char *);
-};
-
-struct mapscene_loader {
-	const char *name;
-	void (*load)(struct map *);
-};
-
-static void
-finish(struct action *a)
-{
-	free(a->data);
-}
-
-void
-load_teleport(struct map *m, int x, int y, int w, int h, const char *line)
-{
-	struct teleport *tp;
-
-	tp = alloc_new0(sizeof (*tp));
-	tp->x = x;
-	tp->y = y;
-	tp->w = w;
-	tp->h = h;
-	tp->map = m;
-
-	if (sscanf(line, "|%255[^|]|%d|%d", tp->destination, &tp->origin_x, &tp->origin_y) < 1)
-		panic();
-
-	teleport_action(tp)->finish = finish;
-	action_stack_add(&m->astack_par, &tp->action);
-}
-
-void
-load_spawner(struct map *m, int x, int y, int w, int h, const char *line)
-{
-	(void)x;
-	(void)y;
-	(void)w;
-	(void)h;
-
-	struct spawner *s;
-
-	s = alloc_new0(sizeof (*s));
-	s->map = m;
-
-	sscanf(line, "|%u|%u", &s->low, &s->high);
-
-	spawner_action(s)->finish = finish;
-	action_stack_add(&m->astack_par, &s->action);
-}
-
-/* Default objects supported on all maps. Must be sorted. */
-static const struct action_loader loaders[] = {
-	{ "spawner",    load_spawner    },
-	{ "teleport",   load_teleport   }
-};
-
-#if 0
-
-/* Per map actions, name refer to map names. Must be sorted. */
-static const struct action_loader maploaders[] = {
-};
-
-/* Per map loaders, to add extra data. Must be sorted. */
-static const struct mapscene_loader mapscenes[] = {
-};
-
-#endif
-
-static int
-cmp_name(const char *key, const struct action_loader *ld)
-{
-	return strncmp(key, ld->name, strlen(ld->name));
-}
-
-#if 0
-
-static int
-cmp_title(const char *key, const struct action_loader *ld)
-{
-	return strcmp(key, ld->name);
-}
-
-#endif
-
-void
-mapscene_load_action(struct map *m, int x, int y, int w, int h, const char *exec)
-{
-	assert(m);
-	assert(exec);
-
-	struct action_loader *ld;
-
-	/* 1. Load predefined loaders. */
-	if ((ld = SEARCH(exec, loaders, sizeof (*ld), cmp_name)))
-		ld->load(m, x, y, w, h, exec + strcspn(exec, "|"));
-
-#if 0
-	/* 2. Load per map objects. */
-	if ((ld = SEARCH(m->title, maploaders, sizeof (*ld), cmp_title)))
-		ld->load(m, x, y, w, h, exec);
-#endif
-}
-
-void
-mapscene_load(struct map *m)
-{
-	assert(m);
-
-#if 0
-	struct mapscene_loader *ld;
-
-	/* Same layout, can use cmp_title as well. */
-	if ((ld = SEARCH(m->title, mapscenes, sizeof (*ld), cmp_title)))
-		ld->load(m);
-#endif
-
-	/* Add the trace hud. */
-	action_stack_add(&m->astack_par, trace_hud_action());
-}
--- a/src/libmlk-adventure/adventure/mapscene/mapscene.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * mapscene.h -- map scene loader with actions
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_MAPSCENE_MAPSCENE_H
-#define MOLKO_ADVENTURE_MAPSCENE_MAPSCENE_H
-
-#include <core/core.h>
-
-struct map;
-
-CORE_BEGIN_DECLS
-
-void
-mapscene_load_action(struct map *, int, int, int, int, const char *);
-
-void
-mapscene_load(struct map *);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_MAPSCENE_MAPSCENE_H */
--- a/src/libmlk-adventure/adventure/molko.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/*
- * molko.c -- main structure for Molko's Adventure
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <string.h>
-#include <locale.h>
-
-#include <core/clock.h>
-#include <core/core.h>
-#include <core/event.h>
-#include <core/image.h>
-#include <core/panic.h>
-#include <core/sys.h>
-#include <core/trace.h>
-#include <core/translate.h>
-#include <core/util.h>
-#include <core/window.h>
-
-#include <ui/ui.h>
-
-#include <rpg/rpg.h>
-
-#include <adventure/state/battle.h>
-#include <adventure/state/panic.h>
-#include <adventure/state/splashscreen.h>
-#include <adventure/state/mainmenu.h>
-#include <adventure/state/map.h>
-
-#include "assets.h"
-#include "molko.h"
-#include "trace_hud.h"
-
-#define WINDOW_WIDTH    1280
-#define WINDOW_HEIGHT   720
-
-#include "character/neth.h"
-#include "item/potion.h"
-
-static jmp_buf panic_buf;
-
-struct molko molko;
-
-static void
-crash(void)
-{
-	game.inhibit = 0;
-	longjmp(panic_buf, 1);
-}
-
-void
-molko_init(void)
-{
-	setlocale(LC_ALL, "");
-
-	if (core_init("fr.malikania", "molko") < 0 || ui_init() < 0|| rpg_init() < 0)
-		panic();
-	if (translate_init("libmlk-adventure") < 0)
-		panic();
-	if (window_open("Molko's Adventure", WINDOW_WIDTH, WINDOW_HEIGHT) < 0)
-		panic();
-
-	/*
-	 * From here, we can setup our panic state which requires a window
-	 * to be running.
-	 */
-
-	/* Init other stuff. */
-	assets_init();
-
-	/* Start to splash. */
-	game_push(state_mainmenu_new());
-	molko.team.members[0] = &character_neth;
-	molko.team.members[1] = &character_neth;
-	inventory_add(&molko.inventory, &item_potion, 100);
-
-	/* Init unrecoverable panic state. */
-	molko.panic = state_panic_new();
-	panic_handler = crash;
-	trace_handler = trace_hud_handler;
-}
-
-void
-molko_run(void)
-{
-	if (setjmp(panic_buf) == 0) {
-		/* Initial game run. */
-		game_loop();
-	} else {
-		/* Clear event queue to avoid accidental key presses. */
-		for (union event ev; event_poll(&ev); )
-			continue;
-
-		game_push(molko.panic);
-		game_loop();
-	}
-}
-
-void
-molko_teleport(const char *map, int origin_x, int origin_y)
-{
-	molko.state = MOLKO_STATE_MAP;
-
-	game_push(state_map_new(map, origin_x, origin_y));
-	game.inhibit = INHIBIT_NONE;
-}
-
-void
-molko_fight(struct battle *bt)
-{
-	molko.state = MOLKO_STATE_BATTLE;
-
-	game_push(state_battle_new(bt));
-}
-
-const char *
-molko_path(const char *file)
-{
-	assert(file);
-
-	return util_pathf("%s/%s", sys_dir(SYS_DIR_DATA), file);
-}
-
-void
-molko_finish(void)
-{
-	window_finish();
-	rpg_finish();
-	ui_finish();
-	core_finish();
-}
--- a/src/libmlk-adventure/adventure/molko.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * molko.h -- main structure for Molko's Adventure
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_MOLKO_H
-#define MOLKO_ADVENTURE_MOLKO_H
-
-#include <core/core.h>
-#include <core/game.h>
-#include <core/texture.h>
-#include <core/sprite.h>
-
-#include <rpg/inventory.h>
-#include <rpg/team.h>
-
-struct battle;
-
-enum molko_state {
-	MOLKO_STATE_MAP,
-	MOLKO_STATE_BATTLE,
-};
-
-struct molko {
-	struct state *panic;
-
-	/* Make sure to set this accordingly when changing states. */
-	enum molko_state state;
-
-	struct team team;
-	struct inventory inventory;
-
-	/* For map state. */
-	struct texture map_player_texture;
-	struct sprite map_player_sprite;
-};
-
-CORE_BEGIN_DECLS
-
-extern struct molko molko;
-
-void
-molko_init(void);
-
-void
-molko_run(void);
-
-void
-molko_teleport(const char *map, int origin_x, int origin_y);
-
-void
-molko_fight(struct battle *bt);
-
-const char *
-molko_path(const char *file);
-
-void
-molko_finish(void);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_MOLKO_H */
--- a/src/libmlk-adventure/adventure/spell/fire-minor.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * fire-minor.c -- minor fire
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include <stdlib.h>
-
-#include <core/action.h>
-#include <core/alloc.h>
-#include <core/animation.h>
-#include <core/maths.h>
-
-#include <rpg/battle.h>
-#include <rpg/character.h>
-#include <rpg/selection.h>
-
-#include <adventure/adventure_p.h>
-#include <adventure/assets.h>
-
-#include "fire-minor.h"
-
-struct rendering {
-	struct battle *battle;
-	struct battle_entity *source;
-	struct battle_entity *target;
-	struct action action;
-	struct animation animation;
-};
-
-static int
-update(struct action *act, unsigned int ticks)
-{
-	struct rendering *rdr = act->data;
-
-	return animation_update(&rdr->animation, ticks);
-}
-
-static void
-draw(struct action *act)
-{
-	const struct rendering *rdr = act->data;
-
-	animation_draw(&rdr->animation, rdr->target->x, rdr->target->y);
-}
-
-static void
-end(struct action *act)
-{
-	struct rendering *rdr = act->data;
-	float base;
-
-	/* Compute damage. */
-	/* TODO: move this into a general maths computation. */
-	/* TODO: move min/max limits outside. */
-	base  = util_nrand(50, 70);
-	base += base * (maths_scale(rdr->source->ch->atk + rdr->source->ch->atkbonus, 0, 1000, 0, 100) / 100);
-
-	/* Reduce damage taken. */
-	base -= base * (maths_scale(rdr->target->ch->atk + rdr->target->ch->atkbonus, 0, 1000, 0, 100) / 200);
-	base  = base < 0 ? 0 : base;
-
-	/* TODO: add battle_damage function*/
-	rdr->target->ch->hp = fmax(rdr->target->ch->hp - base, rdr->target->ch->hp);
-	battle_indicator_hp(rdr->battle, rdr->target->ch, base);
-}
-
-static void
-finish(struct action *act)
-{
-	free(act->data);
-}
-
-static void
-select(const struct battle *bt, struct selection *slt)
-{
-	slt->index_side = 0;
-
-	selection_first(slt, bt);
-}
-
-static void
-action(struct battle *bt, struct character *owner, const struct selection *slt)
-{
-	struct rendering *rdr;
-
-	/* Action. */
-	rdr = alloc_new0(sizeof (*rdr));
-	rdr->action.data = rdr;
-	rdr->action.update = update;
-	rdr->action.draw = draw;
-	rdr->action.end = end;
-	rdr->action.finish = finish;
-
-	/* Battle and target. */
-	rdr->battle = bt;
-	rdr->source = battle_find(bt, owner);
-	rdr->target = &bt->enemies[slt->index_character];
-
-	/* Animation. */
-	rdr->animation.delay = 10;
-	rdr->animation.sprite = &assets_sprites[ASSETS_SPRITE_EXPLOSION];
-	animation_start(&rdr->animation);
-
-	action_stack_add(&bt->actions[0], &rdr->action);
-}
-
-const struct spell spell_fire_minor = {
-	.name = N_("Fire Minor"),
-	.description = N_("A small amount of fire balls"),
-	.mp = 10,
-	.type = SPELL_TYPE_FIRE,
-	.select_kind = SELECTION_KIND_ONE,
-	.select_side = SELECTION_SIDE_ENEMY,
-	.select = select,
-	.action = action
-};
--- a/src/libmlk-adventure/adventure/spell/fire-minor.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * fire-minor.h -- minor fire
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_FIRE_MINOR_H
-#define MOLKO_ADVENTURE_FIRE_MINOR_H
-
-extern const struct spell spell_fire_minor;
-
-#endif /* !MOLKO_ADVENTURE_FIRE_MINOR_H */
--- a/src/libmlk-adventure/adventure/state/battle.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-/*
- * battle.c -- manage a battle
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include <core/alloc.h>
-#include <core/game.h>
-#include <core/painter.h>
-#include <core/state.h>
-
-#include <rpg/battle.h>
-
-#include "battle.h"
-
-struct self {
-	struct battle *battle;
-	struct state state;
-};
-
-static void
-start(struct state *state)
-{
-	struct self *self = state->data;
-
-	battle_start(self->battle);
-}
-
-static void
-handle(struct state *state, const union event *ev)
-{
-	struct self *self = state->data;
-
-	battle_handle(self->battle, ev);
-}
-
-static void
-update(struct state *state, unsigned int ticks)
-{
-	struct self *self = state->data;
-
-	/* TODO: once we have stacked states, pop it. */
-	if (battle_update(self->battle, ticks))
-		game_pop();
-}
-
-static void
-draw(struct state *state)
-{
-	struct self *self = state->data;
-
-	painter_set_color(0xffffffff);
-	painter_clear();
-	battle_draw(self->battle);
-	painter_present();
-}
-
-static void
-finish(struct state *state)
-{
-	struct self *self = state->data;
-
-	battle_finish(self->battle);
-
-	free(self->battle);
-	free(self);
-}
-
-struct state *
-state_battle_new(struct battle *bt)
-{
-	assert(bt);
-
-	struct self *self;
-
-	self = alloc_new0(sizeof (*self));
-	self->battle = bt;
-	self->state.data = self;
-	self->state.start = start;
-	self->state.handle = handle;
-	self->state.update = update;
-	self->state.draw = draw;
-	self->state.finish = finish;
-
-	return &self->state;
-}
--- a/src/libmlk-adventure/adventure/state/battle.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * battle.h -- manage a battle
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_STATE_BATTLE_H
-#define MOLKO_ADVENTURE_STATE_BATTLE_H
-
-#include <core/core.h>
-
-struct battle;
-struct state;
-
-CORE_BEGIN_DECLS
-
-struct state *
-state_battle_new(struct battle *);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_STATE_BATTLE_H */
--- a/src/libmlk-adventure/adventure/state/continue.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * continue.c -- select save to continue the game
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <core/alloc.h>
-#include <core/event.h>
-#include <core/game.h>
-#include <core/painter.h>
-#include <core/state.h>
-
-#include <adventure/dialog/save.h>
-
-#include "mainmenu.h"
-#include "continue.h"
-
-struct self {
-	struct state state;
-	struct dialog_save dialog;
-};
-
-static void
-start(struct state *state)
-{
-	struct self *self = state->data;
-
-	dialog_save_init(&self->dialog);
-}
-
-static void
-handle(struct state *state, const union event *ev)
-{
-	struct self *self = state->data;
-	int selected = 0;
-
-	switch (ev->type) {
-	case EVENT_QUIT:
-		game_quit();
-		break;
-	case EVENT_KEYDOWN:
-		if (ev->key.key == KEY_ESCAPE)
-			game_push(state_mainmenu_new());
-		else
-			selected = dialog_save_handle(&self->dialog, ev);
-		break;
-	default:
-		selected = dialog_save_handle(&self->dialog, ev);
-		break;
-	}
-
-	if (selected)
-		game_quit();
-}
-
-static void
-update(struct state *state, unsigned int ticks)
-{
-	struct self *self = state->data;
-
-	dialog_save_update(&self->dialog, ticks);
-}
-
-static void
-draw(struct state *state)
-{
-	struct self *self = state->data;
-
-	painter_set_color(0xffffffff);
-	painter_clear();
-	dialog_save_draw(&self->dialog);
-	painter_present();
-}
-
-static void
-finish(struct state *state)
-{
-	struct self *self = state->data;
-
-	dialog_save_finish(&self->dialog);
-}
-
-struct state *
-state_continue_new(void)
-{
-	struct self *self;
-
-	self = alloc_new0(sizeof (*self));
-	self->state.data = self;
-	self->state.start = start;
-	self->state.handle = handle;
-	self->state.update = update;
-	self->state.draw = draw;
-	self->state.finish = finish;
-
-	return &self->state;
-}
--- a/src/libmlk-adventure/adventure/state/continue.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * continue.h -- select save to continue the game
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_STATE_CONTINUE_H
-#define MOLKO_ADVENTURE_STATE_CONTINUE_H
-
-#include <core/core.h>
-
-struct state;
-
-CORE_BEGIN_DECLS
-
-struct state *
-state_continue_new(void);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_STATE_CONTINUE_H */
--- a/src/libmlk-adventure/adventure/state/mainmenu.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-/*
- * mainmenu.c -- game main menu
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <core/alloc.h>
-#include <core/event.h>
-#include <core/font.h>
-#include <core/game.h>
-#include <core/image.h>
-#include <core/painter.h>
-#include <core/panic.h>
-#include <core/state.h>
-#include <core/texture.h>
-#include <core/util.h>
-#include <core/window.h>
-
-#include <ui/align.h>
-#include <ui/label.h>
-#include <ui/theme.h>
-
-#include <rpg/character.h>
-
-#include <adventure/assets.h>
-#include <adventure/molko.h>
-#include <adventure/adventure_p.h>
-
-#include <adventure/item/potion.h>
-#include <adventure/character/neth.h>
-
-#include "mainmenu.h"
-#include "continue.h"
-
-struct self {
-	struct state state;
-
-	struct {
-		struct texture tex;
-		int x;
-		int y;
-	} texts[4];
-
-	unsigned int itemsel;           /* Selected item. */
-};
-
-static void
-new(void)
-{
-	/* TODO: temporary. */
-	molko.team.members[0] = &character_neth;
-	character_reset(molko.team.members[0]);
-	molko.team.members[0]->hp = molko.team.members[0]->hpmax;
-	molko.team.members[0]->mp = molko.team.members[0]->mpmax;
-	inventory_add(&molko.inventory, &item_potion, 10);
-
-	molko_teleport("maps/map-world.map", -1, -1);
-}
-
-static void
-resume(void)
-{
-	game_push(state_continue_new());
-}
-
-static void
-quit(void)
-{
-	game_quit();
-}
-
-static void
-perform(struct self *self)
-{
-	assert(self->itemsel < 3);
-
-	static void (*handlers[])(void) = {
-		[0] = new,
-		[1] = resume,
-		[2] = quit
-	};
-
-	handlers[self->itemsel]();
-}
-
-static void
-init_title(struct self *self, struct font *font)
-{
-	if (font_render(font, &self->texts[3].tex, "Molko's Adventure", 0x000000ff) < 0)
-		panic();
-	
-	/* Align header. */
-	align(ALIGN_CENTER, &self->texts[3].x, NULL, self->texts[3].tex.w, self->texts[3].tex.h,
-	    0, 0, window.w, window.h);
-
-	self->texts[3].y = self->texts[3].x;
-}
-
-static void
-init_items(struct self *self, struct font *font)
-{
-	if (font_render(font, &self->texts[0].tex, _("New"), 0x000000ff) < 0 ||
-	    font_render(font, &self->texts[1].tex, _("Continue"), 0x000000ff) < 0 ||
-	    font_render(font, &self->texts[2].tex, _("Quit"), 0x000000ff) < 0)
-		panic();
-
-	self->texts[0].x = (window.w / 2) - (self->texts[0].tex.w / 2);
-	self->texts[0].y = window.h * 0.75;
-
-	self->texts[1].x = self->texts[0].x;
-	self->texts[1].y = self->texts[0].y + self->texts[0].tex.h;
-
-	self->texts[2].x = self->texts[0].x;
-	self->texts[2].y = self->texts[1].y + self->texts[1].tex.h;
-}
-
-static void
-start(struct state *state)
-{
-	struct self *self = state->data;
-	struct font fonts[2];
-
-	if (font_open(&fonts[0], molko_path("fonts/teutonic.ttf"), 130) < 0||
-	    font_open(&fonts[1], molko_path("fonts/pirata-one.ttf"), 30) < 0)
-		panic();
-
-	fonts[0].style = fonts[1].style = FONT_STYLE_ANTIALIASED;
-
-	init_title(self, &fonts[0]);
-	init_items(self, &fonts[1]);
-
-	font_finish(&fonts[0]);
-	font_finish(&fonts[1]);
-}
-
-static void
-handle(struct state *state, const union event *event)
-{
-	struct self *self = state->data;
-
-	switch (event->type) {
-	case EVENT_QUIT:
-		game_quit();
-		break;
-	case EVENT_KEYDOWN:
-		switch (event->key.key) {
-		case KEY_UP:
-			self->itemsel = self->itemsel == 0 ? 2 : self->itemsel - 1;
-			break;
-		case KEY_DOWN:
-			self->itemsel = (self->itemsel + 1) % 3;
-			break;
-		case KEY_ENTER:
-			perform(self);
-			break;
-		default:
-			break;
-		}
-		break;
-	default:
-		break;
-	}
-}
-
-static void
-draw(struct state *state)
-{
-	struct self *self = state->data;
-	struct sprite *cursor = &assets_sprites[ASSETS_SPRITE_UI_CURSOR];
-	int x, y;
-
-	painter_set_color(0xffffffff);
-	painter_clear();
-
-	for (size_t i = 0; i < UTIL_SIZE(self->texts); ++i)
-		texture_draw(&self->texts[i].tex, self->texts[i].x, self->texts[i].y);
-
-	x  = self->texts[self->itemsel].x;
-	x -= cursor->cellw * 2;
-	y  = self->texts[self->itemsel].y;
-	y += self->texts[self->itemsel].tex.h / 2;
-	y -= cursor->cellh / 2;
-
-	sprite_draw(cursor, 1, 2, x, y);
-	painter_present();
-}
-
-static void
-finish(struct state *state)
-{
-	struct self *self = state->data;
-
-	for (size_t i = 0; i < UTIL_SIZE(self->texts); ++i)
-		texture_finish(&self->texts[i].tex);
-
-	free(self);
-}
-
-struct state *
-state_mainmenu_new(void)
-{
-	struct self *self;
-
-	self = alloc_new0(sizeof (*self));
-	self->state.data = self;
-	self->state.start = start;
-	self->state.handle = handle;
-	self->state.draw = draw;
-	self->state.finish = finish;
-
-	return &self->state;
-}
--- a/src/libmlk-adventure/adventure/state/mainmenu.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * mainmenu.h -- game main menu
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_STATE_MAINMENU_H
-#define MOLKO_ADVENTURE_STATE_MAINMENU_H
-
-#include <core/core.h>
-
-struct state;
-
-CORE_BEGIN_DECLS
-
-struct state *
-state_mainmenu_new(void);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_STATE_MAINMENU_H */
--- a/src/libmlk-adventure/adventure/state/map.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
- * map.c -- map state
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <port/port.h>
-
-#include <core/event.h>
-#include <core/image.h>
-#include <core/painter.h>
-#include <core/panic.h>
-#include <core/state.h>
-
-#include <rpg/map.h>
-#include <rpg/map-file.h>
-
-#include <adventure/mapscene/mapscene.h>
-
-#include <adventure/molko.h>
-
-#include "map.h"
-
-struct self {
-	struct state state;
-	char name[FILENAME_MAX];
-	int origin_x;
-	int origin_y;
-	struct map map;
-	struct map_file map_file;
-};
-
-static void
-start(struct state *state)
-{
-	struct self *self = state->data;
-
-	self->map_file.load_action = mapscene_load_action;
-
-	if (map_file_open(&self->map_file, &self->map, molko_path(self->name)) < 0)
-		panic();
-
-	/* TODO: find this from team maybe. */
-	if (image_open(&molko.map_player_texture, molko_path("sprites/john.png")) < 0)
-		panic();
-
-	sprite_init(&molko.map_player_sprite, &molko.map_player_texture, 48, 48);
-	self->map.player_sprite = &molko.map_player_sprite;
-
-	/* TODO: add support for saving origin in save. */
-	if (self->origin_x >= 0)
-		self->map.player_x = self->origin_x;
-	if (self->origin_y >= 0)
-		self->map.player_y = self->origin_y;
-
-	mapscene_load(&self->map);
-
-	if (map_init(&self->map) < 0)
-		panic();
-}
-
-static void
-handle(struct state *state, const union event *ev)
-{
-	struct self *self = state->data;
-
-	if (ev->type == EVENT_QUIT)
-		game_quit();
-	else
-		map_handle(&self->map, ev);
-}
-
-static void
-update(struct state *state, unsigned int ticks)
-{
-	struct self *self = state->data;
-
-	map_update(&self->map, ticks);
-}
-
-static void
-draw(struct state *state)
-{
-	struct self *self = state->data;
-
-	painter_clear();
-	map_draw(&self->map);
-	painter_present();
-}
-
-static void
-suspend(struct state *state)
-{
-	struct self *self = state->data;
-
-	self->map.player_movement = 0;
-}
-
-static void
-finish(struct state *state)
-{
-	struct self *self = state->data;
-
-	map_finish(&self->map);
-	map_file_finish(&self->map_file);
-
-	free(self);
-}
-
-struct state *
-state_map_new(const char *name, int origin_x, int origin_y)
-{
-	(void)origin_x;
-	(void)origin_y;
-
-	struct self *self;
-
-	self = alloc_new0(sizeof (*self));
-	self->origin_x = origin_x;
-	self->origin_y = origin_y;
-	port_strlcpy(self->name, name, sizeof (self->name));
-
-	self->state.data = self;
-	self->state.start = start;
-	self->state.handle = handle;
-	self->state.update = update;
-	self->state.draw = draw;
-	self->state.suspend = suspend;
-	self->state.finish = finish;
-
-	return &self->state;
-}
--- a/src/libmlk-adventure/adventure/state/map.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * map.h -- map state
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_STATE_MAP_H
-#define MOLKO_ADVENTURE_STATE_MAP_H
-
-#include <core/core.h>
-
-struct state;
-
-CORE_BEGIN_DECLS
-
-struct state *
-state_map_new(const char *, int, int);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_STATE_MAP_H */
-
--- a/src/libmlk-adventure/adventure/state/panic.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * panic_state.c -- panic state
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <core/alloc.h>
-#include <core/error.h>
-#include <core/event.h>
-#include <core/font.h>
-#include <core/game.h>
-#include <core/painter.h>
-#include <core/panic.h>
-#include <core/state.h>
-#include <core/sys.h>
-#include <core/texture.h>
-#include <core/window.h>
-
-#include <ui/align.h>
-#include <ui/theme.h>
-
-#include "panic.h"
-
-#define BACKGROUND 0x4f5070ff
-#define FOREGROUND 0xffffffff
-
-#define OUT "molko-adventure.txt"
-
-struct self {
-	struct state state;
-
-	struct {
-		struct texture tex;
-		int x;
-		int y;
-	} texts[4];
-};
-
-static void
-die(const char *fmt, ...)
-{
-	assert(fmt);
-
-	va_list ap;
-
-	va_start(ap, fmt);
-	fprintf(stderr, "abort: ");
-	vfprintf(stderr, fmt, ap);
-	va_end(ap);
-	abort();
-	exit(1);
-}
-
-static void
-stop(void)
-{
-	die("%s", error());
-}
-
-static void
-dump(void)
-{
-	FILE *fp;
-
-	if ((fp = fopen(OUT, "w"))) {
-		/* TODO: add more info here. */
-		fprintf(fp, "Molko's Adventure crash dump report\n");
-		fclose(fp);
-	}
-
-	abort();
-}
-
-static void
-handle_keydown(const struct event_key *ev)
-{
-	assert(ev);
-
-	switch (ev->key) {
-	case KEY_q:
-		game_quit();
-		break;
-	case KEY_s:
-		dump();
-		break;
-	default:
-		break;
-	}
-}
-
-static void
-start(struct state *state)
-{
-	struct self *self = state->data;
-	struct theme *theme;
-	struct font *font;
-
-	/* We remove the panic handler to avoid infinite recursion. */
-	panic_handler = stop;
-
-	theme = theme_default();
-	font = theme->fonts[THEME_FONT_INTERFACE];
-
-	if (font_render(font, &self->texts[0].tex, "An unrecoverable error occured and the game cannot continue.", FOREGROUND) < 0||
-	    font_render(font, &self->texts[1].tex, "Please report the detailed error as provided below.", FOREGROUND) < 0||
-	    font_render(font, &self->texts[2].tex, "Press <s> to save information and generate a core dump.", FOREGROUND) < 0||
-	    font_render(font, &self->texts[3].tex, "Press <q> to quit without saving information.", FOREGROUND) < 0)
-		die("%s", error());
-
-	/* All align x the same. */
-	for (size_t i = 0; i < UTIL_SIZE(self->texts); ++i)
-		self->texts[i].x = theme->padding;
-
-	/* Header (0-1). */
-	self->texts[0].y = theme->padding;
-	self->texts[1].y = self->texts[0].y + self->texts[0].tex.h + theme->padding;
-
-	/* Footer. (2-3). */
-	self->texts[3].y = window.h - self->texts[2].tex.h - theme->padding;
-	self->texts[2].y = self->texts[3].y - self->texts[3].tex.h - theme->padding;
-}
-
-static void
-handle(struct state *state, const union event *ev)
-{
-	assert(ev);
-
-	(void)state;
-
-	switch (ev->type) {
-	case EVENT_KEYDOWN:
-		handle_keydown(&ev->key);
-		break;
-	default:
-		break;
-	}
-}
-
-static void
-draw(struct state *state)
-{
-	struct self *self = state->data;
-	struct theme *theme = theme_default();
-	struct texture tex;
-	struct font *font;
-	int x, y;
-
-	painter_set_color(BACKGROUND);
-	painter_clear();
-
-	for (size_t i = 0; i < UTIL_SIZE(self->texts); ++i)
-		texture_draw(&self->texts[i].tex, self->texts[i].x, self->texts[i].y);
-
-	/* The error is only available here. */
-	font = theme->fonts[THEME_FONT_INTERFACE];
-
-	if (font_render(font, &tex, error(), FOREGROUND) < 0)
-		die("%s\n", error());
-
-	align(ALIGN_LEFT, &x, &y, tex.w, tex.h, 0, 0, window.w, window.h);
-
-	texture_draw(&tex, x + theme->padding, y);
-	texture_finish(&tex);
-
-	painter_present();
-}
-
-static void
-finish(struct state *state)
-{
-	struct self *self = state->data;
-
-	for (size_t i = 0; i < UTIL_SIZE(self->texts); ++i)
-		texture_finish(&self->texts[i].tex);
-
-	free(self);
-}
-
-struct state *
-state_panic_new(void)
-{
-	struct self *self;
-
-	self = alloc_new0(sizeof (*self));
-	self->state.data = self;
-	self->state.start = start;
-	self->state.handle = handle;
-	self->state.draw = draw;
-	self->state.finish = finish;
-
-	return &self->state;
-}
--- a/src/libmlk-adventure/adventure/state/panic.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * panic_state.h -- panic state
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_STATE_PANIC_H
-#define MOLKO_ADVENTURE_STATE_PANIC_H
-
-#include <core/core.h>
-
-struct state;
-
-CORE_BEGIN_DECLS
-
-struct state *
-state_panic_new(void);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_STATE_PANIC_H */
--- a/src/libmlk-adventure/adventure/state/splashscreen.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*
- * splashscreen.c -- splash screen state
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <core/alloc.h>
-#include <core/font.h>
-#include <core/game.h>
-#include <core/image.h>
-#include <core/painter.h>
-#include <core/panic.h>
-#include <core/state.h>
-#include <core/sys.h>
-#include <core/texture.h>
-#include <core/window.h>
-
-#include <ui/align.h>
-
-#include <adventure/molko.h>
-
-#include "splashscreen.h"
-#include "mainmenu.h"
-
-#define DELAY 3000
-
-struct self {
-	struct state state;
-	struct texture tex;
-	int x;
-	int y;
-	unsigned int elapsed;
-};
-
-static void
-start(struct state *state)
-{
-	struct self *self = state->data;
-	struct font font;
-
-	if (font_open(&font, molko_path("fonts/cubic.ttf"), 80) < 0)
-		panic();
-
-	font.style = FONT_STYLE_ANTIALIASED;
-
-	if (!font_render(&font, &self->tex, "malikania", 0x19332dff))
-		panic();
-
-	align(ALIGN_CENTER, &self->x, &self->y, self->tex.w, self->tex.h,
-	    0, 0, window.w, window.h);
-	font_finish(&font);
-}
-
-static void
-update(struct state *state, unsigned int ticks)
-{
-	struct self *self = state->data;
-
-	self->elapsed += ticks;
-
-	if (self->elapsed >= DELAY)
-		game_push(state_mainmenu_new());
-}
-
-static void
-draw(struct state *state)
-{
-	struct self *self = state->data;
-
-	painter_set_color(0xffffffff);
-	painter_clear();
-	texture_draw(&self->tex, self->x, self->y);
-	painter_present();
-}
-
-static void
-finish(struct state *state)
-{
-	struct self *self = state->data;
-
-	texture_finish(&self->tex);
-
-	free(self);
-}
-
-struct state *
-state_splashscreen_new(void)
-{
-	struct self *self;
-
-	self = alloc_new0(sizeof (*self));
-	self->state.data = self;
-	self->state.start = start;
-	self->state.update = update;
-	self->state.draw = draw;
-	self->state.finish = finish;
-
-	return &self->state;
-}
--- a/src/libmlk-adventure/adventure/state/splashscreen.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * splashscreen.h -- splash screen state
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_STATE_SPLASHSCREEN_H
-#define MOLKO_ADVENTURE_STATE_SPLASHSCREEN_H
-
-#include <core/core.h>
-
-struct state;
-
-CORE_BEGIN_DECLS
-
-struct state *
-state_splashscreen_new(void);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_STATE_SPLASHSCREEN_H */
--- a/src/libmlk-adventure/adventure/trace_hud.c	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
- * trace_hud.c -- on screen hud
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <core/action.h>
-#include <core/font.h>
-#include <core/trace.h>
-#include <core/window.h>
-
-#include <ui/label.h>
-#include <ui/theme.h>
-
-#include "trace_hud.h"
-
-#define LINES_MAX       (4)
-#define THEME(t)        ((t) ? (t) : theme_default())
-
-static struct {
-	char lines[LINES_MAX + 1][TRACE_LINE_MAX];
-	unsigned int elapsed;
-} data;
-
-struct trace_hud trace_hud = {
-	.timeout = TRACE_HUD_TIMEOUT_DEFAULT
-};
-
-void
-trace_hud_handler(const char *str)
-{
-	assert(str);
-
-	/* 1.Try to find an empty line. */
-	for (size_t i = 0; i < LINES_MAX; ++i) {
-		if (data.lines[i][0] == '\0') {
-			snprintf(data.lines[i], sizeof (data.lines[i]), "%s", str);
-			return;
-		}
-	}
-
-	/* 2. All lines are full, put in last one and move other. */
-	memmove(&data.lines[0], &data.lines[1], sizeof (data.lines[0]) * LINES_MAX - 1);
-	snprintf(data.lines[LINES_MAX - 1], sizeof (data.lines[0]), "%s", str);
-
-	/* 3. Reset elapsed time now. */
-	data.elapsed = 0;
-}
-
-void
-trace_hud_update(unsigned int ticks)
-{
-	data.elapsed += ticks;
-
-	/*
-	 * We have an empty line in the data.lines at LINES_MAX, so we simply so
-	 * to move the whole array.
-	 *
-	 * [0] = "abc"
-	 * [1] = "def"
-	 * [2] = "xyz"
-	 * [3] = "zef"
-	 * [n] = "ldkf"
-	 * [LINES_MAX + 1] = "\0"
-	 */
-	if (data.elapsed >= trace_hud.timeout) {
-		data.elapsed = 0;
-		memmove(&data.lines[0], &data.lines[1], sizeof (data.lines[0]) * LINES_MAX);
-	}
-}
-
-void
-trace_hud_draw(void)
-{
-	struct theme *th;
-	int x, y;
-
-	th = THEME(trace_hud.theme);
-	x = th->padding;
-	y = th->padding;
-
-	for (int i = 0; i < LINES_MAX && data.lines[i][0]; ++i) {
-		label_draw(&(struct label) {
-			.x = x,
-			.y = y,
-			.text = data.lines[i],
-			.theme = th,
-			.flags = LABEL_FLAGS_SHADOW
-		});
-
-		y += font_height(th->fonts[THEME_FONT_INTERFACE]);
-		y += th->padding;
-	}
-}
-
-void
-trace_hud_clear(void)
-{
-	memset(&data, 0, sizeof (data));
-}
-
-static int
-update(struct action *a, unsigned int ticks)
-{
-	(void)a;
-
-	trace_hud_update(ticks);
-
-	return 0;
-}
-
-static void
-draw(struct action *a)
-{
-	(void)a;
-
-	trace_hud_draw();
-}
-
-struct action *
-trace_hud_action(void)
-{
-	static struct action a = {
-		.update = update,
-		.draw = draw
-	};
-
-	return &a;
-}
--- a/src/libmlk-adventure/adventure/trace_hud.h	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * trace_hud.h -- on screen hud
- *
- * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef MOLKO_ADVENTURE_TRACE_HUD_H
-#define MOLKO_ADVENTURE_TRACE_HUD_H
-
-#include <core/core.h>
-
-#define TRACE_HUD_TIMEOUT_DEFAULT (3000)
-
-struct action;
-struct theme;
-
-struct trace_hud {
-	struct theme *theme;
-	unsigned int timeout;
-};
-
-CORE_BEGIN_DECLS
-
-extern struct trace_hud trace_hud;
-
-void
-trace_hud_handler(const char *);
-
-void
-trace_hud_update(unsigned int);
-
-void
-trace_hud_draw(void);
-
-void
-trace_hud_clear(void);
-
-struct action *
-trace_hud_action(void);
-
-CORE_END_DECLS
-
-#endif /* !MOLKO_ADVENTURE_TRACE_HUD_H */
--- a/src/libmlk-adventure/nls/fr.po	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#
-# fr.po -- French translations for libmlk-adventure
-#
-# Copyright (c) 2020-2021 David Demelier <markand@malikania.fr>
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-06-28 21:06+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: libmlk-adventure/adventure/spell/fire-minor.c:123
-msgid "A small amount of fire balls"
-msgstr ""
-
-#: libmlk-adventure/adventure/character/black-cat.c:44
-msgid "Black Cat"
-msgstr ""
-
-#: libmlk-adventure/adventure/state/mainmenu.c:119
-msgid "Continue"
-msgstr "Continuer"
-
-#: libmlk-adventure/adventure/spell/fire-minor.c:122
-msgid "Fire Minor"
-msgstr ""
-
-#: libmlk-adventure/adventure/dialog/save.c:160
-#, c-format
-msgid "Last played: %s"
-msgstr ""
-
-#: libmlk-adventure/adventure/character/neth.c:41
-msgid "Neth"
-msgstr ""
-
-#: libmlk-adventure/adventure/state/mainmenu.c:118
-msgid "New"
-msgstr "Nouvelle partie"
-
-#: libmlk-adventure/adventure/item/potion.c:57
-msgid "Potion"
-msgstr ""
-
-#: libmlk-adventure/adventure/state/mainmenu.c:120
-msgid "Quit"
-msgstr "Quitter"
-
-#: libmlk-adventure/adventure/item/potion.c:58
-msgid "Recover 50 HP."
-msgstr ""
-
-#: libmlk-adventure/adventure/dialog/save.c:166
-#, c-format
-msgid "Time played: %s"
-msgstr ""
--- a/src/libmlk-adventure/nls/libmlk-adventure.pot	Sun Oct 24 09:55:12 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-06-28 21:06+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=CHARSET\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: libmlk-adventure/adventure/spell/fire-minor.c:123
-msgid "A small amount of fire balls"
-msgstr ""
-
-#: libmlk-adventure/adventure/character/black-cat.c:44
-msgid "Black Cat"
-msgstr ""
-
-#: libmlk-adventure/adventure/state/mainmenu.c:119
-msgid "Continue"
-msgstr ""
-
-#: libmlk-adventure/adventure/spell/fire-minor.c:122
-msgid "Fire Minor"
-msgstr ""
-
-#: libmlk-adventure/adventure/dialog/save.c:160
-#, c-format
-msgid "Last played: %s"
-msgstr ""
-
-#: libmlk-adventure/adventure/character/neth.c:41
-msgid "Neth"
-msgstr ""
-
-#: libmlk-adventure/adventure/state/mainmenu.c:118
-msgid "New"
-msgstr ""
-
-#: libmlk-adventure/adventure/item/potion.c:57
-msgid "Potion"
-msgstr ""
-
-#: libmlk-adventure/adventure/state/mainmenu.c:120
-msgid "Quit"
-msgstr ""
-
-#: libmlk-adventure/adventure/item/potion.c:58
-msgid "Recover 50 HP."
-msgstr ""
-
-#: libmlk-adventure/adventure/dialog/save.c:166
-#, c-format
-msgid "Time played: %s"
-msgstr ""
--- a/tests/CMakeLists.txt	Sun Oct 24 09:55:12 2021 +0200
+++ b/tests/CMakeLists.txt	Sun Oct 24 11:29:04 2021 +0200
@@ -40,7 +40,7 @@
 foreach (t ${TESTS})
 	add_executable(test-${t} ${tests_SOURCE_DIR}/test-${t}.c)
 	add_test(NAME test-${t} COMMAND test-${t})
-	target_link_libraries(test-${t} libmlk-adventure libmlk-rexo)
+	target_link_libraries(test-${t} libmlk-rpg libmlk-rexo)
 	target_compile_definitions(test-${t} PRIVATE DIRECTORY="${tests_SOURCE_DIR}/assets")
 	set_target_properties(test-${t} PROPERTIES FOLDER tests)
 	source_group("" FILES test-${t}.c)