mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
More work on BlockDefinitions. Remove minecraft.net functonality from launcher because classic was removed from minecraft.net.
This commit is contained in:
parent
25406a0bb2
commit
5593bda240
@ -11,24 +11,21 @@ namespace ClassicalSharp {
|
||||
for( int neighbourI = 1; neighbourI < BlocksCount; neighbourI++ ) {
|
||||
byte tile = (byte)tileI, neighbour = (byte)neighbourI;
|
||||
bool hidden = IsHidden( tile, neighbour );
|
||||
if( hidden ) {
|
||||
SetHidden( tile, neighbour, TileSide.Left, true );
|
||||
SetHidden( tile, neighbour, TileSide.Right, true );
|
||||
SetHidden( tile, neighbour, TileSide.Front, true );
|
||||
SetHidden( tile, neighbour, TileSide.Back, true );
|
||||
SetHidden( tile, neighbour, TileSide.Top, Height[tile] == 1 );
|
||||
SetHidden( tile, neighbour, TileSide.Bottom, Height[neighbour] == 1 );
|
||||
}
|
||||
if( tile == neighbour && !CullWithNeighbours[tile] )
|
||||
hidden = false;
|
||||
|
||||
SetHidden( tile, neighbour, TileSide.Left, hidden );
|
||||
SetHidden( tile, neighbour, TileSide.Right, hidden );
|
||||
SetHidden( tile, neighbour, TileSide.Front, hidden );
|
||||
SetHidden( tile, neighbour, TileSide.Back, hidden );
|
||||
SetHidden( tile, neighbour, TileSide.Top, hidden && Height[tile] == 1 );
|
||||
SetHidden( tile, neighbour, TileSide.Bottom, hidden && Height[neighbour] == 1 );
|
||||
}
|
||||
}
|
||||
// Leaves should show faces with their neighbours (matches Classic)
|
||||
for( int i = 0; i < TileSide.Sides; i++ ) {
|
||||
SetHidden( (byte)Block.Leaves, (byte)Block.Leaves, i, false );
|
||||
}
|
||||
}
|
||||
|
||||
bool IsHidden( byte tile, byte block ) {
|
||||
return
|
||||
return
|
||||
((tile == block || (IsOpaque[block] && !IsLiquid[block])) && !IsSprite[tile]) ||
|
||||
(IsLiquid[tile] && block == (byte)Block.Ice);
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ namespace ClassicalSharp {
|
||||
|
||||
public float[] SpeedMultiplier = new float[BlocksCount];
|
||||
|
||||
public bool[] CullWithNeighbours = new bool[BlocksCount];
|
||||
|
||||
public const byte MaxDefinedCpeBlock = (byte)Block.StoneBrick;
|
||||
public const int CpeBlocksCount = MaxDefinedCpeBlock + 1;
|
||||
public const byte MaxDefinedBlock = byte.MaxValue;
|
||||
@ -52,6 +54,7 @@ namespace ClassicalSharp {
|
||||
IsOpaque[tile] = true;
|
||||
CollideType[tile] = BlockCollideType.Solid;
|
||||
SpeedMultiplier[tile] = 1;
|
||||
CullWithNeighbours[tile] = true;
|
||||
}
|
||||
for( int i = 0; i < CpeBlocksCount; i++ ) {
|
||||
Name[i] = Enum.GetName( typeof( Block ), (byte)i );
|
||||
@ -70,6 +73,7 @@ namespace ClassicalSharp {
|
||||
FogColour[(byte)Block.Lava] = new FastColour( 153, 25, 0 );
|
||||
CollideType[(byte)Block.Snow] = BlockCollideType.WalkThrough;
|
||||
SpeedMultiplier[0] = 1f;
|
||||
CullWithNeighbours[(byte)Block.Leaves] = false;
|
||||
SetupTextures();
|
||||
|
||||
SetBlockHeight( Block.Slab, 8/16f );
|
||||
@ -155,6 +159,8 @@ namespace ClassicalSharp {
|
||||
Height[id] = 1;
|
||||
BlocksLight[id] = true;
|
||||
EmitsLight[id] = false;
|
||||
CullWithNeighbours[id] = true;
|
||||
|
||||
Name[id] = "Invalid";
|
||||
FogColour[id] = default( FastColour );
|
||||
FogDensity[id] = 0;
|
||||
|
@ -289,7 +289,11 @@ namespace ClassicalSharp {
|
||||
|
||||
info.Name[block] = reader.ReadAsciiString();
|
||||
info.CollideType[block] = (BlockCollideType)reader.ReadUInt8();
|
||||
// TODO: Liquid collide type not properly supported.
|
||||
if( info.CollideType[block] != BlockCollideType.Solid ) {
|
||||
info.IsTransparent[block] = true;
|
||||
info.IsOpaque[block] = false;
|
||||
}
|
||||
|
||||
info.SpeedMultiplier[block] = (float)Math.Pow( 2, (reader.ReadUInt8() - 128) / 64f );
|
||||
info.SetTop( reader.ReadUInt8(), (Block)block );
|
||||
info.SetSide( reader.ReadUInt8(), (Block)block );
|
||||
@ -298,21 +302,30 @@ namespace ClassicalSharp {
|
||||
reader.ReadUInt8(); // walk sound, but we ignore this.
|
||||
info.EmitsLight[block] = reader.ReadUInt8() != 0;
|
||||
|
||||
|
||||
byte shape = reader.ReadUInt8();
|
||||
if( shape == 1 ) info.Height[block] = 1;
|
||||
else if( shape == 2 ) info.Height[block] = 0.5f;
|
||||
// TODO: upside down slab not properly supported
|
||||
else if( shape == 3 ) info.Height[block] = 0.5f;
|
||||
else if( shape == 4 ) info.IsSprite[block] = true;
|
||||
if( shape == 2 ) {
|
||||
info.Height[block] = 0.5f;
|
||||
} else if( shape == 3 ) { // TODO: upside down slab not properly supported
|
||||
info.Height[block] = 0.5f;
|
||||
} else if( shape == 4 ) {
|
||||
info.IsSprite[block] = true;
|
||||
}
|
||||
if( info.IsOpaque[block] )
|
||||
info.IsOpaque[block] = shape == 0;
|
||||
if( shape != 1 )
|
||||
info.IsTransparent[block] = true;
|
||||
|
||||
byte blockDraw = reader.ReadUInt8();
|
||||
if( blockDraw == 0 ) info.IsOpaque[block] = true;
|
||||
else if( blockDraw == 1 ) info.IsTransparent[block] = true;
|
||||
else if( blockDraw == 2 ) info.IsTransparent[block] = true; // TODO: hide neighbours
|
||||
else if( blockDraw == 3 ) info.IsTranslucent[block] = true;
|
||||
|
||||
Console.WriteLine( block + " : " + shape + "," + blockDraw );
|
||||
if( blockDraw == 1 ) {
|
||||
info.IsTransparent[block] = true;
|
||||
} else if( blockDraw == 2 ) {
|
||||
info.IsTransparent[block] = true;
|
||||
info.CullWithNeighbours[block] = false;
|
||||
} else if( blockDraw == 3 ) {
|
||||
info.IsTranslucent[block] = true;
|
||||
}
|
||||
if( info.IsOpaque[block] )
|
||||
info.IsOpaque[block] = blockDraw == 0;
|
||||
|
||||
byte fogDensity = reader.ReadUInt8();
|
||||
info.FogDensity[block] = fogDensity == 0 ? 0 : (fogDensity + 1) / 128f;
|
||||
|
@ -84,7 +84,6 @@
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.GameState.cs" />
|
||||
<Compile Include="MinecraftSession.cs" />
|
||||
<Compile Include="Patcher\Animations.cs" />
|
||||
<Compile Include="Patcher\ResourceFetcher.cs" />
|
||||
<Compile Include="Patcher\ZipWriter.cs" />
|
||||
|
310
Launcher/MainForm.Designer.cs
generated
310
Launcher/MainForm.Designer.cs
generated
@ -53,29 +53,6 @@ namespace Launcher
|
||||
this.txtCCSearch = new System.Windows.Forms.TextBox();
|
||||
this.lblCCSearch = new System.Windows.Forms.Label();
|
||||
this.tabMinecraftNet = new System.Windows.Forms.TabPage();
|
||||
this.tabMC = new System.Windows.Forms.TabControl();
|
||||
this.tabMCSignIn = new System.Windows.Forms.TabPage();
|
||||
this.prgMCStatus = new System.Windows.Forms.ProgressBar();
|
||||
this.lblMCStatusLabel = new System.Windows.Forms.Label();
|
||||
this.lblMCStatus = new System.Windows.Forms.Label();
|
||||
this.lbMCUser = new System.Windows.Forms.Label();
|
||||
this.btnMCSignIn = new System.Windows.Forms.Button();
|
||||
this.txtMCUser = new System.Windows.Forms.TextBox();
|
||||
this.txtMCPassword = new System.Windows.Forms.TextBox();
|
||||
this.lblMCPass = new System.Windows.Forms.Label();
|
||||
this.tabMCServers = new System.Windows.Forms.TabPage();
|
||||
this.cbMCHideInvalid = new System.Windows.Forms.CheckBox();
|
||||
this.txtMCHash = new System.Windows.Forms.TextBox();
|
||||
this.lblMCHash = new System.Windows.Forms.Label();
|
||||
this.btnMCConnect = new System.Windows.Forms.Button();
|
||||
this.tblMCServers = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
|
||||
this.cbMCHideEmpty = new System.Windows.Forms.CheckBox();
|
||||
this.txtMCSearch = new System.Windows.Forms.TextBox();
|
||||
this.lblMCSearch = new System.Windows.Forms.Label();
|
||||
this.tabDC = new System.Windows.Forms.TabPage();
|
||||
this.lblDChint = new System.Windows.Forms.Label();
|
||||
this.txtDCmppass = new System.Windows.Forms.TextBox();
|
||||
@ -89,14 +66,13 @@ namespace Launcher
|
||||
this.lblDCaddress = new System.Windows.Forms.Label();
|
||||
this.lblDCuser = new System.Windows.Forms.Label();
|
||||
this.tabs = new System.Windows.Forms.TabControl();
|
||||
this.lblMCdead = new System.Windows.Forms.Label();
|
||||
this.lblMCdead2 = new System.Windows.Forms.Label();
|
||||
this.tabClassicubeNet.SuspendLayout();
|
||||
this.tabCC.SuspendLayout();
|
||||
this.tabCCSignIn.SuspendLayout();
|
||||
this.tabCCServers.SuspendLayout();
|
||||
this.tabMinecraftNet.SuspendLayout();
|
||||
this.tabMC.SuspendLayout();
|
||||
this.tabMCSignIn.SuspendLayout();
|
||||
this.tabMCServers.SuspendLayout();
|
||||
this.tabDC.SuspendLayout();
|
||||
this.tabs.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -332,7 +308,8 @@ namespace Launcher
|
||||
//
|
||||
// tabMinecraftNet
|
||||
//
|
||||
this.tabMinecraftNet.Controls.Add(this.tabMC);
|
||||
this.tabMinecraftNet.Controls.Add(this.lblMCdead2);
|
||||
this.tabMinecraftNet.Controls.Add(this.lblMCdead);
|
||||
this.tabMinecraftNet.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabMinecraftNet.Name = "tabMinecraftNet";
|
||||
this.tabMinecraftNet.Padding = new System.Windows.Forms.Padding(3);
|
||||
@ -341,237 +318,6 @@ namespace Launcher
|
||||
this.tabMinecraftNet.Text = "minecraft.net";
|
||||
this.tabMinecraftNet.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabMC
|
||||
//
|
||||
this.tabMC.Controls.Add(this.tabMCSignIn);
|
||||
this.tabMC.Controls.Add(this.tabMCServers);
|
||||
this.tabMC.Location = new System.Drawing.Point(0, 0);
|
||||
this.tabMC.Name = "tabMC";
|
||||
this.tabMC.SelectedIndex = 0;
|
||||
this.tabMC.Size = new System.Drawing.Size(482, 444);
|
||||
this.tabMC.TabIndex = 2;
|
||||
//
|
||||
// tabMCSignIn
|
||||
//
|
||||
this.tabMCSignIn.Controls.Add(this.prgMCStatus);
|
||||
this.tabMCSignIn.Controls.Add(this.lblMCStatusLabel);
|
||||
this.tabMCSignIn.Controls.Add(this.lblMCStatus);
|
||||
this.tabMCSignIn.Controls.Add(this.lbMCUser);
|
||||
this.tabMCSignIn.Controls.Add(this.btnMCSignIn);
|
||||
this.tabMCSignIn.Controls.Add(this.txtMCUser);
|
||||
this.tabMCSignIn.Controls.Add(this.txtMCPassword);
|
||||
this.tabMCSignIn.Controls.Add(this.lblMCPass);
|
||||
this.tabMCSignIn.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabMCSignIn.Name = "tabMCSignIn";
|
||||
this.tabMCSignIn.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabMCSignIn.Size = new System.Drawing.Size(474, 418);
|
||||
this.tabMCSignIn.TabIndex = 0;
|
||||
this.tabMCSignIn.Text = "Sign in";
|
||||
this.tabMCSignIn.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// prgMCStatus
|
||||
//
|
||||
this.prgMCStatus.ForeColor = System.Drawing.SystemColors.Desktop;
|
||||
this.prgMCStatus.Location = new System.Drawing.Point(10, 200);
|
||||
this.prgMCStatus.Name = "prgMCStatus";
|
||||
this.prgMCStatus.Size = new System.Drawing.Size(200, 20);
|
||||
this.prgMCStatus.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
|
||||
this.prgMCStatus.TabIndex = 8;
|
||||
//
|
||||
// lblMCStatusLabel
|
||||
//
|
||||
this.lblMCStatusLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblMCStatusLabel.Location = new System.Drawing.Point(10, 180);
|
||||
this.lblMCStatusLabel.Name = "lblMCStatusLabel";
|
||||
this.lblMCStatusLabel.Size = new System.Drawing.Size(77, 20);
|
||||
this.lblMCStatusLabel.TabIndex = 7;
|
||||
this.lblMCStatusLabel.Text = "Status:";
|
||||
//
|
||||
// lblMCStatus
|
||||
//
|
||||
this.lblMCStatus.AutoSize = true;
|
||||
this.lblMCStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblMCStatus.Location = new System.Drawing.Point(10, 230);
|
||||
this.lblMCStatus.Name = "lblMCStatus";
|
||||
this.lblMCStatus.Size = new System.Drawing.Size(0, 17);
|
||||
this.lblMCStatus.TabIndex = 6;
|
||||
//
|
||||
// lbMCUser
|
||||
//
|
||||
this.lbMCUser.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lbMCUser.Location = new System.Drawing.Point(10, 10);
|
||||
this.lbMCUser.Name = "lbMCUser";
|
||||
this.lbMCUser.Size = new System.Drawing.Size(81, 20);
|
||||
this.lbMCUser.TabIndex = 0;
|
||||
this.lbMCUser.Text = "Username";
|
||||
//
|
||||
// btnMCSignIn
|
||||
//
|
||||
this.btnMCSignIn.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnMCSignIn.Location = new System.Drawing.Point(10, 120);
|
||||
this.btnMCSignIn.Name = "btnMCSignIn";
|
||||
this.btnMCSignIn.Size = new System.Drawing.Size(100, 30);
|
||||
this.btnMCSignIn.TabIndex = 4;
|
||||
this.btnMCSignIn.Text = "Sign in";
|
||||
this.btnMCSignIn.UseVisualStyleBackColor = true;
|
||||
this.btnMCSignIn.Click += new System.EventHandler(this.btnMCSignInClick);
|
||||
//
|
||||
// txtMCUser
|
||||
//
|
||||
this.txtMCUser.Location = new System.Drawing.Point(10, 30);
|
||||
this.txtMCUser.MaxLength = 64;
|
||||
this.txtMCUser.Name = "txtMCUser";
|
||||
this.txtMCUser.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtMCUser.TabIndex = 1;
|
||||
//
|
||||
// txtMCPassword
|
||||
//
|
||||
this.txtMCPassword.Location = new System.Drawing.Point(10, 80);
|
||||
this.txtMCPassword.MaxLength = 64;
|
||||
this.txtMCPassword.Name = "txtMCPassword";
|
||||
this.txtMCPassword.PasswordChar = '*';
|
||||
this.txtMCPassword.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtMCPassword.TabIndex = 3;
|
||||
//
|
||||
// lblMCPass
|
||||
//
|
||||
this.lblMCPass.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblMCPass.Location = new System.Drawing.Point(10, 60);
|
||||
this.lblMCPass.Name = "lblMCPass";
|
||||
this.lblMCPass.Size = new System.Drawing.Size(77, 20);
|
||||
this.lblMCPass.TabIndex = 2;
|
||||
this.lblMCPass.Text = "Password";
|
||||
//
|
||||
// tabMCServers
|
||||
//
|
||||
this.tabMCServers.Controls.Add(this.cbMCHideInvalid);
|
||||
this.tabMCServers.Controls.Add(this.txtMCHash);
|
||||
this.tabMCServers.Controls.Add(this.lblMCHash);
|
||||
this.tabMCServers.Controls.Add(this.btnMCConnect);
|
||||
this.tabMCServers.Controls.Add(this.tblMCServers);
|
||||
this.tabMCServers.Controls.Add(this.cbMCHideEmpty);
|
||||
this.tabMCServers.Controls.Add(this.txtMCSearch);
|
||||
this.tabMCServers.Controls.Add(this.lblMCSearch);
|
||||
this.tabMCServers.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabMCServers.Name = "tabMCServers";
|
||||
this.tabMCServers.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabMCServers.Size = new System.Drawing.Size(474, 418);
|
||||
this.tabMCServers.TabIndex = 1;
|
||||
this.tabMCServers.Text = "minecraft.net server";
|
||||
this.tabMCServers.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbMCHideInvalid
|
||||
//
|
||||
this.cbMCHideInvalid.AutoSize = true;
|
||||
this.cbMCHideInvalid.Location = new System.Drawing.Point(230, 21);
|
||||
this.cbMCHideInvalid.Name = "cbMCHideInvalid";
|
||||
this.cbMCHideInvalid.Size = new System.Drawing.Size(118, 17);
|
||||
this.cbMCHideInvalid.TabIndex = 10;
|
||||
this.cbMCHideInvalid.Text = "Hide invalid servers";
|
||||
this.cbMCHideInvalid.UseVisualStyleBackColor = true;
|
||||
this.cbMCHideInvalid.CheckedChanged += new System.EventHandler(this.cbMCHideInvalidCheckedChanged);
|
||||
//
|
||||
// txtMCHash
|
||||
//
|
||||
this.txtMCHash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.txtMCHash.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.txtMCHash.Location = new System.Drawing.Point(137, 389);
|
||||
this.txtMCHash.Name = "txtMCHash";
|
||||
this.txtMCHash.Size = new System.Drawing.Size(190, 20);
|
||||
this.txtMCHash.TabIndex = 9;
|
||||
this.txtMCHash.TextChanged += new System.EventHandler(this.txtMCHashTextChanged);
|
||||
//
|
||||
// lblMCHash
|
||||
//
|
||||
this.lblMCHash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.lblMCHash.AutoSize = true;
|
||||
this.lblMCHash.Location = new System.Drawing.Point(3, 392);
|
||||
this.lblMCHash.Name = "lblMCHash";
|
||||
this.lblMCHash.Size = new System.Drawing.Size(134, 13);
|
||||
this.lblMCHash.TabIndex = 8;
|
||||
this.lblMCHash.Text = "minecraft.net/classic/play/";
|
||||
//
|
||||
// btnMCConnect
|
||||
//
|
||||
this.btnMCConnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnMCConnect.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnMCConnect.Location = new System.Drawing.Point(367, 382);
|
||||
this.btnMCConnect.Name = "btnMCConnect";
|
||||
this.btnMCConnect.Size = new System.Drawing.Size(100, 30);
|
||||
this.btnMCConnect.TabIndex = 7;
|
||||
this.btnMCConnect.Text = "Connect";
|
||||
this.btnMCConnect.UseVisualStyleBackColor = true;
|
||||
this.btnMCConnect.Click += new System.EventHandler(this.btnMCConnectClick);
|
||||
//
|
||||
// tblMCServers
|
||||
//
|
||||
this.tblMCServers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1,
|
||||
this.columnHeader2,
|
||||
this.columnHeader3,
|
||||
this.columnHeader4});
|
||||
this.tblMCServers.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.tblMCServers.FullRowSelect = true;
|
||||
this.tblMCServers.GridLines = true;
|
||||
this.tblMCServers.HideSelection = false;
|
||||
this.tblMCServers.Location = new System.Drawing.Point(0, 40);
|
||||
this.tblMCServers.Name = "tblMCServers";
|
||||
this.tblMCServers.Size = new System.Drawing.Size(474, 335);
|
||||
this.tblMCServers.TabIndex = 6;
|
||||
this.tblMCServers.UseCompatibleStateImageBehavior = false;
|
||||
this.tblMCServers.View = System.Windows.Forms.View.Details;
|
||||
this.tblMCServers.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.tblMCServersColumnClick);
|
||||
this.tblMCServers.Click += new System.EventHandler(this.tblMCServersClick);
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "Name";
|
||||
this.columnHeader1.Width = 100;
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Players";
|
||||
this.columnHeader2.Width = 90;
|
||||
//
|
||||
// columnHeader3
|
||||
//
|
||||
this.columnHeader3.Text = "Max players";
|
||||
this.columnHeader3.Width = 90;
|
||||
//
|
||||
// columnHeader4
|
||||
//
|
||||
this.columnHeader4.Text = "Uptime";
|
||||
this.columnHeader4.Width = 100;
|
||||
//
|
||||
// cbMCHideEmpty
|
||||
//
|
||||
this.cbMCHideEmpty.AutoSize = true;
|
||||
this.cbMCHideEmpty.Location = new System.Drawing.Point(230, 3);
|
||||
this.cbMCHideEmpty.Name = "cbMCHideEmpty";
|
||||
this.cbMCHideEmpty.Size = new System.Drawing.Size(116, 17);
|
||||
this.cbMCHideEmpty.TabIndex = 3;
|
||||
this.cbMCHideEmpty.Text = "Hide empty servers";
|
||||
this.cbMCHideEmpty.UseVisualStyleBackColor = true;
|
||||
this.cbMCHideEmpty.CheckedChanged += new System.EventHandler(this.cbMCHideEmptyCheckedChanged);
|
||||
//
|
||||
// txtMCSearch
|
||||
//
|
||||
this.txtMCSearch.Location = new System.Drawing.Point(80, 10);
|
||||
this.txtMCSearch.Name = "txtMCSearch";
|
||||
this.txtMCSearch.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtMCSearch.TabIndex = 2;
|
||||
this.txtMCSearch.TextChanged += new System.EventHandler(this.txtMCSearchTextChanged);
|
||||
//
|
||||
// lblMCSearch
|
||||
//
|
||||
this.lblMCSearch.AutoSize = true;
|
||||
this.lblMCSearch.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblMCSearch.Location = new System.Drawing.Point(10, 10);
|
||||
this.lblMCSearch.Name = "lblMCSearch";
|
||||
this.lblMCSearch.Size = new System.Drawing.Size(64, 20);
|
||||
this.lblMCSearch.TabIndex = 1;
|
||||
this.lblMCSearch.Text = "Search:";
|
||||
//
|
||||
// tabDC
|
||||
//
|
||||
this.tabDC.Controls.Add(this.lblDChint);
|
||||
@ -704,6 +450,24 @@ namespace Launcher
|
||||
this.tabs.Size = new System.Drawing.Size(482, 466);
|
||||
this.tabs.TabIndex = 0;
|
||||
//
|
||||
// lblMCdead
|
||||
//
|
||||
this.lblMCdead.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblMCdead.Location = new System.Drawing.Point(20, 20);
|
||||
this.lblMCdead.Name = "lblMCdead";
|
||||
this.lblMCdead.Size = new System.Drawing.Size(380, 23);
|
||||
this.lblMCdead.TabIndex = 0;
|
||||
this.lblMCdead.Text = "Classic has been removed from minecraft.net.";
|
||||
//
|
||||
// lblMCdead2
|
||||
//
|
||||
this.lblMCdead2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblMCdead2.Location = new System.Drawing.Point(20, 62);
|
||||
this.lblMCdead2.Name = "lblMCdead2";
|
||||
this.lblMCdead2.Size = new System.Drawing.Size(300, 41);
|
||||
this.lblMCdead2.TabIndex = 1;
|
||||
this.lblMCdead2.Text = "But don\'t despair! You can sign up for an account at classicube.net.";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -720,16 +484,13 @@ namespace Launcher
|
||||
this.tabCCServers.ResumeLayout(false);
|
||||
this.tabCCServers.PerformLayout();
|
||||
this.tabMinecraftNet.ResumeLayout(false);
|
||||
this.tabMC.ResumeLayout(false);
|
||||
this.tabMCSignIn.ResumeLayout(false);
|
||||
this.tabMCSignIn.PerformLayout();
|
||||
this.tabMCServers.ResumeLayout(false);
|
||||
this.tabMCServers.PerformLayout();
|
||||
this.tabDC.ResumeLayout(false);
|
||||
this.tabDC.PerformLayout();
|
||||
this.tabs.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
private System.Windows.Forms.Label lblMCdead;
|
||||
private System.Windows.Forms.Label lblMCdead2;
|
||||
private System.Windows.Forms.Label lblDChint;
|
||||
private System.Windows.Forms.Label lblDCuser;
|
||||
private System.Windows.Forms.Label lblDCaddress;
|
||||
@ -741,29 +502,6 @@ namespace Launcher
|
||||
private System.Windows.Forms.TextBox txtDCport;
|
||||
private System.Windows.Forms.TextBox txtDCuser;
|
||||
private System.Windows.Forms.TextBox txtDCmppass;
|
||||
private System.Windows.Forms.CheckBox cbMCHideInvalid;
|
||||
private System.Windows.Forms.Label lblMCSearch;
|
||||
private System.Windows.Forms.TextBox txtMCSearch;
|
||||
private System.Windows.Forms.CheckBox cbMCHideEmpty;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader4;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader3;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ListView tblMCServers;
|
||||
private System.Windows.Forms.Button btnMCConnect;
|
||||
private System.Windows.Forms.Label lblMCHash;
|
||||
private System.Windows.Forms.TextBox txtMCHash;
|
||||
private System.Windows.Forms.TabPage tabMCServers;
|
||||
private System.Windows.Forms.Label lblMCPass;
|
||||
private System.Windows.Forms.TextBox txtMCPassword;
|
||||
private System.Windows.Forms.TextBox txtMCUser;
|
||||
private System.Windows.Forms.Button btnMCSignIn;
|
||||
private System.Windows.Forms.Label lbMCUser;
|
||||
private System.Windows.Forms.Label lblMCStatus;
|
||||
private System.Windows.Forms.Label lblMCStatusLabel;
|
||||
private System.Windows.Forms.ProgressBar prgMCStatus;
|
||||
private System.Windows.Forms.TabPage tabMCSignIn;
|
||||
private System.Windows.Forms.TabControl tabMC;
|
||||
private System.Windows.Forms.TextBox txtCCHash;
|
||||
private System.Windows.Forms.Label lblCCPlayUrl;
|
||||
private System.Windows.Forms.Button btnCCConnect;
|
||||
|
@ -17,26 +17,15 @@ namespace Launcher {
|
||||
InitializeComponent();
|
||||
AdjustTabs();
|
||||
// hide tabs at start
|
||||
tabMC.TabPages.Remove( tabMCServers );
|
||||
tabCC.TabPages.Remove( tabCCServers );
|
||||
Shown += DisplayResourcesDialog;
|
||||
|
||||
mc = new GameState() { Progress = prgMCStatus, Status = lblMCStatus,
|
||||
Username = txtMCUser, Password = txtMCPassword, HostServer = "minecraft.net",
|
||||
Session = new MinecraftSession(), SignInButton = btnMCSignIn, Tab = tabMC,
|
||||
ServersTab = tabMCServers, ServersTable = tblMCServers, Hash = txtMCHash,
|
||||
form = this };
|
||||
|
||||
cc = new GameState() { Progress = prgCCStatus, Status = lblCCStatus,
|
||||
Username = txtCCUser, Password = txtCCPassword, HostServer = "classicube.net",
|
||||
Session = new ClassicubeSession(), SignInButton = btnCCSignIn, Tab = tabCC,
|
||||
ServersTab = tabCCServers, ServersTable = tblCCServers, Hash = txtCCHash,
|
||||
form = this };
|
||||
|
||||
mc.Filter = e =>
|
||||
// NOTE: using ToLower().Contains() allocates too many unecessary strings.
|
||||
e.Name.IndexOf( txtMCSearch.Text, StringComparison.OrdinalIgnoreCase ) >= 0
|
||||
&& ( cbMCHideEmpty.Checked ? e.Players[0] != '0' : true )
|
||||
&& ( cbMCHideInvalid.Checked ? Int32.Parse( e.Players ) < 600 : true );
|
||||
cc.Filter = e =>
|
||||
e.Name.IndexOf( txtCCSearch.Text, StringComparison.OrdinalIgnoreCase ) >= 0
|
||||
&& ( cbCCHideEmpty.Checked ? e.Players[0] != '0' : true );
|
||||
@ -50,11 +39,6 @@ namespace Launcher {
|
||||
|
||||
if( tabs.SelectedTab == tabDC ) {
|
||||
BtnDCconnectClick( null, null );
|
||||
} else if( tabs.SelectedTab == tabMinecraftNet ) {
|
||||
if( tabMC.SelectedTab == tabMCSignIn )
|
||||
mc.DoSignIn();
|
||||
else if( tabMC.SelectedTab == tabMCServers )
|
||||
mc.ConnectToServer();
|
||||
} else if( tabs.SelectedTab == tabClassicubeNet ) {
|
||||
if( tabCC.SelectedTab == tabCCSignIn )
|
||||
cc.DoSignIn();
|
||||
@ -87,12 +71,9 @@ namespace Launcher {
|
||||
void AdjustTabs() {
|
||||
tabs.Width = ClientSize.Width + 6;
|
||||
tabs.Height = ClientSize.Height + 3;
|
||||
tabMC.Width = tabCC.Width = tabs.Width;
|
||||
tabMC.Height = tabCC.Height = tabs.SelectedTab.Size.Height + 10;
|
||||
tabCC.Width = tabs.Width;
|
||||
tabCC.Height = tabs.SelectedTab.Size.Height + 10;
|
||||
|
||||
if( tblMCServers.IsHandleCreated ) {
|
||||
AdjustTablePos( tblMCServers, btnMCConnect );
|
||||
}
|
||||
if( tblCCServers.IsHandleCreated ) {
|
||||
AdjustTablePos( tblCCServers, btnCCConnect );
|
||||
}
|
||||
@ -154,43 +135,7 @@ namespace Launcher {
|
||||
if( mppass != null )
|
||||
txtDCmppass.Text = mppass;
|
||||
}
|
||||
#endregion
|
||||
|
||||
NameComparer mcNameComparer = new NameComparer( 0 );
|
||||
NumericalComparer mcPlayersComparer = new NumericalComparer( 1 );
|
||||
NumericalComparer mcMaxPlayersComparer = new NumericalComparer( 2 );
|
||||
UptimeComparer mcUptimeComparer = new UptimeComparer( 3 );
|
||||
void tblMCServersColumnClick( object sender, ColumnClickEventArgs e ) {
|
||||
if( e.Column == 0 ) {
|
||||
mcNameComparer.Invert = !mcNameComparer.Invert;
|
||||
tblMCServers.ListViewItemSorter = mcNameComparer;
|
||||
} else if( e.Column == 1 ) {
|
||||
mcPlayersComparer.Invert = !mcPlayersComparer.Invert;
|
||||
tblMCServers.ListViewItemSorter = mcPlayersComparer;
|
||||
} else if( e.Column == 2 ) {
|
||||
mcMaxPlayersComparer.Invert = !mcMaxPlayersComparer.Invert;
|
||||
tblMCServers.ListViewItemSorter = mcMaxPlayersComparer;
|
||||
} else if( e.Column == 3 ) {
|
||||
mcUptimeComparer.Invert = !mcUptimeComparer.Invert;
|
||||
tblMCServers.ListViewItemSorter = mcUptimeComparer;
|
||||
}
|
||||
tblMCServers.Sort();
|
||||
}
|
||||
|
||||
void txtMCSearchTextChanged( object sender, EventArgs e ) { mc.FilterList(); }
|
||||
|
||||
void cbMCHideEmptyCheckedChanged( object sender, EventArgs e ) { mc.FilterList(); }
|
||||
|
||||
void cbMCHideInvalidCheckedChanged(object sender, EventArgs e ) { mc.FilterList(); }
|
||||
|
||||
void tblMCServersClick( object sender, EventArgs e ) { mc.ServerTableClick(); }
|
||||
|
||||
void txtMCHashTextChanged( object sender, EventArgs e ) { mc.HashChanged(); }
|
||||
|
||||
void btnMCConnectClick( object sender, EventArgs e ) { mc.ConnectToServer(); }
|
||||
|
||||
void btnMCSignInClick( object sender, EventArgs e ) { mc.DoSignIn(); }
|
||||
|
||||
#endregion
|
||||
|
||||
NameComparer ccNameComparer = new NameComparer( 0 );
|
||||
NumericalComparer ccPlayersComparer = new NumericalComparer( 1 );
|
||||
@ -237,18 +182,15 @@ namespace Launcher {
|
||||
Process process = null;
|
||||
UpdateResumeInfo( data, classicubeSkins );
|
||||
|
||||
try {
|
||||
if( Type.GetType( "Mono.Runtime" ) != null ) {
|
||||
process = Process.Start( "mono", "\"ClassicalSharp.exe\" " + args );
|
||||
} else {
|
||||
process = Process.Start( "ClassicalSharp.exe", args );
|
||||
}
|
||||
} catch( Win32Exception ex ) {
|
||||
if( ex.Message.Contains( "The system cannot find the file specified" ) ) {
|
||||
MessageBox.Show( missingExeMessage );
|
||||
} else {
|
||||
throw;
|
||||
}
|
||||
if( !File.Exists( "ClassicalSharp.exe" ) ) {
|
||||
MessageBox.Show( missingExeMessage );
|
||||
return;
|
||||
}
|
||||
|
||||
if( Type.GetType( "Mono.Runtime" ) != null ) {
|
||||
process = Process.Start( "mono", "\"ClassicalSharp.exe\" " + args );
|
||||
} else {
|
||||
process = Process.Start( "ClassicalSharp.exe", args );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,120 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Launcher {
|
||||
|
||||
public class MinecraftSession : GameSession {
|
||||
|
||||
const string minecraftNetUri = "https://minecraft.net/",
|
||||
loginUri = "https://minecraft.net/login",
|
||||
publicServersUri = "https://minecraft.net/classic/list",
|
||||
playUri = "https://minecraft.net/classic/play/";
|
||||
const string loggedInAs = @"<span class=""logged-in"">";
|
||||
const string wrongCredentialsMessage = "Oops, unknown username or password.";
|
||||
StringComparison ordinal = StringComparison.Ordinal;
|
||||
|
||||
public override void Login( string user, string password ) {
|
||||
Username = user;
|
||||
string loginData = String.Format(
|
||||
"username={0}&password={1}",
|
||||
Uri.EscapeDataString( user ),
|
||||
Uri.EscapeDataString( password )
|
||||
);
|
||||
|
||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||
// Step 1: POST to login page username and password.
|
||||
var response = PostHtml( loginUri, loginUri, loginData );
|
||||
foreach( string line in response ) {
|
||||
if( line.Contains( wrongCredentialsMessage ) ) {
|
||||
throw new InvalidOperationException( "Wrong username or password." );
|
||||
} else if( line.Contains( loggedInAs ) ) {
|
||||
Log( "login took " + sw.ElapsedMilliseconds );
|
||||
sw.Stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new InvalidOperationException( "Failed to recognise the login response." );
|
||||
}
|
||||
|
||||
public override GameStartData GetConnectInfo( string hash ) {
|
||||
string uri = playUri + hash;
|
||||
var response = GetHtml( uri, minecraftNetUri );
|
||||
GameStartData data = new GameStartData();
|
||||
data.Username = Username;
|
||||
|
||||
foreach( string line in response ) {
|
||||
int index = 0;
|
||||
// Look for <param name="x" value="x"> tags
|
||||
if( ( index = line.IndexOf( "<param", ordinal ) ) > 0 ) {
|
||||
int nameStart = index + 13;
|
||||
int nameEnd = line.IndexOf( '"', nameStart );
|
||||
string paramName = line.Substring( nameStart, nameEnd - nameStart );
|
||||
|
||||
// Don't read param value by default so we avoid allocating unnecessary 'value' strings.
|
||||
if( paramName == "server" ) {
|
||||
data.Ip = GetParamValue( line, nameEnd );
|
||||
} else if( paramName == "port" ) {
|
||||
data.Port = GetParamValue( line, nameEnd );
|
||||
} else if( paramName == "mppass" ) {
|
||||
data.Mppass = GetParamValue( line, nameEnd );
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static string GetParamValue( string line, int nameEnd ) {
|
||||
int valueStart = nameEnd + 9;
|
||||
int valueEnd = line.IndexOf( '"', valueStart );
|
||||
return line.Substring( valueStart, valueEnd - valueStart );
|
||||
}
|
||||
|
||||
public override List<ServerListEntry> GetPublicServers() {
|
||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||
var response = GetHtml( publicServersUri, minecraftNetUri );
|
||||
List<ServerListEntry> servers = new List<ServerListEntry>();
|
||||
bool foundStart = false;
|
||||
int mode = 0;
|
||||
|
||||
string hash = null, name = null, players = null;
|
||||
string maxPlayers = null, uptime = null;
|
||||
|
||||
foreach( string line in response ) {
|
||||
if( line.StartsWith( " <a href", ordinal ) ) {
|
||||
const int hashStart = 59;
|
||||
int hashEnd = line.IndexOf( '"', hashStart );
|
||||
hash = line.Substring( hashStart, hashEnd - hashStart );
|
||||
|
||||
int nameStart = hashEnd + 2; // point to first char of name
|
||||
int nameEnd = line.IndexOf( '<', nameStart );
|
||||
name = line.Substring( nameStart, nameEnd - nameStart );
|
||||
name = WebUtility.HtmlDecode( name );
|
||||
foundStart = true;
|
||||
mode = 0;
|
||||
}
|
||||
if( !foundStart ) continue;
|
||||
|
||||
// NOTE: >16 checks that the line actually has a value.
|
||||
// this check is necessary, as the page does have lines with just " <td>"
|
||||
if( line.Length > 16 && line.StartsWith( " <td>", ordinal ) ) {
|
||||
const int valStart = 16;
|
||||
int valEnd = line.IndexOf( '<', valStart );
|
||||
string value = line.Substring( valStart, valEnd - valStart );
|
||||
|
||||
if( mode == 0 ) {
|
||||
players = value;
|
||||
} else if( mode == 1 ) {
|
||||
maxPlayers = value;
|
||||
} else if( mode == 2 ) {
|
||||
uptime = value;
|
||||
servers.Add( new ServerListEntry( hash, name, players, maxPlayers, uptime ) );
|
||||
}
|
||||
mode++;
|
||||
}
|
||||
}
|
||||
Log( "servers matching took " + sw.ElapsedMilliseconds );
|
||||
sw.Stop();
|
||||
return servers;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user