Fixed .Net 4 and XP support
This commit is contained in:
1 parent
2df9c2d6f4
commit
6f5834db89
6 files changed
+200
-151
No files matched your search
@@ -19,15 +19,14 @@ namespace Vocaluxe.Base
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (_LogFile != null)
|
||||
if (_LogFile == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_LogFile.Flush();
|
||||
_LogFile.Close();
|
||||
}
|
||||
catch (Exception) {}
|
||||
_LogFile.Flush();
|
||||
_LogFile.Close();
|
||||
}
|
||||
catch (Exception) {}
|
||||
}
|
||||
|
||||
public void Add(string text)
|
||||
@@ -47,7 +46,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
_LogFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _LogFileName), false, Encoding.UTF8);
|
||||
|
||||
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now.ToString());
|
||||
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
|
||||
_LogFile.WriteLine("----------------------------------------");
|
||||
_LogFile.WriteLine();
|
||||
}
|
||||
@@ -99,7 +98,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
_NumErrors++;
|
||||
|
||||
_ErrorLog.Add(_NumErrors.ToString() + ") " + errorText);
|
||||
_ErrorLog.Add(_NumErrors + ") " + errorText);
|
||||
_ErrorLog.Add(String.Empty);
|
||||
}
|
||||
#endregion LogError
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Vocaluxe.Base;
|
||||
|
||||
namespace Vocaluxe
|
||||
{
|
||||
class CSplashScreen : Form
|
||||
{
|
||||
private readonly Bitmap _Logo;
|
||||
|
||||
public CSplashScreen()
|
||||
{
|
||||
string path = Path.Combine(Environment.CurrentDirectory, Path.Combine(CSettings.FolderGraphics, CSettings.Logo));
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
_Logo = new Bitmap(path);
|
||||
ClientSize = new Size(_Logo.Width, _Logo.Height);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading logo: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
|
||||
path = Path.Combine(Environment.CurrentDirectory, CSettings.Icon);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
Icon = new Icon(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading icon: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
BackColor = Color.Transparent;
|
||||
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
Text = CSettings.ProgramName;
|
||||
CenterToScreen();
|
||||
Show();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e) {}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
if (_Logo == null)
|
||||
return;
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
g.DrawImage(_Logo, new Rectangle(0, 0, Width, Height));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,23 @@
|
||||
using System.Drawing.Drawing2D;
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Threading;
|
||||
using SlimDX;
|
||||
using SlimDX.Direct3D9;
|
||||
@@ -117,6 +136,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
_PresentParameters.MultisampleQuality = 0;
|
||||
|
||||
//Apply antialiasing and check if antialiasing mode is supported
|
||||
|
||||
#region Antialiasing
|
||||
int quality = 1;
|
||||
MultisampleType msType;
|
||||
@@ -912,38 +932,11 @@ namespace Vocaluxe.Lib.Draw
|
||||
h = maxSize;
|
||||
}
|
||||
|
||||
//Older graphics card can only handle textures with sizes being powers of two
|
||||
w = (int)_CheckForNextPowerOf2(w);
|
||||
h = (int)_CheckForNextPowerOf2(h);
|
||||
|
||||
Bitmap bmp2 = null;
|
||||
byte[] data;
|
||||
try
|
||||
{
|
||||
if (w != bmp.Width || h != bmp.Height)
|
||||
{
|
||||
//Create a new Bitmap with the new sizes
|
||||
bmp2 = new Bitmap(w, h);
|
||||
//Scale the texture
|
||||
Graphics g = Graphics.FromImage(bmp2);
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||
g.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height));
|
||||
g.Dispose();
|
||||
bmp = bmp2;
|
||||
}
|
||||
|
||||
//Fill the new Bitmap with the texture data
|
||||
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
data = new byte[4 * w * h];
|
||||
Marshal.Copy(bmpData.Scan0, data, 0, data.Length);
|
||||
bmp.UnlockBits(bmpData);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (bmp2 != null)
|
||||
bmp2.Dispose();
|
||||
}
|
||||
//Fill the new Bitmap with the texture data
|
||||
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
byte[] data = new byte[4 * w * h];
|
||||
Marshal.Copy(bmpData.Scan0, data, 0, data.Length);
|
||||
bmp.UnlockBits(bmpData);
|
||||
|
||||
return AddTexture(w, h, ref data);
|
||||
}
|
||||
@@ -997,10 +990,11 @@ namespace Vocaluxe.Lib.Draw
|
||||
t = new Texture(_Device, (int)texture.W2, (int)texture.H2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
|
||||
//Lock the texture and fill it with the data
|
||||
DataRectangle rect = t.LockRectangle(0, LockFlags.Discard);
|
||||
for (int i = 0; i < data.Length; i += 4 * w)
|
||||
int rowWidth = 4 * (int)texture.W2;
|
||||
for (int i = 0; i + rowWidth <= data.Length; i += 4 * w)
|
||||
{
|
||||
rect.Data.Write(data, i, 4 * (int)texture.W2);
|
||||
rect.Data.Position = rect.Data.Position - 4 * (int)texture.W2;
|
||||
rect.Data.Write(data, i, rowWidth);
|
||||
rect.Data.Position = rect.Data.Position - rowWidth;
|
||||
rect.Data.Position += rect.Pitch;
|
||||
}
|
||||
t.UnlockRectangle(0);
|
||||
|
||||
+89
-90
@@ -1,10 +1,30 @@
|
||||
using System;
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using Vocaluxe.Base;
|
||||
using System.Runtime.ExceptionServices;
|
||||
|
||||
namespace Vocaluxe
|
||||
{
|
||||
@@ -13,13 +33,33 @@ namespace Vocaluxe
|
||||
{
|
||||
private static CSplashScreen _SplashScreen;
|
||||
|
||||
[STAThread]
|
||||
// ReSharper disable InconsistentNaming
|
||||
[STAThread, HandleProcessCorruptedStateExceptions]
|
||||
// ReSharper disable InconsistentNaming
|
||||
private static void Main(string[] args)
|
||||
// ReSharper restore InconsistentNaming
|
||||
// ReSharper restore InconsistentNaming
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
|
||||
AppDomain.CurrentDomain.AssemblyResolve += _AssemblyResolver;
|
||||
try
|
||||
{
|
||||
_Run(args);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string stackTrace = "";
|
||||
try
|
||||
{
|
||||
stackTrace = e.StackTrace;
|
||||
}
|
||||
catch {}
|
||||
MessageBox.Show("Unhandled error: " + e.Message + stackTrace);
|
||||
CLog.LogError("Unhandled error: " + e.Message + stackTrace);
|
||||
}
|
||||
_CloseProgram();
|
||||
}
|
||||
|
||||
private static void _Run(string[] args)
|
||||
{
|
||||
// Close program if there is another instance running
|
||||
if (!_EnsureSingleInstance())
|
||||
{
|
||||
@@ -169,17 +209,7 @@ namespace Vocaluxe
|
||||
// Start Main Loop
|
||||
_SplashScreen.Close();
|
||||
|
||||
try
|
||||
{
|
||||
CDraw.MainLoop();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace);
|
||||
CLog.LogError("Unhandled error: " + e.Message + e.StackTrace);
|
||||
}
|
||||
|
||||
_CloseProgram();
|
||||
CDraw.MainLoop();
|
||||
}
|
||||
|
||||
private static void _CloseProgram()
|
||||
@@ -187,32 +217,68 @@ namespace Vocaluxe
|
||||
// Unloading
|
||||
try
|
||||
{
|
||||
CLog.CloseAll();
|
||||
CInput.Close();
|
||||
CSound.RecordCloseAll();
|
||||
CSound.CloseAllStreams();
|
||||
CVideo.VdCloseAll();
|
||||
CDraw.Unload();
|
||||
CLog.CloseAll();
|
||||
CDataBase.CloseConnections();
|
||||
CWebcam.Close();
|
||||
}
|
||||
catch (Exception) {}
|
||||
}
|
||||
|
||||
[HandleProcessCorruptedStateExceptions]
|
||||
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
Exception e = (Exception)args.ExceptionObject;
|
||||
string stackTrace = "";
|
||||
try
|
||||
{
|
||||
stackTrace = e.StackTrace;
|
||||
}
|
||||
catch {}
|
||||
MessageBox.Show("Unhandled exception: " + e.Message + stackTrace);
|
||||
CLog.LogError("Unhandled exception: " + e.Message + stackTrace);
|
||||
}
|
||||
|
||||
private static Assembly _AssemblyResolver(Object sender, ResolveEventArgs args)
|
||||
{
|
||||
// a fix to handle mscorlib.resources
|
||||
if (args.Name.IndexOf(".resources", StringComparison.Ordinal) >= 0)
|
||||
return null;
|
||||
|
||||
string[] arr = args.Name.Split(new char[] {','});
|
||||
if (arr != null)
|
||||
if (arr.Length > 0)
|
||||
{
|
||||
|
||||
#if ARCH_X86
|
||||
Assembly assembly = Assembly.LoadFrom(Path.Combine("x86", arr[0] + ".dll"));
|
||||
string path="x86";
|
||||
#endif
|
||||
|
||||
#if ARCH_X64
|
||||
Assembly assembly = Assembly.LoadFrom(Path.Combine("x64", arr[0] + ".dll"));
|
||||
string path="x64";
|
||||
#endif
|
||||
|
||||
return assembly;
|
||||
path = Path.Combine(path, arr[0] + ".dll");
|
||||
try
|
||||
{
|
||||
Assembly assembly;
|
||||
try
|
||||
{
|
||||
assembly = Assembly.LoadFrom(path);
|
||||
}
|
||||
catch (FileLoadException)
|
||||
{
|
||||
//possibly loading from network, this would work always but better use the normal LoadFrom for more specific errors
|
||||
assembly = Assembly.Load(File.ReadAllBytes(path));
|
||||
}
|
||||
return assembly;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Cannot load assembly "+args.Name+" from "+path+": "+e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -222,74 +288,7 @@ namespace Vocaluxe
|
||||
Process currentProcess = Process.GetCurrentProcess();
|
||||
Process[] processes = Process.GetProcesses();
|
||||
|
||||
if (processes == null)
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < processes.Length; i++)
|
||||
{
|
||||
if (processes[i].Id != currentProcess.Id && currentProcess.ProcessName == processes[i].ProcessName)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class CSplashScreen : Form
|
||||
{
|
||||
private readonly Bitmap _Logo;
|
||||
|
||||
public CSplashScreen()
|
||||
{
|
||||
string path = Path.Combine(Environment.CurrentDirectory, Path.Combine(CSettings.FolderGraphics, CSettings.Logo));
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
_Logo = new Bitmap(path);
|
||||
ClientSize = new Size(_Logo.Width, _Logo.Height);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading logo: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
|
||||
path = Path.Combine(Environment.CurrentDirectory, CSettings.Icon);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
Icon = new Icon(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading icon: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
BackColor = Color.Transparent;
|
||||
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
Text = CSettings.ProgramName;
|
||||
CenterToScreen();
|
||||
Show();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e) {}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
if (_Logo == null)
|
||||
return;
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
g.DrawImage(_Logo, new Rectangle(0, 0, Width, Height));
|
||||
return processes.All(t => t.Id == currentProcess.Id || currentProcess.ProcessName != t.ProcessName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,8 @@ class CCreditName
|
||||
_Image = image;
|
||||
_ImgDot = imgDot;
|
||||
_Particle = particle;
|
||||
_ParticleOffsetX = (int)Math.Round(particleOffsetX * image.Rect.W / image.Texture.W2 - particle.Rect.W / 2);
|
||||
_ParticleOffsetY = (int)Math.Round(particleOffsetY * image.Rect.H / image.Texture.H2 - particle.Rect.H / 2);
|
||||
_ParticleOffsetX = (int)Math.Round(particleOffsetX * image.Rect.W / image.Texture.Width - particle.Rect.W / 2);
|
||||
_ParticleOffsetY = (int)Math.Round(particleOffsetY * image.Rect.H / image.Texture.Height - particle.Rect.H / 2);
|
||||
Active = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,9 @@
|
||||
<Compile Include="Base\CTheme.cs" />
|
||||
<Compile Include="Base\CVideo.cs" />
|
||||
<Compile Include="Base\CWebcam.cs" />
|
||||
<Compile Include="CSplashScreen.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GameModes\CGameMode.cs" />
|
||||
<Compile Include="GameModes\CGameModeNormal.cs" />
|
||||
<Compile Include="GameModes\IGameMode.cs" />
|
||||
@@ -205,10 +208,10 @@
|
||||
<Compile Include="Lib\Draw\CDrawWinForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Lib\Draw\IDraw.cs" />
|
||||
<Compile Include="Lib\Draw\COpenGL.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Lib\Draw\IDraw.cs" />
|
||||
<Compile Include="Lib\Input\CHIDAPI.cs" />
|
||||
<Compile Include="Lib\Input\IInput.cs" />
|
||||
<Compile Include="Lib\Input\WiiMote\CWiiMote.cs" />
|
||||
@@ -236,9 +239,7 @@
|
||||
<Compile Include="Lib\Webcam\CAForgeNet.cs" />
|
||||
<Compile Include="Lib\Webcam\IWebcam.cs" />
|
||||
<Compile Include="Base\CGraphics.cs" />
|
||||
<Compile Include="Program.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Screens\CPopupScreenPlayerControl.cs" />
|
||||
<Compile Include="Screens\CPopupScreenVolumeControl.cs" />
|
||||
@@ -277,16 +278,6 @@
|
||||
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 und x64%29 und Update für .NET Framework 4 %28KB2468871%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
|
||||
Reference in new issue
Block a user