Fixed hispeed stuff

Hispeed setting now mostly matches wacca hispeed.
hispeed gimmicks also show up in visual
hispeed setting also saves between launches
This commit is contained in:
Goatgarien
2023-02-15 06:37:25 -08:00
parent 679ca8c130
commit 89db842aa2
5 changed files with 77 additions and 59 deletions
+9 -5
View File
@@ -257,10 +257,14 @@ namespace BAKKA_Editor
TimeEvents[0].StartTime = Offset * 1000.0;
for (int i = 1; i < TimeEvents.Count; i++)
{
TimeEvents[i].StartTime = ((TimeEvents[i].Measure - TimeEvents[i - 1].Measure) * 4 * TimeEvents[i - 1].TimeSig.Ratio * (60000.0 / TimeEvents[i].BPM)) + TimeEvents[i - 1].StartTime;
TimeEvents[i].StartTime = ((TimeEvents[i].Measure - TimeEvents[i - 1].Measure) * (4.0f * TimeEvents[i - 1].TimeSig.Ratio * (60000.0 / TimeEvents[i - 1].BPM))) + TimeEvents[i - 1].StartTime;
}
}
/*
((60000.0 / evt.BPM) * 4.0 * evt.TimeSig.Ratio) * measure = time
time / ((60000.0 / evt.BPM) * 4.0 * evt.TimeSig.Ratio) = measure
*/
/// <summary>
/// Translate clock time to beats
/// </summary>
@@ -274,7 +278,7 @@ namespace BAKKA_Editor
var evt = TimeEvents.Where(x => time >= x.StartTime).LastOrDefault();
if (evt == null)
evt = TimeEvents[0];
return new BeatInfo((float)(evt.BPM * (time - evt.StartTime) / (60000.0f * evt.TimeSig.Ratio * 4)) + evt.Measure);
return new BeatInfo((float)((time - evt.StartTime) / ((60000.0 / evt.BPM) * 4.0f * evt.TimeSig.Ratio) + evt.Measure));
}
/// <summary>
@@ -290,7 +294,7 @@ namespace BAKKA_Editor
var evt = TimeEvents.Where(x => beat.MeasureDecimal >= x.Measure).LastOrDefault();
if (evt == null)
evt = TimeEvents[0];
return (int)((60000.0 * 4.0 * evt.TimeSig.Ratio / evt.BPM) * (beat.MeasureDecimal - evt.Measure) + evt.StartTime);
return (int)(((60000.0 / evt.BPM) * 4.0f * evt.TimeSig.Ratio) * (beat.MeasureDecimal - evt.Measure) + evt.StartTime);
}
}
}
}
+42 -27
View File
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Drawing.Drawing2D;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
namespace BAKKA_Editor
{
@@ -15,10 +16,7 @@ namespace BAKKA_Editor
public PointF CenterPoint { get; private set; }
public float Radius { get; private set; }
public float CurrentMeasure { get; set; }
/// <summary>
/// Number of measures in the future that are visible
/// </summary>
public float TotalMeasureShowNotes { get; set; } = 0.5f;
public float Hispeed { get; set; } = 1.5f;
// Pens and Brushes
public Pen BasePen { get; set; }
@@ -74,10 +72,27 @@ namespace BAKKA_Editor
FlairPen = new Pen(Color.FromArgb(FlairTransparency, Color.Yellow), PanelSize.Width * 8.0f / 600.0f);
}
private ArcInfo GetScaledRect(float objectTime)
private float GetTotalMeasureShowNotes(Chart chart)
{
//Convert hispeed to frames
float displayFrames = 73.0f - ((Hispeed - 1.5f) * 10.0f);
//Account for hispeed gimmick
var LatestHispeedChange = chart.Gimmicks.Where(x => x.GimmickType == GimmickType.HiSpeedChange && CurrentMeasure >= x.Measure).LastOrDefault();
if (LatestHispeedChange != null)
{
displayFrames = displayFrames / (float)LatestHispeedChange.HiSpeed;
}
//Add frame time to current time
float EndTimeDisplay = chart.GetTime(new BeatInfo(CurrentMeasure)) + ((displayFrames / 60.0f) * 1000.0f);
//convert time back to a measureDecimal
BeatInfo EndMeasure = chart.GetBeat(EndTimeDisplay);
return EndMeasure.MeasureDecimal - CurrentMeasure;
}
private ArcInfo GetScaledRect(Chart chart, float objectTime)
{
ArcInfo info = new();
float notescaleInit = 1 - ((objectTime - CurrentMeasure) * (1 / TotalMeasureShowNotes)); // Scale from 0-1
float notescaleInit = 1 - ((objectTime - CurrentMeasure) * (1 / GetTotalMeasureShowNotes(chart))); // Scale from 0-1
info.NoteScale = (float)Math.Pow(10.0f, notescaleInit) / 10.0f;
float scaledRectSize = DrawRect.Width * info.NoteScale;
float scaledRadius = scaledRectSize / 2.0f;
@@ -89,9 +104,9 @@ namespace BAKKA_Editor
return info;
}
private ArcInfo GetArcInfo(Note note)
private ArcInfo GetArcInfo(Chart chart, Note note)
{
ArcInfo info = GetScaledRect(note.Measure);
ArcInfo info = GetScaledRect(chart, note.Measure);
info.StartAngle = -note.Position * 6;
info.ArcLength = -note.Size * 6;
if(info.ArcLength != -360)
@@ -191,15 +206,15 @@ namespace BAKKA_Editor
}
}
public void DrawCircle()
public void DrawCircle(Chart chart)
{
// Switch drawing modes
bufGraphics.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// Draw measure circle
for (float meas = (float)Math.Ceiling(CurrentMeasure); (meas - CurrentMeasure) < TotalMeasureShowNotes; meas += 1.0f)
for (float meas = (float)Math.Ceiling(CurrentMeasure); (meas - CurrentMeasure) < GetTotalMeasureShowNotes(chart); meas += 1.0f)
{
var info = GetScaledRect(meas);
var info = GetScaledRect(chart, meas);
if (info.Rect.Width >= 1)
{
bufGraphics.Graphics.DrawEllipse(BeatPen, info.Rect);
@@ -248,11 +263,11 @@ namespace BAKKA_Editor
{
List<Gimmick> drawGimmicks = chart.Gimmicks.Where(
x => x.Measure >= CurrentMeasure
&& x.Measure <= (CurrentMeasure + TotalMeasureShowNotes)).ToList();
&& x.Measure <= (CurrentMeasure + GetTotalMeasureShowNotes(chart))).ToList();
foreach (var gimmick in drawGimmicks)
{
var info = GetScaledRect(gimmick.Measure);
var info = GetScaledRect(chart, gimmick.Measure);
if (info.Rect.Width >= 1)
{
@@ -264,19 +279,19 @@ namespace BAKKA_Editor
public void DrawHolds(Chart chart, bool highlightSelectedNote, int selectedNoteIndex)
{
ArcInfo currentInfo = GetScaledRect(CurrentMeasure);
ArcInfo endInfo = GetScaledRect(CurrentMeasure + TotalMeasureShowNotes);
ArcInfo currentInfo = GetScaledRect(chart, CurrentMeasure);
ArcInfo endInfo = GetScaledRect(chart, CurrentMeasure + GetTotalMeasureShowNotes(chart));
// First, draw holes that start before the viewpoint and have nodes that end after
List<Note> holdNotes = chart.Notes.Where(
x => x.Measure < CurrentMeasure
&& x.NextNote != null
&& x.NextNote.Measure > (CurrentMeasure + TotalMeasureShowNotes)
&& x.NextNote.Measure > (CurrentMeasure + GetTotalMeasureShowNotes(chart))
&& x.IsHold).ToList();
foreach (var note in holdNotes)
{
ArcInfo info = GetArcInfo(note);
ArcInfo nextInfo = GetArcInfo((Note)note.NextNote);
ArcInfo info = GetArcInfo(chart, note);
ArcInfo nextInfo = GetArcInfo(chart, (Note)note.NextNote);
//GraphicsPath path = new GraphicsPath();
//path.AddArc(endInfo.Rect, info.StartAngle, info.ArcLength);
//path.AddArc(currentInfo.Rect, info.StartAngle + info.ArcLength, -info.ArcLength);
@@ -323,16 +338,16 @@ namespace BAKKA_Editor
// Second, draw all the notes on-screen
holdNotes = chart.Notes.Where(
x => x.Measure >= CurrentMeasure
&& x.Measure <= (CurrentMeasure + TotalMeasureShowNotes)
&& x.Measure <= (CurrentMeasure + GetTotalMeasureShowNotes(chart))
&& x.IsHold).ToList();
foreach (var note in holdNotes)
{
ArcInfo info = GetArcInfo(note);
ArcInfo info = GetArcInfo(chart, note);
// If the previous note is off-screen, this case handles that
if (note.PrevNote != null && note.PrevNote.Measure < CurrentMeasure)
{
ArcInfo prevInfo = GetArcInfo((Note)note.PrevNote);
ArcInfo prevInfo = GetArcInfo(chart, (Note)note.PrevNote);
float ratio = (currentInfo.Rect.Width - info.Rect.Width) / (prevInfo.Rect.Width - info.Rect.Width);
float startNoteAngle = info.StartAngle;
float endNoteAngle = prevInfo.StartAngle;
@@ -356,9 +371,9 @@ namespace BAKKA_Editor
}
// If the next note is on-screen, this case handles that
if (note.NextNote != null && note.NextNote.Measure <= (CurrentMeasure + TotalMeasureShowNotes))
if (note.NextNote != null && note.NextNote.Measure <= (CurrentMeasure + GetTotalMeasureShowNotes(chart)))
{
ArcInfo nextInfo = GetArcInfo((Note)note.NextNote);
ArcInfo nextInfo = GetArcInfo(chart, (Note)note.NextNote);
GraphicsPath path = new GraphicsPath();
path.AddArc(info.Rect, info.StartAngle, info.ArcLength);
path.AddArc(nextInfo.Rect, nextInfo.StartAngle + nextInfo.ArcLength, -nextInfo.ArcLength);
@@ -366,9 +381,9 @@ namespace BAKKA_Editor
}
// If the next note is off-screen, this case handles that
if (note.NextNote != null && note.NextNote.Measure > (CurrentMeasure + TotalMeasureShowNotes))
if (note.NextNote != null && note.NextNote.Measure > (CurrentMeasure + GetTotalMeasureShowNotes(chart)))
{
ArcInfo nextInfo = GetArcInfo((Note)note.NextNote);
ArcInfo nextInfo = GetArcInfo(chart, (Note)note.NextNote);
float ratio = (endInfo.Rect.Width - nextInfo.Rect.Width) / (info.Rect.Width - nextInfo.Rect.Width);
float startNoteAngle = nextInfo.StartAngle;
float endNoteAngle = info.StartAngle;
@@ -416,11 +431,11 @@ namespace BAKKA_Editor
{
List<Note> drawNotes = chart.Notes.Where(
x => x.Measure >= CurrentMeasure
&& x.Measure <= (CurrentMeasure + TotalMeasureShowNotes)
&& x.Measure <= (CurrentMeasure + GetTotalMeasureShowNotes(chart))
&& !x.IsHold && !x.IsMask).ToList();
foreach (var note in drawNotes)
{
ArcInfo info = GetArcInfo(note);
ArcInfo info = GetArcInfo(chart, note);
if (info.Rect.Width >= 1)
{
+19 -17
View File
@@ -100,6 +100,7 @@
this.showCursorDuringPlaybackToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.highlightViewedNoteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.selectLastInsertedNoteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.showGimmicksInCircleViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.chartToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.initialChartSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -140,7 +141,6 @@
this.noteNextButton = new System.Windows.Forms.Button();
this.notePrevButton = new System.Windows.Forms.Button();
this.autoSaveTimer = new System.Windows.Forms.Timer(this.components);
this.showGimmicksInCircleViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.beat2Numeric)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.beat1Numeric)).BeginInit();
@@ -846,12 +846,13 @@
//
this.visualHispeedNumeric.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.visualHispeedNumeric.DecimalPlaces = 2;
this.visualHispeedNumeric.DecimalPlaces = 1;
this.visualHispeedNumeric.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.visualHispeedNumeric.Increment = new decimal(new int[] {
5,
1,
0,
0,
131072});
65536});
this.visualHispeedNumeric.Location = new System.Drawing.Point(6, 37);
this.visualHispeedNumeric.Maximum = new decimal(new int[] {
500,
@@ -862,12 +863,13 @@
1,
0,
0,
196608});
65536});
this.visualHispeedNumeric.Name = "visualHispeedNumeric";
this.visualHispeedNumeric.Size = new System.Drawing.Size(102, 23);
this.visualHispeedNumeric.Size = new System.Drawing.Size(102, 29);
this.visualHispeedNumeric.TabIndex = 11;
this.visualHispeedNumeric.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.visualHispeedNumeric.Value = new decimal(new int[] {
5,
15,
0,
0,
65536});
@@ -982,6 +984,16 @@
this.selectLastInsertedNoteToolStripMenuItem.Size = new System.Drawing.Size(233, 22);
this.selectLastInsertedNoteToolStripMenuItem.Text = "Select Last Inserted Note";
//
// showGimmicksInCircleViewToolStripMenuItem
//
this.showGimmicksInCircleViewToolStripMenuItem.Checked = true;
this.showGimmicksInCircleViewToolStripMenuItem.CheckOnClick = true;
this.showGimmicksInCircleViewToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
this.showGimmicksInCircleViewToolStripMenuItem.Name = "showGimmicksInCircleViewToolStripMenuItem";
this.showGimmicksInCircleViewToolStripMenuItem.Size = new System.Drawing.Size(233, 22);
this.showGimmicksInCircleViewToolStripMenuItem.Text = "Show Gimmicks In Circle View";
this.showGimmicksInCircleViewToolStripMenuItem.Click += new System.EventHandler(this.showGimmicksInCircleViewToolStripMenuItem_Click);
//
// chartToolStripMenuItem
//
this.chartToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -1392,16 +1404,6 @@
//
this.autoSaveTimer.Tick += new System.EventHandler(this.autoSaveTimer_Tick);
//
// showGimmicksInCircleViewToolStripMenuItem
//
this.showGimmicksInCircleViewToolStripMenuItem.Checked = true;
this.showGimmicksInCircleViewToolStripMenuItem.CheckOnClick = true;
this.showGimmicksInCircleViewToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
this.showGimmicksInCircleViewToolStripMenuItem.Name = "showGimmicksInCircleViewToolStripMenuItem";
this.showGimmicksInCircleViewToolStripMenuItem.Size = new System.Drawing.Size(233, 22);
this.showGimmicksInCircleViewToolStripMenuItem.Text = "Show Gimmicks In Circle View";
this.showGimmicksInCircleViewToolStripMenuItem.Click += new System.EventHandler(this.showGimmicksInCircleViewToolStripMenuItem_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+6 -10
View File
@@ -129,6 +129,7 @@ namespace BAKKA_Editor
highlightViewedNoteToolStripMenuItem.Checked = userSettings.ViewSettings.HighlightViewedNote;
showGimmicksInCircleViewToolStripMenuItem.Checked = userSettings.ViewSettings.ShowGimmicks;
selectLastInsertedNoteToolStripMenuItem.Checked = userSettings.ViewSettings.SelectLastInsertedNote;
visualHispeedNumeric.Value = (decimal)userSettings.ViewSettings.HispeedSetting;
autoSaveTimer.Interval = userSettings.SaveSettings.AutoSaveInterval * 60000;
autoSaveTimer.Enabled = true;
// Update hotkey labels
@@ -352,6 +353,7 @@ namespace BAKKA_Editor
userSettings.ViewSettings.HighlightViewedNote = highlightViewedNoteToolStripMenuItem.Checked;
userSettings.ViewSettings.ShowGimmicks = showGimmicksInCircleViewToolStripMenuItem.Checked;
userSettings.ViewSettings.SelectLastInsertedNote = selectLastInsertedNoteToolStripMenuItem.Checked;
userSettings.ViewSettings.HispeedSetting = circleView.Hispeed;
userSettings.SaveSettings.AutoSaveInterval = autoSaveTimer.Interval / 60000;
//Update user settings.toml
if (File.Exists("settings.toml"))
@@ -540,7 +542,7 @@ namespace BAKKA_Editor
circleView.DrawMasks(chart);
// Draw base and measure circle.
circleView.DrawCircle();
circleView.DrawCircle(chart);
// Draw degree lines
circleView.DrawDegreeLines();
@@ -975,6 +977,8 @@ namespace BAKKA_Editor
songTrackBar.Value = 0;
songTrackBar.Maximum = (int)currentSong.PlayLength;
playButton.Enabled = true;
measureNumeric.Value = 0;
beat1Numeric.Value = 0;
}
}
}
@@ -1022,14 +1026,6 @@ namespace BAKKA_Editor
measureNumeric.Value = info.Measure;
beat1Numeric.Value = (int)((float)info.Beat / 1920.0f * (float)beat2Numeric.Value);
circleView.CurrentMeasure = info.MeasureDecimal;
// TODO Fix hi-speed (it needs to be able to display multiple hi-speeds in the circle view at once)
//// Change hi-speed, if applicable
//var hispeed = chart.Gimmicks.Where(x => x.Measure <= info.Measure && x.GimmickType == GimmickType.HiSpeedChange).LastOrDefault();
//if (hispeed != null && hispeed.HiSpeed != circleView.TotalMeasureShowNotes)
//{
// visualHispeedNumeric.Value = (decimal)hispeed.HiSpeed;
//}
}
circlePanel.Invalidate();
}
@@ -1126,7 +1122,7 @@ namespace BAKKA_Editor
private void visualHispeedNumeric_ValueChanged(object sender, EventArgs e)
{
circleView.TotalMeasureShowNotes = (float)visualHispeedNumeric.Value;
circleView.Hispeed = (float)visualHispeedNumeric.Value;
circlePanel.Invalidate();
}
+1
View File
@@ -20,6 +20,7 @@ namespace BAKKA_Editor
public bool HighlightViewedNote { get; set; } = true;
public bool SelectLastInsertedNote { get; set; } = true;
public bool ShowGimmicks { get; set; } = true;
public float HispeedSetting { get; set; } = 1.5f;
}
internal class SaveSettings