diff --git a/.gitignore b/.gitignore index f2fb525..37ef6f4 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ build/ bld/ [Bb]in/ [Oo]bj/ +.vs/ # Roslyn cache directories *.ide/ diff --git a/CCapi/Form1.Designer.cs b/CCapi/Form1.Designer.cs index 546cc73..1a39253 100644 --- a/CCapi/Form1.Designer.cs +++ b/CCapi/Form1.Designer.cs @@ -48,12 +48,13 @@ private void InitializeComponent() { this.tbFlags = new System.Windows.Forms.TextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.bRawLast5 = new System.Windows.Forms.Button(); - this.tbLast5 = new System.Windows.Forms.TextBox(); this.lTotal = new System.Windows.Forms.Label(); this.tbTotal = new System.Windows.Forms.TextBox(); this.bRefreshLast5 = new System.Windows.Forms.Button(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.tbWebSupport = new System.Windows.Forms.TextBox(); + this.lWeb = new System.Windows.Forms.Label(); this.pbCountry = new System.Windows.Forms.PictureBox(); this.tbFeatured = new System.Windows.Forms.TextBox(); this.lFeatured = new System.Windows.Forms.Label(); @@ -180,22 +181,22 @@ private void InitializeComponent() { this.cbUTC.AutoSize = true; this.cbUTC.Checked = true; this.cbUTC.CheckState = System.Windows.Forms.CheckState.Checked; - this.cbUTC.Location = new System.Drawing.Point(76, 125); + this.cbUTC.Location = new System.Drawing.Point(47, 125); this.cbUTC.Name = "cbUTC"; - this.cbUTC.Size = new System.Drawing.Size(48, 17); + this.cbUTC.Size = new System.Drawing.Size(85, 17); this.cbUTC.TabIndex = 35; - this.cbUTC.Text = "UTC"; + this.cbUTC.Text = "View in UTC"; + this.toolTip1.SetToolTip(this.cbUTC, "Toggle to view registration date and time in UTC or local time."); this.cbUTC.UseVisualStyleBackColor = true; this.cbUTC.CheckedChanged += new System.EventHandler(this.cbUTC_CheckedChanged); // // dtpRegistered // this.dtpRegistered.CustomFormat = "dddd MMMM d, yyyy h:mm:ss tt"; - this.dtpRegistered.Enabled = false; this.dtpRegistered.Location = new System.Drawing.Point(6, 99); this.dtpRegistered.MinDate = new System.DateTime(2013, 8, 13, 0, 0, 0, 0); this.dtpRegistered.Name = "dtpRegistered"; - this.dtpRegistered.Size = new System.Drawing.Size(213, 20); + this.dtpRegistered.Size = new System.Drawing.Size(212, 20); this.dtpRegistered.TabIndex = 32; this.dtpRegistered.Value = new System.DateTime(2020, 1, 8, 0, 0, 0, 0); this.dtpRegistered.ValueChanged += new System.EventHandler(this.dtpRegistered_Changed); @@ -223,7 +224,7 @@ private void InitializeComponent() { // lID // this.lID.AutoSize = true; - this.lID.Location = new System.Drawing.Point(162, 44); + this.lID.Location = new System.Drawing.Point(163, 44); this.lID.Name = "lID"; this.lID.Size = new System.Drawing.Size(21, 13); this.lID.TabIndex = 30; @@ -256,7 +257,7 @@ private void InitializeComponent() { // // bLookup // - this.bLookup.Location = new System.Drawing.Point(130, 20); + this.bLookup.Location = new System.Drawing.Point(164, 20); this.bLookup.Name = "bLookup"; this.bLookup.Size = new System.Drawing.Size(54, 23); this.bLookup.TabIndex = 24; @@ -269,9 +270,9 @@ private void InitializeComponent() { // this.tBSearch.Location = new System.Drawing.Point(6, 21); this.tBSearch.Name = "tBSearch"; - this.tBSearch.Size = new System.Drawing.Size(118, 20); + this.tBSearch.Size = new System.Drawing.Size(153, 20); this.tBSearch.TabIndex = 23; - this.tBSearch.Text = "Player Name/ID"; + this.tBSearch.Text = "Player Name"; this.tBSearch.GotFocus += new System.EventHandler(this.tBSearch_GotFocus); // // groupBox2 @@ -288,11 +289,11 @@ private void InitializeComponent() { // // tbForumTitle // - this.tbForumTitle.Location = new System.Drawing.Point(74, 43); + this.tbForumTitle.Location = new System.Drawing.Point(66, 43); this.tbForumTitle.Multiline = true; this.tbForumTitle.Name = "tbForumTitle"; this.tbForumTitle.ReadOnly = true; - this.tbForumTitle.Size = new System.Drawing.Size(494, 20); + this.tbForumTitle.Size = new System.Drawing.Size(502, 20); this.tbForumTitle.TabIndex = 33; // // lForumTitle @@ -316,7 +317,6 @@ private void InitializeComponent() { // groupBox1 // this.groupBox1.Controls.Add(this.bRawLast5); - this.groupBox1.Controls.Add(this.tbLast5); this.groupBox1.Controls.Add(this.lTotal); this.groupBox1.Controls.Add(this.tbTotal); this.groupBox1.Controls.Add(this.bRefreshLast5); @@ -325,42 +325,32 @@ private void InitializeComponent() { this.groupBox1.Size = new System.Drawing.Size(203, 175); this.groupBox1.TabIndex = 23; this.groupBox1.TabStop = false; - this.groupBox1.Text = "Last Five Accounts"; + this.groupBox1.Text = "ClassiCube Stats"; // // bRawLast5 // - this.bRawLast5.Location = new System.Drawing.Point(6, 21); + this.bRawLast5.Location = new System.Drawing.Point(160, 147); this.bRawLast5.Margin = new System.Windows.Forms.Padding(2); this.bRawLast5.Name = "bRawLast5"; this.bRawLast5.Size = new System.Drawing.Size(37, 23); this.bRawLast5.TabIndex = 23; this.bRawLast5.Text = "Raw"; - this.toolTip1.SetToolTip(this.bRawLast5, "Open the last five accounts in raw JSON."); + this.toolTip1.SetToolTip(this.bRawLast5, "Open ClassiCube\'s statistics in raw JSON."); this.bRawLast5.UseVisualStyleBackColor = true; this.bRawLast5.Click += new System.EventHandler(this.bRawLast5_Click); // - // tbLast5 - // - this.tbLast5.Location = new System.Drawing.Point(6, 48); - this.tbLast5.Multiline = true; - this.tbLast5.Name = "tbLast5"; - this.tbLast5.ReadOnly = true; - this.tbLast5.Size = new System.Drawing.Size(191, 76); - this.tbLast5.TabIndex = 2; - this.tbLast5.Text = "1\r\n2\r\n3\r\n4\r\n5"; - // // lTotal // this.lTotal.AutoSize = true; - this.lTotal.Location = new System.Drawing.Point(10, 143); + this.lTotal.Location = new System.Drawing.Point(12, 69); this.lTotal.Name = "lTotal"; - this.lTotal.Size = new System.Drawing.Size(82, 13); + this.lTotal.Size = new System.Drawing.Size(136, 13); this.lTotal.TabIndex = 6; - this.lTotal.Text = "Total Accounts:"; + this.lTotal.Text = "Total Accounts Registered:"; // // tbTotal // - this.tbTotal.Location = new System.Drawing.Point(102, 139); + this.tbTotal.Location = new System.Drawing.Point(13, 86); this.tbTotal.Name = "tbTotal"; this.tbTotal.ReadOnly = true; this.tbTotal.Size = new System.Drawing.Size(94, 20); @@ -373,7 +363,7 @@ private void InitializeComponent() { this.bRefreshLast5.Size = new System.Drawing.Size(68, 23); this.bRefreshLast5.TabIndex = 4; this.bRefreshLast5.Text = "Refresh"; - this.toolTip1.SetToolTip(this.bRefreshLast5, "Refresh the last five accounts list."); + this.toolTip1.SetToolTip(this.bRefreshLast5, "Update ClassiCube\'s statistics."); this.bRefreshLast5.UseVisualStyleBackColor = true; this.bRefreshLast5.Click += new System.EventHandler(this.bRefreshLast5_Click); // @@ -391,6 +381,8 @@ private void InitializeComponent() { // // groupBox6 // + this.groupBox6.Controls.Add(this.tbWebSupport); + this.groupBox6.Controls.Add(this.lWeb); this.groupBox6.Controls.Add(this.pbCountry); this.groupBox6.Controls.Add(this.tbFeatured); this.groupBox6.Controls.Add(this.lFeatured); @@ -410,11 +402,28 @@ private void InitializeComponent() { this.groupBox6.Size = new System.Drawing.Size(574, 176); this.groupBox6.TabIndex = 28; this.groupBox6.TabStop = false; - this.groupBox6.Text = "Server Info"; + this.groupBox6.Text = "Server Detail"; + // + // tbWebSupport + // + this.tbWebSupport.Location = new System.Drawing.Point(441, 80); + this.tbWebSupport.Name = "tbWebSupport"; + this.tbWebSupport.ReadOnly = true; + this.tbWebSupport.Size = new System.Drawing.Size(54, 20); + this.tbWebSupport.TabIndex = 33; + // + // lWeb + // + this.lWeb.AutoSize = true; + this.lWeb.Location = new System.Drawing.Point(443, 64); + this.lWeb.Name = "lWeb"; + this.lWeb.Size = new System.Drawing.Size(33, 13); + this.lWeb.TabIndex = 32; + this.lWeb.Text = "Web:"; // // pbCountry // - this.pbCountry.Location = new System.Drawing.Point(445, 30); + this.pbCountry.Location = new System.Drawing.Point(431, 30); this.pbCountry.Name = "pbCountry"; this.pbCountry.Size = new System.Drawing.Size(32, 22); this.pbCountry.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -423,16 +432,16 @@ private void InitializeComponent() { // // tbFeatured // - this.tbFeatured.Location = new System.Drawing.Point(391, 80); + this.tbFeatured.Location = new System.Drawing.Point(377, 80); this.tbFeatured.Name = "tbFeatured"; this.tbFeatured.ReadOnly = true; - this.tbFeatured.Size = new System.Drawing.Size(72, 20); + this.tbFeatured.Size = new System.Drawing.Size(54, 20); this.tbFeatured.TabIndex = 30; // // lFeatured // this.lFeatured.AutoSize = true; - this.lFeatured.Location = new System.Drawing.Point(393, 64); + this.lFeatured.Location = new System.Drawing.Point(379, 64); this.lFeatured.Name = "lFeatured"; this.lFeatured.Size = new System.Drawing.Size(52, 13); this.lFeatured.TabIndex = 29; @@ -440,7 +449,7 @@ private void InitializeComponent() { // // tbCountry // - this.tbCountry.Location = new System.Drawing.Point(391, 32); + this.tbCountry.Location = new System.Drawing.Point(377, 32); this.tbCountry.Name = "tbCountry"; this.tbCountry.ReadOnly = true; this.tbCountry.Size = new System.Drawing.Size(48, 20); @@ -449,7 +458,7 @@ private void InitializeComponent() { // lCountry // this.lCountry.AutoSize = true; - this.lCountry.Location = new System.Drawing.Point(393, 16); + this.lCountry.Location = new System.Drawing.Point(379, 16); this.lCountry.Name = "lCountry"; this.lCountry.Size = new System.Drawing.Size(46, 13); this.lCountry.TabIndex = 27; @@ -485,7 +494,7 @@ private void InitializeComponent() { // // bRawServer // - this.bRawServer.Location = new System.Drawing.Point(506, 64); + this.bRawServer.Location = new System.Drawing.Point(506, 148); this.bRawServer.Margin = new System.Windows.Forms.Padding(2); this.bRawServer.Name = "bRawServer"; this.bRawServer.Size = new System.Drawing.Size(62, 23); @@ -497,7 +506,7 @@ private void InitializeComponent() { // // bOpenHash // - this.bOpenHash.Location = new System.Drawing.Point(506, 125); + this.bOpenHash.Location = new System.Drawing.Point(506, 78); this.bOpenHash.Margin = new System.Windows.Forms.Padding(2); this.bOpenHash.Name = "bOpenHash"; this.bOpenHash.Size = new System.Drawing.Size(62, 23); @@ -648,7 +657,6 @@ private void InitializeComponent() { private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.TextBox tbLast5; private System.Windows.Forms.TextBox tbTotal; private System.Windows.Forms.TextBox tbSoftware; private System.Windows.Forms.TextBox tbUptime; @@ -695,6 +703,8 @@ private void InitializeComponent() { private System.Windows.Forms.CheckBox cbUTC; private System.Windows.Forms.TextBox tbRegistered; private System.Windows.Forms.PictureBox pbCountry; + private System.Windows.Forms.TextBox tbWebSupport; + private System.Windows.Forms.Label lWeb; } } diff --git a/CCapi/Form1.cs b/CCapi/Form1.cs index 4a0170f..f74ef04 100644 --- a/CCapi/Form1.cs +++ b/CCapi/Form1.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net; using System.Windows.Forms; +using System.Text.RegularExpressions; using Jason; using ServiceStack.Text; @@ -22,17 +23,17 @@ private void bLookup_Click(object sender, EventArgs e) { } private void tBSearch_GotFocus(object sender, EventArgs e) { - if (tBSearch.Text == "Player Name/ID") { + if (tBSearch.Text == "Player Name") { tBSearch.Text = ""; } } private void bSkinDownload_Click(object sender, EventArgs e) { - HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://classicube.s3.amazonaws.com/skins/" + tbUserName.Text + ".png"); + HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://cdn.classicube.net/skin/" + tbUserName.Text + ".png"); request.Method = "HEAD"; try { request.GetResponse(); - System.Diagnostics.Process.Start("https://classicube.s3.amazonaws.com/skins/" + tbUserName.Text + ".png"); + System.Diagnostics.Process.Start("https://cdn.classicube.net/skin/" + tbUserName.Text + ".png"); } catch { MessageBox.Show("This player has no custom skin!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -104,7 +105,7 @@ private void cbUTC_CheckedChanged(object sender, EventArgs e) { private Image getAvatar(string name) { try { - Stream stream = new WebClient().OpenRead("https://classicube.s3.amazonaws.com/face/" + name + ".png"); + Stream stream = new WebClient().OpenRead("https://cdn.classicube.net/face/" + name + ".png"); return Image.FromStream(stream); } catch { MessageBox.Show("Failed to retrieve skin. ClassiCube.net might be down!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); @@ -117,7 +118,7 @@ private Image getCountry(string name) { return Image.FromStream(stream); } catch { - MessageBox.Show("Failed to retrieve skin. ClassiCube.net might be down!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show("Failed to retrieve assets. ClassiCube.net might be down!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return null; } } @@ -128,7 +129,7 @@ private void getOverallStats() { result = JsonObject.Parse((new WebClient()).DownloadString("https://www.classicube.net/api/players")); tbTotal.Text = result.Get("playercount"); } catch { - MessageBox.Show("Failed to retrieve last five accounts. ClassiCube.net might be down!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show("Failed to retrieve stats. ClassiCube.net might be down!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } @@ -157,6 +158,7 @@ private void getServers() { tbUptime.Text = ""; tbSoftware.Text = ""; tbFeatured.Text = ""; + tbWebSupport.Text = ""; tbHash.Text = ""; tbCountry.Text = ""; pbCountry.Image = null; @@ -179,7 +181,8 @@ public List GetPublicServers() { (string)pairs["hash"], (string)pairs["name"], (string)pairs["players"], (string)pairs["maxplayers"], (string)pairs["uptime"], (string)pairs["software"], - (string)pairs["country_abbr"], (bool)pairs["featured"])); + (string)pairs["country_abbr"], (bool)pairs["featured"], + (bool)pairs["web"])); } return servers; } @@ -187,24 +190,25 @@ private void getServerInfo() { tbPlayers.Text = servers[cbServer.SelectedIndex].Players; txMaxPlayers.Text = servers[cbServer.SelectedIndex].MaximumPlayers; tbUptime.Text = timeToString(TimeSpan.FromSeconds(double.Parse(servers[cbServer.SelectedIndex].Uptime))); - tbSoftware.Text = servers[cbServer.SelectedIndex].Software; + tbSoftware.Text = Regex.Replace(servers[cbServer.SelectedIndex].Software, @"(?i)[&][0-9A-F]", ""); tbHash.Text = servers[cbServer.SelectedIndex].Hash; tbCountry.Text = servers[cbServer.SelectedIndex].Country; pbCountry.Image = getCountry(servers[cbServer.SelectedIndex].Country); tbFeatured.Text = servers[cbServer.SelectedIndex].Featured.ToString(); + tbWebSupport.Text = servers[cbServer.SelectedIndex].WebSupport.ToString(); return; } private string timeToString(TimeSpan span) { if (span.TotalSeconds < 60) { return String.Format("{0} seconds", span.Seconds); } else if (span.TotalMinutes < 60) { - return String.Format("{0} minutes {1} seconds", span.Minutes, span.Seconds); + return String.Format("{0} minutes, {1} seconds", span.Minutes, span.Seconds); } else if (span.TotalHours < 48) { - return String.Format("{0} hours {1} minutes", (int)Math.Floor(span.TotalHours), span.Minutes); + return String.Format("{0} hours, {1} minutes", (int)Math.Floor(span.TotalHours), span.Minutes); } else if (span.TotalDays < 15) { - return String.Format("{0} days {1} hours", span.Days, span.Hours); + return String.Format("{0} days, {1} hours", span.Days, span.Hours); } else { - return String.Format("{0:0} weeks {1:0} days", Math.Floor(span.TotalDays / 7), Math.Floor(span.TotalDays) % 7); + return String.Format("{0:0} weeks, {1:0} days", Math.Floor(span.TotalDays / 7), Math.Floor(span.TotalDays) % 7); } } @@ -218,7 +222,7 @@ private void bRawPlayer_Click(object sender, EventArgs e) { private void bDownloadSkin_Click(object sender, EventArgs e) { - System.Diagnostics.Process.Start("https://www.classicube.net/skins/" + tbUserName.Text + ".png"); + System.Diagnostics.Process.Start("https://www.classicube.net/skin/" + tbUserName.Text + ".png"); } private void bRawServer_Click(object sender, EventArgs e) { @@ -226,8 +230,18 @@ private void bRawServer_Click(object sender, EventArgs e) { } private void bOpenHash_Click(object sender, EventArgs e) { - System.Diagnostics.Process.Start("https://www.classicube.net/server/play/" + servers[cbServer.SelectedIndex].Hash); + try + { + System.Diagnostics.Process.Start("https://www.classicube.net/server/play/" + servers[cbServer.SelectedIndex].Hash); + } + catch + { + MessageBox.Show("Select a server first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } } + + } public class ccServer { public string Hash { get; set; } @@ -238,8 +252,9 @@ public class ccServer { public string Uptime { get; set; } public string Country { get; set; } public bool Featured { get; set; } + public bool WebSupport { get; set; } - public ccServer(string hash, string name, string players, string maxPlayers, string uptime, string software, string country_abbr, bool featured) { + public ccServer(string hash, string name, string players, string maxPlayers, string uptime, string software, string country_abbr, bool featured, bool web) { Hash = hash; Name = name; Players = players; @@ -248,6 +263,7 @@ public ccServer(string hash, string name, string players, string maxPlayers, str Software = software; Country = country_abbr; Featured = featured; + WebSupport = web; } } #endregion