2023-07-17 10:20:00 +02:00
|
|
|
using TaikoSoundEditor.Data;
|
2023-07-28 18:02:47 +02:00
|
|
|
using TaikoSoundEditor.Utils;
|
2023-07-17 10:20:00 +02:00
|
|
|
|
|
|
|
namespace TaikoSoundEditor
|
|
|
|
{
|
|
|
|
public partial class MainForm : Form
|
|
|
|
{
|
|
|
|
public MainForm()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
MusicAttributePathSelector.PathChanged += MusicAttributePathSelector_PathChanged;
|
|
|
|
MusicOrderPathSelector.PathChanged += MusicOrderPathSelector_PathChanged;
|
|
|
|
MusicInfoPathSelector.PathChanged += MusicInfoPathSelector_PathChanged;
|
|
|
|
WordListPathSelector.PathChanged += WordListPathSelector_PathChanged;
|
|
|
|
DirSelector.PathChanged += DirSelector_PathChanged;
|
2023-07-28 18:29:27 +02:00
|
|
|
|
2023-07-17 10:20:00 +02:00
|
|
|
AddedMusicBinding.DataSource = AddedMusic;
|
|
|
|
NewSoundsBox.DataSource = AddedMusicBinding;
|
2023-07-19 07:10:25 +02:00
|
|
|
TabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;
|
2023-07-28 18:29:27 +02:00
|
|
|
|
|
|
|
SimpleGenreBox.DataSource = Enum.GetValues(typeof(Genre));
|
2023-07-19 07:10:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void TabControl_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
Logger.Info($"Commuted to tab {TabControl.SelectedIndex}");
|
2023-07-28 18:02:47 +02:00
|
|
|
}
|
2023-07-17 10:20:00 +02:00
|
|
|
|
|
|
|
#region Editor
|
|
|
|
|
2023-07-28 18:02:47 +02:00
|
|
|
private void LoadMusicInfo(MusicInfo item)
|
2023-07-19 12:07:56 +02:00
|
|
|
{
|
2023-07-19 07:10:25 +02:00
|
|
|
Logger.Info($"Showing properties for MusicInfo: {item}");
|
2023-07-19 12:07:56 +02:00
|
|
|
|
|
|
|
if(item==null)
|
|
|
|
{
|
|
|
|
MusicInfoGrid.SelectedObject = null;
|
|
|
|
MusicAttributesGrid.SelectedObject = null;
|
|
|
|
MusicOrderGrid.SelectedObject = null;
|
|
|
|
WordsGrid.SelectedObject = null;
|
|
|
|
WordSubGrid.SelectedObject = null;
|
|
|
|
WordDetailGrid.SelectedObject = null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-17 10:20:00 +02:00
|
|
|
MusicInfoGrid.SelectedObject = item;
|
|
|
|
MusicAttributesGrid.SelectedObject = MusicAttributes.GetByUniqueId(item.UniqueId);
|
|
|
|
MusicOrderGrid.SelectedObject = MusicOrders.GetByUniqueId(item.UniqueId);
|
|
|
|
WordsGrid.SelectedObject = WordList.GetBySong(item.Id);
|
|
|
|
WordSubGrid.SelectedObject = WordList.GetBySongSub(item.Id);
|
|
|
|
WordDetailGrid.SelectedObject = WordList.GetBySongDetail(item.Id);
|
2023-07-28 18:29:27 +02:00
|
|
|
|
|
|
|
simpleBoxLoading = true;
|
|
|
|
SimpleIdBox.Text = item.Id;
|
|
|
|
SimpleTitleBox.Text = WordList.GetBySong(item.Id).JapaneseText;
|
|
|
|
SimpleSubtitleBox.Text = WordList.GetBySongSub(item.Id).JapaneseText;
|
|
|
|
SimpleDetailBox.Text = WordList.GetBySongDetail(item.Id).JapaneseText;
|
|
|
|
SimpleGenreBox.SelectedItem = MusicOrders.GetByUniqueId(item.UniqueId).Genre;
|
|
|
|
SimpleStarEasyBox.Value = item.StarEasy;
|
|
|
|
SimpleStarNormalBox.Value = item.StarNormal;
|
|
|
|
SimpleStarHardBox.Value = item.StarHard;
|
|
|
|
SimpleStarManiaBox.Value = item.StarMania;
|
|
|
|
SimpleStarUraBox.Value = item.StarUra;
|
|
|
|
SimpleStarUraBox.Enabled = MusicAttributes.GetByUniqueId(item.UniqueId).CanPlayUra;
|
|
|
|
simpleBoxLoading = false;
|
2023-07-17 10:20:00 +02:00
|
|
|
}
|
2023-07-19 12:07:56 +02:00
|
|
|
|
2023-07-28 18:02:47 +02:00
|
|
|
private void LoadNewSongData(NewSongData item)
|
|
|
|
{
|
|
|
|
Logger.Info($"Selection Changed NewSongData: {item}");
|
|
|
|
Logger.Info($"Showing properties for NewSongData: {item}");
|
|
|
|
MusicInfoGrid.SelectedObject = item?.MusicInfo;
|
|
|
|
MusicAttributesGrid.SelectedObject = item?.MusicAttribute;
|
|
|
|
MusicOrderGrid.SelectedObject = item?.MusicOrder;
|
|
|
|
WordsGrid.SelectedObject = item?.Word;
|
|
|
|
WordSubGrid.SelectedObject = item?.WordSub;
|
|
|
|
WordDetailGrid.SelectedObject = item?.WordDetail;
|
|
|
|
indexChanging = false;
|
|
|
|
}
|
|
|
|
|
2023-07-19 12:07:56 +02:00
|
|
|
private bool indexChanging = false;
|
2023-07-17 10:20:00 +02:00
|
|
|
|
|
|
|
private void LoadedMusicBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
{
|
2023-07-19 12:07:56 +02:00
|
|
|
if (indexChanging) return;
|
|
|
|
indexChanging = true;
|
|
|
|
NewSoundsBox.SelectedItem = null;
|
2023-07-17 10:20:00 +02:00
|
|
|
var item = LoadedMusicBox.SelectedItem as MusicInfo;
|
2023-07-19 07:10:25 +02:00
|
|
|
Logger.Info($"Selection Changed MusicItem: {item}");
|
2023-07-28 18:02:47 +02:00
|
|
|
LoadMusicInfo(item);
|
2023-07-19 12:07:56 +02:00
|
|
|
indexChanging = false;
|
2023-07-17 10:20:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void EditorTable_Resize(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
WordsGB.Height = WordSubGB.Height = WordDetailGB.Height = EditorTable.Height / 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void NewSoundsBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
{
|
2023-07-19 12:07:56 +02:00
|
|
|
if (indexChanging) return;
|
|
|
|
indexChanging = true;
|
|
|
|
LoadedMusicBox.SelectedItem = null;
|
2023-07-19 07:10:25 +02:00
|
|
|
var item = NewSoundsBox.SelectedItem as NewSongData;
|
2023-07-28 18:02:47 +02:00
|
|
|
LoadNewSongData(item);
|
2023-07-17 10:20:00 +02:00
|
|
|
}
|
|
|
|
|
2023-07-28 18:02:47 +02:00
|
|
|
#endregion
|
2023-07-19 12:07:56 +02:00
|
|
|
|
2023-07-28 18:02:47 +02:00
|
|
|
private void RemoveSongButton_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
2023-07-19 12:07:56 +02:00
|
|
|
{
|
|
|
|
Logger.Info("Clicked remove song");
|
|
|
|
if (NewSoundsBox.SelectedItem != null)
|
|
|
|
{
|
|
|
|
Logger.Info("Removing newly added song");
|
|
|
|
AddedMusic.Remove(NewSoundsBox.SelectedItem as NewSongData);
|
|
|
|
Logger.Info("Refreshing list");
|
|
|
|
AddedMusicBinding.ResetBindings(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LoadedMusicBox.SelectedItem != null)
|
|
|
|
{
|
|
|
|
Logger.Info("Removing existing song");
|
|
|
|
var mi = LoadedMusicBox.SelectedItem as MusicInfo;
|
|
|
|
var ma = MusicAttributes.GetByUniqueId(mi.UniqueId);
|
|
|
|
var mo = MusicOrders.GetByUniqueId(mi.UniqueId);
|
|
|
|
var w = WordList.GetBySong(mi.Id);
|
|
|
|
var ws = WordList.GetBySongSub(mi.Id);
|
|
|
|
var wd = WordList.GetBySongDetail(mi.Id);
|
|
|
|
|
|
|
|
Logger.Info("Removing music info");
|
|
|
|
MusicInfos.Items.RemoveAll(x => x.UniqueId == mi.UniqueId);
|
|
|
|
Logger.Info("Removing music attribute");
|
|
|
|
MusicAttributes.Items.Remove(ma);
|
|
|
|
Logger.Info("Removing music order");
|
|
|
|
MusicOrders.Items.Remove(mo);
|
|
|
|
Logger.Info("Removing word");
|
|
|
|
WordList.Items.Remove(w);
|
|
|
|
Logger.Info("Removing word sub");
|
|
|
|
WordList.Items.Remove(ws);
|
|
|
|
Logger.Info("Removing word detail");
|
|
|
|
WordList.Items.Remove(wd);
|
|
|
|
|
2023-07-28 18:02:47 +02:00
|
|
|
Logger.Info("Refreshing list");
|
|
|
|
LoadedMusicBinding.DataSource = MusicInfos.Items.Where(mi => mi.UniqueId != 0).ToList();
|
2023-07-19 12:07:56 +02:00
|
|
|
LoadedMusicBinding.ResetBindings(false);
|
2023-07-28 18:02:47 +02:00
|
|
|
|
|
|
|
var sel = LoadedMusicBox.SelectedIndex;
|
|
|
|
|
|
|
|
if (sel >= MusicInfos.Items.Count)
|
|
|
|
sel = MusicInfos.Items.Count - 1;
|
|
|
|
|
|
|
|
LoadedMusicBox.SelectedItem = null;
|
|
|
|
LoadedMusicBox.SelectedIndex = sel;
|
2023-07-19 12:07:56 +02:00
|
|
|
return;
|
|
|
|
}
|
2023-07-28 18:29:27 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
private void SoundViewTab_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
if (!(SoundViewTab.SelectedTab == SoundViewerExpert || SoundViewTab.SelectedTab == SoundViewerSimple))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (LoadedMusicBox.SelectedItem != null)
|
|
|
|
{
|
|
|
|
var item = LoadedMusicBox.SelectedItem as MusicInfo;
|
|
|
|
Logger.Info($"Tab switched, reloading MusicItem: {item}");
|
|
|
|
LoadMusicInfo(item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(NewSoundsBox.SelectedItem!=null)
|
|
|
|
{
|
|
|
|
var item = NewSoundsBox.SelectedItem as NewSongData;
|
|
|
|
Logger.Info($"Tab switched, reloading NewSongData: {item}");
|
|
|
|
LoadNewSongData(item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool simpleBoxLoading = false;
|
|
|
|
private void SimpleBoxChanged(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
|
|
|
{
|
|
|
|
if (simpleBoxLoading) return;
|
|
|
|
|
|
|
|
if (LoadedMusicBox.SelectedItem != null)
|
|
|
|
{
|
|
|
|
var item = LoadedMusicBox.SelectedItem as MusicInfo;
|
|
|
|
|
|
|
|
Logger.Info($"Simple Box changed : {(sender as Control).Name} to value {(sender as Control).Text}");
|
|
|
|
|
|
|
|
|
|
|
|
WordList.GetBySong(item.Id).JapaneseText = SimpleTitleBox.Text;
|
|
|
|
WordList.GetBySongSub(item.Id).JapaneseText = SimpleSubtitleBox.Text;
|
|
|
|
WordList.GetBySongDetail(item.Id).JapaneseText = SimpleDetailBox.Text;
|
|
|
|
MusicOrders.GetByUniqueId(item.UniqueId).Genre = (Genre)SimpleGenreBox.SelectedItem;
|
|
|
|
item.StarEasy = (int)SimpleStarEasyBox.Value;
|
|
|
|
item.StarNormal = (int)SimpleStarNormalBox.Value;
|
|
|
|
item.StarHard = (int)SimpleStarHardBox.Value;
|
|
|
|
item.StarMania = (int)SimpleStarManiaBox.Value;
|
|
|
|
item.StarUra = (int)SimpleStarUraBox.Value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2023-07-17 10:20:00 +02:00
|
|
|
}
|
|
|
|
}
|