public override void Load() { if (!Main.dedServ) //idk? { AchievementsMenu = new UIAchievementsMenu(); MenuInterface = new UserInterface(); LanguageSettings = new UILanguageSettings(); On_AddMenuButtons += Interface_AddMenuButtons; On.Terraria.Main.DrawMenu += Main_DrawMenu; //IL.Terraria.Main.DrawMenu += MoveLogoLower; } }
private void AddCustomAchievements(On.Terraria.GameContent.UI.States.UIAchievementsMenu.orig_InitializePage orig, UIAchievementsMenu self) { orig(self); Type typ = self.GetType(); FieldInfo elementInfo = typ.GetField("_achievementElements", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo achieveInfo = typ.GetField("_achievementsList", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo childrenInfo = typeof(UIElement).GetField("Elements", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo lockInfo = typeof(UIAchievementListItem).GetField("_locked", BindingFlags.NonPublic | BindingFlags.Instance); List <UIElement> children = (List <UIElement>)childrenInfo.GetValue(self); UIElement element = children.FirstOrDefault(c => c is UIElement); List <UIElement> children2 = (List <UIElement>)childrenInfo.GetValue(element); UIElement panel = children2.FirstOrDefault(c => c is UIPanel); List <UIElement> children3 = (List <UIElement>)childrenInfo.GetValue(panel); UIElement scrollbar = children3.FirstOrDefault(c => c is UIScrollbar); List <UIAchievementListItem> elements = (List <UIAchievementListItem>)elementInfo.GetValue(self); UIList achievements = (UIList)achieveInfo.GetValue(self); foreach (ModAchievement achieve in Achievements) { //lockInfo.SetValue(achieve, (achieve as ModAchievement).Unlocked); elements.Add(achieve); achievements.Add(achieve); } elementInfo.SetValue(self, elements); achieveInfo.SetValue(self, achievements); achievements.SetScrollbar(scrollbar as UIScrollbar); }