Skip to content

Commit

Permalink
Add curve import/export, add scroll shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
4yn committed May 3, 2021
1 parent 31602e7 commit 97d05e0
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 18 deletions.
8 changes: 8 additions & 0 deletions Ched.Core/Notes/Slide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public class StepTap : TapBase
private int tickOffset = 1;
[Newtonsoft.Json.JsonProperty]
private bool isVisible = true;
[Newtonsoft.Json.JsonProperty]
private bool isCurve = false;

public int TickOffset
{
Expand All @@ -147,6 +149,12 @@ public bool IsVisible
set { isVisible = value; }
}

public bool IsCurve
{
get { return isCurve; }
set { isCurve = value; }
}

public override bool IsTap { get { return false; } }

public override int Tick { get { return ParentNote.StartTick + TickOffset; } }
Expand Down
1 change: 1 addition & 0 deletions Ched.Drawing/ColorProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ColorProfile
public GradientColor HoldColor { get; set; }
public GradientColor SlideBackgroundColor { get; set; }
public GradientColor SlideColor { get; set; }
public GradientColor SlideCurveColor { get; set; }
public Color SlideLineColor { get; set; }
public GradientColor AirActionColor { get; set; }
public Color AirUpColor { get; set; }
Expand Down
5 changes: 5 additions & 0 deletions Ched.Drawing/NoteGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public static void DrawSlideStep(this DrawingContext dc, RectangleF rect)
dc.Graphics.DrawNote(rect, dc.ColorProfile.SlideColor, dc.ColorProfile.BorderColor);
}

public static void DrawSlideCurve(this DrawingContext dc, RectangleF rect)
{
dc.Graphics.DrawNote(rect, dc.ColorProfile.SlideCurveColor, dc.ColorProfile.BorderColor);
}

/// <summary>
/// SLIDEの背景を描画します。
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions Ched/Ched.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@
<ItemGroup>
<None Include="Resources\information.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\slidecurve.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\BASS.Native.2.4.12.2\build\BASS.Native.targets" Condition="Exists('..\packages\BASS.Native.2.4.12.2\build\BASS.Native.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
19 changes: 17 additions & 2 deletions Ched/Components/Exporter/SusExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,23 @@ public void Export(Stream stream)
Tick = p.Tick,
LaneIndex = p.LaneIndex,
Width = p.Width,
Type = p.IsVisible ? "3" : "5"
}).Take(slide.Note.StepNotes.Count - 1);
Type = p.IsVisible ? "3" : (p.IsCurve ? "4": "5")
}).Take(slide.Note.StepNotes.Count - 1).ToArray();
// Filter out consecutive curves
var lastStepType = steps[0].Type;
for (int i = 1; i < steps.Count(); i++)
{
if (lastStepType == "4" && steps[i].Type == "4")
{
steps[i] = new {
Tick = steps[i].Tick,
LaneIndex = slide.Note.StartLaneIndex,
Width = slide.Note.StartWidth,
Type = "5"
};
}
lastStepType = steps[i].Type;
}
var endNote = slide.Note.StepNotes.OrderBy(p => p.TickOffset).Last();
var end = new[] { new
{
Expand Down
9 changes: 9 additions & 0 deletions Ched/Localization/MainFormStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Ched/Localization/MainFormStrings.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,7 @@
<data name="FollowWhenPlaying" xml:space="preserve">
<value>Scroll When Playing</value>
</data>
<data name="SlideCurve" xml:space="preserve">
<value>SLIDE (CURVE)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Ched/Localization/MainFormStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,7 @@
<data name="FollowWhenPlaying" xml:space="preserve">
<value>再生時にスクロール</value>
</data>
<data name="SlideCurve" xml:space="preserve">
<value>SLIDE(湾曲)</value>
</data>
</root>
5 changes: 4 additions & 1 deletion Ched/Plugins/SusImportPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ private Score ConvertScore(IScoreBookImportPluginArgs args, SusScoreData raw)
};
foreach (var step in steps.Skip(1))
{
/*
if (step.Type == '4')
{
args.ReportDiagnostic(new Diagnostic(DiagnosticSeverity.Warning, $"スライド変曲点は中継点としてインポートされます。(行: {step.LineIndex + 1})"));
args.ReportDiagnostic(new Diagnostic(DiagnosticSeverity.Warning, $"スライド変曲点は中継点としてインポートされます。(行: {step.LineIndex + 1
}
*/
var stepTap = new Slide.StepTap(slide)
{
IsVisible = step.Type == '3' || step.Type == '2',
IsCurve = step.Type == '4',
TickOffset = step.Position.Tick - slide.StartTick
};
stepTap.SetPosition(step.Position.LaneIndex - slide.StartLaneIndex, step.Position.Width - slide.StartWidth);
Expand Down
2 changes: 1 addition & 1 deletion Ched/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
[assembly: ComVisible(false)]
[assembly: Guid("4c0c9f98-6fcf-4d2f-b821-37a66362dc75")]

[assembly: AssemblyVersion("3.0.1.0")]
[assembly: AssemblyVersion("3.0.1.1")]

[assembly: DisableDpiAwareness]
10 changes: 10 additions & 0 deletions Ched/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Ched/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,7 @@
<data name="WarningIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\exclamation.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SlideCurveIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\slidecurve.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added Ched/Resources/slidecurve.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 35 additions & 4 deletions Ched/UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ private ToolStrip CreateNewNoteTypeToolStrip(NoteView noteView)
{
noteView.NewNoteType = NoteType.Slide;
noteView.IsNewSlideStepVisible = false;
noteView.IsNewSlideStepCurve = false;
})
{
DisplayStyle = ToolStripItemDisplayStyle.Image
Expand All @@ -931,6 +932,16 @@ private ToolStrip CreateNewNoteTypeToolStrip(NoteView noteView)
{
noteView.NewNoteType = NoteType.Slide;
noteView.IsNewSlideStepVisible = true;
noteView.IsNewSlideStepCurve = false;
})
{
DisplayStyle = ToolStripItemDisplayStyle.Image
};
var slideCurveButton = new ToolStripButton(MainFormStrings.SlideCurve , Resources.SlideCurveIcon, (s, e) =>
{
noteView.NewNoteType = NoteType.Slide;
noteView.IsNewSlideStepVisible = false;
noteView.IsNewSlideStepCurve = true;
})
{
DisplayStyle = ToolStripItemDisplayStyle.Image
Expand Down Expand Up @@ -1001,8 +1012,9 @@ private ToolStrip CreateNewNoteTypeToolStrip(NoteView noteView)
tapButton.Checked = noteView.NewNoteType.HasFlag(NoteType.Tap);
exTapButton.Checked = noteView.NewNoteType.HasFlag(NoteType.ExTap);
holdButton.Checked = noteView.NewNoteType.HasFlag(NoteType.Hold);
slideButton.Checked = noteView.NewNoteType.HasFlag(NoteType.Slide) && !noteView.IsNewSlideStepVisible;
slideStepButton.Checked = noteView.NewNoteType.HasFlag(NoteType.Slide) && noteView.IsNewSlideStepVisible;
slideButton.Checked = noteView.NewNoteType.HasFlag(NoteType.Slide) && !noteView.IsNewSlideStepVisible && !noteView.IsNewSlideStepCurve;
slideStepButton.Checked = noteView.NewNoteType.HasFlag(NoteType.Slide) && noteView.IsNewSlideStepVisible && !noteView.IsNewSlideStepCurve;
slideCurveButton.Checked = noteView.NewNoteType.HasFlag(NoteType.Slide) && !noteView.IsNewSlideStepVisible && noteView.IsNewSlideStepCurve;
airKind.Checked = noteView.NewNoteType.HasFlag(NoteType.Air);
airActionButton.Checked = noteView.NewNoteType.HasFlag(NoteType.AirAction);
flickButton.Checked = noteView.NewNoteType.HasFlag(NoteType.Flick);
Expand All @@ -1029,7 +1041,7 @@ private ToolStrip CreateNewNoteTypeToolStrip(NoteView noteView)

return new ToolStrip(new ToolStripItem[]
{
tapButton, exTapButton, holdButton, slideButton, slideStepButton, airKind, airActionButton, flickButton, damageButton,
tapButton, exTapButton, holdButton, slideButton, slideStepButton, slideCurveButton, airKind, airActionButton, flickButton, damageButton,
quantizeComboBox
});
}
Expand Down Expand Up @@ -1064,10 +1076,17 @@ private void SetupHotkeys()
case Keys.S:
NoteView.NewNoteType = NoteType.Slide;
NoteView.IsNewSlideStepVisible = false;
NoteView.IsNewSlideStepCurve = false;
break;
case Keys.X:
NoteView.NewNoteType = NoteType.Slide;
NoteView.IsNewSlideStepVisible = true;
NoteView.IsNewSlideStepCurve = false;
break;
case Keys.C:
NoteView.NewNoteType = NoteType.Slide;
NoteView.IsNewSlideStepVisible = false;
NoteView.IsNewSlideStepCurve = true;
break;
case Keys.A:
if (NoteView.EditMode != EditMode.Edit || NoteView.NewNoteType != NoteType.Air || NoteView.AirDirection.VerticalDirection != VerticalAirDirection.Up)
Expand Down Expand Up @@ -1120,9 +1139,21 @@ private void SetupHotkeys()
case Keys.F:
NoteView.NewNoteType = NoteType.Flick;
break;
case Keys.C:
case Keys.V:
NoteView.NewNoteType = NoteType.Damage;
break;
case Keys.D1:
NoteView.ScrollRelative(-1.0);
break;
case Keys.D2:
NoteView.ScrollRelative(-0.1);
break;
case Keys.D3:
NoteView.ScrollRelative(0.1);
break;
case Keys.D4:
NoteView.ScrollRelative(1.0);
break;
}
};
}
Expand Down
34 changes: 31 additions & 3 deletions Ched/UI/NoteView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public partial class NoteView : Control
private NoteType newNoteType = NoteType.Tap;
private AirDirection airDirection = new AirDirection(VerticalAirDirection.Up, HorizontalAirDirection.Center);
private bool isNewSlideStepVisible = true;
private bool isNewSlideStepCurve = true;
private bool playing = false;
private bool isFollowWhenPlaying = false;

Expand Down Expand Up @@ -305,6 +306,16 @@ public bool IsNewSlideStepVisible
}
}

public bool IsNewSlideStepCurve
{
get { return isNewSlideStepCurve; }
set
{
isNewSlideStepCurve = value;
NewNoteTypeChanged?.Invoke(this, EventArgs.Empty);
}
}

public bool Playing
{
get { return playing; }
Expand Down Expand Up @@ -385,6 +396,7 @@ public NoteView(OperationManager manager)
HoldColor = new GradientColor(Color.FromArgb(196, 86, 0), Color.FromArgb(244, 156, 102)),
HoldBackgroundColor = new GradientColor(Color.FromArgb(196, 166, 44, 168), Color.FromArgb(196, 216, 216, 0)),
SlideColor = new GradientColor(Color.FromArgb(0, 16, 138), Color.FromArgb(86, 106, 255)),
SlideCurveColor = new GradientColor(Color.FromArgb(128, 128, 138), Color.FromArgb(128, 128, 255)),
SlideLineColor = Color.FromArgb(196, 0, 214, 192),
SlideBackgroundColor = new GradientColor(Color.FromArgb(196, 166, 44, 168), Color.FromArgb(196, 0, 164, 146)),
AirUpColor = Color.FromArgb(28, 206, 22),
Expand Down Expand Up @@ -1172,7 +1184,8 @@ IObservable<MouseEventArgs> addAirActionHandler()
var newStep = new Slide.StepTap(note)
{
TickOffset = tickOffset,
IsVisible = IsNewSlideStepVisible
IsVisible = IsNewSlideStepVisible,
IsCurve = IsNewSlideStepCurve
};
newStep.SetPosition(laneIndex - note.StartLaneIndex, width - note.StartWidth);
note.StepNotes.Add(newStep);
Expand Down Expand Up @@ -1712,8 +1725,18 @@ protected override void OnPaint(PaintEventArgs pe)
if (!Editable && !step.IsVisible) continue;
if (Notes.GetReferencedAir(step).Count() > 0) break; // AIR付き終点
RectangleF rect = GetRectFromNotePosition(step.Tick, step.LaneIndex, step.Width);
if (step.IsVisible) dc.DrawSlideStep(rect);
else dc.DrawBorder(rect);
if (step.IsVisible)
{
dc.DrawSlideStep(rect);
}
else if (step.IsCurve)
{
dc.DrawSlideCurve(rect);
}
else
{
dc.DrawBorder(rect);
}
}
}

Expand Down Expand Up @@ -2215,6 +2238,11 @@ public void UpdateScore(Score score)
Invalidate();
}

public void ScrollRelative(double distance)
{
HeadTick = HeadTick + (int) ((TailTick - HeadTick) * distance);
}

public class NoteCollection
{
public event EventHandler NoteChanged;
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
![note thickness](./resources/note-thickness.png)

- Pre-included .sus import from [sus2img](https://github.com/paralleltree/sus2img)
- Added bezier curve note
- Import/export with .sus works
- Preview does not work
- Use at most 1 curve between every 2 slide steps
- Added scroll up/down shortcut buttons

Look in the releases panel to the right.

Expand Down
23 changes: 16 additions & 7 deletions resources/keyboard-layout.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
[
[
"~\n`",
"!\n1",
"@\n2",
"#\n3",
"$\n4",
{
"c": "#ce9cff"
},
"1\n\n\n\n\n\nScroll",
"2\n◀️\n\n\n\n\nScroll",
"3\n▶️\n\n\n\n\nScroll",
"4\n\n\n\n\n\nScroll",
{
"c": "#cccccc"
},
"%\n5",
"^\n6",
"&\n7",
Expand Down Expand Up @@ -134,13 +140,16 @@
},
"X\nStep",
{
"c": "#8390fc"
"c": "#a5afc9"
},
"C\nCurve",
{
"c": "#525ed1"
},
"C\nAvoid",
"V\nAvoid",
{
"c": "#cccccc"
},
"V",
"B",
"N",
"M",
Expand Down
Binary file modified resources/keyboard-layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 97d05e0

Please sign in to comment.