add WIP server browser
This commit is contained in:
parent
60a4dfedd8
commit
6ffbf1c26c
|
|
@ -1,4 +1,5 @@
|
||||||
#region Usings
|
#region Usings
|
||||||
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -34,5 +35,27 @@ public class VarStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Game Server Definition
|
||||||
|
public class GameServer
|
||||||
|
{
|
||||||
|
public GameServer(string name, string ip, string port, string client, string players, string maxPlayers)
|
||||||
|
{
|
||||||
|
ServerName = name;
|
||||||
|
ServerIP = ip;
|
||||||
|
ServerPort = Convert.ToInt32(port);
|
||||||
|
ServerClient = client;
|
||||||
|
ServerPlayers = Convert.ToInt32(players);
|
||||||
|
ServerMaxPlayers = Convert.ToInt32(maxPlayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ServerName { get; set; }
|
||||||
|
public string ServerIP { get; set; }
|
||||||
|
public int ServerPort { get; set; }
|
||||||
|
public string ServerClient { get; set; }
|
||||||
|
public int ServerPlayers { get; set; }
|
||||||
|
public int ServerMaxPlayers { get; set; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -1331,7 +1331,8 @@ namespace NovetusLauncher
|
||||||
|
|
||||||
private void button36_Click(object sender, EventArgs e)
|
private void button36_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
MessageBox.Show("no functionality");
|
ServerBrowser browser = new ServerBrowser();
|
||||||
|
browser.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBox9_CheckedChanged(object sender, EventArgs e)
|
private void checkBox9_CheckedChanged(object sender, EventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -1502,7 +1502,8 @@ namespace NovetusLauncher
|
||||||
|
|
||||||
private void button37_Click(object sender, EventArgs e)
|
private void button37_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
MessageBox.Show("no functionality");
|
ServerBrowser browser = new ServerBrowser();
|
||||||
|
browser.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBox9_CheckedChanged(object sender, EventArgs e)
|
private void checkBox9_CheckedChanged(object sender, EventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
|
||||||
|
namespace NovetusLauncher
|
||||||
|
{
|
||||||
|
partial class ServerBrowser
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServerBrowser));
|
||||||
|
this.JoinGameButton = new System.Windows.Forms.Button();
|
||||||
|
this.MasterServerBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.MasterServerLabel = new System.Windows.Forms.Label();
|
||||||
|
this.MasterServerRefreshButton = new System.Windows.Forms.Button();
|
||||||
|
this.ServerListView = new System.Windows.Forms.ListView();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// JoinGameButton
|
||||||
|
//
|
||||||
|
this.JoinGameButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.JoinGameButton.Location = new System.Drawing.Point(713, 8);
|
||||||
|
this.JoinGameButton.Name = "JoinGameButton";
|
||||||
|
this.JoinGameButton.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.JoinGameButton.TabIndex = 0;
|
||||||
|
this.JoinGameButton.Text = "JOIN GAME";
|
||||||
|
this.JoinGameButton.UseVisualStyleBackColor = true;
|
||||||
|
this.JoinGameButton.Click += new System.EventHandler(this.JoinGameButton_Click);
|
||||||
|
//
|
||||||
|
// MasterServerBox
|
||||||
|
//
|
||||||
|
this.MasterServerBox.Location = new System.Drawing.Point(108, 10);
|
||||||
|
this.MasterServerBox.Name = "MasterServerBox";
|
||||||
|
this.MasterServerBox.Size = new System.Drawing.Size(131, 20);
|
||||||
|
this.MasterServerBox.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// MasterServerLabel
|
||||||
|
//
|
||||||
|
this.MasterServerLabel.AutoSize = true;
|
||||||
|
this.MasterServerLabel.Location = new System.Drawing.Point(12, 13);
|
||||||
|
this.MasterServerLabel.Name = "MasterServerLabel";
|
||||||
|
this.MasterServerLabel.Size = new System.Drawing.Size(89, 13);
|
||||||
|
this.MasterServerLabel.TabIndex = 2;
|
||||||
|
this.MasterServerLabel.Text = "Master Server IP:";
|
||||||
|
//
|
||||||
|
// MasterServerRefreshButton
|
||||||
|
//
|
||||||
|
this.MasterServerRefreshButton.AutoEllipsis = true;
|
||||||
|
this.MasterServerRefreshButton.Location = new System.Drawing.Point(245, 8);
|
||||||
|
this.MasterServerRefreshButton.Name = "MasterServerRefreshButton";
|
||||||
|
this.MasterServerRefreshButton.Size = new System.Drawing.Size(125, 23);
|
||||||
|
this.MasterServerRefreshButton.TabIndex = 3;
|
||||||
|
this.MasterServerRefreshButton.Text = "REFRESH SERVERS";
|
||||||
|
this.MasterServerRefreshButton.UseVisualStyleBackColor = true;
|
||||||
|
this.MasterServerRefreshButton.Click += new System.EventHandler(this.MasterServerRefreshButton_Click);
|
||||||
|
//
|
||||||
|
// ServerListView
|
||||||
|
//
|
||||||
|
this.ServerListView.HideSelection = false;
|
||||||
|
this.ServerListView.Location = new System.Drawing.Point(15, 36);
|
||||||
|
this.ServerListView.Name = "ServerListView";
|
||||||
|
this.ServerListView.Size = new System.Drawing.Size(773, 408);
|
||||||
|
this.ServerListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||||
|
this.ServerListView.TabIndex = 4;
|
||||||
|
this.ServerListView.UseCompatibleStateImageBehavior = false;
|
||||||
|
this.ServerListView.View = System.Windows.Forms.View.Details;
|
||||||
|
this.ServerListView.SelectedIndexChanged += new System.EventHandler(this.ServerListView_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// ServerBrowser
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 456);
|
||||||
|
this.Controls.Add(this.ServerListView);
|
||||||
|
this.Controls.Add(this.MasterServerRefreshButton);
|
||||||
|
this.Controls.Add(this.MasterServerLabel);
|
||||||
|
this.Controls.Add(this.MasterServerBox);
|
||||||
|
this.Controls.Add(this.JoinGameButton);
|
||||||
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.Name = "ServerBrowser";
|
||||||
|
this.Text = "Server Browser";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button JoinGameButton;
|
||||||
|
private System.Windows.Forms.TextBox MasterServerBox;
|
||||||
|
private System.Windows.Forms.Label MasterServerLabel;
|
||||||
|
private System.Windows.Forms.Button MasterServerRefreshButton;
|
||||||
|
private System.Windows.Forms.ListView ServerListView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.ListViewItem;
|
||||||
|
|
||||||
|
namespace NovetusLauncher
|
||||||
|
{
|
||||||
|
public partial class ServerBrowser : Form
|
||||||
|
{
|
||||||
|
List<VarStorage.GameServer> serverList = new List<VarStorage.GameServer>();
|
||||||
|
private int selectedServer;
|
||||||
|
|
||||||
|
public ServerBrowser()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MasterServerRefreshButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(MasterServerBox.Text))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
serverList.Clear();
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/2471209/how-to-read-a-file-from-internet#2471245
|
||||||
|
//https://stackoverflow.com/questions/10826260/is-there-a-way-to-read-from-a-website-one-line-at-a-time
|
||||||
|
WebClient client = new WebClient();
|
||||||
|
using (Stream stream = client.OpenRead("http://" + MasterServerBox.Text + "/serverlist.txt"))
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(stream))
|
||||||
|
{
|
||||||
|
string line;
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
string[] serverInfo = line.Split('|');
|
||||||
|
VarStorage.GameServer gameServer = new VarStorage.GameServer(serverInfo[0], serverInfo[1], serverInfo[2], serverInfo[3], serverInfo[4], serverInfo[5]);
|
||||||
|
serverList.Add(gameServer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerListView.BeginUpdate();
|
||||||
|
ServerListView.Clear();
|
||||||
|
|
||||||
|
var ColumnName = new ColumnHeader();
|
||||||
|
ColumnName.Text = "Name";
|
||||||
|
ColumnName.TextAlign = HorizontalAlignment.Center;
|
||||||
|
ColumnName.Width = 284;
|
||||||
|
ServerListView.Columns.Add(ColumnName);
|
||||||
|
|
||||||
|
var ColumnClient = new ColumnHeader();
|
||||||
|
ColumnClient.Text = "Client";
|
||||||
|
ColumnClient.TextAlign = HorizontalAlignment.Center;
|
||||||
|
ColumnClient.Width = 75;
|
||||||
|
ServerListView.Columns.Add(ColumnClient);
|
||||||
|
|
||||||
|
var ColumnPlayers = new ColumnHeader();
|
||||||
|
ColumnPlayers.Text = "Player Count";
|
||||||
|
ColumnPlayers.TextAlign = HorizontalAlignment.Center;
|
||||||
|
ColumnPlayers.Width = 81;
|
||||||
|
ServerListView.Columns.Add(ColumnPlayers);
|
||||||
|
|
||||||
|
foreach (var server in serverList)
|
||||||
|
{
|
||||||
|
var serverItem = new ListViewItem(server.ServerName);
|
||||||
|
|
||||||
|
var serverClient = new ListViewSubItem(serverItem, server.ServerClient);
|
||||||
|
serverItem.SubItems.Add(serverClient);
|
||||||
|
|
||||||
|
var serverPlayers = new ListViewSubItem(serverItem, server.ServerPlayers.ToString() + "/" + server.ServerMaxPlayers.ToString());
|
||||||
|
serverItem.SubItems.Add(serverPlayers);
|
||||||
|
|
||||||
|
ServerListView.Items.Add(serverItem);
|
||||||
|
}
|
||||||
|
ServerListView.EndUpdate();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void JoinGameButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (serverList[selectedServer] != null)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ServerListView.Items[selectedServer].Text + " = " + serverList[selectedServer].ServerName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("broke");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ServerListView_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ServerListView.SelectedIndices.Count <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int intselectedindex = ServerListView.SelectedIndices[0];
|
||||||
|
if (intselectedindex >= 0)
|
||||||
|
{
|
||||||
|
selectedServer = ServerListView.Items[intselectedindex].Index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -205,6 +205,12 @@
|
||||||
<Compile Include="Forms\SDK\SplashTester.Designer.cs">
|
<Compile Include="Forms\SDK\SplashTester.Designer.cs">
|
||||||
<DependentUpon>SplashTester.cs</DependentUpon>
|
<DependentUpon>SplashTester.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Forms\ServerBrowser.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Forms\ServerBrowser.Designer.cs">
|
||||||
|
<DependentUpon>ServerBrowser.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
|
@ -258,6 +264,9 @@
|
||||||
<EmbeddedResource Include="Forms\SDK\SplashTester.resx">
|
<EmbeddedResource Include="Forms\SDK\SplashTester.resx">
|
||||||
<DependentUpon>SplashTester.cs</DependentUpon>
|
<DependentUpon>SplashTester.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Forms\ServerBrowser.resx">
|
||||||
|
<DependentUpon>ServerBrowser.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
|
|
||||||
|
|
@ -81,9 +81,12 @@ namespace NovetusURI
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
this.Controls.Add(this.progressBar1);
|
this.Controls.Add(this.progressBar1);
|
||||||
this.Controls.Add(this.pictureBox1);
|
this.Controls.Add(this.pictureBox1);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
this.Name = "LoaderForm";
|
this.Name = "LoaderForm";
|
||||||
|
this.Text = "Loading...";
|
||||||
this.Load += new System.EventHandler(this.LoaderFormLoad);
|
this.Load += new System.EventHandler(this.LoaderFormLoad);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,12 @@ $ip = $argv[2];
|
||||||
$port = $argv[3];
|
$port = $argv[3];
|
||||||
//client name
|
//client name
|
||||||
$client = $argv[4];
|
$client = $argv[4];
|
||||||
|
//players
|
||||||
|
$players = $argv[5];
|
||||||
|
//maxplayers
|
||||||
|
$maxplayers = $argv[6];
|
||||||
//online status
|
//online status
|
||||||
$online = $argv[5];
|
$online = $argv[7];
|
||||||
|
|
||||||
//strings
|
//strings
|
||||||
$deleteentry = 1;
|
$deleteentry = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue