Inheritance: Terraria.GameContent.UI.Elements.UIPanel
Example #1
0
        private static void EnableListOnly(UIMouseEvent evt, UIElement listeningElement)
        {
            UIModPackItem modListItem = (UIModPackItem)listeningElement.Parent;

            foreach (var item in UIModPacks.mods)
            {
                ModLoader.DisableMod(item);
            }
            foreach (string modname in modListItem.mods)
            {
                if (UIModPacks.mods.Contains(modname))
                {
                    ModLoader.EnableMod(modname);
                }
            }
            Main.menuMode = Interface.reloadModsID;             // should reload, which should refresh enabled counts

            if (modListItem.numModsMissing > 0)
            {
                string missing = "The following mods were not found:\n";
                for (int i = 0; i < modListItem.mods.Length; i++)
                {
                    if (modListItem.modMissing[i])
                    {
                        missing += modListItem.mods[i] + "\n";
                    }
                }
                Interface.infoMessage.SetMessage(missing);
                Interface.infoMessage.SetGotoMenu(Interface.reloadModsID);
                Main.menuMode = Interface.infoMessageID;
            }
        }
Example #2
0
        private static void EnableListOnly(UIMouseEvent evt, UIElement listeningElement)
        {
            UIModPackItem modListItem = (UIModPackItem)listeningElement.Parent;

            foreach (var item in UIModPacks.mods)
            {
                ModLoader.DisableMod(item);
            }
            foreach (string modname in modListItem.mods)
            {
                if (UIModPacks.mods.Contains(modname))
                {
                    ModLoader.EnableMod(modname);
                }
            }
            Main.menuMode = Interface.reloadModsID;             // should reload, which should refresh enabled counts

            if (modListItem.numModsMissing > 0)
            {
                string missing = "";
                for (int i = 0; i < modListItem.mods.Length; i++)
                {
                    if (modListItem.modMissing[i])
                    {
                        missing += modListItem.mods[i] + "\n";
                    }
                }
                Interface.infoMessage.Show(Language.GetTextValue("tModLoader.ModPackModsMissing", missing), Interface.reloadModsID);
            }
        }
Example #3
0
        private static void ViewInModBrowser(UIMouseEvent evt, UIElement listeningElement)
        {
            UIModPackItem modListItem = ((UIModPackItem)listeningElement.Parent);

            Interface.modBrowser.Activate();
            Interface.modBrowser.specialModPackFilter = modListItem.mods.ToList();
            Interface.modBrowser.SortList();
            Main.PlaySound(SoundID.MenuOpen);
            Main.menuMode = Interface.modBrowserID;
        }
Example #4
0
        private void DeleteButtonClick(UIMouseEvent evt, UIElement listeningElement)
        {
            UIModPackItem modPackItem = ((UIModPackItem)listeningElement.Parent);

            Directory.CreateDirectory(UIModPacks.ModListSaveDirectory);
            string path = UIModPacks.ModListSaveDirectory + Path.DirectorySeparatorChar + modPackItem.filename + ".json";

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            Main.menuMode = Interface.modPacksMenuID;            // should reload
        }
Example #5
0
        private static void ViewListInfo(UIMouseEvent evt, UIElement listeningElement)
        {
            UIModPackItem modListItem = ((UIModPackItem)listeningElement.Parent);

            Main.PlaySound(10, -1, -1, 1);
            string message = "";

            for (int i = 0; i < modListItem.mods.Length; i++)
            {
                message += modListItem.mods[i] + (modListItem.modMissing[i] ? Language.GetTextValue("tModLoader.ModPackMissing") : ModLoader.IsEnabled(modListItem.mods[i]) ? "" : Language.GetTextValue("tModLoader.ModPackDisabled")) + "\n";
            }
            //Interface.infoMessage.SetMessage($"This list contains the following mods:\n{String.Join("\n", ((UIModListItem)listeningElement.Parent).mods)}");
            Interface.infoMessage.Show(Language.GetTextValue("tModLoader.ModPackModsContained", message), Interface.modPacksMenuID);
        }
Example #6
0
        private static void ViewInModBrowser(UIMouseEvent evt, UIElement listeningElement)
        {
            UIModPackItem modListItem = ((UIModPackItem)listeningElement.Parent);

            Interface.modBrowser.Activate();
            Interface.modBrowser.filterTextBox.currentString = "";
            Interface.modBrowser.SpecialModPackFilter        = modListItem.mods.ToList();
            Interface.modBrowser.SpecialModPackFilterTitle   = "Modlist";         // Too long: " + modListItem.modName.Text;
            Interface.modBrowser.updateFilterMode            = UpdateFilter.All;  // Set to 'All' so all mods from ModPack are visible
            Interface.modBrowser.uIToggleImage.setCurrentState((int)Interface.modBrowser.updateFilterMode);
            Interface.modBrowser.updateNeeded = true;
            Main.PlaySound(SoundID.MenuOpen);
            Main.menuMode = Interface.modBrowserID;
        }
Example #7
0
        private static void ViewListInfo(UIMouseEvent evt, UIElement listeningElement)
        {
            UIModPackItem modListItem = ((UIModPackItem)listeningElement.Parent);

            Main.PlaySound(10, -1, -1, 1);
            string message = "This list contains the following mods:\n";

            for (int i = 0; i < modListItem.mods.Length; i++)
            {
                message += modListItem.mods[i] + (modListItem.modMissing[i] ? " - Missing" : "") + "\n";
            }
            //Interface.infoMessage.SetMessage($"This list contains the following mods:\n{String.Join("\n", ((UIModListItem)listeningElement.Parent).mods)}");
            Interface.infoMessage.SetMessage(message);
            Interface.infoMessage.SetGotoMenu(Interface.modPacksMenuID);
            Main.menuMode = Interface.infoMessageID;
        }
Example #8
0
        private static void ViewInModBrowser(UIMouseEvent evt, UIElement listeningElement)
        {
            UIModPackItem modListItem = ((UIModPackItem)listeningElement.Parent);

            Interface.modBrowser.Activate();
            Interface.modBrowser.FilterTextBox.Text        = "";
            Interface.modBrowser.SpecialModPackFilter      = modListItem._mods.ToList();
            Interface.modBrowser.SpecialModPackFilterTitle = Language.GetTextValue("tModLoader.MBFilterModlist"); // Too long: " + modListItem.modName.Text;
            Interface.modBrowser.UpdateFilterMode          = UpdateFilter.All;                                    // Set to 'All' so all mods from ModPack are visible
            Interface.modBrowser.ModSideFilterMode         = ModSideFilter.All;
            Interface.modBrowser.UpdateFilterToggle.SetCurrentState((int)Interface.modBrowser.UpdateFilterMode);
            Interface.modBrowser.ModSideFilterToggle.SetCurrentState((int)Interface.modBrowser.ModSideFilterMode);
            Interface.modBrowser.UpdateNeeded = true;
            SoundEngine.PlaySound(SoundID.MenuOpen);
            Main.menuMode = Interface.modBrowserID;
        }
Example #9
0
        public override void OnActivate()
        {
            scrollPanel.Append(uiLoader);
            modListList.Clear();
            if (SynchronizationContext.Current == null)
            {
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            }
            Task.Factory
            .StartNew(delegate
            {
                mods = ModOrganizer.FindMods().Select(m => m.Name).ToArray();
                return(FindModLists());
            })
            .ContinueWith(task =>
            {
                string[] modListsFullPath = task.Result;
                foreach (string modListFilePath in modListsFullPath)
                {
                    try
                    {
                        string[] mods = { };
                        //string path = ModListSaveDirectory + Path.DirectorySeparatorChar + modListFilePath + ".json";

                        if (File.Exists(modListFilePath))
                        {
                            using (StreamReader r = new StreamReader(modListFilePath))
                            {
                                string json = r.ReadToEnd();

                                mods = JsonConvert.DeserializeObject <string[]>(json);
                            }
                        }
                        UIModPackItem modItem = new UIModPackItem(Path.GetFileNameWithoutExtension(modListFilePath), mods);
                        modListList.Add(modItem);
                    }
                    catch
                    {
                        UIAutoScaleTextTextPanel <string> badModPackMessage = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackMalformed", Path.GetFileName(modListFilePath)));
                        badModPackMessage.Width.Set(0, 1);
                        badModPackMessage.Height.Set(50, 0);
                        modListList.Add(badModPackMessage);
                    }
                }
                scrollPanel.RemoveChild(uiLoader);
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Example #10
0
        public override void OnActivate()
        {
            if (!scrollPanel.HasChild(uiLoader))
            {
                scrollPanel.Append(uiLoader);
            }
            modListList.Clear();
            if (SynchronizationContext.Current == null)
            {
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            }
            Task.Factory
            .StartNew(delegate
            {
                mods = ModLoader.FindMods();
                return(FindModLists());
            })
            .ContinueWith(task =>
            {
                string[] modListsFullPath = task.Result;
                foreach (string modListFilePath in modListsFullPath)
                {
                    string[] mods = { };
                    //string path = ModListSaveDirectory + Path.DirectorySeparatorChar + modListFilePath + ".json";

                    if (File.Exists(modListFilePath))
                    {
                        using (StreamReader r = new StreamReader(modListFilePath))
                        {
                            string json = r.ReadToEnd();
                            mods        = JsonConvert.DeserializeObject <string[]>(json);
                        }
                    }

                    UIModPackItem modItem = new UIModPackItem(Path.GetFileNameWithoutExtension(modListFilePath), mods);
                    modListList.Add(modItem);
                }
                if (scrollPanel.HasChild(uiLoader))
                {
                    scrollPanel.RemoveChild(uiLoader);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Example #11
0
        public override void OnActivate()
        {
            mods = ModLoader.FindMods();

            modListList.Clear();
            string[] modListsFullPath = FindModLists();
            foreach (string modListFilePath in modListsFullPath)
            {
                string[] mods = { };
                //string path = ModListSaveDirectory + Path.DirectorySeparatorChar + modListFilePath + ".json";

                if (File.Exists(modListFilePath))
                {
                    using (StreamReader r = new StreamReader(modListFilePath))
                    {
                        string json = r.ReadToEnd();
                        mods = JsonConvert.DeserializeObject <string[]>(json);
                    }
                }

                UIModPackItem modItem = new UIModPackItem(Path.GetFileNameWithoutExtension(modListFilePath), mods);
                modListList.Add(modItem);
            }
        }
Example #12
0
		public override void OnActivate()
		{
			mods = ModLoader.FindMods();

			modListList.Clear();
			string[] modListsFullPath = FindModLists();
			foreach (string modListFilePath in modListsFullPath)
			{
				string[] mods = { };
				//string path = ModListSaveDirectory + Path.DirectorySeparatorChar + modListFilePath + ".json";

				if (File.Exists(modListFilePath))
				{
					using (StreamReader r = new StreamReader(modListFilePath))
					{
						string json = r.ReadToEnd();
						mods = JsonConvert.DeserializeObject<string[]>(json);
					}
				}

				UIModPackItem modItem = new UIModPackItem(Path.GetFileNameWithoutExtension(modListFilePath), mods);
				modListList.Add(modItem);
			}
		}