Use ProgressBar on ScoreScreen, removed unused stuff

This commit is contained in:
Florian Küpper committed 2017-09-10 11:17:21 +02:00
1 parent 6ebbfb37bd
commit 5dfdad61c4
5 files changed
+614 -573

No files matched your search

@@ -1,5 +1,9 @@
ScreenScore
++++++++++
Version 4:
Removed <ScreenSettingAnimationDirection>, <StaticPointsBarBGP$N$>, <StaticPointsBarP$N$>
Added <ProgressBarPointsP$N$>
++++++++++++++++++++
Version 3:
Add <ScreenSettingShortScore>, <ScreenSettingShortRating>, <ScreenSettingShortDifficulty> to change text-string with player-num >= <Value>
Add <ScreenSettingAnimationDirection>, set <Value> to "vertical" to draw animation in vertical direction.
File diff suppressed because it is too large. Load diff
-5
View File
@@ -134,7 +134,6 @@ namespace Vocaluxe.Base
// ReSharper restore MemberHidesStaticFromOuterClass
[DefaultValue(ESongSorting.TR_CONFIG_ARTIST)] public ESongSorting SongSorting;
[DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn IgnoreArticles;
[DefaultValue(10)] public float ScoreAnimationTime;
[DefaultValue(ETimerMode.TR_CONFIG_TIMERMODE_REMAINING)] public ETimerMode TimerMode;
[XmlAltName("NumPlayer"), DefaultValue(2)] public int NumPlayers;
[DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn Tabs;
@@ -344,8 +343,6 @@ namespace Vocaluxe.Base
{
Config.Game.SongFolder = SongFolders.ToArray();
}
if ((Config.Game.ScoreAnimationTime > 0 && Config.Game.ScoreAnimationTime < 1) || Config.Game.ScoreAnimationTime < 0)
Config.Game.ScoreAnimationTime = 1;
if (Config.Game.MinLineBreakTime < 0)
Config.Game.MinLineBreakTime = 0.1f;
@@ -469,8 +466,6 @@ namespace Vocaluxe.Base
return "SongSorting: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongSorting)));
case "IgnoreArticles":
return "Ignore articles on song-sorting: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)));
case "ScoreAnimationTime":
return "ScoreAnimationTime: Values >= 1 or 0 for no animation. Time is in seconds.";
case "TimerMode":
return "TimerMode: " + CHelper.ListStrings(Enum.GetNames(typeof(ETimerMode)));
case "NumPlayers":
+29 -79
View File
@@ -33,7 +33,7 @@ namespace Vocaluxe.Screens
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
{
get { return 3; }
get { return 4; }
}
private const string _TextSong = "TextSong";
@@ -41,7 +41,6 @@ namespace Vocaluxe.Screens
private const string _ScreenSettingShortScore = "ScreenSettingShortScore";
private const string _ScreenSettingShortRating = "ScreenSettingShortRating";
private const string _ScreenSettingShortDifficulty = "ScreenSettingShortDifficulty";
private const string _ScreenSettingAnimationDirection = "ScreenSettingAnimationDirection";
private CBackground _SlideShowBG;
@@ -49,13 +48,10 @@ namespace Vocaluxe.Screens
private string[,] _TextScores;
private string[,] _TextRatings;
private string[,] _TextDifficulty;
private string[,] _StaticPointsBarBG;
private string[,] _StaticPointsBar;
private string[,] _ProgressBarPoints;
private string[,] _StaticAvatar;
private double[] _StaticPointsBarDrawnPoints;
private int _Round;
private CPoints _Points;
private Stopwatch _Timer;
public override EMusicType CurrentMusicType
{
@@ -77,9 +73,12 @@ namespace Vocaluxe.Screens
_ThemeStatics = statics.ToArray();
_ThemeScreenSettings = new string[] {_ScreenSettingShortScore, _ScreenSettingShortRating, _ScreenSettingShortDifficulty, _ScreenSettingAnimationDirection};
var progressBars = new List<string>();
_BuildProgressBarString(ref progressBars);
_StaticPointsBarDrawnPoints = new double[CSettings.MaxNumPlayer];
_ThemeProgressBars = progressBars.ToArray();
_ThemeScreenSettings = new string[] {_ScreenSettingShortScore, _ScreenSettingShortRating, _ScreenSettingShortDifficulty};
_SlideShowBG = GetNewBackground();
_AddBackground(_SlideShowBG);
@@ -157,34 +156,6 @@ namespace Vocaluxe.Screens
for (int p = 0; p < players.Length; p++)
players[p].Points = (int)(players[p].Points / CGame.NumRounds);
}
for (int p = 0; p < players.Length; p++)
{
if (_StaticPointsBarDrawnPoints[p] < players[p].Points)
{
if (CConfig.Config.Game.ScoreAnimationTime >= 1)
{
_StaticPointsBarDrawnPoints[p] = (_Timer.ElapsedMilliseconds / 1000f) / CConfig.Config.Game.ScoreAnimationTime * 10000;
if (_StaticPointsBarDrawnPoints[p] > players[p].Points)
_StaticPointsBarDrawnPoints[p] = players[p].Points;
var direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue();
if (direction.ToLower() == "vertical")
{
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].W = ((float)_StaticPointsBarDrawnPoints[p]) *
(_Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].W / CSettings.MaxScore);
}
else
{
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].H = ((float)_StaticPointsBarDrawnPoints[p]) *
(_Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].H / CSettings.MaxScore);
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].Y = _Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].H +
_Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].Y -
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].H;
}
}
}
}
return true;
}
@@ -242,8 +213,6 @@ namespace Vocaluxe.Screens
private void _BuildStaticStrings(ref List<string> statics)
{
_StaticPointsBar = new string[CSettings.MaxNumPlayer,CSettings.MaxNumPlayer];
_StaticPointsBarBG = new string[CSettings.MaxNumPlayer,CSettings.MaxNumPlayer];
_StaticAvatar = new string[CSettings.MaxNumPlayer,CSettings.MaxNumPlayer];
for (int numplayer = 0; numplayer < CSettings.MaxNumPlayer; numplayer++)
@@ -253,17 +222,31 @@ namespace Vocaluxe.Screens
if (player > numplayer)
continue;
string target = "P" + (player + 1) + "N" + (numplayer + 1);
_StaticPointsBarBG[player, numplayer] = "StaticPointsBarBG" + target;
_StaticPointsBar[player, numplayer] = "StaticPointsBar" + target;
_StaticAvatar[player, numplayer] = "StaticAvatar" + target;
statics.Add(_StaticPointsBarBG[player, numplayer]);
statics.Add(_StaticPointsBar[player, numplayer]);
statics.Add(_StaticAvatar[player, numplayer]);
}
}
}
private void _BuildProgressBarString(ref List<string> progressBars)
{
_ProgressBarPoints = new string[CSettings.MaxNumPlayer, CSettings.MaxNumPlayer];
for (int numplayer = 0; numplayer < CSettings.MaxNumPlayer; numplayer++)
{
for (int player = 0; player < CSettings.MaxNumPlayer; player++)
{
if (player > numplayer)
continue;
string target = "P" + (player + 1) + "N" + (numplayer + 1);
_ProgressBarPoints[player, numplayer] = "ProgressBarPoints" + target;
progressBars.Add(_ProgressBarPoints[player, numplayer]);
}
}
}
private void _UpdateRatings()
{
CSong song = null;
@@ -296,7 +279,6 @@ namespace Vocaluxe.Screens
players[p].Points = (int)Math.Round(players[p].Points / CGame.NumRounds);
}
var pointAnimDirection = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue();
for (int p = 0; p < players.Length; p++)
{
string name = CProfiles.GetPlayerName(players[p].ProfileID, p);
@@ -326,43 +308,11 @@ namespace Vocaluxe.Screens
else
_Texts[_TextRatings[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points)));
_StaticPointsBarDrawnPoints[p] = 0.0;
if (pointAnimDirection.ToLower() == "vertical")
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].W = 0;
else
{
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].H = 0;
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].Y = _Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].H +
_Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].Y -
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].H;
}
_ProgressBars[_ProgressBarPoints[p, CGame.NumPlayers - 1]].Progress = (float)players[p].Points / CSettings.MaxScore;
if (CProfiles.IsProfileIDValid(players[p].ProfileID))
_Statics[_StaticAvatar[p, CGame.NumPlayers - 1]].Texture = CProfiles.GetAvatarTextureFromProfile(players[p].ProfileID);
}
if (CConfig.Config.Game.ScoreAnimationTime < 1)
{
for (int p = 0; p < CGame.NumPlayers; p++)
{
if (pointAnimDirection.ToLower() == "vertical")
{
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].W = ((float)players[p].Points) *
(_Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].W / CSettings.MaxScore);
}
else
{
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].H = ((float)players[p].Points) *
(_Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].H / CSettings.MaxScore);
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].Y = _Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].H +
_Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].Y -
_Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].H;
}
_StaticPointsBarDrawnPoints[p] = players[p].Points;
}
}
_Timer = new Stopwatch();
_Timer.Start();
}
private void _SetVisibility()
@@ -377,8 +327,8 @@ namespace Vocaluxe.Screens
_Texts[_TextScores[player, numplayer]].Visible = numplayer + 1 == CGame.NumPlayers;
_Texts[_TextRatings[player, numplayer]].Visible = numplayer + 1 == CGame.NumPlayers;
_Texts[_TextDifficulty[player, numplayer]].Visible = numplayer + 1 == CGame.NumPlayers;
_Statics[_StaticPointsBar[player, numplayer]].Visible = numplayer + 1 == CGame.NumPlayers;
_Statics[_StaticPointsBarBG[player, numplayer]].Visible = numplayer + 1 == CGame.NumPlayers;
_ProgressBars[_ProgressBarPoints[player, numplayer]].Visible = numplayer + 1 == CGame.NumPlayers;
_ProgressBars[_ProgressBarPoints[player, numplayer]].Reset(true);
_Statics[_StaticAvatar[player, numplayer]].Visible = numplayer + 1 == CGame.NumPlayers;
_Statics[_StaticAvatar[player, numplayer]].Texture = null;
+52 -25
View File
@@ -121,10 +121,19 @@ namespace VocaluxeLib.Menu
public float Progress
{
get { return _ProgressTarget; }
set { _ProgressTarget = value; }
set
{
//Animation is still running, so use current state for calculations
if(_ProgressCurrent != _ProgressTarget)
{
_ProgressLast = _ProgressCurrent;
_ColorProgressLast = _ColorProgressCurrent;
}
_ProgressTarget = value;
}
}
private float _ProgressCurrent;
private float _ProgressLast = -1f;
private float _ProgressLast;
private SColorF _ColorProgressCurrent;
private SColorF _ColorProgressTarget;
@@ -139,6 +148,7 @@ namespace VocaluxeLib.Menu
private Stopwatch _AnimTimer;
private float _AnimDuration;
private bool _Animate;
public CProgressBar(int partyModeID)
{
@@ -187,9 +197,9 @@ namespace VocaluxeLib.Menu
return false;
}
public void Reset()
public void Reset(bool animateInit = false)
{
_ProgressLast = -1;
_Animate = animateInit;
}
public void Draw()
@@ -214,8 +224,6 @@ namespace VocaluxeLib.Menu
if (Reflection)
CBase.Drawing.DrawTextureReflection(_TextureBackground, Rect, color, Rect, ReflectionSpace, ReflectionHeight);
}
else
CBase.Drawing.DrawRect(ColorBackground, Rect);
//Draw progress
if (_TextureProgressBegin != null)
@@ -224,8 +232,6 @@ namespace VocaluxeLib.Menu
if (Reflection)
CBase.Drawing.DrawTextureReflection(_TextureProgressBegin, _RectProgressBegin, _ColorProgressCurrent, _RectProgressBegin, ReflectionSpace, ReflectionHeight);
}
else
CBase.Drawing.DrawRect(_ColorProgressCurrent, _RectProgressBegin);
if (_TextureProgressMid != null)
{
@@ -242,8 +248,6 @@ namespace VocaluxeLib.Menu
if (Reflection)
CBase.Drawing.DrawTextureReflection(_TextureProgressEnd, _RectProgressEnd, _ColorProgressCurrent, _RectProgressEnd, ReflectionSpace, ReflectionHeight);
}
else
CBase.Drawing.DrawRect(_ColorProgressCurrent, _RectProgressEnd);
//Draw foreground
color = new SColorF(ColorForeground.R, ColorForeground.G, ColorForeground.B, ColorForeground.A * Alpha);
@@ -253,8 +257,6 @@ namespace VocaluxeLib.Menu
if (Reflection)
CBase.Drawing.DrawTextureReflection(_TextureForeground, Rect, color, Rect, ReflectionSpace, ReflectionHeight);
}
else
CBase.Drawing.DrawRect(ColorForeground, Rect);
}
if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
@@ -302,14 +304,13 @@ namespace VocaluxeLib.Menu
if (_ProgressCurrent == _ProgressTarget)
return;
if (_ProgressLast != -1)
if (_Animate)
_CheckAnimation();
else
_ProgressCurrent = _ProgressLast = _ProgressTarget;
_UpdateProgressColor();
if (_ProgressLast == -1)
_ProgressCurrent = _ProgressLast = _ProgressTarget;
_UpdateProgressLeft();
_UpdateProgressMid();
_UpdateProgressRight();
@@ -342,6 +343,8 @@ namespace VocaluxeLib.Menu
_ProgressLast = _ProgressCurrent = _ProgressTarget;
_ColorProgressLast = _ColorProgressCurrent = _ColorProgressTarget;
}
_Animate = true;
}
private void _UpdateProgressColor()
@@ -350,7 +353,7 @@ namespace VocaluxeLib.Menu
if (col.From < _ProgressTarget)
col.Color.Get(_PartyModeID, out _ColorProgressTarget);
if(_ProgressLast != -1 && _Theme.AnimateColoring == EOffOn.TR_CONFIG_ON)
if(_Animate && _Theme.AnimateColoring == EOffOn.TR_CONFIG_ON)
{
float animFactor = (_AnimTimer.ElapsedMilliseconds / _AnimDuration).Clamp(0, 1);
@@ -369,22 +372,34 @@ namespace VocaluxeLib.Menu
{
case EDirection.Right:
_TextureProgressBegin = TextureProgressLeft;
_RectProgressBegin = new SRectF(Rect.X, Rect.Y, Rect.H * _TextureProgressBegin.OrigAspect, Rect.H, Rect.Z);
if (_TextureProgressBegin == null)
_RectProgressBegin = new SRectF(Rect.X, Rect.Y, 0, 0, Rect.Z);
else
_RectProgressBegin = new SRectF(Rect.X, Rect.Y, Rect.H * _TextureProgressBegin.OrigAspect, Rect.H, Rect.Z);
break;
case EDirection.Up:
_TextureProgressBegin = TextureProgressRight;
_RectProgressBegin = new SRectF(Rect.X, Rect.Y + Rect.H - Rect.W * _TextureProgressBegin.OrigAspect, Rect.W, Rect.W * _TextureProgressBegin.OrigAspect, Rect.Z);
if (_TextureProgressBegin == null)
_RectProgressBegin = new SRectF(Rect.X, Rect.Y + Rect.H, 0, 0, Rect.Z);
else
_RectProgressBegin = new SRectF(Rect.X, Rect.Y + Rect.H - Rect.W * _TextureProgressBegin.OrigAspect, Rect.W, Rect.W * _TextureProgressBegin.OrigAspect, Rect.Z);
break;
case EDirection.Left:
_TextureProgressBegin = TextureProgressRight;
_RectProgressBegin = new SRectF(Rect.X + Rect.W - Rect.H * _TextureProgressBegin.OrigAspect, Rect.Y, Rect.H *_TextureProgressBegin.OrigAspect, Rect.H, Rect.Z);
if (_TextureProgressBegin == null)
_RectProgressBegin = new SRectF(Rect.X + Rect.W, Rect.Y, 0, 0, Rect.Z);
else
_RectProgressBegin = new SRectF(Rect.X + Rect.W - Rect.H * _TextureProgressBegin.OrigAspect, Rect.Y, Rect.H *_TextureProgressBegin.OrigAspect, Rect.H, Rect.Z);
break;
case EDirection.Down:
_TextureProgressBegin = TextureProgressLeft;
_RectProgressBegin = new SRectF(Rect.X, Rect.Y, Rect.W, Rect.W * _TextureProgressBegin.OrigAspect, Rect.Z);
if (_TextureProgressBegin == null)
_RectProgressBegin = new SRectF(Rect.X, Rect.Y, 0, 0, Rect.Z);
else
_RectProgressBegin = new SRectF(Rect.X, Rect.Y, Rect.W, Rect.W * _TextureProgressBegin.OrigAspect, Rect.Z);
break;
}
}
@@ -419,22 +434,34 @@ namespace VocaluxeLib.Menu
{
case EDirection.Right:
_TextureProgressEnd = _TextureProgressRight;
_RectProgressEnd = new SRectF(_RectProgressMid.X + _RectProgressMid.W, Rect.Y, Rect.H * _TextureProgressBegin.OrigAspect, Rect.H, Rect.Z);
if (_TextureProgressEnd == null)
_RectProgressEnd = new SRectF(_RectProgressMid.X + _RectProgressMid.W, Rect.Y, 0, 0, Rect.Z);
else
_RectProgressEnd = new SRectF(_RectProgressMid.X + _RectProgressMid.W, Rect.Y, Rect.H * _TextureProgressBegin.OrigAspect, Rect.H, Rect.Z);
break;
case EDirection.Up:
_TextureProgressEnd = _TextureProgressLeft;
_RectProgressEnd = new SRectF(Rect.X, _RectProgressMid.Y + Rect.W, Rect.W, Rect.W * _TextureProgressBegin.OrigAspect, Rect.Z);
if (_TextureProgressEnd == null)
_RectProgressEnd = new SRectF(Rect.X, _RectProgressMid.Y + Rect.W, 0, 0, Rect.Z);
else
_RectProgressEnd = new SRectF(Rect.X, _RectProgressMid.Y + Rect.W, Rect.W, Rect.W * _TextureProgressBegin.OrigAspect, Rect.Z);
break;
case EDirection.Left:
_TextureProgressEnd = _TextureProgressLeft;
_RectProgressEnd = new SRectF(_RectProgressMid.X - Rect.H, Rect.Y, Rect.H * _TextureProgressBegin.OrigAspect, Rect.H, Rect.Z);
if (_TextureProgressEnd == null)
_RectProgressEnd = new SRectF(_RectProgressMid.X - Rect.H, Rect.Y, 0, 0, Rect.Z);
else
_RectProgressEnd = new SRectF(_RectProgressMid.X - Rect.H, Rect.Y, Rect.H * _TextureProgressBegin.OrigAspect, Rect.H, Rect.Z);
break;
case EDirection.Down:
_TextureProgressEnd = _TextureProgressRight;
_RectProgressEnd = new SRectF(Rect.X, _RectProgressMid.Y + _RectProgressMid.H, Rect.W, Rect.W * _TextureProgressBegin.OrigAspect, Rect.Z);
if (_TextureProgressEnd == null)
_RectProgressEnd = new SRectF(Rect.X, _RectProgressMid.Y + _RectProgressMid.H, 0, 0, Rect.Z);
else
_RectProgressEnd = new SRectF(Rect.X, _RectProgressMid.Y + _RectProgressMid.H, Rect.W, Rect.W * _TextureProgressBegin.OrigAspect, Rect.Z);
break;
}
}