Auto cleanup of Vocaluxe

This commit is contained in:
Flamefire committed 2013-03-22 21:09:43 +01:00
1 parent cd62c3cd88
commit b497b58740
77 files changed
+1496 -2332

No files matched your search

@@ -1,11 +1,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
[assembly: System.Runtime.InteropServices.ComVisible(false)] [assembly: ComVisible(false)]
namespace VocaluxeLib.PartyModes.Challenge namespace VocaluxeLib.PartyModes.Challenge
{ {
#region Communication #region Communication
#region ToScreen #region ToScreen
public struct DataToScreenConfig public struct DataToScreenConfig
{ {
@@ -51,17 +55,14 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
res = row.NumSingPoints.CompareTo(NumSingPoints); res = row.NumSingPoints.CompareTo(NumSingPoints);
if (res == 0) if (res == 0)
{
res = row.NumWon.CompareTo(NumWon); res = row.NumWon.CompareTo(NumWon);
} }
}
return res; return res;
} }
throw new ArgumentException("object is not a ResultTableRow"); throw new ArgumentException("object is not a ResultTableRow");
} }
} }
#endregion ToScreen #endregion ToScreen
#region FromScreen #region FromScreen
@@ -92,6 +93,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public bool FadeToNameSelection; public bool FadeToNameSelection;
} }
#endregion FromScreen #endregion FromScreen
#endregion Communication #endregion Communication
public sealed class PartyModeChallenge : CPartyMode public sealed class PartyModeChallenge : CPartyMode
@@ -102,7 +104,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private const int MinTeams = 0; private const int MinTeams = 0;
private const int MaxNumRounds = 100; private const int MaxNumRounds = 100;
enum EStage private enum EStage
{ {
NotStarted, NotStarted,
Config, Config,
@@ -111,7 +113,7 @@ namespace VocaluxeLib.PartyModes.Challenge
Singing Singing
} }
struct Data private struct Data
{ {
public int NumPlayer; public int NumPlayer;
public int NumPlayerAtOnce; public int NumPlayerAtOnce;
@@ -127,7 +129,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public int[] CatSongIndices; public int[] CatSongIndices;
} }
struct Stats private struct Stats
{ {
public int ProfileID; public int ProfileID;
public int SingPoints; public int SingPoints;
@@ -147,8 +149,8 @@ namespace VocaluxeLib.PartyModes.Challenge
_ScreenSongOptions.Selection.RandomOnly = false; _ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = true; _ScreenSongOptions.Selection.PartyMode = true;
_ScreenSongOptions.Selection.CategoryChangeAllowed = true; _ScreenSongOptions.Selection.CategoryChangeAllowed = true;
_ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 }; _ScreenSongOptions.Selection.NumJokers = new[] {5, 5};
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; _ScreenSongOptions.Selection.TeamNames = new[] {"foo", "bar"};
_ScreenSongOptions.Sorting.SearchString = String.Empty; _ScreenSongOptions.Sorting.SearchString = String.Empty;
_ScreenSongOptions.Sorting.SearchActive = false; _ScreenSongOptions.Sorting.SearchActive = false;
@@ -438,7 +440,6 @@ namespace VocaluxeLib.PartyModes.Challenge
public override void SongSelected(int SongID) public override void SongSelected(int SongID)
{ {
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
CBase.Game.Reset(); CBase.Game.Reset();
@@ -500,30 +501,30 @@ namespace VocaluxeLib.PartyModes.Challenge
switch (GameData.NumPlayerAtOnce) switch (GameData.NumPlayerAtOnce)
{ {
case 1: case 1:
_ScreenSongOptions.Selection.NumJokers = new int[] { 10 }; _ScreenSongOptions.Selection.NumJokers = new[] {10};
break; break;
case 2: case 2:
_ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 }; _ScreenSongOptions.Selection.NumJokers = new[] {5, 5};
break; break;
case 3: case 3:
_ScreenSongOptions.Selection.NumJokers = new int[] { 4, 4, 4 }; _ScreenSongOptions.Selection.NumJokers = new[] {4, 4, 4};
break; break;
case 4: case 4:
_ScreenSongOptions.Selection.NumJokers = new int[] { 3, 3, 3, 3 }; _ScreenSongOptions.Selection.NumJokers = new[] {3, 3, 3, 3};
break; break;
case 5: case 5:
_ScreenSongOptions.Selection.NumJokers = new int[] { 2, 2, 2, 2, 2 }; _ScreenSongOptions.Selection.NumJokers = new[] {2, 2, 2, 2, 2};
break; break;
case 6: case 6:
_ScreenSongOptions.Selection.NumJokers = new int[] { 2, 2, 2, 2, 2, 2 }; _ScreenSongOptions.Selection.NumJokers = new[] {2, 2, 2, 2, 2, 2};
break; break;
default: default:
_ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 }; _ScreenSongOptions.Selection.NumJokers = new[] {5, 5};
break; break;
} }
} }
@@ -534,13 +535,13 @@ namespace VocaluxeLib.PartyModes.Challenge
if (profiles == null) if (profiles == null)
{ {
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; _ScreenSongOptions.Selection.TeamNames = new[] {"foo", "bar"};
return; return;
} }
if (GameData.NumPlayerAtOnce < 1 || GameData.ProfileIDs.Count < GameData.NumPlayerAtOnce || profiles.Length < GameData.NumPlayerAtOnce) if (GameData.NumPlayerAtOnce < 1 || GameData.ProfileIDs.Count < GameData.NumPlayerAtOnce || profiles.Length < GameData.NumPlayerAtOnce)
{ {
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; _ScreenSongOptions.Selection.TeamNames = new[] {"foo", "bar"};
return; return;
} }
@@ -581,11 +582,9 @@ namespace VocaluxeLib.PartyModes.Challenge
for (int i = 0; i < GameData.NumRounds; i++) for (int i = 0; i < GameData.NumRounds; i++)
{ {
for (int j = 0; j < GameData.NumPlayerAtOnce; j++) for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
{
GameData.Results[i, j] = 0; GameData.Results[i, j] = 0;
} }
} }
}
else else
{ {
SPlayer[] results = CBase.Game.GetPlayer(); SPlayer[] results = CBase.Game.GetPlayer();
@@ -596,9 +595,7 @@ namespace VocaluxeLib.PartyModes.Challenge
return; return;
for (int j = 0; j < GameData.NumPlayerAtOnce; j++) for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
{
GameData.Results[GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points); GameData.Results[GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points);
}
List<Stats> points = GetPointsForPlayer(results); List<Stats> points = GetPointsForPlayer(results);
@@ -695,7 +692,6 @@ namespace VocaluxeLib.PartyModes.Challenge
} }
return result; return result;
} }
@@ -705,10 +701,8 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
GameData.CatSongIndices = new int[CBase.Songs.GetNumCategories()]; GameData.CatSongIndices = new int[CBase.Songs.GetNumCategories()];
for (int i = 0; i < GameData.CatSongIndices.Length; i++) for (int i = 0; i < GameData.CatSongIndices.Length; i++)
{
GameData.CatSongIndices[i] = -1; GameData.CatSongIndices[i] = -1;
} }
}
if (CBase.Songs.GetNumCategories() == 0 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF) if (CBase.Songs.GetNumCategories() == 0 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)
GameData.CatSongIndices = null; GameData.CatSongIndices = null;
+26 -63
View File
@@ -11,17 +11,17 @@ namespace Vocaluxe.Base
static class CBackgroundMusic static class CBackgroundMusic
{ {
private static int _CurrentMusicStream = -1; private static int _CurrentMusicStream = -1;
private static int _PreviousMusicIndex = 0; private static int _PreviousMusicIndex;
private static PlaylistElement _CurrentPlaylistElement = new PlaylistElement(); private static PlaylistElement _CurrentPlaylistElement = new PlaylistElement();
private static List<PlaylistElement> _AllFileNames = new List<PlaylistElement>(); private static readonly List<PlaylistElement> _AllFileNames = new List<PlaylistElement>();
private static List<PlaylistElement> _NotPlayedFileNames = new List<PlaylistElement>(); private static readonly List<PlaylistElement> _NotPlayedFileNames = new List<PlaylistElement>();
private static List<PlaylistElement> _BGMusicFileNames = new List<PlaylistElement>(); private static readonly List<PlaylistElement> _BGMusicFileNames = new List<PlaylistElement>();
private static List<PlaylistElement> _PreviousFileNames = new List<PlaylistElement>(); private static readonly List<PlaylistElement> _PreviousFileNames = new List<PlaylistElement>();
private static int _Video = -1; private static int _Video = -1;
private static STexture _CurrentVideoTexture = new STexture(-1); private static STexture _CurrentVideoTexture = new STexture(-1);
private static Stopwatch _FadeTimer = new Stopwatch(); private static readonly Stopwatch _FadeTimer = new Stopwatch();
private static bool _VideoEnabled; private static bool _VideoEnabled;
private static bool _OwnMusicAdded; private static bool _OwnMusicAdded;
@@ -33,10 +33,7 @@ namespace Vocaluxe.Base
public static bool VideoEnabled public static bool VideoEnabled
{ {
get get { return _VideoEnabled; }
{
return _VideoEnabled;
}
set set
{ {
if (_VideoEnabled && value) if (_VideoEnabled && value)
@@ -53,23 +50,13 @@ namespace Vocaluxe.Base
public static bool CanSing public static bool CanSing
{ {
get get { return _CanSing; }
{ set { _CanSing = value; }
return _CanSing;
}
set
{
_CanSing = value;
}
} }
public static bool Disabled public static bool Disabled
{ {
get get { return _Disabled; }
{
return _Disabled;
}
set set
{ {
_Disabled = value; _Disabled = value;
@@ -82,46 +69,28 @@ namespace Vocaluxe.Base
public static bool RepeatSong public static bool RepeatSong
{ {
get get { return _RepeatSong; }
{ set { _RepeatSong = value; }
return _RepeatSong;
}
set
{
_RepeatSong = value;
}
} }
public static int SongID public static int SongID
{ {
get get { return _CurrentPlaylistElement.SongID; }
{
return _CurrentPlaylistElement.SongID;
}
} }
public static bool Duet public static bool Duet
{ {
get get { return _CurrentPlaylistElement.Duet; }
{
return _CurrentPlaylistElement.Duet;
}
} }
public static bool SongHasVideo public static bool SongHasVideo
{ {
get get { return File.Exists(_CurrentPlaylistElement.VideoFilePath); }
{
return File.Exists(_CurrentPlaylistElement.VideoFilePath);
}
} }
public static bool Playing public static bool Playing
{ {
get get { return _Playing; }
{
return _Playing;
}
} }
public static string ArtistAndTitle public static string ArtistAndTitle
@@ -137,10 +106,7 @@ namespace Vocaluxe.Base
public static STexture Cover public static STexture Cover
{ {
get get { return _CurrentPlaylistElement.Cover; }
{
return _CurrentPlaylistElement.Cover;
}
} }
public static void Init() public static void Init()
@@ -148,14 +114,10 @@ namespace Vocaluxe.Base
List<string> templist = new List<string>(); List<string> templist = new List<string>();
foreach (string ending in CSettings.MusicFileTypes) foreach (string ending in CSettings.MusicFileTypes)
{
templist.AddRange(CHelper.ListFiles(CSettings.sFolderBackgroundMusic, ending, true, true)); templist.AddRange(CHelper.ListFiles(CSettings.sFolderBackgroundMusic, ending, true, true));
}
foreach (string path in templist) foreach (string path in templist)
{
_BGMusicFileNames.Add(new PlaylistElement(path)); _BGMusicFileNames.Add(new PlaylistElement(path));
}
if (CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC) if (CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC)
AddBackgroundMusic(); AddBackgroundMusic();
@@ -246,11 +208,13 @@ namespace Vocaluxe.Base
else else
CSound.SetPosition(_CurrentMusicStream, 0); CSound.SetPosition(_CurrentMusicStream, 0);
if (_VideoEnabled && _Video != -1) if (_VideoEnabled && _Video != -1)
{
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
} }
}
else else
Next(); Next();
} }
@@ -309,11 +273,13 @@ namespace Vocaluxe.Base
else else
CSound.SetPosition(_CurrentMusicStream, 0); CSound.SetPosition(_CurrentMusicStream, 0);
if (_VideoEnabled && _Video != -1) if (_VideoEnabled && _Video != -1)
{
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
} }
}
else else
{ {
Stop(); Stop();
@@ -339,12 +305,14 @@ namespace Vocaluxe.Base
else else
CSound.SetPosition(_CurrentMusicStream, 0); CSound.SetPosition(_CurrentMusicStream, 0);
if (_VideoEnabled && _Video != -1) if (_VideoEnabled && _Video != -1)
{
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
} }
} }
}
public static void ApplyVolume() public static void ApplyVolume()
{ {
@@ -485,9 +453,7 @@ namespace Vocaluxe.Base
float vtime = 0f; float vtime = 0f;
CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), ref vtime); CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), ref vtime);
if (_FadeTimer.ElapsedMilliseconds <= 3000L) if (_FadeTimer.ElapsedMilliseconds <= 3000L)
{
_CurrentVideoTexture.color.A = (_FadeTimer.ElapsedMilliseconds / 3000f); _CurrentVideoTexture.color.A = (_FadeTimer.ElapsedMilliseconds / 3000f);
}
else else
{ {
_CurrentVideoTexture.color.A = 1f; _CurrentVideoTexture.color.A = 1f;
@@ -527,9 +493,9 @@ namespace Vocaluxe.Base
class PlaylistElement class PlaylistElement
{ {
private CSong _Song = null; private readonly CSong _Song;
private int _SongID; private readonly int _SongID;
public int SongID public int SongID
{ {
get { return _SongID; } get { return _SongID; }
@@ -547,10 +513,7 @@ class PlaylistElement
return _MusicFilePath; return _MusicFilePath;
} }
set set { _MusicFilePath = value; }
{
_MusicFilePath = value;
}
} }
public string VideoFilePath public string VideoFilePath
+37 -71
View File
@@ -5,8 +5,6 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using Vocaluxe.Lib.Sound; using Vocaluxe.Lib.Sound;
using Vocaluxe.Lib.Webcam; using Vocaluxe.Lib.Webcam;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -15,7 +13,7 @@ namespace Vocaluxe.Base
{ {
static class CConfig static class CConfig
{ {
private static XmlWriterSettings _settings = new XmlWriterSettings(); private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
// Debug // Debug
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF; public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
@@ -95,11 +93,11 @@ namespace Vocaluxe.Base
public static SWebcamConfig WebcamConfig; public static SWebcamConfig WebcamConfig;
//Lists to save parameters and values //Lists to save parameters and values
private static List<string> _Params = new List<string>(); private static readonly List<string> _Params = new List<string>();
private static List<string> _Values = new List<string>(); private static readonly List<string> _Values = new List<string>();
//Variables to save old values for commandline-parameters //Variables to save old values for commandline-parameters
private static List<string> SongFolderOld = new List<string>(); private static readonly List<string> SongFolderOld = new List<string>();
public static void Init() public static void Init()
{ {
@@ -127,21 +125,21 @@ namespace Vocaluxe.Base
string value = string.Empty; string value = string.Empty;
#region Debug #region Debug
xmlReader.TryGetEnumValue<EDebugLevel>("//root/Debug/DebugLevel", ref DebugLevel); xmlReader.TryGetEnumValue("//root/Debug/DebugLevel", ref DebugLevel);
#endregion Debug #endregion Debug
#region Graphics #region Graphics
xmlReader.TryGetEnumValue<ERenderer>("//root/Graphics/Renderer", ref Renderer); xmlReader.TryGetEnumValue("//root/Graphics/Renderer", ref Renderer);
xmlReader.TryGetEnumValue<ETextureQuality>("//root/Graphics/TextureQuality", ref TextureQuality); xmlReader.TryGetEnumValue("//root/Graphics/TextureQuality", ref TextureQuality);
xmlReader.TryGetIntValueRange("//root/Graphics/CoverSize", ref CoverSize, 32, 1024); xmlReader.TryGetIntValueRange("//root/Graphics/CoverSize", ref CoverSize, 32, 1024);
xmlReader.TryGetIntValue("//root/Graphics/ScreenW", ref ScreenW); xmlReader.TryGetIntValue("//root/Graphics/ScreenW", ref ScreenW);
xmlReader.TryGetIntValue("//root/Graphics/ScreenH", ref ScreenH); xmlReader.TryGetIntValue("//root/Graphics/ScreenH", ref ScreenH);
xmlReader.TryGetEnumValue<EAntiAliasingModes>("//root/Graphics/AAMode", ref AAMode); xmlReader.TryGetEnumValue("//root/Graphics/AAMode", ref AAMode);
xmlReader.TryGetEnumValue<EColorDeep>("//root/Graphics/Colors", ref Colors); xmlReader.TryGetEnumValue("//root/Graphics/Colors", ref Colors);
xmlReader.TryGetFloatValue("//root/Graphics/MaxFPS", ref MaxFPS); xmlReader.TryGetFloatValue("//root/Graphics/MaxFPS", ref MaxFPS);
xmlReader.TryGetEnumValue<EOffOn>("//root/Graphics/VSync", ref VSync); xmlReader.TryGetEnumValue("//root/Graphics/VSync", ref VSync);
xmlReader.TryGetEnumValue<EOffOn>("//root/Graphics/FullScreen", ref FullScreen); xmlReader.TryGetEnumValue("//root/Graphics/FullScreen", ref FullScreen);
xmlReader.TryGetFloatValue("//root/Graphics/FadeTime", ref FadeTime); xmlReader.TryGetFloatValue("//root/Graphics/FadeTime", ref FadeTime);
#endregion Graphics #endregion Graphics
@@ -159,16 +157,16 @@ namespace Vocaluxe.Base
#endregion Theme #endregion Theme
#region Sound #region Sound
xmlReader.TryGetEnumValue<EPlaybackLib>("//root/Sound/PlayBackLib", ref PlayBackLib); xmlReader.TryGetEnumValue("//root/Sound/PlayBackLib", ref PlayBackLib);
xmlReader.TryGetEnumValue<ERecordLib>("//root/Sound/RecordLib", ref RecordLib); xmlReader.TryGetEnumValue("//root/Sound/RecordLib", ref RecordLib);
xmlReader.TryGetEnumValue<EBufferSize>("//root/Sound/AudioBufferSize", ref AudioBufferSize); xmlReader.TryGetEnumValue("//root/Sound/AudioBufferSize", ref AudioBufferSize);
xmlReader.TryGetIntValueRange("//root/Sound/AudioLatency", ref AudioLatency, -500, 500); xmlReader.TryGetIntValueRange("//root/Sound/AudioLatency", ref AudioLatency, -500, 500);
xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusic", ref BackgroundMusic); xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusic", ref BackgroundMusic);
xmlReader.TryGetIntValueRange("//root/Sound/BackgroundMusicVolume", ref BackgroundMusicVolume); xmlReader.TryGetIntValueRange("//root/Sound/BackgroundMusicVolume", ref BackgroundMusicVolume);
xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicSource", ref BackgroundMusicSource); xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicSource", ref BackgroundMusicSource);
xmlReader.TryGetEnumValue<EOffOn>("//root/Sound/BackgroundMusicUseStart", ref BackgroundMusicUseStart); xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicUseStart", ref BackgroundMusicUseStart);
xmlReader.TryGetIntValueRange("//root/Sound/PreviewMusicVolume", ref PreviewMusicVolume); xmlReader.TryGetIntValueRange("//root/Sound/PreviewMusicVolume", ref PreviewMusicVolume);
xmlReader.TryGetIntValueRange("//root/Sound/GameMusicVolume", ref GameMusicVolume); xmlReader.TryGetIntValueRange("//root/Sound/GameMusicVolume", ref GameMusicVolume);
#endregion Sound #endregion Sound
@@ -187,21 +185,19 @@ namespace Vocaluxe.Base
i++; i++;
} }
xmlReader.TryGetEnumValue<ESongMenu>("//root/Game/SongMenu", ref SongMenu); xmlReader.TryGetEnumValue("//root/Game/SongMenu", ref SongMenu);
xmlReader.TryGetEnumValue<ESongSorting>("//root/Game/SongSorting", ref SongSorting); xmlReader.TryGetEnumValue("//root/Game/SongSorting", ref SongSorting);
xmlReader.TryGetEnumValue<EOffOn>("//root/Game/IgnoreArticles", ref IgnoreArticles); xmlReader.TryGetEnumValue("//root/Game/IgnoreArticles", ref IgnoreArticles);
xmlReader.TryGetFloatValue("//root/Game/ScoreAnimationTime", ref ScoreAnimationTime); xmlReader.TryGetFloatValue("//root/Game/ScoreAnimationTime", ref ScoreAnimationTime);
xmlReader.TryGetEnumValue<ETimerMode>("//root/Game/TimerMode", ref TimerMode); xmlReader.TryGetEnumValue("//root/Game/TimerMode", ref TimerMode);
xmlReader.TryGetIntValue("//root/Game/NumPlayer", ref NumPlayer); xmlReader.TryGetIntValue("//root/Game/NumPlayer", ref NumPlayer);
xmlReader.TryGetEnumValue("//root/Game/Tabs", ref Tabs); xmlReader.TryGetEnumValue("//root/Game/Tabs", ref Tabs);
xmlReader.GetValue("//root/Game/Language", ref Language, Language); xmlReader.GetValue("//root/Game/Language", ref Language, Language);
xmlReader.TryGetEnumValue<EOffOn>("//root/Game/LyricsOnTop", ref LyricsOnTop); xmlReader.TryGetEnumValue("//root/Game/LyricsOnTop", ref LyricsOnTop);
xmlReader.TryGetFloatValue("//root/Game/MinLineBreakTime", ref MinLineBreakTime); xmlReader.TryGetFloatValue("//root/Game/MinLineBreakTime", ref MinLineBreakTime);
if ((ScoreAnimationTime > 0 && ScoreAnimationTime < 1) || ScoreAnimationTime < 0) if ((ScoreAnimationTime > 0 && ScoreAnimationTime < 1) || ScoreAnimationTime < 0)
{
ScoreAnimationTime = 1; ScoreAnimationTime = 1;
}
if (MinLineBreakTime < 0) if (MinLineBreakTime < 0)
MinLineBreakTime = 0.1f; MinLineBreakTime = 0.1f;
@@ -212,27 +208,22 @@ namespace Vocaluxe.Base
bool _LangExists = CLanguage.SetLanguage(Language); bool _LangExists = CLanguage.SetLanguage(Language);
//TODO: What should we do, if English not exists? //TODO: What should we do, if English not exists?
if(_LangExists == false){ if (_LangExists == false)
Language = "English"; Language = "English";
}
//Read players from config //Read players from config
for (i = 1; i <= CSettings.MaxNumPlayer; i++) for (i = 1; i <= CSettings.MaxNumPlayer; i++)
{
xmlReader.GetValue("//root/Game/Players/Player" + i.ToString(), ref Players[i - 1], string.Empty); xmlReader.GetValue("//root/Game/Players/Player" + i.ToString(), ref Players[i - 1], string.Empty);
}
#endregion Game #endregion Game
#region Video #region Video
xmlReader.TryGetEnumValue<EVideoDecoder>("//root/Video/VideoDecoder", ref VideoDecoder); xmlReader.TryGetEnumValue("//root/Video/VideoDecoder", ref VideoDecoder);
xmlReader.TryGetEnumValue<EOffOn>("//root/Video/VideoBackgrounds", ref VideoBackgrounds); xmlReader.TryGetEnumValue("//root/Video/VideoBackgrounds", ref VideoBackgrounds);
xmlReader.TryGetEnumValue<EOffOn>("//root/Video/VideoPreview", ref VideoPreview); xmlReader.TryGetEnumValue("//root/Video/VideoPreview", ref VideoPreview);
xmlReader.TryGetEnumValue<EOffOn>("//root/Video/VideosInSongs", ref VideosInSongs); xmlReader.TryGetEnumValue("//root/Video/VideosInSongs", ref VideosInSongs);
xmlReader.TryGetEnumValue<EOffOn>("//root/Video/VideosToBackground", ref VideosToBackground); xmlReader.TryGetEnumValue("//root/Video/VideosToBackground", ref VideosToBackground);
xmlReader.TryGetEnumValue<EWebcamLib>("//root/Video/WebcamLib", ref WebcamLib); xmlReader.TryGetEnumValue("//root/Video/WebcamLib", ref WebcamLib);
WebcamConfig = new SWebcamConfig(); WebcamConfig = new SWebcamConfig();
xmlReader.GetValue("//root/Video/WebcamConfig/MonikerString", ref WebcamConfig.MonikerString, String.Empty); xmlReader.GetValue("//root/Video/WebcamConfig/MonikerString", ref WebcamConfig.MonikerString, String.Empty);
xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Framerate", ref WebcamConfig.Framerate); xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Framerate", ref WebcamConfig.Framerate);
@@ -261,7 +252,6 @@ namespace Vocaluxe.Base
public static bool SaveConfig() public static bool SaveConfig()
{ {
XmlWriter writer = null; XmlWriter writer = null;
try try
{ {
@@ -273,15 +263,15 @@ namespace Vocaluxe.Base
writer.WriteStartElement("Info"); writer.WriteStartElement("Info");
writer.WriteElementString("Version", CSettings.GetFullVersionText()); writer.WriteElementString("Version", CSettings.GetFullVersionText());
writer.WriteElementString("Time", System.DateTime.Now.ToString()); writer.WriteElementString("Time", DateTime.Now.ToString());
writer.WriteElementString("Platform", System.Environment.OSVersion.Platform.ToString()); writer.WriteElementString("Platform", Environment.OSVersion.Platform.ToString());
writer.WriteElementString("OSVersion", System.Environment.OSVersion.ToString()); writer.WriteElementString("OSVersion", Environment.OSVersion.ToString());
writer.WriteElementString("ProcessorCount", System.Environment.ProcessorCount.ToString()); writer.WriteElementString("ProcessorCount", Environment.ProcessorCount.ToString());
writer.WriteElementString("Screens", Screen.AllScreens.Length.ToString()); writer.WriteElementString("Screens", Screen.AllScreens.Length.ToString());
writer.WriteElementString("PrimaryScreenResolution", Screen.PrimaryScreen.Bounds.Size.ToString()); writer.WriteElementString("PrimaryScreenResolution", Screen.PrimaryScreen.Bounds.Size.ToString());
writer.WriteElementString("Directory", System.Environment.CurrentDirectory.ToString()); writer.WriteElementString("Directory", Environment.CurrentDirectory);
writer.WriteEndElement(); writer.WriteEndElement();
#endregion Info #endregion Info
@@ -419,19 +409,15 @@ namespace Vocaluxe.Base
//Write "old" song-folders to config. //Write "old" song-folders to config.
writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ..."); writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
for (int i = 0; i < SongFolderOld.Count; i++) for (int i = 0; i < SongFolderOld.Count; i++)
{
writer.WriteElementString("SongFolder" + (i + 1).ToString(), SongFolderOld[i]); writer.WriteElementString("SongFolder" + (i + 1).ToString(), SongFolderOld[i]);
} }
}
else else
{ {
//Write "normal" song-folders to config. //Write "normal" song-folders to config.
writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ..."); writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
for (int i = 0; i < SongFolder.Count; i++) for (int i = 0; i < SongFolder.Count; i++)
{
writer.WriteElementString("SongFolder" + (i + 1).ToString(), SongFolder[i]); writer.WriteElementString("SongFolder" + (i + 1).ToString(), SongFolder[i]);
} }
}
writer.WriteComment("SongMenu: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongMenu)))); writer.WriteComment("SongMenu: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongMenu))));
writer.WriteElementString("SongMenu", Enum.GetName(typeof(ESongMenu), SongMenu)); writer.WriteElementString("SongMenu", Enum.GetName(typeof(ESongMenu), SongMenu));
@@ -463,9 +449,7 @@ namespace Vocaluxe.Base
writer.WriteComment("Default profile for players 1..." + CSettings.MaxNumPlayer.ToString() + ":"); writer.WriteComment("Default profile for players 1..." + CSettings.MaxNumPlayer.ToString() + ":");
writer.WriteStartElement("Players"); writer.WriteStartElement("Players");
for (int i = 1; i <= CSettings.MaxNumPlayer; i++) for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{
writer.WriteElementString("Player" + i.ToString(), Path.GetFileName(Players[i - 1])); writer.WriteElementString("Player" + i.ToString(), Path.GetFileName(Players[i - 1]));
}
writer.WriteEndElement(); writer.WriteEndElement();
writer.WriteEndElement(); writer.WriteEndElement();
@@ -567,11 +551,9 @@ namespace Vocaluxe.Base
for (int inp = 0; inp < Devices[dev].Inputs.Count; inp++) for (int inp = 0; inp < Devices[dev].Inputs.Count; inp++)
{ {
if (Devices[dev].Inputs[inp].PlayerChannel1 != 0 || Devices[dev].Inputs[inp].PlayerChannel2 != 0) if (Devices[dev].Inputs[inp].PlayerChannel1 != 0 || Devices[dev].Inputs[inp].PlayerChannel2 != 0)
{
return true; return true;
} }
} }
}
return false; return false;
} }
@@ -593,10 +575,8 @@ namespace Vocaluxe.Base
for (int inp = 0; inp < Devices[dev].Inputs.Count; inp++) for (int inp = 0; inp < Devices[dev].Inputs.Count; inp++)
{ {
if (Devices[dev].Inputs[inp].PlayerChannel1 == player || Devices[dev].Inputs[inp].PlayerChannel2 == player) if (Devices[dev].Inputs[inp].PlayerChannel1 == player || Devices[dev].Inputs[inp].PlayerChannel2 == player)
{
return true; return true;
} }
}
} }
return false; return false;
} }
@@ -688,9 +668,7 @@ namespace Vocaluxe.Base
//Complete argument string //Complete argument string
string arguments = string.Empty; string arguments = string.Empty;
foreach (string arg in args) foreach (string arg in args)
{
arguments += arg + " "; arguments += arg + " ";
}
args = SpliterParam.Split(arguments); args = SpliterParam.Split(arguments);
@@ -706,7 +684,6 @@ namespace Vocaluxe.Base
switch (parts.Length) switch (parts.Length)
{ {
//Only found a parameter //Only found a parameter
case 1: case 1:
if (!Regex.IsMatch(parts[0], @"\s") && parts[0].Length > 0) if (!Regex.IsMatch(parts[0], @"\s") && parts[0].Length > 0)
@@ -738,8 +715,8 @@ namespace Vocaluxe.Base
/// <summary> /// <summary>
/// Apply command-line-parameters (before reading config.xml) /// Apply command-line-parameters (before reading config.xml)
/// </summary> /// </summary>
public static void UseCommandLineParamsBefore(){ public static void UseCommandLineParamsBefore()
{
//Check each parameter //Check each parameter
for (int i = 0; i < _Params.Count; i++) for (int i = 0; i < _Params.Count; i++)
{ {
@@ -755,17 +732,13 @@ namespace Vocaluxe.Base
case "configfile": case "configfile":
//Check if value is valid //Check if value is valid
if (CheckFile(value)) if (CheckFile(value))
{
CSettings.sFileConfig = value; CSettings.sFileConfig = value;
}
break; break;
case "scorefile": case "scorefile":
//Check if value is valid //Check if value is valid
if (CheckFile(value)) if (CheckFile(value))
{
CSettings.sFileHighscoreDB = value; CSettings.sFileHighscoreDB = value;
}
break; break;
case "playlistfolder": case "playlistfolder":
@@ -786,7 +759,6 @@ namespace Vocaluxe.Base
/// </summary> /// </summary>
public static void UseCommandLineParamsAfter() public static void UseCommandLineParamsAfter()
{ {
//Check each parameter //Check each parameter
for (int i = 0; i < _Params.Count; i++) for (int i = 0; i < _Params.Count; i++)
{ {
@@ -818,19 +790,15 @@ namespace Vocaluxe.Base
private static bool CheckFile(string value) private static bool CheckFile(string value)
{ {
char[] chars = Path.GetInvalidPathChars(); char[] chars = Path.GetInvalidPathChars();
for(int i=0; i<chars.Length; i++){ for (int i = 0; i < chars.Length; i++)
if(value.Contains(chars[i].ToString())){ {
if (value.Contains(chars[i].ToString()))
return false; return false;
} }
}
if (Path.GetFileName(value).Length == 0) if (Path.GetFileName(value).Length == 0)
{
return false; return false;
}
if (!Path.HasExtension(value)) if (!Path.HasExtension(value))
{
return false; return false;
}
return true; return true;
} }
@@ -854,11 +822,9 @@ namespace Vocaluxe.Base
} }
} }
else else
{
CGame.Player[j].ProfileID = -1; CGame.Player[j].ProfileID = -1;
} }
} }
} }
} }
} }
}
+4 -17
View File
@@ -23,12 +23,12 @@ namespace Vocaluxe.Base
abstract class CCover abstract class CCover
{ {
private static XmlWriterSettings _settings = new XmlWriterSettings(); private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
private static List<SCover> _Cover = new List<SCover>(); private static readonly List<SCover> _Cover = new List<SCover>();
private static List<SCoverTheme> _CoverThemes = new List<SCoverTheme>(); private static readonly List<SCoverTheme> _CoverThemes = new List<SCoverTheme>();
private static STexture _NoCover = new STexture(-1); private static STexture _NoCover = new STexture(-1);
private static Object _MutexCover = new Object(); private static readonly Object _MutexCover = new Object();
public static STexture NoCover public static STexture NoCover
{ {
@@ -54,9 +54,7 @@ namespace Vocaluxe.Base
{ {
List<string> CoverThemes = new List<string>(); List<string> CoverThemes = new List<string>();
for (int i = 0; i < _CoverThemes.Count; i++) for (int i = 0; i < _CoverThemes.Count; i++)
{
CoverThemes.Add(_CoverThemes[i].Name); CoverThemes.Add(_CoverThemes[i].Name);
}
return CoverThemes.ToArray(); return CoverThemes.ToArray();
} }
@@ -71,10 +69,8 @@ namespace Vocaluxe.Base
for (int i = 0; i < _CoverThemes.Count; i++) for (int i = 0; i < _CoverThemes.Count; i++)
{ {
if (_CoverThemes[i].Name == CConfig.CoverTheme) if (_CoverThemes[i].Name == CConfig.CoverTheme)
{
return i; return i;
} }
}
return -1; return -1;
} }
@@ -109,11 +105,9 @@ namespace Vocaluxe.Base
foreach (SCover cover in _Cover) foreach (SCover cover in _Cover)
{ {
if (cover.Name == Name) if (cover.Name == Name)
{
return true; return true;
} }
} }
}
return false; return false;
} }
@@ -190,7 +184,6 @@ namespace Vocaluxe.Base
if (coverTheme.Name.Length > 0) if (coverTheme.Name.Length > 0)
{ {
CXMLReader xmlReader = CXMLReader.OpenFile((Path.Combine(CSettings.sFolderCover, coverTheme.File))); CXMLReader xmlReader = CXMLReader.OpenFile((Path.Combine(CSettings.sFolderCover, coverTheme.File)));
if (xmlReader != null) if (xmlReader != null)
@@ -209,23 +202,17 @@ namespace Vocaluxe.Base
sk.Name = name; sk.Name = name;
sk.Value = Path.Combine(coverTheme.Folder, value); sk.Value = Path.Combine(coverTheme.Folder, value);
if (File.Exists(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value)))) if (File.Exists(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value))))
{
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value))); sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value)));
}
else else
{
sk.Texture = _NoCover; sk.Texture = _NoCover;
}
_Cover.Add(sk); _Cover.Add(sk);
if (sk.Name == "NoCover") if (sk.Name == "NoCover")
{
_NoCover = sk.Texture; _NoCover = sk.Texture;
} }
} }
} }
}
List<string> files = new List<string>(); List<string> files = new List<string>();
+3 -3
View File
@@ -1,7 +1,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Draw;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -9,7 +9,7 @@ namespace Vocaluxe.Base
{ {
static class CDraw static class CDraw
{ {
private static IDraw _Draw = null; private static IDraw _Draw;
public static void InitDraw() public static void InitDraw()
{ {
@@ -161,7 +161,7 @@ namespace Vocaluxe.Base
if (MaxSize == 0) if (MaxSize == 0)
return _Draw.AddTexture(TexturePath); return _Draw.AddTexture(TexturePath);
if (!System.IO.File.Exists(TexturePath)) if (!File.Exists(TexturePath))
return new STexture(-1); return new STexture(-1);
using (Bitmap origin = new Bitmap(TexturePath)) using (Bitmap origin = new Bitmap(TexturePath))
+18 -21
View File
@@ -4,6 +4,7 @@ using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Text; using System.Drawing.Text;
using System.IO; using System.IO;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -12,7 +13,7 @@ namespace Vocaluxe.Base
{ {
class CGlyph class CGlyph
{ {
private float _SIZEh = 50f; private readonly float _SIZEh = 50f;
public float SIZEh public float SIZEh
{ {
get { return _SIZEh; } get { return _SIZEh; }
@@ -34,7 +35,8 @@ namespace Vocaluxe.Base
Font fo; Font fo;
Size sizeB; Size sizeB;
SizeF size; SizeF size;
using(Graphics g=Graphics.FromHwnd(IntPtr.Zero)){ using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
{
fo = CFonts.GetFont(); fo = CFonts.GetFont();
sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags); sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
@@ -43,12 +45,12 @@ namespace Vocaluxe.Base
using (Bitmap bmp = new Bitmap((int)(sizeB.Width * 2f), sizeB.Height)) using (Bitmap bmp = new Bitmap((int)(sizeB.Width * 2f), sizeB.Height))
{ {
Graphics g = System.Drawing.Graphics.FromImage(bmp); Graphics g = Graphics.FromImage(bmp);
g.Clear(System.Drawing.Color.Transparent); g.Clear(Color.Transparent);
g.SmoothingMode = SmoothingMode.AntiAlias; g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
CFonts.Height = SIZEh; CFonts.Height = SIZEh;
fo = CFonts.GetFont(); fo = CFonts.GetFont();
@@ -74,7 +76,6 @@ namespace Vocaluxe.Base
(int)CFonts.OutlineColor.B * 255), (int)CFonts.OutlineColor.B * 255),
SIZEh * outline)) SIZEh * outline))
{ {
pen.LineJoin = LineJoin.Round; pen.LineJoin = LineJoin.Round;
g.DrawPath(pen, path); g.DrawPath(pen, path);
g.FillPath(Brushes.White, path); g.FillPath(Brushes.White, path);
@@ -134,10 +135,10 @@ namespace Vocaluxe.Base
class CFont : IDisposable class CFont : IDisposable
{ {
private Dictionary<char, CGlyph> _Glyphs; private readonly Dictionary<char, CGlyph> _Glyphs;
private PrivateFontCollection fonts = null; private PrivateFontCollection fonts;
private FontFamily family; private FontFamily family;
private float SIZEh; private readonly float SIZEh;
public string FilePath; public string FilePath;
@@ -259,9 +260,7 @@ namespace Vocaluxe.Base
public void UnloadAllGlyphs() public void UnloadAllGlyphs()
{ {
foreach (CGlyph glyph in _Glyphs.Values) foreach (CGlyph glyph in _Glyphs.Values)
{
glyph.UnloadTexture(); glyph.UnloadTexture();
}
_Glyphs.Clear(); _Glyphs.Clear();
} }
@@ -302,14 +301,13 @@ namespace Vocaluxe.Base
static class CFonts static class CFonts
{ {
private static XmlWriterSettings _settings = new XmlWriterSettings(); private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
private static List<SFont> _Fonts; private static List<SFont> _Fonts;
private static int _CurrentFont; private static int _CurrentFont;
private static float _Height = 1f; private static float _Height = 1f;
public static int PartyModeID public static int PartyModeID { get; set; }
{ get; set; }
public static EStyle Style = EStyle.Normal; public static EStyle Style = EStyle.Normal;
@@ -361,7 +359,7 @@ namespace Vocaluxe.Base
public static void Init() public static void Init()
{ {
_settings.Indent = true; _settings.Indent = true;
_settings.Encoding = System.Text.Encoding.UTF8; _settings.Encoding = Encoding.UTF8;
_settings.ConformanceLevel = ConformanceLevel.Document; _settings.ConformanceLevel = ConformanceLevel.Document;
_CurrentFont = 0; _CurrentFont = 0;
@@ -548,7 +546,8 @@ namespace Vocaluxe.Base
public static RectangleF GetTextBounds(CText text, float height) public static RectangleF GetTextBounds(CText text, float height)
{ {
Height = height; Height = height;
return new RectangleF(text.X, text.Y, GetTextWidth(CLanguage.Translate(text.Text, text.TranslationID)), GetTextHeight(CLanguage.Translate(text.Text, text.TranslationID))); return new RectangleF(text.X, text.Y, GetTextWidth(CLanguage.Translate(text.Text, text.TranslationID)),
GetTextHeight(CLanguage.Translate(text.Text, text.TranslationID)));
} }
public static float GetTextWidth(string text) public static float GetTextWidth(string text)
@@ -556,9 +555,7 @@ namespace Vocaluxe.Base
float dx = 0; float dx = 0;
CFont Font = _GetCurrentFont(); CFont Font = _GetCurrentFont();
foreach (char chr in text) foreach (char chr in text)
{
dx += Font.GetWidth(chr); dx += Font.GetWidth(chr);
}
return dx; return dx;
} }
@@ -576,7 +573,8 @@ namespace Vocaluxe.Base
return h; return h;
} }
private static void _LoadFontFiles(CXMLReader xmlReader, string FontFolder, string ThemeName="", int PartyModeId=-1){ private static void _LoadFontFiles(CXMLReader xmlReader, string FontFolder, string ThemeName = "", int PartyModeId = -1)
{
string value = string.Empty; string value = string.Empty;
int i = 1; int i = 1;
while (xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Folder", ref value, value)) while (xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Folder", ref value, value))
@@ -649,7 +647,7 @@ namespace Vocaluxe.Base
/// <returns></returns> /// <returns></returns>
private static bool LoadFontList() private static bool LoadFontList()
{ {
CXMLReader xmlReader = CXMLReader.OpenFile(System.IO.Path.Combine(CSettings.sFolderFonts, CSettings.sFileFonts)); CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.sFolderFonts, CSettings.sFileFonts));
if (xmlReader == null) if (xmlReader == null)
return false; return false;
@@ -797,7 +795,6 @@ namespace Vocaluxe.Base
} }
Style = EStyle.Normal; Style = EStyle.Normal;
SetFont("Normal"); SetFont("Normal");
} }
} }
} }
+9 -26
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Vocaluxe.GameModes; using Vocaluxe.GameModes;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SingNotes; using VocaluxeLib.Menu.SingNotes;
@@ -14,13 +13,13 @@ namespace Vocaluxe.Base
private static SPlayer[] _Player; private static SPlayer[] _Player;
private static int _NumPlayer = CConfig.NumPlayer; private static int _NumPlayer = CConfig.NumPlayer;
private static float _Beat = 0f; private static float _Beat;
private static int _CurrentBeat = 0; private static int _CurrentBeat;
private static float _MidBeatD = 0f; private static float _MidBeatD;
private static int _CurrentBeatD = 0; private static int _CurrentBeatD;
private static int _OldBeatD = 0; private static int _OldBeatD;
private static Random _Rand = new Random(); private static readonly Random _Rand = new Random();
public static Random Rand public static Random Rand
{ {
@@ -221,16 +220,13 @@ namespace Vocaluxe.Base
_CurrentBeatD = (int)Math.Floor(_MidBeatD); _CurrentBeatD = (int)Math.Floor(_MidBeatD);
for (int p = 0; p < _NumPlayer; p++) for (int p = 0; p < _NumPlayer; p++)
{
CSound.AnalyzeBuffer(p); CSound.AnalyzeBuffer(p);
}
if (_OldBeatD >= _CurrentBeatD) if (_OldBeatD >= _CurrentBeatD)
return; return;
for (int p = 0; p < _NumPlayer; p++) for (int p = 0; p < _NumPlayer; p++)
{ {
for (int beat = _OldBeatD + 1; beat <= _CurrentBeatD; beat++) for (int beat = _OldBeatD + 1; beat <= _CurrentBeatD; beat++)
{ {
if ((_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat) || if ((_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat) ||
@@ -257,9 +253,7 @@ namespace Vocaluxe.Base
_Player[p].CurrentLine = Line; _Player[p].CurrentLine = Line;
while (_Player[p].SingLine.Count <= Line) while (_Player[p].SingLine.Count <= Line)
{
_Player[p].SingLine.Add(new CLine()); _Player[p].SingLine.Add(new CLine());
}
CNote[] notes = lines[Line].Notes; CNote[] notes = lines[Line].Notes;
int Note = -1; int Note = -1;
@@ -305,7 +299,8 @@ namespace Vocaluxe.Base
{ {
// valid // valid
//CSound.RecordSetTone(p, Tone); //CSound.RecordSetTone(p, Tone);
double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[Note].PointsForBeat / (double)song.Notes.GetLines(_Player[p].LineNr).Points; double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[Note].PointsForBeat /
song.Notes.GetLines(_Player[p].LineNr).Points;
if (notes[Note].NoteType == ENoteType.Golden) if (notes[Note].NoteType == ENoteType.Golden)
_Player[p].PointsGoldenNotes += points; _Player[p].PointsGoldenNotes += points;
@@ -318,14 +313,10 @@ namespace Vocaluxe.Base
if (notes[Note].StartBeat == beat || nt.EndBeat + 1 != beat || nt.Tone != Tone || !nt.Hit) if (notes[Note].StartBeat == beat || nt.EndBeat + 1 != beat || nt.Tone != Tone || !nt.Hit)
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, Tone, String.Empty, true, notes[Note].NoteType)); _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, Tone, String.Empty, true, notes[Note].NoteType));
else else
{
_Player[p].SingLine[Line].IncLastNoteLength(); _Player[p].SingLine[Line].IncLastNoteLength();
} }
}
else else
{
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, Tone, String.Empty, true, notes[Note].NoteType)); _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, Tone, String.Empty, true, notes[Note].NoteType));
}
_Player[p].SingLine[Line].LastNote.IsPerfect(notes[Note]); _Player[p].SingLine[Line].LastNote.IsPerfect(notes[Note]);
_Player[p].SingLine[Line].IsPerfect(lines[Line]); _Player[p].SingLine[Line].IsPerfect(lines[Line]);
@@ -336,20 +327,13 @@ namespace Vocaluxe.Base
{ {
CNote nt = _Player[p].SingLine[Line].LastNote; CNote nt = _Player[p].SingLine[Line].LastNote;
if (nt.Tone == TonePlayer && nt.EndBeat + 1 == beat && !nt.Hit) if (nt.Tone == TonePlayer && nt.EndBeat + 1 == beat && !nt.Hit)
{
_Player[p].SingLine[Line].IncLastNoteLength(); _Player[p].SingLine[Line].IncLastNoteLength();
}
else else
{
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle)); _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle));
} }
}
else else
{
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle)); _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle));
} }
}
} }
// Line Bonus // Line Bonus
@@ -358,7 +342,7 @@ namespace Vocaluxe.Base
{ {
if (notes[Note].EndBeat == beat && lines[Line].Points > 0f) if (notes[Note].EndBeat == beat && lines[Line].Points > 0f)
{ {
double factor = (double)_Player[p].SingLine[Line].Points / (double)lines[Line].Points; double factor = _Player[p].SingLine[Line].Points / (double)lines[Line].Points;
if (factor < 0.4) if (factor < 0.4)
factor = 0.0; factor = 0.0;
else if (factor > 0.9) else if (factor > 0.9)
@@ -377,7 +361,6 @@ namespace Vocaluxe.Base
} }
} }
} }
} }
} }
_OldBeatD = _CurrentBeatD; _OldBeatD = _CurrentBeatD;
+12 -38
View File
@@ -19,14 +19,14 @@ namespace Vocaluxe.Base
class CCursor class CCursor
{ {
private Stopwatch _CursorFadingTimer; private readonly Stopwatch _CursorFadingTimer;
private float _CursorTargetAlpha; private float _CursorTargetAlpha;
private float _CursorStartAlpha; private float _CursorStartAlpha;
private float _CursorFadingTime; private float _CursorFadingTime;
private STexture _Cursor; private STexture _Cursor;
private string _CursorName = String.Empty; private readonly string _CursorName = String.Empty;
private Stopwatch _Movetimer; private readonly Stopwatch _Movetimer;
public bool ShowCursor; public bool ShowCursor;
public bool Visible = true; public bool Visible = true;
@@ -160,7 +160,7 @@ namespace Vocaluxe.Base
static class CGraphics static class CGraphics
{ {
private static bool _Fading = false; private static bool _Fading;
private static Stopwatch _FadingTimer; private static Stopwatch _FadingTimer;
private static CCursor _Cursor; private static CCursor _Cursor;
private static float _GlobalAlpha; private static float _GlobalAlpha;
@@ -171,11 +171,11 @@ namespace Vocaluxe.Base
private static EScreens _NextScreen; private static EScreens _NextScreen;
private static EPopupScreens _CurrentPopupScreen; private static EPopupScreens _CurrentPopupScreen;
private static List<IMenu> _Screens = new List<IMenu>(); private static readonly List<IMenu> _Screens = new List<IMenu>();
private static List<IMenu> _PopupScreens = new List<IMenu>(); private static readonly List<IMenu> _PopupScreens = new List<IMenu>();
private static Stopwatch _VolumePopupTimer; private static Stopwatch _VolumePopupTimer;
private static bool CursorOverVolumeControl = false; private static bool CursorOverVolumeControl;
public static float GlobalAlpha public static float GlobalAlpha
{ {
@@ -265,43 +265,31 @@ namespace Vocaluxe.Base
{ {
ReloadCursor(); ReloadCursor();
for (int i = 0; i < _Screens.Count; i++) for (int i = 0; i < _Screens.Count; i++)
{
_Screens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1)); _Screens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1));
}
for (int i = 0; i < _PopupScreens.Count; i++) for (int i = 0; i < _PopupScreens.Count; i++)
{
_PopupScreens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1)); _PopupScreens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1));
} }
}
public static void ReloadSkin() public static void ReloadSkin()
{ {
ReloadCursor(); ReloadCursor();
for (int i = 0; i < _Screens.Count; i++) for (int i = 0; i < _Screens.Count; i++)
{
_Screens[i].ReloadTextures(); _Screens[i].ReloadTextures();
}
for (int i = 0; i < _PopupScreens.Count; i++) for (int i = 0; i < _PopupScreens.Count; i++)
{
_PopupScreens[i].ReloadTextures(); _PopupScreens[i].ReloadTextures();
} }
}
public static void SaveTheme() public static void SaveTheme()
{ {
CTheme.SaveTheme(); CTheme.SaveTheme();
for (int i = 0; i < _Screens.Count; i++) for (int i = 0; i < _Screens.Count; i++)
{
_Screens[i].SaveTheme(); _Screens[i].SaveTheme();
}
for (int i = 0; i < _PopupScreens.Count; i++) for (int i = 0; i < _PopupScreens.Count; i++)
{
_PopupScreens[i].SaveTheme(); _PopupScreens[i].SaveTheme();
} }
}
public static void InitFirstScreen() public static void InitFirstScreen()
{ {
@@ -438,9 +426,7 @@ namespace Vocaluxe.Base
} }
for (int i = 0; i < _PopupScreens.Count; i++) for (int i = 0; i < _PopupScreens.Count; i++)
{
_PopupScreens[i].Draw(); _PopupScreens[i].Draw();
}
_Cursor.Draw(); _Cursor.Draw();
DrawDebugInfos(); DrawDebugInfos();
@@ -490,7 +476,6 @@ namespace Vocaluxe.Base
{ {
_Cursor.ShowCursor = true; _Cursor.ShowCursor = true;
} }
#endregion public methods #endregion public methods
#region private stuff #region private stuff
@@ -502,7 +487,8 @@ namespace Vocaluxe.Base
MouseEvent InputMouseEvent = new MouseEvent(); MouseEvent InputMouseEvent = new MouseEvent();
bool PopupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing && bool PopupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing &&
(_CurrentScreen != EScreens.ScreenSong || (_CurrentScreen == EScreens.ScreenSong && !CSongs.IsInCategory && CConfig.Tabs ==EOffOn.TR_CONFIG_ON)) (_CurrentScreen != EScreens.ScreenSong ||
(_CurrentScreen == EScreens.ScreenSong && !CSongs.IsInCategory && CConfig.Tabs == EOffOn.TR_CONFIG_ON))
&& _CurrentScreen != EScreens.ScreenCredits && !CBackgroundMusic.Disabled; && _CurrentScreen != EScreens.ScreenCredits && !CBackgroundMusic.Disabled;
bool PopupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits && _CurrentScreen != EScreens.ScreenOptionsRecord; bool PopupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits && _CurrentScreen != EScreens.ScreenOptionsRecord;
@@ -555,12 +541,13 @@ namespace Vocaluxe.Base
int Diff = 0; int Diff = 0;
if ((KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp)) || (KeyEvent.Sender == ESender.WiiMote && KeyEvent.Key == Keys.Add)) if ((KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp)) || (KeyEvent.Sender == ESender.WiiMote && KeyEvent.Key == Keys.Add))
Diff = 5; Diff = 5;
else if ((KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) || (KeyEvent.Sender == ESender.WiiMote && KeyEvent.Key == Keys.Subtract)) else if ((KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) ||
(KeyEvent.Sender == ESender.WiiMote && KeyEvent.Key == Keys.Subtract))
Diff = -5; Diff = -5;
if (Diff != 0) if (Diff != 0)
{ {
switch (CGraphics.CurrentScreen) switch (CurrentScreen)
{ {
case EScreens.ScreenSong: case EScreens.ScreenSong:
if (CSongs.IsInCategory) if (CSongs.IsInCategory)
@@ -599,17 +586,11 @@ namespace Vocaluxe.Base
} }
if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.F1)) if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.F1))
{
CSettings.GameState = EGameState.EditTheme; CSettings.GameState = EGameState.EditTheme;
}
else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.Enter)) else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.Enter))
{
CSettings.bFullScreen = !CSettings.bFullScreen; CSettings.bFullScreen = !CSettings.bFullScreen;
}
else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.P)) else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.P))
{
CDraw.MakeScreenShot(); CDraw.MakeScreenShot();
}
else else
{ {
if (!_Fading) if (!_Fading)
@@ -703,13 +684,9 @@ namespace Vocaluxe.Base
_Screens[(int)_CurrentScreen].NextInteraction(); _Screens[(int)_CurrentScreen].NextInteraction();
} }
else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.Enter)) else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.Enter))
{
CSettings.bFullScreen = !CSettings.bFullScreen; CSettings.bFullScreen = !CSettings.bFullScreen;
}
else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.P)) else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.P))
{
CDraw.MakeScreenShot(); CDraw.MakeScreenShot();
}
else else
{ {
if (!_Fading) if (!_Fading)
@@ -741,9 +718,7 @@ namespace Vocaluxe.Base
} }
if (_VolumePopupTimer.IsRunning) if (_VolumePopupTimer.IsRunning)
{
_Cursor.FadeIn(); _Cursor.FadeIn();
}
if (_CurrentPopupScreen != EPopupScreens.NoPopup) if (_CurrentPopupScreen != EPopupScreens.NoPopup)
_PopupScreens[(int)_CurrentPopupScreen].UpdateGame(); _PopupScreens[(int)_CurrentPopupScreen].UpdateGame();
@@ -752,7 +727,6 @@ namespace Vocaluxe.Base
private static void DrawDebugInfos() private static void DrawDebugInfos()
{ {
string txt = String.Empty; string txt = String.Empty;
CFonts.Style = EStyle.Normal; CFonts.Style = EStyle.Normal;
CFonts.SetFont("Normal"); CFonts.SetFont("Normal");
+2 -3
View File
@@ -1,5 +1,4 @@
using Vocaluxe.Lib.Input;
using Vocaluxe.Lib.Input;
using Vocaluxe.Lib.Input.WiiMote; using Vocaluxe.Lib.Input.WiiMote;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -7,7 +6,7 @@ namespace Vocaluxe.Base
{ {
static class CInput static class CInput
{ {
static IInput _Input; private static IInput _Input;
public static void Init() public static void Init()
{ {
+5 -8
View File
@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
using System.Xml; using System.Xml;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -23,10 +24,10 @@ namespace Vocaluxe.Base
static class CLanguage static class CLanguage
{ {
private static XmlWriterSettings _settings = new XmlWriterSettings(); private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
private static List<SLanguage> _Languages; private static List<SLanguage> _Languages;
private static int _CurrentLanguage = 0; private static int _CurrentLanguage;
private static int _FallbackLanguage = 0; private static int _FallbackLanguage;
public static int LanguageId public static int LanguageId
{ {
@@ -48,9 +49,7 @@ namespace Vocaluxe.Base
string[] Languages = new string[_Languages.Count]; string[] Languages = new string[_Languages.Count];
for (int i = 0; i < _Languages.Count; i++) for (int i = 0; i < _Languages.Count; i++)
{
Languages[i] = _Languages[i].Name; Languages[i] = _Languages[i].Name;
}
return Languages; return Languages;
} }
@@ -59,17 +58,15 @@ namespace Vocaluxe.Base
{ {
_Languages = new List<SLanguage>(); _Languages = new List<SLanguage>();
_settings.Indent = true; _settings.Indent = true;
_settings.Encoding = System.Text.Encoding.UTF8; _settings.Encoding = Encoding.UTF8;
_settings.ConformanceLevel = ConformanceLevel.Document; _settings.ConformanceLevel = ConformanceLevel.Document;
List<string> files = new List<string>(); List<string> files = new List<string>();
files.AddRange(CHelper.ListFiles(CSettings.sFolderLanguages, "*.xml", true, true)); files.AddRange(CHelper.ListFiles(CSettings.sFolderLanguages, "*.xml", true, true));
foreach (string file in files) foreach (string file in files)
{
LoadLanguageFile(file); LoadLanguageFile(file);
} }
}
public static bool SetLanguage(string Language) public static bool SetLanguage(string Language)
{ {
+7 -17
View File
@@ -7,9 +7,9 @@ namespace Vocaluxe.Base
{ {
class Log : IDisposable class Log : IDisposable
{ {
private string _LogFileName; private readonly string _LogFileName;
private string _LogName; private readonly string _LogName;
private StreamWriter _LogFile = null; private StreamWriter _LogFile;
public Log(string FileName, string LogName) public Log(string FileName, string LogName)
{ {
@@ -26,9 +26,7 @@ namespace Vocaluxe.Base
_LogFile.Flush(); _LogFile.Flush();
_LogFile.Close(); _LogFile.Close();
} }
catch (Exception) catch (Exception) {}
{
}
} }
} }
@@ -42,9 +40,7 @@ namespace Vocaluxe.Base
_LogFile.WriteLine(Text); _LogFile.WriteLine(Text);
_LogFile.Flush(); _LogFile.Flush();
} }
catch (Exception) catch (Exception) {}
{
}
} }
private void Open() private void Open()
@@ -77,7 +73,7 @@ namespace Vocaluxe.Base
private static int _NumErrors; private static int _NumErrors;
private static Stopwatch[] _BenchmarkTimer; private static Stopwatch[] _BenchmarkTimer;
private static double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency; private static readonly double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
public static void Init() public static void Init()
{ {
@@ -88,10 +84,8 @@ namespace Vocaluxe.Base
_NumErrors = 0; _NumErrors = 0;
_BenchmarkTimer = new Stopwatch[MAXBenchmarks]; _BenchmarkTimer = new Stopwatch[MAXBenchmarks];
for (int i = 0; i < _BenchmarkTimer.Length; i++) for (int i = 0; i < _BenchmarkTimer.Length; i++)
{
_BenchmarkTimer[i] = new Stopwatch(); _BenchmarkTimer[i] = new Stopwatch();
} }
}
public static void CloseAll() public static void CloseAll()
{ {
@@ -128,9 +122,7 @@ namespace Vocaluxe.Base
string space = String.Empty; string space = String.Empty;
for (int i = 0; i < BenchmarkNr; i++) for (int i = 0; i < BenchmarkNr; i++)
{
space += " "; space += " ";
}
_BenchmarkLog.Add(space + "Start " + Text); _BenchmarkLog.Add(space + "Start " + Text);
_BenchmarkTimer[BenchmarkNr].Start(); _BenchmarkTimer[BenchmarkNr].Start();
@@ -145,15 +137,13 @@ namespace Vocaluxe.Base
string space = String.Empty; string space = String.Empty;
for (int i = 0; i < BenchmarkNr; i++) for (int i = 0; i < BenchmarkNr; i++)
{
space += " "; space += " ";
}
float ms; float ms;
if (Stopwatch.IsHighResolution && nanosecPerTick != 0.0) if (Stopwatch.IsHighResolution && nanosecPerTick != 0.0)
ms = (float)((nanosecPerTick * _BenchmarkTimer[BenchmarkNr].ElapsedTicks) / (1000.0 * 1000.0)); ms = (float)((nanosecPerTick * _BenchmarkTimer[BenchmarkNr].ElapsedTicks) / (1000.0 * 1000.0));
else else
ms = (float)_BenchmarkTimer[BenchmarkNr].ElapsedMilliseconds; ms = _BenchmarkTimer[BenchmarkNr].ElapsedMilliseconds;
_BenchmarkLog.Add(space + "Stop " + Text + ", Elapsed Time: " + ms.ToString("0.000") + "ms"); _BenchmarkLog.Add(space + "Stop " + Text + ", Elapsed Time: " + ms.ToString("0.000") + "ms");
_BenchmarkLog.Add(String.Empty); _BenchmarkLog.Add(String.Empty);
+1 -8
View File
@@ -273,12 +273,9 @@ namespace Vocaluxe.Base
{ {
CTheme.LoadTheme(); CTheme.LoadTheme();
} }
} }
class BHelper : IHelper class BHelper : IHelper {}
{
}
class BBackgroundMusic : IBackgroundMusic class BBackgroundMusic : IBackgroundMusic
{ {
@@ -327,7 +324,6 @@ namespace Vocaluxe.Base
CBackgroundMusic.Play(); CBackgroundMusic.Play();
} }
public void ApplyVolume() public void ApplyVolume()
{ {
CBackgroundMusic.ApplyVolume(); CBackgroundMusic.ApplyVolume();
@@ -685,7 +681,6 @@ namespace Vocaluxe.Base
{ {
return CVideo.VdClose(VideoStream); return CVideo.VdClose(VideoStream);
} }
} }
class BSound : ISound class BSound : ISound
@@ -797,8 +792,6 @@ namespace Vocaluxe.Base
return CPlaylists.NumPlaylists; return CPlaylists.NumPlaylists;
} }
public void AddPlaylistSong(int PlaylistID, int SongID) public void AddPlaylistSong(int PlaylistID, int SongID)
{ {
CPlaylists.AddPlaylistSong(PlaylistID, SongID); CPlaylists.AddPlaylistSong(PlaylistID, SongID);
+2 -4
View File
@@ -8,6 +8,7 @@ using VocaluxeLib.PartyModes;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
#region Structs #region Structs
struct SPartyMode struct SPartyMode
{ {
@@ -27,10 +28,9 @@ namespace Vocaluxe.Base
} }
#endregion Structs #endregion Structs
static class CParty static class CParty
{ {
const int PartyModeSystemVersion = 1; private const int PartyModeSystemVersion = 1;
private static Dictionary<int, SPartyMode> _PartyModes; private static Dictionary<int, SPartyMode> _PartyModes;
private static Queue<int> _IDs; private static Queue<int> _IDs;
@@ -355,9 +355,7 @@ namespace Vocaluxe.Base
if (CompileResult.Errors.Count > 0) if (CompileResult.Errors.Count > 0)
{ {
foreach (CompilerError e in CompileResult.Errors) foreach (CompilerError e in CompileResult.Errors)
{
CLog.LogError("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + e.ErrorText + " in '" + e.FileName + "' (" + e.Line + ")"); CLog.LogError("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + e.ErrorText + " in '" + e.FileName + "' (" + e.Line + ")");
}
return null; return null;
} }
return CompileResult.CompiledAssembly; return CompileResult.CompiledAssembly;
-12
View File
@@ -2,14 +2,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using Vocaluxe.Lib.Playlist; using Vocaluxe.Lib.Playlist;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
static class CPlaylists static class CPlaylists
{ {
private static List<CPlaylistFile> _Playlists; private static List<CPlaylistFile> _Playlists;
@@ -25,9 +23,7 @@ namespace Vocaluxe.Base
{ {
List<string> names = new List<string>(); List<string> names = new List<string>();
for (int i = 0; i < _Playlists.Count; i++) for (int i = 0; i < _Playlists.Count; i++)
{
names.Add(_Playlists[i].PlaylistName); names.Add(_Playlists[i].PlaylistName);
}
return names.ToArray(); return names.ToArray();
} }
} }
@@ -84,9 +80,7 @@ namespace Vocaluxe.Base
List<string> result = new List<string>(); List<string> result = new List<string>();
foreach (CPlaylistFile playlist in _Playlists) foreach (CPlaylistFile playlist in _Playlists)
{
result.Add(playlist.PlaylistName); result.Add(playlist.PlaylistName);
}
return result.ToArray(); return result.ToArray();
} }
@@ -132,8 +126,6 @@ namespace Vocaluxe.Base
return (_Playlists.Count - 1); return (_Playlists.Count - 1);
} }
public static void AddPlaylistSong(int PlaylistID, int SongID) public static void AddPlaylistSong(int PlaylistID, int SongID)
{ {
if (PlaylistID >= _Playlists.Count || PlaylistID < 0) if (PlaylistID >= _Playlists.Count || PlaylistID < 0)
@@ -230,10 +222,8 @@ namespace Vocaluxe.Base
StreamReader sr; StreamReader sr;
try try
{ {
using (sr = new StreamReader(file, Encoding.Default, true)) using (sr = new StreamReader(file, Encoding.Default, true))
{ {
int pos = -1; int pos = -1;
string line; string line;
while ((line = sr.ReadLine()) != null) while ((line = sr.ReadLine()) != null)
@@ -247,10 +237,8 @@ namespace Vocaluxe.Base
string Identifier = line.Substring(1, pos - 1).Trim(); string Identifier = line.Substring(1, pos - 1).Trim();
string Value = line.Substring(pos + 1, line.Length - pos - 1).Trim(); string Value = line.Substring(pos + 1, line.Length - pos - 1).Trim();
if (Identifier.ToUpper() == "NAME") if (Identifier.ToUpper() == "NAME")
{
pl.PlaylistName = Value; pl.PlaylistName = Value;
} }
}
//Song //Song
else else
{ {
+7 -17
View File
@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
using System.Xml; using System.Xml;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -8,9 +9,9 @@ namespace Vocaluxe.Base
{ {
static class CProfiles static class CProfiles
{ {
private static XmlWriterSettings _settings = new XmlWriterSettings(); private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
private static List<SProfile> _Profiles; private static List<SProfile> _Profiles;
private static List<SAvatar> _Avatars = new List<SAvatar>(); private static readonly List<SAvatar> _Avatars = new List<SAvatar>();
public static SProfile[] Profiles public static SProfile[] Profiles
{ {
@@ -35,7 +36,7 @@ namespace Vocaluxe.Base
public static void Init() public static void Init()
{ {
_settings.Indent = true; _settings.Indent = true;
_settings.Encoding = System.Text.Encoding.UTF8; _settings.Encoding = Encoding.UTF8;
_settings.ConformanceLevel = ConformanceLevel.Document; _settings.ConformanceLevel = ConformanceLevel.Document;
LoadAvatars(); LoadAvatars();
@@ -72,9 +73,7 @@ namespace Vocaluxe.Base
public static void SaveProfiles() public static void SaveProfiles()
{ {
for (int i = 0; i < _Profiles.Count; i++) for (int i = 0; i < _Profiles.Count; i++)
{
SaveProfile(i); SaveProfile(i);
}
LoadProfiles(); LoadProfiles();
} }
@@ -85,9 +84,7 @@ namespace Vocaluxe.Base
files.AddRange(CHelper.ListFiles(CSettings.sFolderProfiles, "*.xml", true, true)); files.AddRange(CHelper.ListFiles(CSettings.sFolderProfiles, "*.xml", true, true));
foreach (string file in files) foreach (string file in files)
{
LoadProfile(file); LoadProfile(file);
}
SortProfilesByName(); SortProfilesByName();
} }
@@ -307,10 +304,8 @@ namespace Vocaluxe.Base
{ {
i++; i++;
if (!File.Exists(Path.Combine(CSettings.sFolderProfiles, filename + i + ".xml"))) if (!File.Exists(Path.Combine(CSettings.sFolderProfiles, filename + i + ".xml")))
{
filename += i; filename += i;
} }
}
SProfile profile = _Profiles[ProfileID]; SProfile profile = _Profiles[ProfileID];
profile.ProfileFile = Path.Combine(CSettings.sFolderProfiles, filename + ".xml"); profile.ProfileFile = Path.Combine(CSettings.sFolderProfiles, filename + ".xml");
@@ -329,7 +324,6 @@ namespace Vocaluxe.Base
} }
try try
{ {
writer.WriteStartDocument(); writer.WriteStartDocument();
writer.WriteStartElement("root"); writer.WriteStartElement("root");
@@ -368,27 +362,23 @@ namespace Vocaluxe.Base
profile.PlayerName = value; profile.PlayerName = value;
profile.Difficulty = EGameDifficulty.TR_CONFIG_EASY; profile.Difficulty = EGameDifficulty.TR_CONFIG_EASY;
xmlReader.TryGetEnumValue<EGameDifficulty>("//root/Info/Difficulty", ref profile.Difficulty); xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref profile.Difficulty);
profile.Avatar = new SAvatar(-1); profile.Avatar = new SAvatar(-1);
if (xmlReader.GetValue("//root/Info/Avatar", ref value, value)) if (xmlReader.GetValue("//root/Info/Avatar", ref value, value))
{
profile.Avatar = GetAvatar(value); profile.Avatar = GetAvatar(value);
}
profile.GuestProfile = EOffOn.TR_CONFIG_OFF; profile.GuestProfile = EOffOn.TR_CONFIG_OFF;
xmlReader.TryGetEnumValue<EOffOn>("//root/Info/GuestProfile", ref profile.GuestProfile); xmlReader.TryGetEnumValue("//root/Info/GuestProfile", ref profile.GuestProfile);
profile.Active = EOffOn.TR_CONFIG_ON; profile.Active = EOffOn.TR_CONFIG_ON;
xmlReader.TryGetEnumValue<EOffOn>("//root/Info/Active", ref profile.Active); xmlReader.TryGetEnumValue("//root/Info/Active", ref profile.Active);
_Profiles.Add(profile); _Profiles.Add(profile);
} }
else else
{
CLog.LogError("Can't find PlayerName in Profile File: " + FileName); CLog.LogError("Can't find PlayerName in Profile File: " + FileName);
} }
}
#endregion private methods #endregion private methods
} }
} }
+6 -6
View File
@@ -29,7 +29,6 @@ namespace Vocaluxe.Base
public const EArch ARCH = EArch.x64; public const EArch ARCH = EArch.x64;
#endif #endif
public static EGameState GameState = EGameState.Start; public static EGameState GameState = EGameState.Start;
public const string sProgramName = "Vocaluxe"; public const string sProgramName = "Vocaluxe";
@@ -46,7 +45,6 @@ namespace Vocaluxe.Base
public const int iDatabaseCoverVersion = 1; public const int iDatabaseCoverVersion = 1;
public const int iDatabaseCreditsRessourcesVersion = 1; public const int iDatabaseCreditsRessourcesVersion = 1;
public static int iRenderW = 1280; public static int iRenderW = 1280;
public static int iRenderH = 720; public static int iRenderH = 720;
@@ -89,7 +87,6 @@ namespace Vocaluxe.Base
public const string sFolderBackgroundMusic = "BackgroundMusic"; public const string sFolderBackgroundMusic = "BackgroundMusic";
public static string sFolderPlaylists = "Playlists"; public static string sFolderPlaylists = "Playlists";
public static string sFolderPartyModes = "PartyModes"; public static string sFolderPartyModes = "PartyModes";
public const string sFolderPartyModeCode = "Code"; public const string sFolderPartyModeCode = "Code";
public const string sFolderPartyModeScreens = "Screens"; public const string sFolderPartyModeScreens = "Screens";
@@ -122,9 +119,12 @@ namespace Vocaluxe.Base
public const float BackgroundMusicFadeTime = 0.5f; public const float BackgroundMusicFadeTime = 0.5f;
public static List<string> MusicFileTypes = new List<string>() public static List<string> MusicFileTypes = new List<string>
{ {
"*.mp3","*.wma","*.ogg","*.wav" "*.mp3",
"*.wma",
"*.ogg",
"*.wav"
}; };
public static string GetVersionText() public static string GetVersionText()
@@ -161,7 +161,7 @@ namespace Vocaluxe.Base
public static float GetRenderAspect() public static float GetRenderAspect()
{ {
return (float)iRenderW / (float)iRenderH; return iRenderW / (float)iRenderH;
} }
public static void MouseInactive() public static void MouseInactive()
+8 -9
View File
@@ -8,7 +8,7 @@ namespace Vocaluxe.Base
{ {
class CSongCategorizer : CObservable class CSongCategorizer : CObservable
{ {
private List<CCategory> _Categories = new List<CCategory>(); private readonly List<CCategory> _Categories = new List<CCategory>();
private EOffOn _Tabs = CConfig.Tabs; private EOffOn _Tabs = CConfig.Tabs;
public CSongCategorizer() public CSongCategorizer()
@@ -18,7 +18,11 @@ namespace Vocaluxe.Base
public List<CCategory> Categories public List<CCategory> Categories
{ {
get { _FillCategories(); return _Categories; } get
{
_FillCategories();
return _Categories;
}
} }
public EOffOn Tabs public EOffOn Tabs
@@ -48,9 +52,7 @@ namespace Vocaluxe.Base
Char firstLetter = Char.ToUpper(CSongs.Sorter.SortedSongs[i].SortString.Normalize(NormalizationForm.FormD)[0]); Char firstLetter = Char.ToUpper(CSongs.Sorter.SortedSongs[i].SortString.Normalize(NormalizationForm.FormD)[0]);
if (!Char.IsLetter(firstLetter)) if (!Char.IsLetter(firstLetter))
{
firstLetter = '#'; firstLetter = '#';
}
if (firstLetter.ToString() != category) if (firstLetter.ToString() != category)
{ {
if (firstLetter != '#' || NotLetterCat == -1) if (firstLetter != '#' || NotLetterCat == -1)
@@ -97,7 +99,6 @@ namespace Vocaluxe.Base
CSongs.Sorter.SortedSongs[i].CatIndex = NoCategoryIndex; CSongs.Sorter.SortedSongs[i].CatIndex = NoCategoryIndex;
} }
} }
} }
private void _CreateCategories() private void _CreateCategories()
@@ -130,6 +131,7 @@ namespace Vocaluxe.Base
else else
{ {
if (Sorting == ESongSorting.TR_CONFIG_DECADE) if (Sorting == ESongSorting.TR_CONFIG_DECADE)
{
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
{ {
string Year = CSongs.Sorter.SortedSongs[i].SortString; string Year = CSongs.Sorter.SortedSongs[i].SortString;
@@ -139,6 +141,7 @@ namespace Vocaluxe.Base
CSongs.Sorter.SortedSongs[i].SortString = Year + "0 - " + Year + "9"; CSongs.Sorter.SortedSongs[i].SortString = Year + "0 - " + Year + "9";
} }
} }
}
_CreateCategoriesNormal(NoCategoryName); _CreateCategoriesNormal(NoCategoryName);
} }
} }
@@ -155,17 +158,13 @@ namespace Vocaluxe.Base
//No categories. So don't create them! //No categories. So don't create them!
_Categories.Add(new CCategory("")); _Categories.Add(new CCategory(""));
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
{
CSongs.Sorter.SortedSongs[i].CatIndex = 0; CSongs.Sorter.SortedSongs[i].CatIndex = 0;
} }
}
else else
_CreateCategories(); _CreateCategories();
foreach (CCategory cat in _Categories) foreach (CCategory cat in _Categories)
{
cat.CoverTextureSmall = CCover.Cover(cat.Name); cat.CoverTextureSmall = CCover.Cover(cat.Name);
}
_Changed = false; _Changed = false;
} }
} }
+6 -5
View File
@@ -14,7 +14,11 @@ namespace Vocaluxe.Base
public List<CSong> FilteredSongs public List<CSong> FilteredSongs
{ {
get { _FilterSongs(); return _FilteredSongs; } get
{
_FilterSongs();
return _FilteredSongs;
}
} }
public String SearchString public String SearchString
@@ -62,7 +66,7 @@ namespace Vocaluxe.Base
string[] searchStrings = null; string[] searchStrings = null;
if (_SearchString.Length > 0) if (_SearchString.Length > 0)
searchStrings = _SearchString.ToUpper().Split(new char[] { ' ' }); searchStrings = _SearchString.ToUpper().Split(new[] {' '});
foreach (CSong song in CSongs.Songs) foreach (CSong song in CSongs.Songs)
{ {
@@ -77,9 +81,7 @@ namespace Vocaluxe.Base
bool contains = true; bool contains = true;
foreach (string str in searchStrings) foreach (string str in searchStrings)
{
contains &= search.Contains(str); contains &= search.Contains(str);
}
if (contains) if (contains)
_FilteredSongs.Add(song); _FilteredSongs.Add(song);
} }
@@ -87,6 +89,5 @@ namespace Vocaluxe.Base
} }
_Changed = false; _Changed = false;
} }
} }
} }
+7 -10
View File
@@ -19,7 +19,11 @@ namespace Vocaluxe.Base
public SongPointer[] SortedSongs public SongPointer[] SortedSongs
{ {
get { _SortSongs(); return _SortedSongs; } get
{
_SortSongs();
return _SortedSongs;
}
} }
public EOffOn IgnoreArticles public EOffOn IgnoreArticles
@@ -72,18 +76,14 @@ namespace Vocaluxe.Base
{ {
res = CSongs.Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].ArtistSorting.ToUpper()); res = CSongs.Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].ArtistSorting.ToUpper());
if (res == 0) if (res == 0)
{
return CSongs.Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].TitleSorting.ToUpper()); return CSongs.Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].TitleSorting.ToUpper());
}
return res; return res;
} }
else else
{ {
res = CSongs.Songs[s1.SongID].Artist.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Artist.ToUpper()); res = CSongs.Songs[s1.SongID].Artist.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Artist.ToUpper());
if (res == 0) if (res == 0)
{
return CSongs.Songs[s1.SongID].Title.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Title.ToUpper()); return CSongs.Songs[s1.SongID].Title.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Title.ToUpper());
}
return res; return res;
} }
} }
@@ -110,7 +110,8 @@ namespace Vocaluxe.Base
List<SongPointer> SortList = new List<SongPointer>(); List<SongPointer> SortList = new List<SongPointer>();
if (fieldName.Length == 0) if (fieldName.Length == 0)
CSongs.Filter.FilteredSongs.ForEach((song) => SortList.Add(new SongPointer(song.ID, ""))); CSongs.Filter.FilteredSongs.ForEach((song) => SortList.Add(new SongPointer(song.ID, "")));
else{ else
{
field = Type.GetType("Vocaluxe.Menu.SongMenu.CSong,VocaluxeLib").GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); field = Type.GetType("Vocaluxe.Menu.SongMenu.CSong,VocaluxeLib").GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
isString = field.FieldType == typeof(string); isString = field.FieldType == typeof(string);
if (!isString && field.FieldType != typeof(List<String>)) if (!isString && field.FieldType != typeof(List<String>))
@@ -124,19 +125,15 @@ namespace Vocaluxe.Base
{ {
List<String> values = (List<String>)value; List<String> values = (List<String>)value;
if (values.Count == 0) if (values.Count == 0)
{
SortList.Add(new SongPointer(song.ID, "")); SortList.Add(new SongPointer(song.ID, ""));
}
else else
{ {
foreach (String sortString in (List<String>)value) foreach (String sortString in (List<String>)value)
{
SortList.Add(new SongPointer(song.ID, sortString)); SortList.Add(new SongPointer(song.ID, sortString));
} }
} }
} }
} }
}
return SortList; return SortList;
} }
+10 -13
View File
@@ -27,16 +27,16 @@ namespace Vocaluxe.Base
static class CSongs static class CSongs
{ {
private static List<CSong> _Songs = new List<CSong>(); private static readonly List<CSong> _Songs = new List<CSong>();
private static List<CSong> _SongsForRandom = new List<CSong>(); private static readonly List<CSong> _SongsForRandom = new List<CSong>();
private static bool _SongsLoaded = false; private static bool _SongsLoaded;
private static bool _CoverLoaded = false; private static bool _CoverLoaded;
private static int _CoverLoadIndex = 0; private static int _CoverLoadIndex;
private static int _CatIndex = -1; private static int _CatIndex = -1;
private static List<CCategory> _CategoriesForRandom = new List<CCategory>(); private static readonly List<CCategory> _CategoriesForRandom = new List<CCategory>();
private static Stopwatch _CoverLoadTimer = new Stopwatch(); private static readonly Stopwatch _CoverLoadTimer = new Stopwatch();
public static CSongFilter Filter = new CSongFilter(); public static CSongFilter Filter = new CSongFilter();
public static CSongSorter Sorter = new CSongSorter(); public static CSongSorter Sorter = new CSongSorter();
@@ -96,12 +96,10 @@ namespace Vocaluxe.Base
_CatIndex = value; _CatIndex = value;
for (int i = 0; i < Sorter.SortedSongs.Length; i++) for (int i = 0; i < Sorter.SortedSongs.Length; i++)
{
Sorter.SortedSongs[i].Visible = (Sorter.SortedSongs[i].CatIndex == _CatIndex && !Sorter.SortedSongs[i].PartyHidden); Sorter.SortedSongs[i].Visible = (Sorter.SortedSongs[i].CatIndex == _CatIndex && !Sorter.SortedSongs[i].PartyHidden);
} }
} }
} }
}
public static bool IsInCategory public static bool IsInCategory
{ {
@@ -134,6 +132,7 @@ namespace Vocaluxe.Base
else else
Category++; Category++;
} }
public static void PrevCategory() public static void PrevCategory()
{ {
if (Category == 0) if (Category == 0)
@@ -156,6 +155,7 @@ namespace Vocaluxe.Base
return -2; return -2;
} }
public static int NumSongsWithCoverLoaded public static int NumSongsWithCoverLoaded
{ {
get { return _CoverLoadIndex; } get { return _CoverLoadIndex; }
@@ -168,8 +168,8 @@ namespace Vocaluxe.Base
if (SongIndex < _Songs.Count) if (SongIndex < _Songs.Count)
_Songs[SongIndex].CoverTextureSmall = Texture; _Songs[SongIndex].CoverTextureSmall = Texture;
} }
public static void SetCoverBig(int SongIndex, STexture Texture) public static void SetCoverBig(int SongIndex, STexture Texture)
{ {
if (!_SongsLoaded) if (!_SongsLoaded)
@@ -177,7 +177,6 @@ namespace Vocaluxe.Base
if (SongIndex < _Songs.Count) if (SongIndex < _Songs.Count)
_Songs[SongIndex].CoverTextureBig = Texture; _Songs[SongIndex].CoverTextureBig = Texture;
} }
public static string GetCurrentCategoryName() public static string GetCurrentCategoryName()
@@ -255,9 +254,7 @@ namespace Vocaluxe.Base
public static int GetRandomSong() public static int GetRandomSong()
{ {
if (_SongsForRandom.Count == 0) if (_SongsForRandom.Count == 0)
{
UpdateRandomSongList(); UpdateRandomSongList();
}
if (_SongsForRandom.Count == 0) if (_SongsForRandom.Count == 0)
return -1; return -1;
+22 -34
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using Vocaluxe.Lib.Sound; using Vocaluxe.Lib.Sound;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -15,7 +14,7 @@ namespace Vocaluxe.Base
static class CSound static class CSound
{ {
#region Playback #region Playback
private static IPlayback _Playback = null; private static IPlayback _Playback;
public static bool PlaybackInit() public static bool PlaybackInit()
{ {
@@ -150,8 +149,8 @@ namespace Vocaluxe.Base
{ {
_Playback.SetPosition(Stream, Position); _Playback.SetPosition(Stream, Position);
} }
#endregion Stream Handling #endregion Stream Handling
#endregion Playback #endregion Playback
#region Sounds #region Sounds
@@ -168,16 +167,16 @@ namespace Vocaluxe.Base
if (file.Length == 0) if (file.Length == 0)
return -1; return -1;
int stream = CSound.Load(file); int stream = Load(file);
float length = CSound.GetLength(stream); float length = GetLength(stream);
CSound.Play(stream); Play(stream);
CSound.FadeAndStop(stream, 100f, length); FadeAndStop(stream, 100f, length);
return stream; return stream;
} }
#endregion Sounds #endregion Sounds
#region Record #region Record
private static IRecord _Record = null; private static IRecord _Record;
public static bool RecordInit() public static bool RecordInit()
{ {
@@ -291,10 +290,8 @@ namespace Vocaluxe.Base
CConfig.MicConfig[p].DeviceDriver == devicedriver && CConfig.MicConfig[p].DeviceDriver == devicedriver &&
CConfig.MicConfig[p].InputName == input && CConfig.MicConfig[p].InputName == input &&
CConfig.MicConfig[p].Channel == channel) CConfig.MicConfig[p].Channel == channel)
{
return p + 1; return p + 1;
} }
}
return 0; return 0;
} }
#endregion Record #endregion Record
@@ -305,25 +302,23 @@ namespace Vocaluxe.Base
private const double _BaseToneFreq = 65.4064; private const double _BaseToneFreq = 65.4064;
private const int _NumHalfTones = 47; private const int _NumHalfTones = 47;
private float[] _ToneWeigth; private readonly float[] _ToneWeigth;
private Int16[] _AnalysisBuffer = new Int16[4096]; private Int16[] _AnalysisBuffer = new Int16[4096];
private Object _AnalysisBufferLock = new Object(); private readonly Object _AnalysisBufferLock = new Object();
private bool _ToneValid = false; private bool _ToneValid;
private int _Tone = 0; private int _Tone;
private int _ToneAbs = 0; private int _ToneAbs;
private double _MaxVolume = 0.0; private double _MaxVolume;
private bool _NewSamples; private bool _NewSamples;
private MemoryStream _Stream = null; // full buffer private MemoryStream _Stream; // full buffer
public CBuffer() public CBuffer()
{ {
_ToneWeigth = new float[_NumHalfTones]; _ToneWeigth = new float[_NumHalfTones];
for (int i = 0; i < _ToneWeigth.Length; i++) for (int i = 0; i < _ToneWeigth.Length; i++)
{
_ToneWeigth[i] = 0.99f; _ToneWeigth[i] = 0.99f;
}
_Stream = new MemoryStream(); _Stream = new MemoryStream();
_NewSamples = false; _NewSamples = false;
} }
@@ -422,7 +417,6 @@ namespace Vocaluxe.Base
public void ProcessNewBuffer(byte[] buffer) public void ProcessNewBuffer(byte[] buffer)
{ {
// apply software boost // apply software boost
//BoostBuffer(Buffer, BufferSize); //BoostBuffer(Buffer, BufferSize);
@@ -469,7 +463,7 @@ namespace Vocaluxe.Base
_MaxVolume = 0; _MaxVolume = 0;
for (int i = 0; i < _AnalysisBuffer.Length / 4; i++) for (int i = 0; i < _AnalysisBuffer.Length / 4; i++)
{ {
float Volume = Math.Abs((float)_AnalysisBuffer[i]) / (float)Int16.MaxValue; float Volume = Math.Abs((float)_AnalysisBuffer[i]) / Int16.MaxValue;
if (Volume > MaxVolume) if (Volume > MaxVolume)
_MaxVolume = Volume; _MaxVolume = Volume;
} }
@@ -478,12 +472,8 @@ namespace Vocaluxe.Base
AnalyzeByAutocorrelation(true); AnalyzeByAutocorrelation(true);
else else
AnalyzeByAutocorrelation(false); AnalyzeByAutocorrelation(false);
}
catch (Exception)
{
} }
catch (Exception) {}
} }
private void AnalyzeByAutocorrelation(bool valid) private void AnalyzeByAutocorrelation(bool valid)
@@ -521,9 +511,7 @@ namespace Vocaluxe.Base
if (valid && MaxWeight - MinWeight > 0.01) if (valid && MaxWeight - MinWeight > 0.01)
{ {
for (int i = 0; i < Weigth.Length; i++) for (int i = 0; i < Weigth.Length; i++)
{
_ToneWeigth[i] = Weigth[i]; _ToneWeigth[i] = Weigth[i];
}
_ToneAbs = MaxTone; _ToneAbs = MaxTone;
_Tone = MaxTone % 12; _Tone = MaxTone % 12;
@@ -546,7 +534,7 @@ namespace Vocaluxe.Base
{ {
// calc distance (correlation: 1-dist) to corresponding sample in next period // calc distance (correlation: 1-dist) to corresponding sample in next period
// distance (0=equal .. 1=totally different) between correlated samples // distance (0=equal .. 1=totally different) between correlated samples
double Dist = Math.Abs((double)_AnalysisBuffer[SampleIndex] - _AnalysisBuffer[CorrelatingSampleIndex]) / (double)Int16.MaxValue; double Dist = Math.Abs((double)_AnalysisBuffer[SampleIndex] - _AnalysisBuffer[CorrelatingSampleIndex]) / Int16.MaxValue;
AccumDist += Dist; AccumDist += Dist;
SampleIndex++; SampleIndex++;
CorrelatingSampleIndex++; CorrelatingSampleIndex++;
@@ -568,8 +556,8 @@ namespace Vocaluxe.Base
class CSyncTimer class CSyncTimer
{ {
private PT1 _ExternTime; private readonly PT1 _ExternTime;
private Stopwatch _Timer; private readonly Stopwatch _Timer;
private float _SetValue; private float _SetValue;
public float Time public float Time
@@ -648,9 +636,9 @@ namespace Vocaluxe.Base
private float _CurrentTime; private float _CurrentTime;
private float _OldTime; private float _OldTime;
private Stopwatch _STimer; private readonly Stopwatch _STimer;
private float _K; private readonly float _K;
private float _T; private readonly float _T;
public float Time public float Time
{ {
+6 -23
View File
@@ -8,6 +8,7 @@ using VocaluxeLib.Menu;
namespace Vocaluxe.Base namespace Vocaluxe.Base
{ {
#region Structs #region Structs
struct Theme struct Theme
{ {
@@ -79,12 +80,12 @@ namespace Vocaluxe.Base
static class CTheme static class CTheme
{ {
// Version number for main theme and skin files. Increment it, if you've changed something on the theme files! // Version number for main theme and skin files. Increment it, if you've changed something on the theme files!
const int ThemeSystemVersion = 5; private const int ThemeSystemVersion = 5;
const int SkinSystemVersion = 3; private const int SkinSystemVersion = 3;
#region Vars #region Vars
private static XmlWriterSettings _settings = new XmlWriterSettings(); private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
private static List<Theme> _Themes = new List<Theme>(); private static readonly List<Theme> _Themes = new List<Theme>();
public static string[] ThemeNames public static string[] ThemeNames
{ {
get get
@@ -99,7 +100,7 @@ namespace Vocaluxe.Base
} }
} }
private static List<Skin> _Skins = new List<Skin>(); private static readonly List<Skin> _Skins = new List<Skin>();
public static string[] SkinNames public static string[] SkinNames
{ {
get get
@@ -360,9 +361,7 @@ namespace Vocaluxe.Base
writer.WriteStartElement("Skins"); writer.WriteStartElement("Skins");
foreach (SkinElement element in _Skins[SkinIndex].SkinList.Values) foreach (SkinElement element in _Skins[SkinIndex].SkinList.Values)
{
writer.WriteElementString(element.Name, element.Value); writer.WriteElementString(element.Name, element.Value);
}
writer.WriteEndElement(); writer.WriteEndElement();
#endregion Skins #endregion Skins
@@ -370,9 +369,7 @@ namespace Vocaluxe.Base
writer.WriteStartElement("Videos"); writer.WriteStartElement("Videos");
foreach (SkinElement element in _Skins[SkinIndex].VideoList) foreach (SkinElement element in _Skins[SkinIndex].VideoList)
{
writer.WriteElementString(element.Name, element.Value); writer.WriteElementString(element.Name, element.Value);
}
writer.WriteEndElement(); writer.WriteEndElement();
#endregion Videos #endregion Videos
@@ -393,10 +390,8 @@ namespace Vocaluxe.Base
List<string> files = CHelper.ListFiles(path, "*.xml", false); List<string> files = CHelper.ListFiles(path, "*.xml", false);
foreach (string file in files) foreach (string file in files)
{
AddTheme(Path.Combine(path, file), -1); AddTheme(Path.Combine(path, file), -1);
} }
}
public static bool AddTheme(string FilePath, int PartyModeID) public static bool AddTheme(string FilePath, int PartyModeID)
{ {
@@ -533,14 +528,10 @@ namespace Vocaluxe.Base
for (int i = 0; i < _Skins.Count; i++) for (int i = 0; i < _Skins.Count; i++)
{ {
if (PartyModeID != -1 && _Skins[i].PartyModeID == PartyModeID) if (PartyModeID != -1 && _Skins[i].PartyModeID == PartyModeID)
{
return i; return i;
}
else if (PartyModeID == -1 && _Skins[i].Name == CConfig.Skin) else if (PartyModeID == -1 && _Skins[i].Name == CConfig.Skin)
{
return i; return i;
} }
}
return -1; return -1;
} }
@@ -550,14 +541,10 @@ namespace Vocaluxe.Base
for (int i = 0; i < _Themes.Count; i++) for (int i = 0; i < _Themes.Count; i++)
{ {
if (PartyModeID != -1 && _Themes[i].PartyModeID == PartyModeID) if (PartyModeID != -1 && _Themes[i].PartyModeID == PartyModeID)
{
return i; return i;
}
else if (PartyModeID == -1 && _Themes[i].Name == CConfig.Theme) else if (PartyModeID == -1 && _Themes[i].Name == CConfig.Theme)
{
return i; return i;
} }
}
return -1; return -1;
} }
@@ -582,9 +569,7 @@ namespace Vocaluxe.Base
{ {
int SkinIndex = GetSkinIndex(PartyModeID); int SkinIndex = GetSkinIndex(PartyModeID);
if (SkinIndex != -1 && TextureName != null && _Skins[SkinIndex].SkinList.ContainsKey(TextureName)) if (SkinIndex != -1 && TextureName != null && _Skins[SkinIndex].SkinList.ContainsKey(TextureName))
{
return _Skins[SkinIndex].SkinList[TextureName].Texture; return _Skins[SkinIndex].SkinList[TextureName].Texture;
}
return new STexture(-1); return new STexture(-1);
} }
@@ -832,9 +817,7 @@ namespace Vocaluxe.Base
writer.WriteElementString("H", Cursor.h.ToString("#0.000")); writer.WriteElementString("H", Cursor.h.ToString("#0.000"));
if (Cursor.color.Length > 0) if (Cursor.color.Length > 0)
{
writer.WriteElementString("Color", Cursor.color); writer.WriteElementString("Color", Cursor.color);
}
else else
{ {
writer.WriteElementString("R", Cursor.r.ToString("#0.000")); writer.WriteElementString("R", Cursor.r.ToString("#0.000"));
+23 -38
View File
@@ -8,9 +8,9 @@ namespace Vocaluxe.Base
{ {
static class CTime static class CTime
{ {
private static Stopwatch _Stopwatch = new Stopwatch(); private static readonly Stopwatch _Stopwatch = new Stopwatch();
private static float _fps = 0.0f; private static float _fps;
private static double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency; private static readonly double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
public static void Reset() public static void Reset()
{ {
@@ -22,7 +22,6 @@ namespace Vocaluxe.Base
_Stopwatch.Start(); _Stopwatch.Start();
} }
public static void Restart() public static void Restart()
{ {
Reset(); Reset();
@@ -42,7 +41,7 @@ namespace Vocaluxe.Base
if (Stopwatch.IsHighResolution && ticks != 0) if (Stopwatch.IsHighResolution && ticks != 0)
return (float)((nanosecPerTick * ticks) / (1000.0 * 1000.0)); return (float)((nanosecPerTick * ticks) / (1000.0 * 1000.0));
else else
return (float)_Stopwatch.ElapsedMilliseconds; return _Stopwatch.ElapsedMilliseconds;
} }
else else
return 0f; return 0f;
@@ -53,14 +52,11 @@ namespace Vocaluxe.Base
float ms = GetMilliseconds(); float ms = GetMilliseconds();
if (ms > 0) if (ms > 0)
{
_fps = 1 / ms; _fps = 1 / ms;
}
return _fps * 1000f; return _fps * 1000f;
} }
public static double GetFPS() public static double GetFPS()
{ {
return _fps * 1000f; return _fps * 1000f;
@@ -69,10 +65,10 @@ namespace Vocaluxe.Base
class CKeys class CKeys
{ {
private List<KeyEvent> _KeysPool; private readonly List<KeyEvent> _KeysPool;
private List<KeyEvent> _ActualPool; private readonly List<KeyEvent> _ActualPool;
private Object _CopyLock = new Object(); private readonly Object _CopyLock = new Object();
private bool _ModALT; private bool _ModALT;
private bool _ModCTRL; private bool _ModCTRL;
@@ -80,8 +76,7 @@ namespace Vocaluxe.Base
private bool _KeyPressed; private bool _KeyPressed;
private Keys _Keys; private Keys _Keys;
private Char _char; private Char _char;
private System.Diagnostics.Stopwatch _timer; private readonly Stopwatch _timer;
public CKeys() public CKeys()
{ {
@@ -94,7 +89,7 @@ namespace Vocaluxe.Base
_KeysPool = new List<KeyEvent>(); _KeysPool = new List<KeyEvent>();
_ActualPool = new List<KeyEvent>(); _ActualPool = new List<KeyEvent>();
_timer = new System.Diagnostics.Stopwatch(); _timer = new Stopwatch();
} }
private void Add(bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key) private void Add(bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key)
@@ -115,10 +110,7 @@ namespace Vocaluxe.Base
{ {
_KeysPool.Add(pool); _KeysPool.Add(pool);
} }
catch (Exception) catch (Exception) {}
{
}
} }
_timer.Reset(); _timer.Reset();
@@ -140,7 +132,6 @@ namespace Vocaluxe.Base
_ModCTRL = ((keys & Keys.Control) == Keys.Control); _ModCTRL = ((keys & Keys.Control) == Keys.Control);
} }
public void KeyDown(KeyEventArgs e) public void KeyDown(KeyEventArgs e)
{ {
CheckModifiers(); CheckModifiers();
@@ -182,7 +173,8 @@ namespace Vocaluxe.Base
Del(0); Del(0);
return true; return true;
} }
else return false; else
return false;
} }
public void CopyEvents() public void CopyEvents()
@@ -190,30 +182,27 @@ namespace Vocaluxe.Base
lock (_CopyLock) lock (_CopyLock)
{ {
foreach (KeyEvent e in _KeysPool) foreach (KeyEvent e in _KeysPool)
{
_ActualPool.Add(e); _ActualPool.Add(e);
}
_KeysPool.Clear(); _KeysPool.Clear();
} }
} }
} }
class CMouse class CMouse
{ {
private List<MouseEvent> _EventsPool; private readonly List<MouseEvent> _EventsPool;
private List<MouseEvent> _CurrentPool; private readonly List<MouseEvent> _CurrentPool;
private int _x = 0; private int _x;
private int _y = 0; private int _y;
private Object _CopyLock = new Object(); private readonly Object _CopyLock = new Object();
private bool _ModALT; private bool _ModALT;
private bool _ModCTRL; private bool _ModCTRL;
private bool _ModSHIFT; private bool _ModSHIFT;
private System.Diagnostics.Stopwatch _timer; private readonly Stopwatch _timer;
public int X public int X
{ {
@@ -236,13 +225,13 @@ namespace Vocaluxe.Base
_EventsPool = new List<MouseEvent>(); _EventsPool = new List<MouseEvent>();
_CurrentPool = new List<MouseEvent>(); _CurrentPool = new List<MouseEvent>();
_timer = new System.Diagnostics.Stopwatch(); _timer = new Stopwatch();
} }
private void Add(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh) private void Add(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
{ {
x = (int)((float)x * (float)CSettings.iRenderW / (float)CDraw.GetScreenWidth()); x = (int)(x * (float)CSettings.iRenderW / CDraw.GetScreenWidth());
y = (int)((float)y * (float)CSettings.iRenderH / (float)CDraw.GetScreenHeight()); y = (int)(y * (float)CSettings.iRenderH / CDraw.GetScreenHeight());
MouseEvent pool = new MouseEvent(ESender.Mouse, alt, shift, ctrl, x, y, lb, ld, rb, -wheel / 120, lbh, rbh, mb, mbh); MouseEvent pool = new MouseEvent(ESender.Mouse, alt, shift, ctrl, x, y, lb, ld, rb, -wheel / 120, lbh, rbh, mb, mbh);
@@ -302,9 +291,7 @@ namespace Vocaluxe.Base
} }
} }
else else
{
_timer.Reset(); _timer.Reset();
}
Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, lb, ld, e.Button == MouseButtons.Right, e.Delta, false, false, Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, lb, ld, e.Button == MouseButtons.Right, e.Delta, false, false,
e.Button == MouseButtons.Middle, false); e.Button == MouseButtons.Middle, false);
@@ -324,7 +311,8 @@ namespace Vocaluxe.Base
Del(0); Del(0);
return true; return true;
} }
else return false; else
return false;
} }
public void CopyEvents() public void CopyEvents()
@@ -332,12 +320,9 @@ namespace Vocaluxe.Base
lock (_CopyLock) lock (_CopyLock)
{ {
foreach (MouseEvent e in _EventsPool) foreach (MouseEvent e in _EventsPool)
{
_CurrentPool.Add(e); _CurrentPool.Add(e);
}
_EventsPool.Clear(); _EventsPool.Clear();
} }
} }
} }
} }
+1 -3
View File
@@ -95,7 +95,6 @@ namespace Vocaluxe.Base
{ {
_VideoDecoder.Update(); _VideoDecoder.Update();
} }
#endregion Interface #endregion Interface
#endregion VideoDecoder #endregion VideoDecoder
@@ -105,7 +104,7 @@ namespace Vocaluxe.Base
{ {
private STexture _VideoTexture; private STexture _VideoTexture;
private int _VideoStream; private int _VideoStream;
private Stopwatch _VideoTimer; private readonly Stopwatch _VideoTimer;
private bool _Finished; private bool _Finished;
private bool _Loaded; private bool _Loaded;
@@ -155,7 +154,6 @@ namespace Vocaluxe.Base
{ {
if (!_Finished) if (!_Finished)
{ {
float VideoTime = _VideoTimer.ElapsedMilliseconds / 1000f; float VideoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
_Finished = CVideo.VdFinished(_VideoStream); _Finished = CVideo.VdFinished(_VideoStream);
-1
View File
@@ -1,5 +1,4 @@
using System.Drawing; using System.Drawing;
using Vocaluxe.Lib.Webcam; using Vocaluxe.Lib.Webcam;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
+1 -6
View File
@@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -35,9 +34,7 @@ namespace Vocaluxe.GameModes
public virtual EGameMode GetCurrentGameMode() public virtual EGameMode GetCurrentGameMode()
{ {
if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count)
{
return _SongQueque[_CurrentSong].GameMode; return _SongQueque[_CurrentSong].GameMode;
}
return EGameMode.TR_GAMEMODE_NORMAL; return EGameMode.TR_GAMEMODE_NORMAL;
} }
@@ -220,8 +217,6 @@ namespace Vocaluxe.GameModes
} }
#endregion Implementation #endregion Implementation
protected virtual void SongManipulation(int SongIndex) protected virtual void SongManipulation(int SongIndex) {}
{
}
} }
} }
+1 -2
View File
@@ -1,5 +1,4 @@
namespace Vocaluxe.GameModes
namespace Vocaluxe.GameModes
{ {
// Nomal singing // Nomal singing
class CGameModeNormal : CGameMode class CGameModeNormal : CGameMode
+50 -20
View File
@@ -8,23 +8,53 @@
// "Meldung(en) unterdrücken", und klicken Sie auf "In Projektunterdrückungsdatei". // "Meldung(en) unterdrücken", und klicken Sie auf "In Projektunterdrückungsdatei".
// Sie müssen dieser Datei nicht manuell Unterdrückungen hinzufügen. // Sie müssen dieser Datei nicht manuell Unterdrückungen hinzufügen.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom", Scope = "member", Target = "Vocaluxe.MainProgram.#AssemblyResolver(System.Object,System.ResolveEventArgs)")] using System.Diagnostics.CodeAnalysis;
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member", Target = "Vocaluxe.Lib.Draw.CDrawWinForm.#ColorizeBitmap(System.Drawing.Bitmap,Vocaluxe.Menu.SColorF)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member", Target = "Vocaluxe.Lib.Draw.CDrawWinForm.#CopyScreen(Vocaluxe.Menu.STexture&)")] [assembly:
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member", Target = "Vocaluxe.Base.CGlyph.#.ctor(System.Char,System.Single)")] SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom", Scope = "member",
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member", Target = "Vocaluxe.Lib.Draw.CDirect3D.#AddTexture(System.Drawing.Bitmap,System.String)")] Target = "Vocaluxe.MainProgram.#AssemblyResolver(System.Object,System.ResolveEventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member", Target = "Vocaluxe.Lib.Draw.CDirect3D.#AddTexture(System.Int32,System.Int32,System.Byte[]&)")] [assembly:
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member", Target = "Vocaluxe.Lib.Draw.CDirect3D.#CopyScreen()")] SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member",
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Scope = "type", Target = "Vocaluxe.Lib.Input.WiiMote.InputReport")] Target = "Vocaluxe.Lib.Draw.CDrawWinForm.#ColorizeBitmap(System.Drawing.Bitmap,Vocaluxe.Menu.SColorF)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Scope = "type", Target = "PortAudioSharp.PortAudio+PaDeviceIndex")] [assembly:
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Scope = "type", Target = "PortAudioSharp.PortAudio+PaSampleFormat")] SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member",
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Scope = "type", Target = "PortAudioSharp.PortAudio+PaStreamCallbackFlags")] Target = "Vocaluxe.Lib.Draw.CDrawWinForm.#CopyScreen(Vocaluxe.Menu.STexture&)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Vocaluxe.Lib.Video.Gstreamer.CGstreamerVideoWrapper.#GetFrame(System.Int32,System.Single)")] [assembly:
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Vocaluxe.Lib.Input.CHIDAPI.#ReadTimeout(System.IntPtr,System.Byte[]&,System.Int32,System.Int32)")] SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member",
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Vocaluxe.Lib.Input.CHIDAPI.#Read(System.IntPtr,System.Byte[]&,System.Int32)")] Target = "Vocaluxe.Base.CGlyph.#.ctor(System.Char,System.Single)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "PortAudioSharp.PortAudio.#Pa_GetVersionText()")] [assembly:
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "PortAudioSharp.PortAudio.#Pa_GetErrorText(PortAudioSharp.PortAudio+PaError)")] SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member",
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "PortAudioSharp.PortAudio.#Pa_GetHostApiInfo(System.Int32)")] Target = "Vocaluxe.Lib.Draw.CDirect3D.#AddTexture(System.Drawing.Bitmap,System.String)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "PortAudioSharp.PortAudio.#Pa_GetLastHostErrorInfo()")] [assembly:
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "PortAudioSharp.PortAudio.#Pa_GetDeviceInfo(System.Int32)")] SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member",
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "PortAudioSharp.PortAudio.#Pa_GetStreamInfo(System.IntPtr)")] Target = "Vocaluxe.Lib.Draw.CDirect3D.#AddTexture(System.Int32,System.Int32,System.Byte[]&)")]
[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Objekte verwerfen, bevor Bereich verloren geht", Scope = "member", Target = "Vocaluxe.Lib.Draw.CDirect3D.#CopyScreen()")
]
[assembly: SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Scope = "type", Target = "Vocaluxe.Lib.Input.WiiMote.InputReport")]
[assembly: SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Scope = "type", Target = "PortAudioSharp.PortAudio+PaDeviceIndex")]
[assembly: SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Scope = "type", Target = "PortAudioSharp.PortAudio+PaSampleFormat")]
[assembly: SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Scope = "type", Target = "PortAudioSharp.PortAudio+PaStreamCallbackFlags")]
[assembly:
SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member",
Target = "Vocaluxe.Lib.Video.Gstreamer.CGstreamerVideoWrapper.#GetFrame(System.Int32,System.Single)")]
[assembly:
SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member",
Target = "Vocaluxe.Lib.Input.CHIDAPI.#ReadTimeout(System.IntPtr,System.Byte[]&,System.Int32,System.Int32)")]
[assembly:
SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member",
Target = "Vocaluxe.Lib.Input.CHIDAPI.#Read(System.IntPtr,System.Byte[]&,System.Int32)")]
[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "PortAudioSharp.PortAudio.#Pa_GetVersionText()")]
[assembly:
SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member",
Target = "PortAudioSharp.PortAudio.#Pa_GetErrorText(PortAudioSharp.PortAudio+PaError)")]
[assembly:
SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member",
Target = "PortAudioSharp.PortAudio.#Pa_GetHostApiInfo(System.Int32)")]
[assembly:
SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "PortAudioSharp.PortAudio.#Pa_GetLastHostErrorInfo()")]
[assembly:
SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member",
Target = "PortAudioSharp.PortAudio.#Pa_GetDeviceInfo(System.Int32)")]
[assembly:
SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member",
Target = "PortAudioSharp.PortAudio.#Pa_GetStreamInfo(System.IntPtr)")]
+100 -107
View File
@@ -1,4 +1,6 @@
using SlimDX; using System.Drawing.Drawing2D;
using System.Threading;
using SlimDX;
using SlimDX.Direct3D9; using SlimDX.Direct3D9;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -16,42 +18,40 @@ namespace Vocaluxe.Lib.Draw
class CDirect3D : Form, IDraw class CDirect3D : Form, IDraw
{ {
#region private vars #region private vars
private readonly CKeys _Keys;
private CKeys _Keys; private readonly CMouse _Mouse;
private CMouse _Mouse;
private bool _Run; private bool _Run;
private Direct3D _D3D; private readonly Direct3D _D3D;
private Device _Device = null; private readonly Device _Device;
private PresentParameters _PresentParameters; private readonly PresentParameters _PresentParameters;
private bool _fullscreen = false; private bool _fullscreen;
private Size _OldSize; private Size _OldSize;
private Size _SizeBeforeMinimize; private Size _SizeBeforeMinimize;
private Dictionary<int, STexture> _Textures; private readonly Dictionary<int, STexture> _Textures;
private Dictionary<int, Texture> _D3DTextures; private readonly Dictionary<int, Texture> _D3DTextures;
private List<STextureQueque> _Queque; private readonly List<STextureQueque> _Queque;
private Queue<int> _IDs; private readonly Queue<int> _IDs;
private Object MutexTexture = new Object(); private readonly Object MutexTexture = new Object();
private VertexBuffer _VertexBuffer; private VertexBuffer _VertexBuffer;
private IndexBuffer _IndexBuffer; private IndexBuffer _IndexBuffer;
private int h = 1; private int h = 1;
private int w = 1; private int w = 1;
private int y = 0; private int y;
private int x = 0; private int x;
private STexture _BlankTexture; private STexture _BlankTexture;
private Queue<TexturedColoredVertex> _Vertices; private readonly Queue<TexturedColoredVertex> _Vertices;
private Queue<Texture> _VerticesTextures; private readonly Queue<Texture> _VerticesTextures;
private Queue<Matrix> _VerticesRotationMatrices; private readonly Queue<SlimDX.Matrix> _VerticesRotationMatrices;
private bool _NonPowerOf2TextureSupported;
private readonly bool _NonPowerOf2TextureSupported;
#endregion private vars #endregion private vars
/// <summary> /// <summary>
@@ -59,7 +59,7 @@ namespace Vocaluxe.Lib.Draw
/// </summary> /// </summary>
public CDirect3D() public CDirect3D()
{ {
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon)); Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.sIcon));
_Textures = new Dictionary<int, STexture>(); _Textures = new Dictionary<int, STexture>();
_D3DTextures = new Dictionary<int, Texture>(); _D3DTextures = new Dictionary<int, Texture>();
_Queque = new List<STextureQueque>(); _Queque = new List<STextureQueque>();
@@ -71,7 +71,7 @@ namespace Vocaluxe.Lib.Draw
_Vertices = new Queue<TexturedColoredVertex>(); _Vertices = new Queue<TexturedColoredVertex>();
_VerticesTextures = new Queue<Texture>(); _VerticesTextures = new Queue<Texture>();
_VerticesRotationMatrices = new Queue<Matrix>(); _VerticesRotationMatrices = new Queue<SlimDX.Matrix>();
_Keys = new CKeys(); _Keys = new CKeys();
try try
@@ -87,24 +87,24 @@ namespace Vocaluxe.Lib.Draw
Environment.Exit(Environment.ExitCode); Environment.Exit(Environment.ExitCode);
} }
this.Paint += new PaintEventHandler(this.OnPaintEvent); Paint += OnPaintEvent;
this.Closing += new CancelEventHandler(this.OnClosingEvent); Closing += OnClosingEvent;
this.Resize += new EventHandler(this.OnResizeEvent); Resize += OnResizeEvent;
this.KeyDown += new KeyEventHandler(this.OnKeyDown); KeyDown += OnKeyDown;
this.PreviewKeyDown += new PreviewKeyDownEventHandler(this.OnPreviewKeyDown); PreviewKeyDown += OnPreviewKeyDown;
this.KeyPress += new KeyPressEventHandler(this.OnKeyPress); KeyPress += OnKeyPress;
this.KeyUp += new KeyEventHandler(this.OnKeyUp); KeyUp += OnKeyUp;
_Mouse = new CMouse(); _Mouse = new CMouse();
this.MouseMove += new MouseEventHandler(this.OnMouseMove); MouseMove += OnMouseMove;
this.MouseWheel += new MouseEventHandler(this.OnMouseWheel); MouseWheel += OnMouseWheel;
this.MouseDown += new MouseEventHandler(this.OnMouseDown); MouseDown += OnMouseDown;
this.MouseUp += new MouseEventHandler(this.OnMouseUp); MouseUp += OnMouseUp;
this.MouseLeave += new EventHandler(this.OnMouseLeave); MouseLeave += OnMouseLeave;
this.MouseEnter += new EventHandler(this.OnMouseEnter); MouseEnter += OnMouseEnter;
this.ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH); ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH);
_SizeBeforeMinimize = ClientSize; _SizeBeforeMinimize = ClientSize;
_PresentParameters = new PresentParameters(); _PresentParameters = new PresentParameters();
@@ -117,6 +117,7 @@ namespace Vocaluxe.Lib.Draw
_PresentParameters.MultisampleQuality = 0; _PresentParameters.MultisampleQuality = 0;
//Apply antialiasing and check if antialiasing mode is supported //Apply antialiasing and check if antialiasing mode is supported
#region Antialiasing #region Antialiasing
int quality = 1; int quality = 1;
MultisampleType msType; MultisampleType msType;
@@ -140,7 +141,9 @@ namespace Vocaluxe.Lib.Draw
break; break;
} }
if (!_D3D.CheckDeviceMultisampleType(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware, _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format, false, msType, out quality)) if (
!_D3D.CheckDeviceMultisampleType(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware, _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format, false, msType,
out quality))
{ {
CLog.LogError("[Direct3D] This AAMode is not supported by this device or driver, fallback to no AA"); CLog.LogError("[Direct3D] This AAMode is not supported by this device or driver, fallback to no AA");
msType = MultisampleType.None; msType = MultisampleType.None;
@@ -182,24 +185,19 @@ namespace Vocaluxe.Lib.Draw
MessageBox.Show("Something went wrong during device creating, please check if your DirectX redistributables " + MessageBox.Show("Something went wrong during device creating, please check if your DirectX redistributables " +
"and graphic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109", "and graphic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109",
CSettings.sProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error); CSettings.sProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error);
CLog.LogError("Something went wrong during device creating, please check if your DirectX redistributables and grafic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109"); CLog.LogError(
"Something went wrong during device creating, please check if your DirectX redistributables and grafic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109");
Environment.Exit(Environment.ExitCode); Environment.Exit(Environment.ExitCode);
} }
} }
this.CenterToScreen(); CenterToScreen();
} }
#region form events #region form events
private void OnPaintEvent(object sender, PaintEventArgs e) private void OnPaintEvent(object sender, PaintEventArgs e) {}
{
} private void OnResizeEvent(object sender, EventArgs e) {}
private void OnResizeEvent(object sender, EventArgs e)
{
}
private void OnClosingEvent(object sender, CancelEventArgs e) private void OnClosingEvent(object sender, CancelEventArgs e)
{ {
@@ -247,9 +245,7 @@ namespace Vocaluxe.Lib.Draw
{ {
// The window was minimized, so restore it to the last known size // The window was minimized, so restore it to the last known size
if (ClientSize.Width == 0 || ClientSize.Height == 0) if (ClientSize.Width == 0 || ClientSize.Height == 0)
{
ClientSize = _SizeBeforeMinimize; ClientSize = _SizeBeforeMinimize;
}
if (_Run) if (_Run)
{ {
h = ClientSize.Height; h = ClientSize.Height;
@@ -257,16 +253,16 @@ namespace Vocaluxe.Lib.Draw
y = 0; y = 0;
x = 0; x = 0;
if ((float)w / (float)h > CSettings.GetRenderAspect()) if (w / (float)h > CSettings.GetRenderAspect())
{ {
//The windows's width is too big //The windows's width is too big
w = (int)Math.Round((float)h * CSettings.GetRenderAspect()); w = (int)Math.Round(h * CSettings.GetRenderAspect());
x = (ClientSize.Width - w) / 2; x = (ClientSize.Width - w) / 2;
} }
else else
{ {
//The windows's height is too big //The windows's height is too big
h = (int)Math.Round((float)w / CSettings.GetRenderAspect()); h = (int)Math.Round(w / CSettings.GetRenderAspect());
y = (ClientSize.Height - h) / 2; y = (ClientSize.Height - h) / 2;
} }
@@ -294,40 +290,41 @@ namespace Vocaluxe.Lib.Draw
//This currently not using real fullscreen mode but a borderless window //This currently not using real fullscreen mode but a borderless window
//Real fullscreen could be gained setting _PresentParameters.Windowed = true //Real fullscreen could be gained setting _PresentParameters.Windowed = true
//And calling Reset() and Init() after //And calling Reset() and Init() after
_OldSize = this.ClientSize; _OldSize = ClientSize;
int ScreenNr = 0; int ScreenNr = 0;
for (int i = 0; i < Screen.AllScreens.Length; i++) for (int i = 0; i < Screen.AllScreens.Length; i++)
{ {
Screen scr = Screen.AllScreens[i]; Screen scr = Screen.AllScreens[i];
if (scr.Bounds.Top <= this.Top && scr.Bounds.Left <= this.Left) if (scr.Bounds.Top <= Top && scr.Bounds.Left <= Left)
ScreenNr = i; ScreenNr = i;
} }
this.ClientSize = new Size(Screen.AllScreens[ScreenNr].Bounds.Width, Screen.AllScreens[ScreenNr].Bounds.Height); ClientSize = new Size(Screen.AllScreens[ScreenNr].Bounds.Width, Screen.AllScreens[ScreenNr].Bounds.Height);
this.FormBorderStyle = FormBorderStyle.None; FormBorderStyle = FormBorderStyle.None;
CenterToScreen(); CenterToScreen();
_fullscreen = true; _fullscreen = true;
CConfig.FullScreen = EOffOn.TR_CONFIG_ON; CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
if (this.WindowState == FormWindowState.Maximized) if (WindowState == FormWindowState.Maximized)
{ {
this.WindowState = FormWindowState.Normal; WindowState = FormWindowState.Normal;
RResize(); RResize();
this.WindowState = FormWindowState.Maximized; WindowState = FormWindowState.Maximized;
} }
else else
RResize(); RResize();
CConfig.SaveConfig(); CConfig.SaveConfig();
} }
/// <summary> /// <summary>
/// Triggers the windowed mode /// Triggers the windowed mode
/// </summary> /// </summary>
private void LeaveFullScreen() private void LeaveFullScreen()
{ {
this.ClientSize = _OldSize; ClientSize = _OldSize;
this.FormBorderStyle = FormBorderStyle.Sizable; FormBorderStyle = FormBorderStyle.Sizable;
CenterToScreen(); CenterToScreen();
_fullscreen = false; _fullscreen = false;
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF; CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
@@ -371,30 +368,29 @@ namespace Vocaluxe.Lib.Draw
#endregion #endregion
#region keyboard event handlers #region keyboard event handlers
private void OnPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
private void OnPreviewKeyDown(object sender, System.Windows.Forms.PreviewKeyDownEventArgs e)
{ {
OnKeyDown(sender, new KeyEventArgs(e.KeyData)); OnKeyDown(sender, new KeyEventArgs(e.KeyData));
} }
private void OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e) private void OnKeyDown(object sender, KeyEventArgs e)
{ {
_Keys.KeyDown(e); _Keys.KeyDown(e);
} }
private void OnKeyPress(object sender, KeyPressEventArgs e)
private void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{ {
_Keys.KeyPress(e); _Keys.KeyPress(e);
} }
private void OnKeyUp(object sender, System.Windows.Forms.KeyEventArgs e) private void OnKeyUp(object sender, KeyEventArgs e)
{ {
_Keys.KeyUp(e); _Keys.KeyUp(e);
} }
#endregion keyboard event handlers #endregion keyboard event handlers
#region implementation #region implementation
#region main stuff #region main stuff
/// <summary> /// <summary>
/// Inits the Device /// Inits the Device
@@ -404,10 +400,12 @@ namespace Vocaluxe.Lib.Draw
{ {
if (!_Device.Disposed) if (!_Device.Disposed)
{ {
this.Text = CSettings.GetFullVersionText(); Text = CSettings.GetFullVersionText();
Matrix translate = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0)); SlimDX.Matrix translate = SlimDX.Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
Matrix projection = Matrix.OrthoOffCenterLH(-CSettings.iRenderW / 2, CSettings.iRenderW / 2, -CSettings.iRenderH / 2, CSettings.iRenderH / 2, CSettings.zNear, CSettings.zFar); SlimDX.Matrix projection = SlimDX.Matrix.OrthoOffCenterLH(-CSettings.iRenderW / 2, CSettings.iRenderW / 2, -CSettings.iRenderH / 2, CSettings.iRenderH / 2,
_VertexBuffer = new VertexBuffer(_Device, CSettings.iVertexBufferElements * (4 * Marshal.SizeOf(typeof(TexturedColoredVertex))), Usage.WriteOnly | Usage.Dynamic, VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default); CSettings.zNear, CSettings.zFar);
_VertexBuffer = new VertexBuffer(_Device, CSettings.iVertexBufferElements * (4 * Marshal.SizeOf(typeof(TexturedColoredVertex))), Usage.WriteOnly | Usage.Dynamic,
VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default);
if (_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(TexturedColoredVertex))).IsFailure) if (_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(TexturedColoredVertex))).IsFailure)
CLog.LogError("Failed to set stream source"); CLog.LogError("Failed to set stream source");
@@ -422,9 +420,9 @@ namespace Vocaluxe.Lib.Draw
CLog.LogError("Failed to enable alpha blending"); CLog.LogError("Failed to enable alpha blending");
if (_Device.SetRenderState(RenderState.Lighting, false).IsFailure) if (_Device.SetRenderState(RenderState.Lighting, false).IsFailure)
CLog.LogError("Failed to disable lighting"); CLog.LogError("Failed to disable lighting");
if(_Device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha).IsFailure) if (_Device.SetRenderState(RenderState.DestinationBlend, SlimDX.Direct3D9.Blend.InverseSourceAlpha).IsFailure)
CLog.LogError("Failed to set destination blend"); CLog.LogError("Failed to set destination blend");
if(_Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha).IsFailure) if (_Device.SetRenderState(RenderState.SourceBlend, SlimDX.Direct3D9.Blend.SourceAlpha).IsFailure)
CLog.LogError("Failed to set source blend"); CLog.LogError("Failed to set source blend");
if (_PresentParameters.Multisample != MultisampleType.None) if (_PresentParameters.Multisample != MultisampleType.None)
{ {
@@ -471,13 +469,13 @@ namespace Vocaluxe.Lib.Draw
g.Clear(Color.White); g.Clear(Color.White);
g.Dispose(); g.Dispose();
_BlankTexture = AddTexture(blankMap); _BlankTexture = AddTexture(blankMap);
} }
return true; return true;
} }
else else
return false; return false;
} }
/// <summary> /// <summary>
/// Starts the rendering /// Starts the rendering
/// </summary> /// </summary>
@@ -485,7 +483,7 @@ namespace Vocaluxe.Lib.Draw
{ {
_Run = true; _Run = true;
int delay = 0; int delay = 0;
this.Show(); Show();
if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON)
{ {
@@ -494,7 +492,7 @@ namespace Vocaluxe.Lib.Draw
} }
//Resize window if aspect ratio is incorrect //Resize window if aspect ratio is incorrect
if ((float)w / (float)h != CSettings.GetRenderAspect()) if (w / (float)h != CSettings.GetRenderAspect())
RResize(); RResize();
while (_Run) while (_Run)
@@ -544,13 +542,13 @@ namespace Vocaluxe.Lib.Draw
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds()); delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF) if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF)
System.Threading.Thread.Sleep(delay); Thread.Sleep(delay);
//Calculate the FPS Rate and restart the timer after a frame //Calculate the FPS Rate and restart the timer after a frame
CTime.CalculateFPS(); CTime.CalculateFPS();
CTime.Restart(); CTime.Restart();
} }
} }
this.Close(); Close();
} }
/// <summary> /// <summary>
@@ -576,10 +574,8 @@ namespace Vocaluxe.Lib.Draw
foreach (KeyValuePair<int, Texture> p in _D3DTextures) foreach (KeyValuePair<int, Texture> p in _D3DTextures)
{ {
if (p.Value != null) if (p.Value != null)
{
p.Value.Dispose(); p.Value.Dispose();
} }
}
TexturedColoredVertex.GetDeclaration(_Device).Dispose(); TexturedColoredVertex.GetDeclaration(_Device).Dispose();
_VertexBuffer.Dispose(); _VertexBuffer.Dispose();
@@ -637,7 +633,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="vertices">A TexturedColoredVertex array containg 4 vertices</param> /// <param name="vertices">A TexturedColoredVertex array containg 4 vertices</param>
/// <param name="tex">The texture the vertex should be textured with</param> /// <param name="tex">The texture the vertex should be textured with</param>
/// <param name="rotation">The vertices' rotation</param> /// <param name="rotation">The vertices' rotation</param>
private void AddToVertexBuffer(TexturedColoredVertex[] vertices, Texture tex, Matrix rotation) private void AddToVertexBuffer(TexturedColoredVertex[] vertices, Texture tex, SlimDX.Matrix rotation)
{ {
//The vertexbuffer is full, so we need to flush it before we can continue //The vertexbuffer is full, so we need to flush it before we can continue
if (_Vertices.Count >= CSettings.iVertexBufferElements) if (_Vertices.Count >= CSettings.iVertexBufferElements)
@@ -659,7 +655,7 @@ namespace Vocaluxe.Lib.Draw
{ {
//The vertex buffer locks are slow actions, its better to lock once per frame and write all vertices to the buffer at once //The vertex buffer locks are slow actions, its better to lock once per frame and write all vertices to the buffer at once
DataStream stream = _VertexBuffer.Lock(0, _Vertices.Count * Marshal.SizeOf(typeof(TexturedColoredVertex)), LockFlags.Discard); DataStream stream = _VertexBuffer.Lock(0, _Vertices.Count * Marshal.SizeOf(typeof(TexturedColoredVertex)), LockFlags.Discard);
stream.WriteRange<TexturedColoredVertex>(_Vertices.ToArray()); stream.WriteRange(_Vertices.ToArray());
_VertexBuffer.Unlock(); _VertexBuffer.Unlock();
stream.Dispose(); stream.Dispose();
@@ -684,7 +680,6 @@ namespace Vocaluxe.Lib.Draw
#endregion main stuff #endregion main stuff
#region Basic Draw Methods #region Basic Draw Methods
/// <summary> /// <summary>
/// Removes all textures from the screen /// Removes all textures from the screen
/// </summary> /// </summary>
@@ -829,11 +824,11 @@ namespace Vocaluxe.Lib.Draw
{ {
DrawTextureReflection(_BlankTexture, rect, color, rect, space, height); DrawTextureReflection(_BlankTexture, rect, color, rect, space, height);
} }
#endregion Basic Draw Methods #endregion Basic Draw Methods
#region Textures
#region adding
#region Textures
#region adding
/// <summary> /// <summary>
/// Adds a texture and stores it in the VRam /// Adds a texture and stores it in the VRam
/// </summary> /// </summary>
@@ -841,7 +836,7 @@ namespace Vocaluxe.Lib.Draw
/// <returns>A STexture object containing the added texture</returns> /// <returns>A STexture object containing the added texture</returns>
public STexture AddTexture(string TexturePath) public STexture AddTexture(string TexturePath)
{ {
if (System.IO.File.Exists(TexturePath)) if (File.Exists(TexturePath))
{ {
Bitmap bmp; Bitmap bmp;
try try
@@ -925,22 +920,21 @@ namespace Vocaluxe.Lib.Draw
byte[] Data; byte[] Data;
try try
{ {
if (w != bmp.Width || h != bmp.Height) if (w != bmp.Width || h != bmp.Height)
{ {
//Create a new Bitmap with the new sizes //Create a new Bitmap with the new sizes
bmp2 = new Bitmap(w, h); bmp2 = new Bitmap(w, h);
//Scale the texture //Scale the texture
Graphics g = Graphics.FromImage(bmp2); Graphics g = Graphics.FromImage(bmp2);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.SmoothingMode = SmoothingMode.HighQuality;
g.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height)); g.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height));
g.Dispose(); g.Dispose();
bmp = bmp2; bmp = bmp2;
} }
//Fill the new Bitmap with the texture data //Fill the new Bitmap with the texture data
BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
Data = new byte[4 * w * h]; Data = new byte[4 * w * h];
Marshal.Copy(bmp_data.Scan0, Data, 0, Data.Length); Marshal.Copy(bmp_data.Scan0, Data, 0, Data.Length);
bmp.UnlockBits(bmp_data); bmp.UnlockBits(bmp_data);
@@ -1045,7 +1039,6 @@ namespace Vocaluxe.Lib.Draw
} }
return texture; return texture;
} }
#endregion adding #endregion adding
#region updating #region updating
@@ -1306,7 +1299,6 @@ namespace Vocaluxe.Lib.Draw
/// <param name="color">A SColorF struct containing a color which the texture will be colored in</param> /// <param name="color">A SColorF struct containing a color which the texture will be colored in</param>
/// <param name="begin">A Value ranging from 0 to 1 containing the beginning of the texture</param> /// <param name="begin">A Value ranging from 0 to 1 containing the beginning of the texture</param>
/// <param name="end">A Value ranging from 0 to 1 containing the ending of the texture</param> /// <param name="end">A Value ranging from 0 to 1 containing the ending of the texture</param>
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end) public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end)
{ {
if (_TextureExists(ref Texture)) if (_TextureExists(ref Texture))
@@ -1457,6 +1449,7 @@ namespace Vocaluxe.Lib.Draw
return _Textures.Count; return _Textures.Count;
} }
#endregion Textures #endregion Textures
#endregion implementation #endregion implementation
#region utility #region utility
@@ -1469,30 +1462,32 @@ namespace Vocaluxe.Lib.Draw
{ {
if (!_NonPowerOf2TextureSupported) if (!_NonPowerOf2TextureSupported)
{ {
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive."); if (n < 0)
return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2))); throw new ArgumentOutOfRangeException("n", "Must be positive.");
return (float)Math.Pow(2, Math.Ceiling(Math.Log(n, 2)));
} }
else return n; else
return n;
} }
private Matrix CalculateRotationMatrix(float rot, float rx1, float rx2, float ry1, float ry2) private SlimDX.Matrix CalculateRotationMatrix(float rot, float rx1, float rx2, float ry1, float ry2)
{ {
Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0)); SlimDX.Matrix originTranslation = SlimDX.Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
if (rot != 0) if (rot != 0)
{ {
float rotation = rot * (float)Math.PI / 180; float rotation = rot * (float)Math.PI / 180;
float centerX = (rx1 + rx2) / 2f; float centerX = (rx1 + rx2) / 2f;
float centerY = -(ry1 + ry2) / 2f; float centerY = -(ry1 + ry2) / 2f;
Matrix translationA = Matrix.Translation(-centerX, -centerY, 0); SlimDX.Matrix translationA = SlimDX.Matrix.Translation(-centerX, -centerY, 0);
Matrix rotationMat = Matrix.RotationZ(-rotation); SlimDX.Matrix rotationMat = SlimDX.Matrix.RotationZ(-rotation);
Matrix translationB = Matrix.Translation(centerX, centerY, 0); SlimDX.Matrix translationB = SlimDX.Matrix.Translation(centerX, centerY, 0);
//Multiplicate the matrices to get the real world matrix, //Multiplicate the matrices to get the real world matrix,
//First shift the texture into the center //First shift the texture into the center
//Rotate it and shift it back to the origin position //Rotate it and shift it back to the origin position
//Apply the originTranslation after //Apply the originTranslation after
Matrix result = translationA * rotationMat * translationB * originTranslation; SlimDX.Matrix result = translationA * rotationMat * translationB * originTranslation;
return result; return result;
} }
return originTranslation; return originTranslation;
@@ -1517,17 +1512,15 @@ namespace Vocaluxe.Lib.Draw
public TexturedColoredVertex(Vector3 position, Vector2 texture, int color) public TexturedColoredVertex(Vector3 position, Vector2 texture, int color)
{ {
this.Position = position; Position = position;
this.Texture = texture; Texture = texture;
this.Color = color; Color = color;
} }
public static VertexDeclaration GetDeclaration(Device device) public static VertexDeclaration GetDeclaration(Device device)
{ {
if (sDeclaration == null || sDeclaration.Disposed) if (sDeclaration == null || sDeclaration.Disposed)
{
sDeclaration = new VertexDeclaration(device, Elements); sDeclaration = new VertexDeclaration(device, Elements);
}
return sDeclaration; return sDeclaration;
} }
+48 -79
View File
@@ -5,6 +5,7 @@ using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -14,50 +15,50 @@ namespace Vocaluxe.Lib.Draw
class CDrawWinForm : Form, IDraw class CDrawWinForm : Form, IDraw
{ {
private bool _Run; private bool _Run;
private Bitmap _backbuffer; private readonly Bitmap _backbuffer;
private Graphics _g; private readonly Graphics _g;
private bool _fullscreen = false; private bool _fullscreen;
private CKeys _Keys; private readonly CKeys _Keys;
private CMouse _Mouse; private readonly CMouse _Mouse;
private FormBorderStyle _brdStyle; private FormBorderStyle _brdStyle;
private bool _topMost; private bool _topMost;
private Rectangle _bounds; private Rectangle _bounds;
private List<STexture> _Textures; private readonly List<STexture> _Textures;
private List<Bitmap> _Bitmaps; private readonly List<Bitmap> _Bitmaps;
private Color ClearColor = Color.DarkBlue; private readonly Color ClearColor = Color.DarkBlue;
public CDrawWinForm() public CDrawWinForm()
{ {
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon)); Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.sIcon));
_Textures = new List<STexture>(); _Textures = new List<STexture>();
_Bitmaps = new List<Bitmap>(); _Bitmaps = new List<Bitmap>();
_Keys = new CKeys(); _Keys = new CKeys();
_Mouse = new CMouse(); _Mouse = new CMouse();
this.ClientSize = new Size(1280, 720); ClientSize = new Size(1280, 720);
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Opaque, true); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Opaque, true);
// Create the backbuffer // Create the backbuffer
_backbuffer = new Bitmap(CSettings.iRenderW, CSettings.iRenderH); _backbuffer = new Bitmap(CSettings.iRenderW, CSettings.iRenderH);
_g = Graphics.FromImage(_backbuffer); _g = Graphics.FromImage(_backbuffer);
_g.Clear(Color.DarkBlue); _g.Clear(Color.DarkBlue);
this.Paint += new PaintEventHandler(this.OnPaintEvent); Paint += OnPaintEvent;
this.Closing += new CancelEventHandler(this.OnClosingEvent); Closing += OnClosingEvent;
this.KeyDown += new KeyEventHandler(this.OnKeyDownEvent); KeyDown += OnKeyDownEvent;
this.KeyPress += new KeyPressEventHandler(this.OnKeyPressEvent); KeyPress += OnKeyPressEvent;
this.KeyUp += new KeyEventHandler(this.OnKeyUpEvent); KeyUp += OnKeyUpEvent;
this.Resize += new EventHandler(this.OnResizeEvent); Resize += OnResizeEvent;
this.MouseMove += new MouseEventHandler(this.OnMouseMove); MouseMove += OnMouseMove;
this.MouseDown += new MouseEventHandler(this.OnMouseDown); MouseDown += OnMouseDown;
this.MouseUp += new MouseEventHandler(this.OnMouseUp); MouseUp += OnMouseUp;
FlipBuffer(); FlipBuffer();
Cursor.Show(); Cursor.Show();
@@ -71,33 +72,29 @@ namespace Vocaluxe.Lib.Draw
private void DrawBuffer() private void DrawBuffer()
{ {
Graphics gFrontBuffer = Graphics.FromHwnd(this.Handle); Graphics gFrontBuffer = Graphics.FromHwnd(Handle);
int h = this.ClientSize.Height; int h = ClientSize.Height;
int w = this.ClientSize.Width; int w = ClientSize.Width;
int y = 0; int y = 0;
int x = 0; int x = 0;
if ((float)this.ClientSize.Width / (float)this.ClientSize.Height > CSettings.GetRenderAspect()) if (ClientSize.Width / (float)ClientSize.Height > CSettings.GetRenderAspect())
{ {
w = (int)Math.Round((float)this.ClientSize.Height * CSettings.GetRenderAspect()); w = (int)Math.Round(ClientSize.Height * CSettings.GetRenderAspect());
x = (this.ClientSize.Width - w) / 2; x = (ClientSize.Width - w) / 2;
} }
else else
{ {
h = (int)Math.Round((float)this.ClientSize.Width / CSettings.GetRenderAspect()); h = (int)Math.Round(ClientSize.Width / CSettings.GetRenderAspect());
y = (this.ClientSize.Height - h) / 2; y = (ClientSize.Height - h) / 2;
} }
gFrontBuffer.DrawImage(_backbuffer, new Rectangle(x, y, w, h), new Rectangle(0, 0, _backbuffer.Width, _backbuffer.Height), GraphicsUnit.Pixel); gFrontBuffer.DrawImage(_backbuffer, new Rectangle(x, y, w, h), new Rectangle(0, 0, _backbuffer.Width, _backbuffer.Height), GraphicsUnit.Pixel);
} }
private void OnPaintEvent(object sender, PaintEventArgs e) private void OnPaintEvent(object sender, PaintEventArgs e) {}
{
}
#region FullScreenStuff #region FullScreenStuff
private void ToggleFullScreen() private void ToggleFullScreen()
{ {
if (!_fullscreen) if (!_fullscreen)
@@ -142,7 +139,7 @@ namespace Vocaluxe.Lib.Draw
private void OnResizeEvent(object sender, EventArgs e) private void OnResizeEvent(object sender, EventArgs e)
{ {
Graphics gFrontBuffer = Graphics.FromHwnd(this.Handle); Graphics gFrontBuffer = Graphics.FromHwnd(Handle);
gFrontBuffer.Clear(Color.Black); gFrontBuffer.Clear(Color.Black);
} }
@@ -172,17 +169,17 @@ namespace Vocaluxe.Lib.Draw
} }
} }
private void OnKeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e) private void OnKeyDownEvent(object sender, KeyEventArgs e)
{ {
_Keys.KeyDown(e); _Keys.KeyDown(e);
} }
private void OnKeyPressEvent(object sender, System.Windows.Forms.KeyPressEventArgs e) private void OnKeyPressEvent(object sender, KeyPressEventArgs e)
{ {
_Keys.KeyPress(e); _Keys.KeyPress(e);
} }
private void OnKeyUpEvent(object sender, System.Windows.Forms.KeyEventArgs e) private void OnKeyUpEvent(object sender, KeyEventArgs e)
{ {
_Keys.KeyUp(e); _Keys.KeyUp(e);
} }
@@ -206,7 +203,7 @@ namespace Vocaluxe.Lib.Draw
public bool Init() public bool Init()
{ {
this.Text = CSettings.GetFullVersionText(); Text = CSettings.GetFullVersionText();
return true; return true;
} }
@@ -214,7 +211,7 @@ namespace Vocaluxe.Lib.Draw
{ {
_Run = true; _Run = true;
int delay = 0; int delay = 0;
this.Show(); Show();
if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON)
{ {
@@ -239,29 +236,29 @@ namespace Vocaluxe.Lib.Draw
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds()); delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
if (delay >= 1) if (delay >= 1)
System.Threading.Thread.Sleep(delay); Thread.Sleep(delay);
CTime.CalculateFPS(); CTime.CalculateFPS();
CTime.Restart(); CTime.Restart();
} }
} }
this.Close(); Close();
} }
public bool Unload() public bool Unload()
{ {
this.Dispose(); Dispose();
return true; return true;
} }
public int GetScreenWidth() public int GetScreenWidth()
{ {
return this.ClientSize.Width; return ClientSize.Width;
} }
public int GetScreenHeight() public int GetScreenHeight()
{ {
return this.ClientSize.Height; return ClientSize.Height;
} }
public RectangleF GetTextBounds(CText text) public RectangleF GetTextBounds(CText text)
@@ -309,10 +306,8 @@ namespace Vocaluxe.Lib.Draw
Texture = CopyScreen(); Texture = CopyScreen();
} }
else else
{
_Bitmaps[Texture.index] = new Bitmap(_backbuffer); _Bitmaps[Texture.index] = new Bitmap(_backbuffer);
} }
}
public void MakeScreenShot() public void MakeScreenShot()
{ {
@@ -343,16 +338,9 @@ namespace Vocaluxe.Lib.Draw
CFonts.DrawText(Text, h, x, y, z, new SColorF(1, 1, 1, 1)); CFonts.DrawText(Text, h, x, y, z, new SColorF(1, 1, 1, 1));
} }
public void DrawColor(SColorF color, SRectF rect) {}
public void DrawColor(SColorF color, SRectF rect) public void DrawColorReflection(SColorF color, SRectF rect, float space, float height) {}
{
}
public void DrawColorReflection(SColorF color, SRectF rect, float space, float height)
{
}
public STexture AddTexture(Bitmap bmp) public STexture AddTexture(Bitmap bmp)
{ {
@@ -378,7 +366,7 @@ namespace Vocaluxe.Lib.Draw
public STexture AddTexture(string TexturePath) public STexture AddTexture(string TexturePath)
{ {
STexture texture = new STexture(); STexture texture = new STexture();
if (System.IO.File.Exists(TexturePath)) if (File.Exists(TexturePath))
{ {
bool found = false; bool found = false;
foreach (STexture tex in _Textures) foreach (STexture tex in _Textures)
@@ -394,11 +382,9 @@ namespace Vocaluxe.Lib.Draw
if (!found) if (!found)
{ {
using (Bitmap bmp = new Bitmap(TexturePath)) using (Bitmap bmp = new Bitmap(TexturePath))
{
return AddTexture(bmp); return AddTexture(bmp);
} }
} }
}
return texture; return texture;
} }
@@ -434,7 +420,7 @@ namespace Vocaluxe.Lib.Draw
{ {
using (Bitmap bmp = new Bitmap(W, H)) using (Bitmap bmp = new Bitmap(W, H))
{ {
BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb); BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
Marshal.Copy(Data, 0, bmp_data.Scan0, Data.Length); Marshal.Copy(Data, 0, bmp_data.Scan0, Data.Length);
bmp.UnlockBits(bmp_data); bmp.UnlockBits(bmp_data);
return AddTexture(bmp); return AddTexture(bmp);
@@ -451,7 +437,7 @@ namespace Vocaluxe.Lib.Draw
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index)) if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
{ {
BitmapData bmp_data = _Bitmaps[Texture.index].LockBits(new Rectangle(0, 0, _Bitmaps[Texture.index].Width, _Bitmaps[Texture.index].Height), BitmapData bmp_data = _Bitmaps[Texture.index].LockBits(new Rectangle(0, 0, _Bitmaps[Texture.index].Width, _Bitmaps[Texture.index].Height),
ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb); ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
Marshal.Copy(Data, 0, bmp_data.Scan0, Data.Length); Marshal.Copy(Data, 0, bmp_data.Scan0, Data.Length);
_Bitmaps[Texture.index].UnlockBits(bmp_data); _Bitmaps[Texture.index].UnlockBits(bmp_data);
} }
@@ -461,42 +447,32 @@ namespace Vocaluxe.Lib.Draw
public void DrawTexture(STexture Texture) public void DrawTexture(STexture Texture)
{ {
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index)) if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
{
DrawTexture(Texture, Texture.rect, Texture.color); DrawTexture(Texture, Texture.rect, Texture.color);
} }
}
public void DrawTexture(STexture Texture, SRectF rect) public void DrawTexture(STexture Texture, SRectF rect)
{ {
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index)) if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
{
DrawTexture(Texture, rect, Texture.color); DrawTexture(Texture, rect, Texture.color);
} }
}
public void DrawTexture(STexture Texture, SRectF rect, SColorF color) public void DrawTexture(STexture Texture, SRectF rect, SColorF color)
{ {
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index)) if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
{
DrawTexture(Texture, rect, color, rect, false); DrawTexture(Texture, rect, color, rect, false);
} }
}
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds) public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds)
{ {
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index)) if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
{
DrawTexture(Texture, rect, color, bounds, false); DrawTexture(Texture, rect, color, bounds, false);
} }
}
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, bool mirrored) public void DrawTexture(STexture Texture, SRectF rect, SColorF color, bool mirrored)
{ {
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index)) if ((Texture.index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > Texture.index))
{
DrawTexture(Texture, rect, color, rect, mirrored); DrawTexture(Texture, rect, color, rect, mirrored);
} }
}
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored) public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored)
{ {
@@ -508,14 +484,9 @@ namespace Vocaluxe.Lib.Draw
} }
} }
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end) public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end) {}
{
} public void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) {}
public void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
{
}
public int TextureCount() public int TextureCount()
{ {
@@ -528,7 +499,6 @@ namespace Vocaluxe.Lib.Draw
using (Graphics g = Graphics.FromImage(newBitmap)) using (Graphics g = Graphics.FromImage(newBitmap))
{ {
ColorMatrix cm = new ColorMatrix(); ColorMatrix cm = new ColorMatrix();
cm.Matrix33 = color.A; cm.Matrix33 = color.A;
cm.Matrix00 = color.R; cm.Matrix00 = color.R;
@@ -542,7 +512,6 @@ namespace Vocaluxe.Lib.Draw
g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height), g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height),
0, 0, original.Width, original.Height, GraphicsUnit.Pixel, ia); 0, 0, original.Width, original.Height, GraphicsUnit.Pixel, ia);
} }
} }
File diff suppressed because it is too large. Load diff
+29 -12
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Vocaluxe.Base; using Vocaluxe.Base;
namespace Vocaluxe.Lib.Input namespace Vocaluxe.Lib.Input
@@ -8,8 +7,7 @@ namespace Vocaluxe.Lib.Input
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HIDDeviceInfo public struct HIDDeviceInfo
{ {
[MarshalAsAttribute(UnmanagedType.LPTStr)] [MarshalAs(UnmanagedType.LPTStr)] public String Path;
public String Path;
public ushort VendorString; public ushort VendorString;
public ushort ProductID; public ushort ProductID;
public String SerialNumber; public String SerialNumber;
@@ -21,6 +19,7 @@ namespace Vocaluxe.Lib.Input
public int InterfaceNumber; public int InterfaceNumber;
internal IntPtr Next; internal IntPtr Next;
} }
public static class CHIDAPI public static class CHIDAPI
{ {
#if ARCH_X86 #if ARCH_X86
@@ -43,9 +42,9 @@ namespace Vocaluxe.Lib.Input
#endif #endif
#endif #endif
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_init", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_init", CharSet = CharSet.Unicode)]
private static extern int hid_init(); private static extern int hid_init();
public static bool Init() public static bool Init()
{ {
int result = -1; int result = -1;
@@ -55,7 +54,7 @@ namespace Vocaluxe.Lib.Input
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Error CHIDAPI.Init(): " + e.ToString()); CLog.LogError("Error CHIDAPI.Init(): " + e);
return false; return false;
} }
@@ -67,6 +66,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_exit", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_exit", CharSet = CharSet.Unicode)]
private static extern int hid_exit(); private static extern int hid_exit();
public static bool Exit() public static bool Exit()
{ {
int result = -1; int result = -1;
@@ -76,7 +76,7 @@ namespace Vocaluxe.Lib.Input
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Error CHIDAPI.Exit(): " + e.ToString()); CLog.LogError("Error CHIDAPI.Exit(): " + e);
return false; return false;
} }
@@ -85,8 +85,11 @@ namespace Vocaluxe.Lib.Input
return false; return false;
} }
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_enumerate", CharSet = CharSet.Ansi)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_enumerate", CharSet = CharSet.Ansi)]
private static extern IntPtr hid_enumerate(ushort VendorID, ushort ProductID); //HIDDeviceInfo private static extern IntPtr hid_enumerate(ushort VendorID, ushort ProductID);
//HIDDeviceInfo
public static IntPtr Enumerate(ushort VendorID, ushort ProductID) //HIDDeviceInfo public static IntPtr Enumerate(ushort VendorID, ushort ProductID) //HIDDeviceInfo
{ {
return hid_enumerate(VendorID, ProductID); return hid_enumerate(VendorID, ProductID);
@@ -94,6 +97,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_free_enumeration", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_free_enumeration", CharSet = CharSet.Unicode)]
private static extern void hid_free_enumeration(HIDDeviceInfo devs); private static extern void hid_free_enumeration(HIDDeviceInfo devs);
public static void FreeEnumeration(HIDDeviceInfo devs) public static void FreeEnumeration(HIDDeviceInfo devs)
{ {
hid_free_enumeration(devs); hid_free_enumeration(devs);
@@ -101,6 +105,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_open", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_open", CharSet = CharSet.Unicode)]
private static extern IntPtr hid_open(ushort VendorID, ushort ProductID, IntPtr SerialNumber); private static extern IntPtr hid_open(ushort VendorID, ushort ProductID, IntPtr SerialNumber);
public static bool Open(ushort VendorID, ushort ProductID, out IntPtr Handle) public static bool Open(ushort VendorID, ushort ProductID, out IntPtr Handle)
{ {
Handle = IntPtr.Zero; Handle = IntPtr.Zero;
@@ -110,7 +115,7 @@ namespace Vocaluxe.Lib.Input
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Error CHIDAPI.Open(): " + e.ToString()); CLog.LogError("Error CHIDAPI.Open(): " + e);
return false; return false;
} }
@@ -118,11 +123,11 @@ namespace Vocaluxe.Lib.Input
return true; return true;
return false; return false;
} }
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_open_path", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_open_path", CharSet = CharSet.Unicode)]
private static extern IntPtr hid_open_path(string Path); private static extern IntPtr hid_open_path(string Path);
public static IntPtr OpenPath(string Path) public static IntPtr OpenPath(string Path)
{ {
return hid_open_path(Path); return hid_open_path(Path);
@@ -130,6 +135,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_write", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_write", CharSet = CharSet.Unicode)]
private static extern int hid_write(IntPtr device, byte[] data, int length); private static extern int hid_write(IntPtr device, byte[] data, int length);
public static int Write(IntPtr Device, byte[] Data) public static int Write(IntPtr Device, byte[] Data)
{ {
return hid_write(Device, Data, Data.Length); return hid_write(Device, Data, Data.Length);
@@ -137,6 +143,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_read_timeout", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_read_timeout", CharSet = CharSet.Unicode)]
private static extern int hid_read_timeout(IntPtr device, IntPtr data, int length, int milliseconds); private static extern int hid_read_timeout(IntPtr device, IntPtr data, int length, int milliseconds);
public static int ReadTimeout(IntPtr Device, out byte[] Data, int length, int milliseconds) public static int ReadTimeout(IntPtr Device, out byte[] Data, int length, int milliseconds)
{ {
Data = new byte[length]; Data = new byte[length];
@@ -150,7 +157,7 @@ namespace Vocaluxe.Lib.Input
catch (Exception e) catch (Exception e)
{ {
result = -1; result = -1;
CLog.LogError("Error CHIDAPI.ReadTimeout(): " + e.ToString()); CLog.LogError("Error CHIDAPI.ReadTimeout(): " + e);
} }
if (result != -1) if (result != -1)
@@ -164,6 +171,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_read", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_read", CharSet = CharSet.Unicode)]
private static extern int hid_read(IntPtr device, IntPtr data, int length); private static extern int hid_read(IntPtr device, IntPtr data, int length);
public static int Read(IntPtr Device, out byte[] Data, int length) public static int Read(IntPtr Device, out byte[] Data, int length)
{ {
Data = new byte[length]; Data = new byte[length];
@@ -177,7 +185,7 @@ namespace Vocaluxe.Lib.Input
catch (Exception e) catch (Exception e)
{ {
result = -1; result = -1;
CLog.LogError("Error CHIDAPI.Read(): " + e.ToString()); CLog.LogError("Error CHIDAPI.Read(): " + e);
} }
if (result != -1) if (result != -1)
@@ -191,6 +199,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_set_nonblocking", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_set_nonblocking", CharSet = CharSet.Unicode)]
private static extern int hid_set_nonblocking(IntPtr device, bool nonblock); private static extern int hid_set_nonblocking(IntPtr device, bool nonblock);
public static int Read(IntPtr Device, bool Nonblocking) public static int Read(IntPtr Device, bool Nonblocking)
{ {
return hid_set_nonblocking(Device, Nonblocking); return hid_set_nonblocking(Device, Nonblocking);
@@ -198,6 +207,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_send_feature_report", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_send_feature_report", CharSet = CharSet.Unicode)]
private static extern int hid_send_feature_report(IntPtr device, string data, int length); private static extern int hid_send_feature_report(IntPtr device, string data, int length);
public static int SendFeatureReport(IntPtr Device, string Data) public static int SendFeatureReport(IntPtr Device, string Data)
{ {
return hid_send_feature_report(Device, Data, Data.Length); return hid_send_feature_report(Device, Data, Data.Length);
@@ -205,6 +215,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_feature_report", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_feature_report", CharSet = CharSet.Unicode)]
private static extern int hid_get_feature_report(IntPtr device, string Data, int length); private static extern int hid_get_feature_report(IntPtr device, string Data, int length);
public static int GetFeatureReport(IntPtr Device, string Data) public static int GetFeatureReport(IntPtr Device, string Data)
{ {
return hid_get_feature_report(Device, Data, Data.Length); return hid_get_feature_report(Device, Data, Data.Length);
@@ -212,6 +223,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_close", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_close", CharSet = CharSet.Unicode)]
private static extern void hid_close(IntPtr device); private static extern void hid_close(IntPtr device);
public static bool Close(IntPtr Device) public static bool Close(IntPtr Device)
{ {
try try
@@ -220,7 +232,7 @@ namespace Vocaluxe.Lib.Input
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Error CHIDAPI.Close(): " + e.ToString()); CLog.LogError("Error CHIDAPI.Close(): " + e);
return false; return false;
} }
return true; return true;
@@ -228,6 +240,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_manufacturer_string", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_manufacturer_string", CharSet = CharSet.Unicode)]
private static extern int hid_get_manufacturer_string(IntPtr device, string Data, int maxlength); private static extern int hid_get_manufacturer_string(IntPtr device, string Data, int maxlength);
public static int GetManufacturerString(IntPtr Device, string Data, int MaxLength) public static int GetManufacturerString(IntPtr Device, string Data, int MaxLength)
{ {
return hid_get_manufacturer_string(Device, Data, MaxLength); return hid_get_manufacturer_string(Device, Data, MaxLength);
@@ -235,6 +248,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_product_string", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_product_string", CharSet = CharSet.Unicode)]
private static extern int hid_get_product_string(IntPtr device, string Data, int maxlength); private static extern int hid_get_product_string(IntPtr device, string Data, int maxlength);
public static int GetProductString(IntPtr Device, string Data, int MaxLength) public static int GetProductString(IntPtr Device, string Data, int MaxLength)
{ {
return hid_get_product_string(Device, Data, MaxLength); return hid_get_product_string(Device, Data, MaxLength);
@@ -242,6 +256,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_serial_number_string", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_serial_number_string", CharSet = CharSet.Unicode)]
private static extern int hid_get_serial_number_string(IntPtr device, string Data, int maxlength); private static extern int hid_get_serial_number_string(IntPtr device, string Data, int maxlength);
public static int GetSerialNumberString(IntPtr Device, string Data, int MaxLength) public static int GetSerialNumberString(IntPtr Device, string Data, int MaxLength)
{ {
return hid_get_serial_number_string(Device, Data, MaxLength); return hid_get_serial_number_string(Device, Data, MaxLength);
@@ -249,6 +264,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_indexed_string", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_get_indexed_string", CharSet = CharSet.Unicode)]
private static extern int hid_get_indexed_string(IntPtr device, string Data, int maxlength); private static extern int hid_get_indexed_string(IntPtr device, string Data, int maxlength);
public static int GetIndexedString(IntPtr Device, string Data, int MaxLength) public static int GetIndexedString(IntPtr Device, string Data, int MaxLength)
{ {
return hid_get_indexed_string(Device, Data, MaxLength); return hid_get_indexed_string(Device, Data, MaxLength);
@@ -256,6 +272,7 @@ namespace Vocaluxe.Lib.Input
[DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_error", CharSet = CharSet.Unicode)] [DllImport(HIDapiDll, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, EntryPoint = "hid_error", CharSet = CharSet.Unicode)]
private static extern string hid_error(IntPtr device); private static extern string hid_error(IntPtr device);
public static string Error(IntPtr Device) public static string Error(IntPtr Device)
{ {
return hid_error(Device); return hid_error(Device);
+3 -3
View File
@@ -31,7 +31,7 @@ namespace Vocaluxe.Lib.Input
class RumbleTimer class RumbleTimer
{ {
private Stopwatch _timer; private readonly Stopwatch _timer;
private float _duration; private float _duration;
public bool ShouldStart public bool ShouldStart
@@ -86,8 +86,8 @@ namespace Vocaluxe.Lib.Input
class CGesture class CGesture
{ {
Point _Begin; private Point _Begin;
bool _locked; private bool _locked;
public CGesture() public CGesture()
{ {
+13 -15
View File
@@ -10,15 +10,15 @@ namespace Vocaluxe.Lib.Input.WiiMote
{ {
class CWiiMote : IInput, IDisposable class CWiiMote : IInput, IDisposable
{ {
WiiMoteLib _WiiMote = null; private WiiMoteLib _WiiMote;
private List<KeyEvent> _KeysPool; private List<KeyEvent> _KeysPool;
private List<KeyEvent> _CurrentKeysPool; private List<KeyEvent> _CurrentKeysPool;
private Object _KeyCopyLock = new Object(); private readonly Object _KeyCopyLock = new Object();
private List<MouseEvent> _MousePool; private List<MouseEvent> _MousePool;
private List<MouseEvent> _CurrentMousePool; private List<MouseEvent> _CurrentMousePool;
private Object _MouseCopyLock = new Object(); private readonly Object _MouseCopyLock = new Object();
private bool[] _ButtonStates; private bool[] _ButtonStates;
private Point _OldPosition; private Point _OldPosition;
@@ -70,7 +70,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
return true; return true;
} }
public bool Disconnect() public bool Disconnect()
{ {
_Active = false; _Active = false;
@@ -95,7 +94,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
_CurrentKeysPool.RemoveAt(0); _CurrentKeysPool.RemoveAt(0);
return true; return true;
} }
else return false; else
return false;
} }
public bool PollMouseEvent(ref MouseEvent MouseEvent) public bool PollMouseEvent(ref MouseEvent MouseEvent)
@@ -106,7 +106,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
_CurrentMousePool.RemoveAt(0); _CurrentMousePool.RemoveAt(0);
return true; return true;
} }
else return false; else
return false;
} }
public void SetRumble(float Duration) public void SetRumble(float Duration)
@@ -163,7 +164,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
} }
catch catch
{ {
return false; ; return false;
;
} }
_WiiMote.SetReportType(InputReport.IRAccel, IRSensitivity.Max, false); _WiiMote.SetReportType(InputReport.IRAccel, IRSensitivity.Max, false);
@@ -255,11 +257,11 @@ namespace Vocaluxe.Lib.Input.WiiMote
//mouse events //mouse events
float reducing = 0.15f; float reducing = 0.15f;
float factor = 1f / (1f - reducing * 2f); float factor = 1f / (1f - reducing * 2f);
float rx = (((float)p.X / 1024f) - reducing) * factor; float rx = ((p.X / 1024f) - reducing) * factor;
float ry = (((float)p.Y / 768f) - reducing) * factor; float ry = ((p.Y / 768f) - reducing) * factor;
int x = (int)(rx * (float)CSettings.iRenderW); int x = (int)(rx * CSettings.iRenderW);
int y = (int)(ry * (float)CSettings.iRenderH); int y = (int)(ry * CSettings.iRenderH);
bool ld = false; bool ld = false;
@@ -306,18 +308,14 @@ namespace Vocaluxe.Lib.Input.WiiMote
lock (_KeyCopyLock) lock (_KeyCopyLock)
{ {
foreach (KeyEvent e in _KeysPool) foreach (KeyEvent e in _KeysPool)
{
_CurrentKeysPool.Add(e); _CurrentKeysPool.Add(e);
}
_KeysPool.Clear(); _KeysPool.Clear();
} }
lock (_MouseCopyLock) lock (_MouseCopyLock)
{ {
foreach (MouseEvent e in _MousePool) foreach (MouseEvent e in _MousePool)
{
_CurrentMousePool.Add(e); _CurrentMousePool.Add(e);
}
_MousePool.Clear(); _MousePool.Clear();
} }
} }
+10 -14
View File
@@ -1,12 +1,12 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Threading; using System.Threading;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Input.WiiMote namespace Vocaluxe.Lib.Input.WiiMote
{ {
#region DataTypes #region DataTypes
public class WiiMoteStatus public class WiiMoteStatus
{ {
@@ -149,17 +149,14 @@ namespace Vocaluxe.Lib.Input.WiiMote
private int _Address; private int _Address;
private short _Size; private short _Size;
private Thread _Reader; private readonly Thread _Reader;
private bool _Active; private bool _Active;
private bool _Error; private bool _Error;
private bool _Connected; private bool _Connected;
public bool Connected public bool Connected
{ {
get get { return _Connected; }
{
return _Connected;
}
} }
private readonly WiiMoteStatus _WiiMoteState = new WiiMoteStatus(); private readonly WiiMoteStatus _WiiMoteState = new WiiMoteStatus();
@@ -303,7 +300,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("(WiiMoteLib) Error reading from device: " + e.ToString()); CLog.LogError("(WiiMoteLib) Error reading from device: " + e);
} }
if (ParseInputReport(buff)) if (ParseInputReport(buff))
@@ -415,11 +412,11 @@ namespace Vocaluxe.Lib.Input.WiiMote
_WiiMoteState.AccelState.RawValues.Y = buff[4]; _WiiMoteState.AccelState.RawValues.Y = buff[4];
_WiiMoteState.AccelState.RawValues.Z = buff[5]; _WiiMoteState.AccelState.RawValues.Z = buff[5];
_WiiMoteState.AccelState.Values.X = (float)((float)_WiiMoteState.AccelState.RawValues.X - _WiiMoteState.AccelCalibrationInfo.X0) / _WiiMoteState.AccelState.Values.X = ((float)_WiiMoteState.AccelState.RawValues.X - _WiiMoteState.AccelCalibrationInfo.X0) /
((float)_WiiMoteState.AccelCalibrationInfo.XG - _WiiMoteState.AccelCalibrationInfo.X0); ((float)_WiiMoteState.AccelCalibrationInfo.XG - _WiiMoteState.AccelCalibrationInfo.X0);
_WiiMoteState.AccelState.Values.Y = (float)((float)_WiiMoteState.AccelState.RawValues.Y - _WiiMoteState.AccelCalibrationInfo.Y0) / _WiiMoteState.AccelState.Values.Y = ((float)_WiiMoteState.AccelState.RawValues.Y - _WiiMoteState.AccelCalibrationInfo.Y0) /
((float)_WiiMoteState.AccelCalibrationInfo.YG - _WiiMoteState.AccelCalibrationInfo.Y0); ((float)_WiiMoteState.AccelCalibrationInfo.YG - _WiiMoteState.AccelCalibrationInfo.Y0);
_WiiMoteState.AccelState.Values.Z = (float)((float)_WiiMoteState.AccelState.RawValues.Z - _WiiMoteState.AccelCalibrationInfo.Z0) / _WiiMoteState.AccelState.Values.Z = ((float)_WiiMoteState.AccelState.RawValues.Z - _WiiMoteState.AccelCalibrationInfo.Z0) /
((float)_WiiMoteState.AccelCalibrationInfo.ZG - _WiiMoteState.AccelCalibrationInfo.Z0); ((float)_WiiMoteState.AccelCalibrationInfo.ZG - _WiiMoteState.AccelCalibrationInfo.Z0);
} }
@@ -475,7 +472,6 @@ namespace Vocaluxe.Lib.Input.WiiMote
else else
_WiiMoteState.IRState.Position.Y = _WiiMoteState.IRState.Sensors[0].Position.Y + _WiiMoteState.IRState.Distance.Y / 2; _WiiMoteState.IRState.Position.Y = _WiiMoteState.IRState.Sensors[0].Position.Y + _WiiMoteState.IRState.Distance.Y / 2;
} }
} }
private void ParseReadData(byte[] buff) private void ParseReadData(byte[] buff)
@@ -506,8 +502,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
get get
{ {
if (_WiiMoteState.Rumble) if (_WiiMoteState.Rumble)
return (byte)0x1; return 0x1;
return (byte)0x0; return 0x0;
} }
} }
@@ -637,7 +633,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
private void WriteData(int address, byte data) private void WriteData(int address, byte data)
{ {
WriteData(address, 1, new byte[] { data }); WriteData(address, 1, new[] {data});
} }
private void WriteData(int address, byte size, byte[] buff) private void WriteData(int address, byte size, byte[] buff)
+4 -17
View File
@@ -1,8 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
using System.Xml; using System.Xml;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -11,7 +11,7 @@ namespace Vocaluxe.Lib.Playlist
{ {
public class CPlaylistFile public class CPlaylistFile
{ {
private static XmlWriterSettings _settings = new XmlWriterSettings(); private static readonly XmlWriterSettings _settings = new XmlWriterSettings();
public string PlaylistName; public string PlaylistName;
public string PlaylistFile; public string PlaylistFile;
@@ -34,11 +34,10 @@ namespace Vocaluxe.Lib.Playlist
private void Init() private void Init()
{ {
_settings.Indent = true; _settings.Indent = true;
_settings.Encoding = System.Text.Encoding.UTF8; _settings.Encoding = Encoding.UTF8;
_settings.ConformanceLevel = ConformanceLevel.Document; _settings.ConformanceLevel = ConformanceLevel.Document;
} }
public void SavePlaylist() public void SavePlaylist()
{ {
if (PlaylistFile.Length == 0) if (PlaylistFile.Length == 0)
@@ -58,10 +57,8 @@ namespace Vocaluxe.Lib.Playlist
{ {
i++; i++;
if (!File.Exists(Path.Combine(CSettings.sFolderPlaylists, filename + i + ".xml"))) if (!File.Exists(Path.Combine(CSettings.sFolderPlaylists, filename + i + ".xml")))
{
filename += i; filename += i;
} }
}
PlaylistFile = Path.Combine(CSettings.sFolderPlaylists, filename + ".xml"); PlaylistFile = Path.Combine(CSettings.sFolderPlaylists, filename + ".xml");
} }
@@ -105,10 +102,8 @@ namespace Vocaluxe.Lib.Playlist
writer.WriteEndElement(); writer.WriteEndElement();
} }
else else
{
CLog.LogError("Playlist.SavePlaylist(): Can't find Song. This should never happen!"); CLog.LogError("Playlist.SavePlaylist(): Can't find Song. This should never happen!");
} }
}
writer.WriteEndElement(); writer.WriteEndElement();
writer.WriteEndElement(); //end of root writer.WriteEndElement(); //end of root
@@ -144,7 +139,7 @@ namespace Vocaluxe.Lib.Playlist
{ {
xmlReader.GetValue("//root/Songs/" + songs[i] + "/Artist", ref artist, String.Empty); xmlReader.GetValue("//root/Songs/" + songs[i] + "/Artist", ref artist, String.Empty);
xmlReader.GetValue("//root/Songs/" + songs[i] + "/Title", ref title, String.Empty); xmlReader.GetValue("//root/Songs/" + songs[i] + "/Title", ref title, String.Empty);
xmlReader.TryGetEnumValue<EGameMode>("//root/Songs/" + songs[i] + "/GameMode", ref gm); xmlReader.TryGetEnumValue("//root/Songs/" + songs[i] + "/GameMode", ref gm);
CPlaylistSong song = new CPlaylistSong(); CPlaylistSong song = new CPlaylistSong();
song.SongID = -1; song.SongID = -1;
@@ -165,16 +160,12 @@ namespace Vocaluxe.Lib.Playlist
Songs.Add(song); Songs.Add(song);
} }
else else
{
CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + PlaylistFile); CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + PlaylistFile);
} }
} }
}
else else
{
CLog.LogError("Can't find PlaylistName in Playlist File: " + PlaylistFile); CLog.LogError("Can't find PlaylistName in Playlist File: " + PlaylistFile);
} }
}
public void AddSong(int SongID) public void AddSong(int SongID)
{ {
@@ -205,18 +196,14 @@ namespace Vocaluxe.Lib.Playlist
public void SongUp(int SongNr) public void SongUp(int SongNr)
{ {
if (SongNr < Songs.Count - 1 && SongNr > 0) if (SongNr < Songs.Count - 1 && SongNr > 0)
{
Songs.Reverse(SongNr - 1, 2); Songs.Reverse(SongNr - 1, 2);
} }
}
public void SongDown(int SongNr) public void SongDown(int SongNr)
{ {
if (SongNr < Songs.Count - 1 && SongNr >= 0) if (SongNr < Songs.Count - 1 && SongNr >= 0)
{
Songs.Reverse(SongNr, 2); Songs.Reverse(SongNr, 2);
} }
}
public void SongMove(int SourceNr, int DestNr) public void SongMove(int SourceNr, int DestNr)
{ {
+75 -94
View File
@@ -9,20 +9,18 @@ namespace Vocaluxe.Lib.Sound
{ {
class CDirectSoundRecord : IRecord class CDirectSoundRecord : IRecord
{ {
private bool _initialized = false; private bool _initialized;
private List<SRecordDevice> _Devices = null; private List<SRecordDevice> _Devices;
private SRecordDevice[] _DeviceConfig = null; private SRecordDevice[] _DeviceConfig;
private List<SoundCardSource> _Sources = null; private List<SoundCardSource> _Sources;
private CBuffer[] _Buffer; private readonly CBuffer[] _Buffer;
public CDirectSoundRecord() public CDirectSoundRecord()
{ {
_Buffer = new CBuffer[CSettings.MaxNumPlayer]; _Buffer = new CBuffer[CSettings.MaxNumPlayer];
for (int i = 0; i < _Buffer.Length; i++) for (int i = 0; i < _Buffer.Length; i++)
{
_Buffer[i] = new CBuffer(); _Buffer[i] = new CBuffer();
}
Init(); Init();
} }
@@ -38,7 +36,6 @@ namespace Vocaluxe.Lib.Sound
{ {
using (DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid)) using (DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid))
{ {
SRecordDevice device = new SRecordDevice(); SRecordDevice device = new SRecordDevice();
device.Driver = dev.DriverGuid.ToString(); device.Driver = dev.DriverGuid.ToString();
device.ID = id; device.ID = id;
@@ -81,9 +78,7 @@ namespace Vocaluxe.Lib.Sound
return false; return false;
for (int i = 0; i < _Buffer.Length; i++) for (int i = 0; i < _Buffer.Length; i++)
{
_Buffer[i].Reset(); _Buffer[i].Reset();
}
_DeviceConfig = DeviceConfig; _DeviceConfig = DeviceConfig;
bool[] active = new bool[DeviceConfig.Length]; bool[] active = new bool[DeviceConfig.Length];
@@ -108,11 +103,10 @@ namespace Vocaluxe.Lib.Sound
{ {
SoundCardSource source = new SoundCardSource(guid[i], channels[i]); SoundCardSource source = new SoundCardSource(guid[i], channels[i]);
source.SampleRateKHz = 44.1; source.SampleRateKHz = 44.1;
source.SampleDataReady += this.OnDataReady; source.SampleDataReady += OnDataReady;
source.Start(); source.Start();
_Sources.Add(source); _Sources.Add(source);
} }
} }
@@ -134,6 +128,7 @@ namespace Vocaluxe.Lib.Sound
return true; return true;
} }
public void AnalyzeBuffer(int Player) public void AnalyzeBuffer(int Player)
{ {
if (!_initialized) if (!_initialized)
@@ -243,8 +238,8 @@ namespace Vocaluxe.Lib.Sound
{ {
public SampleDataEventArgs(byte[] data, Guid guid) public SampleDataEventArgs(byte[] data, Guid guid)
{ {
this.Data = data; Data = data;
this.Guid = guid; Guid = guid;
} }
public byte[] Data { get; private set; } public byte[] Data { get; private set; }
@@ -254,167 +249,154 @@ namespace Vocaluxe.Lib.Sound
public class SoundCardSource : IDisposable public class SoundCardSource : IDisposable
{ {
private volatile bool running; private volatile bool running;
private int bufferSize; private readonly int bufferSize;
private CaptureBuffer buffer; private CaptureBuffer buffer;
private CaptureBufferDescription bufferDescription; private CaptureBufferDescription bufferDescription;
private DirectSoundCapture captureDevice; private DirectSoundCapture captureDevice;
private WaveFormat waveFormat; private readonly WaveFormat waveFormat;
private Thread captureThread; private Thread captureThread;
private List<NotificationPosition> notifications; private List<NotificationPosition> notifications;
private int bufferPortionCount; private int bufferPortionCount;
private int bufferPortionSize; private int bufferPortionSize;
private WaitHandle[] waitHandles; private WaitHandle[] waitHandles;
private double sampleRate; private double sampleRate;
private Guid guid; private readonly Guid guid;
private short channels; private readonly short channels;
public SoundCardSource(Guid guid, short channels) public SoundCardSource(Guid guid, short channels)
{ {
this.guid = guid; this.guid = guid;
this.channels = channels; this.channels = channels;
this.waveFormat = new WaveFormat(); waveFormat = new WaveFormat();
this.SampleRateKHz = 44.1; SampleRateKHz = 44.1;
this.bufferSize = 2048; bufferSize = 2048;
} }
public event EventHandler<SampleDataEventArgs> SampleDataReady = delegate { }; public event EventHandler<SampleDataEventArgs> SampleDataReady = delegate { };
public double SampleRateKHz public double SampleRateKHz
{ {
get get { return sampleRate; }
{
return this.sampleRate;
}
set set
{ {
this.sampleRate = value; sampleRate = value;
if (this.running) if (running)
{ Restart();
this.Restart();
}
} }
} }
public void Start() public void Start()
{ {
if (this.running) if (running)
{
throw new InvalidOperationException(); throw new InvalidOperationException();
}
if (this.captureDevice == null) if (captureDevice == null)
{ captureDevice = new DirectSoundCapture(guid);
this.captureDevice = new DirectSoundCapture(guid);
}
this.waveFormat.FormatTag = WaveFormatTag.Pcm; // Change to WaveFormatTag.IeeeFloat for float waveFormat.FormatTag = WaveFormatTag.Pcm; // Change to WaveFormatTag.IeeeFloat for float
this.waveFormat.BitsPerSample = 16; // Set this to 32 for float waveFormat.BitsPerSample = 16; // Set this to 32 for float
this.waveFormat.BlockAlignment = (short)(channels * (waveFormat.BitsPerSample / 8)); waveFormat.BlockAlignment = (short)(channels * (waveFormat.BitsPerSample / 8));
this.waveFormat.Channels = this.channels; waveFormat.Channels = channels;
this.waveFormat.SamplesPerSecond = (int)(this.SampleRateKHz * 1000D); waveFormat.SamplesPerSecond = (int)(SampleRateKHz * 1000D);
this.waveFormat.AverageBytesPerSecond = waveFormat.AverageBytesPerSecond =
this.waveFormat.SamplesPerSecond * waveFormat.SamplesPerSecond *
this.waveFormat.BlockAlignment; waveFormat.BlockAlignment;
this.bufferPortionCount = 2; bufferPortionCount = 2;
this.bufferDescription.BufferBytes = this.bufferSize * sizeof(short) * bufferPortionCount * this.channels; bufferDescription.BufferBytes = bufferSize * sizeof(short) * bufferPortionCount * channels;
this.bufferDescription.Format = this.waveFormat; bufferDescription.Format = waveFormat;
this.bufferDescription.WaveMapped = false; bufferDescription.WaveMapped = false;
this.buffer = new CaptureBuffer(this.captureDevice, this.bufferDescription); buffer = new CaptureBuffer(captureDevice, bufferDescription);
this.bufferPortionSize = this.buffer.SizeInBytes / this.bufferPortionCount; bufferPortionSize = buffer.SizeInBytes / bufferPortionCount;
this.notifications = new List<NotificationPosition>(); notifications = new List<NotificationPosition>();
for (int i = 0; i < this.bufferPortionCount; i++) for (int i = 0; i < bufferPortionCount; i++)
{ {
NotificationPosition notification = new NotificationPosition(); NotificationPosition notification = new NotificationPosition();
notification.Offset = this.bufferPortionCount - 1 + (bufferPortionSize * i); notification.Offset = bufferPortionCount - 1 + (bufferPortionSize * i);
notification.Event = new AutoResetEvent(false); notification.Event = new AutoResetEvent(false);
this.notifications.Add(notification); notifications.Add(notification);
} }
this.buffer.SetNotificationPositions(this.notifications.ToArray()); buffer.SetNotificationPositions(notifications.ToArray());
this.waitHandles = new WaitHandle[this.notifications.Count]; waitHandles = new WaitHandle[notifications.Count];
for (int i = 0; i < this.notifications.Count; i++) for (int i = 0; i < notifications.Count; i++)
{ waitHandles[i] = notifications[i].Event;
this.waitHandles[i] = this.notifications[i].Event;
}
this.captureThread = new Thread(new ThreadStart(this.CaptureThread)); captureThread = new Thread(CaptureThread);
this.captureThread.IsBackground = true; captureThread.IsBackground = true;
this.running = true; running = true;
this.captureThread.Start(); captureThread.Start();
} }
public void Stop() public void Stop()
{ {
this.running = false; running = false;
if (this.captureThread != null) if (captureThread != null)
{ {
this.captureThread.Join(); captureThread.Join();
this.captureThread = null; captureThread = null;
} }
if (this.buffer != null) if (buffer != null)
{ {
this.buffer.Dispose(); buffer.Dispose();
this.buffer = null; buffer = null;
} }
if (this.notifications != null) if (notifications != null)
{ {
for (int i = 0; i < this.notifications.Count; i++) for (int i = 0; i < notifications.Count; i++)
{ notifications[i].Event.Close();
this.notifications[i].Event.Close();
}
this.notifications.Clear(); notifications.Clear();
this.notifications = null; notifications = null;
} }
} }
public void Restart() public void Restart()
{ {
this.Stop(); Stop();
this.Start(); Start();
} }
private void CaptureThread() private void CaptureThread()
{ {
int bufferPortionSamples = this.bufferPortionSize / sizeof(byte); int bufferPortionSamples = bufferPortionSize / sizeof(byte);
// Buffer type must match this.waveFormat.FormatTag and this.waveFormat.BitsPerSample // Buffer type must match this.waveFormat.FormatTag and this.waveFormat.BitsPerSample
byte[] bufferPortion = new byte[bufferPortionSamples]; byte[] bufferPortion = new byte[bufferPortionSamples];
int bufferPortionIndex; int bufferPortionIndex;
this.buffer.Start(true); buffer.Start(true);
while (this.running) while (running)
{ {
bufferPortionIndex = WaitHandle.WaitAny(this.waitHandles); bufferPortionIndex = WaitHandle.WaitAny(waitHandles);
this.buffer.Read( buffer.Read(
bufferPortion, bufferPortion,
0, 0,
bufferPortionSamples, bufferPortionSamples,
bufferPortionSize * Math.Abs((bufferPortionIndex - 1) % bufferPortionCount)); bufferPortionSize * Math.Abs((bufferPortionIndex - 1) % bufferPortionCount));
this.SampleDataReady(this, new SampleDataEventArgs(bufferPortion, guid)); SampleDataReady(this, new SampleDataEventArgs(bufferPortion, guid));
} }
this.buffer.Stop(); buffer.Stop();
} }
public void Dispose() public void Dispose()
{ {
this.Dispose(true); Dispose(true);
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
@@ -422,16 +404,15 @@ namespace Vocaluxe.Lib.Sound
{ {
if (disposing) if (disposing)
{ {
this.Stop(); Stop();
if (this.captureDevice != null) if (captureDevice != null)
{ {
this.captureDevice.Dispose(); captureDevice.Dispose();
this.captureDevice = null; captureDevice = null;
} }
} }
} }
} }
} }
} }
+2 -1
View File
@@ -7,6 +7,7 @@ namespace Vocaluxe.Lib.Sound
class CGstreamerAudio : IPlayback class CGstreamerAudio : IPlayback
{ {
//static float LastPosition; //static float LastPosition;
#region log #region log
public CGstreamerAudioWrapper.LogCallback Log; public CGstreamerAudioWrapper.LogCallback Log;
@@ -19,7 +20,7 @@ namespace Vocaluxe.Lib.Sound
public CGstreamerAudio() public CGstreamerAudio()
{ {
Init(); Init();
Log = new CGstreamerAudioWrapper.LogCallback(LogHandler); Log = LogHandler;
//Is this really needed? CodaAnalyzer complains about it... //Is this really needed? CodaAnalyzer complains about it...
//GC.SuppressFinalize(Log); //GC.SuppressFinalize(Log);
CGstreamerAudioWrapper.SetLogCallback(Log); CGstreamerAudioWrapper.SetLogCallback(Log);
+34 -98
View File
@@ -11,17 +11,16 @@ namespace Vocaluxe.Lib.Sound
{ {
class COpenALPlay : IPlayback, IDisposable class COpenALPlay : IPlayback, IDisposable
{ {
private bool _Initialized = false; private bool _Initialized;
private List<OpenAlStream> _Decoder = new List<OpenAlStream>(); private readonly List<OpenAlStream> _Decoder = new List<OpenAlStream>();
private CLOSEPROC closeproc; private CLOSEPROC closeproc;
private int _Count = 1; private int _Count = 1;
private AudioContext AC; private AudioContext AC;
private Object MutexDecoder = new Object(); private readonly Object MutexDecoder = new Object();
private List<AudioStreams> _Streams; private List<AudioStreams> _Streams;
public COpenALPlay() public COpenALPlay()
{ {
Init(); Init();
@@ -37,7 +36,7 @@ namespace Vocaluxe.Lib.Sound
AC.MakeCurrent(); AC.MakeCurrent();
closeproc = new CLOSEPROC(close_proc); closeproc = close_proc;
_Initialized = true; _Initialized = true;
_Streams = new List<AudioStreams>(); _Streams = new List<AudioStreams>();
@@ -49,11 +48,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
for (int i = 0; i < _Decoder.Count; i++) for (int i = 0; i < _Decoder.Count; i++)
{
_Decoder[i].Free(closeproc, i + 1, MutexDecoder); _Decoder[i].Free(closeproc, i + 1, MutexDecoder);
} }
} }
}
public void SetGlobalVolume(float Volume) public void SetGlobalVolume(float Volume)
{ {
@@ -81,12 +78,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
foreach (OpenAlStream stream in _Decoder) foreach (OpenAlStream stream in _Decoder)
{
stream.UploadData(); stream.UploadData();
} }
} }
}
} }
#region Stream Handling #region Stream Handling
@@ -110,7 +104,6 @@ namespace Vocaluxe.Lib.Sound
_Streams.Add(stream); _Streams.Add(stream);
return stream.handle; return stream.handle;
} }
} }
return 0; return 0;
} }
@@ -122,12 +115,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Free(closeproc, Stream, MutexDecoder); _Decoder[GetStreamIndex(Stream)].Free(closeproc, Stream, MutexDecoder);
} }
} }
}
} }
public void Play(int Stream) public void Play(int Stream)
@@ -147,7 +137,6 @@ namespace Vocaluxe.Lib.Sound
_Decoder[GetStreamIndex(Stream)].Play(); _Decoder[GetStreamIndex(Stream)].Play();
} }
} }
} }
} }
@@ -158,12 +147,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Paused = true; _Decoder[GetStreamIndex(Stream)].Paused = true;
} }
} }
}
} }
public void Stop(int Stream) public void Stop(int Stream)
@@ -178,12 +164,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Fade(TargetVolume, Seconds); _Decoder[GetStreamIndex(Stream)].Fade(TargetVolume, Seconds);
} }
} }
}
} }
public void FadeAndPause(int Stream, float TargetVolume, float Seconds) public void FadeAndPause(int Stream, float TargetVolume, float Seconds)
@@ -193,12 +176,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].FadeAndPause(TargetVolume, Seconds); _Decoder[GetStreamIndex(Stream)].FadeAndPause(TargetVolume, Seconds);
} }
} }
}
} }
public void FadeAndStop(int Stream, float TargetVolume, float Seconds) public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
@@ -208,12 +188,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].FadeAndStop(TargetVolume, Seconds, closeproc, Stream); _Decoder[GetStreamIndex(Stream)].FadeAndStop(TargetVolume, Seconds, closeproc, Stream);
} }
} }
}
} }
public void SetStreamVolume(int Stream, float Volume) public void SetStreamVolume(int Stream, float Volume)
@@ -223,12 +200,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Volume = Volume; _Decoder[GetStreamIndex(Stream)].Volume = Volume;
} }
} }
}
} }
public void SetStreamVolumeMax(int Stream, float Volume) public void SetStreamVolumeMax(int Stream, float Volume)
@@ -238,12 +212,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].VolumeMax = Volume; _Decoder[GetStreamIndex(Stream)].VolumeMax = Volume;
} }
} }
}
} }
public float GetLength(int Stream) public float GetLength(int Stream)
@@ -253,12 +224,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return _Decoder[GetStreamIndex(Stream)].Length; return _Decoder[GetStreamIndex(Stream)].Length;
} }
} }
}
return 0f; return 0f;
} }
@@ -269,10 +237,8 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return _Decoder[GetStreamIndex(Stream)].Position; return _Decoder[GetStreamIndex(Stream)].Position;
} }
}
return 0f; return 0f;
} }
@@ -286,12 +252,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return !_Decoder[GetStreamIndex(Stream)].Paused && !_Decoder[GetStreamIndex(Stream)].Finished; return !_Decoder[GetStreamIndex(Stream)].Paused && !_Decoder[GetStreamIndex(Stream)].Finished;
} }
} }
}
return false; return false;
} }
@@ -302,12 +265,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return _Decoder[GetStreamIndex(Stream)].Paused; return _Decoder[GetStreamIndex(Stream)].Paused;
} }
} }
}
return false; return false;
} }
@@ -318,12 +278,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return _Decoder[GetStreamIndex(Stream)].Finished; return _Decoder[GetStreamIndex(Stream)].Finished;
} }
} }
}
return true; return true;
} }
@@ -334,25 +291,19 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Skip(Position); _Decoder[GetStreamIndex(Stream)].Skip(Position);
} }
} }
}
} }
#endregion Stream Handling #endregion Stream Handling
private bool AlreadyAdded(int Stream) private bool AlreadyAdded(int Stream)
{ {
foreach (AudioStreams st in _Streams) foreach (AudioStreams st in _Streams)
{ {
if (st.handle == Stream) if (st.handle == Stream)
{
return true; return true;
} }
}
return false; return false;
} }
@@ -371,11 +322,9 @@ namespace Vocaluxe.Lib.Sound
if (_Initialized) if (_Initialized)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
Close(Stream); Close(Stream);
} }
} }
}
private void close_proc(int StreamID) private void close_proc(int StreamID)
{ {
@@ -390,7 +339,6 @@ namespace Vocaluxe.Lib.Sound
_Streams.RemoveAt(Index); _Streams.RemoveAt(Index);
} }
} }
} }
} }
@@ -403,11 +351,11 @@ namespace Vocaluxe.Lib.Sound
class OpenAlStream : IDisposable class OpenAlStream : IDisposable
{ {
const int buffer_size = 2048; private const int buffer_size = 2048;
const int buffer_count = 5; private const int buffer_count = 5;
const long BUFSIZE = 50000L; private const long BUFSIZE = 50000L;
Object CloseMutex; private Object CloseMutex;
private int[] _buffers; private int[] _buffers;
private int _state; private int _state;
@@ -419,52 +367,50 @@ namespace Vocaluxe.Lib.Sound
private float _Volume = 1f; private float _Volume = 1f;
private float _VolumeMax = 1f; private float _VolumeMax = 1f;
private Stopwatch _fadeTimer = new Stopwatch(); private readonly Stopwatch _fadeTimer = new Stopwatch();
private float _fadeTime = 0f; private float _fadeTime;
private float _targetVolume = 1f; private float _targetVolume = 1f;
private float _startVolume = 1f; private float _startVolume = 1f;
private bool _closeStreamAfterFade = false; private bool _closeStreamAfterFade;
private bool _pauseStreamAfterFade = false; private bool _pauseStreamAfterFade;
private bool _fading = false; private bool _fading;
private Stopwatch _FadeTimer = new Stopwatch(); private Stopwatch _FadeTimer = new Stopwatch();
private Stopwatch _Timer = new Stopwatch(); private readonly Stopwatch _Timer = new Stopwatch();
private CLOSEPROC _Closeproc; private CLOSEPROC _Closeproc;
private int _StreamID; private int _StreamID;
private string _FileName; private string _FileName;
private IAudioDecoder _Decoder; private IAudioDecoder _Decoder;
private float _BytesPerSecond; private float _BytesPerSecond;
private bool _NoMoreData = false; private bool _NoMoreData;
private bool _FileOpened;
private bool _FileOpened = false; private bool _waiting;
private bool _skip;
private bool _waiting = false; private bool _Loop;
private bool _skip = false; private float _Duration;
private float _CurrentTime;
private float _TimeCode;
private bool _Loop = false; private bool _Paused;
private float _Duration = 0f;
private float _CurrentTime = 0f;
private float _TimeCode = 0f;
private bool _Paused = false;
private RingBuffer _data; private RingBuffer _data;
private float _SetStart = 0f; private float _SetStart;
private float _Start = 0f; private float _Start;
private bool _SetLoop = false; private bool _SetLoop;
private bool _SetSkip = false; private bool _SetSkip;
private bool _terminated = false; private bool _terminated;
private Thread _DecoderThread; private readonly Thread _DecoderThread;
AutoResetEvent EventDecode = new AutoResetEvent(false); private AutoResetEvent EventDecode = new AutoResetEvent(false);
Object MutexData = new Object(); private readonly Object MutexData = new Object();
Object MutexSyncSignals = new Object(); private readonly Object MutexSyncSignals = new Object();
public OpenAlStream() public OpenAlStream()
{ {
@@ -619,7 +565,7 @@ namespace Vocaluxe.Lib.Sound
if (_FileOpened) if (_FileOpened)
return -1; return -1;
if (!System.IO.File.Exists(FileName)) if (!File.Exists(FileName))
return -1; return -1;
if (_FileOpened) if (_FileOpened)
@@ -633,9 +579,7 @@ namespace Vocaluxe.Lib.Sound
_source = AL.GenSource(); _source = AL.GenSource();
_buffers = new int[buffer_count]; _buffers = new int[buffer_count];
for (int i = 0; i < buffer_count; i++) for (int i = 0; i < buffer_count; i++)
{
_buffers[i] = AL.GenBuffer(); _buffers[i] = AL.GenBuffer();
}
_state = 0; _state = 0;
//AL.SourceQueueBuffers(_source, _buffers.Length, _buffers); //AL.SourceQueueBuffers(_source, _buffers.Length, _buffers);
@@ -676,7 +620,6 @@ namespace Vocaluxe.Lib.Sound
return -1; return -1;
} }
public bool Skip(float Time) public bool Skip(float Time)
{ {
lock (MutexSyncSignals) lock (MutexSyncSignals)
@@ -719,7 +662,6 @@ namespace Vocaluxe.Lib.Sound
} }
DoDecode(); DoDecode();
} }
if (!_terminated) if (!_terminated)
{ {
@@ -734,7 +676,6 @@ namespace Vocaluxe.Lib.Sound
_Loop = _SetLoop; _Loop = _SetLoop;
} }
} }
} }
DoFree(); DoFree();
@@ -779,9 +720,7 @@ namespace Vocaluxe.Lib.Sound
DoSkip(); DoSkip();
} }
else else
{
_NoMoreData = true; _NoMoreData = true;
}
return; return;
} }
@@ -812,7 +751,7 @@ namespace Vocaluxe.Lib.Sound
{ {
if (_fading) if (_fading)
{ {
if ((float)_fadeTimer.ElapsedMilliseconds / 1000f < _fadeTime) if (_fadeTimer.ElapsedMilliseconds / 1000f < _fadeTime)
_Volume = _startVolume + (_targetVolume - _startVolume) * ((_fadeTimer.ElapsedMilliseconds / 1000f) / _fadeTime); _Volume = _startVolume + (_targetVolume - _startVolume) * ((_fadeTimer.ElapsedMilliseconds / 1000f) / _fadeTime);
else else
{ {
@@ -906,10 +845,8 @@ namespace Vocaluxe.Lib.Sound
} }
AL.GetSource(_source, ALGetSourcei.SourceState, out _state); AL.GetSource(_source, ALGetSourcei.SourceState, out _state);
if ((ALSourceState)_state != ALSourceState.Playing) if ((ALSourceState)_state != ALSourceState.Playing)
{
AL.SourcePlay(_source); AL.SourcePlay(_source);
} }
}
_CurrentTime = _TimeCode - _data.BytesNotRead / _BytesPerSecond - 0.1f; _CurrentTime = _TimeCode - _data.BytesNotRead / _BytesPerSecond - 0.1f;
_Timer.Reset(); _Timer.Reset();
@@ -923,4 +860,3 @@ namespace Vocaluxe.Lib.Sound
} }
} }
} }
+2 -5
View File
@@ -1,7 +1,4 @@
namespace Vocaluxe.Lib.Sound
namespace Vocaluxe.Lib.Sound
{
class COpenALRecord
{ {
} class COpenALRecord {}
} }
+36 -91
View File
@@ -12,16 +12,15 @@ namespace Vocaluxe.Lib.Sound
{ {
class CPortAudioPlay : IPlayback class CPortAudioPlay : IPlayback
{ {
private bool _Initialized = false; private bool _Initialized;
private List<PortAudioStream> _Decoder = new List<PortAudioStream>(); private readonly List<PortAudioStream> _Decoder = new List<PortAudioStream>();
private CLOSEPROC closeproc; private CLOSEPROC closeproc;
private int _Count = 1; private int _Count = 1;
private Object MutexDecoder = new Object(); private readonly Object MutexDecoder = new Object();
private List<AudioStreams> _Streams; private List<AudioStreams> _Streams;
public CPortAudioPlay() public CPortAudioPlay()
{ {
Init(); Init();
@@ -32,7 +31,7 @@ namespace Vocaluxe.Lib.Sound
if (_Initialized) if (_Initialized)
CloseAll(); CloseAll();
closeproc = new CLOSEPROC(close_proc); closeproc = close_proc;
_Initialized = true; _Initialized = true;
_Streams = new List<AudioStreams>(); _Streams = new List<AudioStreams>();
@@ -44,11 +43,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
for (int i = 0; i < _Decoder.Count; i++) for (int i = 0; i < _Decoder.Count; i++)
{
_Decoder[i].Free(closeproc, i + 1); _Decoder[i].Free(closeproc, i + 1);
} }
} }
}
public void SetGlobalVolume(float Volume) public void SetGlobalVolume(float Volume)
{ {
@@ -69,9 +66,7 @@ namespace Vocaluxe.Lib.Sound
} }
} }
public void Update() public void Update() {}
{
}
#region Stream Handling #region Stream Handling
public int Load(string Media) public int Load(string Media)
@@ -94,7 +89,6 @@ namespace Vocaluxe.Lib.Sound
_Streams.Add(stream); _Streams.Add(stream);
return stream.handle; return stream.handle;
} }
} }
return 0; return 0;
} }
@@ -106,12 +100,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Free(closeproc, Stream); _Decoder[GetStreamIndex(Stream)].Free(closeproc, Stream);
} }
} }
}
} }
public void Play(int Stream) public void Play(int Stream)
@@ -131,7 +122,6 @@ namespace Vocaluxe.Lib.Sound
_Decoder[GetStreamIndex(Stream)].Play(); _Decoder[GetStreamIndex(Stream)].Play();
} }
} }
} }
} }
@@ -142,12 +132,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Paused = true; _Decoder[GetStreamIndex(Stream)].Paused = true;
} }
} }
}
} }
public void Stop(int Stream) public void Stop(int Stream)
@@ -162,12 +149,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Fade(TargetVolume, Seconds); _Decoder[GetStreamIndex(Stream)].Fade(TargetVolume, Seconds);
} }
} }
}
} }
public void FadeAndPause(int Stream, float TargetVolume, float Seconds) public void FadeAndPause(int Stream, float TargetVolume, float Seconds)
@@ -177,12 +161,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].FadeAndPause(TargetVolume, Seconds); _Decoder[GetStreamIndex(Stream)].FadeAndPause(TargetVolume, Seconds);
} }
} }
}
} }
public void FadeAndStop(int Stream, float TargetVolume, float Seconds) public void FadeAndStop(int Stream, float TargetVolume, float Seconds)
@@ -192,12 +173,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].FadeAndStop(TargetVolume, Seconds, closeproc, Stream); _Decoder[GetStreamIndex(Stream)].FadeAndStop(TargetVolume, Seconds, closeproc, Stream);
} }
} }
}
} }
public void SetStreamVolume(int Stream, float Volume) public void SetStreamVolume(int Stream, float Volume)
@@ -207,12 +185,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Volume = Volume; _Decoder[GetStreamIndex(Stream)].Volume = Volume;
} }
} }
}
} }
public void SetStreamVolumeMax(int Stream, float Volume) public void SetStreamVolumeMax(int Stream, float Volume)
@@ -222,12 +197,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].VolumeMax = Volume; _Decoder[GetStreamIndex(Stream)].VolumeMax = Volume;
} }
} }
}
} }
public float GetLength(int Stream) public float GetLength(int Stream)
@@ -237,12 +209,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return _Decoder[GetStreamIndex(Stream)].Length; return _Decoder[GetStreamIndex(Stream)].Length;
} }
} }
}
return 0f; return 0f;
} }
@@ -253,10 +222,8 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return _Decoder[GetStreamIndex(Stream)].Position; return _Decoder[GetStreamIndex(Stream)].Position;
} }
}
return 0f; return 0f;
} }
@@ -270,12 +237,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return !_Decoder[GetStreamIndex(Stream)].Paused && !_Decoder[GetStreamIndex(Stream)].Finished; return !_Decoder[GetStreamIndex(Stream)].Paused && !_Decoder[GetStreamIndex(Stream)].Finished;
} }
} }
}
return false; return false;
} }
@@ -286,12 +250,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return _Decoder[GetStreamIndex(Stream)].Paused; return _Decoder[GetStreamIndex(Stream)].Paused;
} }
} }
}
return false; return false;
} }
@@ -302,12 +263,9 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
return _Decoder[GetStreamIndex(Stream)].Finished; return _Decoder[GetStreamIndex(Stream)].Finished;
} }
} }
}
return true; return true;
} }
@@ -318,25 +276,19 @@ namespace Vocaluxe.Lib.Sound
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
_Decoder[GetStreamIndex(Stream)].Skip(Position); _Decoder[GetStreamIndex(Stream)].Skip(Position);
} }
} }
}
} }
#endregion Stream Handling #endregion Stream Handling
private bool AlreadyAdded(int Stream) private bool AlreadyAdded(int Stream)
{ {
foreach (AudioStreams st in _Streams) foreach (AudioStreams st in _Streams)
{ {
if (st.handle == Stream) if (st.handle == Stream)
{
return true; return true;
} }
}
return false; return false;
} }
@@ -355,11 +307,9 @@ namespace Vocaluxe.Lib.Sound
if (_Initialized) if (_Initialized)
{ {
if (AlreadyAdded(Stream)) if (AlreadyAdded(Stream))
{
Close(Stream); Close(Stream);
} }
} }
}
private void close_proc(int StreamID) private void close_proc(int StreamID)
{ {
@@ -374,33 +324,31 @@ namespace Vocaluxe.Lib.Sound
_Streams.RemoveAt(Index); _Streams.RemoveAt(Index);
} }
} }
} }
} }
} }
class PortAudioStream : IDisposable class PortAudioStream : IDisposable
{ {
const long BUFSIZE = 1000000L; private const long BUFSIZE = 1000000L;
const long BEGINREFILL = 800000L; private const long BEGINREFILL = 800000L;
private CSyncTimer _SyncTimer; private readonly CSyncTimer _SyncTimer;
private static bool _Initialized = false; private static bool _Initialized;
private static int _NumStreams = 0; private static int _NumStreams;
private static Object _Mutex = new object(); private static readonly Object _Mutex = new object();
private int _ByteCount = 4; private int _ByteCount = 4;
private float _Volume = 1f; private float _Volume = 1f;
private float _VolumeMax = 1f; private float _VolumeMax = 1f;
private Stopwatch _fadeTimer = new Stopwatch(); private readonly Stopwatch _fadeTimer = new Stopwatch();
private float _fadeTime = 0f; private float _fadeTime;
private float _targetVolume = 1f; private float _targetVolume = 1f;
private float _startVolume = 1f; private float _startVolume = 1f;
private bool _closeStreamAfterFade = false; private bool _closeStreamAfterFade;
private bool _pauseStreamAfterFade = false; private bool _pauseStreamAfterFade;
private bool _fading = false; private bool _fading;
private static PortAudio.PaHostApiInfo _apiInfo; private static PortAudio.PaHostApiInfo _apiInfo;
private static PortAudio.PaDeviceInfo _outputDeviceInfo; private static PortAudio.PaDeviceInfo _outputDeviceInfo;
@@ -414,34 +362,33 @@ namespace Vocaluxe.Lib.Sound
private string _FileName; private string _FileName;
private IAudioDecoder _Decoder; private IAudioDecoder _Decoder;
private float _BytesPerSecond; private float _BytesPerSecond;
private bool _NoMoreData = false; private bool _NoMoreData;
private bool _FileOpened;
private bool _FileOpened = false; private bool _waiting;
private bool _skip;
private bool _waiting = false; private bool _Loop;
private bool _skip = false; private float _Duration;
private float _CurrentTime;
private float _TimeCode;
private bool _Loop = false; private bool _Paused;
private float _Duration = 0f;
private float _CurrentTime = 0f;
private float _TimeCode = 0f;
private bool _Paused = false;
private RingBuffer _data; private RingBuffer _data;
private float _SetStart = 0f; private float _SetStart;
private float _Start = 0f; private float _Start;
private bool _SetLoop = false; private bool _SetLoop;
private bool _SetSkip = false; private bool _SetSkip;
private bool _terminated = false; private bool _terminated;
private Thread _DecoderThread; private readonly Thread _DecoderThread;
private AutoResetEvent EventDecode = new AutoResetEvent(false); private AutoResetEvent EventDecode = new AutoResetEvent(false);
private Object _LockData = new Object(); private readonly Object _LockData = new Object();
private Object _LockSyncSignals = new Object(); private readonly Object _LockSyncSignals = new Object();
public PortAudioStream() public PortAudioStream()
{ {
@@ -607,7 +554,7 @@ namespace Vocaluxe.Lib.Sound
if (_FileOpened) if (_FileOpened)
return -1; return -1;
if (!System.IO.File.Exists(FileName)) if (!File.Exists(FileName))
return -1; return -1;
if (_FileOpened) if (_FileOpened)
@@ -634,7 +581,7 @@ namespace Vocaluxe.Lib.Sound
} }
} }
_paStreamCallback = new PortAudio.PaStreamCallbackDelegate(_PaStreamCallback); _paStreamCallback = _PaStreamCallback;
} }
catch (Exception) catch (Exception)
@@ -805,9 +752,7 @@ namespace Vocaluxe.Lib.Sound
DoSkip(); DoSkip();
} }
else else
{
_NoMoreData = true; _NoMoreData = true;
}
return; return;
} }
@@ -967,7 +912,7 @@ namespace Vocaluxe.Lib.Sound
{ {
if (_fading) if (_fading)
{ {
if ((float)_fadeTimer.ElapsedMilliseconds / 1000f < _fadeTime) if (_fadeTimer.ElapsedMilliseconds / 1000f < _fadeTime)
_Volume = _startVolume + (_targetVolume - _startVolume) * ((_fadeTimer.ElapsedMilliseconds / 1000f) / _fadeTime); _Volume = _startVolume + (_targetVolume - _startVolume) * ((_fadeTimer.ElapsedMilliseconds / 1000f) / _fadeTime);
else else
{ {
+8 -16
View File
@@ -1,4 +1,5 @@
using PortAudioSharp; using System.Threading;
using PortAudioSharp;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -8,15 +9,14 @@ namespace Vocaluxe.Lib.Sound
{ {
class CPortAudioRecord : IRecord class CPortAudioRecord : IRecord
{ {
private bool _initialized = false; private bool _initialized;
private List<SRecordDevice> _Devices = null; private List<SRecordDevice> _Devices;
private SRecordDevice[] _DeviceConfig; private SRecordDevice[] _DeviceConfig;
private PortAudio.PaStreamCallbackDelegate _myRecProc; private PortAudio.PaStreamCallbackDelegate _myRecProc;
private IntPtr[] _recHandle; private IntPtr[] _recHandle;
private CBuffer[] _Buffer; private readonly CBuffer[] _Buffer;
public CPortAudioRecord() public CPortAudioRecord()
{ {
@@ -24,9 +24,7 @@ namespace Vocaluxe.Lib.Sound
_Buffer = new CBuffer[CSettings.MaxNumPlayer]; _Buffer = new CBuffer[CSettings.MaxNumPlayer];
for (int i = 0; i < _Buffer.Length; i++) for (int i = 0; i < _Buffer.Length; i++)
{
_Buffer[i] = new CBuffer(); _Buffer[i] = new CBuffer();
}
Init(); Init();
} }
@@ -76,7 +74,7 @@ namespace Vocaluxe.Lib.Sound
} }
_recHandle = new IntPtr[_Devices.Count]; _recHandle = new IntPtr[_Devices.Count];
_myRecProc = new PortAudio.PaStreamCallbackDelegate(myPaStreamCallback); _myRecProc = myPaStreamCallback;
_DeviceConfig = _Devices.ToArray(); _DeviceConfig = _Devices.ToArray();
} }
@@ -110,24 +108,20 @@ namespace Vocaluxe.Lib.Sound
return false; return false;
for (int i = 0; i < _Buffer.Length; i++) for (int i = 0; i < _Buffer.Length; i++)
{
_Buffer[i].Reset(); _Buffer[i].Reset();
}
for (int i = 0; i < _recHandle.Length; i++) for (int i = 0; i < _recHandle.Length; i++)
{ {
int waitcount = 0; int waitcount = 0;
while (waitcount < 5 && PortAudio.Pa_IsStreamStopped(_recHandle[i]) == PortAudio.PaError.paStreamIsNotStopped) while (waitcount < 5 && PortAudio.Pa_IsStreamStopped(_recHandle[i]) == PortAudio.PaError.paStreamIsNotStopped)
{ {
System.Threading.Thread.Sleep(1); Thread.Sleep(1);
waitcount++; waitcount++;
} }
} }
for (int i = 0; i < _recHandle.Length; i++) for (int i = 0; i < _recHandle.Length; i++)
{
_recHandle[i] = IntPtr.Zero; _recHandle[i] = IntPtr.Zero;
}
_DeviceConfig = DeviceConfig; _DeviceConfig = DeviceConfig;
bool[] active = new bool[DeviceConfig.Length]; bool[] active = new bool[DeviceConfig.Length];
@@ -181,9 +175,7 @@ namespace Vocaluxe.Lib.Sound
return false; return false;
for (int i = 0; i < _recHandle.Length; i++) for (int i = 0; i < _recHandle.Length; i++)
{
PortAudio.Pa_StopStream(_recHandle[i]); PortAudio.Pa_StopStream(_recHandle[i]);
}
return true; return true;
} }
@@ -326,7 +318,7 @@ namespace Vocaluxe.Lib.Sound
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Error on Stream Callback (rec): " + e.ToString()); CLog.LogError("Error on Stream Callback (rec): " + e);
} }
return PortAudio.PaStreamCallbackResult.paContinue; return PortAudio.PaStreamCallbackResult.paContinue;
+5 -14
View File
@@ -1,26 +1,19 @@
namespace Vocaluxe.Lib.Sound.Decoder
namespace Vocaluxe.Lib.Sound.Decoder
{ {
abstract class CAudioDecoder : IAudioDecoder abstract class CAudioDecoder : IAudioDecoder
{ {
protected bool _Initialized; protected bool _Initialized;
public virtual void Init() public virtual void Init() {}
{
}
public virtual void Close() public virtual void Close() {}
{
}
public void Open(string FileName) public void Open(string FileName)
{ {
Open(FileName, false); Open(FileName, false);
} }
public virtual void Open(string FileName, bool Loop) public virtual void Open(string FileName, bool Loop) {}
{
}
public virtual FormatInfo GetFormatInfo() public virtual FormatInfo GetFormatInfo()
{ {
@@ -32,9 +25,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
return 0f; return 0f;
} }
public virtual void SetPosition(float Time) public virtual void SetPosition(float Time) {}
{
}
public virtual float GetPosition() public virtual float GetPosition()
{ {
@@ -1,7 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.Lib.Video.Acinerella; using Vocaluxe.Lib.Video.Acinerella;
@@ -21,12 +20,12 @@ namespace Vocaluxe.Lib.Sound.Decoder
private float _CurrentTime; private float _CurrentTime;
private string _FileName; private string _FileName;
private bool _FileOpened = false; private bool _FileOpened;
public override void Init() public override void Init()
{ {
_rc = new TAc_read_callback(read_proc); _rc = read_proc;
_sc = new TAc_seek_callback(seek_proc); _sc = seek_proc;
_FileOpened = false; _FileOpened = false;
@@ -134,7 +133,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
if (!_Initialized && !_FileOpened) if (!_Initialized && !_FileOpened)
return 0f; return 0f;
return (float)_Instance.info.duration / 1000f; return _Instance.info.duration / 1000f;
} }
public override void SetPosition(float Time) public override void SetPosition(float Time)
@@ -214,7 +213,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
private Int64 seek_proc(IntPtr sender, Int64 pos, Int32 whence) private Int64 seek_proc(IntPtr sender, Int64 pos, Int32 whence)
{ {
return (Int64)_fs.Seek((long)pos, (SeekOrigin)whence); return _fs.Seek(pos, (SeekOrigin)whence);
} }
#endregion Callbacks #endregion Callbacks
+1 -2
View File
@@ -1,5 +1,4 @@
namespace Vocaluxe.Lib.Sound.Decoder
namespace Vocaluxe.Lib.Sound.Decoder
{ {
struct FormatInfo struct FormatInfo
{ {
@@ -17,7 +17,9 @@ namespace Vocaluxe.Lib.Sound.Gstreamer
#endif #endif
#endif #endif
#endregion arch #endregion arch
public delegate void LogCallback(string message); public delegate void LogCallback(string message);
[DllImport(Dll)] [DllImport(Dll)]
public static extern void SetLogCallback(LogCallback c); public static extern void SetLogCallback(LogCallback c);
+3 -6
View File
@@ -53,18 +53,15 @@ namespace Vocaluxe.Lib.Sound
class RingBuffer class RingBuffer
{ {
private byte[] _data; private readonly byte[] _data;
private long _size; private readonly long _size;
private long _readPos; private long _readPos;
private long _writePos; private long _writePos;
private long _bytesNotRead; private long _bytesNotRead;
public long BytesNotRead public long BytesNotRead
{ {
get get { return _bytesNotRead; }
{
return _bytesNotRead;
}
} }
public RingBuffer(long size) public RingBuffer(long size)
+57 -55
View File
@@ -23,18 +23,17 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace PortAudioSharp
namespace PortAudioSharp { {
/** /**
<summary> <summary>
PortAudio v.19 bindings for .NET PortAudio v.19 bindings for .NET
</summary> </summary>
*/ */
public partial class PortAudio public partial class PortAudio
{ {
#region **** PORTAUDIO CALLBACKS **** #region **** PORTAUDIO CALLBACKS ****
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate PaStreamCallbackResult PaStreamCallbackDelegate( public delegate PaStreamCallbackResult PaStreamCallbackDelegate(
IntPtr input, IntPtr input,
@@ -46,17 +45,14 @@ namespace PortAudioSharp {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void PaStreamFinishedCallbackDelegate(IntPtr userData); public delegate void PaStreamFinishedCallbackDelegate(IntPtr userData);
#endregion #endregion
#region **** PORTAUDIO DATA STRUCTURES **** #region **** PORTAUDIO DATA STRUCTURES ****
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PaDeviceInfo { public struct PaDeviceInfo
{
public int structVersion; public int structVersion;
[MarshalAs (UnmanagedType.LPStr)] [MarshalAs(UnmanagedType.LPStr)] public string name;
public string name;
public int hostApi; public int hostApi;
public int maxInputChannels; public int maxInputChannels;
public int maxOutputChannels; public int maxOutputChannels;
@@ -66,8 +62,9 @@ namespace PortAudioSharp {
public double defaultHighOutputLatency; public double defaultHighOutputLatency;
public double defaultSampleRate; public double defaultSampleRate;
public override string ToString() { public override string ToString()
return "[" + this.GetType().Name + "]" + "\n" {
return "[" + GetType().Name + "]" + "\n"
+ "name: " + name + "\n" + "name: " + name + "\n"
+ "hostApi: " + hostApi + "\n" + "hostApi: " + hostApi + "\n"
+ "maxInputChannels: " + maxInputChannels + "\n" + "maxInputChannels: " + maxInputChannels + "\n"
@@ -81,18 +78,18 @@ namespace PortAudioSharp {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PaHostApiInfo { public struct PaHostApiInfo
{
public int structVersion; public int structVersion;
public PaHostApiTypeId type; public PaHostApiTypeId type;
[MarshalAs (UnmanagedType.LPStr)] [MarshalAs(UnmanagedType.LPStr)] public string name;
public string name;
public int deviceCount; public int deviceCount;
public int defaultInputDevice; public int defaultInputDevice;
public int defaultOutputDevice; public int defaultOutputDevice;
public override string ToString() { public override string ToString()
return "[" + this.GetType().Name + "]" + "\n" {
return "[" + GetType().Name + "]" + "\n"
+ "structVersion: " + structVersion + "\n" + "structVersion: " + structVersion + "\n"
+ "type: " + type + "\n" + "type: " + type + "\n"
+ "name: " + name + "\n" + "name: " + name + "\n"
@@ -103,15 +100,15 @@ namespace PortAudioSharp {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PaHostErrorInfo { public struct PaHostErrorInfo
{
public PaHostApiTypeId hostApiType; public PaHostApiTypeId hostApiType;
public int errorCode; public int errorCode;
[MarshalAs (UnmanagedType.LPStr)] [MarshalAs(UnmanagedType.LPStr)] public string errorText;
public string errorText;
public override string ToString() { public override string ToString()
return "[" + this.GetType().Name + "]" + "\n" {
return "[" + GetType().Name + "]" + "\n"
+ "hostApiType: " + hostApiType + "\n" + "hostApiType: " + hostApiType + "\n"
+ "errorCode: " + errorCode + "\n" + "errorCode: " + errorCode + "\n"
+ "errorText: " + errorText; + "errorText: " + errorText;
@@ -119,14 +116,15 @@ namespace PortAudioSharp {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PaStreamCallbackTimeInfo { public struct PaStreamCallbackTimeInfo
{
public double inputBufferAdcTime; public double inputBufferAdcTime;
public double currentTime; public double currentTime;
public double outputBufferDacTime; public double outputBufferDacTime;
public override string ToString() { public override string ToString()
return "[" + this.GetType().Name + "]" + "\n" {
return "[" + GetType().Name + "]" + "\n"
+ "currentTime: " + currentTime + "\n" + "currentTime: " + currentTime + "\n"
+ "inputBufferAdcTime: " + inputBufferAdcTime + "\n" + "inputBufferAdcTime: " + inputBufferAdcTime + "\n"
+ "outputBufferDacTime: " + outputBufferDacTime; + "outputBufferDacTime: " + outputBufferDacTime;
@@ -134,15 +132,16 @@ namespace PortAudioSharp {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PaStreamInfo { public struct PaStreamInfo
{
public int structVersion; public int structVersion;
public double inputLatency; public double inputLatency;
public double outputLatency; public double outputLatency;
public double sampleRate; public double sampleRate;
public override string ToString() { public override string ToString()
return "[" + this.GetType().Name + "]" + "\n" {
return "[" + GetType().Name + "]" + "\n"
+ "structVersion: " + structVersion + "\n" + "structVersion: " + structVersion + "\n"
+ "inputLatency: " + inputLatency + "\n" + "inputLatency: " + inputLatency + "\n"
+ "outputLatency: " + outputLatency + "\n" + "outputLatency: " + outputLatency + "\n"
@@ -151,28 +150,27 @@ namespace PortAudioSharp {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PaStreamParameters { public struct PaStreamParameters
{
public int device; public int device;
public int channelCount; public int channelCount;
public PaSampleFormat sampleFormat; public PaSampleFormat sampleFormat;
public double suggestedLatency; public double suggestedLatency;
internal IntPtr hostApiSpecificStreamInfo; internal IntPtr hostApiSpecificStreamInfo;
public override string ToString() { public override string ToString()
return "[" + this.GetType().Name + "]" + "\n" {
return "[" + GetType().Name + "]" + "\n"
+ "device: " + device + "\n" + "device: " + device + "\n"
+ "channelCount: " + channelCount + "\n" + "channelCount: " + channelCount + "\n"
+ "sampleFormat: " + sampleFormat + "\n" + "sampleFormat: " + sampleFormat + "\n"
+ "suggestedLatency: " + suggestedLatency; + "suggestedLatency: " + suggestedLatency;
} }
} }
#endregion #endregion
#region **** PORTAUDIO DEFINES **** #region **** PORTAUDIO DEFINES ****
public enum PaDeviceIndex
public enum PaDeviceIndex: int
{ {
paNoDevice = -1, paNoDevice = -1,
paUseHostApiSpecificDeviceSpecification = -2 paUseHostApiSpecificDeviceSpecification = -2
@@ -211,12 +209,11 @@ namespace PortAudioSharp {
paOutputOverflow = 0x00000008, paOutputOverflow = 0x00000008,
paPrimingOutput = 0x00000010 paPrimingOutput = 0x00000010
} }
#endregion #endregion
#region **** PORTAUDIO ENUMERATIONS **** #region **** PORTAUDIO ENUMERATIONS ****
public enum PaError
public enum PaError : int { {
paNoError = 0, paNoError = 0,
paNotInitialized = -10000, paNotInitialized = -10000,
paUnanticipatedHostError, paUnanticipatedHostError,
@@ -249,7 +246,8 @@ namespace PortAudioSharp {
paBadBufferPtr paBadBufferPtr
} }
public enum PaHostApiTypeId : uint { public enum PaHostApiTypeId : uint
{
paInDevelopment = 0, paInDevelopment = 0,
paDirectSound = 1, paDirectSound = 1,
paMME = 2, paMME = 2,
@@ -266,12 +264,12 @@ namespace PortAudioSharp {
paAudioScienceHPI = 14 paAudioScienceHPI = 14
} }
public enum PaStreamCallbackResult : uint { public enum PaStreamCallbackResult : uint
{
paContinue = 0, paContinue = 0,
paComplete = 1, paComplete = 1,
paAbort = 2 paAbort = 2
} }
#endregion #endregion
#region **** PORTAUDIO FUNCTIONS **** #region **** PORTAUDIO FUNCTIONS ****
@@ -301,7 +299,8 @@ namespace PortAudioSharp {
[DllImport(PaDll, EntryPoint = "Pa_GetVersionText")] [DllImport(PaDll, EntryPoint = "Pa_GetVersionText")]
private static extern IntPtr IntPtr_Pa_GetVersionText(); private static extern IntPtr IntPtr_Pa_GetVersionText();
public static string Pa_GetVersionText() { public static string Pa_GetVersionText()
{
IntPtr strptr = IntPtr_Pa_GetVersionText(); IntPtr strptr = IntPtr_Pa_GetVersionText();
return Marshal.PtrToStringAnsi(strptr); return Marshal.PtrToStringAnsi(strptr);
} }
@@ -309,7 +308,8 @@ namespace PortAudioSharp {
[DllImport(PaDll, EntryPoint = "Pa_GetErrorText")] [DllImport(PaDll, EntryPoint = "Pa_GetErrorText")]
public static extern IntPtr IntPtr_Pa_GetErrorText(PaError errorCode); public static extern IntPtr IntPtr_Pa_GetErrorText(PaError errorCode);
public static string Pa_GetErrorText(PaError errorCode) { public static string Pa_GetErrorText(PaError errorCode)
{
IntPtr strptr = IntPtr_Pa_GetErrorText(errorCode); IntPtr strptr = IntPtr_Pa_GetErrorText(errorCode);
return Marshal.PtrToStringAnsi(strptr); return Marshal.PtrToStringAnsi(strptr);
} }
@@ -329,7 +329,8 @@ namespace PortAudioSharp {
[DllImport(PaDll, EntryPoint = "Pa_GetHostApiInfo")] [DllImport(PaDll, EntryPoint = "Pa_GetHostApiInfo")]
public static extern IntPtr IntPtr_Pa_GetHostApiInfo(int hostApi); public static extern IntPtr IntPtr_Pa_GetHostApiInfo(int hostApi);
public static PaHostApiInfo Pa_GetHostApiInfo(int hostApi) { public static PaHostApiInfo Pa_GetHostApiInfo(int hostApi)
{
IntPtr structptr = IntPtr_Pa_GetHostApiInfo(hostApi); IntPtr structptr = IntPtr_Pa_GetHostApiInfo(hostApi);
return (PaHostApiInfo)Marshal.PtrToStructure(structptr, typeof(PaHostApiInfo)); return (PaHostApiInfo)Marshal.PtrToStructure(structptr, typeof(PaHostApiInfo));
} }
@@ -343,7 +344,8 @@ namespace PortAudioSharp {
[DllImport(PaDll, EntryPoint = "Pa_GetLastHostErrorInfo")] [DllImport(PaDll, EntryPoint = "Pa_GetLastHostErrorInfo")]
public static extern IntPtr IntPtr_Pa_GetLastHostErrorInfo(); public static extern IntPtr IntPtr_Pa_GetLastHostErrorInfo();
public static PaHostErrorInfo Pa_GetLastHostErrorInfo() { public static PaHostErrorInfo Pa_GetLastHostErrorInfo()
{
IntPtr structptr = IntPtr_Pa_GetLastHostErrorInfo(); IntPtr structptr = IntPtr_Pa_GetLastHostErrorInfo();
return (PaHostErrorInfo)Marshal.PtrToStructure(structptr, typeof(PaHostErrorInfo)); return (PaHostErrorInfo)Marshal.PtrToStructure(structptr, typeof(PaHostErrorInfo));
} }
@@ -360,7 +362,8 @@ namespace PortAudioSharp {
[DllImport(PaDll, EntryPoint = "Pa_GetDeviceInfo")] [DllImport(PaDll, EntryPoint = "Pa_GetDeviceInfo")]
public static extern IntPtr IntPtr_Pa_GetDeviceInfo(int device); public static extern IntPtr IntPtr_Pa_GetDeviceInfo(int device);
public static PaDeviceInfo Pa_GetDeviceInfo(int device) { public static PaDeviceInfo Pa_GetDeviceInfo(int device)
{
IntPtr structptr = IntPtr_Pa_GetDeviceInfo(device); IntPtr structptr = IntPtr_Pa_GetDeviceInfo(device);
return (PaDeviceInfo)Marshal.PtrToStructure(structptr, typeof(PaDeviceInfo)); return (PaDeviceInfo)Marshal.PtrToStructure(structptr, typeof(PaDeviceInfo));
} }
@@ -441,7 +444,8 @@ namespace PortAudioSharp {
[DllImport(PaDll, EntryPoint = "Pa_GetStreamInfo")] [DllImport(PaDll, EntryPoint = "Pa_GetStreamInfo")]
public static extern IntPtr IntPtr_Pa_GetStreamInfo(IntPtr stream); public static extern IntPtr IntPtr_Pa_GetStreamInfo(IntPtr stream);
public static PaStreamInfo Pa_GetStreamInfo(IntPtr stream) { public static PaStreamInfo Pa_GetStreamInfo(IntPtr stream)
{
IntPtr structptr = IntPtr_Pa_GetStreamInfo(stream); IntPtr structptr = IntPtr_Pa_GetStreamInfo(stream);
return (PaStreamInfo)Marshal.PtrToStructure(structptr, typeof(PaStreamInfo)); return (PaStreamInfo)Marshal.PtrToStructure(structptr, typeof(PaStreamInfo));
} }
@@ -547,13 +551,11 @@ namespace PortAudioSharp {
[DllImport(PaDll)] [DllImport(PaDll)]
public static extern void Pa_Sleep(int msec); public static extern void Pa_Sleep(int msec);
#endregion #endregion
private PortAudio() { private PortAudio()
{
// This is a static class // This is a static class
} }
} }
} }
+15 -21
View File
@@ -23,19 +23,18 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace PortAudioSharp { namespace PortAudioSharp
{
/// <summary> PortAudio v.19 bindings for .NET - ASIO bindings </summary> /// <summary> PortAudio v.19 bindings for .NET - ASIO bindings </summary>
public partial class PortAudio public partial class PortAudio
{ {
#region **** PORTAUDIO CALLBACKS **** #region **** PORTAUDIO CALLBACKS ****
#endregion #endregion
#region **** PORTAUDIO DATA STRUCTURES **** #region **** PORTAUDIO DATA STRUCTURES ****
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PaAsioStreamInfo { public struct PaAsioStreamInfo
{
public ulong size; /**< sizeof(PaAsioStreamInfo) */ public ulong size; /**< sizeof(PaAsioStreamInfo) */
public int hostApiType; /**< paASIO */ public int hostApiType; /**< paASIO */
public ulong version; /**< 1 */ public ulong version; /**< 1 */
@@ -50,23 +49,18 @@ namespace PortAudioSharp {
/// The values in the selectors array must specify channels within the /// The values in the selectors array must specify channels within the
/// range of supported channels for the device or paInvalidChannelCount will /// range of supported channels for the device or paInvalidChannelCount will
/// result. /// result.
IntPtr channelSelectors; private readonly IntPtr channelSelectors;
} }
#endregion #endregion
#region **** PORTAUDIO DEFINES **** #region **** PORTAUDIO DEFINES ****
public const int paAsioUseChannelSelectors = 0x01; public const int paAsioUseChannelSelectors = 0x01;
#endregion #endregion
#region **** PORTAUDIO ENUMERATIONS **** #region **** PORTAUDIO ENUMERATIONS ****
#endregion #endregion
#region **** PORTAUDIO FUNCTIONS **** #region **** PORTAUDIO FUNCTIONS ****
// /// <summary> Retrieve legal latency settings for the specificed device, in samples. </summary> // /// <summary> Retrieve legal latency settings for the specificed device, in samples. </summary>
// /// <param name="device"> The global index of the device about which the query is being made. </param> // /// <param name="device"> The global index of the device about which the query is being made. </param>
// /// <param name="minLatency"> A pointer to the location which will recieve the minimum latency value. </param> // /// <param name="minLatency"> A pointer to the location which will recieve the minimum latency value. </param>
@@ -81,10 +75,12 @@ namespace PortAudioSharp {
/// <summary> Display the ASIO control panel for the specified device. </summary> /// <summary> Display the ASIO control panel for the specified device. </summary>
/// <param name="device"> The global index of the device whose control panel is to be displayed. </param> /// <param name="device"> The global index of the device whose control panel is to be displayed. </param>
/// <param name="systemSpecific">On Windows, the calling application's main window handle, /// <param name="systemSpecific">
/// on Macintosh this value should be zero.</param> /// On Windows, the calling application's main window handle,
/// on Macintosh this value should be zero.
/// </param>
[DllImport("PortAudio.dll")] [DllImport("PortAudio.dll")]
public static extern PortAudio.PaError PaAsio_ShowControlPanel(int device, IntPtr systemSpecific); public static extern PaError PaAsio_ShowControlPanel(int device, IntPtr systemSpecific);
// /// <summary> Retrieve a pointer to a string containing the name of the specified input channel. </summary> // /// <summary> Retrieve a pointer to a string containing the name of the specified input channel. </summary>
// /// The string is valid until Pa_Terminate is called. // /// The string is valid until Pa_Terminate is called.
@@ -97,17 +93,15 @@ namespace PortAudioSharp {
// PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex, const char** channelName ); // PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex, const char** channelName );
/// <summary> Set the sample rate of an open paASIO stream. </summary> /// <summary> Set the sample rate of an open paASIO stream. </summary>
/// <param name="">stream</param> The stream to operate on. /// <param name="">stream</param>
/// <param name="sampleRate"></param> The new sample rate. /// The stream to operate on.
/// <param name="sampleRate"></param>
/// The new sample rate.
/// Note that this function may fail if the stream is alredy running and the /// Note that this function may fail if the stream is alredy running and the
/// ASIO driver does not support switching the sample rate of a running stream. /// ASIO driver does not support switching the sample rate of a running stream.
/// <returns> paIncompatibleStreamHostApi if stream is not a paASIO stream. </returns> /// <returns> paIncompatibleStreamHostApi if stream is not a paASIO stream. </returns>
[DllImport("PortAudio.dll")] [DllImport("PortAudio.dll")]
public static extern PortAudio.PaError PaAsio_SetStreamSampleRate(IntPtr stream, double sampleRate); public static extern PaError PaAsio_SetStreamSampleRate(IntPtr stream, double sampleRate);
#endregion #endregion
} }
} }
+4 -8
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Vocaluxe.Lib.Video.Acinerella namespace Vocaluxe.Lib.Video.Acinerella
{ {
public enum TAc_stream_type : sbyte public enum TAc_stream_type : sbyte
@@ -33,7 +32,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
AC_OUTPUT_BGRA32 = 3 AC_OUTPUT_BGRA32 = 3
} }
// Contains information about the whole file/stream that has been opened. Default // Contains information about the whole file/stream that has been opened. Default
// values are "" for strings and -1 for integer values. // values are "" for strings and -1 for integer values.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
@@ -96,13 +94,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
public TAc_video_stream_info video_info; public TAc_video_stream_info video_info;
} }
// Contains information about an Acinerella video/audio decoder. // Contains information about an Acinerella video/audio decoder.
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct TAc_decoder public struct TAc_decoder
{ {
//Pointer on the Acinerella instance //Pointer on the Acinerella instance
private IntPtr pAcInstance; private readonly IntPtr pAcInstance;
//Contains the type of the decoder. //Contains the type of the decoder.
public TAc_decoder_type dec_type; public TAc_decoder_type dec_type;
@@ -130,7 +127,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
public Int32 stream_index; public Int32 stream_index;
} }
// Callback function used to ask the application to read data. Should return // Callback function used to ask the application to read data. Should return
// the number of bytes read or an value smaller than zero if an error occured. // the number of bytes read or an value smaller than zero if an error occured.
//TAc_read_callback = function(sender: Pointer; byte[] buf, int size): integer; cdecl; //TAc_read_callback = function(sender: Pointer; byte[] buf, int size): integer; cdecl;
@@ -153,7 +149,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate Int32 TAc_openclose_callback(IntPtr sender); public delegate Int32 TAc_openclose_callback(IntPtr sender);
public static class CAcinerella public static class CAcinerella
{ {
#if ARCH_X86 #if ARCH_X86
@@ -176,7 +171,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
#endif #endif
#endif #endif
private static Object _lock = new Object(); private static readonly Object _lock = new Object();
// Defines the type of an Acinerella media stream. Currently only video and // Defines the type of an Acinerella media stream. Currently only video and
// audio streams are supported, subtitle and data streams will be marked as // audio streams are supported, subtitle and data streams will be marked as
@@ -225,6 +220,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
close_proc: TAc_openclose_callback; close_proc: TAc_openclose_callback;
proberesult: PAc_proberesult): integer; cdecl; external ac_dll; proberesult: PAc_proberesult): integer; cdecl; external ac_dll;
*/ */
[DllImport(AcDll, EntryPoint = "ac_open", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] [DllImport(AcDll, EntryPoint = "ac_open", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern Int32 _ac_open( private static extern Int32 _ac_open(
IntPtr PAc_instance, IntPtr PAc_instance,
@@ -356,7 +352,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
[DllImport(AcDll, EntryPoint = "ac_get_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] [DllImport(AcDll, EntryPoint = "ac_get_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern Int32 _ac_get_frame(IntPtr PAcInstance, IntPtr PAc_decoder); private static extern Int32 _ac_get_frame(IntPtr PAcInstance, IntPtr PAc_decoder);
public static Int32 ac_get_frame(IntPtr PAcInstance, IntPtr PAc_decoder) public static Int32 ac_get_frame(IntPtr PAcInstance, IntPtr PAc_decoder)
{ {
lock (_lock) lock (_lock)
@@ -364,6 +359,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
return _ac_get_frame(PAcInstance, PAc_decoder); return _ac_get_frame(PAcInstance, PAc_decoder);
} }
} }
[DllImport(AcDll, EntryPoint = "ac_skip_frames", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] [DllImport(AcDll, EntryPoint = "ac_skip_frames", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern Int32 _ac_skip_frames(IntPtr PAcInstance, IntPtr PAc_decoder, Int32 num); private static extern Int32 _ac_skip_frames(IntPtr PAcInstance, IntPtr PAc_decoder, Int32 num);
+4 -14
View File
@@ -48,36 +48,26 @@ namespace Vocaluxe.Lib.Video
return true; return true;
} }
public virtual void SetLoop(int StreamID, bool Loop) public virtual void SetLoop(int StreamID, bool Loop) {}
{
}
public virtual void Pause(int StreamID) public virtual void Pause(int StreamID) {}
{
}
public virtual void Resume(int StreamID) public virtual void Resume(int StreamID) {}
{
}
public virtual bool Finished(int StreamID) public virtual bool Finished(int StreamID)
{ {
return false; return false;
} }
public virtual void Update() public virtual void Update() {}
{
}
protected bool AlreadyAdded(int StreamID) protected bool AlreadyAdded(int StreamID)
{ {
foreach (VideoStreams st in _Streams) foreach (VideoStreams st in _Streams)
{ {
if (st.handle == StreamID) if (st.handle == StreamID)
{
return true; return true;
} }
}
return false; return false;
} }
+43 -88
View File
@@ -4,7 +4,6 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.Lib.Video.Acinerella; using Vocaluxe.Lib.Video.Acinerella;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -15,16 +14,15 @@ namespace Vocaluxe.Lib.Video
class CVideoDecoderFFmpeg : CVideoDecoder class CVideoDecoderFFmpeg : CVideoDecoder
{ {
private List<Decoder> _Decoder = new List<Decoder>(); private readonly List<Decoder> _Decoder = new List<Decoder>();
private CLOSEPROC closeproc; private CLOSEPROC closeproc;
private int _Count = 1; private int _Count = 1;
private Object MutexDecoder = new Object(); private readonly Object MutexDecoder = new Object();
public override bool Init() public override bool Init()
{ {
closeproc = new CLOSEPROC(close_proc); closeproc = close_proc;
CloseAll(); CloseAll();
return base.Init(); return base.Init();
@@ -35,11 +33,9 @@ namespace Vocaluxe.Lib.Video
lock (MutexDecoder) lock (MutexDecoder)
{ {
for (int i = 0; i < _Decoder.Count; i++) for (int i = 0; i < _Decoder.Count; i++)
{
_Decoder[i].Free(closeproc, i + 1); _Decoder[i].Free(closeproc, i + 1);
} }
} }
}
public override int Load(string VideoFileName) public override int Load(string VideoFileName)
{ {
@@ -56,7 +52,6 @@ namespace Vocaluxe.Lib.Video
_Streams.Add(stream); _Streams.Add(stream);
return stream.handle; return stream.handle;
} }
} }
return -1; return -1;
} }
@@ -73,7 +68,6 @@ namespace Vocaluxe.Lib.Video
return true; return true;
} }
} }
} }
return false; return false;
} }
@@ -85,12 +79,9 @@ namespace Vocaluxe.Lib.Video
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(StreamID)) if (AlreadyAdded(StreamID))
{
return _Decoder[GetStreamIndex(StreamID)].GetFrame(ref Frame, Time, ref VideoTime); return _Decoder[GetStreamIndex(StreamID)].GetFrame(ref Frame, Time, ref VideoTime);
} }
} }
}
return false; return false;
} }
@@ -101,12 +92,9 @@ namespace Vocaluxe.Lib.Video
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(StreamID)) if (AlreadyAdded(StreamID))
{
return _Decoder[GetStreamIndex(StreamID)].Length; return _Decoder[GetStreamIndex(StreamID)].Length;
} }
} }
}
return 0f; return 0f;
} }
@@ -117,12 +105,9 @@ namespace Vocaluxe.Lib.Video
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(StreamID)) if (AlreadyAdded(StreamID))
{
return _Decoder[GetStreamIndex(StreamID)].Skip(Start, Gap); return _Decoder[GetStreamIndex(StreamID)].Skip(Start, Gap);
} }
} }
}
return false; return false;
} }
@@ -133,12 +118,9 @@ namespace Vocaluxe.Lib.Video
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(StreamID)) if (AlreadyAdded(StreamID))
{
_Decoder[GetStreamIndex(StreamID)].Loop = Loop; _Decoder[GetStreamIndex(StreamID)].Loop = Loop;
} }
} }
}
} }
public override void Pause(int StreamID) public override void Pause(int StreamID)
@@ -148,12 +130,9 @@ namespace Vocaluxe.Lib.Video
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(StreamID)) if (AlreadyAdded(StreamID))
{
_Decoder[GetStreamIndex(StreamID)].Paused = true; _Decoder[GetStreamIndex(StreamID)].Paused = true;
} }
} }
}
} }
public override void Resume(int StreamID) public override void Resume(int StreamID)
@@ -163,12 +142,9 @@ namespace Vocaluxe.Lib.Video
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(StreamID)) if (AlreadyAdded(StreamID))
{
_Decoder[GetStreamIndex(StreamID)].Paused = false; _Decoder[GetStreamIndex(StreamID)].Paused = false;
} }
} }
}
} }
public override bool Finished(int StreamID) public override bool Finished(int StreamID)
@@ -178,11 +154,9 @@ namespace Vocaluxe.Lib.Video
lock (MutexDecoder) lock (MutexDecoder)
{ {
if (AlreadyAdded(StreamID)) if (AlreadyAdded(StreamID))
{
return _Decoder[GetStreamIndex(StreamID)].Finished; return _Decoder[GetStreamIndex(StreamID)].Finished;
} }
} }
}
return true; return true;
} }
@@ -199,7 +173,6 @@ namespace Vocaluxe.Lib.Video
_Streams.RemoveAt(Index); _Streams.RemoveAt(Index);
} }
} }
} }
} }
} }
@@ -216,57 +189,56 @@ namespace Vocaluxe.Lib.Video
private IntPtr _instance = IntPtr.Zero; // acinerella instance private IntPtr _instance = IntPtr.Zero; // acinerella instance
private IntPtr _videodecoder = IntPtr.Zero; // acinerella video decoder instance private IntPtr _videodecoder = IntPtr.Zero; // acinerella video decoder instance
private Stopwatch _LoopTimer = new Stopwatch(); private readonly Stopwatch _LoopTimer = new Stopwatch();
private CLOSEPROC _Closeproc; // delegate for stream closing private CLOSEPROC _Closeproc; // delegate for stream closing
private int _StreamID; // stream ID for stream closing private int _StreamID; // stream ID for stream closing
private string _FileName; // current video file name private string _FileName; // current video file name
private FileStream _fs; // video file stream private FileStream _fs; // video file stream
private TAc_read_callback _rc; // read callback for acinerella private readonly TAc_read_callback _rc; // read callback for acinerella
private TAc_seek_callback _sc; // seek callback for acinerella private readonly TAc_seek_callback _sc; // seek callback for acinerella
private bool _FileOpened = false; private bool _FileOpened;
private float _VideoTimeBase = 0f; // frame time private float _VideoTimeBase; // frame time
private float _VideoDecoderTime = 0f; // time of last decoded frame private float _VideoDecoderTime; // time of last decoded frame
private float _CurrentVideoTime = 0f; // current video position private float _CurrentVideoTime; // current video position
private bool _BufferFull = false; // buffer is full, waiting for free frame slot private bool _BufferFull; // buffer is full, waiting for free frame slot
private bool _skip = false; // do skip private bool _skip; // do skip
private float _Time = 0f; private float _Time;
private float _Gap = 0f; private float _Gap;
private float _Start = 0f; private float _Start;
private bool _Loop = false; private bool _Loop;
private float _Duration = 0f; private float _Duration;
private float _VideoSkipTime = 0f; // = VideoGap private float _VideoSkipTime; // = VideoGap
private float _SkipTime = 0f; // = Start + VideoGap private float _SkipTime; // = Start + VideoGap
private bool _Paused = false; private bool _Paused;
private bool _NoMoreFrames = false; private bool _NoMoreFrames;
private bool _Finished = false; private bool _Finished;
private bool _BeforeLoop = false; private bool _BeforeLoop;
private int _Width;
private int _Height;
private float _SetTime;
private float _SetGap;
private float _SetStart;
private bool _SetLoop;
private bool _SetSkip;
private bool _terminated;
private int _Width = 0; private readonly Thread _thread;
private int _Height = 0;
private float _SetTime = 0f;
private float _SetGap = 0f;
private float _SetStart = 0f;
private bool _SetLoop = false;
private bool _SetSkip = false;
private bool _terminated = false;
private Thread _thread;
//AutoResetEvent EventDecode = new AutoResetEvent(false); //AutoResetEvent EventDecode = new AutoResetEvent(false);
SFrameBuffer[] _FrameBuffer = new SFrameBuffer[5]; private readonly SFrameBuffer[] _FrameBuffer = new SFrameBuffer[5];
private bool _NewFrame = false; private bool _NewFrame;
Object MutexFramebuffer = new Object(); private readonly Object MutexFramebuffer = new Object();
Object MutexSyncSignals = new Object(); private readonly Object MutexSyncSignals = new Object();
public Decoder() public Decoder()
{ {
_rc = new TAc_read_callback(read_proc); _rc = read_proc;
_sc = new TAc_seek_callback(seek_proc); _sc = seek_proc;
_thread = new Thread(Execute); _thread = new Thread(Execute);
} }
@@ -297,16 +269,12 @@ namespace Vocaluxe.Lib.Video
{ {
_Paused = value; _Paused = value;
if (_Paused) if (_Paused)
{
_LoopTimer.Stop(); _LoopTimer.Stop();
}
else else
{
_LoopTimer.Start(); _LoopTimer.Start();
} }
} }
} }
}
public bool Loop public bool Loop
{ {
@@ -316,10 +284,7 @@ namespace Vocaluxe.Lib.Video
public bool Finished public bool Finished
{ {
get get { return _Finished; }
{
return _Finished;
}
} }
public bool Open(string FileName) public bool Open(string FileName)
@@ -327,7 +292,7 @@ namespace Vocaluxe.Lib.Video
if (_FileOpened) if (_FileOpened)
return false; return false;
if (!System.IO.File.Exists(FileName)) if (!File.Exists(FileName))
return false; return false;
_FileName = FileName; _FileName = FileName;
@@ -410,14 +375,13 @@ namespace Vocaluxe.Lib.Video
{ {
CLog.LogError("Error seeking video file \"" + _FileName + "\": " + e.Message); CLog.LogError("Error seeking video file \"" + _FileName + "\": " + e.Message);
} }
} }
else else
{ {
_VideoDecoderTime = 0f; _VideoDecoderTime = 0f;
try try
{ {
CAcinerella.ac_seek(_videodecoder, -1, (Int64)0); CAcinerella.ac_seek(_videodecoder, -1, 0);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -509,7 +473,7 @@ namespace Vocaluxe.Lib.Video
return; return;
} }
_Duration = (float)Instance.info.duration / 1000f; _Duration = Instance.info.duration / 1000f;
int VideoStreamIndex = -1; int VideoStreamIndex = -1;
@@ -587,7 +551,6 @@ namespace Vocaluxe.Lib.Video
{ {
CLog.LogError("Error AcSkipFrame " + _FileName); CLog.LogError("Error AcSkipFrame " + _FileName);
} }
} }
if (!_BeforeLoop && (!DropFrame || FrameFinished != 0)) if (!_BeforeLoop && (!DropFrame || FrameFinished != 0))
@@ -638,9 +601,7 @@ namespace Vocaluxe.Lib.Video
DoSkip(); DoSkip();
} }
else else
{
_NoMoreFrames = true; _NoMoreFrames = true;
}
return; return;
} }
else else
@@ -669,9 +630,7 @@ namespace Vocaluxe.Lib.Video
} }
if (num == -1) if (num == -1)
{
_BufferFull = true; _BufferFull = true;
}
else else
{ {
TAc_decoder Videodecoder = (TAc_decoder)Marshal.PtrToStructure(_videodecoder, typeof(TAc_decoder)); TAc_decoder Videodecoder = (TAc_decoder)Marshal.PtrToStructure(_videodecoder, typeof(TAc_decoder));
@@ -721,9 +680,7 @@ namespace Vocaluxe.Lib.Video
frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].data); frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].data);
} }
else else
{
CDraw.UpdateTexture(ref frame, ref _FrameBuffer[num].data); CDraw.UpdateTexture(ref frame, ref _FrameBuffer[num].data);
}
lock (MutexSyncSignals) lock (MutexSyncSignals)
{ {
@@ -750,9 +707,7 @@ namespace Vocaluxe.Lib.Video
float td = _SetTime + _VideoSkipTime - _FrameBuffer[i].time; float td = _SetTime + _VideoSkipTime - _FrameBuffer[i].time;
if (td > _VideoTimeBase * 2f) if (td > _VideoTimeBase * 2f)
{
_FrameBuffer[i].displayed = true; _FrameBuffer[i].displayed = true;
}
if (!_FrameBuffer[i].displayed && (td < diff) && (td > _VideoTimeBase)) if (!_FrameBuffer[i].displayed && (td < diff) && (td > _VideoTimeBase))
{ {
@@ -799,7 +754,7 @@ namespace Vocaluxe.Lib.Video
private Int64 seek_proc(IntPtr sender, Int64 pos, Int32 whence) private Int64 seek_proc(IntPtr sender, Int64 pos, Int32 whence)
{ {
return (Int64)_fs.Seek((long)pos, (SeekOrigin)whence); return _fs.Seek(pos, (SeekOrigin)whence);
} }
#endregion Callbacks #endregion Callbacks
+1 -4
View File
@@ -13,14 +13,13 @@ namespace Vocaluxe.Lib.Video
private void LogHandler(string text) private void LogHandler(string text)
{ {
CLog.LogError(text); CLog.LogError(text);
} }
#endregion log #endregion log
public bool Init() public bool Init()
{ {
bool retval = CGstreamerVideoWrapper.InitVideo(); bool retval = CGstreamerVideoWrapper.InitVideo();
Log = new CGstreamerVideoWrapper.LogCallback(LogHandler); Log = LogHandler;
//Really needed? CodeAnalysis complains //Really needed? CodeAnalysis complains
//GC.SuppressFinalize(Log); //GC.SuppressFinalize(Log);
CGstreamerVideoWrapper.SetVideoLogCallback(Log); CGstreamerVideoWrapper.SetVideoLogCallback(Log);
@@ -109,9 +108,7 @@ namespace Vocaluxe.Lib.Video
frame = CDraw.AddTexture(Width, Height, ref Data); frame = CDraw.AddTexture(Width, Height, ref Data);
} }
else else
{
CDraw.UpdateTexture(ref frame, ref Data); CDraw.UpdateTexture(ref frame, ref Data);
}
Data = null; Data = null;
} }
} }
@@ -3,7 +3,8 @@ using System.Runtime.InteropServices;
namespace Vocaluxe.Lib.Video.Gstreamer namespace Vocaluxe.Lib.Video.Gstreamer
{ {
public struct NativeFrame { public struct NativeFrame
{
internal IntPtr buffer; internal IntPtr buffer;
public int Size; public int Size;
public int Width; public int Width;
@@ -35,6 +36,7 @@ namespace Vocaluxe.Lib.Video.Gstreamer
#endif #endif
#endif #endif
#endregion arch #endregion arch
public delegate void LogCallback(string message); public delegate void LogCallback(string message);
[DllImport(Dll)] [DllImport(Dll)]
@@ -82,7 +84,6 @@ namespace Vocaluxe.Lib.Video.Gstreamer
m.Videotime = f.Videotime; m.Videotime = f.Videotime;
m.Width = f.Width; m.Width = f.Width;
return m; return m;
} }
[DllImport(Dll)] [DllImport(Dll)]
@@ -106,6 +107,5 @@ namespace Vocaluxe.Lib.Video.Gstreamer
[DllImport(Dll)] [DllImport(Dll)]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
public static extern bool UpdateVideo(); public static extern bool UpdateVideo();
} }
} }
+8 -13
View File
@@ -11,14 +11,14 @@ namespace Vocaluxe.Lib.Webcam
{ {
class CAForgeNet : IWebcam class CAForgeNet : IWebcam
{ {
private List<SWebcamDevice> _Devices = new List<SWebcamDevice>(); private readonly List<SWebcamDevice> _Devices = new List<SWebcamDevice>();
private bool _Paused; private bool _Paused;
private VideoCaptureDevice _Webcam; private VideoCaptureDevice _Webcam;
private FilterInfoCollection _WebcamDevices; private FilterInfoCollection _WebcamDevices;
private SWebcamConfig _Config; private SWebcamConfig _Config;
private byte[] data = new byte[1]; private byte[] data = new byte[1];
private static object _mutexData = new object(); private static readonly object _mutexData = new object();
int _Width, _Height; private int _Width, _Height;
public void Close() public void Close()
{ {
@@ -26,7 +26,7 @@ namespace Vocaluxe.Lib.Webcam
{ {
_Webcam.SignalToStop(); _Webcam.SignalToStop();
_Webcam.WaitForStop(); _Webcam.WaitForStop();
_Webcam.NewFrame -= new NewFrameEventHandler(OnFrame); _Webcam.NewFrame -= OnFrame;
data = new byte[1]; data = new byte[1];
} }
} }
@@ -43,11 +43,9 @@ namespace Vocaluxe.Lib.Webcam
Frame = CDraw.AddTexture(_Width, _Height, ref data); Frame = CDraw.AddTexture(_Width, _Height, ref data);
} }
else else
{
CDraw.UpdateTexture(ref Frame, ref data); CDraw.UpdateTexture(ref Frame, ref data);
} }
} }
}
return false; return false;
} }
@@ -74,7 +72,8 @@ namespace Vocaluxe.Lib.Webcam
int num = 0; int num = 0;
foreach (FilterInfo info in _WebcamDevices) foreach (FilterInfo info in _WebcamDevices)
{ {
SWebcamDevice device = new SWebcamDevice { SWebcamDevice device = new SWebcamDevice
{
ID = num, ID = num,
Name = info.Name, Name = info.Name,
MonikerString = info.MonikerString, MonikerString = info.MonikerString,
@@ -119,18 +118,16 @@ namespace Vocaluxe.Lib.Webcam
public void Pause() public void Pause()
{ {
if (_Webcam != null) if (_Webcam != null)
{
_Paused = true; _Paused = true;
} }
}
public void Start() public void Start()
{ {
if (_Webcam != null) if (_Webcam != null)
{ {
_Webcam.NewFrame -= new NewFrameEventHandler(OnFrame); _Webcam.NewFrame -= OnFrame;
//Subscribe to NewFrame event //Subscribe to NewFrame event
_Webcam.NewFrame += new NewFrameEventHandler(OnFrame); _Webcam.NewFrame += OnFrame;
_Webcam.Start(); _Webcam.Start();
_Paused = false; _Paused = false;
} }
@@ -139,10 +136,8 @@ namespace Vocaluxe.Lib.Webcam
public void Stop() public void Stop()
{ {
if (_Webcam != null) if (_Webcam != null)
{
_Webcam.SignalToStop(); _Webcam.SignalToStop();
} }
}
public SWebcamDevice[] GetDevices() public SWebcamDevice[] GetDevices()
{ {
+20 -26
View File
@@ -11,12 +11,12 @@ namespace Vocaluxe
// just a small comment for the new develop branch // just a small comment for the new develop branch
static class MainProgram static class MainProgram
{ {
static SplashScreen _SplashScreen; private static SplashScreen _SplashScreen;
[STAThread] [STAThread]
static void Main(string[] args) private static void Main(string[] args)
{ {
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver); AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver;
// Close program if there is another instance running // Close program if there is another instance running
if (!EnsureSingleInstance()) if (!EnsureSingleInstance())
@@ -180,7 +180,7 @@ namespace Vocaluxe
CloseProgram(); CloseProgram();
} }
static void CloseProgram() private static void CloseProgram()
{ {
// Unloading // Unloading
try try
@@ -194,15 +194,12 @@ namespace Vocaluxe
CDataBase.CloseConnections(); CDataBase.CloseConnections();
CWebcam.Close(); CWebcam.Close();
} }
catch (Exception) catch (Exception) {}
{
} }
} private static Assembly AssemblyResolver(Object sender, ResolveEventArgs args)
static Assembly AssemblyResolver(Object sender, ResolveEventArgs args)
{ {
string[] arr = args.Name.Split(new Char[] { ',' }); string[] arr = args.Name.Split(new[] {','});
if (arr != null) if (arr != null)
{ {
#if ARCH_X86 #if ARCH_X86
@@ -218,7 +215,7 @@ namespace Vocaluxe
return null; return null;
} }
static bool EnsureSingleInstance() private static bool EnsureSingleInstance()
{ {
Process currentProcess = Process.GetCurrentProcess(); Process currentProcess = Process.GetCurrentProcess();
Process[] processes = Process.GetProcesses(); Process[] processes = Process.GetProcesses();
@@ -238,7 +235,7 @@ namespace Vocaluxe
class SplashScreen : Form class SplashScreen : Form
{ {
Bitmap logo; private readonly Bitmap logo;
public SplashScreen() public SplashScreen()
{ {
@@ -248,23 +245,22 @@ namespace Vocaluxe
try try
{ {
logo = new Bitmap(path); logo = new Bitmap(path);
this.ClientSize = new Size(logo.Width, logo.Height); ClientSize = new Size(logo.Width, logo.Height);
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Error loading logo: " + e.Message); CLog.LogError("Error loading logo: " + e.Message);
} }
} }
else else
CLog.LogError("Can't find " + path); CLog.LogError("Can't find " + path);
path = Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon); path = Path.Combine(Environment.CurrentDirectory, CSettings.sIcon);
if (File.Exists(path)) if (File.Exists(path))
{ {
try try
{ {
this.Icon = new System.Drawing.Icon(path); Icon = new Icon(path);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -275,25 +271,23 @@ namespace Vocaluxe
CLog.LogError("Can't find " + path); CLog.LogError("Can't find " + path);
SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent; BackColor = Color.Transparent;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; FormBorderStyle = FormBorderStyle.None;
this.Text = CSettings.sProgramName; Text = CSettings.sProgramName;
this.CenterToScreen(); CenterToScreen();
this.Show(); Show();
} }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) protected override void OnPaint(PaintEventArgs e) {}
{
}
protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs e) protected override void OnPaintBackground(PaintEventArgs e)
{ {
if (logo == null) if (logo == null)
return; return;
Graphics g = e.Graphics; Graphics g = e.Graphics;
g.DrawImage(logo, new Rectangle(0, 0, this.Width, this.Height)); g.DrawImage(logo, new Rectangle(0, 0, Width, Height));
} }
} }
} }
+4
View File
@@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden // Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind. // die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("Vocaluxe.Properties")] [assembly: AssemblyTitle("Vocaluxe.Properties")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
@@ -16,9 +17,11 @@ using System.Runtime.InteropServices;
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("da631594-f891-4994-9869-c37e626e44f9")] [assembly: Guid("da631594-f891-4994-9869-c37e626e44f9")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
@@ -28,5 +31,6 @@ using System.Runtime.InteropServices;
// Buildnummer // Buildnummer
// Revision // Revision
// //
[assembly: AssemblyVersion("0.3.0.0")] [assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
+14 -24
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -10,7 +9,10 @@ namespace Vocaluxe.Screens
class CPopupScreenPlayerControl : CMenu class CPopupScreenPlayerControl : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
{
get { return 1; }
}
private const string StaticBG = "StaticBG"; private const string StaticBG = "StaticBG";
private const string StaticCover = "StaticCover"; private const string StaticCover = "StaticCover";
@@ -25,14 +27,11 @@ namespace Vocaluxe.Screens
private const string ButtonToBackgroundVideo = "ButtonToBackgroundVideo"; private const string ButtonToBackgroundVideo = "ButtonToBackgroundVideo";
private const string TextCurrentSong = "TextCurrentSong"; private const string TextCurrentSong = "TextCurrentSong";
private bool _VideoPreview = false; private bool _VideoPreview;
private bool VideoPreview private bool VideoPreview
{ {
get get { return _VideoPreview; }
{
return _VideoPreview;
}
set set
{ {
_VideoPreview = value; _VideoPreview = value;
@@ -45,10 +44,7 @@ namespace Vocaluxe.Screens
private bool VideoBackground private bool VideoBackground
{ {
get get { return CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON; }
{
return CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON;
}
set set
{ {
if (!value) if (!value)
@@ -69,16 +65,12 @@ namespace Vocaluxe.Screens
} }
} }
public CPopupScreenPlayerControl()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeStatics = new string[] { StaticBG, StaticCover }; _ThemeStatics = new[] {StaticBG, StaticCover};
_ThemeTexts = new string[] { TextCurrentSong }; _ThemeTexts = new[] {TextCurrentSong};
List<string> buttons = new List<string>(); List<string> buttons = new List<string>();
buttons.Add(ButtonPlay); buttons.Add(ButtonPlay);
@@ -102,10 +94,7 @@ namespace Vocaluxe.Screens
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -160,11 +149,13 @@ namespace Vocaluxe.Screens
StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet); StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet);
if (Buttons[ButtonToBackgroundVideo].Selected) if (Buttons[ButtonToBackgroundVideo].Selected)
VideoBackground = !VideoBackground; VideoBackground = !VideoBackground;
} else if (MouseEvent.LB) }
else if (MouseEvent.LB)
{ {
//CGraphics.HidePopup(EPopupScreens.PopupPlayerControl); //CGraphics.HidePopup(EPopupScreens.PopupPlayerControl);
return false; return false;
} else if (MouseEvent.RB) }
else if (MouseEvent.RB)
{ {
//CGraphics.HidePopup(EPopupScreens.PopupPlayerControl); //CGraphics.HidePopup(EPopupScreens.PopupPlayerControl);
return false; return false;
@@ -174,7 +165,6 @@ namespace Vocaluxe.Screens
public override bool UpdateGame() public override bool UpdateGame()
{ {
Statics[StaticCover].Visible = !_VideoPreview || !CBackgroundMusic.SongHasVideo; Statics[StaticCover].Visible = !_VideoPreview || !CBackgroundMusic.SongHasVideo;
Buttons[ButtonToBackgroundVideo].Pressed = VideoBackground; Buttons[ButtonToBackgroundVideo].Pressed = VideoBackground;
Buttons[ButtonShowVideo].Pressed = _VideoPreview; Buttons[ButtonShowVideo].Pressed = _VideoPreview;
+13 -18
View File
@@ -1,5 +1,4 @@
using Vocaluxe.Base;
using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace Vocaluxe.Screens namespace Vocaluxe.Screens
@@ -7,24 +6,21 @@ namespace Vocaluxe.Screens
class CPopupScreenVolumeControl : CMenu class CPopupScreenVolumeControl : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
{
get { return 1; }
}
private const string StaticBG = "StaticBG"; private const string StaticBG = "StaticBG";
private const string SelectSlideVolume = "SelectSlideVolume"; private const string SelectSlideVolume = "SelectSlideVolume";
public CPopupScreenVolumeControl()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeStatics = new string[] { StaticBG }; _ThemeStatics = new[] {StaticBG};
_ThemeSelectSlides = new string[] { SelectSlideVolume }; _ThemeSelectSlides = new[] {SelectSlideVolume};
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
@@ -32,7 +28,8 @@ namespace Vocaluxe.Screens
base.LoadTheme(XmlPath); base.LoadTheme(XmlPath);
_ScreenArea = Statics[StaticBG].Rect; _ScreenArea = Statics[StaticBG].Rect;
SelectSlides[SelectSlideVolume].AddValues(new string[] { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" }); SelectSlides[SelectSlideVolume].AddValues(new[]
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
} }
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
@@ -68,9 +65,7 @@ namespace Vocaluxe.Screens
return true; return true;
} }
else if (MouseEvent.RB) else if (MouseEvent.RB)
{
return false; return false;
}
return true; return true;
} }
@@ -126,17 +121,17 @@ namespace Vocaluxe.Screens
{ {
case EScreens.ScreenSong: case EScreens.ScreenSong:
if (CSongs.IsInCategory) if (CSongs.IsInCategory)
SelectSlides[SelectSlideVolume].Selection = (int)(CConfig.PreviewMusicVolume / 5); SelectSlides[SelectSlideVolume].Selection = (CConfig.PreviewMusicVolume / 5);
else else
SelectSlides[SelectSlideVolume].Selection = ((int)CConfig.BackgroundMusicVolume / 5); SelectSlides[SelectSlideVolume].Selection = (CConfig.BackgroundMusicVolume / 5);
break; break;
case EScreens.ScreenSing: case EScreens.ScreenSing:
SelectSlides[SelectSlideVolume].Selection = ((int)CConfig.GameMusicVolume / 5); SelectSlides[SelectSlideVolume].Selection = (CConfig.GameMusicVolume / 5);
break; break;
default: default:
SelectSlides[SelectSlideVolume].Selection = ((int)CConfig.BackgroundMusicVolume / 5); SelectSlides[SelectSlideVolume].Selection = (CConfig.BackgroundMusicVolume / 5);
break; break;
} }
} }
+27 -49
View File
@@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -15,11 +14,11 @@ enum EDirection
class CCreditName class CCreditName
{ {
private CStatic _Image; private readonly CStatic _Image;
private CStatic _ImgDot; private readonly CStatic _ImgDot;
private CParticleEffect _Particle; private readonly CParticleEffect _Particle;
private int _ParticleOffsetX; private readonly int _ParticleOffsetX;
private int _ParticleOffsetY; private readonly int _ParticleOffsetY;
public EDirection Direction; public EDirection Direction;
public float StartTimeUp; public float StartTimeUp;
public bool Active; public bool Active;
@@ -29,17 +28,14 @@ class CCreditName
_Image = Image; _Image = Image;
_ImgDot = ImgDot; _ImgDot = ImgDot;
_Particle = Particle; _Particle = Particle;
_ParticleOffsetX = (int)Math.Round(ParticleOffsetX * (float)Image.Rect.W / Image.Texture.w2 - Particle.Rect.W / 2); _ParticleOffsetX = (int)Math.Round(ParticleOffsetX * Image.Rect.W / Image.Texture.w2 - Particle.Rect.W / 2);
_ParticleOffsetY = (int)Math.Round(ParticleOffsetY * (float)Image.Rect.H / Image.Texture.h2 - Particle.Rect.H / 2); _ParticleOffsetY = (int)Math.Round(ParticleOffsetY * Image.Rect.H / Image.Texture.h2 - Particle.Rect.H / 2);
Active = true; Active = true;
} }
public float X public float X
{ {
get get { return _Image.Rect.X; }
{
return _Image.Rect.X;
}
set set
{ {
_Image.Rect.X = value; _Image.Rect.X = value;
@@ -49,10 +45,7 @@ class CCreditName
} }
public float Y public float Y
{ {
get get { return _Image.Rect.Y; }
{
return _Image.Rect.Y;
}
set set
{ {
_Image.Rect.Y = value; _Image.Rect.Y = value;
@@ -61,8 +54,14 @@ class CCreditName
} }
} }
public float W { get { return _Image.Rect.W; } } public float W
public float H { get { return _Image.Rect.H; } } {
get { return _Image.Rect.W; }
}
public float H
{
get { return _Image.Rect.H; }
}
public float Alpha public float Alpha
{ {
@@ -90,7 +89,10 @@ namespace Vocaluxe.Screens
class CScreenCredits : CMenu class CScreenCredits : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
{
get { return 1; }
}
private CStatic logo; private CStatic logo;
private CParticleEffect starsRed; private CParticleEffect starsRed;
@@ -119,10 +121,6 @@ namespace Vocaluxe.Screens
private STexture _TexNamePantero; private STexture _TexNamePantero;
private STexture _TexNamePinky007; private STexture _TexNamePinky007;
public CScreenCredits()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
@@ -141,14 +139,14 @@ namespace Vocaluxe.Screens
paragraph = "Inspired by the achievements of UltraStar Deluxe and its variants and pursuing the goal of making " + paragraph = "Inspired by the achievements of UltraStar Deluxe and its variants and pursuing the goal of making " +
"a good thing even better, we ended up rewriting the game from scratch. And a new implementation in a new " + "a good thing even better, we ended up rewriting the game from scratch. And a new implementation in a new " +
"programming language called for a new name - and VOCALUXE [ˈvoʊˈkəˈlʌks] it is!"; "programming language called for a new name - and VOCALUXE [ˈvoʊˈkəˈlʌks] it is!";
words = paragraph.Split(new Char[] { ' ' }); words = paragraph.Split(new[] {' '});
paragraphs.Add(words); paragraphs.Add(words);
paragraph = "This first public version has already implemented many of the original features and it is fully " + paragraph = "This first public version has already implemented many of the original features and it is fully " +
"compatible with all the song files in your existing song collection. The code design allows a much faster " + "compatible with all the song files in your existing song collection. The code design allows a much faster " +
"implementation of new features, thus the roadmap for the next few stable releases is packed and we expect much " + "implementation of new features, thus the roadmap for the next few stable releases is packed and we expect much " +
"shorter release cycles than ever before. And, of course, our and your ideas may be the features of tomorrow."; "shorter release cycles than ever before. And, of course, our and your ideas may be the features of tomorrow.";
words = paragraph.Split(new Char[] { ' ' }); words = paragraph.Split(new[] {' '});
paragraphs.Add(words); paragraphs.Add(words);
paragraph = "We appreciate the feedback in the beta release phase and are, of course, always open for bug reports, " + paragraph = "We appreciate the feedback in the beta release phase and are, of course, always open for bug reports, " +
@@ -156,12 +154,12 @@ namespace Vocaluxe.Screens
"Vocaluxe an international experience from the very beginning and all those diligent song makers out there - " + "Vocaluxe an international experience from the very beginning and all those diligent song makers out there - " +
"there's something for everyone in the huge collection of available songs! Last but not least, thanks to " + "there's something for everyone in the huge collection of available songs! Last but not least, thanks to " +
"Kosal Sen's Philly Sans type used in the Vocaluxe Logo."; "Kosal Sen's Philly Sans type used in the Vocaluxe Logo.";
words = paragraph.Split(new Char[] { ' ' }); words = paragraph.Split(new[] {' '});
paragraphs.Add(words); paragraphs.Add(words);
paragraph = "Go ahead and grab your mics, crank up your stereo, warm up your voice and get ready to sing to the best " + paragraph = "Go ahead and grab your mics, crank up your stereo, warm up your voice and get ready to sing to the best " +
"of your abilities!"; "of your abilities!";
words = paragraph.Split(new Char[] { ' ' }); words = paragraph.Split(new[] {' '});
paragraphs.Add(words); paragraphs.Add(words);
} }
@@ -218,7 +216,6 @@ namespace Vocaluxe.Screens
} }
} }
} }
} }
public override void ReloadTheme(string XmlPath) {} public override void ReloadTheme(string XmlPath) {}
@@ -249,18 +246,14 @@ namespace Vocaluxe.Screens
public override bool HandleMouse(MouseEvent MouseEvent) public override bool HandleMouse(MouseEvent MouseEvent)
{ {
if (MouseEvent.LB || MouseEvent.RB) if (MouseEvent.LB || MouseEvent.RB)
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
}
return true; return true;
} }
public override bool UpdateGame() public override bool UpdateGame()
{ {
if (!animation()) if (!animation())
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
}
return true; return true;
} }
@@ -297,13 +290,11 @@ namespace Vocaluxe.Screens
{ {
credit.X = -450; credit.X = -450;
credit.Direction = EDirection.Left; credit.Direction = EDirection.Left;
} }
credit.Y = 580; credit.Y = 580;
_CreditNames.Add(credit); _CreditNames.Add(credit);
} }
public override void OnShow() public override void OnShow()
{ {
base.OnShow(); base.OnShow();
@@ -356,18 +347,14 @@ namespace Vocaluxe.Screens
//Draw credit-entries //Draw credit-entries
foreach (CCreditName cn in _CreditNames) foreach (CCreditName cn in _CreditNames)
{
cn.Draw(); cn.Draw();
}
//Draw Text //Draw Text
if (TextTimer.IsRunning) if (TextTimer.IsRunning)
{ {
for (int i = 0; i < paragraphTexts.Count; i++) for (int i = 0; i < paragraphTexts.Count; i++)
{
paragraphTexts[i].Draw(); paragraphTexts[i].Draw();
} }
}
return true; return true;
} }
@@ -382,9 +369,7 @@ namespace Vocaluxe.Screens
starsRed.Rect.Y = logo.Rect.Y; starsRed.Rect.Y = logo.Rect.Y;
starsBlue.Rect.Y = logo.Rect.Y; starsBlue.Rect.Y = logo.Rect.Y;
if (LogoTimer.ElapsedMilliseconds >= 2000 && !CreditsTimer.IsRunning) if (LogoTimer.ElapsedMilliseconds >= 2000 && !CreditsTimer.IsRunning)
{
CreditsTimer.Start(); CreditsTimer.Start();
}
if (LogoTimer.ElapsedMilliseconds >= 3000) if (LogoTimer.ElapsedMilliseconds >= 3000)
{ {
LogoTimer.Stop(); LogoTimer.Stop();
@@ -413,14 +398,14 @@ namespace Vocaluxe.Screens
_CreditNames[i].Direction = EDirection.Up; _CreditNames[i].Direction = EDirection.Up;
_CreditNames[i].StartTimeUp = CreditsTimer.ElapsedMilliseconds; _CreditNames[i].StartTimeUp = CreditsTimer.ElapsedMilliseconds;
} }
} }
break; break;
case EDirection.Left: case EDirection.Left:
if (i * 4000f <= CreditsTimer.ElapsedMilliseconds) if (i * 4000f <= CreditsTimer.ElapsedMilliseconds)
{ {
_CreditNames[i].X = CSettings.iRenderW - (((CSettings.iRenderW - _CreditNames[i].W) / 2) / 3000f) * (CreditsTimer.ElapsedMilliseconds - (i * 4000f)); _CreditNames[i].X = CSettings.iRenderW -
(((CSettings.iRenderW - _CreditNames[i].W) / 2) / 3000f) * (CreditsTimer.ElapsedMilliseconds - (i * 4000f));
//Check if name is in middle of screen and should go up //Check if name is in middle of screen and should go up
if (_CreditNames[i].X <= (CSettings.iRenderW - _CreditNames[i].W) / 2) if (_CreditNames[i].X <= (CSettings.iRenderW - _CreditNames[i].W) / 2)
@@ -428,7 +413,6 @@ namespace Vocaluxe.Screens
_CreditNames[i].Direction = EDirection.Up; _CreditNames[i].Direction = EDirection.Up;
_CreditNames[i].StartTimeUp = CreditsTimer.ElapsedMilliseconds; _CreditNames[i].StartTimeUp = CreditsTimer.ElapsedMilliseconds;
} }
} }
break; break;
@@ -457,13 +441,9 @@ namespace Vocaluxe.Screens
float alpha = ((360 - _CreditNames[i].Y) / 200); float alpha = ((360 - _CreditNames[i].Y) / 200);
//Catch some bad alpha-values //Catch some bad alpha-values
if (alpha > 1) if (alpha > 1)
{
alpha = 1; alpha = 1;
}
else if (alpha < 0) else if (alpha < 0)
{
alpha = 0; alpha = 0;
}
_CreditNames[i].Alpha = 1 - alpha; _CreditNames[i].Alpha = 1 - alpha;
} }
@@ -474,9 +454,7 @@ namespace Vocaluxe.Screens
} }
if (TextTimer.IsRunning) if (TextTimer.IsRunning)
{
active = TextTimer.ElapsedMilliseconds <= 60000; active = TextTimer.ElapsedMilliseconds <= 60000;
}
return active; return active;
} }
+7 -31
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -11,7 +10,10 @@ namespace Vocaluxe.Screens
class CScreenHighscore : CMenu class CScreenHighscore : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 2; } } protected override int _ScreenVersion
{
get { return 2; }
}
private const int NumEntrys = 10; private const int NumEntrys = 10;
private const string TextSongName = "TextSongName"; private const string TextSongName = "TextSongName";
@@ -28,10 +30,6 @@ namespace Vocaluxe.Screens
private int _Pos; private int _Pos;
private bool _IsDuet; private bool _IsDuet;
public CScreenHighscore()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
@@ -70,9 +68,7 @@ namespace Vocaluxe.Screens
ParticleEffectNew = new string[NumEntrys]; ParticleEffectNew = new string[NumEntrys];
for (int i = 0; i < NumEntrys; i++) for (int i = 0; i < NumEntrys; i++)
{
ParticleEffectNew[i] = "ParticleEffectNew" + (i + 1).ToString(); ParticleEffectNew[i] = "ParticleEffectNew" + (i + 1).ToString();
}
_ThemeTexts = texts.ToArray(); _ThemeTexts = texts.ToArray();
_ThemeParticleEffects = ParticleEffectNew; _ThemeParticleEffects = ParticleEffectNew;
@@ -82,10 +78,7 @@ namespace Vocaluxe.Screens
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
{ {
if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -119,20 +112,13 @@ namespace Vocaluxe.Screens
public override bool HandleMouse(MouseEvent MouseEvent) public override bool HandleMouse(MouseEvent MouseEvent)
{ {
if (MouseEvent.LB && IsMouseOver(MouseEvent)) if (MouseEvent.LB && IsMouseOver(MouseEvent)) {}
{
}
if (MouseEvent.LB) if (MouseEvent.LB)
{
LeaveScreen(); LeaveScreen();
}
if (MouseEvent.RB) if (MouseEvent.RB)
{
LeaveScreen(); LeaveScreen();
}
if (MouseEvent.MB) if (MouseEvent.MB)
{ {
@@ -171,15 +157,11 @@ namespace Vocaluxe.Screens
Texts[TextScore[p]].Text = _Scores[_Round][_Pos + p].Score.ToString("00000"); Texts[TextScore[p]].Text = _Scores[_Round][_Pos + p].Score.ToString("00000");
Texts[TextDate[p]].Text = _Scores[_Round][_Pos + p].Date; Texts[TextDate[p]].Text = _Scores[_Round][_Pos + p].Date;
if (isNewEntry(_Scores[_Round][_Pos + p].ID) == true) if (isNewEntry(_Scores[_Round][_Pos + p].ID))
{
ParticleEffects[ParticleEffectNew[p]].Visible = true; ParticleEffects[ParticleEffectNew[p]].Visible = true;
}
else else
{
ParticleEffects[ParticleEffectNew[p]].Visible = false; ParticleEffects[ParticleEffectNew[p]].Visible = false;
} }
}
else else
{ {
Texts[TextNumber[p]].Visible = false; Texts[TextNumber[p]].Visible = false;
@@ -200,9 +182,7 @@ namespace Vocaluxe.Screens
CPoints _Points = CGame.GetPoints(); CPoints _Points = CGame.GetPoints();
_Scores = new List<SScores>[_Points.NumRounds]; _Scores = new List<SScores>[_Points.NumRounds];
for (int i = 0; i < _Scores.Length; i++) for (int i = 0; i < _Scores.Length; i++)
{
_Scores[i] = new List<SScores>(); _Scores[i] = new List<SScores>();
}
_NewEntryIDs.Clear(); _NewEntryIDs.Clear();
AddScoresToDB(); AddScoresToDB();
LoadScores(); LoadScores();
@@ -221,10 +201,8 @@ namespace Vocaluxe.Screens
for (int i = 0; i < _NewEntryIDs.Count; i++) for (int i = 0; i < _NewEntryIDs.Count; i++)
{ {
if (_NewEntryIDs[i] == id) if (_NewEntryIDs[i] == id)
{
return true; return true;
} }
}
return false; return false;
} }
@@ -272,9 +250,7 @@ namespace Vocaluxe.Screens
Texts[TextSongName].Text = song.Artist + " - " + song.Title; Texts[TextSongName].Text = song.Artist + " - " + song.Title;
if (points.NumRounds > 1) if (points.NumRounds > 1)
{
Texts[TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")"; Texts[TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
}
switch (CGame.GetGameMode(_Round)) switch (CGame.GetGameMode(_Round))
{ {
+16 -33
View File
@@ -1,7 +1,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -10,12 +9,15 @@ namespace Vocaluxe.Screens
class CScreenLoad : CMenu class CScreenLoad : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
const float WaitTime = 0.5f; //wait time before starting first video {
get { return 1; }
}
private const float WaitTime = 0.5f; //wait time before starting first video
const string TextStatus = "TextStatus"; private const string TextStatus = "TextStatus";
private readonly string[] IntroVideo = new string[] { "IntroIn", "IntroMid", "IntroOut" }; private readonly string[] IntroVideo = new[] {"IntroIn", "IntroMid", "IntroOut"};
private Thread _SongLoaderThread; private Thread _SongLoaderThread;
private Stopwatch _timer; private Stopwatch _timer;
@@ -26,21 +28,14 @@ namespace Vocaluxe.Screens
private bool _BGMusicStartet; private bool _BGMusicStartet;
public CScreenLoad()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeTexts = new string[] { TextStatus }; _ThemeTexts = new[] {TextStatus};
_Intros = new VideoPlayer[IntroVideo.Length]; _Intros = new VideoPlayer[IntroVideo.Length];
for (int i = 0; i < _Intros.Length; i++) for (int i = 0; i < _Intros.Length; i++)
{
_Intros[i] = new VideoPlayer(); _Intros[i] = new VideoPlayer();
}
_timer = new Stopwatch(); _timer = new Stopwatch();
} }
@@ -48,10 +43,7 @@ namespace Vocaluxe.Screens
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -72,9 +64,7 @@ namespace Vocaluxe.Screens
base.HandleMouse(MouseEvent); base.HandleMouse(MouseEvent);
if (MouseEvent.LB || MouseEvent.RB) if (MouseEvent.LB || MouseEvent.RB)
{
_SkipIntro = true; _SkipIntro = true;
}
return true; return true;
} }
@@ -94,7 +84,7 @@ namespace Vocaluxe.Screens
} }
} }
_SongLoaderThread = new Thread(new ThreadStart(CSongs.LoadSongs)); _SongLoaderThread = new Thread(CSongs.LoadSongs);
_SongLoaderThread.Name = "SongLoader"; _SongLoaderThread.Name = "SongLoader";
Texts[TextStatus].Text = CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": 0 " + Texts[TextStatus].Text = CLanguage.Translate("TR_SCREENLOAD_TOTAL") + ": 0 " +
@@ -108,10 +98,8 @@ namespace Vocaluxe.Screens
if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON)
{ {
for (int i = 0; i < _Intros.Length; i++) for (int i = 0; i < _Intros.Length; i++)
{
_Intros[i].Load(IntroVideo[i]); _Intros[i].Load(IntroVideo[i]);
} }
}
_BGMusicStartet = false; _BGMusicStartet = false;
} }
@@ -123,10 +111,8 @@ namespace Vocaluxe.Screens
if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON)
{ {
for (int i = 0; i < _Intros.Length; i++) for (int i = 0; i < _Intros.Length; i++)
{
_Intros[i].PreLoad(); _Intros[i].PreLoad();
} }
}
CLog.StartBenchmark(0, "Load Songs Full"); CLog.StartBenchmark(0, "Load Songs Full");
_SongLoaderThread.IsBackground = true; _SongLoaderThread.IsBackground = true;
@@ -159,9 +145,7 @@ namespace Vocaluxe.Screens
bool next = (CConfig.CoverLoading != ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART || CSongs.CoverLoaded); bool next = (CConfig.CoverLoading != ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART || CSongs.CoverLoaded);
if ((_IntroOutPlayed || _SkipIntro) && next && CSettings.GameState != EGameState.EditTheme && CSongs.SongsLoaded) if ((_IntroOutPlayed || _SkipIntro) && next && CSettings.GameState != EGameState.EditTheme && CSongs.SongsLoaded)
{
CSettings.GameState = EGameState.Normal; CSettings.GameState = EGameState.Normal;
}
if (CSettings.GameState == EGameState.Normal) if (CSettings.GameState == EGameState.Normal)
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
@@ -190,9 +174,7 @@ namespace Vocaluxe.Screens
DrawBG(); DrawBG();
for (int i = 0; i < _Intros.Length; i++) for (int i = 0; i < _Intros.Length; i++)
{
_Intros[i].Draw(); _Intros[i].Draw();
}
DrawFG(); DrawFG();
return true; return true;
@@ -205,9 +187,7 @@ namespace Vocaluxe.Screens
_timer.Reset(); _timer.Reset();
for (int i = 0; i < _Intros.Length; i++) for (int i = 0; i < _Intros.Length; i++)
{
_Intros[i].Close(); _Intros[i].Close();
}
CBackgroundMusic.CanSing = true; CBackgroundMusic.CanSing = true;
@@ -234,17 +214,20 @@ namespace Vocaluxe.Screens
{ {
_CurrentIntroVideoNr = 0; _CurrentIntroVideoNr = 0;
_Intros[0].Start(); _Intros[0].Start();
}else if (_CurrentIntroVideoNr == 0 && _Intros[0].IsFinished && CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART) }
else if (_CurrentIntroVideoNr == 0 && _Intros[0].IsFinished && CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART)
{ {
_CurrentIntroVideoNr = 1; _CurrentIntroVideoNr = 1;
_Intros[1].Loop = true; _Intros[1].Loop = true;
_Intros[1].Start(); _Intros[1].Start();
}else if ((_CurrentIntroVideoNr == 1 && CSongs.CoverLoaded) || }
else if ((_CurrentIntroVideoNr == 1 && CSongs.CoverLoaded) ||
(_CurrentIntroVideoNr == 0 && _Intros[0].IsFinished)) (_CurrentIntroVideoNr == 0 && _Intros[0].IsFinished))
{ {
_CurrentIntroVideoNr = 2; _CurrentIntroVideoNr = 2;
_Intros[2].Start(); _Intros[2].Start();
}else if (_CurrentIntroVideoNr == 2 && _Intros[2].IsFinished) }
else if (_CurrentIntroVideoNr == 2 && _Intros[2].IsFinished)
_IntroOutPlayed = true; _IntroOutPlayed = true;
} }
} }
+12 -17
View File
@@ -1,5 +1,4 @@
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -8,26 +7,25 @@ namespace Vocaluxe.Screens
class CScreenMain : CMenu class CScreenMain : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
{
get { return 1; }
}
const string ButtonSing = "ButtonSing"; private const string ButtonSing = "ButtonSing";
const string ButtonParty = "ButtonParty"; private const string ButtonParty = "ButtonParty";
const string ButtonOptions = "ButtonOptions"; private const string ButtonOptions = "ButtonOptions";
const string ButtonProfiles = "ButtonProfiles"; private const string ButtonProfiles = "ButtonProfiles";
const string ButtonExit = "ButtonExit"; private const string ButtonExit = "ButtonExit";
//CParticleEffect Snowflakes; //CParticleEffect Snowflakes;
public CScreenMain()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeStatics = new string[] { "StaticMenuBar" }; _ThemeStatics = new[] {"StaticMenuBar"};
_ThemeButtons = new string[] { ButtonSing, ButtonParty, ButtonOptions, ButtonProfiles, ButtonExit }; _ThemeButtons = new[] {ButtonSing, ButtonParty, ButtonOptions, ButtonProfiles, ButtonExit};
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
@@ -39,10 +37,7 @@ namespace Vocaluxe.Screens
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
+22 -69
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -10,7 +9,10 @@ namespace Vocaluxe.Screens
class CScreenNames : CMenu class CScreenNames : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 3; } } protected override int _ScreenVersion
{
get { return 3; }
}
private CStatic chooseAvatarStatic; private CStatic chooseAvatarStatic;
private int OldMouseX; private int OldMouseX;
@@ -24,37 +26,32 @@ namespace Vocaluxe.Screens
private const string StaticWarningMics = "StaticWarningMics"; private const string StaticWarningMics = "StaticWarningMics";
private const string TextWarningProfiles = "TextWarningProfiles"; private const string TextWarningProfiles = "TextWarningProfiles";
private const string StaticWarningProfiles = "StaticWarningProfiles"; private const string StaticWarningProfiles = "StaticWarningProfiles";
private readonly string[] StaticPlayer = new string[] { "StaticPlayer1", "StaticPlayer2", "StaticPlayer3", "StaticPlayer4", "StaticPlayer5", "StaticPlayer6" }; private readonly string[] StaticPlayer = new[] {"StaticPlayer1", "StaticPlayer2", "StaticPlayer3", "StaticPlayer4", "StaticPlayer5", "StaticPlayer6"};
private readonly string[] StaticPlayerAvatar = new string[] { "StaticPlayerAvatar1", "StaticPlayerAvatar2", "StaticPlayerAvatar3", "StaticPlayerAvatar4", "StaticPlayerAvatar5", "StaticPlayerAvatar6" }; private readonly string[] StaticPlayerAvatar = new[]
private readonly string[] TextPlayer = new string[] { "TextPlayer1", "TextPlayer2", "TextPlayer3", "TextPlayer4", "TextPlayer5", "TextPlayer6" }; {"StaticPlayerAvatar1", "StaticPlayerAvatar2", "StaticPlayerAvatar3", "StaticPlayerAvatar4", "StaticPlayerAvatar5", "StaticPlayerAvatar6"};
private readonly string[] EqualizerPlayer = new string[] { "EqualizerPlayer1", "EqualizerPlayer2", "EqualizerPlayer3", "EqualizerPlayer4", "EqualizerPlayer5", "EqualizerPlayer6" }; private readonly string[] TextPlayer = new[] {"TextPlayer1", "TextPlayer2", "TextPlayer3", "TextPlayer4", "TextPlayer5", "TextPlayer6"};
private readonly string[] SelectSlideDuetPlayer = new string[] { "SelectSlideDuetPlayer1", "SelectSlideDuetPlayer2", "SelectSlideDuetPlayer3", "SelectSlideDuetPlayer4", "SelectSlideDuetPlayer5", "SelectSlideDuetPlayer6" }; private readonly string[] EqualizerPlayer = new[] {"EqualizerPlayer1", "EqualizerPlayer2", "EqualizerPlayer3", "EqualizerPlayer4", "EqualizerPlayer5", "EqualizerPlayer6"};
private STexture[] OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer]; private readonly string[] SelectSlideDuetPlayer = new[]
{"SelectSlideDuetPlayer1", "SelectSlideDuetPlayer2", "SelectSlideDuetPlayer3", "SelectSlideDuetPlayer4", "SelectSlideDuetPlayer5", "SelectSlideDuetPlayer6"};
private readonly STexture[] OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer];
private bool selectingMouseActive = false; private bool selectingMouseActive;
private bool selectingKeyboardActive = false; private bool selectingKeyboardActive;
private bool selectingKeyboardUnendless = false; private bool selectingKeyboardUnendless;
private int selectingKeyboardPlayerNr = 0; private int selectingKeyboardPlayerNr;
private int SelectedPlayerNr; private int SelectedPlayerNr;
private int[] _PlayerNr; private int[] _PlayerNr;
public CScreenNames()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
List<string> statics = new List<string>(); List<string> statics = new List<string>();
foreach(string text in StaticPlayer){ foreach (string text in StaticPlayer)
statics.Add(text); statics.Add(text);
}
foreach (string text in StaticPlayerAvatar) foreach (string text in StaticPlayerAvatar)
{
statics.Add(text); statics.Add(text);
}
statics.Add(StaticWarningMics); statics.Add(StaticWarningMics);
statics.Add(StaticWarningProfiles); statics.Add(StaticWarningProfiles);
_ThemeStatics = statics.ToArray(); _ThemeStatics = statics.ToArray();
@@ -67,9 +64,8 @@ namespace Vocaluxe.Screens
texts.Clear(); texts.Clear();
texts.Add(TextWarningMics); texts.Add(TextWarningMics);
texts.Add(TextWarningProfiles); texts.Add(TextWarningProfiles);
foreach(string text in TextPlayer){ foreach (string text in TextPlayer)
texts.Add(text); texts.Add(text);
}
_ThemeTexts = texts.ToArray(); _ThemeTexts = texts.ToArray();
texts.Clear(); texts.Clear();
@@ -96,20 +92,14 @@ namespace Vocaluxe.Screens
_PlayerNr = new int[CSettings.MaxNumPlayer]; _PlayerNr = new int[CSettings.MaxNumPlayer];
for (int i = 0; i < _PlayerNr.Length; i++) for (int i = 0; i < _PlayerNr.Length; i++)
{
_PlayerNr[i] = i; _PlayerNr[i] = i;
}
for (int i = 0; i < CSettings.MaxNumPlayer; i++) for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
OriginalPlayerAvatarTextures[i] = Statics[StaticPlayerAvatar[i]].Texture; OriginalPlayerAvatarTextures[i] = Statics[StaticPlayerAvatar[i]].Texture;
}
for (int i = 1; i <= CSettings.MaxNumPlayer; i++) for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{
Equalizers["EqualizerPlayer" + i].ScreenHandles = true; Equalizers["EqualizerPlayer" + i].ScreenHandles = true;
} }
}
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
{ {
@@ -345,7 +335,6 @@ namespace Vocaluxe.Screens
SetInteractionToButton(Buttons[ButtonStart]); SetInteractionToButton(Buttons[ButtonStart]);
} }
break; break;
} }
} }
//Normal Keyboard handling //Normal Keyboard handling
@@ -470,7 +459,7 @@ namespace Vocaluxe.Screens
for (int i = 0; i < StaticPlayer.Length; i++) for (int i = 0; i < StaticPlayer.Length; i++)
{ {
//Check first, if area is "active" //Check first, if area is "active"
if (Statics[StaticPlayer[i]].Visible == true) if (Statics[StaticPlayer[i]].Visible)
{ {
//Check if Mouse is in area //Check if Mouse is in area
if (CHelper.IsInBounds(Statics[StaticPlayer[i]].Rect, MouseEvent)) if (CHelper.IsInBounds(Statics[StaticPlayer[i]].Rect, MouseEvent))
@@ -499,10 +488,7 @@ namespace Vocaluxe.Screens
chooseAvatarStatic.Visible = false; chooseAvatarStatic.Visible = false;
} }
if (MouseEvent.LB && IsMouseOver(MouseEvent)) if (MouseEvent.LB && IsMouseOver(MouseEvent)) {}
{
}
if (MouseEvent.LB && IsMouseOver(MouseEvent)) if (MouseEvent.LB && IsMouseOver(MouseEvent))
{ {
@@ -528,7 +514,6 @@ namespace Vocaluxe.Screens
if (MouseEvent.RB) if (MouseEvent.RB)
{ {
bool exit = true; bool exit = true;
//Remove profile-selection //Remove profile-selection
for (int i = 0; i < CConfig.NumPlayer; i++) for (int i = 0; i < CConfig.NumPlayer; i++)
@@ -629,13 +614,9 @@ namespace Vocaluxe.Screens
base.Draw(); base.Draw();
if (chooseAvatarStatic.Visible) if (chooseAvatarStatic.Visible)
{
chooseAvatarStatic.Draw(); chooseAvatarStatic.Draw();
}
for (int i = 1; i <= CGame.NumPlayer; i++) for (int i = 1; i <= CGame.NumPlayer; i++)
{
Equalizers["EqualizerPlayer" + i].Draw(); Equalizers["EqualizerPlayer" + i].Draw();
}
return true; return true;
} }
@@ -653,15 +634,11 @@ namespace Vocaluxe.Screens
{ {
//Just a work-around for not crashing the game //Just a work-around for not crashing the game
if (CGame.Player[i].Name == null) if (CGame.Player[i].Name == null)
{
CGame.Player[i].Name = ""; CGame.Player[i].Name = "";
} }
}
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
{
CGame.Player[i].LineNr = SelectSlides[SelectSlideDuetPlayer[i]].Selection; CGame.Player[i].LineNr = SelectSlides[SelectSlideDuetPlayer[i]].Selection;
} }
}
CGraphics.FadeTo(EScreens.ScreenSing); CGraphics.FadeTo(EScreens.ScreenSing);
} }
@@ -670,16 +647,14 @@ namespace Vocaluxe.Screens
{ {
SelectSlides[SelectSlidePlayerNumber].Clear(); SelectSlides[SelectSlidePlayerNumber].Clear();
for (int i = 1; i <= CSettings.MaxNumPlayer; i++) for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{
SelectSlides[SelectSlidePlayerNumber].AddValue(CLanguage.Translate("TR_SCREENNAMES_" + i + "PLAYER")); SelectSlides[SelectSlidePlayerNumber].AddValue(CLanguage.Translate("TR_SCREENNAMES_" + i + "PLAYER"));
}
SelectSlides[SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 1; SelectSlides[SelectSlidePlayerNumber].Selection = CConfig.NumPlayer - 1;
} }
private void UpdatePlayerNumber() private void UpdatePlayerNumber()
{ {
CConfig.NumPlayer = (int)SelectSlides[SelectSlidePlayerNumber].Selection + 1; CConfig.NumPlayer = SelectSlides[SelectSlidePlayerNumber].Selection + 1;
CGame.NumPlayer = (int)SelectSlides[SelectSlidePlayerNumber].Selection + 1; CGame.NumPlayer = SelectSlides[SelectSlidePlayerNumber].Selection + 1;
for (int i = 1; i <= CSettings.MaxNumPlayer; i++) for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
{ {
if (i <= CGame.NumPlayer) if (i <= CGame.NumPlayer)
@@ -688,9 +663,7 @@ namespace Vocaluxe.Screens
Statics["StaticPlayerAvatar" + i].Visible = true; Statics["StaticPlayerAvatar" + i].Visible = true;
Texts["TextPlayer" + i].Visible = true; Texts["TextPlayer" + i].Visible = true;
if (Texts["TextPlayer" + i].Text.Length == 0) if (Texts["TextPlayer" + i].Text.Length == 0)
{
Texts["TextPlayer" + i].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + i.ToString(); Texts["TextPlayer" + i].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + i.ToString();
}
Equalizers["EqualizerPlayer" + i].Visible = true; Equalizers["EqualizerPlayer" + i].Visible = true;
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
SelectSlides["SelectSlideDuetPlayer" + i].Visible = true; SelectSlides["SelectSlideDuetPlayer" + i].Visible = true;
@@ -715,10 +688,8 @@ namespace Vocaluxe.Screens
for (int player = 0; player < CConfig.NumPlayer; player++) for (int player = 0; player < CConfig.NumPlayer; player++)
{ {
if (!CConfig.IsMicConfig(player + 1)) if (!CConfig.IsMicConfig(player + 1))
{
_PlayerWithoutMicro.Add(player + 1); _PlayerWithoutMicro.Add(player + 1);
} }
}
if (_PlayerWithoutMicro.Count > 0) if (_PlayerWithoutMicro.Count > 0)
{ {
Statics[StaticWarningMics].Visible = true; Statics[StaticWarningMics].Visible = true;
@@ -730,26 +701,18 @@ namespace Vocaluxe.Screens
for (int i = 0; i < _PlayerWithoutMicro.Count; i++) for (int i = 0; i < _PlayerWithoutMicro.Count; i++)
{ {
if (_PlayerWithoutMicro.Count - 1 == i) if (_PlayerWithoutMicro.Count - 1 == i)
{
PlayerNums += _PlayerWithoutMicro[i].ToString(); PlayerNums += _PlayerWithoutMicro[i].ToString();
}
else if (_PlayerWithoutMicro.Count - 2 == i) else if (_PlayerWithoutMicro.Count - 2 == i)
{
PlayerNums += _PlayerWithoutMicro[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " "; PlayerNums += _PlayerWithoutMicro[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
}
else else
{
PlayerNums += _PlayerWithoutMicro[i].ToString() + ", "; PlayerNums += _PlayerWithoutMicro[i].ToString() + ", ";
} }
}
Texts[TextWarningMics].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_PL").Replace("%v", PlayerNums); Texts[TextWarningMics].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_PL").Replace("%v", PlayerNums);
} }
else else
{
Texts[TextWarningMics].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_SG").Replace("%v", _PlayerWithoutMicro[0].ToString()); Texts[TextWarningMics].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_SG").Replace("%v", _PlayerWithoutMicro[0].ToString());
} }
}
else else
{ {
Statics[StaticWarningMics].Visible = false; Statics[StaticWarningMics].Visible = false;
@@ -763,10 +726,8 @@ namespace Vocaluxe.Screens
for (int player = 0; player < CConfig.NumPlayer; player++) for (int player = 0; player < CConfig.NumPlayer; player++)
{ {
if (CGame.Player[player].ProfileID < 0) if (CGame.Player[player].ProfileID < 0)
{
_PlayerWithoutProfile.Add(player + 1); _PlayerWithoutProfile.Add(player + 1);
} }
}
if (_PlayerWithoutProfile.Count > 0) if (_PlayerWithoutProfile.Count > 0)
{ {
@@ -779,26 +740,18 @@ namespace Vocaluxe.Screens
for (int i = 0; i < _PlayerWithoutProfile.Count; i++) for (int i = 0; i < _PlayerWithoutProfile.Count; i++)
{ {
if (_PlayerWithoutProfile.Count - 1 == i) if (_PlayerWithoutProfile.Count - 1 == i)
{
PlayerNums += _PlayerWithoutProfile[i].ToString(); PlayerNums += _PlayerWithoutProfile[i].ToString();
}
else if (_PlayerWithoutProfile.Count - 2 == i) else if (_PlayerWithoutProfile.Count - 2 == i)
{
PlayerNums += _PlayerWithoutProfile[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " "; PlayerNums += _PlayerWithoutProfile[i].ToString() + " " + CLanguage.Translate("TR_GENERAL_AND") + " ";
}
else else
{
PlayerNums += _PlayerWithoutProfile[i].ToString() + ", "; PlayerNums += _PlayerWithoutProfile[i].ToString() + ", ";
} }
}
Texts[TextWarningProfiles].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_PROFILES_PL").Replace("%v", PlayerNums); Texts[TextWarningProfiles].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_PROFILES_PL").Replace("%v", PlayerNums);
} }
else else
{
Texts[TextWarningProfiles].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_PROFILES_SG").Replace("%v", _PlayerWithoutProfile[0].ToString()); Texts[TextWarningProfiles].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_PROFILES_SG").Replace("%v", _PlayerWithoutProfile[0].ToString());
} }
}
else else
{ {
Statics[StaticWarningProfiles].Visible = false; Statics[StaticWarningProfiles].Visible = false;
+6 -13
View File
@@ -1,5 +1,4 @@
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -8,7 +7,10 @@ namespace Vocaluxe.Screens
class CScreenOptions : CMenu class CScreenOptions : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
{
get { return 1; }
}
private const string ButtonOptionsGame = "ButtonOptionsGame"; private const string ButtonOptionsGame = "ButtonOptionsGame";
private const string ButtonOptionsSound = "ButtonOptionsSound"; private const string ButtonOptionsSound = "ButtonOptionsSound";
@@ -17,25 +19,18 @@ namespace Vocaluxe.Screens
private const string ButtonOptionsLyrics = "ButtonOptionsLyrics"; private const string ButtonOptionsLyrics = "ButtonOptionsLyrics";
private const string ButtonOptionsTheme = "ButtonOptionsTheme"; private const string ButtonOptionsTheme = "ButtonOptionsTheme";
public CScreenOptions()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeButtons = new string[] { ButtonOptionsGame, ButtonOptionsSound, ButtonOptionsRecord, ButtonOptionsVideo, ButtonOptionsLyrics, ButtonOptionsTheme }; _ThemeButtons = new[] {ButtonOptionsGame, ButtonOptionsSound, ButtonOptionsRecord, ButtonOptionsVideo, ButtonOptionsLyrics, ButtonOptionsTheme};
} }
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -101,9 +96,7 @@ namespace Vocaluxe.Screens
} }
if (MouseEvent.RB) if (MouseEvent.RB)
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
}
return true; return true;
} }
+6 -12
View File
@@ -1,5 +1,4 @@
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -8,7 +7,10 @@ namespace Vocaluxe.Screens
class CScreenOptionsGame : CMenu class CScreenOptionsGame : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
{
get { return 1; }
}
private const string SelectSlideLanguage = "SelectSlideLanguage"; private const string SelectSlideLanguage = "SelectSlideLanguage";
private const string SelectSlideDebugLevel = "SelectSlideDebugLevel"; private const string SelectSlideDebugLevel = "SelectSlideDebugLevel";
@@ -19,16 +21,12 @@ namespace Vocaluxe.Screens
private const string ButtonExit = "ButtonExit"; private const string ButtonExit = "ButtonExit";
public CScreenOptionsGame()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeButtons = new string[] { ButtonExit }; _ThemeButtons = new[] {ButtonExit};
_ThemeSelectSlides = new string[] { SelectSlideLanguage, SelectSlideDebugLevel, SelectSlideSongMenu, SelectSlideSongSorting, SelectSlideTabs, SelectSlideTimerMode }; _ThemeSelectSlides = new[] {SelectSlideLanguage, SelectSlideDebugLevel, SelectSlideSongMenu, SelectSlideSongSorting, SelectSlideTabs, SelectSlideTimerMode};
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
@@ -43,7 +41,6 @@ namespace Vocaluxe.Screens
SelectSlides[SelectSlideSongSorting].SetValues<ESongSorting>((int)CConfig.SongSorting); SelectSlides[SelectSlideSongSorting].SetValues<ESongSorting>((int)CConfig.SongSorting);
SelectSlides[SelectSlideTabs].SetValues<EOffOn>((int)CConfig.Tabs); SelectSlides[SelectSlideTabs].SetValues<EOffOn>((int)CConfig.Tabs);
SelectSlides[SelectSlideTimerMode].SetValues<ETimerMode>((int)CConfig.TimerMode); SelectSlides[SelectSlideTimerMode].SetValues<ETimerMode>((int)CConfig.TimerMode);
} }
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
@@ -99,10 +96,8 @@ namespace Vocaluxe.Screens
{ {
SaveConfig(); SaveConfig();
if (Buttons[ButtonExit].Selected) if (Buttons[ButtonExit].Selected)
{
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
}
return true; return true;
} }
@@ -131,7 +126,6 @@ namespace Vocaluxe.Screens
CSongs.Sorter.SongSorting = CConfig.SongSorting; CSongs.Sorter.SongSorting = CConfig.SongSorting;
CSongs.Categorizer.Tabs = CConfig.Tabs; CSongs.Categorizer.Tabs = CConfig.Tabs;
} }
} }
} }
+7 -14
View File
@@ -1,5 +1,4 @@
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -8,23 +7,22 @@ namespace Vocaluxe.Screens
class CScreenOptionsLyrics : CMenu class CScreenOptionsLyrics : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
{
get { return 1; }
}
private const string SelectSlideLyricStyle = "SelectSlideLyricStyle"; private const string SelectSlideLyricStyle = "SelectSlideLyricStyle";
private const string SelectSlideLyricsOnTop = "SelectSlideLyricsOnTop"; private const string SelectSlideLyricsOnTop = "SelectSlideLyricsOnTop";
private const string ButtonExit = "ButtonExit"; private const string ButtonExit = "ButtonExit";
public CScreenOptionsLyrics()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeButtons = new string[] { ButtonExit }; _ThemeButtons = new[] {ButtonExit};
_ThemeSelectSlides = new string[] { SelectSlideLyricStyle, SelectSlideLyricsOnTop }; _ThemeSelectSlides = new[] {SelectSlideLyricStyle, SelectSlideLyricsOnTop};
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
@@ -38,10 +36,7 @@ namespace Vocaluxe.Screens
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -90,10 +85,8 @@ namespace Vocaluxe.Screens
{ {
SaveConfig(); SaveConfig();
if (Buttons[ButtonExit].Selected) if (Buttons[ButtonExit].Selected)
{
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
}
return true; return true;
} }
+11 -40
View File
@@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.Lib.Sound; using Vocaluxe.Lib.Sound;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -17,7 +16,10 @@ namespace Vocaluxe.Screens
class CScreenOptionsRecord : CMenu class CScreenOptionsRecord : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 2; } } protected override int _ScreenVersion
{
get { return 2; }
}
private const float MaxDelayTime = 1f; private const float MaxDelayTime = 1f;
private const string SelectSlideRecordDevices = "SelectSlideRecordDevices"; private const string SelectSlideRecordDevices = "SelectSlideRecordDevices";
@@ -39,7 +41,7 @@ namespace Vocaluxe.Screens
private const string EqualizerChannel1 = "EqualizerChannel1"; private const string EqualizerChannel1 = "EqualizerChannel1";
private const string EqualizerChannel2 = "EqualizerChannel2"; private const string EqualizerChannel2 = "EqualizerChannel2";
private readonly string[] StaticEnergyChannel = new string[] { "StaticEnergyChannel1", "StaticEnergyChannel2" }; private readonly string[] StaticEnergyChannel = new[] {"StaticEnergyChannel1", "StaticEnergyChannel2"};
private float[] ChannelEnergy; private float[] ChannelEnergy;
private SRecordDevice[] _devices; private SRecordDevice[] _devices;
@@ -50,10 +52,6 @@ namespace Vocaluxe.Screens
private bool _DelayTestRunning; private bool _DelayTestRunning;
private int _DelaySound; private int _DelaySound;
public CScreenOptionsRecord()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
@@ -63,10 +61,10 @@ namespace Vocaluxe.Screens
values.AddRange(StaticEnergyChannel); values.AddRange(StaticEnergyChannel);
_ThemeStatics = values.ToArray(); _ThemeStatics = values.ToArray();
_ThemeTexts = new string[] { TextWarning, TextDelayChannel1, TextDelayChannel2 }; _ThemeTexts = new[] {TextWarning, TextDelayChannel1, TextDelayChannel2};
_ThemeButtons = new string[] { ButtonExit, ButtonDelayTest }; _ThemeButtons = new[] {ButtonExit, ButtonDelayTest};
_ThemeSelectSlides = new string[] { SelectSlideRecordDevices, SelectSlideRecordInputs, SelectSlideRecordChannel1, SelectSlideRecordChannel2, SelectSlideDelay }; _ThemeSelectSlides = new[] {SelectSlideRecordDevices, SelectSlideRecordInputs, SelectSlideRecordChannel1, SelectSlideRecordChannel2, SelectSlideDelay};
_ThemeEqualizers = new string[] { EqualizerChannel1, EqualizerChannel2 }; _ThemeEqualizers = new[] {EqualizerChannel1, EqualizerChannel2};
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
@@ -90,9 +88,7 @@ namespace Vocaluxe.Screens
} }
for (int i = 0; i < 26; i++) for (int i = 0; i < 26; i++)
{
SelectSlides[SelectSlideDelay].AddValue((i * 20).ToString() + " ms"); SelectSlides[SelectSlideDelay].AddValue((i * 20).ToString() + " ms");
}
ChannelEnergy = new float[StaticEnergyChannel.Length]; ChannelEnergy = new float[StaticEnergyChannel.Length];
@@ -110,10 +106,7 @@ namespace Vocaluxe.Screens
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -137,9 +130,7 @@ namespace Vocaluxe.Screens
} }
if (Buttons[ButtonDelayTest].Selected) if (Buttons[ButtonDelayTest].Selected)
{
TestDelay(); TestDelay();
}
break; break;
@@ -213,19 +204,15 @@ namespace Vocaluxe.Screens
} }
if (Buttons[ButtonDelayTest].Selected) if (Buttons[ButtonDelayTest].Selected)
{
TestDelay(); TestDelay();
} }
}
return true; return true;
} }
public override bool UpdateGame() public override bool UpdateGame()
{ {
for (int i = 0; i < CSettings.MaxNumPlayer; i++) for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
CSound.AnalyzeBuffer(i); CSound.AnalyzeBuffer(i);
}
if (_DelayTest != null) if (_DelayTest != null)
{ {
@@ -293,9 +280,7 @@ namespace Vocaluxe.Screens
else else
{ {
for (int i = 0; i < ChannelEnergy.Length; i++) for (int i = 0; i < ChannelEnergy.Length; i++)
{
ChannelEnergy[i] = 0f; ChannelEnergy[i] = 0f;
}
Equalizers[EqualizerChannel1].Reset(); Equalizers[EqualizerChannel1].Reset();
Equalizers[EqualizerChannel2].Reset(); Equalizers[EqualizerChannel2].Reset();
} }
@@ -311,9 +296,7 @@ namespace Vocaluxe.Screens
SelectSlides[SelectSlideRecordInputs].Clear(); SelectSlides[SelectSlideRecordInputs].Clear();
for (int i = 0; i < ChannelEnergy.Length; i++) for (int i = 0; i < ChannelEnergy.Length; i++)
{
ChannelEnergy[i] = 0f; ChannelEnergy[i] = 0f;
}
_DeviceNr = -1; _DeviceNr = -1;
_InputNr = -1; _InputNr = -1;
@@ -326,15 +309,11 @@ namespace Vocaluxe.Screens
GetFirstConfiguredRecordDevice(ref _DeviceNr, ref _InputNr); GetFirstConfiguredRecordDevice(ref _DeviceNr, ref _InputNr);
for (int dev = 0; dev < _devices.Length; dev++) for (int dev = 0; dev < _devices.Length; dev++)
{
SelectSlides[SelectSlideRecordDevices].AddValue(_devices[dev].Name); SelectSlides[SelectSlideRecordDevices].AddValue(_devices[dev].Name);
}
SelectSlides[SelectSlideRecordDevices].Selection = _DeviceNr; SelectSlides[SelectSlideRecordDevices].Selection = _DeviceNr;
for (int inp = 0; inp < _devices[0].Inputs.Count; inp++) for (int inp = 0; inp < _devices[0].Inputs.Count; inp++)
{
SelectSlides[SelectSlideRecordInputs].AddValue(_devices[0].Inputs[inp].Name); SelectSlides[SelectSlideRecordInputs].AddValue(_devices[0].Inputs[inp].Name);
}
SelectSlides[SelectSlideRecordInputs].Selection = _InputNr; SelectSlides[SelectSlideRecordInputs].Selection = _InputNr;
UpdateChannels(); UpdateChannels();
} }
@@ -356,7 +335,7 @@ namespace Vocaluxe.Screens
} }
} }
SelectSlides[SelectSlideDelay].Selection = (int)(CConfig.MicDelay / 20); SelectSlides[SelectSlideDelay].Selection = (CConfig.MicDelay / 20);
_DelayTestRunning = false; _DelayTestRunning = false;
_DelaySound = -1; _DelaySound = -1;
@@ -424,9 +403,7 @@ namespace Vocaluxe.Screens
_InputNr = 0; _InputNr = 0;
for (int inp = 0; inp < _devices[_DeviceNr].Inputs.Count; inp++) for (int inp = 0; inp < _devices[_DeviceNr].Inputs.Count; inp++)
{
SelectSlides[SelectSlideRecordInputs].AddValue(_devices[_DeviceNr].Inputs[inp].Name); SelectSlides[SelectSlideRecordInputs].AddValue(_devices[_DeviceNr].Inputs[inp].Name);
}
_InputNr = 0; _InputNr = 0;
SelectSlides[SelectSlideRecordInputs].Selection = 0; SelectSlides[SelectSlideRecordInputs].Selection = 0;
UpdateChannels(); UpdateChannels();
@@ -460,9 +437,7 @@ namespace Vocaluxe.Screens
if (CheckMicConfig()) if (CheckMicConfig())
{ {
for (int p = 0; p < CSettings.MaxNumPlayer; p++) for (int p = 0; p < CSettings.MaxNumPlayer; p++)
{
CConfig.MicConfig[p].Channel = 0; CConfig.MicConfig[p].Channel = 0;
}
for (int dev = 0; dev < _devices.Length; dev++) for (int dev = 0; dev < _devices.Length; dev++)
{ {
@@ -483,7 +458,6 @@ namespace Vocaluxe.Screens
CConfig.MicConfig[_devices[dev].Inputs[inp].PlayerChannel2 - 1].DeviceDriver = _devices[dev].Driver; CConfig.MicConfig[_devices[dev].Inputs[inp].PlayerChannel2 - 1].DeviceDriver = _devices[dev].Driver;
CConfig.MicConfig[_devices[dev].Inputs[inp].PlayerChannel2 - 1].InputName = _devices[dev].Inputs[inp].Name; CConfig.MicConfig[_devices[dev].Inputs[inp].PlayerChannel2 - 1].InputName = _devices[dev].Inputs[inp].Name;
} }
} }
} }
CConfig.SaveConfig(); CConfig.SaveConfig();
@@ -513,9 +487,7 @@ namespace Vocaluxe.Screens
{ {
bool[] IsSet = new bool[CSettings.MaxNumPlayer]; bool[] IsSet = new bool[CSettings.MaxNumPlayer];
for (int i = 0; i < CSettings.MaxNumPlayer; i++) for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
IsSet[i] = false; IsSet[i] = false;
}
if (_devices == null) if (_devices == null)
return true; return true;
@@ -539,7 +511,6 @@ namespace Vocaluxe.Screens
IsSet[_devices[dev].Inputs[inp].PlayerChannel2 - 1] = true; IsSet[_devices[dev].Inputs[inp].PlayerChannel2 - 1] = true;
} }
} }
} }
return true; return true;
+15 -20
View File
@@ -1,5 +1,4 @@
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -8,7 +7,10 @@ namespace Vocaluxe.Screens
class CScreenOptionsSound : CMenu class CScreenOptionsSound : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 3; } } protected override int _ScreenVersion
{
get { return 3; }
}
private const string SelectSlideBackgroundMusic = "SelectSlideBackgroundMusic"; private const string SelectSlideBackgroundMusic = "SelectSlideBackgroundMusic";
private const string SelectSlideBackgroundMusicVolume = "SelectSlideBackgroundMusicVolume"; private const string SelectSlideBackgroundMusicVolume = "SelectSlideBackgroundMusicVolume";
@@ -21,41 +23,37 @@ namespace Vocaluxe.Screens
private int _BackgroundMusicVolume; private int _BackgroundMusicVolume;
private EOffOn _BackgroundMusic; private EOffOn _BackgroundMusic;
public CScreenOptionsSound()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeButtons = new string[] { ButtonExit }; _ThemeButtons = new[] {ButtonExit};
_ThemeSelectSlides = new string[] { SelectSlideBackgroundMusic, SelectSlideBackgroundMusicVolume, SelectSlideBackgroundMusicSource, SelectSlidePreviewMusicVolume, SelectSlideGameMusicVolume }; _ThemeSelectSlides = new[]
{SelectSlideBackgroundMusic, SelectSlideBackgroundMusicVolume, SelectSlideBackgroundMusicSource, SelectSlidePreviewMusicVolume, SelectSlideGameMusicVolume};
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
{ {
base.LoadTheme(XmlPath); base.LoadTheme(XmlPath);
SelectSlides[SelectSlideBackgroundMusic].SetValues<EOffOn>((int)CConfig.BackgroundMusic); SelectSlides[SelectSlideBackgroundMusic].SetValues<EOffOn>((int)CConfig.BackgroundMusic);
SelectSlides[SelectSlideBackgroundMusicVolume].AddValues(new string[] { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"}); SelectSlides[SelectSlideBackgroundMusicVolume].AddValues(new[]
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
SelectSlides[SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5; SelectSlides[SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5;
SelectSlides[SelectSlideBackgroundMusicSource].SetValues<EBackgroundMusicSource>((int)CConfig.BackgroundMusicSource); SelectSlides[SelectSlideBackgroundMusicSource].SetValues<EBackgroundMusicSource>((int)CConfig.BackgroundMusicSource);
SelectSlides[SelectSlideBackgroundMusicSource].Selection = (int)CConfig.BackgroundMusicSource; SelectSlides[SelectSlideBackgroundMusicSource].Selection = (int)CConfig.BackgroundMusicSource;
SelectSlides[SelectSlidePreviewMusicVolume].AddValues(new string[] { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" }); SelectSlides[SelectSlidePreviewMusicVolume].AddValues(new[]
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
SelectSlides[SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5; SelectSlides[SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5;
SelectSlides[SelectSlideGameMusicVolume].AddValues(new string[] { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" }); SelectSlides[SelectSlideGameMusicVolume].AddValues(new[]
{"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"});
SelectSlides[SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5; SelectSlides[SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5;
} }
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -104,19 +102,15 @@ namespace Vocaluxe.Screens
{ {
SaveConfig(); SaveConfig();
if (Buttons[ButtonExit].Selected) if (Buttons[ButtonExit].Selected)
{
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
}
return true; return true;
} }
public override bool UpdateGame() public override bool UpdateGame()
{ {
if (_BackgroundMusicVolume != CConfig.BackgroundMusicVolume) if (_BackgroundMusicVolume != CConfig.BackgroundMusicVolume)
{
SelectSlides[SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5; SelectSlides[SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5;
}
return true; return true;
} }
@@ -135,6 +129,7 @@ namespace Vocaluxe.Screens
SelectSlides[SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5; SelectSlides[SelectSlideGameMusicVolume].Selection = CConfig.GameMusicVolume / 5;
SelectSlides[SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5; SelectSlides[SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5;
} }
private void SaveConfig() private void SaveConfig()
{ {
CConfig.GameMusicVolume = SelectSlides[SelectSlideGameMusicVolume].Selection * 5; CConfig.GameMusicVolume = SelectSlides[SelectSlideGameMusicVolume].Selection * 5;
+8 -18
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -9,7 +8,10 @@ namespace Vocaluxe.Screens
class CScreenOptionsTheme : CMenu class CScreenOptionsTheme : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 3; } } protected override int _ScreenVersion
{
get { return 3; }
}
private const string SelectSlideTheme = "SelectSlideTheme"; private const string SelectSlideTheme = "SelectSlideTheme";
private const string SelectSlideSkin = "SelectSlideSkin"; private const string SelectSlideSkin = "SelectSlideSkin";
@@ -28,16 +30,13 @@ namespace Vocaluxe.Screens
private int _TempSkin; private int _TempSkin;
public CScreenOptionsTheme()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeButtons = new string[] { ButtonExit }; _ThemeButtons = new[] {ButtonExit};
_ThemeSelectSlides = new string[] { _ThemeSelectSlides = new[]
{
SelectSlideTheme, SelectSlideTheme,
SelectSlideSkin, SelectSlideSkin,
SelectSlideCover, SelectSlideCover,
@@ -72,10 +71,7 @@ namespace Vocaluxe.Screens
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -92,9 +88,7 @@ namespace Vocaluxe.Screens
case Keys.Enter: case Keys.Enter:
if (Buttons[ButtonExit].Selected) if (Buttons[ButtonExit].Selected)
{
Close(); Close();
}
break; break;
case Keys.Left: case Keys.Left:
@@ -114,16 +108,12 @@ namespace Vocaluxe.Screens
base.HandleMouse(MouseEvent); base.HandleMouse(MouseEvent);
if (MouseEvent.RB) if (MouseEvent.RB)
{
Close(); Close();
}
if (MouseEvent.LB && IsMouseOver(MouseEvent)) if (MouseEvent.LB && IsMouseOver(MouseEvent))
{ {
if (Buttons[ButtonExit].Selected) if (Buttons[ButtonExit].Selected)
{
Close(); Close();
}
else else
OnChange(); OnChange();
} }
+17 -21
View File
@@ -9,7 +9,10 @@ namespace Vocaluxe.Screens
class CScreenOptionsVideo : CMenu class CScreenOptionsVideo : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 3; } } protected override int _ScreenVersion
{
get { return 3; }
}
private const string SelectSlideVideoBackgrounds = "SelectSlideVideoBackgrounds"; private const string SelectSlideVideoBackgrounds = "SelectSlideVideoBackgrounds";
private const string SelectSlideVideoPreview = "SelectSlideVideoPreview"; private const string SelectSlideVideoPreview = "SelectSlideVideoPreview";
@@ -23,21 +26,21 @@ namespace Vocaluxe.Screens
private const string ButtonExit = "ButtonExit"; private const string ButtonExit = "ButtonExit";
private SWebcamConfig _Config; private SWebcamConfig _Config;
STexture _WebcamTexture = new STexture(-1); private STexture _WebcamTexture = new STexture(-1);
private int _DeviceNr; private int _DeviceNr;
private int _CapabilityNr; private int _CapabilityNr;
public CScreenOptionsVideo()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeStatics = new string[] { StaticWebcamOutput }; _ThemeStatics = new[] {StaticWebcamOutput};
_ThemeButtons = new string[] { ButtonExit }; _ThemeButtons = new[] {ButtonExit};
_ThemeSelectSlides = new string[] { SelectSlideVideoBackgrounds, SelectSlideVideoPreview, SelectSlideVideosInSongs, SelectSlideVideosToBackground, SelectSlideWebcamDevices, SelectSlideWebcamCapabilities }; _ThemeSelectSlides = new[]
{
SelectSlideVideoBackgrounds, SelectSlideVideoPreview, SelectSlideVideosInSongs, SelectSlideVideosToBackground, SelectSlideWebcamDevices,
SelectSlideWebcamCapabilities
};
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
@@ -54,10 +57,7 @@ namespace Vocaluxe.Screens
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -119,10 +119,8 @@ namespace Vocaluxe.Screens
OnCapabilitiesEvent(); OnCapabilitiesEvent();
SaveConfig(); SaveConfig();
if (Buttons[ButtonExit].Selected) if (Buttons[ButtonExit].Selected)
{
CGraphics.FadeTo(EScreens.ScreenOptions); CGraphics.FadeTo(EScreens.ScreenOptions);
} }
}
return true; return true;
} }
@@ -169,15 +167,11 @@ namespace Vocaluxe.Screens
GetFirstConfiguredWebcamDevice(ref _DeviceNr, ref _CapabilityNr); GetFirstConfiguredWebcamDevice(ref _DeviceNr, ref _CapabilityNr);
foreach (SWebcamDevice d in devices) foreach (SWebcamDevice d in devices)
{
SelectSlides[SelectSlideWebcamDevices].AddValue(d.Name); SelectSlides[SelectSlideWebcamDevices].AddValue(d.Name);
}
SelectSlides[SelectSlideWebcamDevices].Selection = _DeviceNr; SelectSlides[SelectSlideWebcamDevices].Selection = _DeviceNr;
foreach (SCapabilities c in devices[_DeviceNr].Capabilities) foreach (SCapabilities c in devices[_DeviceNr].Capabilities)
{
SelectSlides[SelectSlideWebcamCapabilities].AddValue(c.Width.ToString() + " x " + c.Height.ToString() + " @ " + c.Framerate.ToString() + " FPS "); SelectSlides[SelectSlideWebcamCapabilities].AddValue(c.Width.ToString() + " x " + c.Height.ToString() + " @ " + c.Framerate.ToString() + " FPS ");
}
_Config.MonikerString = devices[SelectSlides[SelectSlideWebcamDevices].Selection].MonikerString; _Config.MonikerString = devices[SelectSlides[SelectSlideWebcamDevices].Selection].MonikerString;
_Config.Width = devices[SelectSlides[SelectSlideWebcamDevices].Selection].Capabilities[SelectSlides[SelectSlideWebcamCapabilities].Selection].Width; _Config.Width = devices[SelectSlides[SelectSlideWebcamDevices].Selection].Capabilities[SelectSlides[SelectSlideWebcamCapabilities].Selection].Width;
_Config.Height = devices[SelectSlides[SelectSlideWebcamDevices].Selection].Capabilities[SelectSlides[SelectSlideWebcamCapabilities].Selection].Height; _Config.Height = devices[SelectSlides[SelectSlideWebcamDevices].Selection].Capabilities[SelectSlides[SelectSlideWebcamCapabilities].Selection].Height;
@@ -223,7 +217,8 @@ namespace Vocaluxe.Screens
SWebcamDevice[] d = CWebcam.GetDevices(); SWebcamDevice[] d = CWebcam.GetDevices();
for (int i = 0; i < d[SelectSlides[SelectSlideWebcamDevices].Selection].Capabilities.Count; i++) for (int i = 0; i < d[SelectSlides[SelectSlideWebcamDevices].Selection].Capabilities.Count; i++)
{ {
SelectSlides[SelectSlideWebcamCapabilities].AddValue(d[_DeviceNr].Capabilities[i].Width.ToString() + " x " + d[_DeviceNr].Capabilities[i].Height.ToString() + " @ " + d[_DeviceNr].Capabilities[i].Framerate.ToString() + "FPS"); SelectSlides[SelectSlideWebcamCapabilities].AddValue(d[_DeviceNr].Capabilities[i].Width.ToString() + " x " + d[_DeviceNr].Capabilities[i].Height.ToString() +
" @ " + d[_DeviceNr].Capabilities[i].Framerate.ToString() + "FPS");
} }
SelectSlides[SelectSlideWebcamCapabilities].Selection = 0; SelectSlides[SelectSlideWebcamCapabilities].Selection = 0;
@@ -269,7 +264,8 @@ namespace Vocaluxe.Screens
{ {
for (int j = 0; j < devices[i].Capabilities.Count; j++) for (int j = 0; j < devices[i].Capabilities.Count; j++)
{ {
if (devices[i].Capabilities[j].Framerate == CConfig.WebcamConfig.Framerate && devices[i].Capabilities[j].Width == CConfig.WebcamConfig.Width && devices[i].Capabilities[j].Height == CConfig.WebcamConfig.Height) if (devices[i].Capabilities[j].Framerate == CConfig.WebcamConfig.Framerate && devices[i].Capabilities[j].Width == CConfig.WebcamConfig.Width &&
devices[i].Capabilities[j].Height == CConfig.WebcamConfig.Height)
{ {
Device = i; Device = i;
Capabilities = j; Capabilities = j;
+18 -27
View File
@@ -1,6 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -9,32 +8,31 @@ namespace Vocaluxe.Screens
class CScreenParty : CMenu class CScreenParty : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
{
get { return 1; }
}
const string TextDescription = "TextDescription"; private const string TextDescription = "TextDescription";
const string TextTargetAudience = "TextTargetAudience"; private const string TextTargetAudience = "TextTargetAudience";
const string TextNumTeams = "TextNumTeams"; private const string TextNumTeams = "TextNumTeams";
const string TextNumPlayers = "TextNumPlayers"; private const string TextNumPlayers = "TextNumPlayers";
const string TextAuthor = "TextAuthor"; private const string TextAuthor = "TextAuthor";
const string TextVersion = "TextVersion"; private const string TextVersion = "TextVersion";
const string TextError = "TextError"; private const string TextError = "TextError";
const string ButtonStart = "ButtonStart"; private const string ButtonStart = "ButtonStart";
const string ButtonExit = "ButtonExit"; private const string ButtonExit = "ButtonExit";
const string SelectSlideModes = "SelectSlideModes"; private const string SelectSlideModes = "SelectSlideModes";
private List<SPartyModeInfos> _PartyModeInfos; private List<SPartyModeInfos> _PartyModeInfos;
public CScreenParty()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeTexts = new string[] { TextDescription, TextTargetAudience, TextNumTeams, TextNumPlayers, TextAuthor, TextVersion, TextError }; _ThemeTexts = new[] {TextDescription, TextTargetAudience, TextNumTeams, TextNumPlayers, TextAuthor, TextVersion, TextError};
_ThemeButtons = new string[] { ButtonStart, ButtonExit }; _ThemeButtons = new[] {ButtonStart, ButtonExit};
_ThemeSelectSlides = new string[] { SelectSlideModes }; _ThemeSelectSlides = new[] {SelectSlideModes};
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
@@ -46,10 +44,7 @@ namespace Vocaluxe.Screens
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -94,9 +89,7 @@ namespace Vocaluxe.Screens
} }
if (MouseEvent.RB) if (MouseEvent.RB)
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
}
return true; return true;
} }
@@ -109,9 +102,7 @@ namespace Vocaluxe.Screens
SelectSlides[SelectSlideModes].Clear(); SelectSlides[SelectSlideModes].Clear();
foreach (SPartyModeInfos info in _PartyModeInfos) foreach (SPartyModeInfos info in _PartyModeInfos)
{
SelectSlides[SelectSlideModes].AddValue(info.Name, info.PartyModeID); SelectSlides[SelectSlideModes].AddValue(info.Name, info.PartyModeID);
}
SelectSlides[SelectSlideModes].Selection = 0; SelectSlides[SelectSlideModes].Selection = 0;
UpdateSelection(); UpdateSelection();
+49 -67
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
@@ -16,7 +17,10 @@ namespace Vocaluxe.Screens
class CScreenProfiles : CMenu class CScreenProfiles : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 2; } } protected override int _ScreenVersion
{
get { return 2; }
}
private const string SelectSlideProfiles = "SelectSlideProfiles"; private const string SelectSlideProfiles = "SelectSlideProfiles";
private const string SelectSlideDifficulty = "SelectSlideDifficulty"; private const string SelectSlideDifficulty = "SelectSlideDifficulty";
@@ -38,19 +42,15 @@ namespace Vocaluxe.Screens
private EEditMode _EditMode; private EEditMode _EditMode;
private STexture _WebcamTexture = new STexture(-1); private STexture _WebcamTexture = new STexture(-1);
private Bitmap _Snapshot = null; private Bitmap _Snapshot;
public CScreenProfiles()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_ThemeButtons = new string[] { ButtonPlayerName, ButtonExit, ButtonSave, ButtonNew, ButtonDelete, ButtonWebcam, ButtonSaveSnapshot, ButtonDiscardSnapshot, ButtonTakeSnapshot }; _ThemeButtons = new[] {ButtonPlayerName, ButtonExit, ButtonSave, ButtonNew, ButtonDelete, ButtonWebcam, ButtonSaveSnapshot, ButtonDiscardSnapshot, ButtonTakeSnapshot};
_ThemeSelectSlides = new string[] { SelectSlideProfiles, SelectSlideDifficulty, SelectSlideAvatars, SelectSlideGuestProfile, SelectSlideActive }; _ThemeSelectSlides = new[] {SelectSlideProfiles, SelectSlideDifficulty, SelectSlideAvatars, SelectSlideGuestProfile, SelectSlideActive};
_ThemeStatics = new string[] { StaticAvatar }; _ThemeStatics = new[] {StaticAvatar};
_EditMode = EEditMode.None; _EditMode = EEditMode.None;
} }
@@ -69,7 +69,6 @@ namespace Vocaluxe.Screens
SelectSlides[SelectSlideDifficulty].SetValues<EGameDifficulty>(0); SelectSlides[SelectSlideDifficulty].SetValues<EGameDifficulty>(0);
SelectSlides[SelectSlideGuestProfile].SetValues<EOffOn>(0); SelectSlides[SelectSlideGuestProfile].SetValues<EOffOn>(0);
SelectSlides[SelectSlideActive].SetValues<EOffOn>(0); SelectSlides[SelectSlideActive].SetValues<EOffOn>(0);
} }
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
@@ -99,36 +98,28 @@ namespace Vocaluxe.Screens
case Keys.Enter: case Keys.Enter:
if (Buttons[ButtonExit].Selected) if (Buttons[ButtonExit].Selected)
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
} else if (Buttons[ButtonSave].Selected) else if (Buttons[ButtonSave].Selected)
{
SaveProfiles(); SaveProfiles();
} else if (Buttons[ButtonNew].Selected) else if (Buttons[ButtonNew].Selected)
{
NewProfile(); NewProfile();
} else if (Buttons[ButtonPlayerName].Selected) else if (Buttons[ButtonPlayerName].Selected)
{ {
if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName) if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName)
_EditMode = EEditMode.PlayerName; _EditMode = EEditMode.PlayerName;
else else
_EditMode = EEditMode.None; _EditMode = EEditMode.None;
} else if (Buttons[ButtonDelete].Selected)
{
DeleteProfile();
} else if (Buttons[ButtonWebcam].Selected && CWebcam.GetDevices().Length > 0)
{
OnWebcam();
} else if (Buttons[ButtonSaveSnapshot].Selected && CWebcam.GetDevices().Length > 0)
{
OnSaveSnapshot();
} else if (Buttons[ButtonDiscardSnapshot].Selected && CWebcam.GetDevices().Length > 0)
{
OnDiscardSnapshot();
} else if (Buttons[ButtonTakeSnapshot].Selected && CWebcam.GetDevices().Length > 0)
{
OnTakeSnapshot();
} }
else if (Buttons[ButtonDelete].Selected)
DeleteProfile();
else if (Buttons[ButtonWebcam].Selected && CWebcam.GetDevices().Length > 0)
OnWebcam();
else if (Buttons[ButtonSaveSnapshot].Selected && CWebcam.GetDevices().Length > 0)
OnSaveSnapshot();
else if (Buttons[ButtonDiscardSnapshot].Selected && CWebcam.GetDevices().Length > 0)
OnDiscardSnapshot();
else if (Buttons[ButtonTakeSnapshot].Selected && CWebcam.GetDevices().Length > 0)
OnTakeSnapshot();
break; break;
case Keys.Back: case Keys.Back:
@@ -149,15 +140,18 @@ namespace Vocaluxe.Screens
{ {
CProfiles.SetDifficulty(SelectSlides[SelectSlideProfiles].Selection, CProfiles.SetDifficulty(SelectSlides[SelectSlideProfiles].Selection,
(EGameDifficulty)SelectSlides[SelectSlideDifficulty].Selection); (EGameDifficulty)SelectSlides[SelectSlideDifficulty].Selection);
} else if (SelectSlides[SelectSlideAvatars].Selected) }
else if (SelectSlides[SelectSlideAvatars].Selected)
{ {
CProfiles.SetAvatar(SelectSlides[SelectSlideProfiles].Selection, CProfiles.SetAvatar(SelectSlides[SelectSlideProfiles].Selection,
SelectSlides[SelectSlideAvatars].Selection); SelectSlides[SelectSlideAvatars].Selection);
} else if (SelectSlides[SelectSlideGuestProfile].Selected) }
else if (SelectSlides[SelectSlideGuestProfile].Selected)
{ {
CProfiles.SetGuestProfile(SelectSlides[SelectSlideProfiles].Selection, CProfiles.SetGuestProfile(SelectSlides[SelectSlideProfiles].Selection,
(EOffOn)SelectSlides[SelectSlideGuestProfile].Selection); (EOffOn)SelectSlides[SelectSlideGuestProfile].Selection);
} else if (SelectSlides[SelectSlideActive].Selected) }
else if (SelectSlides[SelectSlideActive].Selected)
{ {
CProfiles.SetActive(SelectSlides[SelectSlideProfiles].Selection, CProfiles.SetActive(SelectSlides[SelectSlideProfiles].Selection,
(EOffOn)SelectSlides[SelectSlideActive].Selection); (EOffOn)SelectSlides[SelectSlideActive].Selection);
@@ -175,59 +169,54 @@ namespace Vocaluxe.Screens
if (MouseEvent.LB && IsMouseOver(MouseEvent)) if (MouseEvent.LB && IsMouseOver(MouseEvent))
{ {
if (Buttons[ButtonExit].Selected) if (Buttons[ButtonExit].Selected)
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
} else if (Buttons[ButtonSave].Selected) else if (Buttons[ButtonSave].Selected)
{
SaveProfiles(); SaveProfiles();
} else if (Buttons[ButtonNew].Selected) else if (Buttons[ButtonNew].Selected)
{
NewProfile(); NewProfile();
} else if (Buttons[ButtonDelete].Selected) { else if (Buttons[ButtonDelete].Selected)
DeleteProfile(); DeleteProfile();
} else if (Buttons[ButtonPlayerName].Selected) else if (Buttons[ButtonPlayerName].Selected)
{ {
if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName) if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName)
_EditMode = EEditMode.PlayerName; _EditMode = EEditMode.PlayerName;
else else
_EditMode = EEditMode.None; _EditMode = EEditMode.None;
} else if (SelectSlides[SelectSlideDifficulty].Selected) }
else if (SelectSlides[SelectSlideDifficulty].Selected)
{ {
CProfiles.SetDifficulty(SelectSlides[SelectSlideProfiles].Selection, CProfiles.SetDifficulty(SelectSlides[SelectSlideProfiles].Selection,
(EGameDifficulty)SelectSlides[SelectSlideDifficulty].Selection); (EGameDifficulty)SelectSlides[SelectSlideDifficulty].Selection);
} else if (SelectSlides[SelectSlideAvatars].Selected) }
else if (SelectSlides[SelectSlideAvatars].Selected)
{ {
CProfiles.SetAvatar(SelectSlides[SelectSlideProfiles].Selection, CProfiles.SetAvatar(SelectSlides[SelectSlideProfiles].Selection,
SelectSlides[SelectSlideAvatars].Selection); SelectSlides[SelectSlideAvatars].Selection);
if (CWebcam.GetDevices().Length > 0 && _WebcamTexture.index > 0) if (CWebcam.GetDevices().Length > 0 && _WebcamTexture.index > 0)
OnDiscardSnapshot(); OnDiscardSnapshot();
} else if (SelectSlides[SelectSlideGuestProfile].Selected) }
else if (SelectSlides[SelectSlideGuestProfile].Selected)
{ {
CProfiles.SetGuestProfile(SelectSlides[SelectSlideProfiles].Selection, CProfiles.SetGuestProfile(SelectSlides[SelectSlideProfiles].Selection,
(EOffOn)SelectSlides[SelectSlideGuestProfile].Selection); (EOffOn)SelectSlides[SelectSlideGuestProfile].Selection);
} else if (SelectSlides[SelectSlideActive].Selected) }
else if (SelectSlides[SelectSlideActive].Selected)
{ {
CProfiles.SetActive(SelectSlides[SelectSlideProfiles].Selection, CProfiles.SetActive(SelectSlides[SelectSlideProfiles].Selection,
(EOffOn)SelectSlides[SelectSlideActive].Selection); (EOffOn)SelectSlides[SelectSlideActive].Selection);
} else if (Buttons[ButtonWebcam].Selected && CWebcam.GetDevices().Length > 0)
{
OnWebcam();
} else if (Buttons[ButtonSaveSnapshot].Selected && CWebcam.GetDevices().Length > 0)
{
OnSaveSnapshot();
} else if (Buttons[ButtonDiscardSnapshot].Selected && CWebcam.GetDevices().Length > 0)
{
OnDiscardSnapshot();
} else if (Buttons[ButtonTakeSnapshot].Selected && CWebcam.GetDevices().Length > 0)
{
OnTakeSnapshot();
} }
else if (Buttons[ButtonWebcam].Selected && CWebcam.GetDevices().Length > 0)
OnWebcam();
else if (Buttons[ButtonSaveSnapshot].Selected && CWebcam.GetDevices().Length > 0)
OnSaveSnapshot();
else if (Buttons[ButtonDiscardSnapshot].Selected && CWebcam.GetDevices().Length > 0)
OnDiscardSnapshot();
else if (Buttons[ButtonTakeSnapshot].Selected && CWebcam.GetDevices().Length > 0)
OnTakeSnapshot();
} }
if (MouseEvent.RB) if (MouseEvent.RB)
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
}
return true; return true;
} }
@@ -256,10 +245,8 @@ namespace Vocaluxe.Screens
string filename = "snapshot"; string filename = "snapshot";
int i = 0; int i = 0;
while (File.Exists(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png"))) while (File.Exists(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png")))
{
i++; i++;
} _Snapshot.Save(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png"), ImageFormat.Png);
_Snapshot.Save(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png"), System.Drawing.Imaging.ImageFormat.Png);
CProfiles.LoadAvatars(); CProfiles.LoadAvatars();
LoadAvatars(); LoadAvatars();
_Snapshot = null; _Snapshot = null;
@@ -273,7 +260,6 @@ namespace Vocaluxe.Screens
CProfiles.SetAvatar(SelectSlides[SelectSlideProfiles].Selection, j); CProfiles.SetAvatar(SelectSlides[SelectSlideProfiles].Selection, j);
break; break;
} }
} }
Buttons[ButtonSaveSnapshot].Visible = false; Buttons[ButtonSaveSnapshot].Visible = false;
@@ -367,9 +353,7 @@ namespace Vocaluxe.Screens
SelectSlides[SelectSlideProfiles].Clear(); SelectSlides[SelectSlideProfiles].Clear();
for (int i = 0; i < CProfiles.NumProfiles; i++) for (int i = 0; i < CProfiles.NumProfiles; i++)
{
SelectSlides[SelectSlideProfiles].AddValue(CProfiles.GetPlayerName(i)); SelectSlides[SelectSlideProfiles].AddValue(CProfiles.GetPlayerName(i));
}
if (CProfiles.NumProfiles > 0 && CProfiles.NumAvatars > 0) if (CProfiles.NumProfiles > 0 && CProfiles.NumAvatars > 0)
{ {
@@ -384,10 +368,8 @@ namespace Vocaluxe.Screens
{ {
SelectSlides[SelectSlideAvatars].Clear(); SelectSlides[SelectSlideAvatars].Clear();
for (int i = 0; i < CProfiles.NumAvatars; i++) for (int i = 0; i < CProfiles.NumAvatars; i++)
{
SelectSlides[SelectSlideAvatars].AddValue(CProfiles.Avatars[i].FileName); SelectSlides[SelectSlideAvatars].AddValue(CProfiles.Avatars[i].FileName);
} }
}
private void NewProfile() private void NewProfile()
{ {
+30 -53
View File
@@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -12,7 +11,10 @@ namespace Vocaluxe.Screens
class CScreenScore : CMenu class CScreenScore : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 3; } } protected override int _ScreenVersion
{
get { return 3; }
}
private const string TextSong = "TextSong"; private const string TextSong = "TextSong";
@@ -33,10 +35,6 @@ namespace Vocaluxe.Screens
private CPoints _Points; private CPoints _Points;
private Stopwatch timer; private Stopwatch timer;
public CScreenScore()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
@@ -53,16 +51,14 @@ namespace Vocaluxe.Screens
_ThemeStatics = statics.ToArray(); _ThemeStatics = statics.ToArray();
_ThemeScreenSettings = new string[] { ScreenSettingShortScore, ScreenSettingShortRating, ScreenSettingShortDifficulty, ScreenSettingAnimationDirection }; _ThemeScreenSettings = new[] {ScreenSettingShortScore, ScreenSettingShortRating, ScreenSettingShortDifficulty, ScreenSettingAnimationDirection};
StaticPointsBarDrawnPoints = new double[CSettings.MaxNumPlayer]; StaticPointsBarDrawnPoints = new double[CSettings.MaxNumPlayer];
} }
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
{ {
if (KeyEvent.KeyPressed) if (KeyEvent.KeyPressed) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -90,19 +86,13 @@ namespace Vocaluxe.Screens
base.HandleMouse(MouseEvent); base.HandleMouse(MouseEvent);
if (MouseEvent.Wheel != 0) if (MouseEvent.Wheel != 0)
{
ChangeRound(MouseEvent.Wheel); ChangeRound(MouseEvent.Wheel);
}
if (MouseEvent.LB) if (MouseEvent.LB)
{
LeaveScreen(); LeaveScreen();
}
if (MouseEvent.RB) if (MouseEvent.RB)
{
LeaveScreen(); LeaveScreen();
}
return true; return true;
} }
@@ -125,20 +115,17 @@ namespace Vocaluxe.Screens
SPlayer[] player = new SPlayer[CGame.NumPlayer]; SPlayer[] player = new SPlayer[CGame.NumPlayer];
if (_Round != 0) if (_Round != 0)
player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
else { else
{
for (int i = 0; i < CGame.NumRounds; i++) for (int i = 0; i < CGame.NumRounds; i++)
{ {
SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer); SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer);
for (int p = 0; p < player.Length; p++) for (int p = 0; p < player.Length; p++)
{
player[p].Points += points[p].Points; player[p].Points += points[p].Points;
} }
}
for (int p = 0; p < player.Length; p++) for (int p = 0; p < player.Length; p++)
{
player[p].Points = (int)(player[p].Points / CGame.NumRounds); player[p].Points = (int)(player[p].Points / CGame.NumRounds);
} }
}
for (int p = 0; p < player.Length; p++) for (int p = 0; p < player.Length; p++)
{ {
if (StaticPointsBarDrawnPoints[p] < player[p].Points) if (StaticPointsBarDrawnPoints[p] < player[p].Points)
@@ -149,18 +136,20 @@ namespace Vocaluxe.Screens
if (StaticPointsBarDrawnPoints[p] > player[p].Points) if (StaticPointsBarDrawnPoints[p] > player[p].Points)
{
StaticPointsBarDrawnPoints[p] = player[p].Points; StaticPointsBarDrawnPoints[p] = player[p].Points;
}
string direction = (string)ScreenSettings[ScreenSettingAnimationDirection].GetValue(); string direction = (string)ScreenSettings[ScreenSettingAnimationDirection].GetValue();
if (direction.ToLower() == "vertical") if (direction.ToLower() == "vertical")
{ {
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = ((float)StaticPointsBarDrawnPoints[p]) * (Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.W / 10000); Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = ((float)StaticPointsBarDrawnPoints[p]) *
(Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.W / 10000);
} }
else else
{ {
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = ((float)StaticPointsBarDrawnPoints[p]) * (Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H / 10000); Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = ((float)StaticPointsBarDrawnPoints[p]) *
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.Y = Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H + Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y - Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H; (Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H / 10000);
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.Y = Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H +
Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y -
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H;
} }
} }
} }
@@ -184,33 +173,19 @@ namespace Vocaluxe.Screens
rating = "TR_RATING_VOCAL_HERO"; rating = "TR_RATING_VOCAL_HERO";
} }
else if (points < 9800 && points >= 8400) else if (points < 9800 && points >= 8400)
{
rating = "TR_RATING_SUPERSTAR"; rating = "TR_RATING_SUPERSTAR";
}
else if (points < 8400 && points >= 7000) else if (points < 8400 && points >= 7000)
{
rating = "TR_RATING_LEAD_SINGER"; rating = "TR_RATING_LEAD_SINGER";
}
else if (points < 7000 && points >= 5600) else if (points < 7000 && points >= 5600)
{
rating = "TR_RATING_RISING_STAR"; rating = "TR_RATING_RISING_STAR";
}
else if (points < 5600 && points >= 4200) else if (points < 5600 && points >= 4200)
{
rating = "TR_RATING_HOPEFUL"; rating = "TR_RATING_HOPEFUL";
}
else if (points < 4200 && points >= 2800) else if (points < 4200 && points >= 2800)
{
rating = "TR_RATING_WANNABE"; rating = "TR_RATING_WANNABE";
}
else if (points < 2800 && points >= 1400) else if (points < 2800 && points >= 1400)
{
rating = "TR_RATING_AMATEUR"; rating = "TR_RATING_AMATEUR";
}
else if (points < 1400) else if (points < 1400)
{
rating = "TR_RATING_TONE_DEAF"; rating = "TR_RATING_TONE_DEAF";
}
return rating; return rating;
} }
@@ -263,7 +238,6 @@ namespace Vocaluxe.Screens
statics.Add(StaticPointsBarBG[player, numplayer]); statics.Add(StaticPointsBarBG[player, numplayer]);
statics.Add(StaticPointsBar[player, numplayer]); statics.Add(StaticPointsBar[player, numplayer]);
statics.Add(StaticAvatar[player, numplayer]); statics.Add(StaticAvatar[player, numplayer]);
} }
} }
} }
@@ -281,9 +255,7 @@ namespace Vocaluxe.Screens
Texts[TextSong].Text = song.Artist + " - " + song.Title; Texts[TextSong].Text = song.Artist + " - " + song.Title;
if (_Points.NumRounds > 1) if (_Points.NumRounds > 1)
{
Texts[TextSong].Text += " (" + _Round + "/" + _Points.NumRounds + ")"; Texts[TextSong].Text += " (" + _Round + "/" + _Points.NumRounds + ")";
}
player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
} }
else else
@@ -304,10 +276,8 @@ namespace Vocaluxe.Screens
} }
} }
for (int p = 0; p < player.Length; p++) for (int p = 0; p < player.Length; p++)
{
player[p].Points = (int)Math.Round((player[p].Points / CGame.NumRounds)); player[p].Points = (int)Math.Round((player[p].Points / CGame.NumRounds));
} }
}
for (int p = 0; p < player.Length; p++) for (int p = 0; p < player.Length; p++)
{ {
@@ -315,8 +285,7 @@ namespace Vocaluxe.Screens
{ {
if (!song.IsDuet) if (!song.IsDuet)
Texts[TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name; Texts[TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name;
else else if (player[p].LineNr == 0 && song.DuetPart1 != "Part 1")
if (player[p].LineNr == 0 && song.DuetPart1 != "Part 1")
Texts[TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name + " (" + song.DuetPart1 + ")"; Texts[TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name + " (" + song.DuetPart1 + ")";
else if (player[p].LineNr == 1 && song.DuetPart2 != "Part 2") else if (player[p].LineNr == 1 && song.DuetPart2 != "Part 2")
Texts[TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name + " (" + song.DuetPart2 + ")"; Texts[TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name + " (" + song.DuetPart2 + ")";
@@ -331,24 +300,30 @@ namespace Vocaluxe.Screens
else else
Texts[TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(player[p].Points)).ToString("0000"); Texts[TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(player[p].Points)).ToString("0000");
if (CGame.NumPlayer < (int)ScreenSettings[ScreenSettingShortDifficulty].GetValue()) if (CGame.NumPlayer < (int)ScreenSettings[ScreenSettingShortDifficulty].GetValue())
Texts[TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " + CLanguage.Translate(player[p].Difficulty.ToString()); {
Texts[TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " +
CLanguage.Translate(player[p].Difficulty.ToString());
}
else else
Texts[TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(player[p].Difficulty.ToString()); Texts[TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(player[p].Difficulty.ToString());
if (CGame.NumPlayer < (int)ScreenSettings[ScreenSettingShortRating].GetValue()) if (CGame.NumPlayer < (int)ScreenSettings[ScreenSettingShortRating].GetValue())
Texts[TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " + CLanguage.Translate(GetRating((int)Math.Round(player[p].Points))); {
Texts[TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " +
CLanguage.Translate(GetRating((int)Math.Round(player[p].Points)));
}
else else
Texts[TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(GetRating((int)Math.Round(player[p].Points))); Texts[TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(GetRating((int)Math.Round(player[p].Points)));
StaticPointsBarDrawnPoints[p] = 0.0; StaticPointsBarDrawnPoints[p] = 0.0;
string direction = (string)ScreenSettings[ScreenSettingAnimationDirection].GetValue(); string direction = (string)ScreenSettings[ScreenSettingAnimationDirection].GetValue();
if (direction.ToLower() == "vertical") if (direction.ToLower() == "vertical")
{
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = 0; Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.W = 0;
}
else else
{ {
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = 0; Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = 0;
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.Y = Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H + Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y - Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H; Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.Y = Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H +
Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y -
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H;
} }
if (player[p].ProfileID >= 0 && player[p].ProfileID < CProfiles.NumProfiles) if (player[p].ProfileID >= 0 && player[p].ProfileID < CProfiles.NumProfiles)
Statics[StaticAvatar[p, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[player[p].ProfileID].Avatar.Texture; Statics[StaticAvatar[p, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[player[p].ProfileID].Avatar.Texture;
@@ -359,7 +334,9 @@ namespace Vocaluxe.Screens
for (int p = 0; p < CGame.NumPlayer; p++) for (int p = 0; p < CGame.NumPlayer; p++)
{ {
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = ((float)player[p].Points) * (Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H / 10000); Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = ((float)player[p].Points) * (Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H / 10000);
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.Y = Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H + Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y - Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H; Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.Y = Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H +
Statics[StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y -
Statics[StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H;
StaticPointsBarDrawnPoints[p] = player[p].Points; StaticPointsBarDrawnPoints[p] = player[p].Points;
} }
} }
+33 -84
View File
@@ -4,7 +4,6 @@ using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SingNotes; using VocaluxeLib.Menu.SingNotes;
@@ -15,9 +14,12 @@ namespace Vocaluxe.Screens
class CScreenSing : CMenu class CScreenSing : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 6; } } protected override int _ScreenVersion
{
get { return 6; }
}
struct TimeRect private struct TimeRect
{ {
public CStatic rect; public CStatic rect;
public float startBeat; public float startBeat;
@@ -64,7 +66,7 @@ namespace Vocaluxe.Screens
private SRectF _TimeLineRect; private SRectF _TimeLineRect;
private List<TimeRect> _TimeRects; private List<TimeRect> _TimeRects;
private bool _FadeOut = false; private bool _FadeOut;
private int _CurrentBeat; private int _CurrentBeat;
private int _CurrentStream = -1; private int _CurrentStream = -1;
@@ -76,15 +78,15 @@ namespace Vocaluxe.Screens
private STexture _CurrentWebcamFrameTexture = new STexture(-1); private STexture _CurrentWebcamFrameTexture = new STexture(-1);
private STexture _Background = new STexture(-1); private STexture _Background = new STexture(-1);
private float _CurrentTime = 0f; private float _CurrentTime;
private float _FinishTime = 0f; private float _FinishTime;
private float _TimeToFirstNote = 0f; private float _TimeToFirstNote;
private float _RemainingTimeToFirstNote = 0f; private float _RemainingTimeToFirstNote;
private float _TimeToFirstNoteDuet = 0f; private float _TimeToFirstNoteDuet;
private float _RemainingTimeToFirstNoteDuet = 0f; private float _RemainingTimeToFirstNoteDuet;
private int[] NoteLines = new int[CSettings.MaxNumPlayer]; private readonly int[] NoteLines = new int[CSettings.MaxNumPlayer];
private Stopwatch _TimerSongText; private Stopwatch _TimerSongText;
private Stopwatch _TimerDuetText1; private Stopwatch _TimerDuetText1;
@@ -93,10 +95,6 @@ namespace Vocaluxe.Screens
private bool _Pause; private bool _Pause;
private bool _Webcam; private bool _Webcam;
public CScreenSing()
{
}
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
@@ -133,8 +131,8 @@ namespace Vocaluxe.Screens
buttons.Add(ButtonSkip); buttons.Add(ButtonSkip);
_ThemeButtons = buttons.ToArray(); _ThemeButtons = buttons.ToArray();
_ThemeLyrics = new string[] { LyricMain, LyricSub, LyricMainDuet, LyricSubDuet, LyricMainTop, LyricSubTop }; _ThemeLyrics = new[] {LyricMain, LyricSub, LyricMainDuet, LyricSubDuet, LyricMainTop, LyricSubTop};
_ThemeSingNotes = new string[] { SingBars }; _ThemeSingNotes = new[] {SingBars};
_TimeRects = new List<TimeRect>(); _TimeRects = new List<TimeRect>();
_TimerSongText = new Stopwatch(); _TimerSongText = new Stopwatch();
@@ -188,9 +186,7 @@ namespace Vocaluxe.Screens
mode++; mode++;
if (mode > Enum.GetNames(typeof(ETimerMode)).Length - 1) if (mode > Enum.GetNames(typeof(ETimerMode)).Length - 1)
{
mode = 0; mode = 0;
}
CConfig.TimerMode = (ETimerMode)mode; CConfig.TimerMode = (ETimerMode)mode;
break; break;
@@ -199,9 +195,7 @@ namespace Vocaluxe.Screens
mode++; mode++;
if (mode > Enum.GetNames(typeof(EPlayerInfo)).Length - 1) if (mode > Enum.GetNames(typeof(EPlayerInfo)).Length - 1)
{
mode = 0; mode = 0;
}
CConfig.PlayerInfo = (EPlayerInfo)mode; CConfig.PlayerInfo = (EPlayerInfo)mode;
CConfig.SaveConfig(); CConfig.SaveConfig();
SetVisibility(); SetVisibility();
@@ -211,8 +205,10 @@ namespace Vocaluxe.Screens
case Keys.S: case Keys.S:
if (CGame.NumRounds > CGame.RoundNr) if (CGame.NumRounds > CGame.RoundNr)
{
if (KeyEvent.ModCTRL) if (KeyEvent.ModCTRL)
LoadNextSong(); LoadNextSong();
}
break; break;
case Keys.W: case Keys.W:
if (CWebcam.GetDevices().Length > 0) if (CWebcam.GetDevices().Length > 0)
@@ -309,9 +305,7 @@ namespace Vocaluxe.Screens
Finish = true; Finish = true;
if (Finish) if (Finish)
{
LoadNextSong(); LoadNextSong();
}
UpdateSongText(); UpdateSongText();
UpdateDuetText(); UpdateDuetText();
@@ -375,14 +369,10 @@ namespace Vocaluxe.Screens
for (int p = 0; p < CGame.NumPlayer; p++) for (int p = 0; p < CGame.NumPlayer; p++)
{ {
if (CGame.Player[p].Points < 10000) if (CGame.Player[p].Points < 10000)
{
Texts[TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Player[p].Points.ToString("0000"); Texts[TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Player[p].Points.ToString("0000");
}
else else
{
Texts[TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Player[p].Points.ToString("00000"); Texts[TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Player[p].Points.ToString("00000");
} }
}
if (_CurrentVideo != -1 && !_FadeOut && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON) if (_CurrentVideo != -1 && !_FadeOut && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON)
{ {
@@ -416,19 +406,13 @@ namespace Vocaluxe.Screens
SingNotes[SingBars].Reset(); SingNotes[SingBars].Reset();
for (int i = 0; i < CSettings.MaxNumPlayer; i++) for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
NoteLines[i] = -1; NoteLines[i] = -1;
}
foreach (CLyric lyric in Lyrics) foreach (CLyric lyric in Lyrics)
{
lyric.LyricStyle = CConfig.LyricStyle; lyric.LyricStyle = CConfig.LyricStyle;
}
for (int p = 0; p < CGame.NumPlayer; p++) for (int p = 0; p < CGame.NumPlayer; p++)
{
Statics[StaticAvatars[p, CGame.NumPlayer - 1]].Aspect = EAspect.Crop; Statics[StaticAvatars[p, CGame.NumPlayer - 1]].Aspect = EAspect.Crop;
}
SetVisibility(); SetVisibility();
UpdateAvatars(); UpdateAvatars();
@@ -470,7 +454,8 @@ namespace Vocaluxe.Screens
_CurrentVideoTexture.color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); _CurrentVideoTexture.color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false);
} }
else else
{ // Draw Background {
// Draw Background
RectangleF bounds = new RectangleF(0, 0, CSettings.iRenderW, CSettings.iRenderH); RectangleF bounds = new RectangleF(0, 0, CSettings.iRenderW, CSettings.iRenderH);
RectangleF rect = new RectangleF(0f, 0f, _Background.width, _Background.height); RectangleF rect = new RectangleF(0f, 0f, _Background.width, _Background.height);
CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop); CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop);
@@ -495,9 +480,7 @@ namespace Vocaluxe.Screens
break; break;
case ETimerLook.TR_CONFIG_TIMERLOOK_EXPANDED: case ETimerLook.TR_CONFIG_TIMERLOOK_EXPANDED:
for (int i = 0; i < _TimeRects.Count; i++) for (int i = 0; i < _TimeRects.Count; i++)
{
CDraw.DrawTexture(_TimeRects[i].rect.Texture, Statics[StaticTimeLine].Rect, _TimeRects[i].rect.Color, _TimeRects[i].rect.Rect); CDraw.DrawTexture(_TimeRects[i].rect.Texture, Statics[StaticTimeLine].Rect, _TimeRects[i].rect.Color, _TimeRects[i].rect.Rect);
}
break; break;
} }
@@ -512,9 +495,7 @@ namespace Vocaluxe.Screens
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
{
SingNotes[SingBars].Draw(NoteLines[i], CGame.Player[i].SingLine, i); SingNotes[SingBars].Draw(NoteLines[i], CGame.Player[i].SingLine, i);
}
DrawLyricHelper(); DrawLyricHelper();
@@ -611,10 +592,8 @@ namespace Vocaluxe.Screens
{ {
//Save duet-assignment before resetting //Save duet-assignment before resetting
for (int i = 0; i < duet_player.Length; i++) for (int i = 0; i < duet_player.Length; i++)
{
duet_player[i] = CGame.Player[i].LineNr; duet_player[i] = CGame.Player[i].LineNr;
} }
}
CGame.ResetPlayer(); CGame.ResetPlayer();
CDraw.RemoveTexture(ref _CurrentVideoTexture); CDraw.RemoveTexture(ref _CurrentVideoTexture);
@@ -652,12 +631,9 @@ namespace Vocaluxe.Screens
else else
{ {
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
{
CGame.Player[i].LineNr = duet_player[i]; CGame.Player[i].LineNr = duet_player[i];
} }
} }
}
SetDuetLyricsVisibility(song.IsDuet); SetDuetLyricsVisibility(song.IsDuet);
for (int p = 0; p < CGame.NumPlayer; p++) for (int p = 0; p < CGame.NumPlayer; p++)
@@ -686,9 +662,7 @@ namespace Vocaluxe.Screens
_TimerDuetText2.Reset(); _TimerDuetText2.Reset();
if (song.Notes.Lines.Length != 2) if (song.Notes.Lines.Length != 2)
{
_TimerSongText.Start(); _TimerSongText.Start();
}
StartSong(); StartSong();
} }
@@ -753,10 +727,12 @@ namespace Vocaluxe.Screens
if (FirstNoteTime <= CurrentTime + 10f) if (FirstNoteTime <= CurrentTime + 10f)
{ {
//First line has no predecessor or line has to be shown //First line has no predecessor or line has to be shown
if(j == 0 || FirstNoteTime - CConfig.MinLineBreakTime <= CurrentTime) return j; if (j == 0 || FirstNoteTime - CConfig.MinLineBreakTime <= CurrentTime)
return j;
float LastNoteTime = CGame.GetTimeFromBeats(line[j - 1].LastNoteBeat, song.BPM); float LastNoteTime = CGame.GetTimeFromBeats(line[j - 1].LastNoteBeat, song.BPM);
//No line break if last line is not fully evaluated (with 50% tolerance -> tested so notes are drawn) //No line break if last line is not fully evaluated (with 50% tolerance -> tested so notes are drawn)
if(LastNoteTime + CConfig.MicDelay/1000f * 1.5f >= CurrentTime) return j-1; if (LastNoteTime + CConfig.MicDelay / 1000f * 1.5f >= CurrentTime)
return j - 1;
return j; return j;
} }
} }
@@ -857,7 +833,8 @@ namespace Vocaluxe.Screens
else else
Buttons[ButtonSkip].Visible = false; Buttons[ButtonSkip].Visible = false;
CSound.Pause(_CurrentStream); CSound.Pause(_CurrentStream);
}else }
else
{ {
Buttons[ButtonCancel].Visible = false; Buttons[ButtonCancel].Visible = false;
Buttons[ButtonContinue].Visible = false; Buttons[ButtonContinue].Visible = false;
@@ -933,10 +910,14 @@ namespace Vocaluxe.Screens
{ {
Texts[TextScores[player, numplayer]].Visible = (numplayer + 1 == CGame.NumPlayer); Texts[TextScores[player, numplayer]].Visible = (numplayer + 1 == CGame.NumPlayer);
Texts[TextNames[player, numplayer]].Visible = ((numplayer + 1 == CGame.NumPlayer) Texts[TextNames[player, numplayer]].Visible = ((numplayer + 1 == CGame.NumPlayer)
&& (CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH || CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_NAME)); &&
(CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH ||
CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_NAME));
Statics[StaticScores[player, numplayer]].Visible = (numplayer + 1 == CGame.NumPlayer); Statics[StaticScores[player, numplayer]].Visible = (numplayer + 1 == CGame.NumPlayer);
Statics[StaticAvatars[player, numplayer]].Visible = ((numplayer + 1 == CGame.NumPlayer) Statics[StaticAvatars[player, numplayer]].Visible = ((numplayer + 1 == CGame.NumPlayer)
&& (CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH || CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_AVATAR)); &&
(CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH ||
CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_AVATAR));
} }
} }
} }
@@ -958,7 +939,6 @@ namespace Vocaluxe.Screens
Statics[StaticLyricsDuet].Alpha = 0f; Statics[StaticLyricsDuet].Alpha = 0f;
Statics[StaticLyricHelperDuet].Alpha = 0f; Statics[StaticLyricHelperDuet].Alpha = 0f;
} }
private void DrawLyricHelper() private void DrawLyricHelper()
@@ -1069,10 +1049,8 @@ namespace Vocaluxe.Screens
for (int j = 0; j < line.Length; j++) for (int j = 0; j < line.Length; j++)
{ {
if (line[j].FirstNoteBeat <= _CurrentBeat) if (line[j].FirstNoteBeat <= _CurrentBeat)
{
CurrentLine = j; CurrentLine = j;
} }
}
// default values // default values
Alpha[i * 2] = 1f; Alpha[i * 2] = 1f;
@@ -1085,10 +1063,8 @@ namespace Vocaluxe.Screens
// => fade in // => fade in
float diff = CGame.GetTimeFromBeats(line[CurrentLine].FirstNoteBeat, Song.BPM) - CurrentTime; float diff = CGame.GetTimeFromBeats(line[CurrentLine].FirstNoteBeat, Song.BPM) - CurrentTime;
if (diff > dt) if (diff > dt)
{
Alpha[i * 2] = 1f - (diff - dt) / rt; Alpha[i * 2] = 1f - (diff - dt) / rt;
} }
}
else if (CurrentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastNoteBeat, Song.BPM) < CurrentTime && else if (CurrentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastNoteBeat, Song.BPM) < CurrentTime &&
CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstNoteBeat, Song.BPM) > CurrentTime) CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstNoteBeat, Song.BPM) > CurrentTime)
{ {
@@ -1135,10 +1111,8 @@ namespace Vocaluxe.Screens
diff = CGame.GetTimeFromBeats(line[CurrentLineSub + 1].FirstNoteBeat, Song.BPM) - CurrentTime; diff = CGame.GetTimeFromBeats(line[CurrentLineSub + 1].FirstNoteBeat, Song.BPM) - CurrentTime;
if (diff > dt) if (diff > dt)
{
Alpha[i * 2 + 1] = 1f - (diff - dt) / rt; Alpha[i * 2 + 1] = 1f - (diff - dt) / rt;
} }
}
if (Alpha[i * 2] < 0f) if (Alpha[i * 2] < 0f)
Alpha[i * 2] = 0f; Alpha[i * 2] = 0f;
@@ -1198,18 +1172,12 @@ namespace Vocaluxe.Screens
Texts[TextDuetName1].Visible = true; Texts[TextDuetName1].Visible = true;
if (t < 3f) if (t < 3f)
{
Texts[TextDuetName1].Color.A = (3f - (3f - t)) / 3f; Texts[TextDuetName1].Color.A = (3f - (3f - t)) / 3f;
}
else if (t < 7f) else if (t < 7f)
{
Texts[TextDuetName1].Color.A = 1f; Texts[TextDuetName1].Color.A = 1f;
}
else else
{
Texts[TextDuetName1].Color.A = (3f - (t - 7f)) / 3f; Texts[TextDuetName1].Color.A = (3f - (t - 7f)) / 3f;
} }
}
else else
{ {
Texts[TextDuetName1].Visible = false; Texts[TextDuetName1].Visible = false;
@@ -1219,9 +1187,7 @@ namespace Vocaluxe.Screens
else if (!_TimerDuetText1.IsRunning && _TimerDuetText1.ElapsedMilliseconds == 0 && Lyrics[LyricMainDuet].Alpha > 0 && CGame.GetSong().IsDuet) else if (!_TimerDuetText1.IsRunning && _TimerDuetText1.ElapsedMilliseconds == 0 && Lyrics[LyricMainDuet].Alpha > 0 && CGame.GetSong().IsDuet)
_TimerDuetText1.Start(); _TimerDuetText1.Start();
else else
{
Texts[TextDuetName1].Visible = false; Texts[TextDuetName1].Visible = false;
}
//Timer for second duet-part //Timer for second duet-part
if (_TimerDuetText2.IsRunning) if (_TimerDuetText2.IsRunning)
{ {
@@ -1231,18 +1197,12 @@ namespace Vocaluxe.Screens
Texts[TextDuetName2].Visible = true; Texts[TextDuetName2].Visible = true;
if (t < 3f) if (t < 3f)
{
Texts[TextDuetName2].Color.A = (3f - (3f - t)) / 3f; Texts[TextDuetName2].Color.A = (3f - (3f - t)) / 3f;
}
else if (t < 7f) else if (t < 7f)
{
Texts[TextDuetName2].Color.A = 1f; Texts[TextDuetName2].Color.A = 1f;
}
else else
{
Texts[TextDuetName2].Color.A = (3f - (t - 7f)) / 3f; Texts[TextDuetName2].Color.A = (3f - (t - 7f)) / 3f;
} }
}
else else
{ {
Texts[TextDuetName2].Visible = false; Texts[TextDuetName2].Visible = false;
@@ -1252,11 +1212,9 @@ namespace Vocaluxe.Screens
else if (!_TimerDuetText2.IsRunning && _TimerDuetText2.ElapsedMilliseconds == 0 && Lyrics[LyricMain].Alpha > 0 && CGame.GetSong().IsDuet) else if (!_TimerDuetText2.IsRunning && _TimerDuetText2.ElapsedMilliseconds == 0 && Lyrics[LyricMain].Alpha > 0 && CGame.GetSong().IsDuet)
_TimerDuetText2.Start(); _TimerDuetText2.Start();
else else
{
Texts[TextDuetName2].Visible = false; Texts[TextDuetName2].Visible = false;
} }
} }
}
private void UpdateTimeLine() private void UpdateTimeLine()
{ {
@@ -1319,7 +1277,6 @@ namespace Vocaluxe.Screens
_TimeRects[i].rect.Texture = Statics[StaticTimeLineExpandedNormal].Texture; _TimeRects[i].rect.Texture = Statics[StaticTimeLineExpandedNormal].Texture;
_TimeRects[i].rect.Color = Statics[StaticTimeLineExpandedNormal].Color; _TimeRects[i].rect.Color = Statics[StaticTimeLineExpandedNormal].Color;
} }
} }
Statics[StaticTimePointer].Rect.X = stat.Rect.X + stat.Rect.W * (CurrentTime / TotalTime); Statics[StaticTimePointer].Rect.X = stat.Rect.X + stat.Rect.W * (CurrentTime / TotalTime);
break; break;
@@ -1368,7 +1325,8 @@ namespace Vocaluxe.Screens
trect.endBeat = Line[j].EndBeat; trect.endBeat = Line[j].EndBeat;
trect.rect = GetNewStatic(new STexture(-1), trect.rect = GetNewStatic(new STexture(-1),
new SColorF(1f, 1f, 1f, 1f), new SColorF(1f, 1f, 1f, 1f),
new SRectF(stat.Rect.X + stat.Rect.W * ((CGame.GetTimeFromBeats(trect.startBeat, song.BPM) + song.Gap - song.Start) / TotalTime), new SRectF(
stat.Rect.X + stat.Rect.W * ((CGame.GetTimeFromBeats(trect.startBeat, song.BPM) + song.Gap - song.Start) / TotalTime),
stat.Rect.Y, stat.Rect.Y,
stat.Rect.W * (CGame.GetTimeFromBeats((trect.endBeat - trect.startBeat), song.BPM) / TotalTime), stat.Rect.W * (CGame.GetTimeFromBeats((trect.endBeat - trect.startBeat), song.BPM) / TotalTime),
stat.Rect.H, stat.Rect.H,
@@ -1377,7 +1335,6 @@ namespace Vocaluxe.Screens
_TimeRects.Add(trect); _TimeRects.Add(trect);
} }
} }
} }
break; break;
} }
@@ -1388,29 +1345,21 @@ namespace Vocaluxe.Screens
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
{ {
if (CGame.Player[i].ProfileID > -1) if (CGame.Player[i].ProfileID > -1)
{
Statics[StaticAvatars[i, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[CGame.Player[i].ProfileID].Avatar.Texture; Statics[StaticAvatars[i, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[CGame.Player[i].ProfileID].Avatar.Texture;
}
else else
{
Statics[StaticAvatars[i, CGame.NumPlayer - 1]].Visible = false; Statics[StaticAvatars[i, CGame.NumPlayer - 1]].Visible = false;
} }
} }
}
private void UpdateNames() private void UpdateNames()
{ {
for (int i = 0; i < CGame.NumPlayer; i++) for (int i = 0; i < CGame.NumPlayer; i++)
{ {
if (CGame.Player[i].ProfileID > -1) if (CGame.Player[i].ProfileID > -1)
{
Texts[TextNames[i, CGame.NumPlayer - 1]].Text = CProfiles.Profiles[CGame.Player[i].ProfileID].PlayerName; Texts[TextNames[i, CGame.NumPlayer - 1]].Text = CProfiles.Profiles[CGame.Player[i].ProfileID].PlayerName;
}
else else
{
Texts[TextNames[i, CGame.NumPlayer - 1]].Visible = false; Texts[TextNames[i, CGame.NumPlayer - 1]].Visible = false;
} }
} }
} }
} }
}
+31 -77
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -11,7 +10,7 @@ namespace Vocaluxe.Screens
{ {
class CScreenSong : CMenu class CScreenSong : CMenu
{ {
enum ESongOptionsView private enum ESongOptionsView
{ {
None, None,
Song, Song,
@@ -20,7 +19,10 @@ namespace Vocaluxe.Screens
} }
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 5; } } protected override int _ScreenVersion
{
get { return 5; }
}
private const string TextCategory = "TextCategory"; private const string TextCategory = "TextCategory";
private const string TextSelection = "TextSelection"; private const string TextSelection = "TextSelection";
@@ -52,13 +54,13 @@ namespace Vocaluxe.Screens
private const string Playlist = "Playlist"; private const string Playlist = "Playlist";
private string _SearchText = String.Empty; private string _SearchText = String.Empty;
private bool _SearchActive = false; private bool _SearchActive;
private readonly List<string> ButtonsJoker = new List<string>(); private readonly List<string> ButtonsJoker = new List<string>();
private List<string> TextsPlayer = new List<string>(); private readonly List<string> TextsPlayer = new List<string>();
private bool _SongOptionsActive = false; private bool _SongOptionsActive;
private bool _PlaylistActive = false; private bool _PlaylistActive;
private List<EGameMode> _AvailableGameModes; private readonly List<EGameMode> _AvailableGameModes;
private ScreenSongOptions _sso; private ScreenSongOptions _sso;
private CStatic DragAndDropCover; private CStatic DragAndDropCover;
@@ -80,9 +82,7 @@ namespace Vocaluxe.Screens
ButtonsJoker.Clear(); ButtonsJoker.Clear();
for (int i = 0; i < CMain.Settings.GetMaxNumPlayer(); i++) for (int i = 0; i < CMain.Settings.GetMaxNumPlayer(); i++)
{
ButtonsJoker.Add("ButtonJoker" + (i + 1)); ButtonsJoker.Add("ButtonJoker" + (i + 1));
}
List<string> blist = new List<string>(); List<string> blist = new List<string>();
blist.AddRange(ButtonsJoker); blist.AddRange(ButtonsJoker);
blist.Add(ButtonOptionsClose); blist.Add(ButtonOptionsClose);
@@ -100,9 +100,7 @@ namespace Vocaluxe.Screens
TextsPlayer.Clear(); TextsPlayer.Clear();
for (int i = 0; i < CMain.Settings.GetMaxNumPlayer(); i++) for (int i = 0; i < CMain.Settings.GetMaxNumPlayer(); i++)
{
TextsPlayer.Add("TextPlayer" + (i + 1)); TextsPlayer.Add("TextPlayer" + (i + 1));
}
List<string> tlist = new List<string>(); List<string> tlist = new List<string>();
tlist.AddRange(TextsPlayer); tlist.AddRange(TextsPlayer);
tlist.Add(TextCategory); tlist.Add(TextCategory);
@@ -111,12 +109,12 @@ namespace Vocaluxe.Screens
tlist.Add(TextSearchBar); tlist.Add(TextSearchBar);
tlist.Add(TextOptionsTitle); tlist.Add(TextOptionsTitle);
_ThemeStatics = new string[] { StaticSearchBar, StaticOptionsBG }; _ThemeStatics = new[] {StaticSearchBar, StaticOptionsBG};
_ThemeTexts = tlist.ToArray(); _ThemeTexts = tlist.ToArray();
_ThemeButtons = blist.ToArray(); _ThemeButtons = blist.ToArray();
_ThemeSelectSlides = new string[] { SelectSlideOptionsMode, SelectSlideOptionsPlaylistAdd, SelectSlideOptionsPlaylistOpen, SelectSlideOptionsNumMedleySongs }; _ThemeSelectSlides = new[] {SelectSlideOptionsMode, SelectSlideOptionsPlaylistAdd, SelectSlideOptionsPlaylistOpen, SelectSlideOptionsNumMedleySongs};
_ThemeSongMenus = new string[] { SongMenu }; _ThemeSongMenus = new[] {SongMenu};
_ThemePlaylists = new string[] { Playlist }; _ThemePlaylists = new[] {Playlist};
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
@@ -194,10 +192,8 @@ namespace Vocaluxe.Screens
} }
} }
if (Buttons[ButtonStart].Selected) if (Buttons[ButtonStart].Selected)
{
HandlePartySongSelection(SongMenus[SongMenu].GetSelectedSong()); HandlePartySongSelection(SongMenus[SongMenu].GetSelectedSong());
} }
}
if (CSongs.NumVisibleSongs > 0 && !_sso.Selection.PartyMode) if (CSongs.NumVisibleSongs > 0 && !_sso.Selection.PartyMode)
{ {
if (SongMenus[SongMenu].GetSelectedSong() != -1 && !_SongOptionsActive) if (SongMenus[SongMenu].GetSelectedSong() != -1 && !_SongOptionsActive)
@@ -219,14 +215,10 @@ namespace Vocaluxe.Screens
case Keys.Back: case Keys.Back:
if (_SearchActive && _SearchText.Length > 0) if (_SearchActive && _SearchText.Length > 0)
{
ApplyNewSearchFilter(_SearchText.Remove(_SearchText.Length - 1)); ApplyNewSearchFilter(_SearchText.Remove(_SearchText.Length - 1));
}
if ((CSongs.Category < 0 || _sso.Sorting.Tabs == EOffOn.TR_CONFIG_OFF) && !_sso.Selection.PartyMode && !_SearchActive) if ((CSongs.Category < 0 || _sso.Sorting.Tabs == EOffOn.TR_CONFIG_OFF) && !_sso.Selection.PartyMode && !_SearchActive)
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
}
break; break;
@@ -241,7 +233,8 @@ namespace Vocaluxe.Screens
_SearchActive = true; _SearchActive = true;
break; break;
} }
if(!_SearchActive){ if (!_SearchActive)
{
switch (KeyEvent.Key) switch (KeyEvent.Key)
{ {
case Keys.Space: case Keys.Space:
@@ -301,9 +294,7 @@ namespace Vocaluxe.Screens
{ {
case Keys.Enter: case Keys.Enter:
if (Buttons[ButtonOptionsClose].Selected) if (Buttons[ButtonOptionsClose].Selected)
{
ToggleSongOptions(ESongOptionsView.None); ToggleSongOptions(ESongOptionsView.None);
}
else if (Buttons[ButtonOptionsSing].Selected) else if (Buttons[ButtonOptionsSing].Selected)
{ {
ToggleSongOptions(ESongOptionsView.None); ToggleSongOptions(ESongOptionsView.None);
@@ -322,25 +313,15 @@ namespace Vocaluxe.Screens
SongMenus[SongMenu].SetSelectedCategory(CSongs.GetRandomCategory()); SongMenus[SongMenu].SetSelectedCategory(CSongs.GetRandomCategory());
} }
else if (Buttons[ButtonOptionsSingAll].Selected) else if (Buttons[ButtonOptionsSingAll].Selected)
{
StartRandomAllSongs(); StartRandomAllSongs();
}
else if (Buttons[ButtonOptionsSingAllVisible].Selected) else if (Buttons[ButtonOptionsSingAllVisible].Selected)
{
StartRandomVisibleSongs(); StartRandomVisibleSongs();
}
else if (Buttons[ButtonOptionsOpenSelectedItem].Selected) else if (Buttons[ButtonOptionsOpenSelectedItem].Selected)
{
_HandleSelectButton(); _HandleSelectButton();
}
else if (SelectSlides[SelectSlideOptionsPlaylistOpen].Selected) else if (SelectSlides[SelectSlideOptionsPlaylistOpen].Selected)
{
OpenPlaylistAction(); OpenPlaylistAction();
}
else if (Buttons[ButtonOptionsRandomMedley].Selected) else if (Buttons[ButtonOptionsRandomMedley].Selected)
{
ToggleSongOptions(ESongOptionsView.Medley); ToggleSongOptions(ESongOptionsView.Medley);
}
else if (Buttons[ButtonOptionsStartMedley].Selected) else if (Buttons[ButtonOptionsStartMedley].Selected)
{ {
ToggleSongOptions(ESongOptionsView.None); ToggleSongOptions(ESongOptionsView.None);
@@ -406,10 +387,8 @@ namespace Vocaluxe.Screens
if (Playlists[Playlist].Visible && _PlaylistActive) if (Playlists[Playlist].Visible && _PlaylistActive)
{ {
if (Playlists[Playlist].HandleMouse(MouseEvent)) if (Playlists[Playlist].HandleMouse(MouseEvent))
{
return true; return true;
} }
}
if (MouseEvent.RB) if (MouseEvent.RB)
@@ -436,9 +415,7 @@ namespace Vocaluxe.Screens
} }
if (MouseEvent.MB && !_sso.Selection.PartyMode) if (MouseEvent.MB && !_sso.Selection.PartyMode)
{
return SelectNextRandom(-1); return SelectNextRandom(-1);
}
if (MouseEvent.LD && !_sso.Selection.PartyMode) if (MouseEvent.LD && !_sso.Selection.PartyMode)
{ {
@@ -466,11 +443,13 @@ namespace Vocaluxe.Screens
{ {
ToggleSongOptions(ESongOptionsView.General); ToggleSongOptions(ESongOptionsView.General);
return true; return true;
} else if (Buttons[ButtonOptionsClose].Selected) }
else if (Buttons[ButtonOptionsClose].Selected)
{ {
ToggleSongOptions(ESongOptionsView.None); ToggleSongOptions(ESongOptionsView.None);
return true; return true;
} else if (Buttons[ButtonOptionsSing].Selected) }
else if (Buttons[ButtonOptionsSing].Selected)
{ {
ToggleSongOptions(ESongOptionsView.None); ToggleSongOptions(ESongOptionsView.None);
StartSong(SongMenus[SongMenu].GetSelectedSong()); StartSong(SongMenus[SongMenu].GetSelectedSong());
@@ -593,7 +572,8 @@ namespace Vocaluxe.Screens
private void _HandleSelectButton() private void _HandleSelectButton()
{ {
if (CSongs.IsInCategory) { if (CSongs.IsInCategory)
{
if (!_sso.Selection.PartyMode) if (!_sso.Selection.PartyMode)
ToggleSongOptions(ESongOptionsView.Song); ToggleSongOptions(ESongOptionsView.Song);
} }
@@ -651,13 +631,9 @@ namespace Vocaluxe.Screens
int song = SongMenus[SongMenu].GetActualSelection(); int song = SongMenus[SongMenu].GetActualSelection();
if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Length) if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Length)
{
Texts[TextSelection].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title; Texts[TextSelection].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title;
}
else if (!CSongs.IsInCategory && song >= 0 && song < CSongs.Categories.Length) else if (!CSongs.IsInCategory && song >= 0 && song < CSongs.Categories.Length)
{
Texts[TextSelection].Text = CSongs.Categories[song].Name; Texts[TextSelection].Text = CSongs.Categories[song].Name;
}
else else
Texts[TextSelection].Text = String.Empty; Texts[TextSelection].Text = String.Empty;
@@ -710,11 +686,9 @@ namespace Vocaluxe.Screens
{ {
CSong song = CSongs.VisibleSongs[SongNr]; CSong song = CSongs.VisibleSongs[SongNr];
if (song != null) if (song != null)
{
CParty.SongSelected(song.ID); CParty.SongSelected(song.ID);
} }
} }
}
private void UpdatePartyModeOptions() private void UpdatePartyModeOptions()
{ {
@@ -810,9 +784,7 @@ namespace Vocaluxe.Screens
{ {
EGameMode gm; EGameMode gm;
if (_AvailableGameModes.Count >= SelectSlides[SelectSlideOptionsMode].Selection) if (_AvailableGameModes.Count >= SelectSlides[SelectSlideOptionsMode].Selection)
{
gm = _AvailableGameModes[SelectSlides[SelectSlideOptionsMode].Selection]; gm = _AvailableGameModes[SelectSlides[SelectSlideOptionsMode].Selection];
}
else else
{ {
if (CSongs.VisibleSongs[SongNr].IsDuet) if (CSongs.VisibleSongs[SongNr].IsDuet)
@@ -874,9 +846,7 @@ namespace Vocaluxe.Screens
List<int> IDs = new List<int>(); List<int> IDs = new List<int>();
for (int i = 0; i < CSongs.AllSongs.Length; i++) for (int i = 0; i < CSongs.AllSongs.Length; i++)
{
IDs.Add(i); IDs.Add(i);
}
while (IDs.Count > 0) while (IDs.Count > 0)
{ {
@@ -902,9 +872,7 @@ namespace Vocaluxe.Screens
List<int> IDs = new List<int>(); List<int> IDs = new List<int>();
for (int i = 0; i < CSongs.VisibleSongs.Length; i++) for (int i = 0; i < CSongs.VisibleSongs.Length; i++)
{
IDs.Add(CSongs.VisibleSongs[i].ID); IDs.Add(CSongs.VisibleSongs[i].ID);
}
while (IDs.Count > 0) while (IDs.Count > 0)
{ {
@@ -932,17 +900,13 @@ namespace Vocaluxe.Screens
if (AllSongs) if (AllSongs)
{ {
for (int i = 0; i < CSongs.AllSongs.Length; i++) for (int i = 0; i < CSongs.AllSongs.Length; i++)
{
IDs.Add(i); IDs.Add(i);
} }
}
else else
{ {
for (int i = 0; i < CSongs.VisibleSongs.Length; i++) for (int i = 0; i < CSongs.VisibleSongs.Length; i++)
{
IDs.Add(CSongs.VisibleSongs[i].ID); IDs.Add(CSongs.VisibleSongs[i].ID);
} }
}
int s = 0; int s = 0;
while (s < NumSongs && IDs.Count > 0) while (s < NumSongs && IDs.Count > 0)
{ {
@@ -1025,9 +989,9 @@ namespace Vocaluxe.Screens
if (CurrentSong != null && CurrentSong.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)) if (CurrentSong != null && CurrentSong.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1; start = curSelected + 1;
} }
int visibleID = Array.FindIndex<CSong>(Songs, start, ct - start, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)); int visibleID = Array.FindIndex(Songs, start, ct - start, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
if (visibleID < 0 && start > 1) if (visibleID < 0 && start > 1)
visibleID = Array.FindIndex<CSong>(Songs, 0, start - 1, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)); visibleID = Array.FindIndex(Songs, 0, start - 1, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
if (visibleID > -1) if (visibleID > -1)
SongMenus[SongMenu].SetSelectedSong(visibleID); SongMenus[SongMenu].SetSelectedSong(visibleID);
} }
@@ -1037,12 +1001,11 @@ namespace Vocaluxe.Screens
int ct = Categories.Length; int ct = Categories.Length;
if (curSelected >= 0 && curSelected < ct - 1 && Categories[curSelected].Name.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)) if (curSelected >= 0 && curSelected < ct - 1 && Categories[curSelected].Name.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1; start = curSelected + 1;
int visibleID = Array.FindIndex<CCategory>(Categories, start, ct - start, element => element.Name.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)); int visibleID = Array.FindIndex(Categories, start, ct - start, element => element.Name.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
if (visibleID < 0 && start > 1) if (visibleID < 0 && start > 1)
visibleID = Array.FindIndex<CCategory>(Categories, 0, start - 1, element => element.Name.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)); visibleID = Array.FindIndex(Categories, 0, start - 1, element => element.Name.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
if (visibleID > -1) if (visibleID > -1)
SongMenus[SongMenu].SetSelectedCategory(visibleID); SongMenus[SongMenu].SetSelectedCategory(visibleID);
} }
} }
@@ -1057,9 +1020,7 @@ namespace Vocaluxe.Screens
int SongIndex = SongMenus[SongMenu].GetSelectedSong(); int SongIndex = SongMenus[SongMenu].GetSelectedSong();
int SongID = -1; int SongID = -1;
if (SongIndex != -1 && CSongs.NumVisibleSongs > 0 && CSongs.NumVisibleSongs > SongIndex) if (SongIndex != -1 && CSongs.NumVisibleSongs > 0 && CSongs.NumVisibleSongs > SongIndex)
{
SongID = CSongs.VisibleSongs[SongIndex].ID; SongID = CSongs.VisibleSongs[SongIndex].ID;
}
if (NewFilterString.Length == 0 && _sso.Sorting.Tabs == EOffOn.TR_CONFIG_ON) if (NewFilterString.Length == 0 && _sso.Sorting.Tabs == EOffOn.TR_CONFIG_ON)
{ {
@@ -1192,17 +1153,13 @@ namespace Vocaluxe.Screens
if (CSongs.IsInCategory) if (CSongs.IsInCategory)
{ {
for (int i = 1; i <= CSongs.VisibleSongs.Length; i++) for (int i = 1; i <= CSongs.VisibleSongs.Length; i++)
{
SelectSlides[SelectSlideOptionsNumMedleySongs].AddValue(i.ToString()); SelectSlides[SelectSlideOptionsNumMedleySongs].AddValue(i.ToString());
} }
}
else else
{ {
for (int i = 1; i <= CSongs.AllSongs.Length; i++) for (int i = 1; i <= CSongs.AllSongs.Length; i++)
{
SelectSlides[SelectSlideOptionsNumMedleySongs].AddValue(i.ToString()); SelectSlides[SelectSlideOptionsNumMedleySongs].AddValue(i.ToString());
} }
}
if (SelectSlides[SelectSlideOptionsNumMedleySongs].NumValues >= 5) if (SelectSlides[SelectSlideOptionsNumMedleySongs].NumValues >= 5)
SelectSlides[SelectSlideOptionsNumMedleySongs].SetSelectionByValueIndex(4); SelectSlides[SelectSlideOptionsNumMedleySongs].SetSelectionByValueIndex(4);
else else
@@ -1264,14 +1221,14 @@ namespace Vocaluxe.Screens
private void OpenAndAddPlaylistAction() private void OpenAndAddPlaylistAction()
{ {
//Open an existing playlist and add song //Open an existing playlist and add song
if (Playlists[Playlist].ActivePlaylistID != (SelectSlides[SelectSlideOptionsPlaylistAdd].Selection - 1) && (SelectSlides[SelectSlideOptionsPlaylistAdd].Selection - 1) != -1) if (Playlists[Playlist].ActivePlaylistID != (SelectSlides[SelectSlideOptionsPlaylistAdd].Selection - 1) &&
(SelectSlides[SelectSlideOptionsPlaylistAdd].Selection - 1) != -1)
{ {
//Check selected game-mode //Check selected game-mode
EGameMode gm; EGameMode gm;
if (_AvailableGameModes.Count >= SelectSlides[SelectSlideOptionsMode].Selection) if (_AvailableGameModes.Count >= SelectSlides[SelectSlideOptionsMode].Selection)
gm = _AvailableGameModes[SelectSlides[SelectSlideOptionsMode].Selection]; gm = _AvailableGameModes[SelectSlides[SelectSlideOptionsMode].Selection];
else else if (CSongs.VisibleSongs[SongMenus[SongMenu].GetSelectedSong()].IsDuet)
if (CSongs.VisibleSongs[SongMenus[SongMenu].GetSelectedSong()].IsDuet)
gm = EGameMode.TR_GAMEMODE_DUET; gm = EGameMode.TR_GAMEMODE_DUET;
else else
gm = EGameMode.TR_GAMEMODE_NORMAL; gm = EGameMode.TR_GAMEMODE_NORMAL;
@@ -1298,8 +1255,7 @@ namespace Vocaluxe.Screens
EGameMode gm; EGameMode gm;
if (_AvailableGameModes.Count >= SelectSlides[SelectSlideOptionsMode].Selection) if (_AvailableGameModes.Count >= SelectSlides[SelectSlideOptionsMode].Selection)
gm = _AvailableGameModes[SelectSlides[SelectSlideOptionsMode].Selection]; gm = _AvailableGameModes[SelectSlides[SelectSlideOptionsMode].Selection];
else else if (CSongs.VisibleSongs[SongMenus[SongMenu].GetSelectedSong()].IsDuet)
if (CSongs.VisibleSongs[SongMenus[SongMenu].GetSelectedSong()].IsDuet)
gm = EGameMode.TR_GAMEMODE_DUET; gm = EGameMode.TR_GAMEMODE_DUET;
else else
gm = EGameMode.TR_GAMEMODE_NORMAL; gm = EGameMode.TR_GAMEMODE_NORMAL;
@@ -1318,7 +1274,6 @@ namespace Vocaluxe.Screens
SelectSlides[SelectSlideOptionsPlaylistOpen].AddValue(CPlaylists.Playlists[Playlists[Playlist].ActivePlaylistID].PlaylistName); SelectSlides[SelectSlideOptionsPlaylistOpen].AddValue(CPlaylists.Playlists[Playlists[Playlist].ActivePlaylistID].PlaylistName);
SetSelectSlidePlaylistToCurrentPlaylist(); SetSelectSlidePlaylistToCurrentPlaylist();
} }
//Add song to loaded playlist //Add song to loaded playlist
else else
@@ -1327,8 +1282,7 @@ namespace Vocaluxe.Screens
EGameMode gm; EGameMode gm;
if (_AvailableGameModes.Count >= SelectSlides[SelectSlideOptionsMode].Selection) if (_AvailableGameModes.Count >= SelectSlides[SelectSlideOptionsMode].Selection)
gm = _AvailableGameModes[SelectSlides[SelectSlideOptionsMode].Selection]; gm = _AvailableGameModes[SelectSlides[SelectSlideOptionsMode].Selection];
else else if (CSongs.VisibleSongs[SongMenus[SongMenu].GetSelectedSong()].IsDuet)
if (CSongs.VisibleSongs[SongMenus[SongMenu].GetSelectedSong()].IsDuet)
gm = EGameMode.TR_GAMEMODE_DUET; gm = EGameMode.TR_GAMEMODE_DUET;
else else
gm = EGameMode.TR_GAMEMODE_NORMAL; gm = EGameMode.TR_GAMEMODE_NORMAL;
+6 -19
View File
@@ -1,7 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -10,20 +9,16 @@ namespace Vocaluxe.Screens
class CScreenTest : CMenu class CScreenTest : CMenu
{ {
// Version number for theme files. Increment it, if you've changed something on the theme files! // Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion { get { return 1; } } protected override int _ScreenVersion
{
get { return 1; }
}
private int _TestMusic = -1; private int _TestMusic = -1;
public CScreenTest()
{
}
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
{ {
if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) {}
{
}
else else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
@@ -56,26 +51,18 @@ namespace Vocaluxe.Screens
public override bool HandleMouse(MouseEvent MouseEvent) public override bool HandleMouse(MouseEvent MouseEvent)
{ {
if (MouseEvent.LB && IsMouseOver(MouseEvent)) if (MouseEvent.LB && IsMouseOver(MouseEvent)) {}
{
}
if (MouseEvent.LB) if (MouseEvent.LB)
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
}
if (MouseEvent.RB) if (MouseEvent.RB)
{
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
}
return true; return true;
} }
public override bool UpdateGame() public override bool UpdateGame()
{ {
return true; return true;
} }