Merge branch 'ClientLib'
Conflicts: Galactic Colors Control/Properties/AssemblyInfo.cs Readme.mdmaster
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5D6A09D1-DCAB-4FD8-B4E6-62D9F41AE8F0}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Galactic_Colors_Control_Console</RootNamespace>
|
||||
<AssemblyName>Galactic Colors Control Console</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</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.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Galactic Colors Control\Galactic Colors Control.csproj">
|
||||
<Project>{93582ce8-c8c8-4e19-908b-d671ecbade25}</Project>
|
||||
<Name>Galactic Colors Control</Name>
|
||||
</ProjectReference>
|
||||
</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>
|
|
@ -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(">");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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")]
|
|
@ -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
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>Trebuchet MS</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>16</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>Tahoma</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>8</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>MV Boli</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>50</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
After Width: | Height: | Size: 167 B |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 297 B |
After Width: | Height: | Size: 167 B |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 173 B |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 305 B |
After Width: | Height: | Size: 300 B |
After Width: | Height: | Size: 252 B |
After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 206 KiB |
After Width: | Height: | Size: 25 KiB |
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F6CDDF1B-5A57-4A84-B57C-749FFF9AE031}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Galactic_Colors_Control_GUI</RootNamespace>
|
||||
<AssemblyName>Galactic Colors Control GUI</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MonoGamePlatform>DesktopGL</MonoGamePlatform>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;LINUX</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\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<DefineConstants>TRACE;LINUX</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Game1.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utilities.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MyMonoGame">
|
||||
<HintPath>..\..\MonoGame\MyMonoGameGUI\MyMonoGameGUI\bin\Release\MyMonoGame.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK">
|
||||
<HintPath>$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NVorbis">
|
||||
<HintPath>$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\NVorbis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MonoGame.Framework">
|
||||
<HintPath>$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Icon.ico" />
|
||||
<Content Include="Content\Textures\background1.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\background0.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\Buttons\0\topLeft.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\Buttons\0\topCenter.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\Buttons\0\topRight.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\Buttons\0\centerLeft.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\Buttons\0\centerCenter.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\Buttons\0\centerRight.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\Buttons\0\bottomLeft.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\Buttons\0\bottomCenter.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\Buttons\0\bottomRight.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\Hub\pointer0.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Textures\LogoSmall.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="OpenTK.dll.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="Content\Content.mgcb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Galactic Colors Control\Galactic Colors Control.csproj">
|
||||
<Project>{93582ce8-c8c8-4e19-908b-d671ecbade25}</Project>
|
||||
<Name>Galactic Colors Control</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.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>
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the main type for your game.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
protected override void Initialize()
|
||||
{
|
||||
nullSprite = new Texture2D(GraphicsDevice, 1, 1);
|
||||
nullSprite.SetData(new Color[1 * 1] { Color.White });
|
||||
|
||||
GUI.Initialise();
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LoadContent will be called once per game and is the place to load
|
||||
/// all of your content.
|
||||
/// </summary>
|
||||
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<SoundEffect>("Sounds/alert");
|
||||
effects[1] = content.Load<SoundEffect>("Sounds/bip");
|
||||
effects[2] = content.Load<SoundEffect>("Sounds/change");
|
||||
effects[3] = content.Load<SoundEffect>("Sounds/valid");
|
||||
|
||||
smallFont = content.Load<SpriteFont>("Fonts/small");
|
||||
basicFont = content.Load<SpriteFont>("Fonts/basic");
|
||||
titleFont = content.Load<SpriteFont>("Fonts/title");
|
||||
|
||||
for (int i = 0; i < pointerSprites.Length; i++) {
|
||||
pointerSprites[i] = content.Load<Texture2D>("Textures/Hub/pointer" + i);
|
||||
}
|
||||
|
||||
backSprites[0] = content.Load<Texture2D>("Textures/background0");
|
||||
backSprites[1] = content.Load<Texture2D>("Textures/background1");
|
||||
|
||||
logoSprite = content.Load<Texture2D>("Textures/LogoSmall");
|
||||
|
||||
for (int i = 0; i < buttonsSprites.Length; i++)
|
||||
{
|
||||
buttonsSprites[i].topLeft = content.Load<Texture2D>("Textures/Hub/Buttons/" + i + "/topLeft");
|
||||
buttonsSprites[i].topCenter = content.Load<Texture2D>("Textures/Hub/Buttons/" + i + "/topCenter");
|
||||
buttonsSprites[i].topRight = content.Load<Texture2D>("Textures/Hub/Buttons/" + i + "/topRight");
|
||||
buttonsSprites[i].centerLeft = content.Load<Texture2D>("Textures/Hub/Buttons/" + i + "/centerLeft");
|
||||
buttonsSprites[i].centerCenter = content.Load<Texture2D>("Textures/Hub/Buttons/" + i + "/centerCenter");
|
||||
buttonsSprites[i].centerRight = content.Load<Texture2D>("Textures/Hub/Buttons/" + i + "/centerRight");
|
||||
buttonsSprites[i].bottomLeft = content.Load<Texture2D>("Textures/Hub/Buttons/" + i + "/bottomLeft");
|
||||
buttonsSprites[i].bottomCenter = content.Load<Texture2D>("Textures/Hub/Buttons/" + i + "/bottomCenter");
|
||||
buttonsSprites[i].bottomRight = content.Load<Texture2D>("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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UnloadContent will be called once per game and is the place to unload
|
||||
/// game-specific content.
|
||||
/// </summary>
|
||||
protected override void UnloadContent()
|
||||
{
|
||||
// TODO: Unload any non ContentManager content here
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the game to run logic such as updating the world,
|
||||
/// checking for collisions, gathering input, and playing audio.
|
||||
/// </summary>
|
||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called when the game should draw itself.
|
||||
/// </summary>
|
||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 144 KiB |
|
@ -0,0 +1,25 @@
|
|||
<configuration>
|
||||
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
|
||||
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
|
||||
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
|
||||
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
|
||||
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
|
||||
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
|
||||
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
|
||||
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0.disabled"/>
|
||||
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
|
||||
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
|
||||
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
|
||||
<!-- XQuartz compatibility (X11 on Mac) -->
|
||||
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
|
||||
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
|
||||
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
|
||||
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
|
||||
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
|
||||
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
|
||||
</configuration>
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
|
||||
namespace Galactic_Colors_Control_GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// The main class.
|
||||
/// </summary>
|
||||
public static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
using (var game = new Game1())
|
||||
game.Run();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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")]
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Galactic_Colors_Control_Server</RootNamespace>
|
||||
<AssemblyName>Galactic Colors Control Server</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<TargetFrameworkProfile />
|
||||
<PublishUrl>publier\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
|
@ -24,7 +26,6 @@
|
|||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>1</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -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); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
|
|
|
@ -5,13 +5,15 @@
|
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{93582CE8-C8C8-4E19-908B-D671ECBADE25}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Galactic_Colors_Control</RootNamespace>
|
||||
<AssemblyName>Galactic Colors Control</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<TargetFrameworkProfile />
|
||||
<PublishUrl>publier\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
|
@ -24,7 +26,6 @@
|
|||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
|
@ -47,6 +48,10 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -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<string> Output = new List<string>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set IP and PORT before
|
||||
/// </summary>
|
||||
/// <returns>Connection succes</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close socket and exit program.
|
||||
/// </summary>
|
||||
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*/");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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")]
|
10
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
|