#include "resource_music.h"

/* Initializes music resource. */
bool
resource_music_init(Resources* self, MusicType type)
{
	if (!music_init(&self->music[type], MUSIC_PATHS[type]))
	{
		printf(STRING_RESOURCE_ERROR, MUSIC_PATHS[type]);
		return false;
	}

	printf(STRING_RESOURCE_INIT, MUSIC_PATHS[type]);

	return true;
}

/* Frees music resources. */
void
resource_music_free(Resources* self, MusicType type)
{
	if (self->music[type].isInit)
	{
		music_free(&self->music[type]);

		printf(STRING_RESOURCE_FREE, MUSIC_PATHS[type]);
	}
}

/* Given an array, initializes music resources. */
void
resource_music_state_init(Resources* self, const MusicType* types, u32 count)
{
	for (s32 i = 0; i < (s32)count; i++)
		resource_music_init(self, types[i]);
}

/* Frees music resources. */
void
resource_music_state_free(Resources* self, const MusicType* types, u32 count)
{
	for (s32 i = 0; i < (s32)count; i++)
		resource_music_free(self, types[i]);
}
