From 47f0fdc84a71a301c6a696dbed33f22bf80c1a6c Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 10 Oct 2020 13:23:42 +0200 Subject: [PATCH 01/13] fixed accessing current beatmap from different thread --- .../Views/PatternGallery/PatternGalleryView.xaml.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs index b3146316..7ae6451a 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs @@ -1,8 +1,11 @@ -using Mapping_Tools.Classes.SystemTools; +using Mapping_Tools.Classes; +using Mapping_Tools.Classes.SystemTools; using Mapping_Tools.Classes.SystemTools.QuickRun; using Mapping_Tools.Classes.Tools; using Mapping_Tools.Classes.Tools.PatternGallery; +using Mapping_Tools.Components.Dialogs.CustomDialog; using Mapping_Tools.Viewmodels; +using MaterialDesignThemes.Wpf; using System; using System.ComponentModel; using System.IO; @@ -11,9 +14,6 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using Mapping_Tools.Classes; -using Mapping_Tools.Components.Dialogs.CustomDialog; -using MaterialDesignThemes.Wpf; namespace Mapping_Tools.Views.PatternGallery { /// @@ -82,7 +82,7 @@ private void RunTool(string[] paths, bool quick = false) private string ExportPattern(PatternGalleryVm args, BackgroundWorker worker, DoWorkEventArgs _) { var reader = EditorReaderStuff.GetFullEditorReaderOrNot(); - var editor = EditorReaderStuff.GetNewestVersionOrNot(IOHelper.GetCurrentBeatmapOrCurrentBeatmap(), reader); + var editor = EditorReaderStuff.GetNewestVersionOrNot(args.Paths[0], reader); var patternCount = args.Patterns.Count(o => o.IsSelected); From fd914bf0f88f5d9868e27e8ec7b7512ce53b0705 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 10 Oct 2020 13:23:52 +0200 Subject: [PATCH 02/13] changed default timing overwrite mode --- Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs index fd586675..64683b1c 100644 --- a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs +++ b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs @@ -25,7 +25,7 @@ public class OsuPatternPlacer { /// /// Determines which timing stuff to keep from the pattern. /// - public TimingOverwriteMode TimingOverwriteMode = TimingOverwriteMode.OriginalTimingOnly; + public TimingOverwriteMode TimingOverwriteMode = TimingOverwriteMode.PatternTimingOnly; public bool IncludeHitsounds = true; public bool ScaleToNewCircleSize = false; public bool ScaleToNewTiming = false; From fd0009577c68ff3643b7bde37d7f68a9eb046d6a Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 10 Oct 2020 13:23:42 +0200 Subject: [PATCH 03/13] fixed accessing current beatmap from different thread --- .../Views/PatternGallery/PatternGalleryView.xaml.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs index b3146316..7ae6451a 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs @@ -1,8 +1,11 @@ -using Mapping_Tools.Classes.SystemTools; +using Mapping_Tools.Classes; +using Mapping_Tools.Classes.SystemTools; using Mapping_Tools.Classes.SystemTools.QuickRun; using Mapping_Tools.Classes.Tools; using Mapping_Tools.Classes.Tools.PatternGallery; +using Mapping_Tools.Components.Dialogs.CustomDialog; using Mapping_Tools.Viewmodels; +using MaterialDesignThemes.Wpf; using System; using System.ComponentModel; using System.IO; @@ -11,9 +14,6 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using Mapping_Tools.Classes; -using Mapping_Tools.Components.Dialogs.CustomDialog; -using MaterialDesignThemes.Wpf; namespace Mapping_Tools.Views.PatternGallery { /// @@ -82,7 +82,7 @@ private void RunTool(string[] paths, bool quick = false) private string ExportPattern(PatternGalleryVm args, BackgroundWorker worker, DoWorkEventArgs _) { var reader = EditorReaderStuff.GetFullEditorReaderOrNot(); - var editor = EditorReaderStuff.GetNewestVersionOrNot(IOHelper.GetCurrentBeatmapOrCurrentBeatmap(), reader); + var editor = EditorReaderStuff.GetNewestVersionOrNot(args.Paths[0], reader); var patternCount = args.Patterns.Count(o => o.IsSelected); From 9f9eb9b63dfc5f9756aa6bc813b8c30b25a6f3dd Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 10 Oct 2020 13:23:52 +0200 Subject: [PATCH 04/13] changed default timing overwrite mode --- Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs index 8cea97b3..982c2495 100644 --- a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs +++ b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs @@ -25,7 +25,7 @@ public class OsuPatternPlacer { /// /// Determines which timing stuff to keep from the pattern. /// - public TimingOverwriteMode TimingOverwriteMode = TimingOverwriteMode.OriginalTimingOnly; + public TimingOverwriteMode TimingOverwriteMode = TimingOverwriteMode.PatternTimingOnly; public bool IncludeHitsounds = true; public bool ScaleToNewCircleSize = false; public bool ScaleToNewTiming = false; From 5a4bccdc938cd1fb54993ccc4f7deb952c3ff7ea Mon Sep 17 00:00:00 2001 From: OliBomby Date: Tue, 20 Oct 2020 10:42:43 +0200 Subject: [PATCH 05/13] added all export options to the GUI --- .../PatternGallery/PatternGalleryView.xaml | 108 +++++++++++++++++- Mapping Tools/viewmodels/PatternGalleryVm.cs | 10 +- 2 files changed, 113 insertions(+), 5 deletions(-) diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml index dbd5adbd..8754b667 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml @@ -6,8 +6,9 @@ xmlns:local="clr-namespace:Mapping_Tools.Views" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:domain="clr-namespace:Mapping_Tools.Components.Domain" + xmlns:viewmodels="clr-namespace:Mapping_Tools.Viewmodels" x:Name="This" - mc:Ignorable="d" Width="900" Height="700" d:DataContext="{d:DesignData PatternGalleryVm}"> + mc:Ignorable="d" Width="900" Height="700" d:DataContext="{d:DesignInstance viewmodels:PatternGalleryVm}"> @@ -19,7 +20,13 @@ - + + + + + + + @@ -27,7 +34,7 @@ - + @@ -129,7 +136,100 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public double Padding { get => OsuPatternPlacer.Padding; @@ -70,11 +70,19 @@ public PatternOverwriteMode PatternOverwriteMode { set => Set(ref OsuPatternPlacer.PatternOverwriteMode, value); } + [JsonIgnore] + public IEnumerable PatternOverwriteModes => + Enum.GetValues(typeof(PatternOverwriteMode)).Cast(); + public TimingOverwriteMode TimingOverwriteMode { get => OsuPatternPlacer.TimingOverwriteMode; set => Set(ref OsuPatternPlacer.TimingOverwriteMode, value); } + [JsonIgnore] + public IEnumerable TimingOverwriteModes => + Enum.GetValues(typeof(TimingOverwriteMode)).Cast(); + public bool IncludeHitsounds { get => OsuPatternPlacer.IncludeHitsounds; set => Set(ref OsuPatternPlacer.IncludeHitsounds, value); From 18c4c533f9d4fd59d2a8d296e958905a126040e6 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Mon, 26 Oct 2020 15:33:52 +0100 Subject: [PATCH 06/13] Update PatternGalleryView.xaml --- Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml index 8754b667..65497ddc 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml @@ -21,9 +21,9 @@ - - + + From 075ffaeea6a0c990d41ac0be251a73c4ff9587d9 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Thu, 29 Oct 2020 15:11:15 +0100 Subject: [PATCH 07/13] enable pattern gallery --- Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs index 3f64ba2f..b3146316 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs @@ -20,7 +20,7 @@ namespace Mapping_Tools.Views.PatternGallery { /// Interactielogica voor PatternGalleryView.xaml /// [SmartQuickRunUsage(SmartQuickRunTargets.Always)] - [HiddenTool] + //[HiddenTool] public partial class PatternGalleryView : ISavable, IQuickRun, IHaveExtraProjectMenuItems { public string AutoSavePath => Path.Combine(MainWindow.AppDataPath, "patterngalleryproject.json"); From 90ba4abce0e77e75a63665434d73f8145dc6b8fe Mon Sep 17 00:00:00 2001 From: OliBomby Date: Thu, 29 Oct 2020 15:30:01 +0100 Subject: [PATCH 08/13] refactor --- .../Tools/PatternGallery/OsuPatternMaker.cs | 43 ++++++++++--------- .../Tools/PatternGallery/OsuPatternPlacer.cs | 5 ++- Mapping Tools/viewmodels/PatternGalleryVm.cs | 10 +++-- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternMaker.cs b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternMaker.cs index 3af2a314..32486fab 100644 --- a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternMaker.cs +++ b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternMaker.cs @@ -8,7 +8,10 @@ namespace Mapping_Tools.Classes.Tools.PatternGallery { public class OsuPatternMaker { - public double Padding { get; set; } = 5; + /// + /// Extra time in milliseconds around patterns for including a wider range of objects in the target beatmap. + /// + public double Padding = 5; public OsuPattern FromSelectedWithSave(Beatmap beatmap, OsuPatternFileHandler fileHandler, string name) { var osuPattern = FromSelected(beatmap, out var patternBeatmap, name); @@ -81,25 +84,6 @@ public OsuPattern FromFile(string filePath, string name) { return FromBeatmap(patternBeatmap, name); } - public OsuPattern FromBeatmap(Beatmap beatmap, string name) { - // Generate a file name and save the pattern - var now = DateTime.Now; - var fileName = GenerateUniquePatternFileName(name, now); - - var startTime = beatmap.GetHitObjectStartTime(); - var endTime = beatmap.GetHitObjectEndTime(); - - return new OsuPattern { - Name = name, - CreationTime = now, - LastUsedTime = now, - FileName = fileName, - ObjectCount = beatmap.HitObjects.Count, - Duration = TimeSpan.FromMilliseconds(endTime - startTime), - BeatLength = beatmap.BeatmapTiming.GetBeatLength(startTime, endTime, true) - }; - } - public OsuPattern FromObjectsWithSave(List hitObjects, List timingPoints, OsuPatternFileHandler fileHandler, string name, TimingPoint firstUnInheritedTimingPoint = null, double globalSv = 1.4, GameMode gameMode = GameMode.Standard) { var osuPattern = FromObjects(hitObjects, timingPoints, out var patternBeatmap, name, @@ -120,6 +104,25 @@ public OsuPattern FromObjects(List hitObjects, List timi return FromBeatmap(patternBeatmap, name); } + public OsuPattern FromBeatmap(Beatmap beatmap, string name) { + // Generate a file name and save the pattern + var now = DateTime.Now; + var fileName = GenerateUniquePatternFileName(name, now); + + var startTime = beatmap.GetHitObjectStartTime(); + var endTime = beatmap.GetHitObjectEndTime(); + + return new OsuPattern { + Name = name, + CreationTime = now, + LastUsedTime = now, + FileName = fileName, + ObjectCount = beatmap.HitObjects.Count, + Duration = TimeSpan.FromMilliseconds(endTime - startTime), + BeatLength = beatmap.BeatmapTiming.GetBeatLength(startTime, endTime, true) + }; + } + #region Helpers private static string GenerateUniquePatternFileName(string name, DateTime time) { diff --git a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs index 64683b1c..8278a41c 100644 --- a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs +++ b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs @@ -72,6 +72,7 @@ public void PlaceOsuPattern(Beatmap patternBeatmap, Beatmap beatmap, double offs patternBeatmap = patternBeatmap.DeepCopy(); } + // Do the offset if (Math.Abs(offset) > Precision.DOUBLE_EPSILON) { patternBeatmap.OffsetTime(offset); } @@ -79,7 +80,7 @@ public void PlaceOsuPattern(Beatmap patternBeatmap, Beatmap beatmap, double offs // We adjust the pattern first so it alligns with the beatmap. // The right timing is applied and optional pre-processing is applied. // Sliderends and object timingpoints get recalculated. - AdjustPatternToBeatmap(patternBeatmap, beatmap, out var parts, out var timingPointsChanges); + PreparePattern(patternBeatmap, beatmap, out var parts, out var timingPointsChanges); // Keep just the timing point changes which are inside the parts. // These timing point changes have everything that is necessary for inside the parts of the pattern. (even timing) @@ -220,7 +221,7 @@ private static TimingPointsChange GetBpmChange(TimingPoint tp, double? customOff /// /// /// - private void AdjustPatternToBeatmap(Beatmap patternBeatmap, Beatmap beatmap, out List parts, out List timingPointsChanges) { + private void PreparePattern(Beatmap patternBeatmap, Beatmap beatmap, out List parts, out List timingPointsChanges) { double patternStartTime = patternBeatmap.GetHitObjectStartTime(); double patternEndTime = patternBeatmap.GetHitObjectEndTime(); diff --git a/Mapping Tools/viewmodels/PatternGalleryVm.cs b/Mapping Tools/viewmodels/PatternGalleryVm.cs index fda7eac3..f6950add 100644 --- a/Mapping Tools/viewmodels/PatternGalleryVm.cs +++ b/Mapping Tools/viewmodels/PatternGalleryVm.cs @@ -44,17 +44,21 @@ public bool? IsAllItemsSelected { [JsonIgnore] public OsuPatternMaker OsuPatternMaker { get; set; } - #region Export Options - [JsonIgnore] public OsuPatternPlacer OsuPatternPlacer { get; set; } + #region Options + /// /// Extra time in millseconds around the patterns for deleting parts of the original map. /// public double Padding { get => OsuPatternPlacer.Padding; - set => Set(ref OsuPatternPlacer.Padding, value); + set { + if (Set(ref OsuPatternPlacer.Padding, value)) { + OsuPatternMaker.Padding = value; + } + } } /// From 33b59ab88d043ddb010a5d8ac77e9154164f29af Mon Sep 17 00:00:00 2001 From: OliBomby Date: Thu, 29 Oct 2020 17:21:26 +0100 Subject: [PATCH 09/13] added export time options --- .../Tools/PatternGallery/ExportTimeMode.cs | 7 +++++ .../Tools/PatternGallery/OsuPatternPlacer.cs | 1 - Mapping Tools/Mapping_Tools.csproj | 1 + .../PatternGallery/PatternGalleryView.xaml | 17 ++++++++++- .../PatternGallery/PatternGalleryView.xaml.cs | 30 +++++++++++++++---- Mapping Tools/viewmodels/PatternGalleryVm.cs | 26 ++++++++++++++++ 6 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 Mapping Tools/Classes/Tools/PatternGallery/ExportTimeMode.cs diff --git a/Mapping Tools/Classes/Tools/PatternGallery/ExportTimeMode.cs b/Mapping Tools/Classes/Tools/PatternGallery/ExportTimeMode.cs new file mode 100644 index 00000000..9d0e79e6 --- /dev/null +++ b/Mapping Tools/Classes/Tools/PatternGallery/ExportTimeMode.cs @@ -0,0 +1,7 @@ +namespace Mapping_Tools.Classes.Tools.PatternGallery { + public enum ExportTimeMode { + Pattern, + Custom, + Current + } +} \ No newline at end of file diff --git a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs index 9c0a9353..17f090ca 100644 --- a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs +++ b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs @@ -93,7 +93,6 @@ public void PlaceOsuPattern(Beatmap patternBeatmap, Beatmap beatmap, double offs } } - Console.WriteLine(beatmap.HitObjects.Count); // Add timingpoint changes for each hitobject to make sure they still have the wanted SV and hitsounds (especially near the edges of parts) // It is possible for the timingpoint of a hitobject at the start of a part to be outside of the part, so this fixes issues related to that timingPointsChanges.AddRange( diff --git a/Mapping Tools/Mapping_Tools.csproj b/Mapping Tools/Mapping_Tools.csproj index 86c35214..2c16cfe7 100644 --- a/Mapping Tools/Mapping_Tools.csproj +++ b/Mapping Tools/Mapping_Tools.csproj @@ -403,6 +403,7 @@ + diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml index 65497ddc..9132869b 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml @@ -140,7 +140,22 @@ - + + + + + + + + + + diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs index 7ae6451a..fe2e9cc3 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs @@ -14,6 +14,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using Editor_Reader; namespace Mapping_Tools.Views.PatternGallery { /// @@ -81,7 +82,26 @@ private void RunTool(string[] paths, bool quick = false) } private string ExportPattern(PatternGalleryVm args, BackgroundWorker worker, DoWorkEventArgs _) { - var reader = EditorReaderStuff.GetFullEditorReaderOrNot(); + EditorReader reader; + double exportTime = 0; + bool usePatternOffset = false; + switch (args.ExportTimeMode) { + case ExportTimeMode.Current: + reader = EditorReaderStuff.GetFullEditorReader(); + exportTime = reader.EditorTime(); + break; + case ExportTimeMode.Pattern: + reader = EditorReaderStuff.GetFullEditorReaderOrNot(); + usePatternOffset = true; + break; + case ExportTimeMode.Custom: + reader = EditorReaderStuff.GetFullEditorReaderOrNot(); + exportTime = args.CustomExportTime; + break; + default: + throw new ArgumentOutOfRangeException(nameof(ExportTimeMode), "Invalid value encountered"); + } + var editor = EditorReaderStuff.GetNewestVersionOrNot(args.Paths[0], reader); var patternCount = args.Patterns.Count(o => o.IsSelected); @@ -89,14 +109,14 @@ private string ExportPattern(PatternGalleryVm args, BackgroundWorker worker, DoW if (patternCount == 0) throw new Exception("No pattern has been selected to export."); + var patternPlacer = args.OsuPatternPlacer; foreach (var pattern in args.Patterns.Where(o => o.IsSelected)) { var patternBeatmap = pattern.GetPatternBeatmap(args.FileHandler); - var patternPlacer = args.OsuPatternPlacer; - if (reader != null && false) { - patternPlacer.PlaceOsuPatternAtTime(patternBeatmap, editor.Beatmap, reader.EditorTime(), false); - } else { + if (usePatternOffset) { patternPlacer.PlaceOsuPattern(patternBeatmap, editor.Beatmap, protectBeatmapPattern:false); + } else { + patternPlacer.PlaceOsuPatternAtTime(patternBeatmap, editor.Beatmap, exportTime, false); } // Increase pattern use count and time diff --git a/Mapping Tools/viewmodels/PatternGalleryVm.cs b/Mapping Tools/viewmodels/PatternGalleryVm.cs index 0222fb95..0d9a4577 100644 --- a/Mapping Tools/viewmodels/PatternGalleryVm.cs +++ b/Mapping Tools/viewmodels/PatternGalleryVm.cs @@ -49,6 +49,29 @@ public bool? IsAllItemsSelected { #region Options + private ExportTimeMode _exportTimeMode; + public ExportTimeMode ExportTimeMode { + get => _exportTimeMode; + set { + if (Set(ref _exportTimeMode, value)) { + RaisePropertyChanged(nameof(CustomExportTimeVisible)); + } + } + } + + [JsonIgnore] + public IEnumerable ExportTimeModes => + Enum.GetValues(typeof(ExportTimeMode)).Cast(); + + private double _customExportTime; + public double CustomExportTime { + get => _customExportTime; + set => Set(ref _customExportTime, value); + } + + [JsonIgnore] + public bool CustomExportTimeVisible => ExportTimeMode == ExportTimeMode.Custom; + /// /// Extra time in milliseconds around the patterns for deleting parts of the original map. /// @@ -166,6 +189,9 @@ public PatternGalleryVm() { OsuPatternMaker = new OsuPatternMaker(); OsuPatternPlacer = new OsuPatternPlacer(); + ExportTimeMode = ExportTimeMode.Current; + CustomExportTime = 0; + AddCodeCommand = new CommandImplementation( async _ => { try { From 839ffdf17dd5b2f6ca8894cf6a4dd208b65558d5 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Thu, 29 Oct 2020 19:36:42 +0100 Subject: [PATCH 10/13] automatically using current beatmap when using current time export --- Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs index fe2e9cc3..1ec5558c 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs @@ -56,7 +56,9 @@ protected override void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e private void Start_Click(object sender, RoutedEventArgs e) { - RunTool(MainWindow.AppWindow.GetCurrentMaps(), quick: false); + RunTool(ViewModel.ExportTimeMode == ExportTimeMode.Current + ? new[] { IOHelper.GetCurrentBeatmapOrCurrentBeatmap() } + : MainWindow.AppWindow.GetCurrentMaps(), quick: false); } public void QuickRun() From 5c8231cf0ba4dd71c50127363b598b9ac4ce4827 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Fri, 30 Oct 2020 16:35:47 +0100 Subject: [PATCH 11/13] fixed duration resnap --- Mapping Tools/Classes/BeatmapHelper/Timing.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mapping Tools/Classes/BeatmapHelper/Timing.cs b/Mapping Tools/Classes/BeatmapHelper/Timing.cs index 1ea738dd..5e34b8ed 100644 --- a/Mapping Tools/Classes/BeatmapHelper/Timing.cs +++ b/Mapping Tools/Classes/BeatmapHelper/Timing.cs @@ -305,7 +305,7 @@ public double ResnapDuration(double time, double duration, IEnumerable Date: Sat, 31 Oct 2020 17:51:48 +0100 Subject: [PATCH 12/13] added fix bpm sv & fixed object snapping & fixed/improved a bunch of other stuff --- .../Classes/BeatmapHelper/HitObject.cs | 13 +- Mapping Tools/Classes/BeatmapHelper/Timing.cs | 3 +- .../Tools/PatternGallery/OsuPatternPlacer.cs | 188 ++++++++++-------- .../PatternGallery/PatternGalleryView.xaml | 9 +- Mapping Tools/viewmodels/PatternGalleryVm.cs | 16 +- 5 files changed, 128 insertions(+), 101 deletions(-) diff --git a/Mapping Tools/Classes/BeatmapHelper/HitObject.cs b/Mapping Tools/Classes/BeatmapHelper/HitObject.cs index 09604d41..90359a83 100644 --- a/Mapping Tools/Classes/BeatmapHelper/HitObject.cs +++ b/Mapping Tools/Classes/BeatmapHelper/HitObject.cs @@ -197,8 +197,9 @@ public double EndTime { set => SetEndTime(value); } // Includes all repeats - private double GetEndTime() { - return Math.Floor(Time + TemporalLength * Repeat + Precision.DOUBLE_EPSILON); + public double GetEndTime(bool floor = true) { + var endTime = Time + TemporalLength * Repeat; + return floor ? Math.Floor(endTime + Precision.DOUBLE_EPSILON) : endTime; } private void SetEndTime(double value) { @@ -507,8 +508,12 @@ public void ChangeTemporalTime(Timing timing, double deltaTemporalTime) { // Change TemporalLength += deltaTemporalTime; - // Clean up body objects - if (TimelineObjects.Count > 0) TimelineObjects.Last().Time = EndTime; + // Move body objects + for (int i = 0; i <= Math.Min(Repeat, TimelineObjects.Count - 1); i++) { + double time = Math.Floor(Time + TemporalLength * i); + TimelineObjects[i].Time = time; + } + BodyHitsounds.RemoveAll(s => s.Offset >= EndTime); } diff --git a/Mapping Tools/Classes/BeatmapHelper/Timing.cs b/Mapping Tools/Classes/BeatmapHelper/Timing.cs index 5e34b8ed..255d4423 100644 --- a/Mapping Tools/Classes/BeatmapHelper/Timing.cs +++ b/Mapping Tools/Classes/BeatmapHelper/Timing.cs @@ -538,7 +538,8 @@ public double CalculateSliderTemporalLength(double time, double length) { } public double CalculateSliderTemporalLength(double time, double length, double sv) { - return (length * GetMpBAtTime(time) * (double.IsNaN(sv) ? -100 : sv)) / (-10000 * SliderMultiplier); + return (length * GetMpBAtTime(time) * (double.IsNaN(sv) ? -100 : MathHelper.Clamp(sv, -1000, -10))) / + (-10000 * SliderMultiplier); } /// diff --git a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs index 17f090ca..42bde846 100644 --- a/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs +++ b/Mapping Tools/Classes/Tools/PatternGallery/OsuPatternPlacer.cs @@ -29,9 +29,10 @@ public class OsuPatternPlacer { public bool IncludeHitsounds = true; public bool ScaleToNewCircleSize = false; public bool ScaleToNewTiming = false; - public bool SnapToNewTiming = false; + public bool SnapToNewTiming = true; public IBeatDivisor[] BeatDivisors = RationalBeatDivisor.GetDefaultBeatDivisors(); - public bool FixGlobalSV = false; + public bool FixGlobalSv = true; + public bool FixBpmSv = true; public bool FixColourHax = false; public bool FixStackLeniency = false; public bool FixTickRate = false; @@ -125,30 +126,21 @@ public void PlaceOsuPattern(Beatmap patternBeatmap, Beatmap beatmap, double offs private List PartitionBeatmap(Beatmap beatmap) { var parts = new List(); - var firstTime = beatmap.HitObjects[0].Time; - var lastObject = beatmap.HitObjects[0]; - double lastGap = 0; - foreach (var ho in beatmap.HitObjects.Skip(1)) { - var gap = beatmap.BeatmapTiming.GetBeatLength(lastObject.EndTime, ho.Time); - - if (gap >= PartingDistance) { - parts.Add(new Part(firstTime, - lastObject.EndTime, - lastGap, - beatmap.BeatmapTiming.GetBeatLength(firstTime, lastObject.EndTime) - )); - - firstTime = ho.Time; - lastGap = gap; - } + int startIndex = 0; + for (int i = 1; i < beatmap.HitObjects.Count; i++) { + var gap = beatmap.BeatmapTiming.GetBeatLength(beatmap.HitObjects[i-1].GetEndTime(), beatmap.HitObjects[i].Time); + + if (Precision.AlmostBigger(gap, PartingDistance)) { + parts.Add(new Part(beatmap.HitObjects[startIndex].Time, + beatmap.HitObjects[i-1].GetEndTime(), + beatmap.HitObjects.GetRange(startIndex, i - startIndex))); - lastObject = ho; + startIndex = i; + } } - parts.Add(new Part(firstTime, - lastObject.EndTime, - lastGap, - beatmap.BeatmapTiming.GetBeatLength(firstTime, lastObject.EndTime) - )); + parts.Add(new Part(beatmap.HitObjects[startIndex].Time, + beatmap.HitObjects[beatmap.HitObjects.Count-1].GetEndTime(), + beatmap.HitObjects.GetRange(startIndex, beatmap.HitObjects.Count - startIndex))); return parts; } @@ -156,15 +148,12 @@ private List PartitionBeatmap(Beatmap beatmap) { private class Part { public double StartTime; public double EndTime; - public double BeatGap; - public double BeatLength; public List HitObjects; - public Part(double startTime, double endTime, double beatGap, double beatLength) { + public Part(double startTime, double endTime, List hitObjects) { StartTime = startTime; EndTime = endTime; - BeatGap = beatGap; - BeatLength = beatLength; + HitObjects = hitObjects; } } @@ -232,24 +221,63 @@ private void PreparePattern(Beatmap patternBeatmap, Beatmap beatmap, out List { - new Part(patternStartTime, patternEndTime, 0, patternTiming.GetBeatLength(patternStartTime, patternEndTime)) + new Part(patternStartTime, patternEndTime, patternBeatmap.HitObjects) }; } - Timing newTiming = new Timing(beatmap.BeatmapTiming.SliderMultiplier); + // Collect Kiai toggles and SliderVelocity changes for mania/taiko + List kiaiToggles = new List(); + List svChanges = new List(); + bool lastKiai = false; + double lastSV = -100; + foreach (TimingPoint tp in patternTiming.TimingPoints) { + if (tp.Kiai != lastKiai) { + kiaiToggles.Add(tp.Copy()); + lastKiai = tp.Kiai; + } + if (tp.Uninherited) { + lastSV = -100; + } else { + if (Math.Abs(tp.MpB - lastSV) > Precision.DOUBLE_EPSILON) { + svChanges.Add(tp.Copy()); + lastSV = tp.MpB; + } + } + } + + // Fix SV for the new global SV + if (FixGlobalSv) { + var globalSvFactor = originalTiming.SliderMultiplier / patternTiming.SliderMultiplier; + foreach (HitObject ho in patternBeatmap.HitObjects) { + ho.SliderVelocity *= globalSvFactor; + } + foreach (TimingPoint tp in svChanges) { + tp.MpB *= globalSvFactor; + } + } + + Timing newTiming = new Timing(originalTiming.SliderMultiplier); // Construct a new timing which is a mix of the beatmap and the pattern. // If ScaleToNewTiming then use beat relative values to determine the duration of timing sections in the pattern. // ScaleToNewTiming must scale all the partitions, timingpoints, hitobjects, and events (if applicable). + var lastEndTime = double.NegativeInfinity; foreach (var part in parts) { var startTime = part.StartTime; var endTime = part.EndTime; // Subtract one to omit BPM changes right on the end of the part. + // Add the redlines in between patterns + newTiming.AddRange(originalTiming.GetRedlinesInRange(lastEndTime, startTime, false)); + var startOriginalRedline = originalTiming.GetRedlineAtTime(startTime); // Minus 1 the offset so its possible to have a custom BPM redline right on the start time if you have @@ -324,7 +352,40 @@ private void PreparePattern(Beatmap patternBeatmap, Beatmap beatmap, out List o.GetEndTime()); + part.EndTime = endTime; + // Update the start time because a resnap could've moved the time of the first hitobject + startTime = part.HitObjects.Min(o => o.Time); + part.StartTime = startTime; + + // Add a redline at the end of the pattern to make sure the BPM goes back to normal after the pattern. var endOriginalRedline = originalTiming.GetRedlineAtTime(endTime); var endPartRedline = inPartRedlines.LastOrDefault() ?? startPartRedline; if (Math.Abs(endPartRedline.MpB - endOriginalRedline.MpB) > Precision.DOUBLE_EPSILON) { @@ -335,51 +396,8 @@ private void PreparePattern(Beatmap patternBeatmap, Beatmap beatmap, out List kiaiToggles = new List(); - List svChanges = new List(); - bool lastKiai = false; - double lastSV = -100; - foreach (TimingPoint tp in patternTiming.TimingPoints) { - if (tp.Kiai != lastKiai) { - kiaiToggles.Add(tp.Copy()); - lastKiai = tp.Kiai; - } - if (tp.Uninherited) { - lastSV = -100; - } else { - if (Math.Abs(tp.MpB - lastSV) > Precision.DOUBLE_EPSILON) { - svChanges.Add(tp.Copy()); - lastSV = tp.MpB; - } - } - } - - // TODO Scale everything to the new timing starting from the first object in the pattern and keeping the number of beats the same. - if (ScaleToNewTiming) { - } - - // Fix SV for the new global SV - if (FixGlobalSV) { - var globalSvFactor = originalTiming.SliderMultiplier / patternTiming.SliderMultiplier; - foreach (HitObject ho in patternBeatmap.HitObjects) { - ho.SliderVelocity *= globalSvFactor; - } - foreach (TimingPoint tp in svChanges) { - tp.MpB *= globalSvFactor; - } - } - - // Recalculate temporal length and re-assign redline for the sliderend resnapping later - // TODO The temporal length needs to be calculated during the timing generating part so it can return the original BPM at the right time (fuck) - foreach (var ho in patternBeatmap.HitObjects) { - ho.UnInheritedTimingPoint = newTiming.GetRedlineAtTime(ho.Time); - if (ho.IsSlider) { - ho.TemporalLength = newTiming.CalculateSliderTemporalLength(ho.Time, ho.PixelLength, ho.SliderVelocity); - } + lastEndTime = endTime; } // Resnap everything to the new timing. @@ -402,29 +420,23 @@ private void PreparePattern(Beatmap patternBeatmap, Beatmap beatmap, out List(); // Add redlines var redlines = newTiming.Redlines; - foreach (TimingPoint tp in redlines) { - timingPointsChanges.Add(new TimingPointsChange(tp, mpb: true, meter: true, unInherited: true, omitFirstBarLine: true)); - } + timingPointsChanges = redlines.Select(tp => new TimingPointsChange(tp, mpb: true, meter: true, unInherited: true, omitFirstBarLine: true)).ToList(); // Add SliderVelocity changes for taiko and mania if (patternMode == GameMode.Taiko || patternMode == GameMode.Mania) { - foreach (TimingPoint tp in svChanges) { - timingPointsChanges.Add(new TimingPointsChange(tp, mpb: true)); - } + timingPointsChanges.AddRange(svChanges.Select(tp => new TimingPointsChange(tp, mpb: true))); } // Add Kiai toggles - foreach (TimingPoint tp in kiaiToggles) { - timingPointsChanges.Add(new TimingPointsChange(tp, kiai: true)); - } + timingPointsChanges.AddRange(kiaiToggles.Select(tp => new TimingPointsChange(tp, kiai: true))); // Add Hitobject stuff foreach (HitObject ho in patternBeatmap.HitObjects) { diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml index 9132869b..5a3cfd8b 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml @@ -223,15 +223,18 @@ - - + IsChecked="{Binding FixGlobalSv}"/> + diff --git a/Mapping Tools/viewmodels/PatternGalleryVm.cs b/Mapping Tools/viewmodels/PatternGalleryVm.cs index 0d9a4577..01b3170d 100644 --- a/Mapping Tools/viewmodels/PatternGalleryVm.cs +++ b/Mapping Tools/viewmodels/PatternGalleryVm.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Text.RegularExpressions; using Mapping_Tools.Classes.BeatmapHelper; +using Mapping_Tools.Classes.MathUtil; using Mapping_Tools.Components.Dialogs.CustomDialog; using MaterialDesignThemes.Wpf; @@ -135,9 +136,14 @@ public IBeatDivisor[] BeatDivisors { set => Set(ref OsuPatternPlacer.BeatDivisors, value); } - public bool FixGlobalSV { - get => OsuPatternPlacer.FixGlobalSV; - set => Set(ref OsuPatternPlacer.FixGlobalSV, value); + public bool FixGlobalSv { + get => OsuPatternPlacer.FixGlobalSv; + set => Set(ref OsuPatternPlacer.FixGlobalSv, value); + } + + public bool FixBpmSv { + get => OsuPatternPlacer.FixBpmSv; + set => Set(ref OsuPatternPlacer.FixBpmSv, value); } public bool FixColourHax { @@ -161,8 +167,8 @@ public double CustomScale { } public double CustomRotate { - get => OsuPatternPlacer.CustomRotate; - set => Set(ref OsuPatternPlacer.CustomRotate, value); + get => MathHelper.RadiansToDegrees(OsuPatternPlacer.CustomRotate); + set => Set(ref OsuPatternPlacer.CustomRotate, MathHelper.DegreesToRadians(value)); } #endregion From eae31f6b44aae10b28a1fce9ad1316181241281b Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sat, 31 Oct 2020 23:08:47 +0100 Subject: [PATCH 13/13] number increase --- Mapping Tools/Properties/AssemblyInfo.cs | 4 ++-- Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Mapping Tools/Properties/AssemblyInfo.cs b/Mapping Tools/Properties/AssemblyInfo.cs index b394ab78..06b1d39b 100644 --- a/Mapping Tools/Properties/AssemblyInfo.cs +++ b/Mapping Tools/Properties/AssemblyInfo.cs @@ -51,7 +51,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.1.1")] -[assembly: AssemblyFileVersion("1.7.1.1")] +[assembly: AssemblyVersion("1.7.1.2")] +[assembly: AssemblyFileVersion("1.7.1.2")] [assembly: NeutralResourcesLanguage("en")] diff --git a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs index 1ec5558c..41655132 100644 --- a/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs +++ b/Mapping Tools/Views/PatternGallery/PatternGalleryView.xaml.cs @@ -21,7 +21,7 @@ namespace Mapping_Tools.Views.PatternGallery { /// Interactielogica voor PatternGalleryView.xaml /// [SmartQuickRunUsage(SmartQuickRunTargets.Always)] - //[HiddenTool] + [HiddenTool] public partial class PatternGalleryView : ISavable, IQuickRun, IHaveExtraProjectMenuItems { public string AutoSavePath => Path.Combine(MainWindow.AppDataPath, "patterngalleryproject.json");