private void _LoadPlayerPanels() { for (int i = 0; i < CGame.NumPlayers; i++) { _NameSelections[_NameSelection].UseProfile(CGame.Players[i].ProfileID); _Statics[_PlayerStaticAvatar[i]].Texture = CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID) ? CProfiles.GetAvatarTextureFromProfile(CGame.Players[i].ProfileID) : _OriginalPlayerAvatarTextures[i]; _Texts[_PlayerText[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID, i + 1); } _PopulateVoiceSelection(); }
private void _LoadProfiles() { _NameSelections[_NameSelection].UpdateList(); _UpdateSlides(); _UpdatePlayerNumber(); _CheckMics(); _CheckPlayers(); CSong firstSong = CGame.GetSong(0); for (int i = 0; i < CSettings.MaxNumPlayer; i++) { _NameSelections[_NameSelection].UseProfile(CGame.Players[i].ProfileID); _Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID) ? CProfiles.GetAvatarTextureFromProfile(CGame.Players[i].ProfileID) : _OriginalPlayerAvatarTextures[i]; _Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID, i + 1); if (CGame.GetNumSongs() == 1 && firstSong.IsDuet) { _SelectSlides[_SelectSlideDuetPlayer[i]].Clear(); _SelectSlides[_SelectSlideDuetPlayer[i]].Visible = i + 1 <= CGame.NumPlayers; for (int j = 0; j < firstSong.Notes.VoiceCount; j++) { _SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(firstSong.Notes.VoiceNames[j]); } _SelectSlides[_SelectSlideDuetPlayer[i]].Selection = i % 2; } else { _SelectSlides[_SelectSlideDuetPlayer[i]].Visible = false; } } _NameSelections[_NameSelection].UpdateList(); _ProfilesChanged = false; _AvatarsChanged = false; }
public override bool HandleMouse(SMouseEvent mouseEvent) { bool stopSelectingFast = false; if (_SelectingFast) { _NameSelections[_NameSelection].HandleMouse(mouseEvent); } else { base.HandleMouse(mouseEvent); } //Check if LeftButton is hold and Select-Mode inactive if (mouseEvent.LBH && _SelectedProfileID == Guid.Empty && !_SelectingFast) { //Save mouse-coords _OldMouseX = mouseEvent.X; _OldMouseY = mouseEvent.Y; //Check if mouse if over tile if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) { //Get player-number of tile _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent); if (_SelectedProfileID != Guid.Empty) { //Update of Drag/Drop-Texture CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent); _ChooseAvatarStatic.Visible = true; _ChooseAvatarStatic.MaxRect = selectedPlayer.Rect; _ChooseAvatarStatic.Z = CSettings.ZNear; _ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1); _ChooseAvatarStatic.Texture = selectedPlayer.Texture; } } else { for (int i = 0; i < CGame.NumPlayers; i++) { if (CHelper.IsInBounds(_Statics[_PlayerStatic[i]].Rect, mouseEvent)) { _SelectingSwitchNr = i; _SelectedProfileID = CGame.Players[i].ProfileID; //Update of Drag/Drop-Texture CStatic selectedPlayer = _Statics[_PlayerStaticAvatar[i]]; _ChooseAvatarStatic.Visible = true; _ChooseAvatarStatic.MaxRect = selectedPlayer.Rect; _ChooseAvatarStatic.Z = CSettings.ZNear; _ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1); _ChooseAvatarStatic.Texture = selectedPlayer.Texture; break; } } } } //Check if LeftButton is hold and Select-Mode active if (mouseEvent.LBH && _SelectedProfileID != Guid.Empty && !_SelectingFast) { //Update coords for Drag/Drop-Texture _ChooseAvatarStatic.X += mouseEvent.X - _OldMouseX; _ChooseAvatarStatic.Y += mouseEvent.Y - _OldMouseY; _OldMouseX = mouseEvent.X; _OldMouseY = mouseEvent.Y; } // LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar else if (_SelectedProfileID != Guid.Empty && !_SelectingFast) { //Foreach Drop-Area for (int i = 0; i < _PlayerStatic.Length; i++) { //Check first, if area is "Active" if (!_Statics[_PlayerStatic[i]].Visible) { continue; } //Check if Mouse is in area if (CHelper.IsInBounds(_Statics[_PlayerStatic[i]].Rect, mouseEvent)) { if (_SelectingSwitchNr > -1 && CGame.Players[i].ProfileID != Guid.Empty) { _UpdateSelectedProfile(_SelectingSwitchNr, CGame.Players[i].ProfileID); } else if (_SelectingSwitchNr > -1) { _ResetPlayerSelection(_SelectingSwitchNr); } if (!CProfiles.IsProfileIDValid(_SelectedProfileID)) { return(true); } _UpdateSelectedProfile(i, _SelectedProfileID); break; } //Selected player is dropped out of area if (_SelectingSwitchNr > -1) { _ResetPlayerSelection(_SelectingSwitchNr); } } _SelectingSwitchNr = -1; _SelectedProfileID = Guid.Empty; //Reset variables _ChooseAvatarStatic.Visible = false; } if (mouseEvent.LB && _SelectingFast) { if (_NameSelections[_NameSelection].IsOverTile(mouseEvent)) { //Get player-number of tile _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent); if (_SelectedProfileID != Guid.Empty) { if (!CProfiles.IsProfileIDValid(_SelectedProfileID)) { return(true); } _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID); _SelectingFastPlayerNr++; if (_SelectingFastPlayerNr <= CGame.NumPlayers) { _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } else { stopSelectingFast = true; } } else { stopSelectingFast = true; } } } else if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonBack].Selected) { CGraphics.FadeTo(EScreen.Song); } else if (_Buttons[_ButtonStart].Selected) { _StartSong(); } else if (_Buttons[_ButtonNewProfile].Selected) { CGraphics.ShowPopup(EPopupScreens.PopupNewPlayer); } else if (_Buttons["ButtonScrollUp"].Selected) { _NameSelections[_NameSelection].UpdateList(_NameSelections[_NameSelection].Offset - 1); } else if (_Buttons["ButtonScrollDown"].Selected) { _NameSelections[_NameSelection].UpdateList(_NameSelections[_NameSelection].Offset + 1); } else { _UpdatePlayerNumber(); } //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); } if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast) { _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent); if (_SelectedProfileID != Guid.Empty) { for (int i = 0; i < CGame.NumPlayers; i++) { if (CGame.Players[i].ProfileID == Guid.Empty) { if (!CProfiles.IsProfileIDValid(_SelectedProfileID)) { return(true); } _UpdateSelectedProfile(i, _SelectedProfileID); break; } } } } if (mouseEvent.RB && _SelectingFast) { stopSelectingFast = true; } else if (mouseEvent.RB) { bool exit = true; //Remove profile-selection for (int i = 0; i < CConfig.Config.Game.NumPlayers; i++) { if (CHelper.IsInBounds(_Statics[_PlayerStatic[i]].Rect, mouseEvent)) { _ResetPlayerSelection(i); exit = false; } } if (exit) { CGraphics.FadeTo(EScreen.Song); } } if (mouseEvent.MB && _SelectingFast) { _SelectingFastPlayerNr++; if (_SelectingFastPlayerNr <= CGame.NumPlayers) { _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } else { stopSelectingFast = true; } } else if (mouseEvent.MB) { _ResetPlayerSelections(); _SelectingFast = true; _SelectingFastPlayerNr = 1; _SelectingKeyboardActive = true; _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } //Check mouse-wheel for scrolling if (mouseEvent.Wheel != 0) { if (CHelper.IsInBounds(_NameSelections[_NameSelection].Rect, mouseEvent)) { int offset = _NameSelections[_NameSelection].Offset + mouseEvent.Wheel; _NameSelections[_NameSelection].UpdateList(offset); } } if (stopSelectingFast) { _SelectingFast = false; _SelectingFastPlayerNr = 0; _SelectingKeyboardActive = false; _NameSelections[_NameSelection].FastSelection(false, -1); } return(true); }
public override bool HandleInput(SKeyEvent keyEvent) { switch (keyEvent.Key) { case Keys.Add: if (CConfig.Config.Game.NumPlayers + 1 <= CSettings.MaxNumPlayer) { _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.Config.Game.NumPlayers; _UpdatePlayerNumber(); //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); } break; case Keys.Subtract: if (CConfig.Config.Game.NumPlayers - 1 > 0) { _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.Config.Game.NumPlayers - 2; _UpdatePlayerNumber(); //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); } break; case Keys.P: if (!_SelectingKeyboardActive) { _SelectingFastPlayerNr = 1; _SelectingFast = true; _ResetPlayerSelections(); } else { if (_SelectingFastPlayerNr + 1 <= CGame.NumPlayers) { _SelectingFastPlayerNr++; } else { _SelectingFastPlayerNr = 1; } _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } break; case Keys.N: CGraphics.ShowPopup(EPopupScreens.PopupNewPlayer); break; } //Check if selecting with keyboard is active if (_SelectingKeyboardActive) { //Handle left/right/up/down _NameSelections[_NameSelection].HandleInput(keyEvent); int numberPressed = -1; bool resetSelection = false; switch (keyEvent.Key) { case Keys.Enter: //Check, if a player is selected if (_NameSelections[_NameSelection].SelectedID != Guid.Empty) { _SelectedProfileID = _NameSelections[_NameSelection].SelectedID; if (!CProfiles.IsProfileIDValid(_SelectedProfileID)) { return(true); } _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID); } //Started selecting with 'P' if (_SelectingFast) { if (_SelectingFastPlayerNr == CGame.NumPlayers) { resetSelection = true; _SelectElement(_Buttons[_ButtonStart]); } else { _SelectingFastPlayerNr++; _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } } else { resetSelection = true; } break; case Keys.D1: case Keys.NumPad1: numberPressed = 1; break; case Keys.D2: case Keys.NumPad2: numberPressed = 2; break; case Keys.D3: case Keys.NumPad3: numberPressed = 3; break; case Keys.D4: case Keys.NumPad4: numberPressed = 4; break; case Keys.D5: case Keys.NumPad5: numberPressed = 5; break; case Keys.D6: case Keys.NumPad6: numberPressed = 6; break; case Keys.Escape: resetSelection = true; _SelectElement(_SelectSlides[_SelectSlidePlayerNumber]); break; case Keys.Delete: //Delete profile-selection _ResetPlayerSelection(_SelectingFastPlayerNr - 1); //Reset all values _SelectingFastPlayerNr = 0; _SelectingKeyboardActive = false; _NameSelections[_NameSelection].FastSelection(false, -1); //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); break; case Keys.F10: if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet) { CSelectSlide selectSlideDuetPart = _SelectSlides[_PlayerSelectSlideDuet[_SelectingFastPlayerNr - 1]]; selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2; //Reset all values _SelectingFastPlayerNr = 0; _SelectingKeyboardActive = false; _SelectingFast = false; _NameSelections[_NameSelection].FastSelection(false, -1); _SelectElement(_Buttons[_ButtonStart]); } break; } if (numberPressed > 0 || resetSelection) { if (numberPressed == _SelectingFastPlayerNr || resetSelection) { //Reset all values _SelectingFastPlayerNr = 0; _SelectingKeyboardActive = false; _SelectElement(_SelectSlides[_SelectSlidePlayerNumber]); _NameSelections[_NameSelection].FastSelection(false, -1); } else if (numberPressed <= CConfig.Config.Game.NumPlayers) { _SelectingFastPlayerNr = numberPressed; _NameSelections[_NameSelection].FastSelection(true, numberPressed); } _SelectingFast = false; if (_PreviousPlayerSelection > -1) { _SelectElement(_Buttons[_PlayerButton[_PreviousPlayerSelection]]); _PreviousPlayerSelection = -1; } } } //Normal Keyboard handling else { base.HandleInput(keyEvent); switch (keyEvent.Key) { case Keys.Escape: case Keys.Back: CGraphics.FadeTo(EScreen.Song); break; case Keys.Enter: if (_Buttons[_ButtonBack].Selected) { CGraphics.FadeTo(EScreen.Song); } else if (_Buttons[_ButtonStart].Selected) { _StartSong(); } else if (_Buttons[_ButtonNewProfile].Selected) { CGraphics.ShowPopup(EPopupScreens.PopupNewPlayer); } for (int p = 0; p < CGame.NumPlayers; p++) { if (_Buttons[_PlayerButton[p]].Selected) { _PreviousPlayerSelection = p; _SelectingFastPlayerNr = p + 1; } } break; case Keys.D1: case Keys.NumPad1: _SelectingFastPlayerNr = 1; break; case Keys.D2: case Keys.NumPad2: _SelectingFastPlayerNr = 2; break; case Keys.D3: case Keys.NumPad3: _SelectingFastPlayerNr = 3; break; case Keys.D4: case Keys.NumPad4: _SelectingFastPlayerNr = 4; break; case Keys.D5: case Keys.NumPad5: _SelectingFastPlayerNr = 5; break; case Keys.D6: case Keys.NumPad6: _SelectingFastPlayerNr = 6; break; default: _UpdatePlayerNumber(); break; } if (_SelectingFastPlayerNr > 0 && _SelectingFastPlayerNr <= CConfig.Config.Game.NumPlayers) { _SelectingKeyboardActive = true; _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } if (_NameSelections[_NameSelection].Selected && !_SelectingKeyboardActive) { _SelectingKeyboardActive = true; _SelectingFast = true; _SelectingFastPlayerNr = 1; _SelectingKeyboardActive = true; _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); } } return(true); }
private void _UpdateRatings() { CSong song = null; var players = new SPlayer[CGame.NumPlayers]; if (_Round >= 0) { song = CGame.GetSong(_Round); if (song == null) { return; } _Texts[_TextSong].Text = song.Artist + " - " + song.Title; if (_Points.NumRounds > 1) { _Texts[_TextSong].Text += " (" + (_Round + 1) + "/" + _Points.NumRounds + ")"; } players = _Points.GetPlayer(_Round, CGame.NumPlayers); } else { _Texts[_TextSong].Text = "TR_SCREENSCORE_OVERALLSCORE"; for (int i = 0; i < CGame.NumRounds; i++) { SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayers); for (int p = 0; p < players.Length; p++) { if (i < 1) { players[p].ProfileID = points[p].ProfileID; } players[p].Points += points[p].Points; } } for (int p = 0; p < players.Length; p++) { players[p].Points = (int)Math.Round(players[p].Points / CGame.NumRounds); } } for (int p = 0; p < players.Length; p++) { string name = CProfiles.GetPlayerName(players[p].ProfileID, p); if (song != null && song.IsDuet) { if (song.Notes.VoiceNames.IsSet(players[p].VoiceNr)) { name += " (" + song.Notes.VoiceNames[players[p].VoiceNr] + ")"; } } _Texts[_TextNames[p, CGame.NumPlayers - 1]].Text = name; if (CGame.NumPlayers < (int)_ScreenSettings[_ScreenSettingShortScore].GetValue()) { _Texts[_TextScores[p, CGame.NumPlayers - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS"); } else { _Texts[_TextScores[p, CGame.NumPlayers - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000"); } if (CGame.NumPlayers < (int)_ScreenSettings[_ScreenSettingShortDifficulty].GetValue()) { _Texts[_TextDifficulty[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " + CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString()); } else { _Texts[_TextDifficulty[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString()); } if (CGame.NumPlayers < (int)_ScreenSettings[_ScreenSettingShortRating].GetValue()) { _Texts[_TextRatings[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " + CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points))); } else { _Texts[_TextRatings[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points))); } _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); } } }
private void _UpdateRatings() { CSong song = null; var players = new SPlayer[CGame.NumPlayers]; if (_Round >= 0) { song = CGame.GetSong(_Round); if (song == null) { return; } _Texts[_TextSong].Text = song.Artist + " - " + song.Title; if (_Points.NumRounds > 1) { _Texts[_TextSong].Text += " (" + (_Round + 1) + "/" + _Points.NumRounds + ")"; } players = _Points.GetPlayer(_Round, CGame.NumPlayers); } else { _Texts[_TextSong].Text = "TR_SCREENSCORE_OVERALLSCORE"; for (int i = 0; i < CGame.NumRounds; i++) { SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayers); for (int p = 0; p < players.Length; p++) { if (i < 1) { players[p].ProfileID = points[p].ProfileID; } players[p].Points += points[p].Points; } } for (int p = 0; p < players.Length; p++) { 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); if (song != null && song.IsDuet) { if (song.Notes.VoiceNames.IsSet(players[p].VoiceNr)) { name += " (" + song.Notes.VoiceNames[players[p].VoiceNr] + ")"; } } _Texts[_TextNames[p, CGame.NumPlayers - 1]].Text = name; if (CGame.NumPlayers < (int)_ScreenSettings[_ScreenSettingShortScore].GetValue()) { _Texts[_TextScores[p, CGame.NumPlayers - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS"); } else { _Texts[_TextScores[p, CGame.NumPlayers - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000"); } if (CGame.NumPlayers < (int)_ScreenSettings[_ScreenSettingShortDifficulty].GetValue()) { _Texts[_TextDifficulty[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " + CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString()); } else { _Texts[_TextDifficulty[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString()); } if (CGame.NumPlayers < (int)_ScreenSettings[_ScreenSettingShortRating].GetValue()) { _Texts[_TextRatings[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " + CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points))); } 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; } 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(); }