Inheritance: Terraria.GameContent.UI.Elements.UIPanel
Beispiel #1
0
        public override void OnActivate()
        {
            _myPublishedMods.Clear();
            string text = Language.GetTextValue("tModLoader.MenuModBrowser") + " " + Language.GetTextValue("tModLoader.MBOfflineWithReason", Language.GetTextValue("tModLoader.MBUnknown"));

            TextPanel.SetText(text, 0.8f, true);
            string response = string.Empty;

            try {
                ServicePointManager.Expect100Continue = false;
                string url    = "http://javid.ddns.net/tModLoader/listmymods.php";
                var    values = new NameValueCollection
                {
                    { "steamid64", ModLoader.SteamID64 },
                    { "modloaderversion", BuildInfo.versionedName },
                    { "passphrase", ModLoader.modBrowserPassphrase },
                };
                byte[] result = IO.UploadFile.UploadFiles(url, null, values);
                response = Encoding.UTF8.GetString(result);
            }
            catch (WebException e) {
                if (e.Status == WebExceptionStatus.Timeout)
                {
                    TextPanel.SetText(Language.GetTextValue("tModLoader.MenuModBrowser") + " " + Language.GetTextValue("tModLoader.MBOfflineWithReason", Language.GetTextValue("tModLoader.MBBusy")), 0.8f, true);
                    return;
                }
                TextPanel.SetText(Language.GetTextValue("tModLoader.MenuModBrowser") + " " + Language.GetTextValue("tModLoader.MBOfflineWithReason", ""), 0.8f, true);
                return;
            }
            catch (Exception e) {
                UIModBrowser.LogModBrowserException(e);
                return;
            }
            try {
                JArray a;
                try {
                    a = JArray.Parse(response);
                }
                catch (Exception e) {
                    throw new Exception($"Manage Published Error Response: {response}", e);
                }

                foreach (JObject o in a.Children <JObject>())
                {
                    var modItem = new UIModManageItem(
                        (string)o["displayname"],
                        (string)o["name"],
                        (string)o["version"],
                        (string)o["author"],
                        (int)o["downloads"],
                        (int)o["downloadsversion"],
                        (string)o["modloaderversion"]
                        );
                    _myPublishedMods.Add(modItem);
                }
            }
            catch (Exception e) {
                UIModBrowser.LogModBrowserException(e);
            }
        }
Beispiel #2
0
        public override void OnActivate()
        {
            myPublishedMods.Clear();
            uITextPanel.SetText("My Published Mods", 0.8f, true);
            string response = "";

            try
            {
                System.Net.ServicePointManager.Expect100Continue = false;
                string          url    = "http://javid.ddns.net/tModLoader/listmymods.php";
                IO.UploadFile[] files  = new IO.UploadFile[0];
                var             values = new NameValueCollection
                {
                    { "steamid64", ModLoader.SteamID64 },
                    { "modloaderversion", ModLoader.versionedName },
                    { "passphrase", ModLoader.modBrowserPassphrase },
                };
                byte[] result = IO.UploadFile.UploadFiles(url, files, values);
                response = System.Text.Encoding.UTF8.GetString(result);
            }
            catch (WebException e)
            {
                if (e.Status == WebExceptionStatus.Timeout)
                {
                    uITextPanel.SetText("Mod Browser OFFLINE (Busy)", 0.8f, true);
                    return;
                }
                uITextPanel.SetText("Mod Browser OFFLINE.", 0.8f, true);
                return;
            }
            catch (Exception e)
            {
                ErrorLogger.LogModBrowserException(e);
                return;
            }
            try
            {
                JArray a = JArray.Parse(response);

                foreach (JObject o in a.Children <JObject>())
                {
                    UIModManageItem modItem = new UIModManageItem(
                        (string)o["displayname"],
                        (string)o["name"],
                        (string)o["version"],
                        (string)o["author"],
                        (string)o["downloads"],
                        (string)o["downloadsversion"],
                        (string)o["modloaderversion"]
                        );
                    myPublishedMods.Add(modItem);
                }
            }
            catch (Exception e)
            {
                ErrorLogger.LogModBrowserException(e);
                return;
            }
        }
        public override void OnActivate()
        {
            myPublishedMods.Clear();
            uITextPanel.SetText("My Published Mods", 0.8f, true);
            String xmlText = "";

            try
            {
                System.Net.ServicePointManager.Expect100Continue = false;
                string          url    = "http://javid.ddns.net/tModLoader/listmymods.php";
                IO.UploadFile[] files  = new IO.UploadFile[0];
                var             values = new NameValueCollection
                {
                    { "steamid64", Steamworks.SteamUser.GetSteamID().ToString() },
                    { "modloaderversion", ModLoader.versionedName },
                    { "passphrase", ModLoader.modBrowserPassphrase },
                };
                byte[] result = IO.UploadFile.UploadFiles(url, files, values);
                xmlText = System.Text.Encoding.UTF8.GetString(result, 0, result.Length);
            }
            catch (WebException e)
            {
                if (e.Status == WebExceptionStatus.Timeout)
                {
                    uITextPanel.SetText("Mod Browser OFFLINE (Busy)", 0.8f, true);
                    return;
                }
                uITextPanel.SetText("Mod Browser OFFLINE.", 0.8f, true);
                return;
            }
            catch (Exception e)
            {
                ErrorLogger.LogModBrowserException(e);
                return;
            }
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlText);
                foreach (XmlNode xmlNode in xmlDoc.DocumentElement)
                {
                    string          displayname      = xmlNode.SelectSingleNode("displayname").InnerText;
                    string          name             = xmlNode.SelectSingleNode("name").InnerText;
                    string          version          = xmlNode.SelectSingleNode("version").InnerText;
                    string          author           = xmlNode.SelectSingleNode("author").InnerText;
                    string          downloads        = xmlNode.SelectSingleNode("downloads").InnerText;
                    string          downloadsversion = xmlNode.SelectSingleNode("downloadsversion").InnerText;
                    string          modloaderversion = xmlNode.SelectSingleNode("modloaderversion").InnerText;
                    UIModManageItem modItem          = new UIModManageItem(displayname, name, version, author, downloads, downloadsversion, modloaderversion);
                    myPublishedMods.Add(modItem);
                }
            }
            catch (Exception e)
            {
                ErrorLogger.LogModBrowserException(e);
                return;
            }
        }
		public override void OnActivate()
		{
			myPublishedMods.Clear();
			uITextPanel.SetText("My Published Mods", 0.8f, true);
			String xmlText = "";
			try
			{
				System.Net.ServicePointManager.Expect100Continue = false;
				string url = "http://javid.ddns.net/tModLoader/listmymods.php";
				IO.UploadFile[] files = new IO.UploadFile[0];
				var values = new NameValueCollection
				{
					{ "steamid64", Steamworks.SteamUser.GetSteamID().ToString() },
					{ "modloaderversion", ModLoader.versionedName },
					{ "passphrase", ModLoader.modBrowserPassphrase },
				};
				byte[] result = IO.UploadFile.UploadFiles(url, files, values);
				xmlText = System.Text.Encoding.UTF8.GetString(result, 0, result.Length);
			}
			catch (WebException e)
			{
				if (e.Status == WebExceptionStatus.Timeout)
				{
					uITextPanel.SetText("Mod Browser OFFLINE (Busy)", 0.8f, true);
					return;
				}
				uITextPanel.SetText("Mod Browser OFFLINE.", 0.8f, true);
				return;
			}
			catch (Exception e)
			{
				ErrorLogger.LogModBrowserException(e);
				return;
			}
			try
			{
				XmlDocument xmlDoc = new XmlDocument();
				xmlDoc.LoadXml(xmlText);
				foreach (XmlNode xmlNode in xmlDoc.DocumentElement)
				{
					string displayname = xmlNode.SelectSingleNode("displayname").InnerText;
					string name = xmlNode.SelectSingleNode("name").InnerText;
					string version = xmlNode.SelectSingleNode("version").InnerText;
					string author = xmlNode.SelectSingleNode("author").InnerText;
					string downloads = xmlNode.SelectSingleNode("downloads").InnerText;
					string downloadsversion = xmlNode.SelectSingleNode("downloadsversion").InnerText;
					string modloaderversion = xmlNode.SelectSingleNode("modloaderversion").InnerText;
					UIModManageItem modItem = new UIModManageItem(displayname, name, version, author, downloads, downloadsversion, modloaderversion);
					myPublishedMods.Add(modItem);
				}
			}
			catch (Exception e)
			{
				ErrorLogger.LogModBrowserException(e);
				return;
			}
		}