From 33cadb8b356f6f6e464c68217df09fed189e0bae Mon Sep 17 00:00:00 2001 From: Edi316 <61267443+Edi316@users.noreply.github.com> Date: Sat, 3 May 2025 09:44:12 +0200 Subject: [PATCH] Add Song Folder in Game Options (#776) * Screen Version 5 * Add Song Folder Button * Add Song Folder Button * Add Song Folder Button * Add Song Folder Button * Add Song Folder Button * Add Song Folder Button --- Output/Languages/en.xml | 2 + .../Changelog/Changelog_ScreenOptionsGame.txt | 7 ++- .../Screens/ScreenOptionsGame.xml | 62 ++++++++++++++++++- Vocaluxe/Screens/CScreenOptionsGame.cs | 55 ++++++++++++++-- 4 files changed, 120 insertions(+), 6 deletions(-) diff --git a/Output/Languages/en.xml b/Output/Languages/en.xml index 6b7dec47..e7867944 100644 --- a/Output/Languages/en.xml +++ b/Output/Languages/en.xml @@ -211,6 +211,7 @@ Credits Please restart the game for the changes to take effect. Server address + Add Song Folder Game Options Language Debug level @@ -221,6 +222,7 @@ Game difficulty Timer mode Highscore style + Select the song folder you want to add Record Options Device Input diff --git a/Output/Themes/Changelog/Changelog_ScreenOptionsGame.txt b/Output/Themes/Changelog/Changelog_ScreenOptionsGame.txt index 2aed5985..548df260 100644 --- a/Output/Themes/Changelog/Changelog_ScreenOptionsGame.txt +++ b/Output/Themes/Changelog/Changelog_ScreenOptionsGame.txt @@ -1,5 +1,10 @@ ScreenOptionsGame +++++++++++ +Version 5: + +Add: + ++++++++++ Version 4: @@ -16,4 +21,4 @@ Version 2: Add: -++++++++++ \ No newline at end of file +++++++++++ diff --git a/Output/Themes/Vocaluxe 2024/Screens/ScreenOptionsGame.xml b/Output/Themes/Vocaluxe 2024/Screens/ScreenOptionsGame.xml index 4589e871..0085c72b 100644 --- a/Output/Themes/Vocaluxe 2024/Screens/ScreenOptionsGame.xml +++ b/Output/Themes/Vocaluxe 2024/Screens/ScreenOptionsGame.xml @@ -2,7 +2,7 @@ ScreenOptionsGame - 4 + 5 @@ -25,6 +25,17 @@ 1 + + Warning + + + 325 + 900 + 1000 + 75 + -1 + + @@ -153,6 +164,20 @@ Outline TR_SCREENOGAME_HIGHSCORESTYLE + + 825 + 920 + -1.1 + 37.5 + 845 + + + Center + Center + + Outline + TR_SCREENO_WARNINGRESTART + + diff --git a/Vocaluxe/Screens/CScreenOptionsGame.cs b/Vocaluxe/Screens/CScreenOptionsGame.cs index 669be7ae..a7b5132c 100644 --- a/Vocaluxe/Screens/CScreenOptionsGame.cs +++ b/Vocaluxe/Screens/CScreenOptionsGame.cs @@ -1,4 +1,4 @@ -#region license +#region license // This file is part of Vocaluxe. // // Vocaluxe is free software: you can redistribute it and/or modify @@ -16,6 +16,8 @@ #endregion using System.Windows.Forms; +using System.Linq; +using System.Collections.Generic; using Vocaluxe.Base; using VocaluxeLib; using VocaluxeLib.Menu; @@ -27,7 +29,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 4; } + get { return 5; } } private const string _SelectSlideLanguage = "SelectSlideLanguage"; @@ -41,13 +43,19 @@ namespace Vocaluxe.Screens private const string _ButtonExit = "ButtonExit"; private const string _ButtonServer = "ButtonServer"; + private const string _ButtonSelectSongFolder = "ButtonSongFolder"; + + private const string _TextWarningRestart = "TextWarningRestart"; + private const string _StaticWarningRestart = "StaticWarningRestart"; public override void Init() { base.Init(); - _ThemeButtons = new string[] {_ButtonExit, _ButtonServer}; + _ThemeButtons = new string[] {_ButtonExit, _ButtonServer, _ButtonSelectSongFolder}; _ThemeSelectSlides = new string[] {_SelectSlideLanguage, _SelectSlideDebugLevel, _SelectSlideSongMenu, _SelectSlideSongSorting, _SelectSlideTabs, _SelectSlideTimerMode, _SelectSlideHighscoreStyle}; + _ThemeTexts = new string[] {_TextWarningRestart}; + _ThemeStatics = new string[] {_StaticWarningRestart}; } public override void LoadTheme(string xmlPath) @@ -64,6 +72,9 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlideAutoplayPreviews].SetValues((int)CConfig.Config.Game.AutoplayPreviews); _SelectSlides[_SelectSlideTimerMode].SetValues((int)CConfig.Config.Game.TimerMode); _SelectSlides[_SelectSlideHighscoreStyle].SetValues((int)CConfig.Config.Game.HighscoreStyle); + + _Texts[_TextWarningRestart].Visible = false; + _Statics[_StaticWarningRestart].Visible = false; } public override bool HandleInput(SKeyEvent keyEvent) @@ -93,7 +104,14 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreen.Options); } else if (_Buttons[_ButtonServer].Selected) + { CGraphics.ShowPopup(EPopupScreens.PopupServerQR); + } + else if (_Buttons[_ButtonSelectSongFolder].Selected && CScreenOptionsGame._OpenSongFolderDialog()) + { + _Texts[_TextWarningRestart].Visible = true; + _Statics[_StaticWarningRestart].Visible = true; + } break; case Keys.Left: @@ -126,7 +144,14 @@ namespace Vocaluxe.Screens _SaveConfig(); } else if (_Buttons[_ButtonServer].Selected) + { CGraphics.ShowPopup(EPopupScreens.PopupServerQR); + } + else if (_Buttons[_ButtonSelectSongFolder].Selected && CScreenOptionsGame._OpenSongFolderDialog()) + { + _Texts[_TextWarningRestart].Visible = true; + _Statics[_StaticWarningRestart].Visible = true; + } } return true; } @@ -136,6 +161,28 @@ namespace Vocaluxe.Screens return true; } + private static bool _OpenSongFolderDialog() + { + using (var dialog = new FolderBrowserDialog()) + { + dialog.Description = CLanguage.Translate("TR_SCREENOGAME_SONGFOLDER"); + dialog.ShowNewFolderButton = true; + if (dialog.ShowDialog() == DialogResult.OK) + { + // Update config with new folder + var folders = CConfig.Config.Game.SongFolder?.ToList() ?? new List(); + if (!folders.Contains(dialog.SelectedPath)) + { + folders.Add(dialog.SelectedPath); + CConfig.Config.Game.SongFolder = folders.ToArray(); + CConfig.SaveConfig(); + } + return true; // Folder was selected + } + } + return false; // Dialog was cancelled + } + private void _SaveConfig() { CLanguage.LanguageId = _SelectSlides[_SelectSlideLanguage].Selection; @@ -154,4 +201,4 @@ namespace Vocaluxe.Screens CSongs.Categorizer.Tabs = CConfig.Config.Game.Tabs; } } -} \ No newline at end of file +}