Add option for placing note on drag #18

Open
yellowberryHN wants to merge 3 commits from yellowberryHN/note-on-drag into C#-master
3 changed files with 1240 additions and 1142 deletions
+1095 -1105
View File
File diff suppressed because it is too large Load Diff
+84 -36
View File
@@ -4,6 +4,7 @@ using IrrKlang;
using BAKKA_Editor.Operations;
using Tomlyn;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace BAKKA_Editor
{
@@ -124,15 +125,15 @@ namespace BAKKA_Editor
File.WriteAllText("settings.toml", Toml.FromModel(userSettings));
}
// Apply settings
showCursorToolStripMenuItem.Checked = userSettings.ViewSettings.ShowCursor;
showCursorDuringPlaybackToolStripMenuItem.Checked = userSettings.ViewSettings.ShowCursorDuringPlayback;
highlightViewedNoteToolStripMenuItem.Checked = userSettings.ViewSettings.HighlightViewedNote;
showGimmicksInCircleViewToolStripMenuItem.Checked = userSettings.ViewSettings.ShowGimmicks;
showCursorToolStripMenuItem.Checked = userSettings.ViewSettings.ShowCursor;
showCursorDuringPlaybackToolStripMenuItem.Checked = userSettings.ViewSettings.ShowCursorDuringPlayback;
highlightViewedNoteToolStripMenuItem.Checked = userSettings.ViewSettings.HighlightViewedNote;
showGimmicksInCircleViewToolStripMenuItem.Checked = userSettings.ViewSettings.ShowGimmicks;
showGimmicksDuringPlaybackToolStripMenuItem.Checked = userSettings.ViewSettings.ShowGimmicksDuringPlayback;
selectLastInsertedNoteToolStripMenuItem.Checked = userSettings.ViewSettings.SelectLastInsertedNote;
visualHispeedNumeric.Value = (decimal)userSettings.ViewSettings.HispeedSetting;
trackBarVolume.Value = userSettings.ViewSettings.Volume;
autoSaveTimer.Interval = userSettings.SaveSettings.AutoSaveInterval * 60000;
selectLastInsertedNoteToolStripMenuItem.Checked = userSettings.ViewSettings.SelectLastInsertedNote;
visualHispeedNumeric.Value = (decimal)userSettings.ViewSettings.HispeedSetting;
trackBarVolume.Value = userSettings.ViewSettings.Volume;
autoSaveTimer.Interval = userSettings.SaveSettings.AutoSaveInterval * 60000;
autoSaveTimer.Enabled = true;
// Update hotkey labels
tapButton.AppendHotkey(userSettings.HotkeySettings.TouchHotkey);
@@ -350,15 +351,15 @@ namespace BAKKA_Editor
if (tempFilePath != "")
File.Delete(tempFilePath);
// Apply settings
userSettings.ViewSettings.ShowCursor = showCursorToolStripMenuItem.Checked;
userSettings.ViewSettings.ShowCursorDuringPlayback = showCursorDuringPlaybackToolStripMenuItem.Checked;
userSettings.ViewSettings.HighlightViewedNote = highlightViewedNoteToolStripMenuItem.Checked;
userSettings.ViewSettings.ShowGimmicks = showGimmicksInCircleViewToolStripMenuItem.Checked;
userSettings.ViewSettings.ShowGimmicksDuringPlayback = showGimmicksDuringPlaybackToolStripMenuItem.Checked;
userSettings.ViewSettings.SelectLastInsertedNote = selectLastInsertedNoteToolStripMenuItem.Checked;
userSettings.ViewSettings.HispeedSetting = circleView.Hispeed;
userSettings.ViewSettings.Volume = trackBarVolume.Value;
userSettings.SaveSettings.AutoSaveInterval = autoSaveTimer.Interval / 60000;
userSettings.ViewSettings.ShowCursor = showCursorToolStripMenuItem.Checked;
userSettings.ViewSettings.ShowCursorDuringPlayback = showCursorDuringPlaybackToolStripMenuItem.Checked;
userSettings.ViewSettings.HighlightViewedNote = highlightViewedNoteToolStripMenuItem.Checked;
userSettings.ViewSettings.ShowGimmicks = showGimmicksInCircleViewToolStripMenuItem.Checked;
userSettings.ViewSettings.ShowGimmicksDuringPlayback = showGimmicksDuringPlaybackToolStripMenuItem.Checked;
userSettings.ViewSettings.SelectLastInsertedNote = selectLastInsertedNoteToolStripMenuItem.Checked;
userSettings.ViewSettings.HispeedSetting = circleView.Hispeed;
userSettings.ViewSettings.Volume = trackBarVolume.Value;
userSettings.SaveSettings.AutoSaveInterval = autoSaveTimer.Interval / 60000;
//Update user settings.toml
if (File.Exists("settings.toml"))
File.WriteAllText("settings.toml", Toml.FromModel(userSettings));
@@ -482,8 +483,8 @@ namespace BAKKA_Editor
minSize = 1;
break;
}
if (sizeNumeric.Value < minSize) sizeNumeric.Value = minSize;
if (sizeTrackBar.Value < minSize) sizeTrackBar.Value = minSize;
if (sizeNumeric.Value < minSize) sizeNumeric.Value = minSize;
if (sizeTrackBar.Value < minSize) sizeTrackBar.Value = minSize;
sizeNumeric.Minimum = minSize;
sizeTrackBar.Minimum = minSize;
circlePanel.Invalidate();
@@ -655,6 +656,8 @@ namespace BAKKA_Editor
{
circleView.CurrentMeasure = (float)measureNumeric.Value + ((float)beat1Numeric.Value / (float)beat2Numeric.Value);
circlePanel.Invalidate();
UpdateNotesOnBeat();
}
if (currentNoteType == NoteType.HoldJoint || currentNoteType == NoteType.HoldEnd)
@@ -676,7 +679,7 @@ namespace BAKKA_Editor
insertButton.Enabled = false;
}
else
{
{
insertButton.Enabled = true;
}
}
@@ -796,7 +799,7 @@ namespace BAKKA_Editor
// don't reset hold state if we're already inserting a hold
if (isInsertingHold)
return;
if (noBonusRadio.Checked)
SetSelectedObject(NoteType.HoldStartNoBonus);
else if (bonusRadio.Checked)
@@ -818,7 +821,7 @@ namespace BAKKA_Editor
private void endHoldCheck_CheckedChanged(object sender, EventArgs e)
{
if(endHoldCheck.Checked && currentNoteType == NoteType.HoldJoint)
if (endHoldCheck.Checked && currentNoteType == NoteType.HoldJoint)
{
SetSelectedObject(NoteType.HoldEnd);
}
@@ -1044,6 +1047,7 @@ namespace BAKKA_Editor
{
playButton.Text = "Pause";
updateTimer.Enabled = true;
notesOnBeat.Items.Clear();
}
playButton.AppendHotkey(userSettings.HotkeySettings.PlayHotkey);
}
@@ -1117,7 +1121,7 @@ namespace BAKKA_Editor
}
var dist = Utils.GetDist(e.Location, circleView.mouseDownPt);
if (dist > 5.0f)
if (dist > 5.0f && dragPlaceNoteToolStripMenuItem.Checked)
InsertObject();
circleView.UpdateMouseUp();
circlePanel.Invalidate();
@@ -1250,6 +1254,7 @@ namespace BAKKA_Editor
if (selectLastInsertedNoteToolStripMenuItem.Checked)
nextSelectedNote = tempNote;
chart.Notes.Add(tempNote);
UpdateNotesOnBeat();
chart.IsSaved = false;
switch (currentNoteType)
{
@@ -1269,7 +1274,7 @@ namespace BAKKA_Editor
private void SetNonHoldButtonState(bool state)
{
isInsertingHold = !state;
tapButton.Enabled = state;
orangeButton.Enabled = state;
greenButton.Enabled = state;
@@ -1388,13 +1393,13 @@ namespace BAKKA_Editor
MessageBox.Show(
$"Authors: Goatgarien and VeroxZik\n" +
$"Contributions: Yellowberry, Farex-GH\n" +
$"Icon: IPIhypster",
$"Icon: IPIhypster",
$"BAKKA Editor {fileVersion}");
}
private void initialChartSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowInitialSettings();
ShowInitialSettings();
}
private void ShowInitialSettings()
@@ -1436,7 +1441,7 @@ namespace BAKKA_Editor
{
circlePanel.Invalidate();
}
private void showGimmicksInCircleViewToolStripMenuItem_Click(object sender, EventArgs e)
{
circlePanel.Invalidate();
@@ -1654,7 +1659,7 @@ namespace BAKKA_Editor
}
// Prevent deletetion of initial BPM and time signature
if (chart.Gimmicks.Count == 0
if (chart.Gimmicks.Count == 0
|| (gimmick.Measure == 0 && (gimmick.GimmickType == GimmickType.BpmChange || gimmick.GimmickType == GimmickType.TimeSignatureChange)))
{
gimmickDeleteButton.Enabled = false;
@@ -1669,7 +1674,7 @@ namespace BAKKA_Editor
{
if (val != -2)
selectedNoteIndex = val;
if(selectedNoteIndex == -1)
if (selectedNoteIndex == -1)
{
noteMeasureLabel.Text = "None";
noteBeatLabel.Text = "None";
@@ -1798,7 +1803,7 @@ namespace BAKKA_Editor
NoteOperation op2 = null;
if (chart.Notes[selectedNoteIndex].NoteType == NoteType.HoldStartBonusFlair || chart.Notes[selectedNoteIndex].NoteType == NoteType.HoldStartNoBonus)
{
if(chart.Notes[selectedNoteIndex].NextNote != null)
if (chart.Notes[selectedNoteIndex].NextNote != null)
{
if (chart.Notes[selectedNoteIndex].NextNote.NoteType == NoteType.HoldEnd)
{
@@ -1808,7 +1813,7 @@ namespace BAKKA_Editor
}
if (chart.Notes[selectedNoteIndex].NoteType == NoteType.HoldEnd)
{
if(chart.Notes[selectedNoteIndex].PrevNote != null)
if (chart.Notes[selectedNoteIndex].PrevNote != null)
{
if (chart.Notes[selectedNoteIndex].PrevNote.NoteType == NoteType.HoldStartBonusFlair || chart.Notes[selectedNoteIndex].PrevNote.NoteType == NoteType.HoldStartNoBonus)
{
@@ -1836,7 +1841,7 @@ namespace BAKKA_Editor
{
val = trackBarVolume.Maximum - trackBarVolume.Value;
}
else if (!increase && (trackBarVolume.Value - val<trackBarVolume.Minimum))
else if (!increase && (trackBarVolume.Value - val < trackBarVolume.Minimum))
{
val = trackBarVolume.Value - trackBarVolume.Minimum;
}
@@ -1865,7 +1870,7 @@ namespace BAKKA_Editor
insertButton.Focus();
return true;
case Keys.Up | Keys.Shift:
/* Fallthrough */
/* Fallthrough */
case Keys.Down | Keys.Shift:
keyData &= ~Keys.Shift;
playbackVolumeChange(keyData == Keys.Up);
@@ -2099,7 +2104,7 @@ namespace BAKKA_Editor
}
}
private void trackBarVolume_ValueChanged(object sender, EventArgs e)
{
/* No song, nothing to do. */
@@ -2108,7 +2113,7 @@ namespace BAKKA_Editor
return;
}
/* Volume is represented as a float from 0-1. */
currentSong.Volume = (float) trackBarVolume.Value / (float) trackBarVolume.Maximum;
currentSong.Volume = (float)trackBarVolume.Value / (float)trackBarVolume.Maximum;
circlePanel.Invalidate();
}
@@ -2154,7 +2159,7 @@ namespace BAKKA_Editor
bool CurrentlyInsertingHold()
{
if(currentNoteType == NoteType.HoldJoint || currentNoteType == NoteType.HoldEnd)
if (currentNoteType == NoteType.HoldJoint || currentNoteType == NoteType.HoldEnd)
{
return true;
}
@@ -2201,5 +2206,48 @@ namespace BAKKA_Editor
circleView.showHispeed = showGimmicksDuringPlaybackToolStripMenuItem.Checked;
circlePanel.Invalidate();
}
private void UpdateNotesOnBeat()
{
// Fill list of notes on beat
notesOnBeat.Items.Clear();
var notes = chart.Notes.Where(n => n.BeatInfo.MeasureDecimal == circleView.CurrentMeasure).Select(n =>
{
var listItem = new ListViewItem(n.NoteType.ToLabel());
listItem.SubItems.Add(n.Position.ToString());
listItem.SubItems.Add(n.Size.ToString());
return listItem;
}).ToArray();
notesOnBeat.Items.AddRange(notes);
}
private void notesOnBeat_SelectedIndexChanged(object sender, EventArgs e)
{
if (notesOnBeat.SelectedItems.Count != 1) return;
var selectedNote = notesOnBeat.SelectedItems[0];
var noteType = selectedNote.Text;
var position = float.Parse(selectedNote.SubItems[1].Text);
var size = float.Parse(selectedNote.SubItems[2].Text);
float currentMeasure = circleView.CurrentMeasure;
// Find the matching selected note
var noteInChart = chart.Notes.FirstOrDefault(x => x.BeatInfo.MeasureDecimal == currentMeasure &&
x.NoteType.ToLabel() == noteType &&
x.Position == position &&
x.Size == size
);
if (noteInChart != null)
{
selectedNoteIndex = chart.Notes.IndexOf(noteInChart);
circlePanel.Invalidate();
UpdateNoteLabels();
}
}
}
}
+61 -1
View File
@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">