private static void CtorModWorlData(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, UIWorldListItem self, WorldFileData data, int snapPointIndex) { orig(self, data, snapPointIndex); if (!SGAConfigClient.Instance.PlayerWorldData) { return; } string path = data.Path.Replace(".wld", ".twld"); TagCompound tag; try { byte[] buffer = FileUtilities.ReadAllBytes(path, data.IsCloudSave); tag = TagIO.FromStream(new MemoryStream(buffer), true); } catch { tag = null; } TagCompound tag2 = tag?.GetList <TagCompound>("modData").FirstOrDefault(testby => testby.GetString("mod") == "SGAmod" && testby.GetString("name") == "SGAWorld"); TagCompound tag3 = tag2?.Get <TagCompound>("data"); SGAmodData.Add(self, tag3); }
private static void ConstructorBlack(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, UIWorldListItem self, WorldFileData data, int snapPointIndex) { orig(self, data, snapPointIndex); if (File.Exists(Path.ChangeExtension(data.Path, ".fwim"))) { self.BackgroundColor = new Color(25, 25, 25); self.BorderColor = new Color(50, 50, 50); } }
private void AddWorldData(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, UIWorldListItem self, WorldFileData data, int snapPointIndex) { orig(self, data, snapPointIndex); string path = data.Path.Replace(".wld", ".twld"); TagCompound tag; try { byte[] buf = FileUtilities.ReadAllBytes(path, data.IsCloudSave); tag = TagIO.FromStream(new MemoryStream(buf), true); } catch { tag = null; } TagCompound tag2 = tag?.GetList <TagCompound>("modData").FirstOrDefault(k => k.GetString("mod") == "StarlightRiver" && k.GetString("name") == "StarlightWorld"); TagCompound tag3 = tag2?.Get <TagCompound>("data"); worldDataCache.Add(self, tag3); }
private static void UIWorldListItemOnctor(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, Terraria.GameContent.UI.Elements.UIWorldListItem self, WorldFileData data, int snappointindex) { orig(self, data, snappointindex); try { string path = Path.ChangeExtension(data.Path, ".twld"); if (File.Exists(path)) { var buf = FileUtilities.ReadAllBytes(path, data.IsCloudSave); var tag = TagIO.FromStream(new MemoryStream(buf)); var list = tag.GetList <TagCompound>("modData").FirstOrDefault((TagCompound m) => m.Get <string>("mod") == "TUA" && m.Get <string>("name") == "TUAWorld"); if (list != null) { TUAWorldData.Add(data.UniqueId, tag.GetList <TagCompound>("modData").FirstOrDefault((TagCompound m) => m.Get <string>("mod") == "TUA" && m.Get <string>("name") == "TUAWorld")); } } } catch (Exception e) { ErrorLogger.Log(e.Message); } }