using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class BuildApp : EditorWindow
{
    private VersionGUI mVersionGUI;

    [MenuItem("Build/打包App")]
    public static void ShowWindow()
    {
        var win = GetWindow<BuildApp>();
        win.Show();
    }

    private void Awake()
    {
        mVersionGUI = new VersionGUI();
        mVersionGUI.Awake();
    }

    private void OnGUI()
    {
        mVersionGUI.DrawVersion();
        DoBuildApp();
    }

    private void DoBuildApp()
    {
        if (GUILayout.Button("Build AssetBundles"))
        {
            // 生成原始lua全量文件的md5
            BuildUtils.GenOriginalLuaFrameworkMD5File();
            GameLogger.Log("GenLuaFrameworkMd5 Done");
            // 打assetbundle
            string targetPath = Application.streamingAssetsPath + "/res";
            BuildUtils.BuildLuaBundle(targetPath);
            BuildUtils.BuildNormalCfgBundle(targetPath);
            BuildUtils.BuildGameResBundle(targetPath);
            GameLogger.Log("BuildAssetBundle Done");
        }
        if (GUILayout.Button("Build App"))
        {
            // 生成原始lua全量文件的md5
            BuildUtils.GenOriginalLuaFrameworkMD5File();
            GameLogger.Log("GenLuaFrameworkMd5 Done");
            // 打assetbundle
            string targetPath = Application.streamingAssetsPath + "/res";
            BuildUtils.BuildLuaBundle(targetPath);
            BuildUtils.BuildNormalCfgBundle(targetPath);
            BuildUtils.BuildGameResBundle(targetPath);
            GameLogger.Log("BuildAssetBundle Done");
            // 打包app
            BuildUtils.BuildApp();
            GameLogger.Log("Build App Done");
        }
    }
}