【MixKey】提交MixKey配置生成修改
parent
575237bff5
commit
dc5a83daee
|
|
@ -215,6 +215,14 @@ MonoBehaviour:
|
|||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
UserData:
|
||||
- CollectPath: Assets/Config/MixKey
|
||||
CollectorGUID: 1f63a174f7b20704f874aa29f9d49ad5
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackDirectory
|
||||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
UserData:
|
||||
- GroupName: UI
|
||||
GroupDesc:
|
||||
AssetTags:
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ namespace Framework
|
|||
await AssetManager.Instance.WaitAllPreloads();
|
||||
// 再加载
|
||||
_tables = new Tables(LoadByteBuf);
|
||||
await StringManager.LoadMixKeyDic();
|
||||
// 再释放
|
||||
Tables.AfterLoaded(_UnlockJson);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,18 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using cfg;
|
||||
using cfg.StringCfg;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using PhxhSDK;
|
||||
using SimpleJSON;
|
||||
using UnityEngine;
|
||||
|
||||
public class StringManager
|
||||
{
|
||||
private static StringManager m_instance;
|
||||
public static LanguageType CurLanguage = LanguageType.Default;
|
||||
public static Dictionary<string, string> MixKeyDic;
|
||||
public static string MixKeyConfigPath = "Assets/Config/MixKey/MixKeyConfig.json";
|
||||
|
||||
public static StringManager Instance
|
||||
{
|
||||
|
|
@ -88,24 +94,24 @@ public class StringManager
|
|||
if (content.Contains("[p0]"))
|
||||
{
|
||||
var param = _GetParam(data, 0);
|
||||
if (param == null || !MixKeyConfig.MixKeyDic.ContainsKey(param))
|
||||
if (param == null || !MixKeyDic.ContainsKey(param))
|
||||
{
|
||||
DebugUtil.LogError($"MixKey配置有误,StringConfigKey: {data.Key}");
|
||||
return content;
|
||||
}
|
||||
var val = MixKeyConfig.MixKeyDic[param];
|
||||
var val = MixKeyDic[param];
|
||||
retStr = retStr.Replace("[p0]", val);
|
||||
}
|
||||
|
||||
if (content.Contains("[p1]"))
|
||||
{
|
||||
var param = _GetParam(data, 1);
|
||||
if (param == null || !MixKeyConfig.MixKeyDic.ContainsKey(param))
|
||||
if (param == null || !MixKeyDic.ContainsKey(param))
|
||||
{
|
||||
DebugUtil.LogError($"MixKey配置有误,StringConfigKey: {data.Key}");
|
||||
return content;
|
||||
}
|
||||
var val = MixKeyConfig.MixKeyDic[param];
|
||||
var val = MixKeyDic[param];
|
||||
retStr = retStr.Replace("[p1]", val);
|
||||
}
|
||||
|
||||
|
|
@ -261,4 +267,21 @@ public class StringManager
|
|||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
#region MixKey加载
|
||||
|
||||
public static async UniTask LoadMixKeyDic()
|
||||
{
|
||||
var txtAsset = await AssetManager.Instance.LoadAssetAsync<TextAsset>(MixKeyConfigPath);
|
||||
if (txtAsset == null)
|
||||
{
|
||||
DebugUtil.LogError("MixKeyConfig 资源无法加载,请检查路径!");
|
||||
return;
|
||||
}
|
||||
var jsonTxt = txtAsset.text;
|
||||
var dic = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonTxt);
|
||||
MixKeyDic = dic;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ public sealed partial class DataCharacterSkin : Bright.Config.BeanBase
|
|||
{ if(!_json["SelectCharacter"].IsString) { throw new SerializationException(); } SelectCharacter = _json["SelectCharacter"]; }
|
||||
{ if(!_json["Poster"].IsString) { throw new SerializationException(); } Poster = _json["Poster"]; }
|
||||
{ if(!_json["PIcHeadPath"].IsString) { throw new SerializationException(); } PIcHeadPath = _json["PIcHeadPath"]; }
|
||||
{ if(!_json["AssistantPoster"].IsString) { throw new SerializationException(); } AssistantPoster = _json["AssistantPoster"]; }
|
||||
{ if(!_json["SkinName"].IsString) { throw new SerializationException(); } SkinName = _json["SkinName"]; }
|
||||
{ if(!_json["SkinDesc"].IsString) { throw new SerializationException(); } SkinDesc = _json["SkinDesc"]; }
|
||||
{ if(!_json["IsAllowPreview"].IsBoolean) { throw new SerializationException(); } IsAllowPreview = _json["IsAllowPreview"]; }
|
||||
|
|
@ -36,7 +37,7 @@ public sealed partial class DataCharacterSkin : Bright.Config.BeanBase
|
|||
PostInit();
|
||||
}
|
||||
|
||||
public DataCharacterSkin(int SkinID, int RoleID, string NameID, string Name, string NickName, string Cultivate, string Favorable, string LevelUp, string SelectCharacter, string Poster, string PIcHeadPath, string SkinName, string SkinDesc, bool IsAllowPreview, string AcquireCondition )
|
||||
public DataCharacterSkin(int SkinID, int RoleID, string NameID, string Name, string NickName, string Cultivate, string Favorable, string LevelUp, string SelectCharacter, string Poster, string PIcHeadPath, string AssistantPoster, string SkinName, string SkinDesc, bool IsAllowPreview, string AcquireCondition )
|
||||
{
|
||||
this.SkinID = SkinID;
|
||||
this.RoleID = RoleID;
|
||||
|
|
@ -49,6 +50,7 @@ public sealed partial class DataCharacterSkin : Bright.Config.BeanBase
|
|||
this.SelectCharacter = SelectCharacter;
|
||||
this.Poster = Poster;
|
||||
this.PIcHeadPath = PIcHeadPath;
|
||||
this.AssistantPoster = AssistantPoster;
|
||||
this.SkinName = SkinName;
|
||||
this.SkinDesc = SkinDesc;
|
||||
this.IsAllowPreview = IsAllowPreview;
|
||||
|
|
@ -106,6 +108,10 @@ public sealed partial class DataCharacterSkin : Bright.Config.BeanBase
|
|||
/// </summary>
|
||||
public string PIcHeadPath { get; private set; }
|
||||
/// <summary>
|
||||
/// AssistantPoster(看板娘立绘)Assets/Art/UI/Texture/Poster/Poster_Default
|
||||
/// </summary>
|
||||
public string AssistantPoster { get; private set; }
|
||||
/// <summary>
|
||||
/// 皮肤名称
|
||||
/// </summary>
|
||||
public string SkinName { get; private set; }
|
||||
|
|
@ -148,6 +154,7 @@ public sealed partial class DataCharacterSkin : Bright.Config.BeanBase
|
|||
+ "SelectCharacter:" + SelectCharacter + ","
|
||||
+ "Poster:" + Poster + ","
|
||||
+ "PIcHeadPath:" + PIcHeadPath + ","
|
||||
+ "AssistantPoster:" + AssistantPoster + ","
|
||||
+ "SkinName:" + SkinName + ","
|
||||
+ "SkinDesc:" + SkinDesc + ","
|
||||
+ "IsAllowPreview:" + IsAllowPreview + ","
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1f63a174f7b20704f874aa29f9d49ad5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 05127403345ac37479ed8cca7abb7ef7
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -36,6 +36,7 @@ public class ConfigWindow : EditorWindow
|
|||
private bool ExportClient;
|
||||
private bool ExportServer;
|
||||
private bool NeedDownload;
|
||||
private bool _isGenMixKey;
|
||||
|
||||
private bool _isDownloading;
|
||||
|
||||
|
|
@ -111,6 +112,7 @@ public class ConfigWindow : EditorWindow
|
|||
|
||||
ExportClient = true;
|
||||
ExportServer = false;
|
||||
_isGenMixKey = false;
|
||||
|
||||
NeedDownload = true;
|
||||
|
||||
|
|
@ -265,6 +267,11 @@ public class ConfigWindow : EditorWindow
|
|||
EditorGUILayout.BeginHorizontal();
|
||||
ExportClient = EditorGUILayout.ToggleLeft("导出客户端", ExportClient);
|
||||
ExportServer = EditorGUILayout.ToggleLeft("导出服务端", ExportServer);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
_isGenMixKey = EditorGUILayout.ToggleLeft("导出时生成MixKey", _isGenMixKey);
|
||||
|
||||
GUILayout.Space(10);
|
||||
NeedDownload = EditorGUILayout.ToggleLeft("下载选中配置", NeedDownload);
|
||||
|
|
@ -341,7 +348,9 @@ public class ConfigWindow : EditorWindow
|
|||
if (GUILayout.Button("生成MixKey配置"))
|
||||
{
|
||||
_GenMixKeyConfig();
|
||||
//GenMixKeyTool.ReplaceMixKey();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void _ShowDonwloadExcels()
|
||||
|
|
@ -429,7 +438,7 @@ public class ConfigWindow : EditorWindow
|
|||
var lubanAsset = AssetDatabase.LoadAssetAtPath<LubanExportConfig>("Assets/Editor/Tools/Luban_Client.asset");
|
||||
var genSuccess = lubanAsset.Gen();
|
||||
|
||||
if (genSuccess)
|
||||
if (genSuccess && _isGenMixKey)
|
||||
{
|
||||
_GenMixKeyConfig();
|
||||
}
|
||||
|
|
@ -445,6 +454,8 @@ public class ConfigWindow : EditorWindow
|
|||
|
||||
private void _GenMixKeyConfig()
|
||||
{
|
||||
GenMixKeyTool.GenMixKeyFile();
|
||||
//GenMixKeyTool.GenMixKeyFile();
|
||||
MixKeyGenJson.IsGenJsonProcess = true;
|
||||
GenMixKeyTool.GenMixKeyJson();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,12 @@ namespace AutoConfig
|
|||
{
|
||||
public class CfgMixKeyData
|
||||
{
|
||||
private string _key;
|
||||
private string _value;
|
||||
public string key;
|
||||
public string value;
|
||||
|
||||
public string cfgPath;
|
||||
public int sheetIndex;
|
||||
public int rowIndex;
|
||||
public int lineIndex;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,11 +13,10 @@ namespace AutoConfig
|
|||
{
|
||||
public static class ExcelRead
|
||||
{
|
||||
private static List<string> _stringCfgMixKeyList;
|
||||
private static List<string> _stringCfgMixValueList;
|
||||
private static List<string> _stringCfgMixKeyList; //stringCfg里面所有的MixKey
|
||||
public static List<string> StringCfgMixValueList = new();
|
||||
|
||||
public static List<string> StringCfgMixKeyList => _stringCfgMixKeyList;
|
||||
public static List<string> StringCfgMixValueList => _stringCfgMixValueList;
|
||||
|
||||
public enum RowInfo
|
||||
{
|
||||
|
|
@ -42,17 +41,21 @@ namespace AutoConfig
|
|||
_stringCfgMixKeyList.Clear();
|
||||
}
|
||||
|
||||
//ExcelWrite.CfgMixKeyDataList.Clear();
|
||||
var stringCfgPath = GenMixKeyTool.CfgPath + "StringConfig.xlsx";
|
||||
var workBook = _GetWorkBook(stringCfgPath);
|
||||
var workBook = GetWorkBook(stringCfgPath);
|
||||
if (workBook == null)
|
||||
{
|
||||
DebugUtil.LogError($"找不到配置表文件,路径: {stringCfgPath}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var sheetNum = workBook.NumberOfSheets;
|
||||
for (int i = 0; i < sheetNum; i++)
|
||||
{
|
||||
int sheetIdx = i;
|
||||
int rowIdx = -1;
|
||||
int lineIdx = -1;
|
||||
var sheet = workBook.GetSheetAt(i);
|
||||
var row = sheet.GetRow(0);
|
||||
var curRowIdx = 0;
|
||||
|
|
@ -60,15 +63,18 @@ namespace AutoConfig
|
|||
while (row != null)
|
||||
{
|
||||
var cell = row.GetCell(0);
|
||||
var cellContent = _TryReadCell(cell);
|
||||
var cellContent = TryReadCell(cell);
|
||||
var lineNum = row.PhysicalNumberOfCells;
|
||||
|
||||
rowIdx = curRowIdx;
|
||||
|
||||
if (cellContent == "##var")
|
||||
{
|
||||
int cIdx = 1;
|
||||
for (; cIdx < lineNum; cIdx++)
|
||||
{
|
||||
var curCell = row.GetCell(cIdx);
|
||||
var curContent = _TryReadCell(curCell);
|
||||
var curContent = TryReadCell(curCell);
|
||||
if (curContent.Contains("Param"))
|
||||
{
|
||||
mixKeyLineIdx.Add(cIdx);
|
||||
|
|
@ -81,13 +87,21 @@ namespace AutoConfig
|
|||
{
|
||||
for (int idx = 0; idx < mixKeyLineIdx.Count; idx++)
|
||||
{
|
||||
lineIdx = mixKeyLineIdx[idx];
|
||||
var curCell = row.GetCell(mixKeyLineIdx[idx]);
|
||||
var curContent = _TryReadCell(curCell);
|
||||
var curContent = TryReadCell(curCell);
|
||||
if (curContent.Length > 0)
|
||||
{
|
||||
if (!_stringCfgMixKeyList.Contains(curContent))
|
||||
{
|
||||
_stringCfgMixKeyList.Add(curContent);
|
||||
// ExcelWrite.CfgMixKeyDataList.Add(curContent, new CfgMixKeyData()
|
||||
// {
|
||||
// key = curContent,
|
||||
// rowIndex = rowIdx,
|
||||
// lineIndex = lineIdx,
|
||||
// sheetIndex = sheetIdx
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -101,7 +115,7 @@ namespace AutoConfig
|
|||
public static List<int> GetValueIndexList(string configName, List<string> keys)
|
||||
{
|
||||
var cfgPath = GenMixKeyTool.CfgPath + configName + ".xlsx";
|
||||
var workBook = _GetWorkBook(cfgPath);
|
||||
var workBook = GetWorkBook(cfgPath);
|
||||
if (workBook == null)
|
||||
{
|
||||
DebugUtil.LogError($"找不到配置表文件,路径: {cfgPath}");
|
||||
|
|
@ -136,14 +150,14 @@ namespace AutoConfig
|
|||
while (row != null)
|
||||
{
|
||||
var cell = row.GetCell(0);
|
||||
var content = _TryReadCell(cell);
|
||||
var content = TryReadCell(cell);
|
||||
if (content == "##var")
|
||||
{
|
||||
int keyIdx = 1;
|
||||
for (; keyIdx < row.PhysicalNumberOfCells; keyIdx++)
|
||||
{
|
||||
cell = row.GetCell(keyIdx);
|
||||
content = _TryReadCell(cell);
|
||||
content = TryReadCell(cell);
|
||||
for (int n = 0; n < needKeyList.Count; n++)
|
||||
{
|
||||
if (needKeyList[n] == content)
|
||||
|
|
@ -178,7 +192,7 @@ namespace AutoConfig
|
|||
List<string> indexList, int listIdx = 0)
|
||||
{
|
||||
var cfgPath = GenMixKeyTool.CfgPath + configName + ".xlsx";
|
||||
var workBook = _GetWorkBook(cfgPath);
|
||||
var workBook = GetWorkBook(cfgPath);
|
||||
if (workBook == null)
|
||||
{
|
||||
DebugUtil.LogError($"找不到配置表文件,路径: {cfgPath}");
|
||||
|
|
@ -205,13 +219,13 @@ namespace AutoConfig
|
|||
while (row != null)
|
||||
{
|
||||
var cell0 = row.GetCell(0);
|
||||
var content0 = _TryReadCell(cell0);
|
||||
var content0 = TryReadCell(cell0);
|
||||
if (content0 == "##var")
|
||||
{
|
||||
for (int idx = 1; idx < row.PhysicalNumberOfCells; idx++)
|
||||
{
|
||||
var cell = row.GetCell(idx);
|
||||
var content = _TryReadCell(cell);
|
||||
var content = TryReadCell(cell);
|
||||
if (content == param)
|
||||
{
|
||||
valueParamIdx = idx;
|
||||
|
|
@ -230,12 +244,12 @@ namespace AutoConfig
|
|||
while (row != null)
|
||||
{
|
||||
var cell0 = row.GetCell(0);
|
||||
var content0 = _TryReadCell(cell0);
|
||||
var content0 = TryReadCell(cell0);
|
||||
if (content0 == "##type")
|
||||
{
|
||||
var idx = valueParamIdx;
|
||||
var cell = row.GetCell(idx);
|
||||
var content = _TryReadCell(cell);
|
||||
var content = TryReadCell(cell);
|
||||
if (content.Contains("list"))
|
||||
{
|
||||
isList = true;
|
||||
|
|
@ -254,7 +268,7 @@ namespace AutoConfig
|
|||
while (row != null)
|
||||
{
|
||||
var cell0 = row.GetCell(keyIdxList[0]);
|
||||
var content0 = _TryReadCell(cell0);
|
||||
var content0 = TryReadCell(cell0);
|
||||
if (content0 == indexList[0])
|
||||
{
|
||||
int idx = 1;
|
||||
|
|
@ -268,7 +282,7 @@ namespace AutoConfig
|
|||
return null;
|
||||
}
|
||||
|
||||
var content = _TryReadCell(cell);
|
||||
var content = TryReadCell(cell);
|
||||
if (content != indexList[idx])
|
||||
{
|
||||
isCurRow = false;
|
||||
|
|
@ -278,7 +292,7 @@ namespace AutoConfig
|
|||
|
||||
if (isCurRow)
|
||||
{
|
||||
var val = _TryReadCell(row.GetCell(valueParamIdx));
|
||||
var val = TryReadCell(row.GetCell(valueParamIdx));
|
||||
if (isList)
|
||||
{
|
||||
string[] strList = val.Split(departChar);
|
||||
|
|
@ -308,7 +322,7 @@ namespace AutoConfig
|
|||
/// </summary>
|
||||
/// <param name="excelPath"></param>
|
||||
/// <returns></returns>
|
||||
private static IWorkbook _GetWorkBook(string excelPath)
|
||||
public static IWorkbook GetWorkBook(string excelPath)
|
||||
{
|
||||
FileStream fs = null;
|
||||
try
|
||||
|
|
@ -341,7 +355,7 @@ namespace AutoConfig
|
|||
/// </summary>
|
||||
/// <param name="cell"></param>
|
||||
/// <returns></returns>
|
||||
private static string _TryReadCell(ICell cell)
|
||||
public static string TryReadCell(ICell cell)
|
||||
{
|
||||
if (cell == null)
|
||||
{
|
||||
|
|
@ -371,7 +385,7 @@ namespace AutoConfig
|
|||
{
|
||||
var cfgFullName = cfgName + ".xlsx";
|
||||
var tableCfg = GenMixKeyTool.CfgPath + "__tables__" + ".xlsx";
|
||||
var workBook = _GetWorkBook(tableCfg);
|
||||
var workBook = GetWorkBook(tableCfg);
|
||||
if (workBook == null)
|
||||
{
|
||||
DebugUtil.LogError("__tables__ 不存在,请检查传入路径");
|
||||
|
|
@ -393,13 +407,13 @@ namespace AutoConfig
|
|||
while (row != null)
|
||||
{
|
||||
var cell = row.GetCell(0);
|
||||
var content = _TryReadCell(cell);
|
||||
var content = TryReadCell(cell);
|
||||
if (content == "##var")
|
||||
{
|
||||
for (int idx = 1; idx < row.PhysicalNumberOfCells; idx++)
|
||||
{
|
||||
var curCell = row.GetCell(idx);
|
||||
var curContent = _TryReadCell(curCell);
|
||||
var curContent = TryReadCell(curCell);
|
||||
if (curContent == "input")
|
||||
{
|
||||
cfgIdx = idx;
|
||||
|
|
@ -422,10 +436,10 @@ namespace AutoConfig
|
|||
row = sheet.GetRow(rowIndex);
|
||||
while (row != null)
|
||||
{
|
||||
var inputContent = _TryReadCell(row.GetCell(cfgIdx));
|
||||
var inputContent = TryReadCell(row.GetCell(cfgIdx));
|
||||
if (inputContent.Contains(cfgFullName))
|
||||
{
|
||||
var keyContent = _TryReadCell(row.GetCell(keyNumIdx));
|
||||
var keyContent = TryReadCell(row.GetCell(keyNumIdx));
|
||||
if (keyContent.Contains("+"))
|
||||
{
|
||||
string[] list = keyContent.Split('+');
|
||||
|
|
@ -449,7 +463,7 @@ namespace AutoConfig
|
|||
private static string GetFirstKey(string configName)
|
||||
{
|
||||
var cfgPath = GenMixKeyTool.CfgPath + configName + ".xlsx";
|
||||
var workBook = _GetWorkBook(cfgPath);
|
||||
var workBook = GetWorkBook(cfgPath);
|
||||
if (workBook == null)
|
||||
{
|
||||
DebugUtil.LogError($"找不到配置表文件,路径: {cfgPath}");
|
||||
|
|
@ -462,10 +476,10 @@ namespace AutoConfig
|
|||
while (row != null)
|
||||
{
|
||||
var cell0 = row.GetCell(0);
|
||||
var str0 = _TryReadCell(cell0);
|
||||
var str0 = TryReadCell(cell0);
|
||||
if (str0 == "##var")
|
||||
{
|
||||
return _TryReadCell(row.GetCell(1));
|
||||
return TryReadCell(row.GetCell(1));
|
||||
}
|
||||
row = sheet.GetRow(++rowIndex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using AutoConfig;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using UnityEngine;
|
||||
|
||||
public class ExcelWrite
|
||||
{
|
||||
private static Dictionary<string, CfgMixKeyData> _cfgMixKeyDataList = new();
|
||||
public static Dictionary<string, CfgMixKeyData> CfgMixKeyDataList => _cfgMixKeyDataList;
|
||||
|
||||
public static string StringConfigPath = Application.dataPath + "/../../Tool/Luban/" + "Datas/"+ "StringConfig.xlsx";
|
||||
public static string StringConfigPath2 = Application.dataPath + "/../../Tool/Luban/" + "Datas/"+ "StringConfig2.xlsx";
|
||||
|
||||
public static IWorkbook _GetWorkBook(string excelPath, FileStream fs)
|
||||
{
|
||||
if (fs == null)
|
||||
{
|
||||
Debug.LogError("无法打开文件{0},跳过处理:" + excelPath);
|
||||
return null;
|
||||
}
|
||||
|
||||
var isXlsx = excelPath.EndsWith(".xlsx", System.StringComparison.CurrentCultureIgnoreCase);
|
||||
if (isXlsx)
|
||||
{
|
||||
IWorkbook workBook = new XSSFWorkbook(fs);
|
||||
return workBook;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool WriteToStringCfg()
|
||||
{
|
||||
try
|
||||
{
|
||||
var fs = new FileStream(StringConfigPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read);
|
||||
var workbook = _GetWorkBook(StringConfigPath, fs);
|
||||
if (workbook == null)
|
||||
{
|
||||
DebugUtil.LogError($"{StringConfigPath} 不存在,请检查传入路径");
|
||||
return false;
|
||||
}
|
||||
|
||||
var fs2 = new FileStream(StringConfigPath2, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
|
||||
var zipStream = new ZipOutputStream(fs2);
|
||||
workbook.SetActiveSheet(0);
|
||||
var sheetTest = workbook.GetSheetAt(0);
|
||||
var rowTest = sheetTest.GetRow(0);
|
||||
var cellT = rowTest.GetCell(0);
|
||||
cellT.SetCellValue("Test000");
|
||||
|
||||
workbook.Write(zipStream);
|
||||
|
||||
fs.Close();
|
||||
return true;
|
||||
// var fs2 = new FileStream(StringConfigPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write);
|
||||
// foreach (var kv in _cfgMixKeyDataList)
|
||||
// {
|
||||
// var data = kv.Value;
|
||||
// var sheet = workbook.GetSheetAt(data.sheetIndex);
|
||||
// var row = sheet.GetRow(data.rowIndex);
|
||||
// var cell = row.GetCell(data.lineIndex);
|
||||
// cell.SetCellValue(data.value);
|
||||
// }
|
||||
// workbook.Write(fs2);
|
||||
// fs.Close();
|
||||
// fs2.Close();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static bool CheckWrite2Config()
|
||||
{
|
||||
return WriteToStringCfg();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7ed63f3a04814dd9a7cee29fc2eeab1a
|
||||
timeCreated: 1718781157
|
||||
|
|
@ -3,6 +3,7 @@ using Gameplay;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Framework;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
|
@ -21,8 +22,12 @@ namespace AutoConfig
|
|||
private static int _listIdx = 0;
|
||||
private static bool _isPer;
|
||||
|
||||
private static int _process;
|
||||
|
||||
private static List<string> _stringCfgMixValueList;
|
||||
|
||||
public static int LoadCfgProcess => _process;
|
||||
|
||||
//配置内容分段枚举
|
||||
private enum KeyPart
|
||||
{
|
||||
|
|
@ -130,25 +135,29 @@ namespace AutoConfig
|
|||
return val;
|
||||
}
|
||||
|
||||
private static void LoadMixValue()
|
||||
private static async UniTask LoadMixValue()
|
||||
{
|
||||
ExcelRead.LoadStrCfgMixKeyList();
|
||||
var keyList = ExcelRead.StringCfgMixKeyList;
|
||||
if (_stringCfgMixValueList == null)
|
||||
{
|
||||
_stringCfgMixValueList = new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
_stringCfgMixValueList.Clear();
|
||||
}
|
||||
|
||||
ExcelRead.StringCfgMixValueList.Clear();
|
||||
_process = 0;
|
||||
for (int i = 0 ; i < keyList.Count; i++)
|
||||
{
|
||||
await UniTask.Delay(1);
|
||||
_process++;
|
||||
var key = keyList[i];
|
||||
var val = GetValue(key);
|
||||
_stringCfgMixValueList.Add(val);
|
||||
ExcelRead.StringCfgMixValueList.Add(val);
|
||||
_ShowGenMixKeyProcess();
|
||||
}
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
private static void _ShowGenMixKeyProcess()
|
||||
{
|
||||
var strInfo = LoadCfgProcess + "/" + ExcelRead.StringCfgMixKeyList.Count;
|
||||
float process = (float)LoadCfgProcess / ExcelRead.StringCfgMixKeyList.Count;
|
||||
EditorUtility.DisplayProgressBar("MixKey生成中", strInfo, process);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -235,6 +244,12 @@ namespace AutoConfig
|
|||
DebugUtil.Log("生成MixKey配置失败!!!");
|
||||
}
|
||||
|
||||
public static async void GenMixKeyJson()
|
||||
{
|
||||
await LoadMixValue();
|
||||
MixKeyGenJson.GenMixKeyJsonFile();
|
||||
}
|
||||
|
||||
public static void Release()
|
||||
{
|
||||
_cfgName = "";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using AutoConfig;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class MixKeyGenJson
|
||||
{
|
||||
public static Dictionary<string, string> MixKeyDic = new();
|
||||
public static readonly string JsonPath = "Assets/Config/MixKey/MixKeyConfig.json";
|
||||
public static bool IsGenJsonProcess;
|
||||
|
||||
private static void _LoadMixKeyDic()
|
||||
{
|
||||
MixKeyDic.Clear();
|
||||
var keyList = ExcelRead.StringCfgMixKeyList;
|
||||
var valList = ExcelRead.StringCfgMixValueList;
|
||||
if (keyList != null)
|
||||
{
|
||||
if (valList != null)
|
||||
{
|
||||
for (int i = 0; i < keyList.Count; i++)
|
||||
{
|
||||
MixKeyDic.Add(keyList[i], valList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string _GenJsonStr()
|
||||
{
|
||||
if (MixKeyDic.Count > 0)
|
||||
{
|
||||
var jsonStr = JsonConvert.SerializeObject(MixKeyDic);
|
||||
return jsonStr;
|
||||
}
|
||||
|
||||
DebugUtil.LogError("生成Json时出错!MixKeyDic为空!");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void GenMixKeyJsonFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
_LoadMixKeyDic();
|
||||
var jsonStr = _GenJsonStr();
|
||||
if (jsonStr == null)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
File.WriteAllText(JsonPath, jsonStr, System.Text.Encoding.UTF8);
|
||||
DebugUtil.Log("生成MixKey配置成功!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugUtil.LogError(e);
|
||||
DebugUtil.Log("生成MixKey配置失败!");
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
IsGenJsonProcess = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e7c95663cf0f44f6a21e802a825fa124
|
||||
timeCreated: 1718872184
|
||||
Loading…
Reference in New Issue