private void load(IFrameBasedClock framedClock) { beatmapProcessor = Ruleset.CreateBeatmapProcessor(EditorBeatmap.PlayableBeatmap); EditorBeatmap.HitObjectAdded += addHitObject; EditorBeatmap.HitObjectRemoved += removeHitObject; EditorBeatmap.StartTimeChanged += UpdateHitObject; Config = Dependencies.Get <RulesetConfigCache>().GetConfigFor(Ruleset); try { drawableRulesetWrapper = new DrawableEditRulesetWrapper <TObject>(CreateDrawableRuleset(Ruleset, EditorBeatmap.PlayableBeatmap)) { Clock = framedClock, ProcessCustomClock = false }; } catch (Exception e) { Logger.Error(e, "Could not load beatmap sucessfully!"); return; } var layerBelowRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChildren(new Drawable[] { distanceSnapGridContainer = new Container { RelativeSizeAxes = Axes.Both }, new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both } }); var layerAboveRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChild(blueprintContainer = new BlueprintContainer()); layerContainers.Add(layerBelowRuleset); layerContainers.Add(layerAboveRuleset); RadioButtonCollection toolboxCollection; InternalChild = new GridContainer { RelativeSizeAxes = Axes.Both, Content = new[] { new Drawable[] { new FillFlowContainer { Name = "Sidebar", RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Right = 10 }, Children = new Drawable[] { new ToolboxGroup { Child = toolboxCollection = new RadioButtonCollection { RelativeSizeAxes = Axes.X } } } }, new Container { Name = "Content", RelativeSizeAxes = Axes.Both, Children = new Drawable[] { layerBelowRuleset, drawableRulesetWrapper, layerAboveRuleset } } }, }, ColumnDimensions = new[] { new Dimension(GridSizeMode.Absolute, 200), } }; toolboxCollection.Items = CompositionTools.Select(t => new RadioButton(t.Name, () => selectTool(t))) .Prepend(new RadioButton("Select", () => selectTool(null))) .ToList(); toolboxCollection.Items[0].Select(); blueprintContainer.SelectionChanged += selectionChanged; }
public virtual IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList <Mod> mods = null, TimeSpan?timeout = null) { using (var cancellationSource = createCancellationTokenSource(timeout)) { mods ??= Array.Empty <Mod>(); var rulesetInstance = ruleset.CreateInstance(); IBeatmapConverter converter = CreateBeatmapConverter(Beatmap, rulesetInstance); // Check if the beatmap can be converted if (Beatmap.HitObjects.Count > 0 && !converter.CanConvert()) { throw new BeatmapInvalidForRulesetException($"{nameof(Beatmaps.Beatmap)} can not be converted for the ruleset (ruleset: {ruleset.InstantiationInfo}, converter: {converter})."); } // Apply conversion mods foreach (var mod in mods.OfType <IApplicableToBeatmapConverter>()) { if (cancellationSource.IsCancellationRequested) { throw new BeatmapLoadTimeoutException(BeatmapInfo); } mod.ApplyToBeatmapConverter(converter); } // Convert IBeatmap converted = converter.Convert(cancellationSource.Token); // Apply conversion mods to the result foreach (var mod in mods.OfType <IApplicableAfterBeatmapConversion>()) { if (cancellationSource.IsCancellationRequested) { throw new BeatmapLoadTimeoutException(BeatmapInfo); } mod.ApplyToBeatmap(converted); } // Apply difficulty mods if (mods.Any(m => m is IApplicableToDifficulty)) { foreach (var mod in mods.OfType <IApplicableToDifficulty>()) { if (cancellationSource.IsCancellationRequested) { throw new BeatmapLoadTimeoutException(BeatmapInfo); } mod.ApplyToDifficulty(converted.Difficulty); } } IBeatmapProcessor processor = rulesetInstance.CreateBeatmapProcessor(converted); foreach (var mod in mods.OfType <IApplicableToBeatmapProcessor>()) { mod.ApplyToBeatmapProcessor(processor); } processor?.PreProcess(); // Compute default values for hitobjects, including creating nested hitobjects in-case they're needed try { foreach (var obj in converted.HitObjects) { if (cancellationSource.IsCancellationRequested) { throw new BeatmapLoadTimeoutException(BeatmapInfo); } obj.ApplyDefaults(converted.ControlPointInfo, converted.Difficulty, cancellationSource.Token); } } catch (OperationCanceledException) { throw new BeatmapLoadTimeoutException(BeatmapInfo); } foreach (var mod in mods.OfType <IApplicableToHitObject>()) { foreach (var obj in converted.HitObjects) { if (cancellationSource.IsCancellationRequested) { throw new BeatmapLoadTimeoutException(BeatmapInfo); } mod.ApplyToHitObject(obj); } } processor?.PostProcess(); foreach (var mod in mods.OfType <IApplicableToBeatmap>()) { cancellationSource.Token.ThrowIfCancellationRequested(); mod.ApplyToBeatmap(converted); } return(converted); } }
public void ApplyToBeatmapProcessor(IBeatmapProcessor beatmapProcessor) { var catchProcessor = (CatchBeatmapProcessor)beatmapProcessor; catchProcessor.HardRockOffsets = true; }
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList <Mod> mods = null) { mods ??= Array.Empty <Mod>(); var rulesetInstance = ruleset.CreateInstance(); IBeatmapConverter converter = CreateBeatmapConverter(Beatmap, rulesetInstance); // Check if the beatmap can be converted if (Beatmap.HitObjects.Count > 0 && !converter.CanConvert()) { throw new BeatmapInvalidForRulesetException($"{nameof(Beatmaps.Beatmap)} can not be converted for the ruleset (ruleset: {ruleset.InstantiationInfo}, converter: {converter})."); } // Apply conversion mods foreach (var mod in mods.OfType <IApplicableToBeatmapConverter>()) { mod.ApplyToBeatmapConverter(converter); } // Convert IBeatmap converted = converter.Convert(); // Apply difficulty mods if (mods.Any(m => m is IApplicableToDifficulty)) { converted.BeatmapInfo = converted.BeatmapInfo.Clone(); converted.BeatmapInfo.BaseDifficulty = converted.BeatmapInfo.BaseDifficulty.Clone(); foreach (var mod in mods.OfType <IApplicableToDifficulty>()) { mod.ApplyToDifficulty(converted.BeatmapInfo.BaseDifficulty); } } IBeatmapProcessor processor = rulesetInstance.CreateBeatmapProcessor(converted); processor?.PreProcess(); // Compute default values for hitobjects, including creating nested hitobjects in-case they're needed foreach (var obj in converted.HitObjects) { obj.ApplyDefaults(converted.ControlPointInfo, converted.BeatmapInfo.BaseDifficulty); } foreach (var mod in mods.OfType <IApplicableToHitObject>()) { foreach (var obj in converted.HitObjects) { mod.ApplyToHitObject(obj); } } processor?.PostProcess(); foreach (var mod in mods.OfType <IApplicableToBeatmap>()) { mod.ApplyToBeatmap(converted); } return(converted); }
public virtual IBeatmap GetPlayableBeatmap(IRulesetInfo ruleset, IReadOnlyList <Mod> mods, CancellationToken token) { var rulesetInstance = ruleset.CreateInstance(); if (rulesetInstance == null) { throw new RulesetLoadException("Creating ruleset instance failed when attempting to create playable beatmap."); } IBeatmapConverter converter = CreateBeatmapConverter(Beatmap, rulesetInstance); // Check if the beatmap can be converted if (Beatmap.HitObjects.Count > 0 && !converter.CanConvert()) { throw new BeatmapInvalidForRulesetException($"{nameof(Beatmaps.Beatmap)} can not be converted for the ruleset (ruleset: {ruleset.InstantiationInfo}, converter: {converter})."); } // Apply conversion mods foreach (var mod in mods.OfType <IApplicableToBeatmapConverter>()) { token.ThrowIfCancellationRequested(); mod.ApplyToBeatmapConverter(converter); } // Convert IBeatmap converted = converter.Convert(token); // Apply conversion mods to the result foreach (var mod in mods.OfType <IApplicableAfterBeatmapConversion>()) { token.ThrowIfCancellationRequested(); mod.ApplyToBeatmap(converted); } // Apply difficulty mods if (mods.Any(m => m is IApplicableToDifficulty)) { foreach (var mod in mods.OfType <IApplicableToDifficulty>()) { token.ThrowIfCancellationRequested(); mod.ApplyToDifficulty(converted.Difficulty); } } IBeatmapProcessor processor = rulesetInstance.CreateBeatmapProcessor(converted); foreach (var mod in mods.OfType <IApplicableToBeatmapProcessor>()) { mod.ApplyToBeatmapProcessor(processor); } processor?.PreProcess(); // Compute default values for hitobjects, including creating nested hitobjects in-case they're needed foreach (var obj in converted.HitObjects) { token.ThrowIfCancellationRequested(); obj.ApplyDefaults(converted.ControlPointInfo, converted.Difficulty, token); } foreach (var mod in mods.OfType <IApplicableToHitObject>()) { foreach (var obj in converted.HitObjects) { token.ThrowIfCancellationRequested(); mod.ApplyToHitObject(obj); } } processor?.PostProcess(); foreach (var mod in mods.OfType <IApplicableToBeatmap>()) { token.ThrowIfCancellationRequested(); mod.ApplyToBeatmap(converted); } return(converted); }