From 360c6ae2fa67c3c4eff2e2bd711d8f543c1d60ee Mon Sep 17 00:00:00 2001 From: Dirk Heinke Date: Tue, 25 Mar 2025 06:26:37 +0100 Subject: [PATCH] Feature/rating pop up (#760) * WIP * WIP * Add text * Cleanup * More Cleanup * Update Changelog * Fix layout --------- Co-authored-by: Florian Schulze Co-authored-by: Florian Ostertag --- Output/Languages/en.xml | 8 + .../Themes/Changelog/Changelog_ScreenSing.txt | 5 + Output/Themes/Vocaluxe 2024/01_Standard.xml | 1 + .../Vocaluxe 2024/Screens/ScreenSing.xml | 507 ++++++++++++++++++ Vocaluxe/Base/CGame.cs | 8 + Vocaluxe/Screens/CScreenSing.cs | 134 ++++- VocaluxeLib/Menu/CInteraction.cs | 3 +- VocaluxeLib/Menu/CMenu.cs | 20 +- VocaluxeLib/Menu/CObjectInteractions.cs | 10 + VocaluxeLib/Menu/CRatingPopup.cs | 131 +++++ VocaluxeLib/Structs.cs | 3 + VocaluxeLib/VocaluxeLib.csproj | 1 + 12 files changed, 828 insertions(+), 3 deletions(-) create mode 100644 VocaluxeLib/Menu/CRatingPopup.cs diff --git a/Output/Languages/en.xml b/Output/Languages/en.xml index e418cddb..bbfb85da 100644 --- a/Output/Languages/en.xml +++ b/Output/Languages/en.xml @@ -174,6 +174,14 @@ No more songs in playlist! No webcam available! Aspect Ratio: %a + perfect! + awesome! + great! + good! + not bad! + bad! + poor! + awful! Skipped %s seconds Scores Rating diff --git a/Output/Themes/Changelog/Changelog_ScreenSing.txt b/Output/Themes/Changelog/Changelog_ScreenSing.txt index 38ce8c20..3bd4bd87 100644 --- a/Output/Themes/Changelog/Changelog_ScreenSing.txt +++ b/Output/Themes/Changelog/Changelog_ScreenSing.txt @@ -1,4 +1,9 @@ ScreenSing ++++++++++ +Version 12 + +Add: + +++++++++ Version 11 diff --git a/Output/Themes/Vocaluxe 2024/01_Standard.xml b/Output/Themes/Vocaluxe 2024/01_Standard.xml index 87989080..47f5840f 100644 --- a/Output/Themes/Vocaluxe 2024/01_Standard.xml +++ b/Output/Themes/Vocaluxe 2024/01_Standard.xml @@ -384,6 +384,7 @@ NotesFillLeft.png NotesFillMid.png NotesFillRight.png + RatingPopUp.png PopupBG.png ScrollUp.png ScrollDown.png diff --git a/Output/Themes/Vocaluxe 2024/Screens/ScreenSing.xml b/Output/Themes/Vocaluxe 2024/Screens/ScreenSing.xml index be33097b..67d44f8a 100644 --- a/Output/Themes/Vocaluxe 2024/Screens/ScreenSing.xml +++ b/Output/Themes/Vocaluxe 2024/Screens/ScreenSing.xml @@ -2751,4 +2751,511 @@ + + + + RatingPopup + + 1425 + 530.5 + 210 + 75 + -1 + + + 100 + 13 + -2 + 49 + 150 + + + Center + Center + + Outline + + + + + RatingPopup + + 1425 + 170.5 + 210 + 75 + -1 + + + 100 + 13 + -2 + 49 + 150 + + + Center + Center + + Outline + + + + + RatingPopup + + 1425 + 560.5 + 210 + 75 + -1 + + + 100 + 13 + -2 + 49 + 150 + + + Center + Center + + Outline + + + + + RatingPopup + + 1575 + 152 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 1575 + 408 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 1575 + 663 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 470 + 171 + 210 + 75 + -1 + + + 100 + 13 + -2 + 49 + 150 + + + Center + Center + + Outline + + + + + RatingPopup + + 470 + 561 + 210 + 75 + -1 + + + 100 + 13 + -2 + 49 + 150 + + + Center + Center + + Outline + + + + + RatingPopup + + 1421 + 171 + 210 + 75 + -1 + + + 100 + 13 + -2 + 49 + 150 + + + Center + Center + + Outline + + + + + RatingPopup + + 1421 + 561 + 210 + 75 + -1 + + + 100 + 13 + -2 + 49 + 150 + + + Center + Center + + Outline + + + + + RatingPopup + + 655.5 + 153 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 655.5 + 408 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 655.5 + 663 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 1608 + 153 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 1608 + 408 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 655.5 + 153 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 655.5 + 408 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 655.5 + 663 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 1608 + 153 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 1608 + 408 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + + RatingPopup + + 1608 + 663 + 140 + 47 + -1 + + + 62 + 8 + -2 + 30 + 100 + + + Center + Center + + Outline + + + + diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index 444d5208..9b101a00 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -211,6 +211,8 @@ namespace Vocaluxe.Base Players[i].GameMode = EGameMode.TR_GAMEMODE_NORMAL; Players[i].DateTicks = DateTime.Now.Ticks; Players[i].SongFinished = false; + Players[i].RatingLastLine = 0f; + Players[i].TimeLastLineChange = float.MaxValue; } _LastEvalBeat = -100; CurrentBeatF = -100; @@ -251,6 +253,11 @@ namespace Vocaluxe.Base if (line < 0 || lines[line].EndBeat < beat) continue; + if (Players[p].CurrentLine != line && line > 0) + { + Players[p].TimeLastLineChange = time; + } + //Check for already sung if (line < Players[p].SungLines.Count - 1) continue; // Already sung whole line @@ -379,6 +386,7 @@ namespace Vocaluxe.Base //Shift fraction of correct sung notes to [-0.1, 0.1], player needs to sing five lines fully correctly to get highest ranking double current = Players[p].SungLines[line].Points / (double)lines[line].Points; Players[p].Rating = (Players[p].Rating + (current * 0.2 - 0.1)).Clamp(0, 1); + Players[p].RatingLastLine = current; } } } diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 17abbe0e..b9c2231a 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -41,7 +41,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 11; } + get { return 12; } } private struct STimeRect @@ -81,6 +81,7 @@ namespace Vocaluxe.Screens private string[,,] _StaticAvatars; private string[,,] _ProgressBarsRating; + private string[,,] _RatingPopupsStrings; private const string _ButtonCancel = "ButtonCancel"; private const string _ButtonContinue = "ButtonContinue"; @@ -100,6 +101,7 @@ namespace Vocaluxe.Screens private string[] _PlayerTextScore; private string[] _PlayerTextName; private string[] _PlayerProgressBarRating; + private string[] _PlayerRatingPopup; private string[] _PlayerStaticScore; private string[] _PlayerStaticAvatar; private List[] _StaticsExtra; @@ -178,9 +180,14 @@ namespace Vocaluxe.Screens _BuildProgressBarStrings(ref progressbars); _ThemeProgressBars = progressbars.ToArray(); + var ratingPopups = new List(); + _BuildRatingPopupStrings(ref ratingPopups); + _ThemeRatingPopups = ratingPopups.ToArray(); + _CreatePlayerStatics(); _CreatePlayerStrings(); _CreateProgressBars(); + _CreateRatingPopups(); _AssignPlayerElements(); _ThemeButtons = new string[] { _ButtonCancel, _ButtonContinue, _ButtonRestartGame, _ButtonRestartRound, _ButtonSkip }; @@ -413,6 +420,7 @@ namespace Vocaluxe.Screens _InitiatePlayerStatics(); _InitiatePlayerStrings(); _InitiateProgressBars(); + _InitiateRatingPopups(); if (_StaticsExtra == null) _CreateExtraStatics(); if (_TextsExtra == null) @@ -507,6 +515,7 @@ namespace Vocaluxe.Screens CGame.UpdatePoints(_CurrentTime); _UpdateRatingBars(); + _UpdateRatingPopups(); _UpdateLyrics(); if (CGame.GameMode == EGameMode.TR_GAMEMODE_MEDLEY) _UpdateMedleyCountdown(); @@ -542,6 +551,7 @@ namespace Vocaluxe.Screens _Texts[_PlayerTextName[p]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; _Texts[_PlayerTextScore[p]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; _ProgressBars[_PlayerProgressBarRating[p]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; + _RatingPopups[_PlayerRatingPopup[p]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; } } @@ -860,6 +870,62 @@ namespace Vocaluxe.Screens } } + private void _UpdateRatingPopups() + { + + for (int i = 0; i < CGame.NumPlayers; i++) + { + + float fadeOutTime = 1f; + float showTime = 0.5f; + var timeSinceLastLine = Math.Abs(_CurrentTime - CGame.Players[i].TimeLastLineChange); + if (timeSinceLastLine < showTime) + { + _RatingPopups[_PlayerRatingPopup[i]].Alpha = 1; + } + else if (timeSinceLastLine < showTime + fadeOutTime) + { + _RatingPopups[_PlayerRatingPopup[i]].Alpha = 1 - (timeSinceLastLine - showTime) / fadeOutTime; + } + else + { + _RatingPopups[_PlayerRatingPopup[i]].Alpha = 0; + } + + switch(CGame.Players[i].RatingLastLine) + { + case 1: + _RatingPopups[_PlayerRatingPopup[i]].Text.Text = "TR_SCREENSING_RATING_1"; + break; + case double rating when rating > 0.90: + _RatingPopups[_PlayerRatingPopup[i]].Text.Text = "TR_SCREENSING_RATING_2"; + break; + case double rating when rating > 0.75: + _RatingPopups[_PlayerRatingPopup[i]].Text.Text = "TR_SCREENSING_RATING_3"; + break; + case double rating when rating > 0.60: + _RatingPopups[_PlayerRatingPopup[i]].Text.Text = "TR_SCREENSING_RATING_4"; + break; + case double rating when rating > 0.45: + _RatingPopups[_PlayerRatingPopup[i]].Text.Text = "TR_SCREENSING_RATING_5"; + break; + case double rating when rating > 0.30: + _RatingPopups[_PlayerRatingPopup[i]].Text.Text = "TR_SCREENSING_RATING_6"; + break; + case double rating when rating >= 0.15: + _RatingPopups[_PlayerRatingPopup[i]].Text.Text = "TR_SCREENSING_RATING_7"; + break; + case double rating when rating < 0.15: + _RatingPopups[_PlayerRatingPopup[i]].Text.Text = "TR_SCREENSING_RATING_8"; + break; + + } + + _RatingPopups[_PlayerRatingPopup[i]].Color = new SColorF(CBase.Themes.GetPlayerColor(i + 1), 1); + + } + } + #endregion #region drawing @@ -1401,6 +1467,7 @@ namespace Vocaluxe.Screens _Statics[_StaticAvatars[screen, player, numplayer]].Visible = false; _ProgressBars[_ProgressBarsRating[screen, player, numplayer]].AllMonitors = false; _ProgressBars[_ProgressBarsRating[screen, player, numplayer]].Visible = false; + _RatingPopups[_RatingPopupsStrings[screen, player, numplayer]].Visible = false; } } } @@ -1412,6 +1479,7 @@ namespace Vocaluxe.Screens _Texts[_PlayerTextScore[player]].Visible = false; _Statics[_PlayerStaticScore[player]].Visible = false; _ProgressBars[_PlayerProgressBarRating[player]].Visible = false; + _RatingPopups[_PlayerRatingPopup[player]].Visible = false; _SingNotes[_SingBars].Visible = false; } @@ -1420,6 +1488,7 @@ namespace Vocaluxe.Screens _Texts[_PlayerTextScore[player]].Visible = true; _Statics[_PlayerStaticScore[player]].Visible = true; _ProgressBars[_PlayerProgressBarRating[player]].Visible = true; + _RatingPopups[_PlayerRatingPopup[player]].Visible = true; _SingNotes[_SingBars].Visible = true; } @@ -1709,6 +1778,26 @@ namespace Vocaluxe.Screens } } + private void _BuildRatingPopupStrings(ref List ratingPopups) + { + _RatingPopupsStrings = new string[CSettings.MaxNumScreens, CSettings.MaxNumPlayer, CSettings.MaxNumPlayer]; + for (int screen = 0; screen < CSettings.MaxNumScreens; screen++) + { + for (int numplayer = 0; numplayer < CSettings.MaxNumPlayer; numplayer++) + { + for (int player = 0; player < CSettings.MaxNumPlayer; player++) + { + if (player <= numplayer) + { + string target = "P" + (player + 1) + "N" + (numplayer + 1); + _RatingPopupsStrings[screen, player, numplayer] = "RatingPopupS" + (screen + 1) + target; + ratingPopups.Add("RatingPopup" + target); + } + } + } + } + } + private void _CreateProgressBars() { for (int screen = 0; screen < CSettings.MaxNumScreens; screen++) @@ -1727,6 +1816,24 @@ namespace Vocaluxe.Screens } } + private void _CreateRatingPopups() + { + for (int screen = 0; screen < CSettings.MaxNumScreens; screen++) + { + for (int numplayer = 0; numplayer < CSettings.MaxNumPlayer; numplayer++) + { + for (int player = 0; player < CSettings.MaxNumPlayer; player++) + { + if (player <= numplayer) + { + string target = "S" + (screen + 1) + "P" + (player + 1) + "N" + (numplayer + 1); + _AddRatingPopup(GetNewRatingPopup(), "RatingPopup" + target); + } + } + } + } + } + private void _InitiateProgressBars() { for (int screen = 0; screen < CSettings.MaxNumScreens; screen++) @@ -1747,6 +1854,26 @@ namespace Vocaluxe.Screens } } + private void _InitiateRatingPopups() + { + for (int screen = 0; screen < CSettings.MaxNumScreens; screen++) + { + for (int numplayer = 0; numplayer < CSettings.MaxNumPlayer; numplayer++) + { + for (int player = 0; player < CSettings.MaxNumPlayer; player++) + { + if (player <= numplayer) + { + string target = "P" + (player + 1) + "N" + (numplayer + 1); + _RatingPopups["RatingPopup" + target].Visible = false; + _RatingPopups["RatingPopupS" + (screen + 1) + target] = GetNewRatingPopup(_RatingPopups["RatingPopup" + target]); + _RatingPopups["RatingPopupS" + (screen + 1) + target].X += screen * CSettings.RenderW; + } + } + } + } + } + private void _CreateExtraStatics() { _StaticsExtra = new List[CSettings.MaxNumScreens]; @@ -1913,6 +2040,7 @@ namespace Vocaluxe.Screens _PlayerStaticAvatar = new String[CGame.NumPlayers]; _PlayerStaticScore = new String[CGame.NumPlayers]; _PlayerProgressBarRating = new String[CGame.NumPlayers]; + _PlayerRatingPopup = new String[CGame.NumPlayers]; int screenPlayers = CGame.NumPlayers / CConfig.GetNumScreens(); int remainingPlayers = CGame.NumPlayers - (screenPlayers * CConfig.GetNumScreens()); @@ -1927,6 +2055,7 @@ namespace Vocaluxe.Screens _PlayerTextScore[player] = _TextScores[s, p, screenPlayers]; _PlayerTextName[player] = _TextNames[s, p, screenPlayers]; _PlayerProgressBarRating[player] = _ProgressBarsRating[s, p, screenPlayers]; + _PlayerRatingPopup[player] = _RatingPopupsStrings[s, p, screenPlayers]; _PlayerStaticAvatar[player] = _StaticAvatars[s, p, screenPlayers]; _PlayerStaticScore[player++] = _StaticScores[s, p, screenPlayers]; if (p == screenPlayers - 1) @@ -1934,6 +2063,7 @@ namespace Vocaluxe.Screens _PlayerTextScore[player] = _TextScores[s, p + 1, screenPlayers]; _PlayerTextName[player] = _TextNames[s, p + 1, screenPlayers]; _PlayerProgressBarRating[player] = _ProgressBarsRating[s, p + 1, screenPlayers]; + _PlayerRatingPopup[player] = _RatingPopupsStrings[s, p + 1, screenPlayers]; _PlayerStaticAvatar[player] = _StaticAvatars[s, p + 1, screenPlayers]; _PlayerStaticScore[player++] = _StaticScores[s, p + 1, screenPlayers]; remainingPlayers--; @@ -1944,6 +2074,7 @@ namespace Vocaluxe.Screens _PlayerTextScore[player] = _TextScores[s, p, screenPlayers - 1]; _PlayerTextName[player] = _TextNames[s, p, screenPlayers - 1]; _PlayerProgressBarRating[player] = _ProgressBarsRating[s, p, screenPlayers - 1]; + _PlayerRatingPopup[player] = _RatingPopupsStrings[s, p, screenPlayers - 1]; _PlayerStaticAvatar[player] = _StaticAvatars[s, p, screenPlayers - 1]; _PlayerStaticScore[player++] = _StaticScores[s, p, screenPlayers - 1]; } @@ -1955,6 +2086,7 @@ namespace Vocaluxe.Screens _PlayerTextScore[player] = _TextScores[s, 0, 0]; _PlayerTextName[player] = _TextNames[s, 0, 0]; _PlayerProgressBarRating[player] = _ProgressBarsRating[s, 0, 0]; + _PlayerRatingPopup[player] = _RatingPopupsStrings[s, 0, 0]; _PlayerStaticAvatar[player] = _StaticAvatars[s, 0, 0]; _PlayerStaticScore[player++] = _StaticScores[s, 0, 0]; remainingPlayers--; diff --git a/VocaluxeLib/Menu/CInteraction.cs b/VocaluxeLib/Menu/CInteraction.cs index 354b299f..9b9a1e7a 100644 --- a/VocaluxeLib/Menu/CInteraction.cs +++ b/VocaluxeLib/Menu/CInteraction.cs @@ -31,7 +31,8 @@ namespace VocaluxeLib.Menu Equalizer, Playlist, ParticleEffect, - ProgressBar + ProgressBar, + RatingPopup, } public class CInteraction diff --git a/VocaluxeLib/Menu/CMenu.cs b/VocaluxeLib/Menu/CMenu.cs index 8c82185a..78f4d2e3 100644 --- a/VocaluxeLib/Menu/CMenu.cs +++ b/VocaluxeLib/Menu/CMenu.cs @@ -53,6 +53,7 @@ namespace VocaluxeLib.Menu [XmlArray("ParticleEffects")] public List ParticleEffects; [XmlArray("ScreenSettings")] public List ScreenSettings; [XmlArray("ProgressBars")] public List ProgressBars; + [XmlArray("RatingPopups")] public List RatingPopups; } struct SZSort @@ -85,6 +86,7 @@ namespace VocaluxeLib.Menu protected string[] _ThemeParticleEffects; protected string[] _ThemeScreenSettings; protected string[] _ThemeProgressBars; + protected string[] _ThemeRatingPopups; protected readonly Dictionary _ScreenSettings = new Dictionary(); // ReSharper restore MemberCanBePrivate.Global @@ -121,6 +123,7 @@ namespace VocaluxeLib.Menu _ThemeParticleEffects = null; _ThemeScreenSettings = null; _ThemeProgressBars = null; + _ThemeRatingPopups = null; } protected virtual void _OnSongMenuChanged() @@ -148,7 +151,8 @@ namespace VocaluxeLib.Menu private static readonly string[] _AllowedMissing = new string[] { "Backgrounds", "Statics", "Texts", "Buttons", "SongMenus", "Lyrics", "SelectSlides", "SingNotes", - "NameSelections", "Equalizers", "Playlists", "ParticleEffects", "ScreenSettings", "ProgressBars" + "NameSelections", "Equalizers", "Playlists", "ParticleEffects", "ScreenSettings", "ProgressBars", + "RatingPopups" }; public override void HandleError(CXmlException e) @@ -198,6 +202,9 @@ namespace VocaluxeLib.Menu foreach (SThemeProgressBar pb in Theme.ProgressBars) _AddProgressBar(new CProgressBar(pb, PartyModeID), pb.Name); + foreach (SThemeRatingPopup rp in Theme.RatingPopups) + _AddRatingPopup(new CRatingPopup(rp, PartyModeID), rp.Name); + foreach (SThemeScreenSetting ss in Theme.ScreenSettings) _AddScreenSetting(new CScreenSetting(ss, PartyModeID), ss.Name); @@ -276,6 +283,7 @@ namespace VocaluxeLib.Menu _AddThemeablesToList(Theme.ParticleEffects, _ParticleEffects); _AddThemeablesToList(Theme.Playlists, _Playlists); _AddThemeablesToList(Theme.ProgressBars, _ProgressBars); + _AddThemeablesToList(Theme.RatingPopups, _RatingPopups); _AddThemeablesToList(Theme.ScreenSettings, _ScreenSettings.Values); _AddThemeablesToList(Theme.SelectSlides, _SelectSlides); _AddThemeablesToList(Theme.Statics, _Statics); @@ -406,6 +414,16 @@ namespace VocaluxeLib.Menu return new CProgressBar(pb); } + public CRatingPopup GetNewRatingPopup() + { + return new CRatingPopup(PartyModeID); + } + + public static CRatingPopup GetNewRatingPopup(CRatingPopup rp) + { + return new CRatingPopup(rp); + } + // ReSharper restore MemberCanBeProtected.Global // ReSharper restore UnusedMember.Global #endregion Create Elements diff --git a/VocaluxeLib/Menu/CObjectInteractions.cs b/VocaluxeLib/Menu/CObjectInteractions.cs index bf83b4e5..340635d0 100644 --- a/VocaluxeLib/Menu/CObjectInteractions.cs +++ b/VocaluxeLib/Menu/CObjectInteractions.cs @@ -47,6 +47,7 @@ namespace VocaluxeLib.Menu protected readonly COrderedDictionaryLite _Playlists; protected readonly COrderedDictionaryLite _ParticleEffects; protected readonly COrderedDictionaryLite _ProgressBars; + protected readonly COrderedDictionaryLite _RatingPopups; private readonly SColorF _HighlightColor = new SColorF(1, 0, 0, 0); protected CObjectInteractions() @@ -64,6 +65,7 @@ namespace VocaluxeLib.Menu _Playlists = new COrderedDictionaryLite(this); _ParticleEffects = new COrderedDictionaryLite(this); _ProgressBars = new COrderedDictionaryLite(this); + _RatingPopups = new COrderedDictionaryLite(this); } public virtual void Init() @@ -89,6 +91,7 @@ namespace VocaluxeLib.Menu _Playlists.Clear(); _ParticleEffects.Clear(); _ProgressBars.Clear(); + _RatingPopups.Clear(); } private void _SetSelected(int newSelection) @@ -302,6 +305,8 @@ namespace VocaluxeLib.Menu return _ParticleEffects[element.Num]; case EType.ProgressBar: return _ProgressBars[element.Num]; + case EType.RatingPopup: + return _RatingPopups[element.Num]; } throw new ArgumentException("Invalid element type: " + element.Type); } @@ -411,6 +416,11 @@ namespace VocaluxeLib.Menu { _AddElement(_ProgressBars.Add(pb, key), EType.ProgressBar); } + + protected void _AddRatingPopup(CRatingPopup rp, String key = null) + { + _AddElement(_RatingPopups.Add(rp, key), EType.RatingPopup); + } #endregion Element-Adding #region InteractionHandling diff --git a/VocaluxeLib/Menu/CRatingPopup.cs b/VocaluxeLib/Menu/CRatingPopup.cs new file mode 100644 index 00000000..c4233e64 --- /dev/null +++ b/VocaluxeLib/Menu/CRatingPopup.cs @@ -0,0 +1,131 @@ +using System.Xml.Serialization; +using VocaluxeLib.Draw; + +namespace VocaluxeLib.Menu +{ + [XmlType("RatingPopup")] + public struct SThemeRatingPopup + { + [XmlAttribute(AttributeName = "Name")] public string Name; + public string SkinRatingPopup; + public SRectF Rect; + public SThemeText Text; + } + + public sealed class CRatingPopup : CMenuElementBase, IMenuElement, IThemeable + { + private readonly int _PartyModeID; + private SThemeRatingPopup _Theme; + private CTextureRef _TextureRatingPopup; + public CTextureRef TextureRatingPopup + { + get { return _TextureRatingPopup ?? CBase.Themes.GetSkinTexture(_Theme.SkinRatingPopup, _PartyModeID); } + + set { _TextureRatingPopup = value; } + } + + public bool Selectable => false; + public bool ThemeLoaded { get; private set; } + public CText Text; + public float Alpha = 1; + public SColorF Color; + + public CRatingPopup(int partyModeID) + { + _PartyModeID = partyModeID; + Text = new CText(partyModeID); + Text.AllMonitors = false; + Visible = false; + } + + public CRatingPopup(CRatingPopup rp) + { + _PartyModeID = rp._PartyModeID; + _TextureRatingPopup = rp._TextureRatingPopup; + Text = new CText(rp.Text); + Text.AllMonitors = false; + Visible = false; + MaxRect = rp.MaxRect; + } + + public CRatingPopup(SThemeRatingPopup theme, int partyModeID) + { + _Theme = theme; + _PartyModeID = partyModeID; + Text = new CText(theme.Text, partyModeID); + Text.AllMonitors = false; + Visible = false; + ThemeLoaded = true; + } + + + public void Draw() + { + SColorF color = Color; + color.A = Alpha; + Text.Color.A = Alpha; + + if (_TextureRatingPopup != null) + { + CBase.Drawing.DrawTexture(_TextureRatingPopup , Rect, color, false); + } + + Text.DrawRelative(Rect.X, Rect.Y); + } + + public object GetTheme() + { + _Theme.Text = (SThemeText)Text.GetTheme(); + return _Theme; + } + + public string GetThemeName() + { + return _Theme.Name; + } + + public void LoadSkin() + { + if (!ThemeLoaded) + return; + + TextureRatingPopup = CBase.Themes.GetSkinTexture(_Theme.SkinRatingPopup, _PartyModeID); + Text = new CText(_Theme.Text, _PartyModeID); + Text.LoadSkin(); + MaxRect = _Theme.Rect; + } + + public void UnloadSkin() + { + } + + public void ReloadSkin() + { + UnloadSkin(); + LoadSkin(); + } + + public void MoveElement(int stepX, int stepY) + { + X += stepX; + Y += stepY; + + _Theme.Rect.X += stepX; + _Theme.Rect.Y += stepY; + } + + public void ResizeElement(int stepW, int stepH) + { + W += stepW; + if (W <= 0) + W = 1; + + H += stepH; + if (H <= 0) + H = 1; + + _Theme.Rect.W = Rect.W; + _Theme.Rect.H = Rect.H; + } + } +} diff --git a/VocaluxeLib/Structs.cs b/VocaluxeLib/Structs.cs index f32b60b4..166e4c65 100644 --- a/VocaluxeLib/Structs.cs +++ b/VocaluxeLib/Structs.cs @@ -346,12 +346,15 @@ namespace VocaluxeLib public double PointsLineBonus; public double PointsGoldenNotes; public double Rating; + public double RatingLastLine; public int NoteDiff; public int VoiceNr; public List SungLines; public int CurrentLine; public int CurrentNote; + public float TimeLastLineChange; + public int SongID; public EGameMode GameMode; public long DateTicks; diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index 242ea280..75d30d9a 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -147,6 +147,7 @@ +