package eu.jonahbauer.wizard.client.libgdx.util;

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.I18NBundleLoader;
import com.badlogic.gdx.assets.loaders.SkinLoader;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.I18NBundle;
import eu.jonahbauer.wizard.client.libgdx.GameAtlas;
import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas;
import lombok.experimental.Delegate;

import java.util.Locale;

public class WizardAssetManager {
    public static final String SKIN = "uiskin.json";
    public static final String ATLAS_SKIN = UiskinAtlas.$PATH;
    public static final String ATLAS_GAME = GameAtlas.$PATH;

    public static final String SFX_CLICK = "sound/button_click.mp3";
    public static final String SFX_CARD_PLAYED = "sound/card_played.mp3";
    public static final String SFX_CARD_SHUFFLE = "sound/card_shuffle.mp3";
    public static final String MUSIC_BACKGROUND = "background.mp3";

    public static final String CURSOR = "cursor.png";
    public static final String MESSAGES = "i18n/messages";

    @Delegate
    private final AssetManager manager = new AssetManager();

    public void loadShared() {
        manager.load(CURSOR, Pixmap.class);
        manager.load(MESSAGES, I18NBundle.class, new I18NBundleLoader.I18NBundleParameter(Locale.getDefault()));
        manager.load(SKIN, Skin.class, new SkinLoader.SkinParameter(ATLAS_SKIN));

        manager.load(MUSIC_BACKGROUND, Music.class);
    }

    public void loadGame() {
        manager.load(ATLAS_GAME, TextureAtlas.class);
    }

    public void unloadGame() {
        manager.unload(ATLAS_GAME);
    }
}
