public static CsvLocalizedData LoadFrom(string path, int numRowsToSkip = 2) { CsvLocalizedData resultOb = new CsvLocalizedData(); if (File.Exists(path)) { resultOb.mapLanguages[DefaultLanguage] = CsvData.LoadFrom(path, numRowsToSkip); } foreach (string lang in LocalizationDB.Languages) { string locPath = path.Replace(".csv", "." + lang + ".csv"); if (File.Exists(locPath)) { resultOb.mapLanguages.Add(lang, CsvData.LoadFrom(locPath, numRowsToSkip)); } } if (resultOb.mapLanguages.ContainsKey(DefaultLanguage)) { resultOb.data = resultOb.mapLanguages[DefaultLanguage]; } return(resultOb); }
private List <T> LoadGameData <T>(string folderPath, string pathNoExt) where T : GameData, new() { var rawData = CsvLocalizedData.LoadFrom(folderPath + pathNoExt + ".csv"); int numRows = rawData.GetNumRows(); if (numRows == 0) { Logger.WriteLine("FAILED to load {0}: empty", pathNoExt); return(null); } T testOb = new T(); if (!testOb.IsRawDataValid(rawData)) { Logger.WriteLine("FAILED to load {0}: layout mismatch!", pathNoExt); return(null); } var resultList = new List <T>(); for (int idx = 0; idx < numRows; idx++) { T entryOb = new T(); entryOb.Parse(rawData, idx); if (entryOb.IsValid()) { resultList.Add(entryOb); } } Logger.WriteLine(">> loaded {0}, entries: {1}", pathNoExt, resultList.Count); return(resultList); }
public override void Parse(CsvLocalizedData rawData, int rowIdx) { string[] defRow = rawData.data.rows[rowIdx]; if (defRow[1].Length > 0) { Name = rawData.GetLocalizedText(rowIdx, 1); } }
public override void Parse(CsvLocalizedData rawData, int rowIdx) { string[] defRow = rawData.data.rows[rowIdx]; Id = int.Parse(defRow[0]); if (Id > 0) { Type = rawData.GetLocalizedText(rowIdx, 1); } }
public override void Parse(CsvLocalizedData rawData, int rowIdx) { string[] defRow = rawData.data.rows[rowIdx]; if (defRow[16] == CardItemType) { Id = int.Parse(defRow[0]); CardName = defRow[15]; } }
public override void Parse(CsvLocalizedData rawData, int rowIdx) { string[] defRow = rawData.data.rows[rowIdx]; if (defRow[6] == NpcType && defRow[7].StartsWith(NpcId)) { Id = int.Parse(defRow[7].Substring(NpcId.Length)); ScaledPosX = float.Parse(defRow[1], CultureInfo.InvariantCulture); ScaledPosZ = float.Parse(defRow[3], CultureInfo.InvariantCulture); MapCode = defRow[8]; } }
public override void Parse(CsvLocalizedData rawData, int rowIdx) { string[] defRow = rawData.data.rows[rowIdx]; MapCode = defRow[7]; if (MapCode.Length > 0 && !MapCode.StartsWith("default")) { Name = defRow[12]; Scale = int.Parse(defRow[8]); OffsetX = int.Parse(defRow[9]); OffsetY = int.Parse(defRow[10]); } }
public override void Parse(CsvLocalizedData rawData, int rowIdx) { string[] defRow = rawData.data.rows[rowIdx]; Id = int.Parse(defRow[0]); TriadId = 0; for (int colIdx = 3; colIdx < defRow.Length; colIdx++) { if (defRow[colIdx].StartsWith(TriadIdPattern)) { TriadId = int.Parse(defRow[colIdx].Substring(TriadIdPattern.Length)); break; } } }
public override void Parse(CsvLocalizedData rawData, int rowIdx) { string[] defRow = rawData.data.rows[rowIdx]; Id = int.Parse(defRow[0]); if (Id > 0) { RuleIds = new List <int>(); for (int idx = 1; idx <= 4; idx++) { if (defRow[idx] != "0") { RuleIds.Add(int.Parse(defRow[idx])); } } } }
public override void Parse(CsvLocalizedData rawData, int rowIdx) { string[] defRow = rawData.data.rows[rowIdx]; Id = int.Parse(defRow[0]); if (Id > 0) { sideTop = int.Parse(defRow[2]); sideBottom = int.Parse(defRow[3]); sideLeft = int.Parse(defRow[5]); sideRight = int.Parse(defRow[4]); cardType = defRow[7]; int rarityStrLen = defRow[6].Length; char lastRarityChar = (rarityStrLen > 0) ? defRow[6][rarityStrLen - 1] : '0'; rarityIdx = lastRarityChar - '0'; sortOrder = int.Parse(defRow[10]); uiGroup = int.Parse(defRow[11]); foreach (var kvp in rawData.mapLanguages) { if (kvp.Key != CsvLocalizedData.DefaultLanguage) { string[] locRow = (rowIdx < kvp.Value.rows.Count) ? kvp.Value.rows[rowIdx] : null; if (locRow != null) { int[] sides = new int[] { int.Parse(locRow[2]), // top int.Parse(locRow[5]), // left int.Parse(locRow[3]), // bottom int.Parse(locRow[4]) // right }; bool isValid = (sides[0] > 0) && (sides[1] > 0) && (sides[2] > 0) && (sides[3] > 0); if (isValid) { locSides.Add(kvp.Key, sides); } } } } } }
public override bool IsRawDataValid(CsvLocalizedData rawData) { return(rawData.GetNumColumns() == 5); }
public override void Parse(CsvLocalizedData rawData, int rowIdx) { string[] defRow = rawData.data.rows[rowIdx]; Id = int.Parse(defRow[0]); if (Id > 0) { CardsFixed = new List <string>(); for (int idx = 1; idx <= 5; idx++) { if (defRow[idx].Length > 0 && defRow[idx] != "0") { CardsFixed.Add(defRow[idx]); } } CardsVariable = new List <string>(); for (int idx = 6; idx <= 10; idx++) { if (defRow[idx].Length > 0 && defRow[idx] != "0") { CardsVariable.Add(defRow[idx]); } } Rules = new List <string>(); for (int idx = 11; idx <= 12; idx++) { if (defRow[idx].Length > 0) { Rules.Add(defRow[idx]); } } Rewards = new List <string>(); for (int idx = 27; idx <= 30; idx++) { if (defRow[idx].Length > 0) { Rewards.Add(defRow[idx]); } } foreach (var kvp in rawData.mapLanguages) { if (kvp.Key != CsvLocalizedData.DefaultLanguage) { string[] locRow = (rowIdx < kvp.Value.rows.Count) ? kvp.Value.rows[rowIdx] : null; if (locRow != null) { List <string> cardNames = new List <string>(); for (int idx = 1; idx <= 10; idx++) { if (locRow[idx].Length > 0 && locRow[idx] != "0") { cardNames.Add(locRow[idx]); } } if (cardNames.Count > 0) { locCards.Add(kvp.Key, cardNames.ToArray()); } } } } } }
public virtual void Parse(CsvLocalizedData rawData, int rowIdx) { }
public virtual bool IsRawDataValid(CsvLocalizedData rawData) { return(false); }