Skip to content

Commit

Permalink
arrows playback controls
Browse files Browse the repository at this point in the history
  • Loading branch information
ImAxel0 committed May 26, 2024
1 parent 70a24fd commit 32fcc99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Openthesia/ProgramData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Openthesia;

public class ProgramData
{
public static readonly string ProgramVersion = "1.0.0";
public static readonly string ProgramVersion = "1.1.0";
public static IntPtr LogoImage;
public static string SettingsPath = Path.Combine(KnownFolders.RoamingAppData.Path, "Openthesia", "Settings.json");
public static string HandsDataPath = Path.Combine(KnownFolders.RoamingAppData.Path, "Openthesia\\HandsData");
Expand Down
25 changes: 15 additions & 10 deletions Openthesia/ScreenCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,6 @@ private static void GetPlaybackInputs()
MidiPlayer.Playback.Speed = cValue;
}
}
/*
if (ImGui.IsMouseDown(ImGuiMouseButton.Right) && ImGui.GetIO().MouseDelta.Y != 0 && !MidiPlayer.IsTimerRunning)
{
float n = ImGui.GetIO().MouseDelta.Y < 0 ? -1 : 1;
if (UpDirection) n = -n;
MidiPlayer.Seconds = Math.Clamp(MidiPlayer.Seconds + n, 0, (int)MidiPlayer.Playback.GetDuration<MetricTimeSpan>().TotalSeconds);
MidiPlayer.Playback.MoveToTime(new MetricTimeSpan(0, 0, (int)MidiPlayer.Seconds));
MidiPlayer.Timer = MidiPlayer.Seconds * 100 * _fallSpeed;
} */

if (ImGui.IsKeyPressed(ImGuiKey.Space, false))
{
Expand All @@ -501,6 +492,20 @@ private static void GetPlaybackInputs()
{
_showTextNotes = !_showTextNotes;
}

if (ImGui.IsKeyPressed(ImGuiKey.RightArrow))
{
var newTime = Math.Clamp(MidiPlayer.Seconds + 1, 0, (float)MidiFileData.MidiFile.GetDuration<MetricTimeSpan>().TotalSeconds);
MidiPlayer.Playback.MoveToTime(new MetricTimeSpan(0, 0, (int)newTime));
MidiPlayer.Timer = (int)newTime * 100 * _fallSpeed;
}

if (ImGui.IsKeyPressed(ImGuiKey.LeftArrow))
{
var newTime = Math.Clamp(MidiPlayer.Seconds - 1, 0, (float)MidiFileData.MidiFile.GetDuration<MetricTimeSpan>().TotalSeconds);
MidiPlayer.Playback.MoveToTime(new MetricTimeSpan(0, 0, (int)newTime));
MidiPlayer.Timer = (int)newTime * 100 * _fallSpeed;
}
}

private static void GetInputs()
Expand Down Expand Up @@ -661,7 +666,7 @@ public static void RenderScreen(bool playMode = false)
{
MidiPlayer.Playback.MoveToTime(new MetricTimeSpan(0, 0, (int)MidiPlayer.Seconds));
//MidiPlayer.Playback.MoveToTime(new MetricTimeSpan(MidiPlayer.Time.Milliseconds));
MidiPlayer.Timer = MidiPlayer.Seconds * 100 * _fallSpeed;
MidiPlayer.Timer = (int)MidiPlayer.Seconds * 100 * _fallSpeed;
}

ImGui.SetNextWindowPos(new(ImGui.GetIO().DisplaySize.X / 2 - 85, CanvasPos.Y + 50));
Expand Down

0 comments on commit 32fcc99

Please sign in to comment.