using Assets.Native.tools.excel.Model;
using Assets.Native.tools.excel.Util;
using ClosedXML.Excel;
using CommonUtil;
using EditorUtils;
using iHuman.UnitySz.Framework;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
using static iHuman.UnitySz.Framework.ResLinkAsset;

public class MapConfigGen{
    const string artPathRoot = "Assets/art/game/practice/";
    const string scriptPathRoot = "Assets/app/src/scenes/mainmap/config";

    [MenuItem("Assets/自定义创建/大地图/大地图主题配置")]
    public static void CreateConfig()
    {
        //创建practiceConfig文件
        var outPutPath = Path.Combine(scriptPathRoot, "theme_cfg.lua");
        string svnPath = "https://10.3.254.33/repos/hongen_read/product/配置/大地图配置.xlsx";
        string excelFile = SvnUtil.getFile(svnPath);

        List<ThemeExcelPageRow> themeExcelContentList = ExcelUtil.ReadExcelWithReflection<ThemeExcelPageRow>(excelFile, "地图配置");

        string result = JsonConvert.SerializeObject(themeExcelContentList, Formatting.Indented);
        result = JsonToLua.ConvertContent(result);
        File.WriteAllText(outPutPath, result);
    }
}