public static string PrintWeatherIdMap(int weather, int mapId, BdatStringCollection tables) { if (weather == 0xFF) { return("All"); } var sb = new StringBuilder(); bool first = true; Weather[] weathers = new Weather[4]; BdatStringItem map = tables["FLD_maplist"][mapId]; weathers[0] = (Weather)Enum.Parse(typeof(Weather), (string)map["wa_type"]); weathers[1] = (Weather)Enum.Parse(typeof(Weather), (string)map["wb_type"]); weathers[2] = (Weather)Enum.Parse(typeof(Weather), (string)map["wc_type"]); weathers[3] = (Weather)Enum.Parse(typeof(Weather), (string)map["wd_type"]); for (int i = 0; i < 4; i++) { if ((weather & (1 << i)) != 0) { if (!first) { sb.Append(", "); } sb.Append(weathers[i]); first = false; } } return(sb.ToString()); }
private static string GetEnhanceCaption(int itemId, BdatStringCollection tables) { BdatStringItem item = tables["BTL_Enhance"][itemId]; if (item == null) { return(null); } int capId = int.Parse((string)item["Caption"]); string cap = (string)tables["btl_enhance_cap"][capId]?["name"]; if (cap == null) { return(null); } var sb = new StringBuilder(cap); var tags = ParseTags(cap); foreach (var tag in tags.OrderByDescending(x => x.Start)) { if (tag.SubType != "Enhance") { continue; } string replace = string.Empty; if (tag.Values.Count <= 0) { int effectId = int.Parse((string)item["EnhanceEffect"]); replace = (string)tables["BTL_EnhanceEff"][effectId]["Param"]; } else if (tag.Values.TryGetValue("kind", out var field)) { replace = (string)item[field]; } sb.Remove(tag.Start, tag.Length); sb.Insert(tag.Start, replace); } return(sb.ToString()); }
public static void ProcessReferences(BdatStringCollection tables, BdatInfo info) { foreach (BdatStringTable table in tables.Tables.Values) { int id = table.BaseId; foreach (var item in table.Items) { foreach (BdatMember member in table.Members.Where(x => x.Type == BdatMemberType.Scalar)) { var val = ReadValue(table.Name, id, member.Name, tables, info); if (val.childTable != null) { BdatStringItem childItem = tables[val.childTable][int.Parse(val.childId)]; childItem.ReferencedBy.Add(item); } } id++; } } }
private static string GetPouchBuffCaption(BdatStringItem item, BdatFieldInfo field, BdatStringCollection tables, BdatInfo info) { if (item == null) { return(null); } int capId = int.Parse((string)item[field.Field]); var cap = ReadValue("BTL_PouchBuff", capId, "Name", tables, info).value; if (cap == null) { return(null); } var sb = new StringBuilder(cap); var tags = ParseTags(cap); foreach (var tag in tags.OrderByDescending(x => x.Start)) { if (tag.SubType != "PouchParam") { continue; } float buffValue = float.Parse((string)item[field.RefField]); sb.Remove(tag.Start, tag.Length); sb.Insert(tag.Start, buffValue); } return(sb.ToString()); }
public static (string value, string childTable, string childId) ReadValue(string tableName, int itemId, string memberName, BdatStringCollection tables, BdatInfo info) { string val = (string)tables[tableName][itemId]?[memberName]; string display = val; string childTable = null; string childId = null; if (val == null || !info.FieldInfo.TryGetValue((tableName, memberName), out var field)) { return(display, null, null); } int refId = int.Parse(val) + field.Adjust; switch (field.Type) { case BdatFieldType.Message: display = (string)tables[field.RefTable][refId]?["name"]; if (display == null && val != "0") { display = refId.ToString(); } break; case BdatFieldType.Reference: ApplyRef(field.RefTable); break; case BdatFieldType.Item: ApplyRef(GetItemTable(refId)); break; case BdatFieldType.Event: ApplyRef(GetEventTable(refId)); break; case BdatFieldType.Condition: var conditionType = (ConditionType)int.Parse((string)tables[tableName][itemId]?[field.RefField]); ApplyRef(GetConditionTable(conditionType)); break; case BdatFieldType.Task: var taskType = (TaskType)int.Parse((string)tables[tableName][itemId]?[field.RefField]); ApplyRef(GetTaskTable(taskType)); break; case BdatFieldType.ShopTable: var shopType = (ShopType)int.Parse((string)tables[tableName][itemId]?[field.RefField]); ApplyRef(GetShopTable(shopType)); break; case BdatFieldType.Character: ApplyRef(GetCharacterTable(refId)); break; case BdatFieldType.Enhance: display = GetEnhanceCaption(itemId, tables); break; case BdatFieldType.TimeRange: display = PrintTimeRange(int.Parse((string)tables[tableName][itemId]?[memberName])); break; case BdatFieldType.WeatherIdMap: display = PrintWeatherIdMap(int.Parse((string)tables[tableName][itemId]?[memberName]), 13, tables); break; case BdatFieldType.PouchBuff: display = GetPouchBuffCaption(tables[tableName][itemId], field, tables, info); break; } if (field.EnumType != null) { if (field.EnumType.GetCustomAttributes(typeof(FlagsAttribute), false).Length > 0) { display = PrintEnumFlags(field.EnumType, refId); } else { display = Enum.GetName(field.EnumType, refId); } } return(display, childTable, childId); void ApplyRef(string refTable) { if (refTable == null || !tables[refTable].ContainsId(refId)) { display = refId == 0 ? null : refId.ToString(); return; } var refIdString = refId.ToString(); display = refIdString; childTable = refTable; childId = refIdString; if (info.DisplayFields.TryGetValue(refTable, out var displayField)) { var child = ReadValue(refTable, refId, displayField, tables, info); if (!string.IsNullOrWhiteSpace(child.value)) { display = child.value; } } } }