using XGame.Framework.Asset;
using System;
using UnityEngine;

namespace XGame.Editor.Asset
{

    public static class PathDefine
    {
        #region 常量
        /// <summary>
        /// Packages相对路径前缀
        /// </summary>
        public const string PackageRelative = "Packages/";
        /// <summary>
        /// Packages全路径前缀
        /// </summary>
        public const string PackageReality = "Library/PackageCache/";
        /// <summary>
        /// 框架在Package里的bundleId
        /// </summary>
        public const string XGameBundleId = "com.xgame.framework"; //"com.unity.ui.builder";
        /// <summary>
        /// Assets相对路径前缀
        /// </summary>
        public const string AssetsRelative = "Assets/";
        /// <summary>
        /// Addressable资源
        /// </summary>
        public const string ResAddressableName = "Res/Addressable";
        /// <summary>
        /// 静态资源，不可动态加载
        /// </summary>
        public const string ResStaticName = "Res/Static";
        /// <summary>
        /// Resources
        /// </summary>
        public const string ResourcesName = "Resources";
        /// <summary>
        /// i18n文件夹
        /// </summary>
        public const string I18nName = "i18n";
        ///// <summary>
        ///// ResStatic资源对应的bundle名前缀
        ///// </summary>
        //public const string rawBundlePrefix = "raw_";
        /// <summary>
        /// Lod资源文件名后缀
        /// 高品质
        /// </summary>
        public const string LodHigh = "_high";
        /// <summary>
        /// lod资源文件名后缀
        /// 低品质
        /// </summary>
        public const string LodLow = "_low";
        #endregion

        #region Package
        /// <summary>
        /// 框架在Package里的相对路径
        /// </summary>
        public static string XGamePackageRelative => $"{PackageRelative}{XGameBundleId}";
        /// <summary>
        /// 内置资源相对路径
        /// AssetDatabase.Load不支持"/"结尾
        /// </summary>
        public static string BuiltInResourcesRelative => $"{PackageRelative}{XGameBundleId}/{ResourcesName}";

        /// <summary>
        /// 内置资源ResStatic相对路径
        /// </summary>
        public static string BuiltInResTests => $"{PackageRelative}{XGameBundleId}/{ResStaticName}/Tests";
        #endregion

        #region Asset
        private static readonly string AppDataPath = Application.dataPath;
        public static readonly string AssetsEditor = "Assets/Editor";
        /// <summary>
        /// Addressable资源相对路径
        /// AssetDatabase.Load不支持"/"结尾
        /// </summary>
        public static string ResAddressableRelative = $"{AssetsRelative}{ResAddressableName}";
        /// <summary>
        /// 静态资源相对路径
        /// </summary>
        public static string ResStaticRelative = $"{AssetsRelative}{ResStaticName}";
        /// <summary>
        /// Resources相对路径
        /// </summary>
        public static string ResourcesRelative = $"{AssetsRelative}{ResourcesName}";
        /// <summary>
        /// 国际化资源目录相对路径
        /// </summary>
        public static string I18nAssetsRelative = $"{AssetsRelative}{I18nName}/";
        /// <summary>
        /// 动态资源全路径
        /// </summary>
        public static string ResAddressablePath => $"{AppDataPath}/{ResAddressableName}";
        /// <summary>
        /// 静态资源全路径
        /// </summary>
        public static string ResStaticPath => $"{AppDataPath}/{ResStaticName}";
        /// <summary>
        /// Resources全路径
        /// </summary>
        public static string ResourcesPath => $"{AppDataPath}/{ResourcesName}";
        /// <summary>
        /// 国际化资源目录全路径
        /// </summary>
        public static string I18nAssetsPath => $"{AppDataPath}/{I18nName}/";

        #endregion

        #region Addressable | AssetBundle
        /// <summary>
        /// bundle数据相对路径
        /// </summary>
        public static readonly string ConfigsRelative = "Assets/AssetConfigs/";

        public static readonly string AddressableDataRelative = $"{ConfigsRelative}Addressable/";

        public static string BundleManifestPath => $"{ConfigsRelative}{Define.ASSET_BUNDLE_MANIFEST}.asset";
        public static string ReferenceManifestPath => $"{ConfigsRelative}{Define.ASSET_REFERENCE_MANIFEST}.asset";
        public static string SceneAssetBundleManifestPath => $"{ConfigsRelative}{Define.SCENE_BUNDLE_MANIFEST}.asset";
        /// <summary>
        /// 项目资源的Addressable配置文件
        /// </summary>
        public static string ProductAssetManifestPath => $"{AddressableDataRelative}{Define.PRODUCT_ASSET_MANIFEST}.asset";
        /// <summary>
        /// 内置资源的Addressable配置文件
        /// </summary>
        public static string BuiltInAssetManifestPath => $"{AddressableDataRelative}{Define.BUILTIN_ASSET_MANIFEST}.asset";
        /// <summary>
        /// 测试资源的Addressable配置文件
        /// </summary>
        public static string TestAssetsManifestPath => $"{AddressableDataRelative}TestAssetsManifest.asset";
        /// <summary>
        /// Addressable的备份文件，用于记录自定义名字的资源信息
        /// </summary>
        public static string AddressableBackupManifestPath => $"{AddressableDataRelative}BackupManifest.asset";
        /// <summary>
        /// 分包规则配置文件
        /// </summary>
        public static string ABPackerManifestPath => $"{ConfigsRelative}PackerInfoManifest.asset";

        /// <summary>
        /// AssetsConfig路径
        /// </summary>
        public static string AssetsConfigPath => $"{AssetsEditor}/AssetsConfig.asset";

        #endregion

        /// <summary>
        /// ExtAssets文件夹路径
        /// </summary>
        public static string ExtAssetsPath => $"{Environment.CurrentDirectory.Replace("\\", "/")}/ExtAssets";
        /// <summary>
        /// 打包默认输出路径
        /// </summary>
        public static string DefaultOutputPath => $"{ExtAssetsPath}/output";
        /// <summary>
        /// AssetBundle输出路径
        /// </summary>
        public static string AssetBundleOutputPath => $"{ExtAssetsPath}/StreamAssets/{PlatformUtil.ActivePlatform}/AssetBundles";

        public static string TestsToAddressable => $"{AssetsRelative}Res/Tests";

    }
}
