aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-03 09:44:29 -0400
committerMichael <[email protected]>2017-05-03 09:44:34 -0400
commit53631ad42df86be557746064a1e3161d32e3228d (patch)
treeb753b3eef4232310873b647b218f09c9ce726cbb /ShiftOS.WinForms/Applications
parent3488ac86fb85553e5eaad0d7dff64bc5f0e260a0 (diff)
downloadshiftos_thereturn-53631ad42df86be557746064a1e3161d32e3228d.tar.gz
shiftos_thereturn-53631ad42df86be557746064a1e3161d32e3228d.tar.bz2
shiftos_thereturn-53631ad42df86be557746064a1e3161d32e3228d.zip
Fix highscore list
Diffstat (limited to 'ShiftOS.WinForms/Applications')
-rw-r--r--ShiftOS.WinForms/Applications/Pong.Designer.cs7
-rw-r--r--ShiftOS.WinForms/Applications/Pong.cs53
2 files changed, 39 insertions, 21 deletions
diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs
index f28868a..aef8911 100644
--- a/ShiftOS.WinForms/Applications/Pong.Designer.cs
+++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs
@@ -80,7 +80,7 @@ namespace ShiftOS.WinForms.Applications
this.tmrstoryline = new System.Windows.Forms.Timer(this.components);
this.pgcontents = new ShiftOS.WinForms.Controls.Canvas();
this.pnlhighscore = new System.Windows.Forms.Panel();
- this.lbhighscore = new System.Windows.Forms.ListBox();
+ this.lbhighscore = new System.Windows.Forms.ListView();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.button2 = new System.Windows.Forms.Button();
this.label10 = new System.Windows.Forms.Label();
@@ -193,11 +193,8 @@ namespace ShiftOS.WinForms.Applications
// lbhighscore
//
this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill;
- this.lbhighscore.FormattingEnabled = true;
this.lbhighscore.Location = new System.Drawing.Point(0, 36);
- this.lbhighscore.MultiColumn = true;
this.lbhighscore.Name = "lbhighscore";
- this.lbhighscore.SelectionMode = System.Windows.Forms.SelectionMode.None;
this.lbhighscore.Size = new System.Drawing.Size(539, 246);
this.lbhighscore.TabIndex = 1;
//
@@ -745,7 +742,7 @@ namespace ShiftOS.WinForms.Applications
internal System.Windows.Forms.Label Label8;
internal System.Windows.Forms.Timer tmrstoryline;
private System.Windows.Forms.Panel pnlhighscore;
- private System.Windows.Forms.ListBox lbhighscore;
+ private System.Windows.Forms.ListView lbhighscore;
private System.Windows.Forms.Label label10;
internal Canvas pgcontents;
internal Canvas ball;
diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs
index 6198cad..e0fe793 100644
--- a/ShiftOS.WinForms/Applications/Pong.cs
+++ b/ShiftOS.WinForms/Applications/Pong.cs
@@ -29,6 +29,7 @@ using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
@@ -310,15 +311,9 @@ namespace ShiftOS.WinForms.Applications
SetupStats();
}
+ [Obsolete("This method does nothing. Use UniteClient for highscore queries.")]
public void SendHighscores()
{
- var highscore = new PongHighscore
- {
- UserName = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}",
- HighestLevel = level,
- HighestCodepoints = totalreward
- };
- ServerManager.SendMessage("pong_sethighscore", JsonConvert.SerializeObject(highscore));
}
// ERROR: Handles clauses are not supported in C#
@@ -614,24 +609,50 @@ namespace ShiftOS.WinForms.Applications
public void SetupHighScores()
{
lbhighscore.Items.Clear();
- ServerManager.MessageReceived += (msg) =>
+ lbhighscore.View = View.Details;
+ lbhighscore.FullRowSelect = true;
+ lbhighscore.Columns.Clear();
+ var n = new ColumnHeader();
+ n.Text = "Player";
+ n.Width = lbhighscore.Width / 3;
+ var l = new ColumnHeader();
+ l.Text = "Level";
+ l.Width = n.Width;
+ var c = new ColumnHeader();
+ c.Text = "Codepoints";
+ c.Width = n.Width;
+ lbhighscore.Columns.Add(n);
+ lbhighscore.Columns.Add(l);
+ lbhighscore.Columns.Add(c);
+
+ var t = new Thread(() =>
{
- if(msg.Name == "pong_highscores")
+ try
{
- var hs = JsonConvert.DeserializeObject<List<PongHighscore>>(msg.Contents);
-
- var orderedhs = hs.OrderByDescending(i => i.HighestLevel);
- foreach(var score in orderedhs)
+ var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken);
+ var hs = unite.GetPongHighscores();
+ foreach (var score in hs.Highscores)
{
+ string username = unite.GetDisplayNameId(score.UserId);
this.Invoke(new Action(() =>
{
- lbhighscore.Items.Add($"{score.UserName}\t\t\t{score.HighestLevel}\t\t{score.HighestCodepoints} CP");
+ var name_item = new ListViewItem();
+ name_item.Text = username;
+ lbhighscore.Items.Add(name_item);
+ name_item.SubItems.Add(score.Level.ToString());
+ name_item.SubItems.Add(score.CodepointsCashout.ToString());
}));
}
}
- };
- ServerManager.SendMessage("pong_gethighscores", null);
+ catch
+ {
+ Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time.");
+ this.Invoke(new Action(pnlgamestats.BringToFront));
+ return;
+ }
+ });
+ t.Start();
pnlhighscore.Show();
}