Fixed genre sort, updated app layout
Song list now gets sorted dynamically. Sorting still leaves to be desired and will require more attention. Made the app window bigger.
This commit is contained in:
parent
12b4d4102f
commit
b81dde230e
@ -11,6 +11,7 @@ using System.Linq;
|
||||
using System;
|
||||
using TaikoSoundEditor.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Runtime.Remoting.Metadata.W3cXsd2001;
|
||||
|
||||
namespace TaikoSoundEditor.Commons.Controls
|
||||
{
|
||||
@ -32,32 +33,21 @@ namespace TaikoSoundEditor.Commons.Controls
|
||||
public void AddSong(IMusicOrder mo)
|
||||
{
|
||||
var songCard = new SongCard(WordList, mo);
|
||||
|
||||
if (Config.MusicOrderSort == Config.MusicOrderSortValueNone)
|
||||
{
|
||||
SongCards.Add(songCard);
|
||||
}
|
||||
else if (Config.MusicOrderSort == Config.MusicOrderSortValueId)
|
||||
{
|
||||
SongCards.Add(songCard);
|
||||
SongCards.Sort((c1, c2) => c1.MusicOrder.UniqueId.CompareTo(c2.MusicOrder.UniqueId));
|
||||
}
|
||||
else if (Config.MusicOrderSort == Config.MusicOrderSortValueGenre)
|
||||
{
|
||||
var firstInGenre = SongCards.Find(c => c.MusicOrder.Genre == mo.Genre);
|
||||
if (firstInGenre == null)
|
||||
{
|
||||
SongCards.Add(songCard);
|
||||
}
|
||||
else
|
||||
{
|
||||
var index = SongCards.IndexOf(firstInGenre);
|
||||
SongCards.Insert(index, songCard);
|
||||
}
|
||||
}
|
||||
SongCards.Add(songCard);
|
||||
CurrentPage = CurrentPage;
|
||||
}
|
||||
|
||||
public void SortSongs()
|
||||
{
|
||||
if (Config.MusicOrderSort == Config.MusicOrderSortValueId) SongCards.Sort((c1, c2) => c1.MusicOrder.UniqueId.CompareTo(c2.MusicOrder.UniqueId));
|
||||
else if (Config.MusicOrderSort == Config.MusicOrderSortValueTitle) SongCards.Sort((c1, c2) => c1.Title.CompareTo(c2.Title));
|
||||
else if (Config.MusicOrderSort == Config.MusicOrderSortValueGenre) SongCards.Sort((c1, c2) => {
|
||||
var ret = c1.Genre.CompareTo(c2.Genre);
|
||||
if (ret == 0) ret = c1.Title.CompareTo(c2.Title);
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
public void RemoveAllSongs(int uniqueId)
|
||||
{
|
||||
SongCards.RemoveAll(c => c.MusicOrder.UniqueId == uniqueId);
|
||||
@ -130,7 +120,7 @@ namespace TaikoSoundEditor.Commons.Controls
|
||||
private static int ItemsPadding = 3;
|
||||
|
||||
public void RefreshMusicOrdersPanel(Graphics g)
|
||||
{
|
||||
{
|
||||
var cards = SongCards.Skip(CurrentPage * ItemsPerPage).Take(ItemsPerPage).ToArray();
|
||||
|
||||
int itemW = MusicOrdersPanel.Width / ItemsPerRow - 2 * ItemsPadding;
|
||||
@ -195,6 +185,8 @@ namespace TaikoSoundEditor.Commons.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public void MusicOrdersPanel_Update() => MusicOrdersPanel.Invalidate();
|
||||
|
||||
private void MusicOrdersPanel_Resize(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||
{
|
||||
MusicOrdersPanel.Invalidate();
|
||||
@ -578,6 +570,7 @@ namespace TaikoSoundEditor.Commons.Controls
|
||||
var newMO = DatatableTypes.Clone(CardToClone.MusicOrder);
|
||||
newMO.Genre = genre;
|
||||
AddSong(newMO);
|
||||
SortSongs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
private static IniFile CreateIniFile()
|
||||
{
|
||||
var ini = new IniFile();
|
||||
if(!ini.KeyExists("MusicOrderSort")) ini.Write(MusicOrderSortProperty, MusicOrderSortValueNone);
|
||||
if(!ini.KeyExists("MusicOrderSort")) ini.Write(MusicOrderSortProperty, MusicOrderSortValueGenre);
|
||||
return ini;
|
||||
}
|
||||
|
||||
@ -14,8 +14,10 @@
|
||||
public static readonly IniFile IniFile = CreateIniFile();
|
||||
|
||||
public static void SetMusicOrderSortById() => IniFile.Write(MusicOrderSortProperty, MusicOrderSortValueId);
|
||||
public static void SetMusicOrderNoSort() => IniFile.Write(MusicOrderSortProperty, MusicOrderSortValueNone);
|
||||
public static void SetMusicOrderSortByGenre() => IniFile.Write(MusicOrderSortProperty, MusicOrderSortValueGenre);
|
||||
public static void SetMusicOrderSortByTitle() => IniFile.Write(MusicOrderSortProperty, MusicOrderSortValueTitle);
|
||||
|
||||
public static void SetMusicOrderNoSort() => IniFile.Write(MusicOrderSortProperty, MusicOrderSortValueNoSort);
|
||||
|
||||
public static string DatatableDefPath
|
||||
{
|
||||
@ -52,8 +54,9 @@
|
||||
public static string MusicOrderSortProperty = "MusicOrderSort";
|
||||
public static string DatatableDefPathProperty = "DatatableDef";
|
||||
|
||||
public static string MusicOrderSortValueNone = "None";
|
||||
public static string MusicOrderSortValueId = "Id";
|
||||
public static string MusicOrderSortValueGenre = "Genre";
|
||||
public static string MusicOrderSortValueGenre = "Genre";
|
||||
public static string MusicOrderSortValueTitle = "Title";
|
||||
public static string MusicOrderSortValueNoSort = "None";
|
||||
}
|
||||
}
|
||||
|
562
MainForm.Designer.cs
generated
562
MainForm.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -174,10 +174,8 @@ namespace TaikoSoundEditor
|
||||
});*/
|
||||
|
||||
MusicOrderViewer.WordList = WordList;
|
||||
foreach (var musicOrder in MusicOrders.Items.Where(_ => MusicInfos.Items.Any(mi => mi.UniqueId == _.UniqueId)))
|
||||
{
|
||||
MusicOrderViewer.AddSong(musicOrder);
|
||||
}
|
||||
foreach (var musicOrder in MusicOrders.Items.Where(_ => MusicInfos.Items.Any(mi => mi.UniqueId == _.UniqueId))) MusicOrderViewer.AddSong(musicOrder);
|
||||
MusicOrderViewer.SortSongs();
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
@ -311,6 +311,7 @@ namespace TaikoSoundEditor
|
||||
MusicAttributes.Items.Add(ns.MusicAttribute);
|
||||
|
||||
MusicOrderViewer.AddSong(mo);
|
||||
MusicOrderViewer.SortSongs();
|
||||
});
|
||||
|
||||
|
||||
|
57
MainForm.cs
57
MainForm.cs
@ -21,18 +21,6 @@ namespace TaikoSoundEditor
|
||||
WordListPathSelector.PathChanged += WordListPathSelector_PathChanged;
|
||||
DirSelector.PathChanged += DirSelector_PathChanged;
|
||||
|
||||
UseEncryptionBox.Checked = Config.UseEncryption;
|
||||
UseEncryptionBox_CheckedChanged(null, null); // update state of the key two text boxes
|
||||
|
||||
//If path is set for the datatable folder, update paths for all the files.
|
||||
if (Config.DatatablesPath != "") DirSelector.Path = Config.DatatablesPath;
|
||||
|
||||
|
||||
DatatableKeyBox.Text = Config.DatatableKey;
|
||||
FumenKeyBox.Text = Config.FumenKey;
|
||||
|
||||
DatatableDef.Path = Config.DatatableDefPath;
|
||||
|
||||
//Other stuff
|
||||
AddedMusicBinding.DataSource = AddedMusic;
|
||||
NewSoundsBox.DataSource = AddedMusicBinding;
|
||||
@ -125,7 +113,7 @@ namespace TaikoSoundEditor
|
||||
Logger.Info($"Selection Changed MusicItem: {item}");
|
||||
LoadMusicInfo(item);
|
||||
indexChanging = false;
|
||||
SoundViewTab.SelectedTab = SoundViewerSimple;
|
||||
if (SoundViewTab.SelectedTab == MusicOrderTab) SoundViewTab.SelectedTab = SoundViewerSimple;
|
||||
});
|
||||
|
||||
private void EditorTable_Resize(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||
@ -140,7 +128,7 @@ namespace TaikoSoundEditor
|
||||
LoadedMusicBox.SelectedItem = null;
|
||||
var item = NewSoundsBox.SelectedItem as NewSongData;
|
||||
LoadNewSongData(item);
|
||||
SoundViewTab.SelectedTab = SoundViewerSimple;
|
||||
if(SoundViewTab.SelectedTab == MusicOrderTab) SoundViewTab.SelectedTab = SoundViewerSimple;
|
||||
});
|
||||
|
||||
#endregion
|
||||
@ -373,7 +361,7 @@ namespace TaikoSoundEditor
|
||||
|
||||
private void MusicOrderSortToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SortByGenreToolStripMenuItem.Checked = SortByIdToolStripMenuItem.Checked = NoSortToolStripMenuItem.Checked = false;
|
||||
SortByGenreToolStripMenuItem.Checked = SortByIdToolStripMenuItem.Checked = sortByTitleToolStripMenuItem.Checked = noSortToolStripMenuItem.Checked = false;
|
||||
|
||||
if (sender == SortByGenreToolStripMenuItem)
|
||||
{
|
||||
@ -385,28 +373,39 @@ namespace TaikoSoundEditor
|
||||
SortByIdToolStripMenuItem.Checked = true;
|
||||
Config.SetMusicOrderSortById();
|
||||
}
|
||||
else //if (sender == NoSortToolStripMenuItem)
|
||||
else if (sender == sortByTitleToolStripMenuItem)
|
||||
{
|
||||
NoSortToolStripMenuItem.Checked = true;
|
||||
sortByTitleToolStripMenuItem.Checked = true;
|
||||
Config.SetMusicOrderSortByTitle();
|
||||
}
|
||||
else //(sender == noSortToolStripMenuItem)
|
||||
{
|
||||
noSortToolStripMenuItem.Checked = true;
|
||||
Config.SetMusicOrderNoSort();
|
||||
}
|
||||
|
||||
MusicOrderViewer.SortSongs();
|
||||
MusicOrderViewer.MusicOrdersPanel_Update();
|
||||
}
|
||||
|
||||
private void LoadPreferences()
|
||||
{
|
||||
UseEncryptionBox.Checked = Config.UseEncryption;
|
||||
UseEncryptionBox_CheckedChanged(null, null); // update state of the key two text boxes
|
||||
|
||||
//If path is set for the datatable folder, update paths for all the files.
|
||||
if (Config.DatatablesPath != "") DirSelector.Path = Config.DatatablesPath;
|
||||
|
||||
|
||||
DatatableKeyBox.Text = Config.DatatableKey;
|
||||
FumenKeyBox.Text = Config.FumenKey;
|
||||
|
||||
DatatableDef.Path = Config.DatatableDefPath;
|
||||
|
||||
var musicOrderSort = Config.IniFile.Read(Config.MusicOrderSortProperty);
|
||||
if (musicOrderSort == Config.MusicOrderSortValueGenre)
|
||||
{
|
||||
SortByGenreToolStripMenuItem.PerformClick();
|
||||
}
|
||||
else if (musicOrderSort == Config.MusicOrderSortValueId)
|
||||
{
|
||||
SortByIdToolStripMenuItem.PerformClick();
|
||||
}
|
||||
else
|
||||
{
|
||||
NoSortToolStripMenuItem.PerformClick();
|
||||
}
|
||||
if (musicOrderSort == Config.MusicOrderSortValueGenre) SortByGenreToolStripMenuItem.PerformClick();
|
||||
else if (musicOrderSort == Config.MusicOrderSortValueId) SortByIdToolStripMenuItem.PerformClick();
|
||||
else if (musicOrderSort == Config.MusicOrderSortValueTitle) sortByTitleToolStripMenuItem.PerformClick();
|
||||
}
|
||||
|
||||
private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||
|
Loading…
Reference in New Issue
Block a user