diff --git a/Galactic Colors Control Console/Galactic Colors Control Console.csproj b/Galactic Colors Control Console/Galactic Colors Control Console.csproj
new file mode 100644
index 0000000..276d774
--- /dev/null
+++ b/Galactic Colors Control Console/Galactic Colors Control Console.csproj
@@ -0,0 +1,64 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}
+ Exe
+ Properties
+ Galactic_Colors_Control_Console
+ Galactic Colors Control Console
+ v4.5
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {93582ce8-c8c8-4e19-908b-d671ecbade25}
+ Galactic Colors Control
+
+
+
+
+
\ No newline at end of file
diff --git a/Galactic Colors Control Console/Program.cs b/Galactic Colors Control Console/Program.cs
new file mode 100644
index 0000000..61dbce1
--- /dev/null
+++ b/Galactic Colors Control Console/Program.cs
@@ -0,0 +1,107 @@
+using System;
+using Galactic_Colors_Control;
+using System.Threading;
+using System.Reflection;
+
+namespace Galactic_Colors_Control_Console
+{
+ internal class Program
+ {
+ private static Client client;
+ private static bool run = true;
+ private static Thread Writer;
+
+ private static void Main()
+ {
+ client = new Client();
+ Console.Title = "Galactic Colors Control Client";
+ Console.Write(">");
+ Write("Galactic Colors Control Client");
+ Write("Console " + Assembly.GetEntryAssembly().GetName().Version.ToString());
+ bool hostSet = false;
+ while(!hostSet)
+ {
+ Write("Enter server host:");
+ string host = client.ValidateHost(Console.ReadLine());
+ if(host == null)
+ {
+ foreach (string output in client.Output.ToArray())
+ {
+ Write(output);
+ }
+ client.Output.Clear();
+ client.ResetHost();
+ }
+ else
+ {
+ Write("Use " + host + "? y/n");
+ ConsoleKeyInfo c = new ConsoleKeyInfo();
+ while(c.Key != ConsoleKey.Y && c.Key != ConsoleKey.N)
+ {
+ c = Console.ReadKey();
+ }
+ if(c.Key == ConsoleKey.Y)
+ {
+ hostSet = true;
+ }
+ else
+ {
+ client.ResetHost();
+ }
+ }
+ }
+ if (client.ConnectHost())
+ {
+ run = true;
+ Writer = new Thread(OutputWriter);
+ Writer.Start();
+ while (run)
+ {
+ client.SendRequest(Console.ReadLine());
+ if (!client.isRunning) { run = false; }
+ }
+ Writer.Join();
+ Console.Read();
+ }
+ else
+ {
+ foreach (string output in client.Output.ToArray())
+ {
+ Write(output);
+ }
+ client.Output.Clear();
+ Console.Read();
+ }
+ }
+
+ private static void OutputWriter()
+ {
+ while (run || client.Output.Count > 0)
+ {
+ if (client.Output.Count > 0)
+ {
+ string text = client.Output[0];
+ switch (text)
+ {
+ case "/clear":
+ Console.Clear();
+ break;
+
+ default:
+ Write(text);
+ break;
+ }
+ client.Output.Remove(text);
+ }
+ Thread.Sleep(200);
+ }
+ }
+
+ private static void Write( string text)
+ {
+ Console.Write("\b");
+ Console.WriteLine(text);
+ Console.Write(">");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Galactic Colors Control Console/Properties/AssemblyInfo.cs b/Galactic Colors Control Console/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..4a2e9d8
--- /dev/null
+++ b/Galactic Colors Control Console/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Les informations générales relatives à un assembly dépendent de
+// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
+// associées à un assembly.
+[assembly: AssemblyTitle("Galactic Colors Control Console")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("sheychen")]
+[assembly: AssemblyProduct("Galactic Colors Control Console")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
+// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
+// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
+[assembly: ComVisible(false)]
+
+// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
+[assembly: Guid("5d6a09d1-dcab-4fd8-b4e6-62d9f41ae8f0")]
+
+// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
+//
+// Version principale
+// Version secondaire
+// Numéro de build
+// Révision
+//
+// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
+// en utilisant '*', comme indiqué ci-dessous :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.1.1")]
+[assembly: AssemblyFileVersion("1.0.1.1")]
diff --git a/Galactic Colors Control GUI/Content/Content.mgcb b/Galactic Colors Control GUI/Content/Content.mgcb
new file mode 100644
index 0000000..e38ff20
--- /dev/null
+++ b/Galactic Colors Control GUI/Content/Content.mgcb
@@ -0,0 +1,57 @@
+
+#----------------------------- Global Properties ----------------------------#
+
+/outputDir:bin/$(Platform)
+/intermediateDir:obj/$(Platform)
+/platform:DesktopGL
+/config:
+/profile:Reach
+/compress:False
+
+#-------------------------------- References --------------------------------#
+
+
+#---------------------------------- Content ---------------------------------#
+
+#begin Fonts/basic.spritefont
+/importer:FontDescriptionImporter
+/processor:FontDescriptionProcessor
+/processorParam:TextureFormat=Compressed
+/build:Fonts/basic.spritefont
+
+#begin Fonts/small.spritefont
+/importer:FontDescriptionImporter
+/processor:FontDescriptionProcessor
+/processorParam:TextureFormat=Compressed
+/build:Fonts/small.spritefont
+
+#begin Fonts/title.spritefont
+/importer:FontDescriptionImporter
+/processor:FontDescriptionProcessor
+/processorParam:TextureFormat=Compressed
+/build:Fonts/title.spritefont
+
+#begin Sounds/alert.mp3
+/importer:Mp3Importer
+/processor:SoundEffectProcessor
+/processorParam:Quality=Best
+/build:Sounds/alert.mp3
+
+#begin Sounds/bip.mp3
+/importer:Mp3Importer
+/processor:SoundEffectProcessor
+/processorParam:Quality=Best
+/build:Sounds/bip.mp3
+
+#begin Sounds/change.mp3
+/importer:Mp3Importer
+/processor:SoundEffectProcessor
+/processorParam:Quality=Best
+/build:Sounds/change.mp3
+
+#begin Sounds/valid.mp3
+/importer:Mp3Importer
+/processor:SoundEffectProcessor
+/processorParam:Quality=Best
+/build:Sounds/valid.mp3
+
diff --git a/Galactic Colors Control GUI/Content/Fonts/basic.spritefont b/Galactic Colors Control GUI/Content/Fonts/basic.spritefont
new file mode 100644
index 0000000..c191e7f
--- /dev/null
+++ b/Galactic Colors Control GUI/Content/Fonts/basic.spritefont
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+ Trebuchet MS
+
+
+ 16
+
+
+ 0
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+ ~
+
+
+
+
diff --git a/Galactic Colors Control GUI/Content/Fonts/small.spritefont b/Galactic Colors Control GUI/Content/Fonts/small.spritefont
new file mode 100644
index 0000000..f4d712e
--- /dev/null
+++ b/Galactic Colors Control GUI/Content/Fonts/small.spritefont
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+ Tahoma
+
+
+ 8
+
+
+ 0
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+ ~
+
+
+
+
\ No newline at end of file
diff --git a/Galactic Colors Control GUI/Content/Fonts/title.spritefont b/Galactic Colors Control GUI/Content/Fonts/title.spritefont
new file mode 100644
index 0000000..2504324
--- /dev/null
+++ b/Galactic Colors Control GUI/Content/Fonts/title.spritefont
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+ MV Boli
+
+
+ 50
+
+
+ 0
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+ ~
+
+
+
+
diff --git a/Galactic Colors Control GUI/Content/Sounds/alert.mp3 b/Galactic Colors Control GUI/Content/Sounds/alert.mp3
new file mode 100644
index 0000000..d80aed4
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Sounds/alert.mp3 differ
diff --git a/Galactic Colors Control GUI/Content/Sounds/bip.mp3 b/Galactic Colors Control GUI/Content/Sounds/bip.mp3
new file mode 100644
index 0000000..a28b430
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Sounds/bip.mp3 differ
diff --git a/Galactic Colors Control GUI/Content/Sounds/change.mp3 b/Galactic Colors Control GUI/Content/Sounds/change.mp3
new file mode 100644
index 0000000..71a3922
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Sounds/change.mp3 differ
diff --git a/Galactic Colors Control GUI/Content/Sounds/valid.mp3 b/Galactic Colors Control GUI/Content/Sounds/valid.mp3
new file mode 100644
index 0000000..903343c
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Sounds/valid.mp3 differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomCenter.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomCenter.png
new file mode 100644
index 0000000..ba3882c
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomCenter.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomLeft.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomLeft.png
new file mode 100644
index 0000000..0565eb6
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomLeft.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomRight.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomRight.png
new file mode 100644
index 0000000..f4030d1
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomRight.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerCenter.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerCenter.png
new file mode 100644
index 0000000..cfff390
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerCenter.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerLeft.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerLeft.png
new file mode 100644
index 0000000..0904246
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerLeft.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerRight.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerRight.png
new file mode 100644
index 0000000..9547c0a
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerRight.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topCenter.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topCenter.png
new file mode 100644
index 0000000..af78ce6
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topCenter.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topLeft.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topLeft.png
new file mode 100644
index 0000000..3fb9dc2
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topLeft.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topRight.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topRight.png
new file mode 100644
index 0000000..e581211
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topRight.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/pointer0.png b/Galactic Colors Control GUI/Content/Textures/Hub/pointer0.png
new file mode 100644
index 0000000..0c44a50
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/pointer0.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/LogoSmall.png b/Galactic Colors Control GUI/Content/Textures/LogoSmall.png
new file mode 100644
index 0000000..cc8e607
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/LogoSmall.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/background0.png b/Galactic Colors Control GUI/Content/Textures/background0.png
new file mode 100644
index 0000000..3a3b521
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/background0.png differ
diff --git a/Galactic Colors Control GUI/Content/Textures/background1.png b/Galactic Colors Control GUI/Content/Textures/background1.png
new file mode 100644
index 0000000..4e57da5
Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/background1.png differ
diff --git a/Galactic Colors Control GUI/Galactic Colors Control GUI.csproj b/Galactic Colors Control GUI/Galactic Colors Control GUI.csproj
new file mode 100644
index 0000000..8a5784c
--- /dev/null
+++ b/Galactic Colors Control GUI/Galactic Colors Control GUI.csproj
@@ -0,0 +1,128 @@
+
+
+
+
+ Debug
+ x86
+ 8.0.30703
+ 2.0
+ {F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}
+ WinExe
+ Properties
+ Galactic_Colors_Control_GUI
+ Galactic Colors Control GUI
+ 512
+ DesktopGL
+ v4.5
+
+
+ x86
+ true
+ full
+ false
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ DEBUG;TRACE;LINUX
+ prompt
+ 4
+
+
+ x86
+ pdbonly
+ true
+ bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
+ TRACE;LINUX
+ prompt
+ 4
+
+
+ Icon.ico
+
+
+
+
+
+
+
+
+
+
+
+
+ ..\..\MonoGame\MyMonoGameGUI\MyMonoGameGUI\bin\Release\MyMonoGame.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\OpenTK.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\NVorbis.dll
+
+
+ $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ Always
+
+
+
+
+
+
+
+ {93582ce8-c8c8-4e19-908b-d671ecbade25}
+ Galactic Colors Control
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Galactic Colors Control GUI/Game1.cs b/Galactic Colors Control GUI/Game1.cs
new file mode 100644
index 0000000..51f39eb
--- /dev/null
+++ b/Galactic Colors Control GUI/Game1.cs
@@ -0,0 +1,508 @@
+using System;
+using MyMonoGame.GUI;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.Audio;
+using Galactic_Colors_Control;
+using System.Threading;
+using System.IO;
+using Microsoft.Xna.Framework.Input;
+using System.Reflection;
+using System.Collections.Generic;
+
+namespace Galactic_Colors_Control_GUI
+{
+ ///
+ /// This is the main type for your game.
+ ///
+ public class Game1 : Game
+ {
+ GraphicsDeviceManager graphics;
+ SpriteBatch spriteBatch;
+ ContentManager content;
+
+ private SoundEffect[] effects = new SoundEffect[4];
+
+ private SpriteFont smallFont;
+ private SpriteFont basicFont;
+ private SpriteFont titleFont;
+
+ internal static Texture2D nullSprite;
+ private Texture2D logoSprite;
+ private Texture2D[] backSprites = new Texture2D[2];
+ private double[] backgroundX = new double[2];
+ private double[] backgroundY = new double[2];
+ private double acceleratorX = 1;
+
+ private Texture2D[] pointerSprites = new Texture2D[1];
+ private boxSprites[] buttonsSprites = new boxSprites[1];
+
+ private Client client;
+ private Manager GUI = new Manager();
+
+ private string skinName;
+ private bool isFullScren = false;
+
+ private enum GameStatus { Home, Connect, Options, Game, Pause, End, Thanks,
+ Title,
+ Indentification,
+ Kick
+ }
+ private GameStatus gameStatus = GameStatus.Home;
+
+ private int ScreenWidth = 1280;
+ private int ScreenHeight = 720;
+
+ private string username = null;
+
+ private static Thread Writer;
+ private bool showOKMessage = false;
+ private string messageTitle;
+ private string messageText = string.Empty;
+ private bool showYNMessage = false;
+ private bool showLoading = false;
+ private bool showChat = false;
+ private string chatText = string.Empty;
+ private string chatInput = string.Empty;
+
+ public Game1()
+ {
+ if (isFullScren)
+ {
+ ScreenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
+ ScreenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
+ }
+ graphics = new GraphicsDeviceManager(this);
+ graphics.PreferredBackBufferWidth = ScreenWidth;
+ graphics.PreferredBackBufferHeight = ScreenHeight;
+ graphics.IsFullScreen = isFullScren;
+ graphics.ApplyChanges();
+ Content.RootDirectory = "Content";
+ content = Content;
+ }
+
+ ///
+ /// Allows the game to perform any initialization it needs to before starting to run.
+ /// This is where it can query for any required services and load any non-graphic
+ /// related content. Calling base.Initialize will enumerate through any components
+ /// and initialize them as well.
+ ///
+ protected override void Initialize()
+ {
+ nullSprite = new Texture2D(GraphicsDevice, 1, 1);
+ nullSprite.SetData(new Color[1 * 1] { Color.White });
+
+ GUI.Initialise();
+ base.Initialize();
+ }
+
+ ///
+ /// LoadContent will be called once per game and is the place to load
+ /// all of your content.
+ ///
+ protected override void LoadContent()
+ {
+ // Create a new SpriteBatch, which can be used to draw textures.
+ spriteBatch = new SpriteBatch(GraphicsDevice);
+
+ //Need OpenAL Update for Windows 10 at least
+ effects[0] = content.Load("Sounds/alert");
+ effects[1] = content.Load("Sounds/bip");
+ effects[2] = content.Load("Sounds/change");
+ effects[3] = content.Load("Sounds/valid");
+
+ smallFont = content.Load("Fonts/small");
+ basicFont = content.Load("Fonts/basic");
+ titleFont = content.Load("Fonts/title");
+
+ for (int i = 0; i < pointerSprites.Length; i++) {
+ pointerSprites[i] = content.Load("Textures/Hub/pointer" + i);
+ }
+
+ backSprites[0] = content.Load("Textures/background0");
+ backSprites[1] = content.Load("Textures/background1");
+
+ logoSprite = content.Load("Textures/LogoSmall");
+
+ for (int i = 0; i < buttonsSprites.Length; i++)
+ {
+ buttonsSprites[i].topLeft = content.Load("Textures/Hub/Buttons/" + i + "/topLeft");
+ buttonsSprites[i].topCenter = content.Load("Textures/Hub/Buttons/" + i + "/topCenter");
+ buttonsSprites[i].topRight = content.Load("Textures/Hub/Buttons/" + i + "/topRight");
+ buttonsSprites[i].centerLeft = content.Load("Textures/Hub/Buttons/" + i + "/centerLeft");
+ buttonsSprites[i].centerCenter = content.Load("Textures/Hub/Buttons/" + i + "/centerCenter");
+ buttonsSprites[i].centerRight = content.Load("Textures/Hub/Buttons/" + i + "/centerRight");
+ buttonsSprites[i].bottomLeft = content.Load("Textures/Hub/Buttons/" + i + "/bottomLeft");
+ buttonsSprites[i].bottomCenter = content.Load("Textures/Hub/Buttons/" + i + "/bottomCenter");
+ buttonsSprites[i].bottomRight = content.Load("Textures/Hub/Buttons/" + i + "/bottomRight");
+ }
+
+ if (Directory.Exists("Skin/" + skinName))
+ {
+ if (Directory.Exists("Skin/" + skinName + "/Sounds"))
+ {
+ Utilities.SoundFromMp3("Skin/" + skinName + "/Sounds/alert.mp3", ref effects[0]);
+ Utilities.SoundFromMp3("Skin/" + skinName + "/Sounds/bip.mp3", ref effects[1]);
+ Utilities.SoundFromMp3("Skin/" + skinName + "/Sounds/change.mp3", ref effects[2]);
+ Utilities.SoundFromMp3("Skin/" + skinName + "/Sounds/valid.mp3", ref effects[3]);
+ }
+
+ if (Directory.Exists("Skin/" + skinName + "/Textures"))
+ {
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/background0.png", ref backSprites[0], GraphicsDevice);
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/background1.png", ref backSprites[1], GraphicsDevice);
+ if (Directory.Exists("Skin/" + skinName + "/Textures/Hub/"))
+ {
+ if(Directory.Exists("Skin/" + skinName + "/Textures/Hub/Buttons"))
+ {
+ for (int i = 0; i < buttonsSprites.Length; i++)
+ {
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/Hub/Buttons/" + i + "/topLeft.png", ref buttonsSprites[i].topLeft, GraphicsDevice);
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/Hub/Buttons/" + i + "/topCenter.png", ref buttonsSprites[i].topCenter, GraphicsDevice);
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/Hub/Buttons/" + i + "/topRight.png", ref buttonsSprites[i].topRight, GraphicsDevice);
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/Hub/Buttons/" + i + "/centerLeft.png", ref buttonsSprites[i].centerLeft, GraphicsDevice);
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/Hub/Buttons/" + i + "/centerCenter.png", ref buttonsSprites[i].centerCenter, GraphicsDevice);
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/Hub/Buttons/" + i + "/centerRight.png", ref buttonsSprites[i].centerRight, GraphicsDevice);
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/Hub/Buttons/" + i + "/bottomLeft.png", ref buttonsSprites[i].bottomLeft, GraphicsDevice);
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/Hub/Buttons/" + i + "/bottomCenter.png", ref buttonsSprites[i].bottomCenter, GraphicsDevice);
+ Utilities.SpriteFromPng("Skin/" + skinName + "Textures/Hub/Buttons/" + i + "/bottomRight.png", ref buttonsSprites[i].bottomRight, GraphicsDevice);
+ }
+ }
+
+ for (int i = 0; i < pointerSprites.Length; i++)
+ {
+ Utilities.SpriteFromPng("Skin/" + skinName + "/Textures/Hub/pointer" + i + ".png", ref pointerSprites[i], GraphicsDevice);
+ }
+ }
+ }
+ }
+
+ // TODO: use this.Content to load your game content here
+ }
+
+ ///
+ /// UnloadContent will be called once per game and is the place to unload
+ /// game-specific content.
+ ///
+ protected override void UnloadContent()
+ {
+ // TODO: Unload any non ContentManager content here
+ }
+
+ ///
+ /// Allows the game to run logic such as updating the world,
+ /// checking for collisions, gathering input, and playing audio.
+ ///
+ /// Provides a snapshot of timing values.
+ protected override void Update(GameTime gameTime)
+ {
+ switch (gameStatus)
+ {
+ case GameStatus.Home:
+ case GameStatus.Title:
+ case GameStatus.Connect:
+ case GameStatus.Indentification:
+ backgroundX[0] -= 1 * acceleratorX;
+ backgroundX[1] -= 2 * acceleratorX;
+ break;
+
+ case GameStatus.Game:
+ if (client.Output.Count > 0)
+ {
+ string text = client.Output[0];
+ switch (text)
+ {
+ case "/clear":
+ chatText = string.Empty;
+ break;
+
+ default:
+ ChatAdd(text);
+ break;
+ }
+ client.Output.Remove(text);
+ }
+ if (!client.isRunning) { gameStatus = GameStatus.Kick; }
+ break;
+ }
+
+ GUI.Update();
+
+ base.Update(gameTime);
+ }
+
+ ///
+ /// This is called when the game should draw itself.
+ ///
+ /// Provides a snapshot of timing values.
+ protected override void Draw(GameTime gameTime)
+ {
+ GraphicsDevice.Clear(Color.DarkGray);
+
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
+
+ GUI.Draw(spriteBatch);
+
+ switch (gameStatus)
+ {
+ case GameStatus.Title:
+ DrawBackground(0);
+ DrawBackground(1);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 2), "Galactic Colors Control", titleFont, new MyMonoGame.Colors(Color.White), Manager.textAlign.centerCenter);
+ break;
+
+ case GameStatus.Home:
+ DrawBackground(0);
+ DrawBackground(1);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 4), "Galactic Colors Control", titleFont, new MyMonoGame.Colors(Color.White), Manager.textAlign.centerCenter);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 4 + 40), "GUI " + Assembly.GetEntryAssembly().GetName().Version.ToString(), basicFont, new MyMonoGame.Colors(Color.White), Manager.textAlign.centerCenter);
+ if (GUI.Button(new Rectangle(ScreenWidth - 64, ScreenHeight - 74,64,64), logoSprite)) { System.Diagnostics.Process.Start("https://sheychen.shost.ca/"); }
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 - 75, ScreenHeight / 2 - 30, 150, 40), buttonsSprites[0], "Play", basicFont, new MyMonoGame.Colors(Color.White, Color.Green))) {
+ GUI.ResetFocus();
+ client = new Client();
+ new Thread(() => {
+ while (acceleratorX < 5)
+ {
+ Thread.Sleep(20);
+ acceleratorX += 0.1d;
+ }
+ gameStatus = GameStatus.Connect;
+ }).Start();
+ }
+ //if (GUI.Button(new Rectangle(ScreenWidth / 2 - 75, ScreenHeight / 2 + 20, 150, 40), buttonsSprites[0], "Options", basicFont, new MyMonoGame.Colors(Color.White, Color.Blue))) {
+ // GUI.ResetFocus();
+ // gameStatus = GameStatus.Options;
+ //}
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 - 75, ScreenHeight / 2 + 70, 150, 40), buttonsSprites[0], "Exit", basicFont, new MyMonoGame.Colors(Color.White, Color.Red))) {
+ GUI.ResetFocus();
+ gameStatus = GameStatus.Title;
+ new Thread(() => {
+ while (acceleratorX > 0)
+ {
+ Thread.Sleep(10);
+ acceleratorX -= 0.01d;
+ }
+ Exit();
+ }).Start();
+ }
+ break;
+
+ case GameStatus.Connect:
+ DrawBackground(0);
+ DrawBackground(1);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 4), "Galactic Colors Control", titleFont, new MyMonoGame.Colors(Color.White), Manager.textAlign.centerCenter);
+ if (showLoading)
+ {
+ GUI.Box(new Rectangle(ScreenWidth / 2 - 150, ScreenHeight / 4 + 50, 300, 50), buttonsSprites[0]);
+ GUI.Label(new Rectangle(ScreenWidth / 2 - 150, ScreenHeight / 4 + 50, 300, 50), "Loading", basicFont);
+ }
+ else
+ {
+ if (showOKMessage)
+ {
+ GUI.Box(new Rectangle(ScreenWidth / 2 - 150, ScreenHeight / 4 + 50, 300, 150), buttonsSprites[0]);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 4 + 60), messageTitle, basicFont, null, Manager.textAlign.bottomCenter);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 4 + 100), messageText, smallFont, null, Manager.textAlign.bottomCenter);
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 - 140, ScreenHeight / 4 + 150, 280, 40), buttonsSprites[0], "Ok", basicFont)) { GUI.ResetFocus(); showOKMessage = false; }
+ }
+ else {
+ if (showYNMessage)
+ {
+ GUI.Box(new Rectangle(ScreenWidth / 2 - 150, ScreenHeight / 4 + 50, 300, 100), buttonsSprites[0]);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 4 + 60), messageTitle, basicFont, null, Manager.textAlign.bottomCenter);
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 - 140, ScreenHeight / 4 + 100, 135, 40), buttonsSprites[0], "Yes", basicFont))
+ {
+ GUI.ResetFocus();
+ new Thread(ConnectHost).Start();
+ showYNMessage = false;
+ }
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 + 5, ScreenHeight / 4 + 100, 135, 40), buttonsSprites[0], "No", basicFont))
+ {
+ client.Output.Clear();
+ client.ResetHost();
+ GUI.ResetFocus();
+ showYNMessage = false;
+ }
+ }
+ else {
+ if (GUI.TextField(new Rectangle(ScreenWidth / 2 - 75, ScreenHeight / 2 - 30, 150, 40), ref username, basicFont, new MyMonoGame.Colors(Color.LightGray, Color.White), Manager.textAlign.centerCenter, "Server address")) { new Thread(ValidateHost).Start(); }
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 - 75, ScreenHeight / 2 + 20, 150, 40), buttonsSprites[0], "Connect", basicFont, new MyMonoGame.Colors(Color.LightGray, Color.White))) { new Thread(ValidateHost).Start(); }
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 - 75, ScreenHeight / 2 + 70, 150, 40), buttonsSprites[0], "Back", basicFont, new MyMonoGame.Colors(Color.LightGray, Color.White)))
+ {
+ GUI.ResetFocus();
+ new Thread(() =>
+ {
+ while (acceleratorX > 1)
+ {
+ Thread.Sleep(20);
+ acceleratorX -= 0.1d;
+ }
+ gameStatus = GameStatus.Home;
+ username = null;
+ }).Start();
+ }
+ }
+ }
+ }
+ break;
+
+ case GameStatus.Indentification:
+ DrawBackground(0);
+ DrawBackground(1);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 4), "Galactic Colors Control", titleFont, new MyMonoGame.Colors(Color.White), Manager.textAlign.centerCenter);
+ if (showLoading)
+ {
+ GUI.Box(new Rectangle(ScreenWidth / 2 - 150, ScreenHeight / 4 + 50, 300, 50), buttonsSprites[0]);
+ GUI.Label(new Rectangle(ScreenWidth / 2 - 150, ScreenHeight / 4 + 50, 300, 50), "Loading", basicFont);
+ }
+ else
+ {
+ if (showOKMessage)
+ {
+ GUI.Box(new Rectangle(ScreenWidth / 2 - 150, ScreenHeight / 4 + 50, 300, 150), buttonsSprites[0]);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 4 + 60), messageTitle, basicFont, null, Manager.textAlign.bottomCenter);
+ GUI.Label(new MyMonoGame.Vector(ScreenWidth / 2, ScreenHeight / 4 + 100), messageText, smallFont, null, Manager.textAlign.bottomCenter);
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 - 140, ScreenHeight / 4 + 150, 280, 40), buttonsSprites[0], "Ok", basicFont)) { GUI.ResetFocus(); showOKMessage = false; }
+ }
+ else {
+ if (GUI.TextField(new Rectangle(ScreenWidth / 2 - 75, ScreenHeight / 2 - 30, 150, 40), ref username, basicFont, new MyMonoGame.Colors(Color.LightGray, Color.White), Manager.textAlign.centerCenter, "Username")) { new Thread(IdentifiacateHost).Start(); }
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 - 75, ScreenHeight / 2 + 20, 150, 40), buttonsSprites[0], "Validate", basicFont, new MyMonoGame.Colors(Color.LightGray, Color.White))) { new Thread(IdentifiacateHost).Start(); }
+ if (GUI.Button(new Rectangle(ScreenWidth / 2 - 75, ScreenHeight / 2 + 70, 150, 40), buttonsSprites[0], "Back", basicFont, new MyMonoGame.Colors(Color.LightGray, Color.White)))
+ {
+ GUI.ResetFocus();
+ new Thread(() =>
+ {
+ while (acceleratorX > 1)
+ {
+ Thread.Sleep(20);
+ acceleratorX -= 0.1d;
+ }
+ gameStatus = GameStatus.Home;
+ username = null;
+ }).Start();
+ }
+ }
+ }
+ break;
+
+ case GameStatus.Game:
+ DrawBackground(0);
+ DrawBackground(1);
+ GUI.Texture(new Rectangle(0,0,ScreenWidth, 30), nullSprite, new MyMonoGame.Colors(new Color(0.1f,0.1f,0.1f)));
+ if(GUI.Button(new Rectangle(5, 5, 50, 20), (showChat ? "Hide" : "Show") + " chat", smallFont, new MyMonoGame.Colors(Color.White, Color.LightGray, Color.Gray))) { GUI.ResetFocus(); showChat = !showChat; }
+ if (showChat)
+ {
+ GUI.Box(new Rectangle(0, 30, 310, 310), buttonsSprites[0]);
+ if(GUI.TextField(new Rectangle(5,35,305,20), ref chatInput, basicFont, null, Manager.textAlign.centerLeft, "Enter message")) { if(chatInput != null) { ChatAdd(chatInput); client.SendRequest(chatInput); chatInput = null; } }
+ GUI.Label(new Rectangle(5, 60, 305, 245), chatText, smallFont, null, Manager.textAlign.topLeft, true);
+ }
+ break;
+ }
+
+ Color ActiveColor = IsActive ? Color.Green : Color.Red;
+ GUI.Label(new MyMonoGame.Vector(10, ScreenHeight - 20), (1 / (float)gameTime.ElapsedGameTime.TotalSeconds).ToString(), smallFont, new MyMonoGame.Colors(ActiveColor));
+ spriteBatch.Draw(pointerSprites[0], new Rectangle(Mouse.GetState().X - 10, Mouse.GetState().Y - 10, 20, 20), Color.Red);
+
+ spriteBatch.End();
+
+ base.Draw(gameTime);
+ }
+
+ private void ValidateHost()
+ {
+ showLoading = true;
+ if ( username == null) { username = ""; }
+ string Host = client.ValidateHost(username);
+ if (Host == null)
+ {
+ messageTitle = "Error";
+ messageText = string.Empty;
+ foreach(string line in client.Output.ToArray()) { messageText += (line + Environment.NewLine); }
+ showOKMessage = true;
+ client.Output.Clear();
+ client.ResetHost();;
+ }
+ else
+ {
+ messageTitle = "Use " + Host + "?";
+ showYNMessage = true;
+ }
+ showLoading = false;
+ }
+
+ private void ConnectHost()
+ {
+ showLoading = true;
+ if (client.ConnectHost())
+ {
+ gameStatus = GameStatus.Indentification;
+ }
+ else
+ {
+ messageTitle = "Error";
+ messageText = string.Empty;
+ foreach (string line in client.Output.ToArray()) { messageText += (line + Environment.NewLine); }
+ showOKMessage = true;
+ client.Output.Clear();
+ client.ResetHost();
+ }
+ showLoading = false;
+ }
+
+ private void IdentifiacateHost()
+ {
+ showLoading = true;
+ if (username != null)
+ {
+ if(username.Length > 3)
+ {
+ client.Output.Clear();
+ client.SendRequest("/connect " + username);
+ bool wait = true;
+ while (wait)
+ {
+ if (client.Output.Count > 0)
+ {
+ wait = false;
+ }
+ }
+ if(client.Output.Contains("Identifiaction succes"))
+ {
+ gameStatus = GameStatus.Game;
+ }
+ else
+ {
+ messageTitle = "Error";
+ messageText = string.Empty;
+ foreach (string line in client.Output.ToArray()) { messageText += (line + Environment.NewLine); }
+ showOKMessage = true;
+ showLoading = false;
+ client.Output.Clear();
+ }
+ }
+ }
+ showLoading = false;
+ }
+
+ private void ChatAdd(string text)
+ {
+ chatText += ((chatText != string.Empty ? Environment.NewLine : "") + text);
+ }
+
+ private void DrawBackground(int index)
+ {
+ if (backgroundX[index] > backSprites[index].Width) { backgroundX[index] = 0; }
+ if (backgroundY[index] > backSprites[index].Height) { backgroundY[index] = 0; }
+ if (backgroundX[index] < 0) { backgroundX[index] = backSprites[index].Width; }
+ if (backgroundY[index] < 0) { backgroundY[index] = backSprites[index].Height; }
+ for (int X = -1; X < ScreenWidth / backSprites[index].Width + 1; X++)
+ {
+ for (int Y = -1; Y < ScreenHeight / backSprites[index].Height + 1; Y++)
+ {
+ GUI.Texture(new Rectangle(X * backSprites[index].Width + (int)backgroundX[index], Y * backSprites[index].Height + (int)backgroundY[index], backSprites[index].Width, backSprites[index].Height), backSprites[index], new MyMonoGame.Colors(Color.White));
+ }
+ }
+ }
+ }
+}
diff --git a/Galactic Colors Control GUI/Icon.ico b/Galactic Colors Control GUI/Icon.ico
new file mode 100644
index 0000000..7d9dec1
Binary files /dev/null and b/Galactic Colors Control GUI/Icon.ico differ
diff --git a/Galactic Colors Control GUI/OpenTK.dll.config b/Galactic Colors Control GUI/OpenTK.dll.config
new file mode 100644
index 0000000..3f888cc
--- /dev/null
+++ b/Galactic Colors Control GUI/OpenTK.dll.config
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Galactic Colors Control GUI/Program.cs b/Galactic Colors Control GUI/Program.cs
new file mode 100644
index 0000000..7360770
--- /dev/null
+++ b/Galactic Colors Control GUI/Program.cs
@@ -0,0 +1,20 @@
+using System;
+
+namespace Galactic_Colors_Control_GUI
+{
+ ///
+ /// The main class.
+ ///
+ public static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ using (var game = new Game1())
+ game.Run();
+ }
+ }
+}
diff --git a/Galactic Colors Control GUI/Properties/AssemblyInfo.cs b/Galactic Colors Control GUI/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..66c2d21
--- /dev/null
+++ b/Galactic Colors Control GUI/Properties/AssemblyInfo.cs
@@ -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("Galactic Colors Control GUI")]
+[assembly: AssemblyProduct("Galactic Colors Control GUI")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyCompany("sheychen")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[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("606d35be-02e8-4a7e-978e-04c2aca6ccd7")]
+
+// 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.1.1")]
+[assembly: AssemblyFileVersion("1.0.1.1")]
diff --git a/Galactic Colors Control GUI/Utilities.cs b/Galactic Colors Control GUI/Utilities.cs
new file mode 100644
index 0000000..da28d29
--- /dev/null
+++ b/Galactic Colors Control GUI/Utilities.cs
@@ -0,0 +1,31 @@
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Graphics;
+using System.IO;
+
+namespace Galactic_Colors_Control_GUI
+{
+ static class Utilities
+ {
+ static public void SpriteFromPng(string path, ref Texture2D sprite, GraphicsDevice graphics)
+ {
+ if (File.Exists(path))
+ {
+ using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
+ {
+ sprite = Texture2D.FromStream(graphics, fileStream);
+ }
+ }
+ }
+
+ static public void SoundFromMp3(string path, ref SoundEffect sound)
+ {
+ if (File.Exists(path))
+ {
+ using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
+ {
+ sound = SoundEffect.FromStream(fileStream);
+ }
+ }
+ }
+ }
+}
diff --git a/Galactic Colors Control Server/App.config b/Galactic Colors Control Server/App.config
index bae5d6d..d1428ad 100644
--- a/Galactic Colors Control Server/App.config
+++ b/Galactic Colors Control Server/App.config
@@ -1,6 +1,6 @@
-
+
diff --git a/Galactic Colors Control Server/Commands/ConnectCommand.cs b/Galactic Colors Control Server/Commands/ConnectCommand.cs
index 5253864..03e36ce 100644
--- a/Galactic Colors Control Server/Commands/ConnectCommand.cs
+++ b/Galactic Colors Control Server/Commands/ConnectCommand.cs
@@ -21,13 +21,24 @@ namespace Galactic_Colors_Control_Server.Commands
if (!Utilities.IsConnect(soc))
{
Logger.Write("Identifiaction request from " + Utilities.GetName(soc), Logger.logType.debug);
- Program.clients[soc].status = 0;
- //args[1] = args[1][0].ToString().ToUpper()[0] + args[1].Substring(1);
- Program.clients[soc].pseudo = args[1];
- Utilities.Send(soc, "Identified as " + args[1], Utilities.dataType.message);
- Utilities.Broadcast(args[1] + " joined the server", Utilities.dataType.message);
- Logger.Write("Identified as " + Utilities.GetName(soc) + " form " + ((IPEndPoint)soc.LocalEndPoint).Address.ToString(), Logger.logType.info);
-
+ bool allreadyconnected = false;
+ foreach(Data client in Program.clients.Values)
+ {
+ if(client.pseudo == args[1]) { allreadyconnected = true; break; }
+ }
+ if (!allreadyconnected)
+ {
+ Program.clients[soc].status = 0;
+ //args[1] = args[1][0].ToString().ToUpper()[0] + args[1].Substring(1);
+ Program.clients[soc].pseudo = args[1];
+ Utilities.Send(soc, "/connected", Utilities.dataType.message);
+ Utilities.Broadcast(args[1] + " joined the server", Utilities.dataType.message);
+ Logger.Write("Identified as " + Utilities.GetName(soc) + " form " + ((IPEndPoint)soc.LocalEndPoint).Address.ToString(), Logger.logType.info);
+ }
+ else
+ {
+ Utilities.Send(soc, "/allreadytaken", Utilities.dataType.message);
+ }
}
else
{
diff --git a/Galactic Colors Control Server/Galactic Colors Control Server.csproj b/Galactic Colors Control Server/Galactic Colors Control Server.csproj
index fe366b8..3845bbe 100644
--- a/Galactic Colors Control Server/Galactic Colors Control Server.csproj
+++ b/Galactic Colors Control Server/Galactic Colors Control Server.csproj
@@ -9,9 +9,11 @@
Properties
Galactic_Colors_Control_Server
Galactic Colors Control Server
- v4.5.2
+ v4.5
512
true
+ false
+
publier\
true
Disk
@@ -24,7 +26,6 @@
true
1
1.0.0.%2a
- false
false
true
diff --git a/Galactic Colors Control Server/Program.cs b/Galactic Colors Control Server/Program.cs
index d8ba8fd..64c5350 100644
--- a/Galactic Colors Control Server/Program.cs
+++ b/Galactic Colors Control Server/Program.cs
@@ -171,29 +171,35 @@ namespace Galactic_Colors_Control_Server
var data = new byte[received];
Array.Copy(buffer, data, received);
- byte[] type = new byte[4];
- type = data.Take(4).ToArray();
- type.Reverse();
- Utilities.dataType dtype = (Utilities.dataType)BitConverter.ToInt32(type, 0);
- byte[] bytes = null;
- bytes = data.Skip(4).ToArray();
- switch (dtype)
- {
- case Utilities.dataType.message:
- string text = Encoding.ASCII.GetString(bytes);
- ExecuteMessage(text, current);
- break;
+ try {
+ byte[] type = new byte[4];
+ type = data.Take(4).ToArray();
+ type.Reverse();
+ Utilities.dataType dtype = (Utilities.dataType)BitConverter.ToInt32(type, 0);
+ byte[] bytes = null;
+ bytes = data.Skip(4).ToArray();
+ switch (dtype)
+ {
+ case Utilities.dataType.message:
+ string text = Encoding.ASCII.GetString(bytes);
+ ExecuteMessage(text, current);
+ break;
- case Utilities.dataType.data:
- Console.WriteLine("data");
- break;
+ case Utilities.dataType.data:
+ Console.WriteLine("data");
+ break;
- default:
- Logger.Write("Unknow type data form" + Utilities.GetName(current), Logger.logType.error);
- break;
+ default:
+ Logger.Write("Unknow type data form" + Utilities.GetName(current), Logger.logType.error);
+ break;
+ }
+
+ if (clients.ContainsKey(current)) { current.BeginReceive(buffer, 0, BUFFER_SIZE, SocketFlags.None, ReceiveCallback, current); }
+ }
+ catch (Exception) {
+ Logger.Write("Client forcefully disconnected from " + Utilities.GetName(current), Logger.logType.info);
+ if (clients.ContainsKey(current)) { clients.Remove(current); }
}
-
- if (clients.ContainsKey(current)) { current.BeginReceive(buffer, 0, BUFFER_SIZE, SocketFlags.None, ReceiveCallback, current); }
}
///
diff --git a/Galactic Colors Control.sln b/Galactic Colors Control.sln
index 0ad449f..b04b58d 100644
--- a/Galactic Colors Control.sln
+++ b/Galactic Colors Control.sln
@@ -7,20 +7,53 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Galactic Colors Control Ser
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Galactic Colors Control", "Galactic Colors Control\Galactic Colors Control.csproj", "{93582CE8-C8C8-4E19-908B-D671ECBADE25}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Galactic Colors Control GUI", "Galactic Colors Control GUI\Galactic Colors Control GUI.csproj", "{F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}"
+ ProjectSection(ProjectDependencies) = postProject
+ {93582CE8-C8C8-4E19-908B-D671ECBADE25} = {93582CE8-C8C8-4E19-908B-D671ECBADE25}
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Galactic Colors Control Console", "Galactic Colors Control Console\Galactic Colors Control Console.csproj", "{5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
+ Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Debug|Any CPU.ActiveCfg = Release|Any CPU
+ {9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Debug|Any CPU.Build.0 = Release|Any CPU
+ {9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Debug|x86.Build.0 = Debug|Any CPU
{9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Release|Any CPU.Build.0 = Release|Any CPU
- {93582CE8-C8C8-4E19-908B-D671ECBADE25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {93582CE8-C8C8-4E19-908B-D671ECBADE25}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Release|x86.ActiveCfg = Release|Any CPU
+ {9E3AF4E1-88C6-4139-A15C-B4F633E80612}.Release|x86.Build.0 = Release|Any CPU
+ {93582CE8-C8C8-4E19-908B-D671ECBADE25}.Debug|Any CPU.ActiveCfg = Release|Any CPU
+ {93582CE8-C8C8-4E19-908B-D671ECBADE25}.Debug|Any CPU.Build.0 = Release|Any CPU
+ {93582CE8-C8C8-4E19-908B-D671ECBADE25}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {93582CE8-C8C8-4E19-908B-D671ECBADE25}.Debug|x86.Build.0 = Debug|Any CPU
{93582CE8-C8C8-4E19-908B-D671ECBADE25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93582CE8-C8C8-4E19-908B-D671ECBADE25}.Release|Any CPU.Build.0 = Release|Any CPU
+ {93582CE8-C8C8-4E19-908B-D671ECBADE25}.Release|x86.ActiveCfg = Release|Any CPU
+ {93582CE8-C8C8-4E19-908B-D671ECBADE25}.Release|x86.Build.0 = Release|Any CPU
+ {F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}.Debug|Any CPU.ActiveCfg = Release|x86
+ {F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}.Debug|Any CPU.Build.0 = Release|x86
+ {F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}.Debug|x86.ActiveCfg = Debug|x86
+ {F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}.Debug|x86.Build.0 = Debug|x86
+ {F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}.Release|Any CPU.ActiveCfg = Release|x86
+ {F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}.Release|Any CPU.Build.0 = Release|x86
+ {F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}.Release|x86.ActiveCfg = Release|x86
+ {F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}.Release|x86.Build.0 = Release|x86
+ {5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}.Debug|x86.Build.0 = Debug|Any CPU
+ {5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}.Release|x86.ActiveCfg = Release|Any CPU
+ {5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Galactic Colors Control/App.config b/Galactic Colors Control/App.config
index bae5d6d..d1428ad 100644
--- a/Galactic Colors Control/App.config
+++ b/Galactic Colors Control/App.config
@@ -1,6 +1,6 @@
-
+
diff --git a/Galactic Colors Control/Galactic Colors Control.csproj b/Galactic Colors Control/Galactic Colors Control.csproj
index d45ce21..3be2765 100644
--- a/Galactic Colors Control/Galactic Colors Control.csproj
+++ b/Galactic Colors Control/Galactic Colors Control.csproj
@@ -5,13 +5,15 @@
Debug
AnyCPU
{93582CE8-C8C8-4E19-908B-D671ECBADE25}
- Exe
+ Library
Properties
Galactic_Colors_Control
Galactic Colors Control
- v4.5.2
+ v4.5
512
true
+ false
+
publier\
true
Disk
@@ -24,7 +26,6 @@
true
0
1.0.0.%2a
- false
false
true
@@ -47,6 +48,10 @@
prompt
4
+
+
+
+
diff --git a/Galactic Colors Control/Program.cs b/Galactic Colors Control/Program.cs
index f13d6c0..4d956a6 100644
--- a/Galactic Colors Control/Program.cs
+++ b/Galactic Colors Control/Program.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
@@ -8,156 +9,150 @@ using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;
-namespace Galactic_Colors_Control_Client
+namespace Galactic_Colors_Control
{
- internal class Program
+ public class Client
{
- private static readonly Socket ClientSocket = new Socket
+ private Socket ClientSocket = new Socket
(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- private static int PORT = 0;
- private static int _errorCount = 0;
- private static bool _run = true;
- private static string IP = null;
+ public int PORT = 0;
+ private int _errorCount = 0;
+ private bool _run = true;
+ public string IP = null;
+
+ public bool isRunning { get { return _run; } }
private enum dataType { message, data };
- private static void Main()
+ public List Output = new List();
+
+ private Thread RecieveThread;
+
+ public void ResetHost()
{
- Console.Title = "Galactic Colors Control Client";
- Console.Write(">");
- ConnectToServer();
- RequestLoop();
- Exit();
+ IP = null;
+ PORT = 0;
}
- private static void ConnectToServer()
+ public string ValidateHost(string text)
{
- int attempts = 0;
-
- while (IP == null)
+ if (text == null) { text = ""; }
+ string[] parts = text.Split(new char[] { ':' }, 2, StringSplitOptions.RemoveEmptyEntries);
+ if (parts.Length == 0)
{
- ConsoleWrite(Environment.NewLine + "Enter server host:");
- string text = Console.ReadLine();
- string[] parts = text.Split(new char[] {':'}, 2, StringSplitOptions.RemoveEmptyEntries);
- if (parts.Length == 0)
+ parts = new string[] { "" };
+ PORT = 25001;
+ }
+ else
+ {
+ if (parts.Length > 1)
+ {
+ if (!int.TryParse(parts[1], out PORT)) { PORT = 0; }
+ if (PORT < 0 || PORT > 65535) { PORT = 0; }
+ }
+ else
{
- parts = new string[] { "" };
PORT = 25001;
}
- else
+ }
+ if (PORT != 0)
+ {
+ try
{
- if (parts.Length > 1)
- {
- if (!int.TryParse(parts[1], out PORT)) { PORT = 0; }
- if (PORT < 0 || PORT > 65535) { PORT = 0; }
- }
- else
- {
- PORT = 25001;
- }
+ IPHostEntry ipHostEntry = Dns.GetHostEntry(parts[0]);
+ IPAddress host = ipHostEntry.AddressList.First(a => a.AddressFamily == AddressFamily.InterNetwork);
+ IP = host.ToString();
+ return IP + ":" + PORT;
}
- if (PORT != 0)
+ catch (Exception e)
{
- try
- {
- IPHostEntry ipHostEntry = Dns.GetHostEntry(parts[0]);
- IPAddress host = ipHostEntry.AddressList.First(a => a.AddressFamily == AddressFamily.InterNetwork);
- ConsoleWrite("Use " + host.ToString() + ":" + PORT + "? y/n");
- ConsoleKey key = ConsoleKey.NoName;
- while (key != ConsoleKey.Y && key != ConsoleKey.N)
- {
- key = Console.ReadKey().Key;
- }
- if (key == ConsoleKey.Y)
- {
- IP = host.ToString();
- }
- else
- {
- PORT = 0;
- }
- }
- catch (Exception e)
- {
- ConsoleWrite(e.Message);
- PORT = 0;
- }
- }
- else
- {
- ConsoleWrite("Incorrect port");
+ Output.Add(e.Message);
+ PORT = 0;
+ return null;
}
}
+ else
+ {
+ Output.Add("Incorrect port");
+ return null;
+ }
+ }
+
+ ///
+ /// Set IP and PORT before
+ ///
+ /// Connection succes
+ public bool ConnectHost()
+ {
+ int attempts = 0;
while (!ClientSocket.Connected && attempts < 5)
{
try
{
attempts++;
- ConsoleWrite("Connection attempt " + attempts);
+ Output.Add("Connection attempt " + attempts);
ClientSocket.Connect(IP, PORT);
}
catch (SocketException)
{
- Console.Clear();
+ Output.Clear();
}
}
if (attempts < 5)
{
- Console.Clear();
- ConsoleWrite("Connected to " + IP.ToString());
+ Output.Clear();
+ Output.Add("Connected to " + IP.ToString());
+ _run = true;
+ RecieveThread = new Thread(ReceiveLoop);
+ RecieveThread.Start();
+ return true;
}
else
{
- Console.Clear();
- ConsoleWrite("Can't connected to " + IP.ToString());
- ClientSocket.Close();
- ConsoleWrite("Press Enter to quit");
- Console.Read();
- Environment.Exit(0);
+ Output.Clear();
+ Output.Add("Can't connected to " + IP.ToString());
+ ResetSocket();
+ return false;
}
}
- private static void RequestLoop()
+ private void ResetSocket()
{
- Thread ReceiveThread = new Thread(new ThreadStart(ReceiveLoop));
- ReceiveThread.Start();
- while (_run)
- {
- SendRequest();
- }
- ReceiveThread.Join();
- if (_errorCount >= 5)
- {
- ConsoleWrite("Exit: Too much network errors");
- }
+ ClientSocket.Close();
+ ClientSocket = new Socket
+ (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
}
///
/// Close socket and exit program.
///
- private static void Exit()
+ public void ExitHost()
{
Send("/exit", dataType.message); // Tell the server we are exiting
+ _run = false;
+ RecieveThread.Join();
ClientSocket.Shutdown(SocketShutdown.Both);
ClientSocket.Close();
- ConsoleWrite("Bye");
- Console.ReadLine();
- Environment.Exit(0);
+ Output.Add("Bye");
+ ResetHost();
}
- private static void SendRequest()
+ public void SendRequest(string request)
{
- string request = Console.ReadLine();
switch (request.ToLower())
{
case "/exit":
- Exit();
+ ExitHost();
break;
case "/ping":
- Ping();
+ PingHost();
+ break;
+
+ case "/clear":
+ Output.Add("/clear");
break;
default:
@@ -166,7 +161,7 @@ namespace Galactic_Colors_Control_Client
}
}
- private static void Ping()
+ private void PingHost()
{
Ping p = new Ping();
PingReply r;
@@ -175,15 +170,15 @@ namespace Galactic_Colors_Control_Client
if (r.Status == IPStatus.Success)
{
- Console.WriteLine(r.RoundtripTime.ToString() + " ms.");
+ Output.Add(r.RoundtripTime.ToString() + " ms.");
}
else
{
- Console.WriteLine("Time out");
+ Output.Add("Time out");
}
}
- private static void Send(object data, dataType dtype)
+ private void Send(object data, dataType dtype)
{
byte[] type = new byte[4];
type = BitConverter.GetBytes((int)dtype);
@@ -212,23 +207,17 @@ namespace Galactic_Colors_Control_Client
}
catch
{
- ConsoleWrite("Can't contact server : " + _errorCount);
+ Output.Add("Can't contact server : " + _errorCount);
_errorCount++;
}
if (_errorCount >= 5)
{
+ Output.Add("Kick : too_much_errors");
_run = false;
}
}
- private static void ConsoleWrite(string v)
- {
- Console.Write("\b");
- Console.WriteLine(v);
- Console.Write(">");
- }
-
- private static void ReceiveLoop()
+ private void ReceiveLoop()
{
while (_run)
{
@@ -240,7 +229,7 @@ namespace Galactic_Colors_Control_Client
}
catch
{
- ConsoleWrite("Server timeout");
+ Output.Add("Server timeout");
}
if (received == 0) return;
_errorCount = 0;
@@ -263,26 +252,34 @@ namespace Galactic_Colors_Control_Client
string[] array = text.Split(new char[1] { ' ' }, 4, StringSplitOptions.RemoveEmptyEntries);
switch (array[0])
{
+ case "connected":
+ Output.Add("Identifiaction succes");
+ break;
+
+ case "allreadytaken":
+ Output.Add("Username Allready Taken");
+ break;
+
case "kick":
if (array.Length > 1)
{
- ConsoleWrite("Kick : " + array[1]);
+ Output.Add("Kick : " + array[1]);
}
else
{
- ConsoleWrite("Kick by server");
+ Output.Add("Kick by server");
}
_run = false;
break;
default:
- Console.WriteLine("Unknown action from server");
+ Output.Add("Unknown action from server");
break;
}
}
else
{
- ConsoleWrite(text);
+ Output.Add(text);
}
break;
@@ -292,6 +289,7 @@ namespace Galactic_Colors_Control_Client
}
Thread.Sleep(200);
}
+ Output.Add("/*exit*/");
}
}
}
\ No newline at end of file
diff --git a/Galactic Colors Control/Properties/AssemblyInfo.cs b/Galactic Colors Control/Properties/AssemblyInfo.cs
index b50f01c..287b513 100644
--- a/Galactic Colors Control/Properties/AssemblyInfo.cs
+++ b/Galactic Colors Control/Properties/AssemblyInfo.cs
@@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Galactic Colors Control")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
+[assembly: AssemblyCompany("sheychen")]
[assembly: AssemblyProduct("Galactic Colors Control")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
@@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.0")]
-[assembly: AssemblyFileVersion("1.0.1.0")]
+[assembly: AssemblyFileVersion("1.0.1.0")]
\ No newline at end of file
diff --git a/Readme.md b/Readme.md
index a8067c7..611f428 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,7 +1,6 @@
# Galactic Colors Control
GCC is a cross plateforme C# minimal RTS.
-Using .Net/[Mono](https://github.com/mono/mono) and [Monogame](https://github.com/MonoGame/MonoGame)
### Prerequisities
@@ -39,6 +38,13 @@ As you wish, I am opened to new ideas.
See also the list of [contributors](https://github.com/sheychen290/Galactic_Colors_Control/contributors) who participated in this project.
+## Using
+
+* .Net/[Mono](https://github.com/mono/mono)
+* [Monogame](https://github.com/MonoGame/MonoGame)
+* [MyMonoGame.GUI](https://github.com/sheychen290/MyMonoGame)
+* [Space Sprites](https://gamedevelopment.tutsplus.com/articles/enjoy-these-totally-free-space-based-shoot-em-up-sprites--gamedev-2368)
+
## License
-This project is licensed under the MIT License - see the [License.md](License.md) file for details
+This project is licensed under the MIT License - see the [License.md](License.md) file for details
\ No newline at end of file