internal void Unpublish(UIMouseEvent evt, UIElement listeningElement) { if (ModLoader.modBrowserPassphrase == "") { Main.menuMode = Interface.enterPassphraseMenuID; Interface.enterPassphraseMenu.SetGotoMenu(Interface.managePublishedID); return; } Main.PlaySound(12, -1, -1, 1); try { System.Net.ServicePointManager.Expect100Continue = false; string url = "http://javid.ddns.net/tModLoader/unpublishmymod.php"; IO.UploadFile[] files = new IO.UploadFile[0]; var values = new NameValueCollection { { "name", this.name }, { "steamid64", Steamworks.SteamUser.GetSteamID().ToString() }, { "modloaderversion", ModLoader.versionedName }, { "passphrase", ModLoader.modBrowserPassphrase }, }; byte[] result = IO.UploadFile.UploadFiles(url, files, values); string s = System.Text.Encoding.UTF8.GetString(result, 0, result.Length); ErrorLogger.LogModUnPublish(s); } catch (Exception e) { ErrorLogger.LogModBrowserException(e); } }
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() { Main.clrInput(); if (!loaded) { uITextPanel.SetText("Mod Browser", 0.8f, true); modListAll.Clear(); TmodFile[] modFiles = ModLoader.FindMods(); List<BuildProperties> modBuildProperties = new List<BuildProperties>(); foreach (TmodFile tmodfile in modFiles) { modBuildProperties.Add(BuildProperties.ReadModFile(tmodfile)); } XmlDocument xmlDoc = new XmlDocument(); try { // xmlDoc = GetDataFromUrl("http://javid.ddns.net/tModLoader/listmods.php"); System.Net.ServicePointManager.Expect100Continue = false; string url = "http://javid.ddns.net/tModLoader/listmods.php"; IO.UploadFile[] files = new IO.UploadFile[0]; var values = new NameValueCollection { { "modloaderversion", ModLoader.versionedName }, }; byte[] result = IO.UploadFile.UploadFiles(url, files, values); xmlDoc.LoadXml(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; } if (e.Status == WebExceptionStatus.ProtocolError) { var resp = (HttpWebResponse)e.Response; if (resp.StatusCode == HttpStatusCode.NotFound) { uITextPanel.SetText("Mod Browser OFFLINE (404)", 0.8f, true); return; } uITextPanel.SetText("Mod Browser OFFLINE..", 0.8f, true); return; } } catch (Exception e) { ErrorLogger.LogModBrowserException(e); return; } try { foreach (XmlNode xmlNode in xmlDoc.DocumentElement) { if (xmlNode.Name.Equals("update")) { updateAvailable = true; updateText = xmlNode.SelectSingleNode("message").InnerText; updateURL = xmlNode.SelectSingleNode("url").InnerText; } else if (xmlNode.Name.Equals("modlist")) { foreach (XmlNode xmlNode2 in xmlNode) { string displayname = xmlNode2.SelectSingleNode("displayname").InnerText; string name = xmlNode2.SelectSingleNode("name").InnerText; string version = xmlNode2.SelectSingleNode("version").InnerText; string author = xmlNode2.SelectSingleNode("author").InnerText; string description = xmlNode2.SelectSingleNode("description").InnerText; string homepage = xmlNode2.SelectSingleNode("homepage").InnerText; string download = xmlNode2.SelectSingleNode("download").InnerText; string timeStamp = xmlNode2.SelectSingleNode("updateTimeStamp").InnerText; int downloads; Int32.TryParse(xmlNode2.SelectSingleNode("downloads").InnerText, out downloads); bool exists = false; bool update = false; foreach (BuildProperties bp in modBuildProperties) { if (bp.displayName.Equals(displayname)) { exists = true; if (!bp.version.Equals(new Version(version.Substring(1)))) { update = true; } } } UIModDownloadItem modItem = new UIModDownloadItem(displayname, name, version, author, description, homepage, download, downloads, timeStamp, update, exists); modListAll.Add(modItem); } SortList(null, null); } } } catch (Exception e) { ErrorLogger.LogModBrowserException(e); return; } loaded = true; } }
public override void OnActivate() { if (!loaded) { uITextPanel.SetText("Mod Browser", 0.8f, true); modListAll.Clear(); TmodFile[] modFiles = ModLoader.FindMods(); List <BuildProperties> modBuildProperties = new List <BuildProperties>(); foreach (TmodFile tmodfile in modFiles) { modBuildProperties.Add(BuildProperties.ReadModFile(tmodfile)); } XmlDocument xmlDoc = new XmlDocument(); try { // xmlDoc = GetDataFromUrl("http://javid.ddns.net/tModLoader/listmods.php"); System.Net.ServicePointManager.Expect100Continue = false; string url = "http://javid.ddns.net/tModLoader/listmods.php"; IO.UploadFile[] files = new IO.UploadFile[0]; var values = new NameValueCollection { { "modloaderversion", ModLoader.version }, }; byte[] result = IO.UploadFile.UploadFiles(url, files, values); xmlDoc.LoadXml(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; } if (e.Status == WebExceptionStatus.ProtocolError) { var resp = (HttpWebResponse)e.Response; if (resp.StatusCode == HttpStatusCode.NotFound) { uITextPanel.SetText("Mod Browser OFFLINE (404)", 0.8f, true); return; } uITextPanel.SetText("Mod Browser OFFLINE..", 0.8f, true); return; } } catch (Exception e) { ErrorLogger.LogModBrowserException(e); return; } try { foreach (XmlNode xmlNode in xmlDoc.DocumentElement) { if (xmlNode.Name.Equals("update")) { updateAvailable = true; updateText = xmlNode.SelectSingleNode("message").InnerText; updateURL = xmlNode.SelectSingleNode("url").InnerText; } else if (xmlNode.Name.Equals("modlist")) { foreach (XmlNode xmlNode2 in xmlNode) { string displayname = xmlNode2.SelectSingleNode("displayname").InnerText; string name = xmlNode2.SelectSingleNode("name").InnerText; string version = xmlNode2.SelectSingleNode("version").InnerText; string author = xmlNode2.SelectSingleNode("author").InnerText; string description = xmlNode2.SelectSingleNode("description").InnerText; string homepage = xmlNode2.SelectSingleNode("homepage").InnerText; string download = xmlNode2.SelectSingleNode("download").InnerText; string timeStamp = xmlNode2.SelectSingleNode("updateTimeStamp").InnerText; int downloads; Int32.TryParse(xmlNode2.SelectSingleNode("downloads").InnerText, out downloads); bool exists = false; bool update = false; foreach (BuildProperties bp in modBuildProperties) { if (bp.displayName.Equals(displayname)) { exists = true; if (!bp.version.Equals(version)) { update = true; } } } UIModDownloadItem modItem = new UIModDownloadItem(displayname, name, version, author, description, homepage, download, downloads, timeStamp, update, exists); modListAll.Add(modItem); } SortList(null, null); } } } catch (Exception e) { ErrorLogger.LogModBrowserException(e); return; } loaded = true; } }