1
0
mirror of synced 2024-11-24 04:20:10 +01:00

can add the same song to multiple genres

This commit is contained in:
NotImplementedLife 2023-08-16 19:05:50 +03:00
parent b1617bf7ad
commit 8c93053867
7 changed files with 251 additions and 95 deletions

View File

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.MusicOrdersPanel = new System.Windows.Forms.Panel();
this.RightButton = new System.Windows.Forms.Button();
this.ControlsPanel = new System.Windows.Forms.Panel();
@ -40,7 +41,18 @@
this.CutButton = new System.Windows.Forms.Button();
this.PageLabel = new System.Windows.Forms.Label();
this.LeftButton = new System.Windows.Forms.Button();
this.GenreCloneMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.cloneAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.popToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.animeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.kidsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.vocaloidToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.gameMusicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.namcoOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.varietyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.classicalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ControlsPanel.SuspendLayout();
this.GenreCloneMenuStrip.SuspendLayout();
this.SuspendLayout();
//
// MusicOrdersPanel
@ -206,6 +218,84 @@
this.LeftButton.UseVisualStyleBackColor = false;
this.LeftButton.Click += new System.EventHandler(this.LeftButton_Click);
//
// GenreCloneMenuStrip
//
this.GenreCloneMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cloneAsToolStripMenuItem});
this.GenreCloneMenuStrip.Name = "GenreCloneMenuStrip";
this.GenreCloneMenuStrip.Size = new System.Drawing.Size(181, 48);
//
// cloneAsToolStripMenuItem
//
this.cloneAsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.popToolStripMenuItem,
this.animeToolStripMenuItem,
this.kidsToolStripMenuItem,
this.vocaloidToolStripMenuItem,
this.gameMusicToolStripMenuItem,
this.namcoOriginalToolStripMenuItem,
this.varietyToolStripMenuItem,
this.classicalToolStripMenuItem});
this.cloneAsToolStripMenuItem.Name = "cloneAsToolStripMenuItem";
this.cloneAsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.cloneAsToolStripMenuItem.Text = "Clone as";
//
// popToolStripMenuItem
//
this.popToolStripMenuItem.Name = "popToolStripMenuItem";
this.popToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.popToolStripMenuItem.Text = "Pop";
this.popToolStripMenuItem.Click += new System.EventHandler(this.GenreCloneToolStripMenuItem_Click);
//
// animeToolStripMenuItem
//
this.animeToolStripMenuItem.Name = "animeToolStripMenuItem";
this.animeToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.animeToolStripMenuItem.Text = "Anime";
this.animeToolStripMenuItem.Click += new System.EventHandler(this.GenreCloneToolStripMenuItem_Click);
//
// kidsToolStripMenuItem
//
this.kidsToolStripMenuItem.Name = "kidsToolStripMenuItem";
this.kidsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.kidsToolStripMenuItem.Text = "Kids";
this.kidsToolStripMenuItem.Click += new System.EventHandler(this.GenreCloneToolStripMenuItem_Click);
//
// vocaloidToolStripMenuItem
//
this.vocaloidToolStripMenuItem.Name = "vocaloidToolStripMenuItem";
this.vocaloidToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.vocaloidToolStripMenuItem.Text = "Vocaloid";
this.vocaloidToolStripMenuItem.Click += new System.EventHandler(this.GenreCloneToolStripMenuItem_Click);
//
// gameMusicToolStripMenuItem
//
this.gameMusicToolStripMenuItem.Name = "gameMusicToolStripMenuItem";
this.gameMusicToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.gameMusicToolStripMenuItem.Text = "GameMusic";
this.gameMusicToolStripMenuItem.Click += new System.EventHandler(this.GenreCloneToolStripMenuItem_Click);
//
// namcoOriginalToolStripMenuItem
//
this.namcoOriginalToolStripMenuItem.Name = "namcoOriginalToolStripMenuItem";
this.namcoOriginalToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.namcoOriginalToolStripMenuItem.Text = "NamcoOriginal";
this.namcoOriginalToolStripMenuItem.Click += new System.EventHandler(this.GenreCloneToolStripMenuItem_Click);
//
// varietyToolStripMenuItem
//
this.varietyToolStripMenuItem.Name = "varietyToolStripMenuItem";
this.varietyToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.varietyToolStripMenuItem.Text = "Variety";
this.varietyToolStripMenuItem.Click += new System.EventHandler(this.GenreCloneToolStripMenuItem_Click);
//
// classicalToolStripMenuItem
//
this.classicalToolStripMenuItem.Name = "classicalToolStripMenuItem";
this.classicalToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.classicalToolStripMenuItem.Text = "Classical";
this.classicalToolStripMenuItem.Click += new System.EventHandler(this.GenreCloneToolStripMenuItem_Click);
//
// MusicOrderViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -218,6 +308,7 @@
this.Size = new System.Drawing.Size(507, 297);
this.ControlsPanel.ResumeLayout(false);
this.ControlsPanel.PerformLayout();
this.GenreCloneMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -236,5 +327,15 @@
private Button Right10Button;
private Button ListStartButton;
private Button ListEndButton;
private ContextMenuStrip GenreCloneMenuStrip;
private ToolStripMenuItem cloneAsToolStripMenuItem;
private ToolStripMenuItem popToolStripMenuItem;
private ToolStripMenuItem animeToolStripMenuItem;
private ToolStripMenuItem kidsToolStripMenuItem;
private ToolStripMenuItem vocaloidToolStripMenuItem;
private ToolStripMenuItem gameMusicToolStripMenuItem;
private ToolStripMenuItem namcoOriginalToolStripMenuItem;
private ToolStripMenuItem varietyToolStripMenuItem;
private ToolStripMenuItem classicalToolStripMenuItem;
}
}

View File

@ -187,108 +187,133 @@ namespace TaikoSoundEditor.Controls
private void MusicOrdersPanel_MouseDown(object sender, MouseEventArgs e) => ExceptionGuard.Run(() =>
{
if (e.Button != MouseButtons.Left) return;
Select();
var cursor = e.Location;
int itemW = MusicOrdersPanel.Width / ItemsPerRow;
int itemH = MusicOrdersPanel.Height / ItemsPerCol;
int row = cursor.Y / itemH;
int col = cursor.X / itemW;
//Debug.WriteLine($"{row} {col}");
if (row < 0 || row >= ItemsPerCol || col < 0 || col >= ItemsPerRow)
return;
var index = CurrentPage * ItemsPerPage + row * ItemsPerRow + col;
if (PasteMode)
if (e.Button == MouseButtons.Right)
{
Select();
var cursor = e.Location;
int itemW = MusicOrdersPanel.Width / ItemsPerRow;
int itemH = MusicOrdersPanel.Height / ItemsPerCol;
int row = cursor.Y / itemH;
int col = cursor.X / itemW;
//Debug.WriteLine($"{row} {col}");
if (row < 0 || row >= ItemsPerCol || col < 0 || col >= ItemsPerRow)
return;
var index = CurrentPage * ItemsPerPage + row * ItemsPerRow + col;
if (index < 0 || index > SongCards.Count) return;
SongCard before = null, after = null;
for (int i = index; i < SongCards.Count; i++)
if (!SongCards[i].IsCut)
{
before = SongCards[i];
break;
}
for (int i = index - 1; i >= 0; i--)
if (!SongCards[i].IsCut)
{
after = SongCards[i];
break;
}
string message = "Do you want to move the selected songs?";
if (before != null)
{
if (after != null && before != after)
{
message = $"Do you want to move the selected songs before {before.Id} and after {after.Id}?";
}
else
{
message = $"Do you want to move the selected songs before {before.Id}?";
}
}
else if (after != null)
{
message = $"Do you want to move the selected songs after {after.Id}?";
}
if (MessageBox.Show(message, "Move songs?", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
SongCards.RemoveAll(CutSelection.Contains);
var ix = after != null ? SongCards.IndexOf(after) + 1 : before != null ? SongCards.IndexOf(before) : 0;
SongCards.InsertRange(ix, CutSelection);
foreach (var c in CutSelection) c.IsCut = false;
CutSelection.Clear();
PasteMode = false;
PasteActive = false;
CutActive = RemoveActive = false;
MusicOrdersPanel.Invalidate();
return;
}
if (index < 0 || index >= SongCards.Count) return;
var card = SongCards[index];
if (Form.ModifierKeys == Keys.Control)
{
if (card.IsSelected)
{
card.IsSelected = false;
Selection.Remove(card);
}
else
{
card.IsSelected = true;
Selection.Add(card);
}
MusicOrdersPanel.Invalidate();
CardToClone = SongCards[index];
GenreCloneMenuStrip.Show(MusicOrdersPanel, cursor);
}
else
{
foreach (var sel in Selection)
if (e.Button != MouseButtons.Left) return;
Select();
var cursor = e.Location;
int itemW = MusicOrdersPanel.Width / ItemsPerRow;
int itemH = MusicOrdersPanel.Height / ItemsPerCol;
int row = cursor.Y / itemH;
int col = cursor.X / itemW;
//Debug.WriteLine($"{row} {col}");
if (row < 0 || row >= ItemsPerCol || col < 0 || col >= ItemsPerRow)
return;
var index = CurrentPage * ItemsPerPage + row * ItemsPerRow + col;
if (PasteMode)
{
sel.IsSelected = false;
if (index < 0 || index > SongCards.Count) return;
SongCard before = null, after = null;
for (int i = index; i < SongCards.Count; i++)
if (!SongCards[i].IsCut)
{
before = SongCards[i];
break;
}
for (int i = index - 1; i >= 0; i--)
if (!SongCards[i].IsCut)
{
after = SongCards[i];
break;
}
string message = "Do you want to move the selected songs?";
if (before != null)
{
if (after != null && before != after)
{
message = $"Do you want to move the selected songs before {before.Id} and after {after.Id}?";
}
else
{
message = $"Do you want to move the selected songs before {before.Id}?";
}
}
else if (after != null)
{
message = $"Do you want to move the selected songs after {after.Id}?";
}
if (MessageBox.Show(message, "Move songs?", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
SongCards.RemoveAll(CutSelection.Contains);
var ix = after != null ? SongCards.IndexOf(after) + 1 : before != null ? SongCards.IndexOf(before) : 0;
SongCards.InsertRange(ix, CutSelection);
foreach (var c in CutSelection) c.IsCut = false;
CutSelection.Clear();
PasteMode = false;
PasteActive = false;
CutActive = RemoveActive = false;
MusicOrdersPanel.Invalidate();
return;
}
Selection.Clear();
card.IsSelected = true;
Selection.Add(card);
MusicOrdersPanel.Invalidate();
if (index < 0 || index >= SongCards.Count) return;
var card = SongCards[index];
if (Form.ModifierKeys == Keys.Control)
{
if (card.IsSelected)
{
card.IsSelected = false;
Selection.Remove(card);
}
else
{
card.IsSelected = true;
Selection.Add(card);
}
MusicOrdersPanel.Invalidate();
}
else
{
foreach (var sel in Selection)
{
sel.IsSelected = false;
}
Selection.Clear();
card.IsSelected = true;
Selection.Add(card);
MusicOrdersPanel.Invalidate();
}
CutActive = RemoveActive = Selection.Count > 0;
}
CutActive = RemoveActive = Selection.Count > 0;
});
private bool _CutActive = false;
@ -375,6 +400,8 @@ namespace TaikoSoundEditor.Controls
MusicOrdersPanel.Invalidate();
});
public bool SongExists(int uniqueId) => SongCards.Any(c => c.MusicOrder.UniqueId == uniqueId);
private void RemoveButton_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
{
var toRemove = Selection.ToList();
@ -495,5 +522,18 @@ namespace TaikoSoundEditor.Controls
SongDoubleClick?.Invoke(this, SongCards[index].MusicOrder);
}
private SongCard CardToClone = null;
private void GenreCloneToolStripMenuItem_Click(object sender, EventArgs e)
{
if (CardToClone == null) return;
var genre = (Genre)Enum.Parse(typeof(Genre), (sender as ToolStripMenuItem).Text);
//MessageBox.Show(genre.ToString());
var newMO = new MusicOrder(CardToClone.MusicOrder);
newMO.Genre = genre;
AddSong(newMO);
}
}
}

View File

@ -57,4 +57,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="GenreCloneMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -24,5 +24,14 @@ namespace TaikoSoundEditor.Data
get => (Genre)GenreNo;
set => GenreNo = (int)value;
}
public MusicOrder() { }
public MusicOrder(MusicOrder source)
{
Genre = source.Genre;
Id = source.Id;
UniqueId = source.UniqueId;
CloseDispType = source.CloseDispType;
}
}
}

View File

@ -268,6 +268,9 @@ namespace TaikoSoundEditor
private void MusicOrderViewer_SongRemoved(Controls.MusicOrderViewer sender, MusicOrder mo) => ExceptionGuard.Run(() =>
{
var uniqId = mo.UniqueId;
if (MusicOrderViewer.SongExists(uniqId))
return;
var mi = MusicInfos.Items.Where(x => x.UniqueId == uniqId).FirstOrDefault();
if (mi != null)

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2023-07-31T16:49:36.9770534Z;True|2023-07-31T19:48:14.6352025+03:00;True|2023-07-30T09:51:53.3737837+03:00;True|2023-07-30T09:20:22.7718733+03:00;True|2023-07-30T09:02:22.1384796+03:00;True|2023-07-30T08:20:21.5020489+03:00;True|2023-07-29T11:28:56.2445862+03:00;True|2023-07-29T11:05:03.3876668+03:00;True|2023-07-29T10:54:04.8963992+03:00;True|2023-07-29T10:22:03.4096107+03:00;True|2023-07-29T10:05:26.6712083+03:00;True|2023-07-28T19:30:15.3174413+03:00;True|2023-07-22T19:07:39.3718711+03:00;True|2023-07-22T19:06:41.2393088+03:00;True|2023-07-22T12:07:26.2620601+03:00;True|2023-07-22T12:06:39.9230498+03:00;True|2023-07-22T11:29:18.0153916+03:00;True|2023-07-22T08:23:07.5000923+03:00;True|2023-07-21T20:03:15.6598520+03:00;True|2023-07-21T19:41:13.2800435+03:00;True|2023-07-19T13:08:33.4726289+03:00;True|2023-07-19T12:08:17.2430335+03:00;True|2023-07-18T09:38:50.7615921+03:00;True|2023-07-18T09:25:23.0403589+03:00;True|2023-07-17T17:57:08.1469738+03:00;True|2023-07-17T11:28:41.9554245+03:00;True|2023-07-17T11:15:26.2194507+03:00;</History>
<History>True|2023-07-31T17:19:48.4524724Z;False|2023-07-31T20:17:55.5982472+03:00;False|2023-07-31T20:17:38.1663347+03:00;True|2023-07-31T19:49:36.9770534+03:00;True|2023-07-31T19:48:14.6352025+03:00;True|2023-07-30T09:51:53.3737837+03:00;True|2023-07-30T09:20:22.7718733+03:00;True|2023-07-30T09:02:22.1384796+03:00;True|2023-07-30T08:20:21.5020489+03:00;True|2023-07-29T11:28:56.2445862+03:00;True|2023-07-29T11:05:03.3876668+03:00;True|2023-07-29T10:54:04.8963992+03:00;True|2023-07-29T10:22:03.4096107+03:00;True|2023-07-29T10:05:26.6712083+03:00;True|2023-07-28T19:30:15.3174413+03:00;True|2023-07-22T19:07:39.3718711+03:00;True|2023-07-22T19:06:41.2393088+03:00;True|2023-07-22T12:07:26.2620601+03:00;True|2023-07-22T12:06:39.9230498+03:00;True|2023-07-22T11:29:18.0153916+03:00;True|2023-07-22T08:23:07.5000923+03:00;True|2023-07-21T20:03:15.6598520+03:00;True|2023-07-21T19:41:13.2800435+03:00;True|2023-07-19T13:08:33.4726289+03:00;True|2023-07-19T12:08:17.2430335+03:00;True|2023-07-18T09:38:50.7615921+03:00;True|2023-07-18T09:25:23.0403589+03:00;True|2023-07-17T17:57:08.1469738+03:00;True|2023-07-17T11:28:41.9554245+03:00;True|2023-07-17T11:15:26.2194507+03:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -22,8 +22,8 @@ namespace TaikoSoundEditor.Utils
throw;
#else
MessageBox.Show(e.Message, "An error occured");
Logger.Error(e);
MessageBox.Show(ex.Message, "An error occured");
Logger.Error(ex);
#endif
}
}