private void AfterCategoryChange() { SetSelectedNow(); SelectSong(_PreviewSelected); foreach (CStatic tile in _Tiles) { tile.Selected = false; } if (_actualSelection >= 0 && _actualSelection < _Tiles.Count) { _Tiles[_actualSelection].Selected = true; } if ((_LastKnownNumSongs == CSongs.NumVisibleSongs) && (_LastKnownCategory == CSongs.Category)) { return; } _LastKnownCategory = CSongs.Category; _LastKnownNumSongs = CSongs.NumVisibleSongs; UpdateList(0); CSongs.UpdateRandomSongList(); }
public virtual CSong GetSong() { if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) { CSong song = CSongs.GetSong(_SongQueque[_CurrentSong].SongID); song = new CSong(song); switch (GetCurrentGameMode()) { case EGameMode.TR_GAMEMODE_MEDLEY: // set medley mode timings song.Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap; if (song.Start < 0f) { song.Start = 0f; } song.Finish = CGame.GetTimeFromBeats(song.Medley.EndBeat, song.BPM) + song.Medley.FadeOutTime + song.Gap; // set lines to medley mode song.Notes.SetMedley(song.Medley.StartBeat, song.Medley.EndBeat); break; case EGameMode.TR_GAMEMODE_SHORTSONG: song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap; // set lines to medley mode song.Notes.SetMedley(song.Notes.GetLines(0).Line[0].FirstNoteBeat, song.ShortEnd); break; } return(song); } return(null); }
public override bool HandleMouse(MouseEvent MouseEvent) { base.HandleMouse(MouseEvent); if ((MouseEvent.RB) && (CSongs.Category < 0)) { CGraphics.FadeTo(EScreens.ScreenMain); } if (MouseEvent.MB && CSongs.Category != -1) { Console.WriteLine("MB pressed"); SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); } else { SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent); } if (MouseEvent.LB && CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) { StartSong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); } return(true); }
public static bool UpdateGameLogic(CKeys Keys, CMouse Mouse) { bool _Run = true; _Cursor.CursorVisible = Mouse.Visible; Mouse.CopyEvents(); Keys.CopyEvents(); CSound.Update(); CBackgroundMusic.Update(); CInput.Update(); if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC && _CurrentScreen != EScreens.ScreenSing) { CSongs.LoadCover(30L, 1); } if (CSettings.GameState != EGameState.EditTheme) { _Run &= HandleInputs(Keys, Mouse); _Run &= Update(); } else { _Run &= HandleInputThemeEditor(Keys, Mouse); _Run &= Update(); } return(_Run); }
public virtual CSong GetSong() { if (_ActualSong >= 0 && _ActualSong < _SongIDs.Count) { return(CSongs.GetSong(_SongIDs[_ActualSong])); } return(null); }
public virtual CSong GetSong(int Num) { if (Num - 1 < _SongIDs.Count) { return(CSongs.GetSong(_SongIDs[Num - 1])); } return(null); }
public virtual CSong GetSong(int Num) { if (Num - 1 < _SongQueque.Count && Num - 1 > -1) { return(CSongs.GetSong(_SongQueque[Num - 1].SongID)); } return(null); }
private bool _AddSong(int songID, EGameMode gameMode) { if (!CSongs.GetSong(songID).IsGameModeAvailable(gameMode)) { return(false); } _SongQueue.Add(new SSongQueueEntry(songID, gameMode)); return(true); }
public CSong GetSong(int songID) { if (songID != _LastSongID) { CSong song = CSongs.GetSong(songID); _LastSong = _PrepareSong(song); _LastSongID = songID; } return(_LastSong); }
public void AddSong(int songID) { var song = new CPlaylistSong { SongID = songID, GameMode = CSongs.GetSong(songID).IsGameModeAvailable(EGameMode.TR_GAMEMODE_DUET) ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL }; Songs.Add(song); }
private void PrevCategory() { if (CSongs.Category > -1) { Reset(); CSongs.PrevCategory(); EnterCategory(CSongs.Category); _Locked = 0; } }
private int _GetDataBaseSongID(int songID, SQLiteCommand command) { CSong song = CSongs.GetSong(songID); if (song == null) { return(-1); } return(_GetDataBaseSongID(song.Artist, song.Title, 0, command)); }
public override bool UpdateGame() { SongMenus[htSongMenus(SongMenu)].Update(); if (SongMenus[htSongMenus(SongMenu)].IsSmallView()) { CheckPlaylist(); } Texts[htTexts(TextCategory)].Text = CSongs.GetActualCategoryName(); if (CSongs.Category > -1 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) { CBackgroundMusic.Disabled = true; } else { CBackgroundMusic.Disabled = false; } int song = SongMenus[htSongMenus(SongMenu)].GetActualSelection(); if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Length) { Texts[htTexts(TextSelection)].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title; } else if (CSongs.Category == -1 && song >= 0 && song < CSongs.Categories.Length) { Texts[htTexts(TextSelection)].Text = CSongs.Categories[song].Name; } else { Texts[htTexts(TextSelection)].Text = String.Empty; } Texts[htTexts(TextSearchBar)].Text = _SearchText; if (_SearchActive) { Texts[htTexts(TextSearchBar)].Text += '|'; Texts[htTexts(TextSearchBar)].Visible = true; Texts[htTexts(TextSearchBarTitle)].Visible = true; Statics[htStatics(StaticSearchBar)].Visible = true; } else { Texts[htTexts(TextSearchBar)].Visible = false; Texts[htTexts(TextSearchBarTitle)].Visible = false; Statics[htStatics(StaticSearchBar)].Visible = false; } return(true); }
private void _UpdateRound() { _IsDuet = false; CPoints points = CGame.GetPoints(); CSong song; if (_FromScreenSong) { song = CSongs.GetSong(CScreenSong.getSelectedSongID()); } else { song = CGame.GetSong(_Round); } if (song == null) { return; } _Texts[_TextSongName].Text = song.Artist + " - " + song.Title; if (points != null && !_FromScreenSong && points.NumRounds > 1) { _Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")"; } switch ((_FromScreenSong ? (EGameMode)_Round : CGame.GetGameMode(_Round))) { case EGameMode.TR_GAMEMODE_NORMAL: _Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL"; break; case EGameMode.TR_GAMEMODE_MEDLEY: _Texts[_TextSongMode].Text = "TR_GAMEMODE_MEDLEY"; break; case EGameMode.TR_GAMEMODE_DUET: _Texts[_TextSongMode].Text = "TR_GAMEMODE_DUET"; _IsDuet = true; break; case EGameMode.TR_GAMEMODE_SHORTSONG: _Texts[_TextSongMode].Text = "TR_GAMEMODE_SHORTSONG"; break; default: _Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL"; break; } _Pos = 0; }
private static SPlaylistSongInfo _GetPlaylistSongInfo(CPlaylistSong playlistSong, int playlistId, int playlistPos) { SPlaylistSongInfo result = new SPlaylistSongInfo(); if (playlistSong != null) { result.PlaylistId = playlistId; result.GameMode = (int)playlistSong.GameMode; result.PlaylistPosition = playlistPos; result.Song = _GetSongInfo(CSongs.GetSong(playlistSong.SongID), true); } return(result); }
/// <summary> /// Get song of specified round /// </summary> /// <param name="round">Round (0 based)</param> /// <returns>Current song or null if out of bounds</returns> public CSong GetSong(int round) { if (round == _CurrentRound) { return(_CurrentSong); } if (round < _SongQueue.Count && round >= 0) { return(CSongs.GetSong(_SongQueue[round].SongID)); } return(null); }
public virtual bool AddSong(int AbsoluteIndex, EGameMode GameMode) { if (CSongs.AllSongs.Length > AbsoluteIndex) { int SongID = CSongs.AllSongs[AbsoluteIndex].ID; if (GameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(SongID).IsDuet) { return(false); } _SongQueque.Add(new SongQueque(SongID, GameMode)); return(true); } return(false); }
public void AddSong(int SongID) { CPlaylistSong song = new CPlaylistSong(); song.SongID = SongID; if (CSongs.GetSong(SongID).IsDuet) { song.GameMode = EGameMode.TR_GAMEMODE_DUET; } else { song.GameMode = EGameMode.TR_GAMEMODE_NORMAL; } Songs.Add(song); }
public override void OnShow() { if (CSongs.Tabs == EOffOn.TR_CONFIG_OFF && CSongs.NumCategories > 0 && CSongs.Category == -1) { EnterCategory(0); } _actualSelection = -1; _Locked = -1; _PreviewSelected = -1; UpdateList(0); //AfterCategoryChange(); SetSelectedSong(_ActSong); AfterCategoryChange(); CSongs.UpdateRandomSongList(); int actcat = _PreviewSelected; if ((CSongs.NumCategories > 0) && (actcat < 0)) { _CoverBig.Texture = CSongs.Categories[0].CoverTextureSmall; _Artist.Text = CSongs.Categories[0].Name; _Title.Text = String.Empty; _SongLength.Text = String.Empty; _PreviewSelected = 0; _Locked = 0; _DuetIcon.Visible = false; _VideoIcon.Visible = false; _MedleyCalcIcon.Visible = false; _MedleyTagIcon.Visible = false; } if (CSongs.NumVisibleSongs == 0 && CSongs.SearchFilter != String.Empty) { _CoverBig.Texture = _CoverBigTexture; _Artist.Text = String.Empty; _Title.Text = String.Empty; _SongLength.Text = String.Empty; _PreviewSelected = -1; _Locked = -1; _DuetIcon.Visible = false; _VideoIcon.Visible = false; _MedleyCalcIcon.Visible = false; _MedleyTagIcon.Visible = false; } }
private void LoadScores() { CPoints points = CGame.GetPoints(); if (points == null) { return; } _Pos = 0; for (int round = 0; round < points.NumRounds; round++) { SPlayer player = points.GetPlayer(round, CGame.NumPlayer)[0]; CDataBase.LoadScore(ref _Scores, player); if (round == _Round) { _IsDuet = false; CSong song = CSongs.GetSong(player.SongID); Texts[htTexts(TextSongName)].Text = song.Artist + " - " + song.Title; switch (CGame.GameMode) { case EGameMode.Normal: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; case EGameMode.Medley: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_MEDLEY"; break; case EGameMode.Duet: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_DUET"; _IsDuet = true; break; default: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; } } } }
private void _SavePlayedSongs() { for (int round = 0; round < _Points.NumRounds; round++) { SPlayer[] players = _Points.GetPlayer(round, CGame.NumPlayers); for (int p = 0; p < players.Length; p++) { if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished) { CSong song = CSongs.GetSong(players[p].SongID); CDataBase.IncreaseSongCounter(song.DataBaseSongID); song.NumPlayed++; song.NumPlayedSession++; break; } } } }
private void SaveConfig() { CConfig.Language = _Languages[SelectSlides[htSelectSlides(SelectSlideLanguage)].Selection]; CConfig.DebugLevel = (EDebugLevel)SelectSlides[htSelectSlides(SelectSlideDebugLevel)].Selection; CConfig.SongMenu = (ESongMenu)SelectSlides[htSelectSlides(SelectSlideSongMenu)].Selection; CConfig.SongSorting = (ESongSorting)SelectSlides[htSelectSlides(SelectSlideSongSorting)].Selection; CConfig.Tabs = (EOffOn)SelectSlides[htSelectSlides(SelectSlideTabs)].Selection; CConfig.TimerMode = (ETimerMode)SelectSlides[htSelectSlides(SelectSlideTimerMode)].Selection; CConfig.SaveConfig(); if (_SongSortingOld != CConfig.SongSorting || _TabsOld != CConfig.Tabs || _LanguageOld != CConfig.Language) { CSongs.Sort(CConfig.SongSorting); CSongs.Category = -1; } CLanguage.SetLanguage(CConfig.Language); }
public int AddScore(SPlayer player) { using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _FilePath; try { connection.Open(); } catch (Exception) { return(-1); } int medley = 0; int duet = 0; int shortSong = 0; switch (player.GameMode) { case EGameMode.TR_GAMEMODE_MEDLEY: medley = 1; break; case EGameMode.TR_GAMEMODE_DUET: duet = 1; break; case EGameMode.TR_GAMEMODE_SHORTSONG: shortSong = 1; break; } using (var command = new SQLiteCommand(connection)) { int dataBaseSongID = CSongs.GetSong(player.SongID).DataBaseSongID; return(_AddScore(CProfiles.GetPlayerName(player.ProfileID), (int)Math.Round(player.Points), player.VoiceNr, player.DateTicks, medley, duet, shortSong, (int)CProfiles.GetDifficulty(player.ProfileID), dataBaseSongID, command)); } } }
private void SaveConfig() { CConfig.Theme = CTheme.ThemeNames[SelectSlides[htSelectSlides(SelectSlideTheme)].Selection]; CConfig.Skin = CTheme.SkinNames[SelectSlides[htSelectSlides(SelectSlideSkin)].Selection]; CConfig.CoverTheme = CCover.CoverThemes[SelectSlides[htSelectSlides(SelectSlideCover)].Selection]; CConfig.DrawNoteLines = (EOffOn)SelectSlides[htSelectSlides(SelectSlideNoteLines)].Selection; CConfig.DrawToneHelper = (EOffOn)SelectSlides[htSelectSlides(SelectSlideToneHelper)].Selection; CConfig.TimerLook = (ETimerLook)SelectSlides[htSelectSlides(SelectSlideTimerLook)].Selection; CConfig.FadePlayerInfo = (EFadePlayerInfo)SelectSlides[htSelectSlides(SelectSlideFadeInfo)].Selection; CConfig.CoverLoading = (ECoverLoading)SelectSlides[htSelectSlides(SelectSlideCoverLoading)].Selection; CConfig.SaveConfig(); if (_OldCoverTheme != SelectSlides[htSelectSlides(SelectSlideCover)].Selection) { CCover.ReloadCover(); CSongs.Sort(CConfig.SongSorting); } if (_OldTheme != SelectSlides[htSelectSlides(SelectSlideTheme)].Selection) { CConfig.Theme = CTheme.ThemeNames[SelectSlides[htSelectSlides(SelectSlideTheme)].Selection]; _OldTheme = SelectSlides[htSelectSlides(SelectSlideTheme)].Selection; CTheme.UnloadSkins(); CFonts.UnloadThemeFonts(CConfig.Theme); CTheme.ListSkins(); CConfig.Skin = CTheme.SkinNames[0]; _OldSkin = 0; _TempSkin = _OldSkin; CConfig.SaveConfig(); CTheme.LoadSkins(); CTheme.LoadTheme(); CGraphics.ReloadTheme(); return; } }
public static string GetMp3Path(int songId) { CSong song = CSongs.GetSong(songId); return(song.GetMP3()); }
public override bool HandleInput(KeyEvent KeyEvent) { base.HandleInput(KeyEvent); if (KeyEvent.Handled) { return(true); } if (_PlaylistActive) { if (!KeyEvent.KeyPressed && KeyEvent.Key == Keys.Tab) { _PlaylistActive = !_PlaylistActive; Playlists[htPlaylists(Playlist)].Selected = _PlaylistActive; SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive); return(true); } Playlists[htPlaylists(Playlist)].HandleInput(KeyEvent); if (CPlaylists.NumPlaylists != SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistOpen)].NumValues) { UpdatePlaylistNames(); } return(true); } if (!_SongOptionsActive) { if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) { if (_SearchActive) { ApplyNewSearchFilter(_SearchText + KeyEvent.Unicode); } /* * else if (!Char.IsControl(KeyEvent.Unicode)) * { * JumpTo(KeyEvent.Unicode); * return true; * } */ } else { SongMenus[htSongMenus(SongMenu)].HandleInput(ref KeyEvent); if (KeyEvent.Handled) { return(true); } switch (KeyEvent.Key) { case Keys.Escape: if (CSongs.Category < 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) { CGraphics.FadeTo(EScreens.ScreenMain); } break; case Keys.Enter: if (CSongs.NumVisibleSongs > 0) { if (SongMenus[htSongMenus(SongMenu)].GetSelectedSong() != -1 && !_SongOptionsActive) { ToggleSongOptions(ESongOptionsView.Song); } } break; case Keys.Tab: if (Playlists[htPlaylists(Playlist)].Visible) { _PlaylistActive = !_PlaylistActive; Playlists[htPlaylists(Playlist)].Selected = _PlaylistActive; SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive); } break; case Keys.Back: if (_SearchText.Length > 0) { ApplyNewSearchFilter(_SearchText.Remove(_SearchText.Length - 1)); } if (!_SearchActive && CSongs.Category < 0) { CGraphics.FadeTo(EScreens.ScreenMain); } break; case Keys.Space: if (!_SearchActive) { ToggleSongOptions(ESongOptionsView.General); } break; case Keys.F3: if (_SearchActive) { _SearchActive = false; _SearchText = String.Empty; ApplyNewSearchFilter(_SearchText); } else { _SearchActive = true; } break; //TODO: Delete it! ??? Shouldn't we keep this as shortcut? case Keys.A: if (!_SearchActive && KeyEvent.Mod == EModifier.None) { StartRandomAllSongs(); } if (KeyEvent.Mod == EModifier.Ctrl) { StartRandomVisibleSongs(); } break; //TODO: Delete that from here and from wiki! case Keys.F: if (KeyEvent.Mod == EModifier.Ctrl) { if (_SearchActive) { _SearchActive = false; _SearchText = String.Empty; ApplyNewSearchFilter(_SearchText); } else { _SearchActive = true; } } break; //TODO: We need another key for random! case Keys.R: if (!_SearchActive && CSongs.Category != -1 && KeyEvent.Mod == EModifier.Ctrl) { SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); } else if (CSongs.Category == -1 && KeyEvent.Mod == EModifier.Ctrl) { SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory()); } break; //TODO: Delete that! case Keys.S: if (!_SearchActive && CSongs.NumVisibleSongs > 0) { StartMedleySong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); } break; } } } else { switch (KeyEvent.Key) { case Keys.Enter: if (Buttons[htButtons(ButtonOptionsClose)].Selected) { ToggleSongOptions(ESongOptionsView.None); } else if (Buttons[htButtons(ButtonOptionsSing)].Selected) { ToggleSongOptions(ESongOptionsView.None); StartSong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); } else if (Buttons[htButtons(ButtonOptionsPlaylist)].Selected) { ToggleSongOptions(ESongOptionsView.None); OpenAndAddPlaylistAction(); } else if (Buttons[htButtons(ButtonOptionsRandom)].Selected) { if (CSongs.Category != -1) { SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); } } else if (Buttons[htButtons(ButtonOptionsRandom)].Selected) { if (CSongs.Category == -1) { SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory()); } } else if (Buttons[htButtons(ButtonOptionsSingAll)].Selected) { StartRandomAllSongs(); } else if (Buttons[htButtons(ButtonOptionsSingAllVisible)].Selected) { StartRandomVisibleSongs(); } else if (Buttons[htButtons(ButtonOptionsOpenPlaylist)].Selected) { ToggleSongOptions(ESongOptionsView.None); OpenPlaylistAction(); } break; case Keys.Escape: case Keys.Back: case Keys.Space: ToggleSongOptions(ESongOptionsView.None); break; } } if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp)) { CConfig.PreviewMusicVolume = CConfig.PreviewMusicVolume + 5; if (CConfig.PreviewMusicVolume > 100) { CConfig.PreviewMusicVolume = 100; } CConfig.SaveConfig(); ApplyVolume(); } else if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) { CConfig.PreviewMusicVolume = CConfig.PreviewMusicVolume - 5; if (CConfig.PreviewMusicVolume < 0) { CConfig.PreviewMusicVolume = 0; } CConfig.SaveConfig(); ApplyVolume(); } return(true); }
public override bool HandleMouse(MouseEvent MouseEvent) { base.HandleMouse(MouseEvent); if (DragAndDropActive) { DragAndDropCover.Rect.X += MouseEvent.X - OldMousePosX; DragAndDropCover.Rect.Y += MouseEvent.Y - OldMousePosY; } OldMousePosX = MouseEvent.X; OldMousePosY = MouseEvent.Y; if (Playlists[htPlaylists(Playlist)].Visible && Playlists[htPlaylists(Playlist)].IsMouseOver(MouseEvent)) { _PlaylistActive = true; Playlists[htPlaylists(Playlist)].Selected = _PlaylistActive; SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive); ToggleSongOptions(ESongOptionsView.None); } else if (CHelper.IsInBounds(SongMenus[htSongMenus(SongMenu)].Rect, MouseEvent.X, MouseEvent.Y)) { _PlaylistActive = false; Playlists[htPlaylists(Playlist)].Selected = _PlaylistActive; SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive); } if (Playlists[htPlaylists(Playlist)].Visible && _PlaylistActive) { if (Playlists[htPlaylists(Playlist)].HandleMouse(MouseEvent)) { if (CPlaylists.NumPlaylists != SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistOpen)].NumValues) { UpdatePlaylistNames(); } return(true); } } if (MouseEvent.RB) { if (_SongOptionsActive) { ToggleSongOptions(ESongOptionsView.None); return(true); } if (CSongs.Category < 0) { CGraphics.FadeTo(EScreens.ScreenMain); return(true); } } if (MouseEvent.MB) { if (CSongs.Category != -1) { ToggleSongOptions(ESongOptionsView.None); SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); return(true); } if (CSongs.Category == -1) { ToggleSongOptions(ESongOptionsView.None); SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory()); return(true); } } if (MouseEvent.LD) { if (CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) { ToggleSongOptions(ESongOptionsView.None); StartVisibleSong(SongMenus[htSongMenus(SongMenu)].GetActualSelection()); return(true); } } SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent); if (MouseEvent.LB) { if (IsMouseOver(MouseEvent)) { if (Buttons[htButtons(ButtonOpenOptions)].Selected) { ToggleSongOptions(ESongOptionsView.General); return(true); } if (Buttons[htButtons(ButtonOptionsClose)].Selected) { ToggleSongOptions(ESongOptionsView.None); return(true); } if (Buttons[htButtons(ButtonOptionsSing)].Selected) { ToggleSongOptions(ESongOptionsView.None); StartSong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); return(true); } if (Buttons[htButtons(ButtonOptionsPlaylist)].Selected) { ToggleSongOptions(ESongOptionsView.None); OpenAndAddPlaylistAction(); return(true); } if (Buttons[htButtons(ButtonOptionsRandom)].Selected) { if (CSongs.Category != -1) { SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); return(true); } } if (Buttons[htButtons(ButtonOptionsRandomCategory)].Selected) { if (CSongs.Category == -1) { SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory()); return(true); } } if (Buttons[htButtons(ButtonOptionsSingAll)].Selected) { ToggleSongOptions(ESongOptionsView.None); StartRandomAllSongs(); return(true); } if (Buttons[htButtons(ButtonOptionsSingAllVisible)].Selected) { ToggleSongOptions(ESongOptionsView.None); StartRandomVisibleSongs(); return(true); } if (Buttons[htButtons(ButtonOptionsOpenPlaylist)].Selected) { ToggleSongOptions(ESongOptionsView.None); OpenPlaylistAction(); return(true); } } if (CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) { if (SongMenus[htSongMenus(SongMenu)].GetSelectedSong() != -1 && !_SongOptionsActive) { ToggleSongOptions(ESongOptionsView.Song); return(true); } else { ToggleSongOptions(ESongOptionsView.None); return(true); } } } if (MouseEvent.LBH) { if (!DragAndDropActive && Playlists[htPlaylists(Playlist)].Visible && CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) { DragAndDropCover = SongMenus[htSongMenus(SongMenu)].GetSelectedSongCover(); DragAndDropCover.Rect.Z = CSettings.zNear; Playlists[htPlaylists(Playlist)].DragAndDropSongID = CSongs.VisibleSongs[SongMenus[htSongMenus(SongMenu)].GetActualSelection()].ID; DragAndDropActive = true; return(true); } } if (!MouseEvent.LBH && DragAndDropActive) { DragAndDropActive = false; Playlists[htPlaylists(Playlist)].DragAndDropSongID = -1; return(true); } return(true); }
public void SavePlaylist() { if (PlaylistFile == string.Empty) { string filename = string.Empty; foreach (char chr in PlaylistName) { if (char.IsLetter(chr)) { filename += chr.ToString(); } } if (filename == String.Empty) { filename = "1"; } int i = 0; while (File.Exists(Path.Combine(CSettings.sFolderPlaylists, filename + ".xml"))) { i++; if (!File.Exists(Path.Combine(CSettings.sFolderPlaylists, filename + i + ".xml"))) { filename += i; } } PlaylistFile = Path.Combine(CSettings.sFolderPlaylists, filename + ".xml"); } XmlWriter writer; try { writer = XmlWriter.Create(PlaylistFile, _settings); } catch (Exception e) { CLog.LogError("Error creating/opening Playlist File " + PlaylistFile + ": " + e.Message); return; } if (writer == null) { CLog.LogError("Error creating/opening Playlist File " + PlaylistFile); return; } writer.WriteStartDocument(); writer.WriteStartElement("root"); writer.WriteStartElement("Info"); writer.WriteElementString("PlaylistName", PlaylistName); writer.WriteEndElement(); writer.WriteStartElement("Songs"); for (int i = 0; i < Songs.Count; i++) { CSong song = CSongs.GetSong(Songs[i].SongID); if (song != null) { writer.WriteStartElement("Song" + (i + 1).ToString()); writer.WriteElementString("Artist", song.Artist); writer.WriteElementString("Title", song.Title); writer.WriteElementString("GameMode", Enum.GetName(typeof(EGameMode), Songs[i].GameMode)); writer.WriteEndElement(); } else { CLog.LogError("Playlist.SavePlaylist(): Can't find Song. This should never happen!"); } } writer.WriteEndElement(); writer.WriteEndElement(); //end of root writer.WriteEndDocument(); writer.Flush(); writer.Close(); }
public override void Draw() { foreach (CStatic tile in _Tiles) { if (tile.Selected && _Active) { tile.Draw(1.2f, tile.Rect.Z - 0.1f, EAspect.Crop, false); } else { if (tile.Texture.index != _CoverTexture.index) { tile.Draw(1f, tile.Rect.Z, EAspect.Crop, false); } else { tile.Draw(1f, tile.Rect.Z, EAspect.Stretch, false); } } } if (CSongs.Category >= 0) { int actsong = _PreviewSelected; if ((CSongs.NumVisibleSongs > actsong) && (actsong >= 0)) { CSong song = CSongs.VisibleSongs[actsong]; _CoverBig.Texture = song.CoverTextureSmall; _Artist.Text = song.Artist; _Title.Text = song.Title; _DuetIcon.Visible = song.IsDuet; _VideoIcon.Visible = song.VideoFileName.Length > 0; _MedleyCalcIcon.Visible = song.Medley.Source == EMedleySource.Calculated; _MedleyTagIcon.Visible = song.Medley.Source == EMedleySource.Tag; float Time = CSound.GetLength(_SongStream); if (song.Finish != 0) { Time = song.Finish; } Time -= song.Start; int min = (int)Math.Floor(Time / 60f); int sec = (int)(Time - min * 60f); _SongLength.Text = min.ToString("00") + ":" + sec.ToString("00"); } } else { int actcat = _PreviewSelected; if ((CSongs.NumCategories > actcat) && (actcat >= 0)) { _CoverBig.Texture = CSongs.Categories[actcat].CoverTextureSmall; _Artist.Text = CSongs.Categories[actcat].Name; int num = CSongs.NumSongsInCategory(actcat); if (num != 1) { _Title.Text = CLanguage.Translate("TR_SCREENSONG_NUMSONGS").Replace("%v", num.ToString()); } else { _Title.Text = CLanguage.Translate("TR_SCREENSONG_NUMSONG").Replace("%v", num.ToString()); } _SongLength.Text = String.Empty; _DuetIcon.Visible = false; _VideoIcon.Visible = false; _MedleyCalcIcon.Visible = false; _MedleyTagIcon.Visible = false; } } _TextBG.Draw(); _CoverBig.Draw(1f, EAspect.Crop); if (_vidtex.color.A < 1) { _CoverBig.Draw(1f, EAspect.Crop); } if (_vidtex.index != -1 && _Video != -1) { RectangleF bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H); RectangleF rect = new RectangleF(0f, 0f, _vidtex.width, _vidtex.height); CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop); CDraw.DrawTexture(_vidtex, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z), _vidtex.color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); CDraw.DrawTextureReflection(_vidtex, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z), _vidtex.color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); } _Artist.Draw(); _Title.Draw(); _SongLength.Draw(); _DuetIcon.Draw(); _VideoIcon.Draw(); _MedleyCalcIcon.Draw(); _MedleyTagIcon.Draw(); }
public override bool HandleInput(KeyEvent KeyEvent) { base.HandleInput(KeyEvent); if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) { if (_SearchActive) { ApplyNewSearchFilter(_SearchText + KeyEvent.Unicode); } /* * else if (!Char.IsControl(KeyEvent.Unicode)) * { * JumpTo(KeyEvent.Unicode); * return true; * } */ } else { SongMenus[htSongMenus(SongMenu)].HandleInput(ref KeyEvent); if (KeyEvent.Handled) { return(true); } switch (KeyEvent.Key) { case Keys.Escape: if (CSongs.Category < 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) { CGraphics.FadeTo(EScreens.ScreenMain); } break; case Keys.Enter: if (CSongs.NumVisibleSongs > 0) { StartSong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); } break; case Keys.Back: if (_SearchText.Length > 0) { ApplyNewSearchFilter(_SearchText.Remove(_SearchText.Length - 1)); } if (!_SearchActive && CSongs.Category < 0) { CGraphics.FadeTo(EScreens.ScreenMain); } break; case Keys.F3: if (_SearchActive) { _SearchActive = false; _SearchText = String.Empty; ApplyNewSearchFilter(_SearchText); } else { _SearchActive = true; } break; case Keys.A: if (!_SearchActive && KeyEvent.Mod == Modifier.None) { StartRandomAllSongs(); } if (KeyEvent.Mod == Modifier.Ctrl) { StartRandomVisibleSongs(); } break; case Keys.F: if (KeyEvent.Mod == Modifier.Ctrl) { if (_SearchActive) { _SearchActive = false; _SearchText = String.Empty; ApplyNewSearchFilter(_SearchText); } else { _SearchActive = true; } } break; case Keys.R: if (CSongs.Category != -1 && KeyEvent.Mod == Modifier.Ctrl) { SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); } break; } } return(true); }