Added Minecraft Client GUI v1.0 to the repository

+ Some BasicIO fixes to Minecraft Console Client
This commit is contained in:
ORelio 2013-08-21 14:31:57 +02:00
parent 84b8b9da2a
commit f26ff323fd
18 changed files with 7413 additions and 9 deletions

4
.gitignore vendored
View file

@ -1,2 +1,4 @@
/MinecraftClient.v11.suo /MinecraftClient.v11.suo
/MinecraftClient.suo /MinecraftClient.suo
/MinecraftClientGUI.v11.suo
/MinecraftClientGUI.suo

View file

@ -151,18 +151,21 @@ namespace MinecraftClient
if (Settings.Login == "") if (Settings.Login == "")
{ {
Console.Write("Username : "); Console.Write(ConsoleIO.basicIO ? "Please type the username of your choice.\n" : "Username : ");
Settings.Login = Console.ReadLine(); Settings.Login = Console.ReadLine();
} }
if (Settings.Password == "") if (Settings.Password == "")
{ {
Console.Write("Password : "); Console.Write(ConsoleIO.basicIO ? "Please type the password for " + Settings.Login + ".\n" : "Password : ");
Settings.Password = Console.ReadLine(); Settings.Password = Console.ReadLine();
//Hide the password if (!ConsoleIO.basicIO)
Console.CursorTop--; {
Console.Write("Password : <******>"); //Hide the password
for (int i = 19; i < Console.BufferWidth; i++) { Console.Write(' '); } Console.CursorTop--;
Console.Write("Password : <******>");
for (int i = 19; i < Console.BufferWidth; i++) { Console.Write(' '); }
}
} }
startupargs = args; startupargs = args;

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3")] [assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.3")] [assembly: AssemblyFileVersion("1.6.1")]

20
MinecraftClientGUI.sln Normal file
View file

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinecraftClientGUI", "MinecraftClientGUI\MinecraftClientGUI.csproj", "{B9E600B3-C8F0-4BF8-85E1-C164956B0B0D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B9E600B3-C8F0-4BF8-85E1-C164956B0B0D}.Debug|x86.ActiveCfg = Debug|x86
{B9E600B3-C8F0-4BF8-85E1-C164956B0B0D}.Debug|x86.Build.0 = Debug|x86
{B9E600B3-C8F0-4BF8-85E1-C164956B0B0D}.Release|x86.ActiveCfg = Release|x86
{B9E600B3-C8F0-4BF8-85E1-C164956B0B0D}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

2
MinecraftClientGUI/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/bin/
/obj/

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

173
MinecraftClientGUI/Form1.Designer.cs generated Normal file
View file

@ -0,0 +1,173 @@
namespace MinecraftClientGUI
{
partial class Form1
{
/// <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(Form1));
this.groupBox_Login = new System.Windows.Forms.GroupBox();
this.btn_connect = new System.Windows.Forms.Button();
this.box_ip = new System.Windows.Forms.TextBox();
this.box_password = new System.Windows.Forms.TextBox();
this.box_Login = new System.Windows.Forms.TextBox();
this.box_output = new System.Windows.Forms.RichTextBox();
this.box_input = new System.Windows.Forms.TextBox();
this.btn_send = new System.Windows.Forms.Button();
this.btn_about = new System.Windows.Forms.Button();
this.groupBox_Login.SuspendLayout();
this.SuspendLayout();
//
// groupBox_Login
//
this.groupBox_Login.BackColor = System.Drawing.Color.Transparent;
this.groupBox_Login.Controls.Add(this.btn_connect);
this.groupBox_Login.Controls.Add(this.box_ip);
this.groupBox_Login.Controls.Add(this.box_password);
this.groupBox_Login.Controls.Add(this.box_Login);
this.groupBox_Login.Location = new System.Drawing.Point(13, 11);
this.groupBox_Login.Name = "groupBox_Login";
this.groupBox_Login.Size = new System.Drawing.Size(564, 46);
this.groupBox_Login.TabIndex = 0;
this.groupBox_Login.TabStop = false;
this.groupBox_Login.Text = " ";
//
// btn_connect
//
this.btn_connect.Location = new System.Drawing.Point(513, 15);
this.btn_connect.Name = "btn_connect";
this.btn_connect.Size = new System.Drawing.Size(40, 23);
this.btn_connect.TabIndex = 6;
this.btn_connect.Text = "Go!";
this.btn_connect.UseVisualStyleBackColor = true;
this.btn_connect.Click += new System.EventHandler(this.btn_connect_Click);
//
// box_ip
//
this.box_ip.Location = new System.Drawing.Point(400, 17);
this.box_ip.Name = "box_ip";
this.box_ip.Size = new System.Drawing.Size(100, 20);
this.box_ip.TabIndex = 5;
this.box_ip.KeyUp += new System.Windows.Forms.KeyEventHandler(this.loginBox_KeyUp);
//
// box_password
//
this.box_password.Location = new System.Drawing.Point(235, 17);
this.box_password.Name = "box_password";
this.box_password.PasswordChar = '•';
this.box_password.Size = new System.Drawing.Size(100, 20);
this.box_password.TabIndex = 3;
this.box_password.KeyUp += new System.Windows.Forms.KeyEventHandler(this.loginBox_KeyUp);
//
// box_Login
//
this.box_Login.Location = new System.Drawing.Point(67, 17);
this.box_Login.Name = "box_Login";
this.box_Login.Size = new System.Drawing.Size(100, 20);
this.box_Login.TabIndex = 1;
this.box_Login.KeyUp += new System.Windows.Forms.KeyEventHandler(this.loginBox_KeyUp);
//
// box_output
//
this.box_output.Location = new System.Drawing.Point(13, 66);
this.box_output.Name = "box_output";
this.box_output.ReadOnly = true;
this.box_output.Size = new System.Drawing.Size(564, 292);
this.box_output.TabIndex = 1;
this.box_output.Text = "";
this.box_output.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.LinkClicked);
//
// box_input
//
this.box_input.AcceptsTab = true;
this.box_input.Location = new System.Drawing.Point(13, 365);
this.box_input.MaxLength = 100;
this.box_input.Multiline = true;
this.box_input.Name = "box_input";
this.box_input.Size = new System.Drawing.Size(490, 20);
this.box_input.TabIndex = 2;
this.box_input.KeyDown += new System.Windows.Forms.KeyEventHandler(this.inputBox_KeyDown);
//
// btn_send
//
this.btn_send.Location = new System.Drawing.Point(509, 364);
this.btn_send.Name = "btn_send";
this.btn_send.Size = new System.Drawing.Size(40, 22);
this.btn_send.TabIndex = 3;
this.btn_send.Text = "Send";
this.btn_send.UseVisualStyleBackColor = true;
this.btn_send.Click += new System.EventHandler(this.btn_send_Click);
//
// btn_about
//
this.btn_about.Location = new System.Drawing.Point(555, 364);
this.btn_about.Name = "btn_about";
this.btn_about.Size = new System.Drawing.Size(22, 22);
this.btn_about.TabIndex = 4;
this.btn_about.Text = "?";
this.btn_about.UseVisualStyleBackColor = true;
this.btn_about.Click += new System.EventHandler(this.btn_about_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(589, 398);
this.Controls.Add(this.btn_about);
this.Controls.Add(this.btn_send);
this.Controls.Add(this.box_input);
this.Controls.Add(this.box_output);
this.Controls.Add(this.groupBox_Login);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Minecraft Console Client GUI";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.onClose);
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox_Login.ResumeLayout(false);
this.groupBox_Login.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.GroupBox groupBox_Login;
private System.Windows.Forms.Button btn_connect;
private System.Windows.Forms.TextBox box_ip;
private System.Windows.Forms.TextBox box_password;
private System.Windows.Forms.TextBox box_Login;
private System.Windows.Forms.RichTextBox box_output;
private System.Windows.Forms.TextBox box_input;
private System.Windows.Forms.Button btn_send;
private System.Windows.Forms.Button btn_about;
}
}

337
MinecraftClientGUI/Form1.cs Normal file
View file

@ -0,0 +1,337 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace MinecraftClientGUI
{
/// <summary>
/// The main graphical user interface
/// </summary>
public partial class Form1 : Form
{
private LinkedList<string> previous = new LinkedList<string>();
private MinecraftClient Client;
private Thread t_clientread;
#region Aero Glass Low-level Windows API
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct MARGINS
{
public int Left;
public int Right;
public int Top;
public int Bottom;
}
[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMargins);
#endregion
public Form1(string[] args)
{
InitializeComponent();
if (args.Length > 0) { initClient(new MinecraftClient(args)); }
}
/// <summary>
/// Define some element properties and init Aero Glass if using Vista or newer
/// </summary>
private void Form1_Load(object sender, EventArgs e)
{
box_output.ScrollBars = RichTextBoxScrollBars.None;
box_output.Font = new Font("Consolas", 8);
box_output.BackColor = Color.White;
if (Environment.OSVersion.Version.Major >= 6)
{
this.BackColor = Color.DarkMagenta; this.TransparencyKey = Color.DarkMagenta;
MARGINS marg = new MARGINS() { Left = -1, Right = -1, Top = -1, Bottom = -1 };
DwmExtendFrameIntoClientArea(this.Handle, ref marg);
}
}
/// <summary>
/// Launch the Minecraft Client by clicking the "Go!" button.
/// If a client is already running, it will be closed.
/// </summary>
private void btn_connect_Click(object sender, EventArgs e)
{
if (Client != null)
{
Client.Close();
t_clientread.Abort();
box_output.Text = "";
}
string username = box_Login.Text;
string password = box_password.Text;
string serverip = box_ip.Text;
if (password == "") { password = "-"; }
if (username != "" && serverip != "")
{
initClient(new MinecraftClient(username, password, serverip));
}
}
/// <summary>
/// Handle a new Minecraft Client
/// </summary>
/// <param name="client">Client to handle</param>
private void initClient(MinecraftClient client)
{
Client = client;
t_clientread = new Thread(new ThreadStart(t_clientread_loop));
t_clientread.Start();
box_input.Select();
}
/// <summary>
/// Thread reading output from the Minecraft Client
/// </summary>
private void t_clientread_loop()
{
while (true && !Client.Disconnected)
{
printstring(Client.ReadLine());
}
}
/// <summary>
/// Print a Minecraft-Formatted string to the console area
/// </summary>
/// <param name="str">String to print</param>
private void printstring(string str)
{
if (!String.IsNullOrEmpty(str))
{
Color color = Color.Black;
FontStyle style = FontStyle.Regular;
string[] subs = str.Split('§');
if (subs[0].Length > 0) { AppendTextBox(box_output, subs[0], Color.Black, FontStyle.Regular); }
for (int i = 1; i < subs.Length; i++)
{
if (subs[i].Length > 0)
{
if (subs[i].Length > 1)
{
switch (subs[i][0])
{
//Font colors
case '0': color = Color.Black; break;
case '1': color = Color.DarkBlue; break;
case '2': color = Color.DarkGreen; break;
case '3': color = Color.DarkCyan; break;
case '4': color = Color.DarkRed; break;
case '5': color = Color.DarkMagenta; break;
case '6': color = Color.DarkGoldenrod; break;
case '7': color = Color.DimGray; break;
case '8': color = Color.Gray; break;
case '9': color = Color.Blue; break;
case 'a': color = Color.Green; break;
case 'b': color = Color.CornflowerBlue; break;
case 'c': color = Color.Red; break;
case 'd': color = Color.Magenta; break;
case 'e': color = Color.Goldenrod; break;
//White on white = invisible so use gray instead
case 'f': color = Color.DimGray; break;
//Font styles. Can use several styles eg Bold + Underline
case 'l': style = style | FontStyle.Bold; break;
case 'm': style = style | FontStyle.Strikeout; break;
case 'n': style = style | FontStyle.Underline; break;
case 'o': style = style | FontStyle.Italic; break;
//Reset font color & style
case 'r': color = Color.Black; style = FontStyle.Regular; break;
}
AppendTextBox(box_output, subs[i].Substring(1, subs[i].Length - 1), color, style);
}
}
}
AppendTextBox(box_output, "\n", Color.Black, FontStyle.Regular);
}
Console.ForegroundColor = ConsoleColor.Gray;
}
/// <summary>
/// Append text to a RichTextBox with font customization
/// </summary>
/// <param name="box">Target RichTextBox</param>
/// <param name="text">Text to add</param>
/// <param name="color">Color of the text</param>
/// <param name="style">Font style of the text</param>
private void AppendTextBox(RichTextBox box, string text, Color color, FontStyle style)
{
if (InvokeRequired)
{
this.Invoke(new Action<RichTextBox, string, Color, FontStyle>(AppendTextBox), new object[] { box, text, color, style });
}
else
{
box.SelectionStart = box.TextLength;
box.SelectionLength = 0;
box.SelectionColor = color;
box.SelectionFont = new Font(box.Font, style);
box.AppendText(text);
box.SelectionColor = box.ForeColor;
box.SelectionStart = box.Text.Length;
box.ScrollToCaret();
}
}
/// <summary>
/// Properly disconnect the client when clicking the [X] close button
/// </summary>
protected void onClose(object sender, EventArgs e)
{
if (t_clientread != null) { t_clientread.Abort(); }
if (Client != null) { new Thread(new ThreadStart(Client.Close)).Start(); }
}
/// <summary>
/// Allows an Enter keypress in "Login", "Password" or "Server IP" box to be considered as a click on the "Go!" button
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void loginBox_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
btn_connect_Click(sender, e);
e.Handled = true;
}
}
/// <summary>
/// Handle special functions in the input box : send with Enter key, command history and tab-complete
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void inputBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
btn_send_Click(sender, e);
e.Handled = true;
}
else if (e.KeyCode == Keys.Down)
{
if (previous.Count > 0)
{
box_input.Text = previous.First.Value;
previous.AddLast(box_input.Text);
previous.RemoveFirst();
box_input.Select(box_input.Text.Length, 0);
}
e.Handled = true;
}
else if (e.KeyCode == Keys.Up)
{
if (previous.Count > 0)
{
box_input.Text = previous.Last.Value;
previous.AddFirst(box_input.Text);
previous.RemoveLast();
box_input.Select(box_input.Text.Length, 0);
}
e.Handled = true;
}
else if (e.KeyCode == Keys.Tab)
{
if (box_input.SelectionStart > 0)
{
string behind_cursor = box_input.Text.Substring(0, box_input.SelectionStart);
string after_cursor = box_input.Text.Substring(box_input.SelectionStart);
string[] behind_temp = behind_cursor.Split(' ');
string autocomplete = Client.tabAutoComplete(behind_temp[behind_temp.Length - 1]);
if (!String.IsNullOrEmpty(autocomplete))
{
behind_temp[behind_temp.Length - 1] = autocomplete;
behind_cursor = String.Join(" ", behind_temp);
box_input.Text = behind_cursor + after_cursor;
box_input.SelectionStart = behind_cursor.Length;
}
}
e.SuppressKeyPress = true;
e.Handled = true;
}
}
/// <summary>
/// Send the input in the input box, if any, by pressing the "Send" button.
/// Handle "/quit" command to properly disconnect and close the GUI.
/// </summary>
private void btn_send_Click(object sender, EventArgs e)
{
if (Client != null)
{
if (box_input.Text.Trim().ToLower() == "/quit")
{
Close();
}
else
{
Client.SendText(box_input.Text);
previous.AddLast(box_input.Text);
box_input.Text = "";
}
}
}
/// <summary>
/// Draw text on glass pane without ClearType, only black pixels
/// </summary>
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
e.Graphics.DrawString("Login Details", this.Font, Brushes.Black, 20, 11);
e.Graphics.DrawString("Username:", this.Font, Brushes.Black, 20, 31);
e.Graphics.DrawString("Password:", this.Font, Brushes.Black, 191, 31);
e.Graphics.DrawString("Server IP:", this.Font, Brushes.Black, 355, 31);
}
/// <summary>
/// Show the "About" message box, open the official topic in an internet browser if the user press OK.
/// </summary>
private void btn_about_Click(object sender, EventArgs e)
{
if (MessageBox.Show("MCC GUI version 1.0 - (c) 2013 ORelio\nAllows to send commands to any Minecraft server\nand receive text messages in a fast and easy way.\n\nPress OK to visit the official topic on Minecraft Forums.",
"About Minecraft Console Client", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
{
System.Diagnostics.Process.Start("http://www.minecraftforum.net/topic/1314800-/");
}
}
/// <summary>
/// Open a link located in the console window
/// </summary>
private void LinkClicked(object sender, LinkClickedEventArgs e)
{
try { System.Diagnostics.Process.Start(e.LinkText); }
catch (Exception ex) { MessageBox.Show("An error occured while opening the link :\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;
namespace MinecraftClientGUI
{
/// <summary>
/// This class acts as a wrapper for MinecraftClient.exe
/// Allows the rest of the program to consider this class as the Minecraft client itself.
/// </summary>
class MinecraftClient
{
public static string ExePath = "MinecraftClient.exe";
public bool Disconnected { get { return disconnected; } }
private LinkedList<string> OutputBuffer = new LinkedList<string>();
private LinkedList<string> tabAutoCompleteBuffer = new LinkedList<string>();
private bool disconnected = false;
private Process Client;
private Thread Reader;
/// <summary>
/// Start a client using command-line arguments
/// </summary>
/// <param name="args">Arguments to pass</param>
public MinecraftClient(string[] args)
{
initClient("\"" + String.Join("\" \"", args) + "\" BasicIO");
}
/// <summary>
/// Start the client using username, password and server IP
/// </summary>
/// <param name="username">Username or email</param>
/// <param name="password">Password for the given username</param>
/// <param name="serverip">Server IP to join</param>
public MinecraftClient(string username, string password, string serverip)
{
initClient('"' + username + "\" \"" + password + "\" \"" + serverip + "\" BasicIO");
}
/// <summary>
/// Inner function for launching the external console application
/// </summary>
/// <param name="arguments">Arguments to pass</param>
private void initClient(string arguments)
{
if (File.Exists(ExePath))
{
Client = new Process();
Client.StartInfo.FileName = ExePath;
Client.StartInfo.Arguments = arguments;
Client.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
Client.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(850);
Client.StartInfo.UseShellExecute = false;
Client.StartInfo.RedirectStandardOutput = true;
Client.StartInfo.RedirectStandardInput = true;
Client.StartInfo.CreateNoWindow = true;
Client.Start();
Reader = new Thread(new ThreadStart(t_reader));
Reader.Start();
}
else throw new FileNotFoundException("Cannot find Minecraft Client Executable!", ExePath);
}
/// <summary>
/// Thread for reading output and app messages from the console
/// </summary>
private void t_reader()
{
while (true)
{
try
{
string line = "";
while (line.Trim() == "")
{
line = Client.StandardOutput.ReadLine() + Client.MainWindowTitle;
if (line == "Server was successfuly joined.") { disconnected = false; }
if (line == "You have left the server.") { disconnected = true; }
if (line[0] == (char)0x00)
{
//App message from the console
string[] command = line.Substring(1).Split((char)0x00);
switch (command[0].ToLower())
{
case "autocomplete":
if (command.Length > 1) { tabAutoCompleteBuffer.AddLast(command[1]); }
else tabAutoCompleteBuffer.AddLast("");
break;
}
}
else OutputBuffer.AddLast(line);
}
}
catch (NullReferenceException) { break; }
}
}
/// <summary>
/// Get the first queuing output line to print
/// </summary>
/// <returns></returns>
public string ReadLine()
{
while (OutputBuffer.Count < 1) { }
string line = OutputBuffer.First.Value;
OutputBuffer.RemoveFirst();
return line;
}
/// <summary>
/// Complete a playername or a command, usually by pressing the TAB key
/// </summary>
/// <param name="text_behindcursor">Text to complete</param>
/// <returns>Returns an autocompletion for the provided text</returns>
public string tabAutoComplete(string text_behindcursor)
{
tabAutoCompleteBuffer.Clear();
if (text_behindcursor != null && text_behindcursor.Trim().Length > 0)
{
text_behindcursor = text_behindcursor.Trim();
SendText((char)0x00 + "autocomplete" + (char)0x00 + text_behindcursor);
int maxwait = 30; while (tabAutoCompleteBuffer.Count < 1 && maxwait > 0) { Thread.Sleep(100); maxwait--; }
if (tabAutoCompleteBuffer.Count > 0)
{
string text_completed = tabAutoCompleteBuffer.First.Value;
tabAutoCompleteBuffer.RemoveFirst();
return text_completed;
}
else return text_behindcursor;
}
else return "";
}
/// <summary>
/// Send a message or a command to the server
/// </summary>
/// <param name="text">Text to send</param>
public void SendText(string text)
{
if (text != null)
{
text = text.Replace("\t", "");
text = text.Replace("\r", "");
text = text.Replace("\n", "");
text = text.Trim();
if (text.Length > 0)
{
Client.StandardInput.WriteLine(text);
}
}
}
/// <summary>
/// Properly disconnect from the server and dispose the client
/// </summary>
public void Close()
{
Client.StandardInput.WriteLine("/quit");
if (Reader.IsAlive) { Reader.Abort(); }
if (!Client.WaitForExit(3000))
{
try { Client.Kill(); } catch { }
}
}
}
}

View file

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B9E600B3-C8F0-4BF8-85E1-C164956B0B0D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MinecraftClientGUI</RootNamespace>
<AssemblyName>MinecraftClientGUI</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>AppIcon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="MinecraftClient.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="AppIcon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>TestBot - Localhost</StartArguments>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MinecraftClientGUI
{
static class Program
{
/// <summary>
/// Minecraft Console Client GUI by ORelio (c) 2013.
/// Allows to use Minecraft Console Client in a more user friendly interface
/// This source code is released under the CDDL 1.0 License.
/// </summary>
[STAThread]
static void Main(string[] args)
{
if (!System.IO.File.Exists(MinecraftClient.ExePath))
{
MessageBox.Show("File not found: " + MinecraftClient.ExePath, "Minecraft client not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(args));
}
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MinecraftClientGUI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MinecraftClientGUI")]
[assembly: AssemblyCopyright("Copyright © ORelio 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("fc338f38-8ee7-49d8-afca-546a938daa90")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]

View file

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18046
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MinecraftClientGUI.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MinecraftClientGUI.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18046
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MinecraftClientGUI.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>