package cn.forevermc.launcher.util;

import cn.forevermc.launcher.ForeverMC;
import cn.forevermc.launcher.bean.APISetting;
import cn.forevermc.launcher.bean.Config;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.imyeyu.inject.annotation.IOCReturn;
import com.imyeyu.io.IOSize;
import com.imyeyu.io.IOSpeedService;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.Image;
import javafx.scene.media.MediaPlayer;
import javafx.scene.paint.Color;

/**
 * 静态资源
 *
 * @author 夜雨
 * @since 2022-11-18 15:41
 */
@com.imyeyu.inject.annotation.Resources
public class Resources {

	/** TimiServer 接口 */
	public static final String TIMI_SERVER_API = "http://localhost:8091";

	/** TimiServer 接口 */
//	public static final String TIMI_SERVER_API = "https://api.imyeyu.com";

	// ---------- 图标 ----------

	/** 启动器图标 */
	public static final Image ICON = new Image("icon.png");

	/** 窗体标题图标 */
	public static final Image ICON_MC = new Image("assets/img/icon-mc.png");

	/** 远古版本窗体标题图标 */
	public static final Image ICON_MC_ANCIENT = new Image("assets/img/icon-mc-ancient.png");

	/** 按钮 */
	public static final Image BTN = new Image("assets/img/btn.png", 396, 36, true, false, true);

	/** 选择钩子 X36 */
	public static final Image CHECK = new Image("assets/img/check.png", 36, 36, false, false);

	/** 选择钩子 X18 */
	public static final Image CHECK_SMALL = new Image("assets/img/check.png", 18, 18, false, false);

	/** 标题 */
	public static final Image TITLE = new Image("assets/img/title.png");

	/** 新标题（1.20 版本开始） */
	public static final Image TITLE_NEW = new Image("assets/img/title-modern.png", 680, 100, true, false);

	/** 语言 */
	public static final Image LANG = new Image("assets/img/lang.png", 26, 26, true, true);

	/** 启动过渡页 */
	public static final Image SPLASH_SCREEN = new Image("splash-screen.png");

	/** Mojang Logo */
	public static final Image MOJANG = new Image("assets/img/mojang.png", 480, -1, true, true);

	/** Mojang Logo 远古版本 */
	public static final Image MOJANG_ANCIENT = new Image("assets/img/mojang_ancient.png", 480, -1, true, true);

	/** 泥土（平铺背景） */
	public static final Image DIRT = new Image("assets/img/dirt.png");

	/** 信息 */
	public static final Image INFO = new Image("assets/img/info.png");

	/** F（ForeverMC 登录方式图标） */
	public static final Image F = new Image("assets/img/f.png");

	/** M（Mojang 登录方式图标） */
	public static final Image M = new Image("assets/img/m.png");

	/** 不死图腾 */
	public static final Image TOTEM = new Image("assets/img/totem.png", 32, -1, true, false);

	/** 命令方块 */
	public static final Image COMMAND_BLOCK = new Image("assets/img/command_block.png", 32, -1, true, false);

	/** 文本投影 */
	public static final DropShadow TEXT_SHADOW = new DropShadow(0, 1, 1, Color.valueOf("#0009"));

	/** @return Gson */
	@IOCReturn
	public Gson gson() {
		return new GsonBuilder().serializeNulls().create();
	}

	/** @return 主配置 */
	@IOCReturn
	public Config config() {
		return ForeverMC.getConfig();
	}

	@IOCReturn
	public APISetting apiSetting() {
		return new APISetting();
	}

	@IOCReturn
	public ObjectProperty<MediaPlayer> bgmPlayer() {
		return new SimpleObjectProperty<>();
	}

	/** @return 字节速度计算主项 */
	@IOCReturn
	public IOSpeedService.Item ioSpeedItem() {
		IOSpeedService service = IOSpeedService.getInstance();
		service.setSalt(IOSize.KB * 4);
		service.start();
		return service.createItem();
	}
}