Merge remote-tracking branch 'remotes/origin/release-0.3' into develop

This commit is contained in:
Alexander Eckart committed 2013-07-03 19:35:42 +02:00
commit 84fc0fcb91
51 files changed
+892 -872

No files matched your search

+6 -2
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidRemote", "AndroidRemote\AndroidRemote.csproj", "{D97EF6F3-7C3F-439F-B022-647948E206D2}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vocaluxe App", "AndroidRemote\Vocaluxe App.csproj", "{D97EF6F3-7C3F-439F-B022-647948E206D2}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +15,10 @@ Global
{D97EF6F3-7C3F-439F-B022-647948E206D2}.Release|Any CPU.Build.0 = Release|Any CPU {D97EF6F3-7C3F-439F-B022-647948E206D2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = AndroidRemote.csproj StartupItem = AndroidRemote\Vocaluxe App.csproj
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = None
$1.ResourceNamePolicy = FileFormatDefault
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
@@ -1,99 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D97EF6F3-7C3F-439F-B022-647948E206D2}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>AndroidRemote</RootNamespace>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AssemblyName>AndroidRemote</AssemblyName>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<ConsolePause>false</ConsolePause>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<DefineConstants>MONO</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
<Reference Include="Newtonsoft.Json.MonoDroid">
<HintPath>Newtonsoft.Json.MonoDroid.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\ClientServerLib\CClient.cs">
<Link>ClientServerLib\CClient.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\CConnection.cs">
<Link>ClientServerLib\CConnection.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\Structs.cs">
<Link>ClientServerLib\Structs.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\BigInt.cs">
<Link>ClientServerLib\DeffieHellman\BigInt.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\DeffieHellman.cs">
<Link>ClientServerLib\DeffieHellman\DeffieHellman.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\StrongNumberProvider.cs">
<Link>ClientServerLib\DeffieHellman\StrongNumberProvider.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\CDiscover.cs">
<Link>ClientServerLib\CDiscover.cs</Link>
</Compile>
<Compile Include="..\..\Vocaluxe\Base\Server\CCommands.cs">
<Link>ClientServerLib\Server\CCommands.cs</Link>
</Compile>
<Compile Include="..\..\Vocaluxe\Base\Server\VocaluxeStructs.cs">
<Link>ClientServerLib\Server\VocaluxeStructs.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
<None Include="Properties\AndroidManifest.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\Main.axml" />
<AndroidResource Include="Resources\values\Strings.xml" />
<AndroidResource Include="Resources\drawable\Icon.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup>
<Folder Include="ClientServerLib\" />
<Folder Include="Assets\" />
<Folder Include="ClientServerLib\Vocaluxe\" />
<Folder Include="ClientServerLib\Server\" />
</ItemGroup>
</Project>
+116 -98
View File
@@ -14,24 +14,29 @@ using Android.Provider;
using ClientServerLib; using ClientServerLib;
using Vocaluxe.Base.Server; using Vocaluxe.Base.Server;
namespace AndroidRemote namespace org.vocaluxe.app
{ {
[Activity (Label = "Vocaluxe Remote", MainLauncher = true, ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation)] [Activity (Label = "Vocaluxe App", MainLauncher = true, ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation)]
public class Activity1 : Activity public class Activity1 : Activity
{ {
private readonly int REQUEST_TAKE_PICTURE = 1;
private readonly int REQUEST_PICK_PICTURE = 2;
CClient client = new CClient(); CClient client = new CClient();
CDiscover discover;
Button bConnect; Button bConnect;
Button bLogin;
Button bSendAvatar; Button bSendAvatar;
Button bSendProfile; Button bSendProfile;
TextView tIP; TextView tIP;
TextView tPassword; TextView tPassword;
bool loggedIn; ProgressDialog pDialog;
byte[] fileBytes; byte[] fileBytes;
Java.IO.File file; Java.IO.File file;
Java.IO.File file2;
Java.IO.File dir; Java.IO.File dir;
System.IO.FileStream fs; System.IO.FileStream fs;
@@ -41,16 +46,15 @@ namespace AndroidRemote
{ {
base.OnCreate (bundle); base.OnCreate (bundle);
loggedIn = false;
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main); SetContentView (Resource.Layout.Main);
pDialog = new ProgressDialog (this);
pDialog.SetCancelable (false);
bConnect = FindViewById<Button> (Resource.Id.btConnect); bConnect = FindViewById<Button> (Resource.Id.btConnect);
bConnect.Click += delegate { Connect(); }; bConnect.Click += delegate { Connect(); };
bLogin = FindViewById<Button> (Resource.Id.btLogin); Button bDiscover = FindViewById<Button> (Resource.Id.btDiscover);
bLogin.Click += delegate { Login(); }; bDiscover.Click += delegate { Discover(); };
bSendAvatar = FindViewById<Button> (Resource.Id.btSendAvatar); bSendAvatar = FindViewById<Button> (Resource.Id.btSendAvatar);
bSendAvatar.Click += SendAvatar; bSendAvatar.Click += SendAvatar;
@@ -62,6 +66,9 @@ namespace AndroidRemote
tPassword = FindViewById<TextView> (Resource.Id.tbPassword); tPassword = FindViewById<TextView> (Resource.Id.tbPassword);
sendProfile = false; sendProfile = false;
discover = new CDiscover(3000, CCommands.BroadcastKeyword);
Discover ();
} }
protected override void OnStop () protected override void OnStop ()
@@ -72,19 +79,55 @@ namespace AndroidRemote
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{ {
base.OnActivityResult(requestCode, resultCode, data); //base.OnActivityResult(requestCode, resultCode, data);
if (resultCode != Result.Ok)
return;
// make it available in the gallery if (requestCode == REQUEST_TAKE_PICTURE)
Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile); {
Android.Net.Uri contentUri = Android.Net.Uri.FromFile(file); // make it available in the gallery
mediaScanIntent.SetData(contentUri); //Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
SendBroadcast(mediaScanIntent); Android.Net.Uri contentUri = Android.Net.Uri.FromFile(file);
System.IO.FileInfo fi = new System.IO.FileInfo(file.Path); //mediaScanIntent.SetData(contentUri);
fs = new System.IO.FileStream(file.Path, System.IO.FileMode.Open); //SendBroadcast(mediaScanIntent);
fileBytes = new byte[fi.Length];
fs.BeginRead (fileBytes, 0, (int)fi.Length, new AsyncCallback(OnFileRead), null); Java.IO.File dir2 = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), Resources.GetString(Resource.String.app_name));
if (!dir.Exists())
{
dir.Mkdirs();
}
file2 = new Java.IO.File(dir, String.Format("myPhoto_{0}.jpg", Guid.NewGuid()));
Intent picker = new Intent ("com.android.camera.action.CROP");
//Intent picker = new Intent (Intent.ActionGetContent, contentUri);
picker.SetDataAndType (contentUri, "image/*");
picker.PutExtra ("crop", "true");
picker.PutExtra ("aspectX", 1);
picker.PutExtra ("aspectY", 1);
picker.PutExtra ("outputX", 512);
picker.PutExtra ("outputY", 512);
picker.PutExtra ("return-data", false);
//picker.PutExtra ("outputFormat", Bitmap.CompressFormat.Jpeg.ToString ());
picker.PutExtra ("noFaceDetection", true);
picker.PutExtra (MediaStore.ExtraOutput, Android.Net.Uri.FromFile(file2));
StartActivityForResult (picker, REQUEST_PICK_PICTURE);
}
if (requestCode == REQUEST_PICK_PICTURE)
{
if (data.Extras != null)
{
System.IO.FileInfo fi = new System.IO.FileInfo(file2.Path);
fs = new System.IO.FileStream(file2.Path, System.IO.FileMode.Open);
fileBytes = new byte[fi.Length];
fs.BeginRead (fileBytes, 0, (int)fi.Length, new AsyncCallback(OnFileRead), null);
fi = null;
}
}
} }
private void OnFileRead(IAsyncResult ar) private void OnFileRead(IAsyncResult ar)
{ {
if (fileBytes == null) if (fileBytes == null)
@@ -93,6 +136,12 @@ namespace AndroidRemote
fs.Flush(); fs.Flush();
fs.Close(); fs.Close();
if (file != null)
file.Delete ();
if (file2 != null)
file2.Delete ();
if (sendProfile) if (sendProfile)
{ {
sendProfile = false; sendProfile = false;
@@ -100,7 +149,6 @@ namespace AndroidRemote
if (tv.Text == String.Empty) if (tv.Text == String.Empty)
return; return;
client.SendMessage (CCommands.CreateCommandSendProfile(fileBytes, tv.Text, 0), OnResponse); client.SendMessage (CCommands.CreateCommandSendProfile(fileBytes, tv.Text, 0), OnResponse);
} }
else else
@@ -116,41 +164,53 @@ namespace AndroidRemote
private void SendAvatar(object sender, EventArgs eventArgs) private void SendAvatar(object sender, EventArgs eventArgs)
{ {
_TakePicture (false);
}
private void SendProfile(object sender, EventArgs eventArgs)
{
_TakePicture (true);
}
private void _TakePicture(bool SendProfile)
{
sendProfile = SendProfile;
if (!IsThereAnAppToTakePictures()) if (!IsThereAnAppToTakePictures())
return; return;
Intent intent = new Intent(MediaStore.ActionImageCapture); Intent intent = new Intent(MediaStore.ActionImageCapture);
dir = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "AndroidRemote"); dir = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), Resources.GetString(Resource.String.app_name));
if (dir.Exists()) if (!dir.Exists())
{ {
dir.Mkdirs(); dir.Mkdirs();
} }
file = new Java.IO.File(dir, String.Format("myPhoto_{0}.jpg", Guid.NewGuid())); file = new Java.IO.File(dir, String.Format("myPhoto_{0}.jpg", Guid.NewGuid()));
intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(file)); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(file));
StartActivityForResult(intent, 0); StartActivityForResult(intent, REQUEST_TAKE_PICTURE);
}
private void SendProfile(object sender, EventArgs eventArgs)
{
sendProfile = true;
SendAvatar(sender, eventArgs);
} }
private void Connect() private void Connect()
{ {
if (!client.Connected) if (!client.Connected)
client.Connect(tIP.Text, 3000, OnConnectionChanged); {
pDialog.SetMessage ("Connecting for Server...");
pDialog.Show ();
client.Connect(tIP.Text, 3000, tPassword.Text, OnConnectionChanged);
}
else else
{
pDialog.Hide ();
client.Disconnect(); client.Disconnect();
}
} }
private void Login() private void Discover()
{ {
if (!loggedIn) pDialog.SetMessage ("Searching for Server...");
client.SendMessage (CCommands.CreateCommandLogin(tPassword.Text), OnResponse); pDialog.Show ();
else discover.Discover (_OnDiscovered);
client.Disconnect();
} }
private void OnConnectionChanged(bool Connected) private void OnConnectionChanged(bool Connected)
@@ -169,18 +229,6 @@ namespace AndroidRemote
int command = BitConverter.ToInt32(Message, 0); int command = BitConverter.ToInt32(Message, 0);
switch (command) switch (command)
{ {
case CCommands.ResponseLoginFailed:
RunOnUiThread (() => Toast.MakeText(this, Resources.GetString(Resource.String.message_login_failed), ToastLength.Short).Show());
break;
case CCommands.ResponseLoginWrongPassword:
RunOnUiThread (() => Toast.MakeText(this, Resources.GetString(Resource.String.message_wrong_password), ToastLength.Short).Show());
break;
case CCommands.ResponseLoginOK:
RunOnUiThread (() => UpdateLoginStatus(true));
break;
case CCommands.ResponseOK: case CCommands.ResponseOK:
RunOnUiThread (() => Toast.MakeText(this, Resources.GetString(Resource.String.message_ok), ToastLength.Short).Show()); RunOnUiThread (() => Toast.MakeText(this, Resources.GetString(Resource.String.message_ok), ToastLength.Short).Show());
break; break;
@@ -194,73 +242,43 @@ namespace AndroidRemote
} }
} }
private void _OnDiscovered(string Address, string HostName)
{
RunOnUiThread (() =>
{
if (Address != CDiscover.sTimeout && Address != CDiscover.sFinished)
{
tIP.Text = Address;
Connect ();
}
else if (Address == CDiscover.sTimeout)
{
pDialog.Hide ();
Toast.MakeText(this, "Cant't find any Vocaluxe Server", ToastLength.Short).Show();
}
});
}
private void UpdateConnectionStatus(bool Connected) private void UpdateConnectionStatus(bool Connected)
{ {
if (Connected) if (Connected)
{ {
bLogin.Enabled = true; pDialog.Hide ();
bConnect.Text = Resources.GetString(Resource.String.button_disconnect); bConnect.Text = Resources.GetString(Resource.String.button_disconnect);
Toast.MakeText(this, Resource.String.message_connected, ToastLength.Short).Show(); Toast.MakeText(this, Resource.String.message_connected, ToastLength.Short).Show();
bSendAvatar.Enabled = true;
bSendProfile.Enabled = true;
} }
else else
{ {
pDialog.Hide ();
client.Disconnect(); client.Disconnect();
bLogin.Enabled = false;
bLogin.Text = Resources.GetString(Resource.String.button_login);
bConnect.Text = Resources.GetString(Resource.String.button_connect); bConnect.Text = Resources.GetString(Resource.String.button_connect);
bSendAvatar.Enabled = false; bSendAvatar.Enabled = false;
bSendProfile.Enabled = false; bSendProfile.Enabled = false;
Toast.MakeText(this, Resources.GetString(Resource.String.message_disconnected), ToastLength.Short).Show(); Toast.MakeText(this, Resources.GetString(Resource.String.message_disconnected), ToastLength.Short).Show();
} }
} }
private void UpdateLoginStatus(bool LoggedIn)
{
loggedIn = LoggedIn;
if (LoggedIn)
{
bLogin.Text = Resources.GetString(Resource.String.button_logout);
Toast.MakeText(this, Resources.GetString(Resource.String.message_logged_in), ToastLength.Short).Show();
bSendAvatar.Enabled = true;
bSendProfile.Enabled = true;
}
else
{
Toast.MakeText(this, Resources.GetString(Resource.String.message_logged_out), ToastLength.Short).Show();
bSendAvatar.Enabled = false;
bSendProfile.Enabled = false;
}
}
}
public static class BitmapHelpers
{
public static Bitmap LoadAndResizeBitmap(this string fileName, int width, int height)
{
// First we get the the dimensions of the file on disk
BitmapFactory.Options options = new BitmapFactory.Options { InJustDecodeBounds = true };
BitmapFactory.DecodeFile(fileName, options);
// Next we calculate the ratio that we need to resize the image by
// in order to fit the requested dimensions.
int outHeight = options.OutHeight;
int outWidth = options.OutWidth;
int inSampleSize = 1;
if (outHeight > height || outWidth > width)
{
inSampleSize = outWidth > outHeight
? outHeight / height
: outWidth / width;
}
// Now we will load the image and have BitmapFactory resize it for us.
options.InSampleSize = inSampleSize;
options.InJustDecodeBounds = false;
Bitmap resizedBitmap = BitmapFactory.DecodeFile(fileName, options);
return resizedBitmap;
}
} }
} }
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="AndroidRemote.AndroidRemote"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="0.1" package="org.vocaluxe.app">
<uses-sdk /> <uses-sdk />
<application android:label="AndroidRemote" android:icon="@drawable/icon"></application> <application android:label="Vocaluxe App" android:icon="@drawable/icon"></application>
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest> </manifest>
@@ -5,7 +5,7 @@ using Android.App;
// Information about this assembly is defined by the following attributes. // Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project. // Change them to the values specific to your project.
[assembly: AssemblyTitle("AndroidRemote")] [assembly: AssemblyTitle("Vocaluxe App")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
+46 -86
View File
@@ -2,16 +2,16 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// Dieser Code wurde von einem Tool generiert. // Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18034 // Laufzeitversion:4.0.30319.18047
// //
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird. // der Code erneut generiert wird.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
[assembly: global::Android.Runtime.ResourceDesignerAttribute("AndroidRemote.Resource", IsApplication=true)] [assembly: global::Android.Runtime.ResourceDesignerAttribute("org.vocaluxe.app.Resource", IsApplication=true)]
namespace AndroidRemote namespace org.vocaluxe.app
{ {
@@ -47,9 +47,6 @@ namespace AndroidRemote
// aapt resource value: 0x7f020000 // aapt resource value: 0x7f020000
public const int Icon = 2130837504; public const int Icon = 2130837504;
// aapt resource value: 0x7f020001
public const int monoandroidsplash = 2130837505;
static Drawable() static Drawable()
{ {
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); global::Android.Runtime.ResourceIdManager.UpdateIdValues();
@@ -63,35 +60,35 @@ namespace AndroidRemote
public partial class Id public partial class Id
{ {
// aapt resource value: 0x7f060002 // aapt resource value: 0x7f050004
public const int btConnect = 2131099650; public const int btConnect = 2131034116;
// aapt resource value: 0x7f060005 // aapt resource value: 0x7f050005
public const int btLogin = 2131099653; public const int btDiscover = 2131034117;
// aapt resource value: 0x7f060006 // aapt resource value: 0x7f050006
public const int btSendAvatar = 2131099654; public const int btSendAvatar = 2131034118;
// aapt resource value: 0x7f060009 // aapt resource value: 0x7f050009
public const int btSendProfile = 2131099657; public const int btSendProfile = 2131034121;
// aapt resource value: 0x7f060001 // aapt resource value: 0x7f050001
public const int tbIP = 2131099649; public const int tbIP = 2131034113;
// aapt resource value: 0x7f060004 // aapt resource value: 0x7f050003
public const int tbPassword = 2131099652; public const int tbPassword = 2131034115;
// aapt resource value: 0x7f060008 // aapt resource value: 0x7f050008
public const int tbPlayerName = 2131099656; public const int tbPlayerName = 2131034120;
// aapt resource value: 0x7f060000 // aapt resource value: 0x7f050000
public const int textView1 = 2131099648; public const int textView1 = 2131034112;
// aapt resource value: 0x7f060003 // aapt resource value: 0x7f050002
public const int textView2 = 2131099651; public const int textView2 = 2131034114;
// aapt resource value: 0x7f060007 // aapt resource value: 0x7f050007
public const int textView3 = 2131099655; public const int textView3 = 2131034119;
static Id() static Id()
{ {
@@ -109,9 +106,6 @@ namespace AndroidRemote
// aapt resource value: 0x7f030000 // aapt resource value: 0x7f030000
public const int Main = 2130903040; public const int Main = 2130903040;
// aapt resource value: 0x7f030001
public const int monoandroidsplash = 2130903041;
static Layout() static Layout()
{ {
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); global::Android.Runtime.ResourceIdManager.UpdateIdValues();
@@ -135,55 +129,37 @@ namespace AndroidRemote
public const int button_disconnect = 2130968578; public const int button_disconnect = 2130968578;
// aapt resource value: 0x7f040003 // aapt resource value: 0x7f040003
public const int button_login = 2130968579; public const int button_send_avatar = 2130968579;
// aapt resource value: 0x7f040004 // aapt resource value: 0x7f040004
public const int button_logout = 2130968580; public const int button_send_profile = 2130968580;
// aapt resource value: 0x7f040005
public const int button_send_avatar = 2130968581;
// aapt resource value: 0x7f040006
public const int button_send_profile = 2130968582;
// aapt resource value: 0x7f040012
public const int ip_address = 2130968594;
// aapt resource value: 0x7f040007
public const int message_connected = 2130968583;
// aapt resource value: 0x7f040008
public const int message_disconnected = 2130968584;
// aapt resource value: 0x7f040009
public const int message_logged_in = 2130968585;
// aapt resource value: 0x7f04000a
public const int message_logged_out = 2130968586;
// aapt resource value: 0x7f04000b
public const int message_login_failed = 2130968587;
// aapt resource value: 0x7f04000e
public const int message_nok = 2130968590;
// aapt resource value: 0x7f04000d
public const int message_ok = 2130968589;
// aapt resource value: 0x7f04000c // aapt resource value: 0x7f04000c
public const int message_wrong_password = 2130968588; public const int ip_address = 2130968588;
// aapt resource value: 0x7f040013 // aapt resource value: 0x7f040005
public const int password = 2130968595; public const int message_connected = 2130968581;
// aapt resource value: 0x7f04000f // aapt resource value: 0x7f040006
public const int text_ip_address = 2130968591; public const int message_disconnected = 2130968582;
// aapt resource value: 0x7f040010 // aapt resource value: 0x7f040008
public const int text_password = 2130968592; public const int message_nok = 2130968584;
// aapt resource value: 0x7f040011 // aapt resource value: 0x7f040007
public const int text_player_name = 2130968593; public const int message_ok = 2130968583;
// aapt resource value: 0x7f04000d
public const int password = 2130968589;
// aapt resource value: 0x7f040009
public const int text_ip_address = 2130968585;
// aapt resource value: 0x7f04000a
public const int text_password = 2130968586;
// aapt resource value: 0x7f04000b
public const int text_player_name = 2130968587;
static String() static String()
{ {
@@ -194,22 +170,6 @@ namespace AndroidRemote
{ {
} }
} }
public partial class Style
{
// aapt resource value: 0x7f050000
public const int Mono_Android_Theme_Splash = 2131034112;
static Style()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Style()
{
}
}
} }
} }
#pragma warning restore 1591 #pragma warning restore 1591
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 60 KiB

@@ -9,54 +9,63 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/textView1" android:id="@+id/textView1"
android:layout_margin="3dp"
android:linksClickable="false" /> android:linksClickable="false" />
<EditText <EditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/tbIP" android:id="@+id/tbIP"
android:layout_margin="3dp"
android:text="@string/ip_address" /> android:text="@string/ip_address" />
<Button
android:text="@string/button_connect"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btConnect" />
<TextView <TextView
android:text="@string/text_password" android:text="@string/text_password"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dp"
android:id="@+id/textView2" /> android:id="@+id/textView2" />
<EditText <EditText
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/tbPassword" android:id="@+id/tbPassword"
android:layout_margin="3dp"
android:text="@string/password" /> android:text="@string/password" />
<Button <Button
android:text="@string/button_login" android:text="@string/button_connect"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/btLogin" android:layout_margin="3dp"
android:enabled="false" /> android:id="@+id/btConnect" />
<Button
android:text="Discover"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:id="@+id/btDiscover" />
<Button <Button
android:text="@string/button_send_avatar" android:text="@string/button_send_avatar"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/btSendAvatar" android:id="@+id/btSendAvatar"
android:layout_margin="3dp"
android:enabled="false" /> android:enabled="false" />
<TextView <TextView
android:text="@string/text_player_name" android:text="@string/text_player_name"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dp"
android:id="@+id/textView3" /> android:id="@+id/textView3" />
<EditText <EditText
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dp"
android:id="@+id/tbPlayerName" /> android:id="@+id/tbPlayerName" />
<Button <Button
android:text="@string/button_send_profile" android:text="@string/button_send_profile"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/btSendProfile" android:id="@+id/btSendProfile"
android:layout_margin="3dp"
android:enabled="false" /> android:enabled="false" />
</LinearLayout> </LinearLayout>
@@ -1,23 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">AndroidRemote</string> <string name="app_name">Vocaluxe App</string>
<string name="button_connect">Connect</string> <string name="button_connect">Connect</string>
<string name="button_disconnect">Disconnect</string> <string name="button_disconnect">Disconnect</string>
<string name="button_login">Login</string>
<string name="button_logout">Logout</string>
<string name="button_send_avatar">Send Avatar Picture</string> <string name="button_send_avatar">Send Avatar Picture</string>
<string name="button_send_profile">Send Profile</string> <string name="button_send_profile">Send Profile</string>
<string name="message_connected">Connected</string> <string name="message_connected">Connected</string>
<string name="message_disconnected">Disconnected</string> <string name="message_disconnected">Disconnected</string>
<string name="message_logged_in">Logged in</string>
<string name="message_logged_out">Logged out</string>
<string name="message_login_failed">Login failed</string>
<string name="message_wrong_password">Wrong Password</string>
<string name="message_ok">Success</string> <string name="message_ok">Success</string>
<string name="message_nok">Error</string> <string name="message_nok">Error</string>
<string name="text_ip_address">IP Address of Vocaluxe Server:</string> <string name="text_ip_address">IP Address of Vocaluxe Server:</string>
<string name="text_password">Password:</string> <string name="text_password">Password:</string>
<string name="text_player_name">Player Name:</string> <string name="text_player_name">Player Name:</string>
<string name="ip_address">192.168.178.57</string> <string name="ip_address"></string>
<string name="password">vocaluxe</string> <string name="password">vocaluxe</string>
</resources> </resources>
@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D97EF6F3-7C3F-439F-B022-647948E206D2}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>org.vocaluxe.app</RootNamespace>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AssemblyName>VocaluxeApp</AssemblyName>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<ConsolePause>false</ConsolePause>
<DefineConstants>MONO</DefineConstants>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
<Reference Include="Newtonsoft.Json.MonoDroid">
<HintPath>Newtonsoft.Json.MonoDroid.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\ClientServerLib\CClient.cs">
<Link>ClientServerLib\CClient.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\CConnection.cs">
<Link>ClientServerLib\CConnection.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\Structs.cs">
<Link>ClientServerLib\Structs.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\BigInt.cs">
<Link>ClientServerLib\DeffieHellman\BigInt.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\DeffieHellman.cs">
<Link>ClientServerLib\DeffieHellman\DeffieHellman.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\StrongNumberProvider.cs">
<Link>ClientServerLib\DeffieHellman\StrongNumberProvider.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\CDiscover.cs">
<Link>ClientServerLib\CDiscover.cs</Link>
</Compile>
<Compile Include="..\..\Vocaluxe\Base\Server\CCommands.cs">
<Link>ClientServerLib\Server\CCommands.cs</Link>
</Compile>
<Compile Include="..\..\Vocaluxe\Base\Server\VocaluxeStructs.cs">
<Link>ClientServerLib\Server\VocaluxeStructs.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
<None Include="Properties\AndroidManifest.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\Main.axml" />
<AndroidResource Include="Resources\values\Strings.xml" />
<AndroidResource Include="Resources\drawable\Icon.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup>
<Folder Include="ClientServerLib\" />
<Folder Include="Assets\" />
<Folder Include="ClientServerLib\Vocaluxe\" />
<Folder Include="ClientServerLib\Server\" />
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>
<Properties>
<Policies>
<TextStylePolicy TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
<NameConventionPolicy>
<Rules>
<NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredPrefixes>
<String>I</String>
</RequiredPrefixes>
</NamingRule>
<NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredSuffixes>
<String>Attribute</String>
</RequiredSuffixes>
</NamingRule>
<NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredSuffixes>
<String>EventArgs</String>
</RequiredSuffixes>
</NamingRule>
<NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredSuffixes>
<String>Exception</String>
</RequiredSuffixes>
</NamingRule>
<NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="PascalCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
<NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Protected, Public" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
<NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
<AllowedPrefixes>
<String>_</String>
<String>m_</String>
</AllowedPrefixes>
</NamingRule>
<NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
<NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
<AllowedPrefixes>
<String>_</String>
<String>m_</String>
</AllowedPrefixes>
</NamingRule>
<NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Parameters" AffectedEntity="Parameter" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
<NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
<RequiredPrefixes>
<String>T</String>
</RequiredPrefixes>
</NamingRule>
</Rules>
</NameConventionPolicy>
<VersionControlPolicy inheritsSet="Mono" />
<ChangeLogPolicy inheritsSet="Mono" />
</Policies>
</Properties>
</MonoDevelop>
</ProjectExtensions>
</Project>
+86 -13
View File
@@ -29,6 +29,8 @@ namespace ClientServerLib
private OnSend onSend; private OnSend onSend;
private OnReceived onReceived; private OnReceived onReceived;
private byte[] data;
public bool Connected public bool Connected
{ {
get { return connected; } get { return connected; }
@@ -41,14 +43,12 @@ namespace ClientServerLib
running = true; running = true;
requests = new List<SRequest>(); requests = new List<SRequest>();
responses = new List<SRequest>(); responses = new List<SRequest>();
data = new byte[bufferLength];
connection = new CConnection(new TcpClient(), -1); connection = new CConnection(new TcpClient(), -1);
clientThread = new Thread(new ThreadStart(Runner));
clientThread.Start();
} }
public void Connect(string IP = "127.0.0.1", int Port = 3000, public void Connect(string IP = "127.0.0.1", int Port = 3000, string Password = null,
OnConnectionChanged OnConnectionChanged = null, OnConnectionChanged OnConnectionChanged = null,
OnSend OnSend = null, OnSend OnSend = null,
OnReceived OnReceived = null) OnReceived OnReceived = null)
@@ -61,7 +61,15 @@ namespace ClientServerLib
ip = IP; ip = IP;
port = Port; port = Port;
connection.Password = Password;
doConnect = true; doConnect = true;
if (clientThread == null)
{
running = true;
clientThread = new Thread(new ThreadStart(Runner));
clientThread.Start();
}
} }
} }
@@ -85,9 +93,13 @@ namespace ClientServerLib
public void Close() public void Close()
{ {
Disconnect();
running = false; running = false;
clientThread.Join(100);
if (clientThread != null)
clientThread.Join(100);
clientThread = null;
DoDisconnect();
} }
public void SendMessage(byte[] Message, ResponseCallback Callback) public void SendMessage(byte[] Message, ResponseCallback Callback)
@@ -111,10 +123,14 @@ namespace ClientServerLib
{ {
try try
{ {
serverEndPoint = new IPEndPoint(IPAddress.Parse(ip), port); IPAddress resolvedIP;
connection.TcpClient.Connect(serverEndPoint); if (TryResolveIPAddress(ip, out resolvedIP))
connected = true; {
RaiseOnConnectionChanged(); serverEndPoint = new IPEndPoint(resolvedIP, port);
connection.TcpClient.Connect(serverEndPoint);
connected = true;
RaiseOnConnectionChanged();
}
} }
catch catch
{ {
@@ -122,7 +138,7 @@ namespace ClientServerLib
for (int i = 0; i < 500; i++) for (int i = 0; i < 500; i++)
{ {
if (doConnect) if (running && doConnect)
Thread.Sleep(10); Thread.Sleep(10);
else else
break; break;
@@ -141,6 +157,7 @@ namespace ClientServerLib
try try
{ {
Communicate(); Communicate();
Thread.Sleep(10);
} }
catch catch
{ {
@@ -148,9 +165,62 @@ namespace ClientServerLib
} }
} }
if (!doConnect && !connected)
{
for (int i = 0; i < 500; i++)
{
if (running && !doConnect)
Thread.Sleep(10);
else
break;
}
}
} }
} }
public bool TryResolveIPAddress(string serverNameOrURL, out IPAddress resolvedIPAddress)
{
bool isResolved = false;
IPHostEntry hostEntry = null;
IPAddress resolvIP = null;
try
{
if (!IPAddress.TryParse(serverNameOrURL, out resolvIP))
{
hostEntry = Dns.GetHostEntry(serverNameOrURL);
if (hostEntry != null && hostEntry.AddressList != null && hostEntry.AddressList.Length > 0)
{
if (hostEntry.AddressList.Length == 1)
{
resolvIP = hostEntry.AddressList[0];
isResolved = true;
}
else
{
foreach (IPAddress var in hostEntry.AddressList)
{
if (var.AddressFamily == AddressFamily.InterNetwork)
{
resolvIP = var;
isResolved = true;
break;
}
}
}
}
}
else
isResolved = true;
}
catch (Exception) {}
finally
{
resolvedIPAddress = resolvIP;
}
return isResolved;
}
private void DoDisconnect() private void DoDisconnect()
{ {
try try
@@ -161,6 +231,7 @@ namespace ClientServerLib
connection = new CConnection(new TcpClient(), -1); connection = new CConnection(new TcpClient(), -1);
connected = false; connected = false;
doConnect = false;
RaiseOnConnectionChanged(); RaiseOnConnectionChanged();
} }
@@ -171,7 +242,6 @@ namespace ClientServerLib
NetworkStream clientStream = connection.TcpClient.GetStream(); NetworkStream clientStream = connection.TcpClient.GetStream();
byte[] data = new byte[bufferLength];
int bytesRead; int bytesRead;
if (!connection.KeySet) if (!connection.KeySet)
@@ -302,7 +372,10 @@ namespace ClientServerLib
{ {
onConnectionChanged(connected); onConnectionChanged(connected);
} }
catch {} catch (Exception e)
{
Console.WriteLine (e.Message);
}
} }
private void RaiseOnSend(byte[] Message) private void RaiseOnSend(byte[] Message)
+36 -5
View File
@@ -14,10 +14,13 @@ namespace ClientServerLib
internal class CConnection internal class CConnection
{ {
private bool keySet; private bool keySet;
private byte[] key;
private bool encryption; private bool encryption;
private string password;
private CDiffieHellman dh; private CDiffieHellman dh;
private UTF8Encoding encoder; private UTF8Encoding encoder;
private int connectionID; private int connectionID;
private static SHA256Managed SHA256 = new SHA256Managed();
public TcpClient TcpClient; public TcpClient TcpClient;
@@ -31,14 +34,26 @@ namespace ClientServerLib
get { return connectionID; } get { return connectionID; }
} }
public CConnection(TcpClient client, int ConnectionID, bool Encryption = false) public string Password
{
set
{
password = value;
encryption = value != null;
keySet = false;
}
}
public CConnection(TcpClient client, int ConnectionID, string Password = null)
{ {
TcpClient = client; TcpClient = client;
client.NoDelay = true; client.NoDelay = true;
keySet = false; keySet = false;
encryption = Encryption; encryption = Password != null;
password = Password;
connectionID = ConnectionID; connectionID = ConnectionID;
encoder = new UTF8Encoding(); encoder = new UTF8Encoding();
key = null;
} }
public byte[] GetKeyParams() public byte[] GetKeyParams()
@@ -64,11 +79,12 @@ namespace ClientServerLib
{ {
encryption = false; encryption = false;
keySet = true; keySet = true;
key = null;
return encoder.GetBytes(response); return encoder.GetBytes(response);
} }
dh = new CDiffieHellman(256).GenerateResponse(response); dh = new CDiffieHellman(256).GenerateResponse(response);
key = _BuildHash(dh.Key, password);
keySet = true; keySet = true;
encryption = true; encryption = true;
return encoder.GetBytes(dh.ToString()); return encoder.GetBytes(dh.ToString());
@@ -81,6 +97,7 @@ namespace ClientServerLib
if (response == "NO ENCRYPTION") if (response == "NO ENCRYPTION")
{ {
keySet = true; keySet = true;
key = null;
return; return;
} }
@@ -88,6 +105,7 @@ namespace ClientServerLib
return; return;
dh.HandleResponse(response); dh.HandleResponse(response);
key = _BuildHash(dh.Key, password);
keySet = true; keySet = true;
} }
@@ -101,6 +119,19 @@ namespace ClientServerLib
return _Decompress(_Decrypt(Data)); return _Decompress(_Decrypt(Data));
} }
private byte[] _BuildHash(byte[] Key, string Password)
{
if (Key == null || Password == null)
return null;
byte[] hash = SHA256.ComputeHash(encoder.GetBytes(Password));
byte[] serial = new byte[Key.Length + hash.Length];
Array.Copy(Key, serial, Key.Length);
Array.Copy(hash, 0, serial, Key.Length, hash.Length);
return SHA256.ComputeHash(serial);
}
private byte[] _Encrypt(byte[] Data) private byte[] _Encrypt(byte[] Data)
{ {
if (Data == null || (!keySet && encryption)) if (Data == null || (!keySet && encryption))
@@ -125,7 +156,7 @@ namespace ClientServerLib
using (Aes aes = new AesManaged()) using (Aes aes = new AesManaged())
{ {
aes.Key = dh.Key; aes.Key = key;
aes.GenerateIV(); aes.GenerateIV();
using (var encryptor = aes.CreateEncryptor(aes.Key, aes.IV)) using (var encryptor = aes.CreateEncryptor(aes.Key, aes.IV))
@@ -184,7 +215,7 @@ namespace ClientServerLib
using (Aes aes = new AesManaged()) using (Aes aes = new AesManaged())
{ {
aes.Key = dh.Key; aes.Key = key;
aes.IV = IV; aes.IV = IV;
byte[] encrypted = new byte[messageLength - 24]; byte[] encrypted = new byte[messageLength - 24];
+6 -1
View File
@@ -14,6 +14,9 @@ namespace ClientServerLib
public class CDiscover public class CDiscover
{ {
public static readonly string sTimeout = "Timeout";
public static readonly string sFinished = "Finished";
private string _Keyword; private string _Keyword;
private string _BroadcastAddress; private string _BroadcastAddress;
private int _Port; private int _Port;
@@ -114,7 +117,9 @@ namespace ClientServerLib
_DiscoverRunning = false; _DiscoverRunning = false;
if (!foundSomething) if (!foundSomething)
_OnDiscovered("Timeout", "unknown"); _OnDiscovered(sTimeout, String.Empty);
else
_OnDiscovered(sFinished, String.Empty);
} }
} }
} }
+26 -8
View File
@@ -14,6 +14,7 @@ namespace ClientServerLib
private Thread listenThread; private Thread listenThread;
private int port; private int port;
private bool encryption; private bool encryption;
private string password;
private int bufferLength = 8192; private int bufferLength = 8192;
private bool running; private bool running;
@@ -22,12 +23,13 @@ namespace ClientServerLib
private Dictionary<int, CConnection> clients; private Dictionary<int, CConnection> clients;
private Queue<int> ids; private Queue<int> ids;
public CServer(HandleRequest RequestCallback, int Port = 3000, bool Encryption = false) public CServer(HandleRequest RequestCallback, int Port = 3000, string Password = null)
{ {
port = Port; port = Port;
running = false; running = false;
requestCallback = RequestCallback; requestCallback = RequestCallback;
encryption = Encryption; encryption = Password != null;
password = Password;
clients = new Dictionary<int, CConnection>(); clients = new Dictionary<int, CConnection>();
ids = new Queue<int>(1000); ids = new Queue<int>(1000);
@@ -92,7 +94,7 @@ namespace ClientServerLib
if (client != null) if (client != null)
{ {
int id = ids.Dequeue(); int id = ids.Dequeue();
CConnection connection = new CConnection(client, id, encryption); CConnection connection = new CConnection(client, id, password);
lock (clients) lock (clients)
{ {
@@ -103,10 +105,19 @@ namespace ClientServerLib
NetworkStream clientStream = client.GetStream(); NetworkStream clientStream = client.GetStream();
byte[] serverParams = connection.GetKeyParams(); byte[] serverParams = connection.GetKeyParams();
clientStream.Write(serverParams, 0, serverParams.Length);
clientStream.Flush();
clientThread.Start(connection); try
{
clientStream.Write(serverParams, 0, serverParams.Length);
clientStream.Flush();
}
catch
{
client = null;
}
if (client != null)
clientThread.Start(connection);
} }
} }
} }
@@ -162,8 +173,15 @@ namespace ClientServerLib
//send message //send message
byte[] encrypted = connection.Encrypt(answer); byte[] encrypted = connection.Encrypt(answer);
clientStream.Write(encrypted, 0, encrypted.Length); try
clientStream.Flush(); {
clientStream.Write(encrypted, 0, encrypted.Length);
clientStream.Flush();
}
catch
{
break;
}
} }
} }
} }
@@ -971,6 +971,9 @@ namespace DiffieHellman
public override bool Equals(object o) public override bool Equals(object o)
{ {
if (o == null)
return false;
BigInteger bi = (BigInteger)o; BigInteger bi = (BigInteger)o;
if (this.dataLength != bi.dataLength) if (this.dataLength != bi.dataLength)
@@ -2965,8 +2968,6 @@ namespace DiffieHellman
{ {
data = new uint[0]; data = new uint[0];
data = null; data = null;
GC.Collect();
GC.Collect();
} }
#endregion #endregion
@@ -115,10 +115,11 @@ namespace DiffieHellman
{ {
// Generate the key. // Generate the key.
using (BigInteger given = new BigInteger(parts[2], 36)) using (BigInteger given = new BigInteger(parts[2], 36))
using (BigInteger key = given.ModPow(mine, prime)) using (BigInteger key = given.ModPow(mine, prime))
{ {
this.key = key.GetBytes(); this.key = key.GetBytes();
} }
// Generate the response. // Generate the response.
using (BigInteger send = g.ModPow(mine, prime)) using (BigInteger send = g.ModPow(mine, prime))
{ {
+3 -17
View File
@@ -42,7 +42,6 @@
this.lbServerIP = new System.Windows.Forms.Label(); this.lbServerIP = new System.Windows.Forms.Label();
this.tbPassword = new System.Windows.Forms.TextBox(); this.tbPassword = new System.Windows.Forms.TextBox();
this.lbPassword = new System.Windows.Forms.Label(); this.lbPassword = new System.Windows.Forms.Label();
this.btLogin = new System.Windows.Forms.Button();
this.btLeft = new System.Windows.Forms.Button(); this.btLeft = new System.Windows.Forms.Button();
this.btRight = new System.Windows.Forms.Button(); this.btRight = new System.Windows.Forms.Button();
this.btUp = new System.Windows.Forms.Button(); this.btUp = new System.Windows.Forms.Button();
@@ -143,7 +142,7 @@
// //
// btConnect // btConnect
// //
this.btConnect.Location = new System.Drawing.Point(831, 64); this.btConnect.Location = new System.Drawing.Point(831, 90);
this.btConnect.Name = "btConnect"; this.btConnect.Name = "btConnect";
this.btConnect.Size = new System.Drawing.Size(165, 23); this.btConnect.Size = new System.Drawing.Size(165, 23);
this.btConnect.TabIndex = 5; this.btConnect.TabIndex = 5;
@@ -162,7 +161,7 @@
// //
// tbPassword // tbPassword
// //
this.tbPassword.Location = new System.Drawing.Point(910, 128); this.tbPassword.Location = new System.Drawing.Point(910, 64);
this.tbPassword.Name = "tbPassword"; this.tbPassword.Name = "tbPassword";
this.tbPassword.Size = new System.Drawing.Size(86, 20); this.tbPassword.Size = new System.Drawing.Size(86, 20);
this.tbPassword.TabIndex = 6; this.tbPassword.TabIndex = 6;
@@ -171,23 +170,12 @@
// lbPassword // lbPassword
// //
this.lbPassword.AutoSize = true; this.lbPassword.AutoSize = true;
this.lbPassword.Location = new System.Drawing.Point(828, 131); this.lbPassword.Location = new System.Drawing.Point(828, 67);
this.lbPassword.Name = "lbPassword"; this.lbPassword.Name = "lbPassword";
this.lbPassword.Size = new System.Drawing.Size(56, 13); this.lbPassword.Size = new System.Drawing.Size(56, 13);
this.lbPassword.TabIndex = 7; this.lbPassword.TabIndex = 7;
this.lbPassword.Text = "Password:"; this.lbPassword.Text = "Password:";
// //
// btLogin
//
this.btLogin.Enabled = false;
this.btLogin.Location = new System.Drawing.Point(831, 154);
this.btLogin.Name = "btLogin";
this.btLogin.Size = new System.Drawing.Size(165, 23);
this.btLogin.TabIndex = 8;
this.btLogin.Text = "Login";
this.btLogin.UseVisualStyleBackColor = true;
this.btLogin.Click += new System.EventHandler(this.btLogin_Click);
//
// btLeft // btLeft
// //
this.btLeft.Enabled = false; this.btLeft.Enabled = false;
@@ -298,7 +286,6 @@
this.Controls.Add(this.btUp); this.Controls.Add(this.btUp);
this.Controls.Add(this.btRight); this.Controls.Add(this.btRight);
this.Controls.Add(this.btLeft); this.Controls.Add(this.btLeft);
this.Controls.Add(this.btLogin);
this.Controls.Add(this.tbDataReceiving); this.Controls.Add(this.tbDataReceiving);
this.Controls.Add(this.lbPassword); this.Controls.Add(this.lbPassword);
this.Controls.Add(this.lbDataReceiving); this.Controls.Add(this.lbDataReceiving);
@@ -336,7 +323,6 @@
private System.Windows.Forms.Label lbServerIP; private System.Windows.Forms.Label lbServerIP;
private System.Windows.Forms.TextBox tbPassword; private System.Windows.Forms.TextBox tbPassword;
private System.Windows.Forms.Label lbPassword; private System.Windows.Forms.Label lbPassword;
private System.Windows.Forms.Button btLogin;
private System.Windows.Forms.Button btLeft; private System.Windows.Forms.Button btLeft;
private System.Windows.Forms.Button btRight; private System.Windows.Forms.Button btRight;
private System.Windows.Forms.Button btUp; private System.Windows.Forms.Button btUp;
+1 -4
View File
@@ -72,7 +72,7 @@ namespace ClientTest
} }
lbConnectionStatusText.Text = "Connecting..."; lbConnectionStatusText.Text = "Connecting...";
client.Connect(tbServerIP.Text, port, OnConnectionChanged, OnSend, OnReceived); client.Connect(tbServerIP.Text, port, tbPassword.Text, OnConnectionChanged, OnSend, OnReceived);
} }
private void Disconnect() private void Disconnect()
@@ -120,7 +120,6 @@ namespace ClientTest
{ {
lbConnectionStatusText.Text = "Connected"; lbConnectionStatusText.Text = "Connected";
btConnect.Text = "Disconnect"; btConnect.Text = "Disconnect";
btLogin.Enabled = true;
btUp.Enabled = true; btUp.Enabled = true;
btDown.Enabled = true; btDown.Enabled = true;
btLeft.Enabled = true; btLeft.Enabled = true;
@@ -136,8 +135,6 @@ namespace ClientTest
client.Disconnect(); client.Disconnect();
lbConnectionStatusText.Text = "Disconnected"; lbConnectionStatusText.Text = "Disconnected";
btConnect.Text = "Connect"; btConnect.Text = "Connect";
btLogin.Text = "Login";
btLogin.Enabled = false;
loggedIn = false; loggedIn = false;
btUp.Enabled = false; btUp.Enabled = false;
btDown.Enabled = false; btDown.Enabled = false;
Binary file not shown.
+1
View File
@@ -92,6 +92,7 @@
<string name="TR_SCREENPARTY_AUTHOR">Author</string> <string name="TR_SCREENPARTY_AUTHOR">Author</string>
<string name="TR_SCREENPARTY_VERSION">Version</string> <string name="TR_SCREENPARTY_VERSION">Version</string>
<string name="TR_SCREENPARTY_ERROR">Can't load this party-mode.</string> <string name="TR_SCREENPARTY_ERROR">Can't load this party-mode.</string>
<string name="TR_SCREENPARTY_ERROR_MICS">There are no mics configured!</string>
<string name="TR_SCREENPARTY_TARGETAUDIENCE">Target audience</string> <string name="TR_SCREENPARTY_TARGETAUDIENCE">Target audience</string>
<string name="TR_SCREENPARTY_NOTEAMS">No teams</string> <string name="TR_SCREENPARTY_NOTEAMS">No teams</string>
<string name="TR_SCREENPARTY_NUMTEAMS">Number of teams</string> <string name="TR_SCREENPARTY_NUMTEAMS">Number of teams</string>
+1 -1
View File
@@ -1,4 +1,4 @@
Vocaluxe 0.2 README Vocaluxe 0.3 README
---------------------------- ----------------------------
================================= =================================
@@ -410,7 +410,7 @@
<Text> <Text>
<!--<X>, <Y>: Text position--> <!--<X>, <Y>: Text position-->
<X>75</X> <X>75</X>
<Y>16</Y> <Y>12</Y>
<!--<H>: Text height--> <!--<H>: Text height-->
<H>27</H> <H>27</H>
<!--<MaxW>: Maximum text width (if exists)--> <!--<MaxW>: Maximum text width (if exists)-->
@@ -467,7 +467,7 @@
<Text> <Text>
<!--<X>, <Y>: Text position--> <!--<X>, <Y>: Text position-->
<X>75</X> <X>75</X>
<Y>16</Y> <Y>12</Y>
<!--<H>: Text height--> <!--<H>: Text height-->
<H>27</H> <H>27</H>
<!--<MaxW>: Maximum text width (if exists)--> <!--<MaxW>: Maximum text width (if exists)-->
@@ -79,9 +79,9 @@
</Static4> </Static4>
<StaticWebcamOutput> <StaticWebcamOutput>
<!--<Skin>: Texture name--> <!--<Skin>: Texture name-->
<Skin>CoverBackground</Skin> <Skin>Invisible</Skin>
<!--<X>, <Y>, <Z>, <W>, <H>: Static position, width and height--> <!--<X>, <Y>, <Z>, <W>, <H>: Static position, width and height-->
<X>75</X> <X>500</X>
<Y>460</Y> <Y>460</Y>
<Z>0,00</Z> <Z>0,00</Z>
<W>320</W> <W>320</W>
@@ -568,7 +568,7 @@
<!--<Font>: Text font name--> <!--<Font>: Text font name-->
<Font>Outline</Font> <Font>Outline</Font>
<!--<Text>: Nothing or translation tag--> <!--<Text>: Nothing or translation tag-->
<Text>TR_BUTTON_EXIT</Text> <Text>TR_BUTTON_BACK</Text>
</Text> </Text>
<!--<Reflection> If exists:--> <!--<Reflection> If exists:-->
<!-- <Space>: Reflection Space--> <!-- <Space>: Reflection Space-->
@@ -533,15 +533,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _SetTeamNames() private void _SetTeamNames()
{ {
CProfile[] profiles = CBase.Profiles.GetProfiles(); if (_GameData.NumPlayerAtOnce < 1 || _GameData.ProfileIDs.Count < _GameData.NumPlayerAtOnce)
if (profiles == null)
{
_ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"};
return;
}
if (_GameData.NumPlayerAtOnce < 1 || _GameData.ProfileIDs.Count < _GameData.NumPlayerAtOnce || profiles.Length < _GameData.NumPlayerAtOnce)
{ {
_ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"}; _ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"};
return; return;
@@ -554,10 +546,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
if (c != null) if (c != null)
{ {
if (_GameData.ProfileIDs[c.Player[i]] < profiles.Length) _ScreenSongOptions.Selection.TeamNames[i] = CBase.Profiles.GetPlayerName(_GameData.ProfileIDs[c.Player[i]]);
_ScreenSongOptions.Selection.TeamNames[i] = profiles[_GameData.ProfileIDs[c.Player[i]]].PlayerName;
else
_ScreenSongOptions.Selection.TeamNames[i] = "foobar";
} }
else else
_ScreenSongOptions.Selection.TeamNames[i] = "foobar"; _ScreenSongOptions.Selection.TeamNames[i] = "foobar";
@@ -380,12 +380,11 @@ namespace VocaluxeLib.PartyModes.Challenge
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count) if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{ {
_Texts[_TextNextPlayerMessage].Visible = true; _Texts[_TextNextPlayerMessage].Visible = true;
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
int pid = _GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i]; int id = _GameState.ProfileIDs[_GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i]];
_NextPlayerStatics[i].Texture = profiles[_GameState.ProfileIDs[pid]].Avatar.Texture; _NextPlayerStatics[i].Texture = CBase.Profiles.GetAvatar(id);
_NextPlayerTexts[i].Text = profiles[_GameState.ProfileIDs[pid]].PlayerName; _NextPlayerTexts[i].Text = CBase.Profiles.GetPlayerName(id);
_NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1); _NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1);
} }
} }
@@ -492,7 +491,6 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdateRoundsTable() private void _UpdateRoundsTable()
{ {
CProfile[] profile = CBase.Profiles.GetProfiles();
for (int i = 0; i < _RoundsTable.Count; i++) for (int i = 0; i < _RoundsTable.Count; i++)
{ {
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++) for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
@@ -503,8 +501,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_RoundsTable[i].TextPlayer[p].Visible = true; _RoundsTable[i].TextPlayer[p].Visible = true;
_RoundsTable[i].TextScores[p].Visible = true; _RoundsTable[i].TextScores[p].Visible = true;
_RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")"; _RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")";
int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]; _RoundsTable[i].TextPlayer[p].Text = CBase.Profiles.GetPlayerName(_GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]);
_RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression // ReSharper disable ConvertIfStatementToConditionalTernaryExpression
if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset) if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset)
// ReSharper restore ConvertIfStatementToConditionalTernaryExpression // ReSharper restore ConvertIfStatementToConditionalTernaryExpression
@@ -586,8 +583,6 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdatePlayerTable() private void _UpdatePlayerTable()
{ {
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _PlayerTable.Count; i++) for (int i = 0; i < _PlayerTable.Count; i++)
{ {
STableRow row = _PlayerTable[i]; STableRow row = _PlayerTable[i];
@@ -602,7 +597,7 @@ namespace VocaluxeLib.PartyModes.Challenge
row.GamePoints.Visible = true; row.GamePoints.Visible = true;
row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + "."; row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + ".";
row.Name.Text = profiles[_GameState.ResultTable[i + _PlayerTableOffset].PlayerID].PlayerName; row.Name.Text = CBase.Profiles.GetPlayerName(_GameState.ResultTable[i + _PlayerTableOffset].PlayerID);
row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString(); row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString();
row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString(); row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString();
row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString(); row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString();
@@ -658,7 +653,6 @@ namespace VocaluxeLib.PartyModes.Challenge
private string _GetPlayerWinString() private string _GetPlayerWinString()
{ {
string s = ""; string s = "";
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.ResultTable.Count; i++) for (int i = 0; i < _GameState.ResultTable.Count; i++)
{ {
@@ -666,7 +660,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
if (i > 0) if (i > 0)
s += ", "; s += ", ";
s += profiles[_GameState.ResultTable[i].PlayerID].PlayerName; s += CBase.Profiles.GetPlayerName(_GameState.ResultTable[i].PlayerID);
} }
else else
break; break;
@@ -62,7 +62,6 @@ namespace VocaluxeLib.PartyModes.Challenge
private bool _SelectingMouseActive; private bool _SelectingMouseActive;
private int _OldMouseX; private int _OldMouseX;
private int _OldMouseY; private int _OldMouseY;
private int _SelectedPlayerNr = -1;
private bool _ButtonsAdded; private bool _ButtonsAdded;
private int _NumPlayer = 4; private int _NumPlayer = 4;
@@ -148,34 +147,6 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
/*
//Check if LeftButton is hold and Select-Mode inactive
if (MouseEvent.LBH && !SelectingMouseActive)
{
//Save mouse-coords
OldMouseX = MouseEvent.X;
OldMouseY = MouseEvent.Y;
//Check if mouse if over tile
for (int i = 0; i < PlayerChooseButtons.Count; i++)
{
if (PlayerChooseButtons[i].Button.Selected)
{
SelectedPlayerNr = PlayerChooseButtons[i].ProfileID;
if (SelectedPlayerNr != -1)
{
//Activate mouse-selecting
SelectingMouseActive = true;
//Update of Drag/Drop-Texture
chooseAvatarStatic.Visible = true;
chooseAvatarStatic.Rect = PlayerChooseButtons[i].Button.Rect;
chooseAvatarStatic.Rect.Z = -100;
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
chooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture;
}
}
}
}*/
//Check if LeftButton is hold and Select-Mode active //Check if LeftButton is hold and Select-Mode active
if (mouseEvent.LBH && _SelectingMouseActive) if (mouseEvent.LBH && _SelectingMouseActive)
{ {
@@ -188,44 +159,6 @@ namespace VocaluxeLib.PartyModes.Challenge
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
else if (_SelectingMouseActive) else if (_SelectingMouseActive)
{ {
//Check if really a player was selected
if (_SelectedPlayerNr != -1)
{
//Foreach Drop-Area
for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
{
//Check first, if area is "active"
if (_PlayerDestinationButtons[i].Visible)
{
//Check if Mouse is in area
if (CHelper.IsInBounds(_PlayerDestinationButtons[i].Rect, mouseEvent))
{
int added = -1;
//Add Player-ID to list.
if (_Data.ScreenNames.ProfileIDs.Count < (i + 1))
{
_Data.ScreenNames.ProfileIDs.Add(_SelectedPlayerNr);
added = _Data.ScreenNames.ProfileIDs.Count - 1;
}
else if (_Data.ScreenNames.ProfileIDs.Count >= (i + 1))
{
_Data.ScreenNames.ProfileIDs[i] = _SelectedPlayerNr;
added = i;
}
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = _ChooseAvatarStatic.Texture;
_PlayerDestinationButtons[added].SelTexture = _ChooseAvatarStatic.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].PlayerName;
//Update Tiles-List
_UpdateButtonPlayerChoose();
}
}
}
_SelectedPlayerNr = -1;
}
//Reset variables //Reset variables
_SelectingMouseActive = false; _SelectingMouseActive = false;
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
@@ -350,12 +283,11 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count) if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count)
{ {
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]; int id = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName; _PlayerChooseButtons[i].ProfileID = id;
_PlayerChooseButtons[i].Button.Texture = _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetPlayerName(id);
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; _PlayerChooseButtons[i].Button.Texture = CBase.Profiles.GetAvatar(id);
_PlayerChooseButtons[i].Button.SelTexture = _PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetAvatar(id);
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); _PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1); _PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true; _PlayerChooseButtons[i].Button.Enabled = true;
@@ -377,14 +309,15 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdateVisibleProfiles() private void _UpdateVisibleProfiles()
{ {
_PlayerChooseButtonsVisibleProfiles.Clear(); _PlayerChooseButtonsVisibleProfiles.Clear();
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++) Profile.CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < profiles.Length; i++)
{ {
bool visible = false; bool visible = false;
//Show profile only if active //Show profile only if active
if (CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON) if (profiles[i].Active == EOffOn.TR_CONFIG_ON)
visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != i); visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profiles[i].ID);
if (visible) if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(i); _PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID);
} }
} }
@@ -409,11 +342,12 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
if (_Data.ScreenNames.ProfileIDs[i] != -1) if (_Data.ScreenNames.ProfileIDs[i] != -1)
{ {
int id = _Data.ScreenNames.ProfileIDs[i];
_PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; _PlayerDestinationButtons[i].Texture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; _PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].PlayerName; _PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetPlayerName(id);
_PlayerDestinationButtons[i].Enabled = true; _PlayerDestinationButtons[i].Enabled = true;
} }
} }
@@ -444,17 +378,18 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
foreach (CPlayerChooseButton button in _PlayerChooseButtons) foreach (CPlayerChooseButton button in _PlayerChooseButtons)
{ {
if (!button.Button.Selected || button.ProfileID == -1 || _Data.ScreenNames.ProfileIDs.Count >= _NumPlayer) int id = button.ProfileID;
if (!button.Button.Selected || id == -1 || _Data.ScreenNames.ProfileIDs.Count >= _NumPlayer)
continue; continue;
_Data.ScreenNames.ProfileIDs.Add(button.ProfileID); _Data.ScreenNames.ProfileIDs.Add(id);
int added = _Data.ScreenNames.ProfileIDs.Count - 1; int added = _Data.ScreenNames.ProfileIDs.Count - 1;
_UpdateButtonNext(); _UpdateButtonNext();
//Update texture and name //Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[button.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[button.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[button.ProfileID].PlayerName; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetPlayerName(id);
_PlayerDestinationButtons[added].Enabled = true; _PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List //Update Tiles-List
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
@@ -380,12 +380,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count) if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{ {
_Texts[_TextNextPlayerMessage].Visible = true; _Texts[_TextNextPlayerMessage].Visible = true;
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
int pid = _GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i]; int id = _GameState.ProfileIDs[_GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i]];
_NextPlayerStatics[i].Texture = profiles[_GameState.ProfileIDs[pid]].Avatar.Texture; _NextPlayerStatics[i].Texture = CBase.Profiles.GetAvatar(id);
_NextPlayerTexts[i].Text = profiles[_GameState.ProfileIDs[pid]].PlayerName; _NextPlayerTexts[i].Text = CBase.Profiles.GetPlayerName(id);
_NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1); _NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1);
} }
} }
@@ -492,7 +491,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateRoundsTable() private void _UpdateRoundsTable()
{ {
CProfile[] profile = CBase.Profiles.GetProfiles();
for (int i = 0; i < _RoundsTable.Count; i++) for (int i = 0; i < _RoundsTable.Count; i++)
{ {
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++) for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
@@ -503,8 +501,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_RoundsTable[i].TextPlayer[p].Visible = true; _RoundsTable[i].TextPlayer[p].Visible = true;
_RoundsTable[i].TextScores[p].Visible = true; _RoundsTable[i].TextScores[p].Visible = true;
_RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")"; _RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")";
int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]; _RoundsTable[i].TextPlayer[p].Text = CBase.Profiles.GetPlayerName(_GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]);
_RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression // ReSharper disable ConvertIfStatementToConditionalTernaryExpression
if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset) if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset)
// ReSharper restore ConvertIfStatementToConditionalTernaryExpression // ReSharper restore ConvertIfStatementToConditionalTernaryExpression
@@ -586,8 +583,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdatePlayerTable() private void _UpdatePlayerTable()
{ {
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _PlayerTable.Count; i++) for (int i = 0; i < _PlayerTable.Count; i++)
{ {
STableRow row = _PlayerTable[i]; STableRow row = _PlayerTable[i];
@@ -602,7 +597,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.GamePoints.Visible = true; row.GamePoints.Visible = true;
row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + "."; row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + ".";
row.Name.Text = profiles[_GameState.ResultTable[i + _PlayerTableOffset].PlayerID].PlayerName; row.Name.Text = CBase.Profiles.GetPlayerName(_GameState.ResultTable[i + _PlayerTableOffset].PlayerID);
row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString(); row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString();
row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString(); row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString();
row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString(); row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString();
@@ -658,15 +653,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private string _GetPlayerWinString() private string _GetPlayerWinString()
{ {
string s = ""; string s = "";
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.ResultTable.Count; i++) for (int i = 0; i < _GameState.ResultTable.Count; i++)
{ {
if (_GameState.ResultTable[i].Position == 1) if (_GameState.ResultTable[i].Position == 1)
{ {
if (i > 0) if (i > 0)
s += ", "; s += ", ";
s += profiles[_GameState.ResultTable[i].PlayerID].PlayerName; s += CBase.Profiles.GetPlayerName(_GameState.ResultTable[i].PlayerID);
} }
else else
break; break;
@@ -19,6 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -61,7 +62,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private bool _SelectingMouseActive; private bool _SelectingMouseActive;
private int _OldMouseX; private int _OldMouseX;
private int _OldMouseY; private int _OldMouseY;
private int _SelectedPlayerNr = -1;
private bool _ButtonsAdded; private bool _ButtonsAdded;
private int _NumPlayer = 4; private int _NumPlayer = 4;
@@ -85,10 +85,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_Data.ScreenNames.ProfileIDs = new List<int>(); _Data.ScreenNames.ProfileIDs = new List<int>();
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _ThemeButtons = new string[] { _ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose };
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDs = new List<int>()}; SFromScreenNames names = new SFromScreenNames { FadeToConfig = false, ProfileIDs = new List<int>() };
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
@@ -114,7 +114,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
base.HandleInput(keyEvent); base.HandleInput(keyEvent);
if (keyEvent.KeyPressed) {} if (keyEvent.KeyPressed) { }
else else
{ {
switch (keyEvent.Key) switch (keyEvent.Key)
@@ -147,34 +147,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
/*
//Check if LeftButton is hold and Select-Mode inactive
if (MouseEvent.LBH && !SelectingMouseActive)
{
//Save mouse-coords
OldMouseX = MouseEvent.X;
OldMouseY = MouseEvent.Y;
//Check if mouse if over tile
for (int i = 0; i < PlayerChooseButtons.Count; i++)
{
if (PlayerChooseButtons[i].Button.Selected)
{
SelectedPlayerNr = PlayerChooseButtons[i].ProfileID;
if (SelectedPlayerNr != -1)
{
//Activate mouse-selecting
SelectingMouseActive = true;
//Update of Drag/Drop-Texture
chooseAvatarStatic.Visible = true;
chooseAvatarStatic.Rect = PlayerChooseButtons[i].Button.Rect;
chooseAvatarStatic.Rect.Z = -100;
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
chooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture;
}
}
}
}*/
//Check if LeftButton is hold and Select-Mode active //Check if LeftButton is hold and Select-Mode active
if (mouseEvent.LBH && _SelectingMouseActive) if (mouseEvent.LBH && _SelectingMouseActive)
{ {
@@ -184,47 +156,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y; _OldMouseY = mouseEvent.Y;
} }
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
else if (_SelectingMouseActive) else if (_SelectingMouseActive)
{ {
//Check if really a player was selected
if (_SelectedPlayerNr != -1)
{
//Foreach Drop-Area
for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
{
//Check first, if area is "active"
if (_PlayerDestinationButtons[i].Visible)
{
//Check if Mouse is in area
if (CHelper.IsInBounds(_PlayerDestinationButtons[i].Rect, mouseEvent))
{
int added = -1;
//Add Player-ID to list.
if (_Data.ScreenNames.ProfileIDs.Count < (i + 1))
{
_Data.ScreenNames.ProfileIDs.Add(_SelectedPlayerNr);
added = _Data.ScreenNames.ProfileIDs.Count - 1;
}
else if (_Data.ScreenNames.ProfileIDs.Count >= (i + 1))
{
_Data.ScreenNames.ProfileIDs[i] = _SelectedPlayerNr;
added = i;
}
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = _ChooseAvatarStatic.Texture;
_PlayerDestinationButtons[added].SelTexture = _ChooseAvatarStatic.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].PlayerName;
//Update Tiles-List
_UpdateButtonPlayerChoose();
}
}
}
_SelectedPlayerNr = -1;
}
//Reset variables //Reset variables
_SelectingMouseActive = false; _SelectingMouseActive = false;
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
@@ -313,7 +247,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]); CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1}; CPlayerChooseButton pcb = new CPlayerChooseButton { Button = b, ProfileID = -1 };
_PlayerChooseButtons.Add(pcb); _PlayerChooseButtons.Add(pcb);
column++; column++;
if (column >= _PlayerChooseButtonsNumH) if (column >= _PlayerChooseButtonsNumH)
@@ -349,12 +283,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count) if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count)
{ {
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]; int id = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName; _PlayerChooseButtons[i].ProfileID = id;
_PlayerChooseButtons[i].Button.Texture = _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetPlayerName(id);
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; _PlayerChooseButtons[i].Button.Texture = CBase.Profiles.GetAvatar(id);
_PlayerChooseButtons[i].Button.SelTexture = _PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetAvatar(id);
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); _PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1); _PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true; _PlayerChooseButtons[i].Button.Enabled = true;
@@ -376,17 +309,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateVisibleProfiles() private void _UpdateVisibleProfiles()
{ {
_PlayerChooseButtonsVisibleProfiles.Clear(); _PlayerChooseButtonsVisibleProfiles.Clear();
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++) Profile.CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < profiles.Length; i++)
{ {
bool visible = false; bool visible = false;
//Show profile only if active //Show profile only if active
if (CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON) if (profiles[i].Active == EOffOn.TR_CONFIG_ON)
{ visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profiles[i].ID);
//Don't show profile if is selected
visible = !_Data.ScreenNames.ProfileIDs.Contains(i);
}
if (visible) if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(i); _PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID);
} }
} }
@@ -411,11 +342,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
if (_Data.ScreenNames.ProfileIDs[i] != -1) if (_Data.ScreenNames.ProfileIDs[i] != -1)
{ {
int id = _Data.ScreenNames.ProfileIDs[i];
_PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; _PlayerDestinationButtons[i].Texture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; _PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].PlayerName; _PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetPlayerName(id);
_PlayerDestinationButtons[i].Enabled = true; _PlayerDestinationButtons[i].Enabled = true;
} }
} }
@@ -444,50 +376,44 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private bool _OnAdd() private bool _OnAdd()
{ {
foreach (CPlayerChooseButton chooseButton in _PlayerChooseButtons) foreach (CPlayerChooseButton button in _PlayerChooseButtons)
{ {
if (chooseButton.Button.Selected && chooseButton.ProfileID != -1) int id = button.ProfileID;
{ if (!button.Button.Selected || id == -1 || _Data.ScreenNames.ProfileIDs.Count >= _NumPlayer)
if (_Data.ScreenNames.ProfileIDs.Count < _NumPlayer) continue;
{ _Data.ScreenNames.ProfileIDs.Add(id);
_Data.ScreenNames.ProfileIDs.Add(chooseButton.ProfileID); int added = _Data.ScreenNames.ProfileIDs.Count - 1;
int added = _Data.ScreenNames.ProfileIDs.Count - 1; _UpdateButtonNext();
_UpdateButtonNext(); //Update texture and name
//Update texture and name _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetPlayerName(id);
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName; _PlayerDestinationButtons[added].Enabled = true;
_PlayerDestinationButtons[added].Enabled = true; //Update Tiles-List
//Update Tiles-List _UpdateButtonPlayerChoose();
_UpdateButtonPlayerChoose(); _CheckInteraction();
_CheckInteraction(); return true;
return true;
}
}
} }
return false; return false;
} }
private bool _OnRemove() private void _OnRemove()
{ {
for (int i = 0; i < _PlayerDestinationButtons.Count; i++) for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
{ {
if (_PlayerDestinationButtons[i].Selected) if (!_PlayerDestinationButtons[i].Selected)
{ continue;
if ((i + 1) <= _Data.ScreenNames.ProfileIDs.Count) if ((i + 1) > _Data.ScreenNames.ProfileIDs.Count)
{ continue;
_Data.ScreenNames.ProfileIDs.RemoveAt(i); _Data.ScreenNames.ProfileIDs.RemoveAt(i);
_UpdateButtonNext(); _UpdateButtonNext();
_UpdateButtonPlayerDestination(); _UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
_CheckInteraction(); _CheckInteraction();
return true; return;
}
}
} }
return false;
} }
private void _Back() private void _Back()
@@ -727,7 +727,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (players.Length < 2) if (players.Length < 2)
return; return;
CProfile[] profiles = CBase.Profiles.GetProfiles();
CRound r = _GameData.Rounds[roundNr]; CRound r = _GameData.Rounds[roundNr];
bool isDuet = CBase.Songs.GetSongByID(r.SongID).IsDuet; bool isDuet = CBase.Songs.GetSongByID(r.SongID).IsDuet;
@@ -740,18 +739,14 @@ namespace VocaluxeLib.PartyModes.TicTacToe
//try to fill with the right data //try to fill with the right data
if (r != null) if (r != null)
{ {
if (_GameData.ProfileIDsTeam1[r.SingerTeam1] < profiles.Length) players[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1];
{ if (isDuet)
players[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1]; players[0].LineNr = 0;
if (isDuet)
players[0].LineNr = 0; players[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2];
} if (isDuet)
if (_GameData.ProfileIDsTeam2[r.SingerTeam2] < profiles.Length) players[1].LineNr = 1;
{
players[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2];
if (isDuet)
players[1].LineNr = 1;
}
SongSelected(r.SongID); SongSelected(r.SongID);
} }
} }
@@ -494,17 +494,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_GameData.Rounds[_SelectedField].SingerTeam1 = singerTeam1; _GameData.Rounds[_SelectedField].SingerTeam1 = singerTeam1;
_GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2; _GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2;
_Texts[_TextNextPlayerT1].Visible = true; _UpdatePlayerInformation();
_Texts[_TextNextPlayerT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Visible = true;
_Texts[_TextNextPlayerNameT2].Visible = true;
CProfile[] profiles = CBase.Profiles.GetProfiles();
_Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
_Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
_Statics[_StaticAvatarT1].Visible = true;
_Statics[_StaticAvatarT2].Visible = true;
_Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture;
_Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture;
} }
int songID = 0; int songID = 0;
@@ -553,17 +543,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_GameData.Rounds[_SelectedField].SingerTeam2 = _GameData.Rounds[_OldSelectedField].SingerTeam2; _GameData.Rounds[_SelectedField].SingerTeam2 = _GameData.Rounds[_OldSelectedField].SingerTeam2;
_UpdateFieldContents(); _UpdateFieldContents();
_Texts[_TextNextPlayerT1].Visible = true; _UpdatePlayerInformation();
_Texts[_TextNextPlayerT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Visible = true;
_Texts[_TextNextPlayerNameT2].Visible = true;
CProfile[] profiles = CBase.Profiles.GetProfiles();
_Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
_Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
_Statics[_StaticAvatarT1].Visible = true;
_Statics[_StaticAvatarT2].Visible = true;
_Statics[_StaticAvatarT1].Texture = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].Avatar.Texture;
_Statics[_StaticAvatarT2].Texture = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].Avatar.Texture;
_UpdateJokerButtons(); _UpdateJokerButtons();
@@ -574,6 +554,20 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_SetInteractionToButton(_Buttons[_ButtonNextRound]); _SetInteractionToButton(_Buttons[_ButtonNextRound]);
} }
private void _UpdatePlayerInformation()
{
_Texts[_TextNextPlayerT1].Visible = true;
_Texts[_TextNextPlayerT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Visible = true;
_Texts[_TextNextPlayerNameT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Text = CBase.Profiles.GetPlayerName(_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]);
_Texts[_TextNextPlayerNameT2].Text = CBase.Profiles.GetPlayerName(_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]);
_Statics[_StaticAvatarT1].Visible = true;
_Statics[_StaticAvatarT2].Visible = true;
_Statics[_StaticAvatarT1].Texture = CBase.Profiles.GetAvatar(_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]);
_Statics[_StaticAvatarT2].Texture = CBase.Profiles.GetAvatar(_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]);
}
private void _UseJoker(int teamNr, int jokerNum) private void _UseJoker(int teamNr, int jokerNum)
{ {
switch (jokerNum) switch (jokerNum)
@@ -187,7 +187,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ChooseAvatarStatic.Rect = chooseButton.Button.Rect; _ChooseAvatarStatic.Rect = chooseButton.Button.Rect;
_ChooseAvatarStatic.Rect.Z = -100; _ChooseAvatarStatic.Rect.Z = -100;
_ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1); _ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
_ChooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].Avatar.Texture; _ChooseAvatarStatic.Texture = CBase.Profiles.GetAvatar(_SelectedPlayerNr);
} }
} }
} }
@@ -254,7 +254,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = _ChooseAvatarStatic.Texture; _PlayerDestinationButtons[added].Texture = _ChooseAvatarStatic.Texture;
_PlayerDestinationButtons[added].SelTexture = _ChooseAvatarStatic.Texture; _PlayerDestinationButtons[added].SelTexture = _ChooseAvatarStatic.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].PlayerName; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetPlayerName(_SelectedPlayerNr);
_PlayerDestinationButtons[added].Enabled = true; _PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List //Update Tiles-List
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
@@ -414,12 +414,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count) if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count)
{ {
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]; int id = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName; _PlayerChooseButtons[i].ProfileID = id;
_PlayerChooseButtons[i].Button.Texture = _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetPlayerName(id);
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; _PlayerChooseButtons[i].Button.Texture = CBase.Profiles.GetAvatar(id);
_PlayerChooseButtons[i].Button.SelTexture = _PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetAvatar(id);
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); _PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1); _PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true; _PlayerChooseButtons[i].Button.Enabled = true;
@@ -441,14 +440,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateVisibleProfiles() private void _UpdateVisibleProfiles()
{ {
_PlayerChooseButtonsVisibleProfiles.Clear(); _PlayerChooseButtonsVisibleProfiles.Clear();
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++) Profile.CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < profiles.Length; i++)
{ {
bool visible = false; bool visible = false;
//Show profile only if active //Show profile only if active
if (CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON) if (profiles[i].Active == EOffOn.TR_CONFIG_ON)
visible = _Data.ScreenNames.ProfileIDsTeam1.All(t => t != i) && _Data.ScreenNames.ProfileIDsTeam2.All(t => t != i); visible = _Data.ScreenNames.ProfileIDsTeam1.All(profileID => profileID != profiles[i].ID) && _Data.ScreenNames.ProfileIDsTeam2.All(profileID => profileID != profiles[i].ID);
if (visible) if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(i); _PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID);
} }
} }
@@ -486,11 +486,12 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
if (_Data.ScreenNames.ProfileIDsTeam1[i] != -1) if (_Data.ScreenNames.ProfileIDsTeam1[i] != -1)
{ {
int id = _Data.ScreenNames.ProfileIDsTeam1[i];
_PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam1[i]].Avatar.Texture; _PlayerDestinationButtons[i].Texture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam1[i]].Avatar.Texture; _PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam1[i]].PlayerName; _PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetPlayerName(id);
_PlayerDestinationButtons[i].Enabled = true; _PlayerDestinationButtons[i].Enabled = true;
} }
} }
@@ -510,11 +511,12 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
if (_Data.ScreenNames.ProfileIDsTeam2[i] != -1) if (_Data.ScreenNames.ProfileIDsTeam2[i] != -1)
{ {
int id = _Data.ScreenNames.ProfileIDsTeam2[i];
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam2[i]].Avatar.Texture; _PlayerDestinationButtons[i].Texture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam2[i]].Avatar.Texture; _PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDsTeam2[i]].PlayerName; _PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetPlayerName(id);
_PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Enabled = true; _PlayerDestinationButtons[i + _PlayerDestinationButtonsNumH].Enabled = true;
} }
} }
@@ -553,9 +555,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
//Update texture and name //Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetAvatar(chooseButton.ProfileID);
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetAvatar(chooseButton.ProfileID);
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetPlayerName(chooseButton.ProfileID);
_PlayerDestinationButtons[added].Enabled = true; _PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List //Update Tiles-List
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
@@ -570,9 +572,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
//Update texture and name //Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetAvatar(chooseButton.ProfileID);
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetAvatar(chooseButton.ProfileID);
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetPlayerName(chooseButton.ProfileID);
_PlayerDestinationButtons[added].Enabled = true; _PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List //Update Tiles-List
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
+33 -29
View File
@@ -28,12 +28,6 @@ using VocaluxeLib.Draw;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
struct SCover
{
public string Name;
public CTexture Texture;
}
struct SCoverTheme struct SCoverTheme
{ {
public string Name; public string Name;
@@ -41,10 +35,10 @@ namespace Vocaluxe.Base
public string File; public string File;
} }
abstract class CCover static class CCover
{ {
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings(); private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
private static readonly List<SCover> _Cover = new List<SCover>(); private static readonly Dictionary<string, CTexture> _Cover = new Dictionary<string, CTexture>();
private static readonly List<SCoverTheme> _CoverThemes = new List<SCoverTheme>(); private static readonly List<SCoverTheme> _CoverThemes = new List<SCoverTheme>();
private static readonly Object _MutexCover = new Object(); private static readonly Object _MutexCover = new Object();
@@ -97,13 +91,11 @@ namespace Vocaluxe.Base
{ {
lock (_MutexCover) lock (_MutexCover)
{ {
foreach (SCover cover in _Cover) if (!_CoverExists(name))
{ return NoCover;
if (cover.Name == name)
return cover.Texture; return _Cover[name];
}
} }
return NoCover;
} }
/// <summary> /// <summary>
@@ -113,7 +105,7 @@ namespace Vocaluxe.Base
{ {
lock (_MutexCover) lock (_MutexCover)
{ {
return _Cover.Any(cover => cover.Name == name); return _Cover.ContainsKey(name);
} }
} }
@@ -122,9 +114,11 @@ namespace Vocaluxe.Base
/// </summary> /// </summary>
public static void ReloadCover() public static void ReloadCover()
{ {
foreach (SCover cover in _Cover) List<string> keys = _Cover.Keys.ToList();
foreach (string key in keys)
{ {
CTexture texture = cover.Texture; CTexture texture = _Cover[key];
CDraw.RemoveTexture(ref texture); CDraw.RemoveTexture(ref texture);
} }
_Cover.Clear(); _Cover.Clear();
@@ -184,8 +178,9 @@ namespace Vocaluxe.Base
if (String.IsNullOrEmpty(coverTheme.Name)) if (String.IsNullOrEmpty(coverTheme.Name))
return; return;
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File));
List<string> ignoreList = new List<string>();
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File));
if (xmlReader != null) if (xmlReader != null)
{ {
lock (_MutexCover) lock (_MutexCover)
@@ -201,12 +196,12 @@ namespace Vocaluxe.Base
string coverFilePath = Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, filePath)); string coverFilePath = Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, filePath));
if (!File.Exists(coverFilePath)) if (!File.Exists(coverFilePath))
continue; continue;
SCover sk = new SCover {Name = name, Texture = CDraw.AddTexture(coverFilePath)};
_Cover.Add(sk); _AddCover(name, coverFilePath);
ignoreList.Add(Path.GetFileName(coverFilePath));
if (sk.Name == "NoCover") if (name == "NoCover")
NoCover = sk.Texture; NoCover = _Cover[name];
} }
} }
} }
@@ -222,15 +217,24 @@ namespace Vocaluxe.Base
foreach (string file in files) foreach (string file in files)
{ {
string name = Path.GetFileNameWithoutExtension(file); if (!ignoreList.Contains(Path.GetFileName(file)))
_AddCover(Path.GetFileNameWithoutExtension(file), file);
}
}
if (_CoverExists(name)) private static void _AddCover(string Name, string File)
continue; {
// ReSharper disable AssignNullToNotNullAttribute CTexture texture = CDraw.AddTexture(File);
SCover sk = new SCover {Name = name, Texture = CDraw.AddTexture(file)};
// ReSharper restore AssignNullToNotNullAttribute
_Cover.Add(sk); if (!_CoverExists(Name))
{
_Cover.Add(Name, texture);
}
else
{
CTexture tex = _Cover[Name];
CDraw.RemoveTexture(ref tex);
_Cover[Name] = texture;
} }
} }
} }
+5
View File
@@ -561,6 +561,11 @@ namespace Vocaluxe.Base
{ {
return CProfiles.GetPlayerName(profileID, playerNum); return CProfiles.GetPlayerName(profileID, playerNum);
} }
public CTexture GetAvatar(int profileID)
{
return CProfiles.GetAvatarTextureFromProfile(profileID);
}
} }
class CBrecord : IRecording class CBrecord : IRecording
+5
View File
@@ -481,6 +481,11 @@ namespace Vocaluxe.Base
return _Profiles[profileID].Avatar.ID; return _Profiles[profileID].Avatar.ID;
} }
public static int GetProfileID(int num)
{
return _Profiles[num].ID;
}
#endregion profile properties #endregion profile properties
#region avatar texture #region avatar texture
+1 -1
View File
@@ -53,7 +53,7 @@ namespace Vocaluxe.Base
//TODO: Remove this when this is decided //TODO: Remove this when this is decided
private const string _ProgramCodeName = "Shining Heaven"; private const string _ProgramCodeName = "Shining Heaven";
public const ERevision VersionRevision = ERevision.Alpha; public const ERevision VersionRevision = ERevision.Beta;
public const int DatabaseHighscoreVersion = 2; public const int DatabaseHighscoreVersion = 2;
public const int DatabaseCoverVersion = 1; public const int DatabaseCoverVersion = 1;
+2 -2
View File
@@ -72,9 +72,9 @@ namespace Vocaluxe.Base
Char firstLetter = Char.ToUpper(songPointer.SortString.Normalize(NormalizationForm.FormD)[0]); Char firstLetter = Char.ToUpper(songPointer.SortString.Normalize(NormalizationForm.FormD)[0]);
if (Char.IsLetter(firstLetter)) if (Char.IsLetter(firstLetter))
{ {
if (lastCategory == null || songPointer.SortString != lastCategory.Name) if (lastCategory == null || firstLetter.ToString() != lastCategory.Name)
{ {
lastCategory = new CCategory(songPointer.SortString); lastCategory = new CCategory(firstLetter.ToString());
_Categories.Add(lastCategory); _Categories.Add(lastCategory);
} }
lastCategory.Songs.Add(songPointer); lastCategory.Songs.Add(songPointer);
+8 -8
View File
@@ -86,28 +86,28 @@ namespace Vocaluxe.Base
private int _SortByFieldArtistTitle(CSongPointer s1, CSongPointer s2) private int _SortByFieldArtistTitle(CSongPointer s1, CSongPointer s2)
{ {
int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase); int res = String.Compare(s1.SortString, s2.SortString, StringComparison.CurrentCultureIgnoreCase);
if (res == 0) if (res == 0)
{ {
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
{ {
res = String.Compare(CSongs.Songs[s1.SongID].ArtistSorting, CSongs.Songs[s2.SongID].ArtistSorting, StringComparison.OrdinalIgnoreCase); res = String.Compare(CSongs.Songs[s1.SongID].ArtistSorting, CSongs.Songs[s2.SongID].ArtistSorting, StringComparison.CurrentCultureIgnoreCase);
return res != 0 ? res : String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase); return res != 0 ? res : String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.CurrentCultureIgnoreCase);
} }
res = String.Compare(CSongs.Songs[s1.SongID].Artist, CSongs.Songs[s2.SongID].Artist, StringComparison.OrdinalIgnoreCase); res = String.Compare(CSongs.Songs[s1.SongID].Artist, CSongs.Songs[s2.SongID].Artist, StringComparison.CurrentCultureIgnoreCase);
return res != 0 ? res : String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.OrdinalIgnoreCase); return res != 0 ? res : String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.CurrentCultureIgnoreCase);
} }
return res; return res;
} }
private int _SortByFieldTitle(CSongPointer s1, CSongPointer s2) private int _SortByFieldTitle(CSongPointer s1, CSongPointer s2)
{ {
int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase); int res = String.Compare(s1.SortString, s2.SortString, StringComparison.CurrentCultureIgnoreCase);
if (res == 0) if (res == 0)
{ {
return _IgnoreArticles == EOffOn.TR_CONFIG_ON return _IgnoreArticles == EOffOn.TR_CONFIG_ON
? String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase) : ? String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.CurrentCultureIgnoreCase) :
String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.OrdinalIgnoreCase); String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.CurrentCultureIgnoreCase);
} }
return res; return res;
} }
+5 -25
View File
@@ -44,7 +44,11 @@ namespace Vocaluxe.Base.Server
public static void Init() public static void Init()
{ {
_Clients = new Dictionary<int, CClientHandler>(); _Clients = new Dictionary<int, CClientHandler>();
_Server = new CServer(RequestHandler, CConfig.ServerPort, CConfig.ServerEncryption == EOffOn.TR_CONFIG_ON); if (CConfig.ServerEncryption == EOffOn.TR_CONFIG_ON)
_Server = new CServer(RequestHandler, CConfig.ServerPort, CConfig.ServerPassword);
else
_Server = new CServer(RequestHandler, CConfig.ServerPort, String.Empty);
_Discover = new CDiscover(CConfig.ServerPort, CCommands.BroadcastKeyword); _Discover = new CDiscover(CConfig.ServerPort, CCommands.BroadcastKeyword);
Controller.Init(); Controller.Init();
} }
@@ -88,30 +92,6 @@ namespace Vocaluxe.Base.Server
} }
int command = BitConverter.ToInt32(message, 0); int command = BitConverter.ToInt32(message, 0);
switch (command)
{
case CCommands.CommandLogin:
SLoginData data;
if (!CCommands.DecodeCommandLogin(message, out data))
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseLoginFailed);
else
{
byte[] serverPw = CCommands.SHA256.ComputeHash(Encoding.UTF8.GetBytes(CConfig.ServerPassword));
if (!serverPw.SequenceEqual(data.SHA256))
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseLoginWrongPassword);
else
{
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseLoginOK);
_Clients[connectionID].LoggedIn = true;
}
}
break;
}
if (!loggedIn)
return answer;
switch (command) switch (command)
{ {
+1 -1
View File
@@ -160,7 +160,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
try try
{ {
CAcinerella.AcSeek(_Videodecoder, (_LastDecodedTime > _SkipTime) ? -1 : 0, (Int64)(_SkipTime * 1000f)); CAcinerella.AcSeek(_Videodecoder, -1, (Int64)(_SkipTime * 1000f));
} }
catch (Exception e) catch (Exception e)
{ {
+2 -2
View File
@@ -51,5 +51,5 @@ using System.Runtime.InteropServices;
// Revision // Revision
// //
[assembly: AssemblyVersion("0.3.0.78")] [assembly: AssemblyVersion("0.3.0.80")]
[assembly: AssemblyFileVersion("0.3.0.78")] [assembly: AssemblyFileVersion("0.3.0.80")]
+60 -111
View File
@@ -62,7 +62,7 @@ namespace Vocaluxe.Screens
private bool _SelectingFast; private bool _SelectingFast;
private int _SelectingSwitchNr = -1; private int _SelectingSwitchNr = -1;
private int _SelectingFastPlayerNr; private int _SelectingFastPlayerNr;
private int _SelectedPlayerNr = -1; private int _SelectedProfileID = -1;
private bool _AvatarsChanged; private bool _AvatarsChanged;
private bool _ProfilesChanged; private bool _ProfilesChanged;
@@ -177,23 +177,13 @@ namespace Vocaluxe.Screens
//Check, if a player is selected //Check, if a player is selected
if (_NameSelections[_NameSelection].Selection > -1) if (_NameSelections[_NameSelection].Selection > -1)
{ {
CProfile[] profiles = CProfiles.GetProfiles(); _SelectedProfileID = _NameSelections[_NameSelection].Selection;
_SelectedPlayerNr = _NameSelections[_NameSelection].Selection;
if (profiles.Length <= _SelectedPlayerNr) if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
return true; return true;
//Update Game-infos with new player _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID);
CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = profiles[_SelectedPlayerNr].ID;
//Update config for default players.
CConfig.Players[_SelectingFastPlayerNr - 1] = profiles[_SelectedPlayerNr].FileName;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = profiles[_SelectedPlayerNr].Avatar.Texture;
_Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
_NameSelections[_NameSelection].UpdateList();
_SetInteractionToButton(_Buttons[_ButtonStart]); _SetInteractionToButton(_Buttons[_ButtonStart]);
} }
//Started selecting with 'P' //Started selecting with 'P'
@@ -242,15 +232,7 @@ namespace Vocaluxe.Screens
case Keys.Delete: case Keys.Delete:
//Delete profile-selection //Delete profile-selection
CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = -1; _ResetPlayerSelection(_SelectingFastPlayerNr - 1);
//Update config for default players.
CConfig.Players[_SelectingFastPlayerNr - 1] = String.Empty;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = _OriginalPlayerAvatarTextures[_SelectingFastPlayerNr - 1];
_Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = CProfiles.GetPlayerName(-1, _SelectingFastPlayerNr);
//Update profile-warning
_CheckPlayers();
//Reset all values //Reset all values
_SelectingFastPlayerNr = 0; _SelectingFastPlayerNr = 0;
_SelectingKeyboardActive = false; _SelectingKeyboardActive = false;
@@ -365,7 +347,7 @@ namespace Vocaluxe.Screens
base.HandleMouse(mouseEvent); base.HandleMouse(mouseEvent);
//Check if LeftButton is hold and Select-Mode inactive //Check if LeftButton is hold and Select-Mode inactive
if (mouseEvent.LBH && _SelectedPlayerNr < 0 && !_SelectingFast) if (mouseEvent.LBH && _SelectedProfileID < 0 && !_SelectingFast)
{ {
//Save mouse-coords //Save mouse-coords
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
@@ -374,8 +356,8 @@ namespace Vocaluxe.Screens
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{ {
//Get player-number of tile //Get player-number of tile
_SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
if (_SelectedPlayerNr != -1) if (_SelectedProfileID != -1)
{ {
//Update of Drag/Drop-Texture //Update of Drag/Drop-Texture
CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent); CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
@@ -393,7 +375,7 @@ namespace Vocaluxe.Screens
if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent))
{ {
_SelectingSwitchNr = i; _SelectingSwitchNr = i;
_SelectedPlayerNr = CGame.Players[i].ProfileID; _SelectedProfileID = CGame.Players[i].ProfileID;
//Update of Drag/Drop-Texture //Update of Drag/Drop-Texture
CStatic selectedPlayer = _Statics[_StaticPlayerAvatar[i]]; CStatic selectedPlayer = _Statics[_StaticPlayerAvatar[i]];
_ChooseAvatarStatic.Visible = true; _ChooseAvatarStatic.Visible = true;
@@ -408,7 +390,7 @@ namespace Vocaluxe.Screens
} }
//Check if LeftButton is hold and Select-Mode active //Check if LeftButton is hold and Select-Mode active
if (mouseEvent.LBH && _SelectedPlayerNr >= 0 && !_SelectingFast) if (mouseEvent.LBH && _SelectedProfileID >= 0 && !_SelectingFast)
{ {
//Update coords for Drag/Drop-Texture //Update coords for Drag/Drop-Texture
_ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX; _ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX;
@@ -417,7 +399,7 @@ namespace Vocaluxe.Screens
_OldMouseY = mouseEvent.Y; _OldMouseY = mouseEvent.Y;
} }
// LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar // LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar
else if (_SelectedPlayerNr >= 0 && !_SelectingFast) else if (_SelectedProfileID >= 0 && !_SelectingFast)
{ {
//Foreach Drop-Area //Foreach Drop-Area
for (int i = 0; i < _StaticPlayer.Length; i++) for (int i = 0; i < _StaticPlayer.Length; i++)
@@ -430,58 +412,27 @@ namespace Vocaluxe.Screens
{ {
if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1) if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID > -1)
{ {
//Update Game-infos with new player _UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID);
CGame.Players[_SelectingSwitchNr].ProfileID = CGame.Players[i].ProfileID;
//Update config for default players.
CConfig.Players[_SelectingSwitchNr] = CProfiles.GetProfileFileName(CGame.Players[i].ProfileID);
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = CProfiles.GetAvatarTextureFromProfile(CGame.Players[i].ProfileID);
_Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID);
} }
else if (_SelectingSwitchNr > -1) else if (_SelectingSwitchNr > -1)
{ {
//Update Game-infos with new player _ResetPlayerSelection(_SelectingSwitchNr);
CGame.Players[_SelectingSwitchNr].ProfileID = -1;
//Update config for default players.
CConfig.Players[_SelectingSwitchNr] = string.Empty;
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = _OriginalPlayerAvatarTextures[_SelectingSwitchNr];
_Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.GetPlayerName(-1, (_SelectingSwitchNr + 1));
} }
CProfile[] profiles = CProfiles.GetProfiles(); if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
if (profiles.Length <= _SelectedPlayerNr)
return true; return true;
//Update Game-infos with new player _UpdateSelectedProfile(i, _SelectedProfileID);
CGame.Players[i].ProfileID = profiles[_SelectedPlayerNr].ID;
//Update config for default players.
CConfig.Players[i] = profiles[_SelectedPlayerNr].FileName;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture;
_Texts[_TextPlayer[i]].Text = profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
_NameSelections[_NameSelection].UpdateList();
break; break;
} }
//Selected player is dropped out of area //Selected player is dropped out of area
if (_SelectingSwitchNr > -1) if (_SelectingSwitchNr > -1)
{ {
//Update Game-infos with new player _ResetPlayerSelection(_SelectingSwitchNr);
CGame.Players[_SelectingSwitchNr].ProfileID = -1;
//Update config for default players.
CConfig.Players[_SelectingSwitchNr] = string.Empty;
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = _OriginalPlayerAvatarTextures[_SelectingSwitchNr];
_Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.GetPlayerName(-1, (_SelectingSwitchNr + 1));
_NameSelections[_NameSelection].UpdateList();
} }
} }
_SelectingSwitchNr = -1; _SelectingSwitchNr = -1;
_SelectedPlayerNr = -1; _SelectedProfileID = -1;
//Reset variables //Reset variables
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
} }
@@ -491,25 +442,14 @@ namespace Vocaluxe.Screens
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
{ {
//Get player-number of tile //Get player-number of tile
_SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
if (_SelectedPlayerNr != -1) if (_SelectedProfileID != -1)
{ {
CProfile[] profiles = CProfiles.GetProfiles(); if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
if (profiles.Length <= _SelectedPlayerNr)
return true; return true;
//Update Game-infos with new player _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID);
CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = profiles[_SelectedPlayerNr].ID;
//Update config for default players.
CConfig.Players[_SelectingFastPlayerNr - 1] = profiles[_SelectedPlayerNr].FileName;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = profiles[_SelectedPlayerNr].Avatar.Texture;
_Texts[_TextPlayer[_SelectingFastPlayerNr - 1]].Text = profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
_NameSelections[_NameSelection].UpdateList();
_SelectingFastPlayerNr++; _SelectingFastPlayerNr++;
if (_SelectingFastPlayerNr <= CGame.NumPlayer) if (_SelectingFastPlayerNr <= CGame.NumPlayer)
_NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
@@ -534,29 +474,17 @@ namespace Vocaluxe.Screens
if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast) if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast)
{ {
_SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
if (_SelectedPlayerNr > -1) if (_SelectedProfileID > -1)
{ {
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
{ {
if (CGame.Players[i].ProfileID == -1) if (CGame.Players[i].ProfileID == -1)
{ {
CProfile[] profiles = CProfiles.GetProfiles(); if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
if (profiles.Length <= _SelectedPlayerNr)
return true; return true;
//Update Game-infos with new player _UpdateSelectedProfile(i, _SelectedProfileID);
CGame.Players[i].ProfileID = profiles[_SelectedPlayerNr].ID;
//Update config for default players.
CConfig.Players[i] = profiles[_SelectedPlayerNr].FileName;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[i]].Texture = profiles[_SelectedPlayerNr].Avatar.Texture;
_Texts[_TextPlayer[i]].Text = profiles[_SelectedPlayerNr].PlayerName;
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
_NameSelections[_NameSelection].UpdateList();
break; break;
} }
} }
@@ -573,17 +501,7 @@ namespace Vocaluxe.Screens
{ {
if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent))
{ {
CGame.Players[i].ProfileID = -1; _ResetPlayerSelection(i);
//Update config for default players.
CConfig.Players[i] = String.Empty;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i];
_Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(-1, i + 1);
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
_NameSelections[_NameSelection].UpdateList();
exit = false; exit = false;
} }
} }
@@ -760,6 +678,22 @@ namespace Vocaluxe.Screens
_CheckPlayers(); _CheckPlayers();
} }
private void _UpdateSelectedProfile(int playerNum, int profileId)
{
//Update Game-infos with new player
CGame.Players[playerNum].ProfileID = profileId;
//Update config for default players.
CConfig.Players[playerNum] = CProfiles.GetProfileFileName(profileId);
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[playerNum]].Texture = CProfiles.GetAvatarTextureFromProfile(profileId);
_Texts[_TextPlayer[playerNum]].Text = CProfiles.GetPlayerName(profileId);
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
_NameSelections[_NameSelection].UpdateList();
}
private void _ResetPlayerSelections() private void _ResetPlayerSelections()
{ {
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
@@ -775,6 +709,21 @@ namespace Vocaluxe.Screens
CConfig.SaveConfig(); CConfig.SaveConfig();
} }
private void _ResetPlayerSelection(int playerNum)
{
CGame.Players[playerNum].ProfileID = -1;
//Update config for default players.
CConfig.Players[playerNum] = String.Empty;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[playerNum]].Texture = _OriginalPlayerAvatarTextures[playerNum];
_Texts[_TextPlayer[playerNum]].Text = CProfiles.GetPlayerName(-1, playerNum + 1);
//Update profile-warning
_CheckPlayers();
//Update Tiles-List
_NameSelections[_NameSelection].UpdateList();
}
private void _CheckMics() private void _CheckMics()
{ {
List<int> playerWithoutMicro = new List<int>(); List<int> playerWithoutMicro = new List<int>();
+73 -14
View File
@@ -172,7 +172,7 @@ namespace Vocaluxe.Screens
{ {
if (_SearchActive) if (_SearchActive)
_ApplyNewSearchFilter(_SearchText + keyEvent.Unicode); _ApplyNewSearchFilter(_SearchText + keyEvent.Unicode);
else else if(!_Sso.Selection.PartyMode)
{ {
_JumpTo(keyEvent.Unicode); _JumpTo(keyEvent.Unicode);
return true; return true;
@@ -284,26 +284,32 @@ namespace Vocaluxe.Screens
break; break;
case Keys.D1: case Keys.D1:
case Keys.NumPad1:
_SelectNextRandom(0); _SelectNextRandom(0);
break; break;
case Keys.D2: case Keys.D2:
case Keys.NumPad2:
_SelectNextRandom(1); _SelectNextRandom(1);
break; break;
case Keys.D3: case Keys.D3:
case Keys.NumPad3:
_SelectNextRandom(2); _SelectNextRandom(2);
break; break;
case Keys.D4: case Keys.D4:
case Keys.NumPad4:
_SelectNextRandom(3); _SelectNextRandom(3);
break; break;
case Keys.D5: case Keys.D5:
case Keys.NumPad5:
_SelectNextRandom(4); _SelectNextRandom(4);
break; break;
case Keys.D6: case Keys.D6:
case Keys.NumPad6:
_SelectNextRandom(5); _SelectNextRandom(5);
break; break;
} }
@@ -443,9 +449,7 @@ namespace Vocaluxe.Screens
if (mouseEvent.LD && !_Sso.Selection.PartyMode) if (mouseEvent.LD && !_Sso.Selection.PartyMode)
{ {
//TODO: Causes Bug if you select a song (e.g. with Select random song) and double click a normal button. if (CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1 && _SongMenus[_SongMenu].IsMouseOverActualSelection(mouseEvent))
//E.g. clicking to fast on Select random song starts the next random song. is this OK?
if (CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1)
{ {
_ToggleSongOptions(ESongOptionsView.None); _ToggleSongOptions(ESongOptionsView.None);
_StartVisibleSong(_SongMenus[_SongMenu].GetActualSelection()); _StartVisibleSong(_SongMenus[_SongMenu].GetActualSelection());
@@ -1003,18 +1007,76 @@ namespace Vocaluxe.Screens
{ {
int start = 0; int start = 0;
int curSelected = _SongMenus[_SongMenu].GetActualSelection(); int curSelected = _SongMenus[_SongMenu].GetActualSelection();
if (CSongs.IsInCategory) bool firstLevel = CConfig.Tabs == EOffOn.TR_CONFIG_OFF && CSongs.IsInCategory;
bool secondSort = CConfig.Tabs == EOffOn.TR_CONFIG_ON &&
(CConfig.SongSorting == ESongSorting.TR_CONFIG_ARTIST ||
CConfig.SongSorting == ESongSorting.TR_CONFIG_ARTIST_LETTER ||
CConfig.SongSorting == ESongSorting.TR_CONFIG_FOLDER ||
CConfig.SongSorting == ESongSorting.TR_CONFIG_TITLE_LETTER);
if (firstLevel && !secondSort)
{ {
//TODO: Check and use sorting method //TODO: What's to do with multiple tags?
//How can we get current letter? I think we have to save it - Or is there a better method?
ReadOnlyCollection<CSong> songs = CSongs.VisibleSongs; ReadOnlyCollection<CSong> songs = CSongs.VisibleSongs;
int ct = songs.Count; int ct = songs.Count;
if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)) int visibleID = -1;
start = curSelected + 1; switch (CConfig.SongSorting)
int visibleID = _FindIndex(songs, start, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); {
case ESongSorting.TR_CONFIG_ARTIST:
case ESongSorting.TR_CONFIG_ARTIST_LETTER:
if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
visibleID = _FindIndex(songs, start, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase));
break;
//TODO: Does this make sense? Maybe we should deactivate this for years? You could only jump between 1 and 2
case ESongSorting.TR_CONFIG_YEAR:
case ESongSorting.TR_CONFIG_DECADE:
if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Year.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
visibleID = _FindIndex(songs, start, element => element.Year.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase));
break;
case ESongSorting.TR_CONFIG_TITLE_LETTER:
if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Title.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
visibleID = _FindIndex(songs, start, element => element.Title.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase));
break;
case ESongSorting.TR_CONFIG_FOLDER:
if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Folder.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
visibleID = _FindIndex(songs, start, element => element.Folder.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase));
break;
}
if (visibleID > -1) if (visibleID > -1)
_SongMenus[_SongMenu].SetSelectedSong(visibleID); _SongMenus[_SongMenu].SetSelectedSong(visibleID);
} }
else else if (secondSort && CSongs.IsInCategory)
{
ReadOnlyCollection<CSong> songs = CSongs.VisibleSongs;
int ct = songs.Count;
int visibleID = -1;
switch (CConfig.SongSorting)
{
case ESongSorting.TR_CONFIG_FOLDER:
case ESongSorting.TR_CONFIG_TITLE_LETTER:
if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
visibleID = _FindIndex(songs, start, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase));
break;
case ESongSorting.TR_CONFIG_ARTIST:
case ESongSorting.TR_CONFIG_ARTIST_LETTER:
if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Title.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
visibleID = _FindIndex(songs, start, element => element.Title.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase));
break;
}
if (visibleID > -1)
_SongMenus[_SongMenu].SetSelectedSong(visibleID);
}
else if(!CSongs.IsInCategory)
{ {
ReadOnlyCollection<CCategory> categories = CSongs.Categories; ReadOnlyCollection<CCategory> categories = CSongs.Categories;
int ct = categories.Count; int ct = categories.Count;
@@ -1137,6 +1199,7 @@ namespace Vocaluxe.Screens
_Buttons[_ButtonOptionsSing].Visible = true; _Buttons[_ButtonOptionsSing].Visible = true;
_Buttons[_ButtonOptionsPlaylist].Visible = true; _Buttons[_ButtonOptionsPlaylist].Visible = true;
_SetInteractionToButton(_Buttons[_ButtonOptionsSing]); _SetInteractionToButton(_Buttons[_ButtonOptionsSing]);
_SetSelectSlidePlaylistToCurrentPlaylist();
} }
private void _ShowSongOptionsGeneral() private void _ShowSongOptionsGeneral()
@@ -1199,7 +1262,6 @@ namespace Vocaluxe.Screens
_Playlists[_Playlist].LoadPlaylist(playlistID); _Playlists[_Playlist].LoadPlaylist(playlistID);
_SongMenus[_SongMenu].SetSmallView(true); _SongMenus[_SongMenu].SetSmallView(true);
_Playlists[_Playlist].Visible = true; _Playlists[_Playlist].Visible = true;
_SetSelectSlidePlaylistToCurrentPlaylist();
} }
} }
@@ -1250,7 +1312,6 @@ namespace Vocaluxe.Screens
//Open playlist //Open playlist
_OpenPlaylist(_Playlists[_Playlist].ActivePlaylistID); _OpenPlaylist(_Playlists[_Playlist].ActivePlaylistID);
_SetSelectSlidePlaylistToCurrentPlaylist();
_Playlists[_Playlist].ScrollToBottom(); _Playlists[_Playlist].ScrollToBottom();
} }
} }
@@ -1278,8 +1339,6 @@ namespace Vocaluxe.Screens
//Add new playlist to select-slide //Add new playlist to select-slide
_SelectSlides[_SelectSlideOptionsPlaylistAdd].AddValue(CPlaylists.Playlists[_Playlists[_Playlist].ActivePlaylistID].PlaylistName); _SelectSlides[_SelectSlideOptionsPlaylistAdd].AddValue(CPlaylists.Playlists[_Playlists[_Playlist].ActivePlaylistID].PlaylistName);
_SelectSlides[_SelectSlideOptionsPlaylistOpen].AddValue(CPlaylists.Playlists[_Playlists[_Playlist].ActivePlaylistID].PlaylistName); _SelectSlides[_SelectSlideOptionsPlaylistOpen].AddValue(CPlaylists.Playlists[_Playlists[_Playlist].ActivePlaylistID].PlaylistName);
_SetSelectSlidePlaylistToCurrentPlaylist();
} }
//Add song to loaded playlist //Add song to loaded playlist
else else
+5 -2
View File
@@ -73,9 +73,12 @@ namespace VocaluxeLib
try try
{ {
int tmp = sr.Peek(); int tmp = sr.Peek();
//Check for ' ', ?, ?, \n, \r //Check for ' ', ?, ?, \n, \r, E
while (tmp != 32 && tmp != 19 && tmp != 16 && tmp != 13 && tmp != 10) while (tmp != 32 && tmp != 19 && tmp != 16 && tmp != 13 && tmp != 10 && tmp != 69)
{ {
if (sr.EndOfStream)
break;
char chr = (char)sr.Read(); char chr = (char)sr.Read();
value += chr.ToString(); value += chr.ToString();
tmp = sr.Peek(); tmp = sr.Peek();
+1
View File
@@ -197,6 +197,7 @@ namespace VocaluxeLib
CProfile[] GetProfiles(); CProfile[] GetProfiles();
EGameDifficulty GetDifficulty(int profileID); EGameDifficulty GetDifficulty(int profileID);
string GetPlayerName(int profileID, int playerNum = 0); string GetPlayerName(int profileID, int playerNum = 0);
CTexture GetAvatar(int profileID);
} }
public interface ISongs public interface ISongs
+11 -11
View File
@@ -44,15 +44,15 @@ namespace VocaluxeLib.Menu
{ {
private class CTile private class CTile
{ {
public int PlayerNr; public int ProfileID;
public readonly CStatic Avatar; public readonly CStatic Avatar;
public readonly CText Name; public readonly CText Name;
public CTile(CStatic av, CText tex, int pl) public CTile(CStatic av, CText tex, int pID)
{ {
Avatar = av; Avatar = av;
Name = tex; Name = tex;
PlayerNr = pl; ProfileID = pID;
} }
} }
@@ -281,7 +281,7 @@ namespace VocaluxeLib.Menu
case Keys.Right: case Keys.Right:
if (_ActualSelection + 1 < _Tiles.Count) if (_ActualSelection + 1 < _Tiles.Count)
{ {
if (_Tiles[_ActualSelection + 1].PlayerNr != -1) if (_Tiles[_ActualSelection + 1].ProfileID != -1)
_ActualSelection++; _ActualSelection++;
} }
else else
@@ -316,7 +316,7 @@ namespace VocaluxeLib.Menu
case Keys.Down: case Keys.Down:
if (_ActualSelection + _NumW < _Tiles.Count) if (_ActualSelection + _NumW < _Tiles.Count)
{ {
if (_Tiles[_ActualSelection + _NumW].PlayerNr != -1) if (_Tiles[_ActualSelection + _NumW].ProfileID != -1)
_ActualSelection += _NumW; _ActualSelection += _NumW;
} }
else else
@@ -326,11 +326,11 @@ namespace VocaluxeLib.Menu
if (offset != Offset) if (offset != Offset)
{ {
_ActualSelection = _ActualSelection - _Tiles.Count + _NumW; _ActualSelection = _ActualSelection - _Tiles.Count + _NumW;
if (_Tiles[_ActualSelection].PlayerNr == -1) if (_Tiles[_ActualSelection].ProfileID == -1)
{ {
for (int i = _Tiles.Count - 1; i >= 0; i--) for (int i = _Tiles.Count - 1; i >= 0; i--)
{ {
if (_Tiles[i].PlayerNr != -1) if (_Tiles[i].ProfileID != -1)
{ {
_ActualSelection = i; _ActualSelection = i;
break; break;
@@ -412,14 +412,14 @@ namespace VocaluxeLib.Menu
_Tiles[i].Avatar.Texture = CBase.Profiles.GetProfiles()[_VisibleProfiles[i + offset * _Tiles.Count]].Avatar.Texture; _Tiles[i].Avatar.Texture = CBase.Profiles.GetProfiles()[_VisibleProfiles[i + offset * _Tiles.Count]].Avatar.Texture;
_Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1); _Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1);
_Tiles[i].Name.Text = CBase.Profiles.GetProfiles()[_VisibleProfiles[i + offset * _Tiles.Count]].PlayerName; _Tiles[i].Name.Text = CBase.Profiles.GetProfiles()[_VisibleProfiles[i + offset * _Tiles.Count]].PlayerName;
_Tiles[i].PlayerNr = _VisibleProfiles[i + offset * _Tiles.Count]; _Tiles[i].ProfileID = _VisibleProfiles[i + offset * _Tiles.Count];
} }
else else
{ {
_Tiles[i].Avatar.Texture = _TextureEmptyTile; _Tiles[i].Avatar.Texture = _TextureEmptyTile;
_Tiles[i].Avatar.Color = ColorEmptyTile; _Tiles[i].Avatar.Color = ColorEmptyTile;
_Tiles[i].Name.Text = ""; _Tiles[i].Name.Text = "";
_Tiles[i].PlayerNr = -1; _Tiles[i].ProfileID = -1;
} }
} }
Offset = offset; Offset = offset;
@@ -441,7 +441,7 @@ namespace VocaluxeLib.Menu
foreach (CTile tile in _Tiles) foreach (CTile tile in _Tiles)
{ {
if (CHelper.IsInBounds(tile.Avatar.Rect, mevent)) if (CHelper.IsInBounds(tile.Avatar.Rect, mevent))
return tile.PlayerNr; return tile.ProfileID;
} }
return -1; return -1;
@@ -515,7 +515,7 @@ namespace VocaluxeLib.Menu
} }
} }
if (visible) if (visible)
_VisibleProfiles.Add(i); _VisibleProfiles.Add(profiles[i].ID);
} }
} }
+2
View File
@@ -199,6 +199,8 @@ namespace VocaluxeLib.Menu
{ {
_Theme.Text = value; _Theme.Text = value;
_Text = translation; _Text = translation;
if (_EditMode)
_Text += "|";
_PositionNeedsUpdate = true; _PositionNeedsUpdate = true;
} }
} }
+5
View File
@@ -98,6 +98,11 @@ namespace VocaluxeLib.Menu.SongMenu
_SongMenu.SetActive(active); _SongMenu.SetActive(active);
} }
public bool IsMouseOverActualSelection(SMouseEvent mEvent)
{
return _SongMenu.IsMouseOverActualSelection(mEvent);
}
public int GetSelectedSong() public int GetSelectedSong()
{ {
return _SongMenu.GetSelectedSong(); return _SongMenu.GetSelectedSong();
@@ -518,6 +518,8 @@ namespace VocaluxeLib.Menu.SongMenu
_Active = active; _Active = active;
} }
public virtual bool IsMouseOverActualSelection(SMouseEvent mEvent) { return false; }
public virtual int GetSelectedSong() public virtual int GetSelectedSong()
{ {
return -1; return -1;
@@ -625,6 +627,9 @@ namespace VocaluxeLib.Menu.SongMenu
if (Math.Abs(startposition) < 0.001) if (Math.Abs(startposition) < 0.001)
startposition = CBase.Sound.GetLength(stream) / 4f; startposition = CBase.Sound.GetLength(stream) / 4f;
if (startposition >= 0.5f)
startposition -= 0.5f;
CBase.Sound.SetPosition(stream, startposition); CBase.Sound.SetPosition(stream, startposition);
CBase.Sound.Play(stream); CBase.Sound.Play(stream);
CBase.Sound.Fade(stream, 100f, 3f); CBase.Sound.Fade(stream, 100f, 3f);
@@ -485,6 +485,15 @@ namespace VocaluxeLib.Menu.SongMenu
return _Locked; return _Locked;
} }
public override bool IsMouseOverActualSelection(SMouseEvent mEvent)
{
CStatic selCov = GetSelectedSongCover();
if (selCov.Texture == null)
return false;
SRectF rect = new SRectF(selCov.Rect.X - selCov.Rect.W*0.2f, selCov.Rect.Y - selCov.Rect.H*0.2f, selCov.Rect.W*1.2f, selCov.Rect.H*1.2f, selCov.Rect.Z);
return CHelper.IsInBounds(rect, mEvent);
}
public override CStatic GetSelectedSongCover() public override CStatic GetSelectedSongCover()
{ {
foreach (CStatic tile in _Tiles) foreach (CStatic tile in _Tiles)
+2
View File
@@ -40,6 +40,8 @@ namespace VocaluxeLib.Menu.SongMenu
bool IsActive(); bool IsActive();
void SetActive(bool active); void SetActive(bool active);
bool IsMouseOverActualSelection(SMouseEvent mEvent);
int GetSelectedCategory(); int GetSelectedCategory();
void SetSelectedCategory(int categoryNr); void SetSelectedCategory(int categoryNr);
int GetActualSelection(); int GetActualSelection();