···448448 {
449449 if (screens.Last() != screen)
450450 throw new InvalidOperationException("Disposal order was wrong");
451451+451452 screens.Remove(screen);
452453 };
453454
···6565 {
6666 if (!activator_cache.TryGetValue(type, out var existing))
6767 return activator_cache[type] = new DependencyActivator(type);
6868+6869 return existing;
6970 }
7071
···7878 var result = container.Get(typeof(T), info);
7979 if (result == null)
8080 return default;
8181+8182 return (T)container.Get(typeof(T), info);
8283 }
8384
+4-1
osu.Framework/Allocation/InvokeOnDisposal.cs
···2121 /// Constructs a new instance, capturing the given action to be run during disposal.
2222 /// </summary>
2323 /// <param name="action">The action to invoke during disposal.</param>
2424- public InvokeOnDisposal(Action action) => this.action = action ?? throw new ArgumentNullException(nameof(action));
2424+ public InvokeOnDisposal(Action action)
2525+ {
2626+ this.action = action ?? throw new ArgumentNullException(nameof(action));
2727+ }
25282629 #region IDisposable Support
2730
+4-1
osu.Framework/Allocation/ValueInvokeOnDisposal.cs
···2323 /// Constructs a new instance, capturing the given action to be run during disposal.
2424 /// </summary>
2525 /// <param name="action">The action to invoke during disposal.</param>
2626- public ValueInvokeOnDisposal(Action action) => this.action = action ?? throw new ArgumentNullException(nameof(action));
2626+ public ValueInvokeOnDisposal(Action action)
2727+ {
2828+ this.action = action ?? throw new ArgumentNullException(nameof(action));
2929+ }
27302831 #region IDisposable Support
2932
···8787 {
8888 if (value < 0)
8989 throw new ArgumentException("Track length must be >= 0.", nameof(value));
9090+9091 length = value;
9192 }
9293 }
+5-1
osu.Framework/Audio/Track/Waveform.cs
···2727 /// The data stream is iteratively decoded to provide this many points per iteration so as to not exceed BASS's internal buffer size.
2828 /// </summary>
2929 private const int points_per_iteration = 100000;
3030+3031 private const int bytes_per_sample = 4;
31323233 /// <summary>
···201202 int kernelWidth = (int)(pointsPerGeneratedPoint * kernel_width_factor) + 1;
202203203204 float[] filter = new float[kernelWidth + 1];
204204- for (int i = 0; i < filter.Length; ++i) {
205205+206206+ for (int i = 0; i < filter.Length; ++i)
207207+ {
205208 filter[i] = (float)Blur.EvalGaussian(i, pointsPerGeneratedPoint);
206209 }
207210···299302 {
300303 if (isDisposed)
301304 return;
305305+302306 isDisposed = true;
303307304308 cancelSource?.Cancel();
+6-5
osu.Framework/Bindables/Bindable.cs
···127127 {
128128 if (!(them is Bindable<T> tThem))
129129 throw new InvalidCastException($"Can't bind to a bindable of type {them.GetType()} from a bindable of type {GetType()}.");
130130+130131 BindTo(tThem);
131132 }
132133···134135 {
135136 if (!(them is Bindable<T> tThem))
136137 throw new InvalidCastException($"Can't bind to a bindable of type {them.GetType()} from a bindable of type {GetType()}.");
138138+137139 BindTo(tThem);
138140 }
139141···143145 /// </summary>
144146 public Bindable<T> BindTarget
145147 {
146146- set { BindTo(value); }
148148+ set => BindTo(value);
147149 }
148150149151 /// <summary>
···235237 Bindings?.ForEachAlive(b =>
236238 {
237239 if (b == source) return;
240240+238241 b.SetValue(previousValue, value, bypassChecks, this);
239242 });
240243 if (EqualityComparer<T>.Default.Equals(beforePropagation, value))
···249252 Bindings?.ForEachAlive(b =>
250253 {
251254 if (b == source) return;
255255+252256 b.SetDisabled(disabled, bypassChecks, this);
253257 });
254258 if (beforePropagation == disabled)
···299303300304 public string Description { get; set; }
301305302302- public override string ToString()
303303- {
304304- return value?.ToString() ?? string.Empty;
305305- }
306306+ public override string ToString() => value?.ToString() ?? string.Empty;
306307307308 /// <summary>
308309 /// Create an unbound clone of this bindable.
+20-1
osu.Framework/Bindables/BindableNumber.cs
···4646 precision = DefaultPrecision;
4747 }
48484949-5049 private T precision;
51505251 public T Precision
···243242 case TypeCode.Byte:
244243 var byteBindable = this as BindableNumber<byte>;
245244 if (byteBindable == null) throw new ArgumentNullException(nameof(byteBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
245245+246246 byteBindable.Value = Convert.ToByte(val);
247247 break;
248248 case TypeCode.SByte:
249249 var sbyteBindable = this as BindableNumber<sbyte>;
250250 if (sbyteBindable == null) throw new ArgumentNullException(nameof(sbyteBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
251251+251252 sbyteBindable.Value = Convert.ToSByte(val);
252253 break;
253254 case TypeCode.UInt16:
254255 var ushortBindable = this as BindableNumber<ushort>;
255256 if (ushortBindable == null) throw new ArgumentNullException(nameof(ushortBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
257257+256258 ushortBindable.Value = Convert.ToUInt16(val);
257259 break;
258260 case TypeCode.Int16:
259261 var shortBindable = this as BindableNumber<short>;
260262 if (shortBindable == null) throw new ArgumentNullException(nameof(shortBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
263263+261264 shortBindable.Value = Convert.ToInt16(val);
262265 break;
263266 case TypeCode.UInt32:
264267 var uintBindable = this as BindableNumber<uint>;
265268 if (uintBindable == null) throw new ArgumentNullException(nameof(uintBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
269269+266270 uintBindable.Value = Convert.ToUInt32(val);
267271 break;
268272 case TypeCode.Int32:
269273 var intBindable = this as BindableNumber<int>;
270274 if (intBindable == null) throw new ArgumentNullException(nameof(intBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
275275+271276 intBindable.Value = Convert.ToInt32(val);
272277 break;
273278 case TypeCode.UInt64:
274279 var ulongBindable = this as BindableNumber<ulong>;
275280 if (ulongBindable == null) throw new ArgumentNullException(nameof(ulongBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
281281+276282 ulongBindable.Value = Convert.ToUInt64(val);
277283 break;
278284 case TypeCode.Int64:
279285 var longBindable = this as BindableNumber<long>;
280286 if (longBindable == null) throw new ArgumentNullException(nameof(longBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
287287+281288 longBindable.Value = Convert.ToInt64(val);
282289 break;
283290 case TypeCode.Single:
284291 var floatBindable = this as BindableNumber<float>;
285292 if (floatBindable == null) throw new ArgumentNullException(nameof(floatBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
293293+286294 floatBindable.Value = Convert.ToSingle(val);
287295 break;
288296 case TypeCode.Double:
289297 var doubleBindable = this as BindableNumber<double>;
290298 if (doubleBindable == null) throw new ArgumentNullException(nameof(doubleBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
299299+291300 doubleBindable.Value = Convert.ToDouble(val);
292301 break;
293302 }
···301310 case TypeCode.Byte:
302311 var byteBindable = this as BindableNumber<byte>;
303312 if (byteBindable == null) throw new ArgumentNullException(nameof(byteBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
313313+304314 byteBindable.Value += Convert.ToByte(val);
305315 break;
306316 case TypeCode.SByte:
307317 var sbyteBindable = this as BindableNumber<sbyte>;
308318 if (sbyteBindable == null) throw new ArgumentNullException(nameof(sbyteBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
319319+309320 sbyteBindable.Value += Convert.ToSByte(val);
310321 break;
311322 case TypeCode.UInt16:
312323 var ushortBindable = this as BindableNumber<ushort>;
313324 if (ushortBindable == null) throw new ArgumentNullException(nameof(ushortBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
325325+314326 ushortBindable.Value += Convert.ToUInt16(val);
315327 break;
316328 case TypeCode.Int16:
317329 var shortBindable = this as BindableNumber<short>;
318330 if (shortBindable == null) throw new ArgumentNullException(nameof(shortBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
331331+319332 shortBindable.Value += Convert.ToInt16(val);
320333 break;
321334 case TypeCode.UInt32:
322335 var uintBindable = this as BindableNumber<uint>;
323336 if (uintBindable == null) throw new ArgumentNullException(nameof(uintBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
337337+324338 uintBindable.Value += Convert.ToUInt32(val);
325339 break;
326340 case TypeCode.Int32:
327341 var intBindable = this as BindableNumber<int>;
328342 if (intBindable == null) throw new ArgumentNullException(nameof(intBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
343343+329344 intBindable.Value += Convert.ToInt32(val);
330345 break;
331346 case TypeCode.UInt64:
332347 var ulongBindable = this as BindableNumber<ulong>;
333348 if (ulongBindable == null) throw new ArgumentNullException(nameof(ulongBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
349349+334350 ulongBindable.Value += Convert.ToUInt64(val);
335351 break;
336352 case TypeCode.Int64:
337353 var longBindable = this as BindableNumber<long>;
338354 if (longBindable == null) throw new ArgumentNullException(nameof(longBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
355355+339356 longBindable.Value += Convert.ToInt64(val);
340357 break;
341358 case TypeCode.Single:
342359 var floatBindable = this as BindableNumber<float>;
343360 if (floatBindable == null) throw new ArgumentNullException(nameof(floatBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
361361+344362 floatBindable.Value += Convert.ToSingle(val);
345363 break;
346364 case TypeCode.Double:
347365 var doubleBindable = this as BindableNumber<double>;
348366 if (doubleBindable == null) throw new ArgumentNullException(nameof(doubleBindable), $"Generic type {typeof(T)} does not match actual bindable type {GetType()}.");
367367+349368 doubleBindable.Value += Convert.ToDouble(val);
350369 break;
351370 }
···2121 {
2222 if (!isValid)
2323 throw new InvalidOperationException($"May not query {nameof(Value)} of an invalid {nameof(Cached<T>)}.");
2424+2425 return value;
2526 }
2627
···331331332332 int i = y.Depth.CompareTo(x.Depth);
333333 if (i != 0) return i;
334334+334335 return x.ChildID.CompareTo(y.ChildID);
335336 }
336337···347348348349 int i = y.Depth.CompareTo(x.Depth);
349350 if (i != 0) return i;
351351+350352 return y.ChildID.CompareTo(x.ChildID);
351353 }
352354···568570 case LoadState.Loading:
569571 if (Thread.CurrentThread != LoadThread)
570572 throw new InvalidThreadForChildMutationException(LoadState, "not on the load thread");
573573+571574 break;
572575 case LoadState.Ready:
573576 // Allow mutating from the load thread since parenting containers may still be in the loading state
574577 if (Thread.CurrentThread != LoadThread && !ThreadSafety.IsUpdateThread)
575578 throw new InvalidThreadForChildMutationException(LoadState, "not on the load or update threads");
579579+576580 break;
577581 case LoadState.Loaded:
578582 if (!ThreadSafety.IsUpdateThread)
579583 throw new InvalidThreadForChildMutationException(LoadState, "not on the update thread");
584584+580585 break;
581586 }
582587 }
···985990 {
986991 if (forceLocalVertexBatch == value)
987992 return;
993993+988994 forceLocalVertexBatch = value;
989995990996 Invalidate(Invalidation.DrawNode);
···11001106 {
11011107 if (base.RemoveCompletedTransforms == value)
11021108 return;
11091109+11031110 base.RemoveCompletedTransforms = value;
1104111111051112 foreach (var c in internalChildren)
···12061213 // Select a cheaper contains method when we don't need rounded edges.
12071214 if (cRadius == 0.0f)
12081215 return base.Contains(screenSpacePos);
12161216+12091217 return DrawRectangle.Shrink(cRadius).DistanceSquared(ToLocalSpace(screenSpacePos)) <= cRadius * cRadius;
12101218 }
12111219···15691577 {
15701578 if ((AutoSizeAxes & Axes.X) != 0)
15711579 throw new InvalidOperationException($"The width of a {nameof(CompositeDrawable)} with {nameof(AutoSizeAxes)} should only be manually set if it is relative to its parent.");
15801580+15721581 base.Width = value;
15731582 }
15741583 }
···15861595 {
15871596 if ((AutoSizeAxes & Axes.Y) != 0)
15881597 throw new InvalidOperationException($"The height of a {nameof(CompositeDrawable)} with {nameof(AutoSizeAxes)} should only be manually set if it is relative to its parent.");
15981598+15891599 base.Height = value;
15901600 }
15911601 }
···16051615 {
16061616 if ((AutoSizeAxes & Axes.Both) != 0)
16071617 throw new InvalidOperationException($"The Size of a {nameof(CompositeDrawable)} with {nameof(AutoSizeAxes)} should only be manually set if it is relative to its parent.");
16181618+16081619 base.Size = value;
16091620 }
16101621 }
···144144145145 placeholderDrawable = (Drawable)cb.DynamicInvoke(args);
146146 }
147147+147148 index = placeholderEnd + 1;
148149 }
149150 }
···153154 strPiece = str.Substring(index);
154155 index = str.Length;
155156 }
157157+156158 // unescape stuff
157159 strPiece = strPiece.Replace("[[", "[").Replace("]]", "]");
158160 sprites.AddRange(AddString(new TextLine(strPiece, line.CreationParameters), newLineIsParagraph));
···161163 {
162164 if (placeholderDrawable.Parent != null)
163165 throw new ArgumentException("All icons used by a customizable text container must not have a parent. If you get this error message it means one of your icon factories created a drawable that was already added to another parent, or you used a drawable as a placeholder that already has another parent or you used an index-based placeholder (like [2]) more than once.");
166166+164167 AddInternal(placeholderDrawable);
165168 }
166169 }
···228228 throw new InvalidOperationException(
229229 $"All drawables in a {nameof(FillFlowContainer)} must use the same RelativeAnchorPosition for the given {nameof(FillDirection)}({Direction}) ({ourRelativeAnchor.Y} != {c.RelativeAnchorPosition.Y}). "
230230 + $"Consider using multiple instances of {nameof(FillFlowContainer)} if this is intentional.");
231231+231232 break;
232233 case FillDirection.Horizontal:
233234 if (c.RelativeAnchorPosition.X != ourRelativeAnchor.X)
234235 throw new InvalidOperationException(
235236 $"All drawables in a {nameof(FillFlowContainer)} must use the same RelativeAnchorPosition for the given {nameof(FillDirection)}({Direction}) ({ourRelativeAnchor.X} != {c.RelativeAnchorPosition.X}). "
236237 + $"Consider using multiple instances of {nameof(FillFlowContainer)} if this is intentional.");
238238+237239 break;
238240 default:
239241 if (c.RelativeAnchorPosition != ourRelativeAnchor)
240242 throw new InvalidOperationException(
241243 $"All drawables in a {nameof(FillFlowContainer)} must use the same RelativeAnchorPosition for the given {nameof(FillDirection)}({Direction}) ({ourRelativeAnchor} != {c.RelativeAnchorPosition}). "
242244 + $"Consider using multiple instances of {nameof(FillFlowContainer)} if this is intentional.");
245245+243246 break;
244247 }
245248
···3333 public float LayoutDuration
3434 {
3535 get => AutoSizeDuration * 2;
3636- set
3737- {
3838- //coupling with autosizeduration allows us to smoothly transition our size
3939- //when no children are left to dictate autosize.
4040- AutoSizeDuration = value / 2;
4141- }
3636+ set => AutoSizeDuration = value / 2;
4237 }
43384439 private Vector2 maximumSize;
···115110 {
116111 if (!layoutChildren.ContainsKey(drawable))
117112 throw new InvalidOperationException($"Cannot change layout position of drawable which is not contained within this {nameof(FlowContainer<T>)}.");
113113+118114 layoutChildren[drawable] = newPosition;
119115 InvalidateLayout();
120116 }
···3333 {
3434 if (text == value)
3535 return;
3636+3637 text = value;
37383839 contentCache.Invalidate();
···190191 /// <param name="level">The level in the document of <paramref name="paragraphBlock"/>.
191192 /// 0 for the root level, 1 for first-level items in a list, 2 for second-level items in a list, etc.</param>
192193 /// <returns>The visualiser.</returns>
193193- protected virtual MarkdownParagraph CreateParagraph(ParagraphBlock paragraphBlock, int level) => new MarkdownParagraph(paragraphBlock, level);
194194+ protected virtual MarkdownParagraph CreateParagraph(ParagraphBlock paragraphBlock, int level) => new MarkdownParagraph(paragraphBlock);
194195195196 /// <summary>
196197 /// Creates the visualiser for a <see cref="QuoteBlock"/>.
···217218 /// Creates the visualiser for a <see cref="ListBlock"/>.
218219 /// </summary>
219220 /// <returns>The visualiser.</returns>
220220- protected virtual MarkdownList CreateList(ListBlock listBlock) => new MarkdownList(listBlock);
221221+ protected virtual MarkdownList CreateList(ListBlock listBlock) => new MarkdownList();
221222222223 /// <summary>
223224 /// Creates the visualiser for a horizontal separator.
224225 /// </summary>
225226 /// <returns>The visualiser.</returns>
226226- protected virtual MarkdownSeparator CreateSeparator(ThematicBreakBlock thematicBlock) => new MarkdownSeparator(thematicBlock);
227227+ protected virtual MarkdownSeparator CreateSeparator(ThematicBreakBlock thematicBlock) => new MarkdownSeparator();
227228228229 /// <summary>
229230 /// Creates the visualiser for an element that isn't implemented.
···11// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
22// See the LICENCE file in the repository root for full licence text.
3344-using Markdig.Syntax;
54using osuTK;
6576namespace osu.Framework.Graphics.Containers.Markdown
···1514 /// </code>
1615 public class MarkdownList : FillFlowContainer
1716 {
1818- public MarkdownList(ListBlock listBlock)
1717+ public MarkdownList()
1918 {
2019 AutoSizeAxes = Axes.Y;
2120 RelativeSizeAxes = Axes.X;
···11// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
22// See the LICENCE file in the repository root for full licence text.
3344-using Markdig.Syntax;
54using osu.Framework.Allocation;
65using osu.Framework.Graphics.Shapes;
76using osuTK.Graphics;
···1615 /// </code>
1716 public class MarkdownSeparator : CompositeDrawable
1817 {
1919- public MarkdownSeparator(ThematicBreakBlock thematicBlock)
1818+ public MarkdownSeparator()
2019 {
2120 AutoSizeAxes = Axes.Y;
2221 RelativeSizeAxes = Axes.X;
···7676 // are still our own responsibility to handle.
7777 nestedTtcChildDrawables.UnionWith(
7878 ((IEnumerable<IDrawable>)newChildDrawables).Reverse()
7979- .SkipWhile(d => d.Parent == this || !(d.Parent is TSelf) && !nestedTtcChildDrawables.Contains(d.Parent)));
7979+ .SkipWhile(d => d.Parent == this || !(d.Parent is TSelf) && !nestedTtcChildDrawables.Contains(d.Parent)));
80808181 // Ignore drawables whose effects are managed by a nested effect container.
8282 if (nestedTtcChildDrawables.Contains(candidate))
8383 continue;
84848585- TTarget target = candidate as TTarget;
8686- if (target != null && target.IsHovered)
8585+ if (candidate is TTarget target && target.IsHovered)
8786 // We found a valid candidate; keep track of it
8887 targetChildren.Add(target);
8988 }
+6-1
osu.Framework/Graphics/Cursor/TooltipContainer.cs
···164164 private double lastRecordedPositionTime;
165165166166 private IHasTooltip lastCandidate;
167167+167168 /// <summary>
168169 /// Determines which drawable should currently receive a tooltip, taking into account
169170 /// <see cref="AppearDelay"/> and <see cref="AppearRadius"/>. Returns null if no valid
···183184 recentMousePositions.Clear();
184185 lastCandidate = targetCandidate;
185186 }
187187+186188 if (targetCandidate == null)
187189 return null;
188190···203205 // we can skip this if the appear-delay is set to 0, since then tooltips can appear instantly and we don't need to wait to record enough positions.
204206 if (appearDelay > 0 && (recentMousePositions.Count == 0 || lastRecordedPositionTime - recentMousePositions[0].Time < appearDelay - positionRecordInterval))
205207 return null;
208208+206209 recentMousePositions.RemoveAll(t => Time.Current - t.Time > appearDelay);
207210208211 // For determining whether to show a tooltip we first select only those positions
···304307 };
305308 }
306309307307- public virtual void Refresh() { }
310310+ public virtual void Refresh()
311311+ {
312312+ }
308313309314 /// <summary>
310315 /// Called whenever the tooltip appears. When overriding do not forget to fade in.
+12-16
osu.Framework/Graphics/Drawable.cs
···165165 private void unbindAllBindables()
166166 {
167167 if (unbindComplete) return;
168168+168169 unbindComplete = true;
169170170171 foreach (var type in GetType().EnumerateBaseTypes())
···942943 set
943944 {
944945 if (fillMode == value) return;
946946+945947 fillMode = value;
946948947949 Invalidate(Invalidation.DrawSize);
···965967 set
966968 {
967969 if (shear == value) return;
970970+968971 if (!Validation.IsFinite(value)) throw new ArgumentException($@"{nameof(Shear)} must be finite, but is {value}.");
969972970973 shear = value;
···984987 set
985988 {
986989 if (value == rotation) return;
990990+987991 if (!Validation.IsFinite(value)) throw new ArgumentException($@"{nameof(Rotation)} must be finite, but is {value}.");
988992989993 rotation = value;
···12741278 {
12751279 if (blending.Equals(value))
12761280 return;
12811281+12771282 blending = value;
1278128312791284 Invalidate(Invalidation.Colour);
···13371342 set
13381343 {
13391344 if (lifetimeStart == value) return;
13451345+13401346 lifetimeStart = value;
13411347 LifetimeChanged?.Invoke(this);
13421348 }
···13511357 set
13521358 {
13531359 if (lifetimeEnd == value) return;
13601360+13541361 lifetimeEnd = value;
13551362 LifetimeChanged?.Invoke(this);
13561363 }
···14601467 {
14611468 if (proxy != null)
14621469 throw new InvalidOperationException("Multiple proxies are not supported.");
14701470+14631471 return proxy = new ProxyDrawable(this);
14641472 }
14651473···17811789 /// </summary>
17821790 /// <param name="input">A vector in local coordinates.</param>
17831791 /// <returns>The vector in screen coordinates.</returns>
17841784- public Vector2 ToScreenSpace(Vector2 input)
17851785- {
17861786- return Vector2Extensions.Transform(input, DrawInfo.Matrix);
17871787- }
17921792+ public Vector2 ToScreenSpace(Vector2 input) => Vector2Extensions.Transform(input, DrawInfo.Matrix);
1788179317891794 /// <summary>
17901795 /// Accepts a rectangle in local coordinates and converts it to a quad in screen space.
17911796 /// </summary>
17921797 /// <param name="input">A rectangle in local coordinates.</param>
17931798 /// <returns>The quad in screen coordinates.</returns>
17941794- public Quad ToScreenSpace(RectangleF input)
17951795- {
17961796- return Quad.FromRectangle(input) * DrawInfo.Matrix;
17971797- }
17991799+ public Quad ToScreenSpace(RectangleF input) => Quad.FromRectangle(input) * DrawInfo.Matrix;
1798180017991801 /// <summary>
18001802 /// Accepts a vector in screen coordinates and converts it to coordinates in local space.
18011803 /// </summary>
18021804 /// <param name="screenSpacePos">A vector in screen coordinates.</param>
18031805 /// <returns>The vector in local coordinates.</returns>
18041804- public Vector2 ToLocalSpace(Vector2 screenSpacePos)
18051805- {
18061806- return Vector2Extensions.Transform(screenSpacePos, DrawInfo.MatrixInverse);
18071807- }
18061806+ public Vector2 ToLocalSpace(Vector2 screenSpacePos) => Vector2Extensions.Transform(screenSpacePos, DrawInfo.MatrixInverse);
1808180718091808 /// <summary>
18101809 /// Accepts a quad in screen coordinates and converts it to coordinates in local space.
18111810 /// </summary>
18121811 /// <param name="screenSpaceQuad">A quad in screen coordinates.</param>
18131812 /// <returns>The quad in local coordinates.</returns>
18141814- public Quad ToLocalSpace(Quad screenSpaceQuad)
18151815- {
18161816- return screenSpaceQuad * DrawInfo.MatrixInverse;
18171817- }
18131813+ public Quad ToLocalSpace(Quad screenSpaceQuad) => screenSpaceQuad * DrawInfo.MatrixInverse;
1818181418191815 #endregion
18201816
···5151 /// <summary>
5252 /// Distance squared from an arbitrary point p to this line.
5353 /// </summary>
5454- public float DistanceSquaredToPoint(Vector2 p)
5555- {
5656- return Vector2Extensions.DistanceSquared(p, ClosestPointTo(p));
5757- }
5454+ public float DistanceSquaredToPoint(Vector2 p) => Vector2Extensions.DistanceSquared(p, ClosestPointTo(p));
58555956 /// <summary>
6057 /// Distance from an arbitrary point to this line.
6158 /// </summary>
6262- public float DistanceToPoint(Vector2 p)
6363- {
6464- return Vector2Extensions.Distance(p, ClosestPointTo(p));
6565- }
5959+ public float DistanceToPoint(Vector2 p) => Vector2Extensions.Distance(p, ClosestPointTo(p));
66606761 /// <summary>
6862 /// Finds the point closest to the given point on this line.
···9286 return pB;
9387 }
94889595- public Matrix4 WorldMatrix()
9696- {
9797- return Matrix4.CreateRotationZ(Theta) * Matrix4.CreateTranslation(StartPoint.X, StartPoint.Y, 0);
9898- }
8989+ public Matrix4 WorldMatrix() => Matrix4.CreateRotationZ(Theta) * Matrix4.CreateTranslation(StartPoint.X, StartPoint.Y, 0);
999010091 /// <summary>
10192 /// It's the end of the world as we know it
10293 /// </summary>
103103- public Matrix4 EndWorldMatrix()
104104- {
105105- return Matrix4.CreateRotationZ(Theta) * Matrix4.CreateTranslation(EndPoint.X, EndPoint.Y, 0);
106106- }
9494+ public Matrix4 EndWorldMatrix() => Matrix4.CreateRotationZ(Theta) * Matrix4.CreateTranslation(EndPoint.X, EndPoint.Y, 0);
10795108108- public object Clone()
109109- {
110110- return MemberwiseClone();
111111- }
9696+ public object Clone() => MemberwiseClone();
11297 }
11398}
···4747 /// </summary>
4848 /// <param name="other">The other range to test against.</param>
4949 /// <returns>Whether the two ranges overlap.</returns>
5050- public bool Overlaps(ProjectionRange other)
5151- {
5252- return Min <= other.Max && Max >= other.Min;
5353- }
5050+ public bool Overlaps(ProjectionRange other) => Min <= other.Max && Max >= other.Min;
5451 }
5552}
+22-38
osu.Framework/Graphics/Primitives/Quad.cs
···3535 public static implicit operator Quad(RectangleI r) => FromRectangle(r);
3636 public static implicit operator Quad(RectangleF r) => FromRectangle(r);
37373838- public static Quad FromRectangle(RectangleF rectangle)
3939- {
4040- return new Quad(new Vector2(rectangle.Left, rectangle.Top),
3838+ public static Quad FromRectangle(RectangleF rectangle) =>
3939+ new Quad(new Vector2(rectangle.Left, rectangle.Top),
4140 new Vector2(rectangle.Right, rectangle.Top),
4241 new Vector2(rectangle.Left, rectangle.Bottom),
4342 new Vector2(rectangle.Right, rectangle.Bottom));
4444- }
45434646- public static Quad operator *(Quad r, Matrix3 m)
4747- {
4848- return new Quad(
4444+ public static Quad operator *(Quad r, Matrix3 m) =>
4545+ new Quad(
4946 Vector2Extensions.Transform(r.TopLeft, m),
5047 Vector2Extensions.Transform(r.TopRight, m),
5148 Vector2Extensions.Transform(r.BottomLeft, m),
5249 Vector2Extensions.Transform(r.BottomRight, m));
5353- }
54505551 public Matrix2 BasisTransform
5652 {
···106102 public Vector2[] Vertices => new[] { TopLeft, TopRight, BottomRight, BottomLeft };
107103 public Vector2[] AxisVertices => Vertices;
108104109109- public bool Contains(Vector2 pos)
110110- {
111111- return
112112- new Triangle(BottomRight, BottomLeft, TopRight).Contains(pos) ||
113113- new Triangle(TopLeft, TopRight, BottomLeft).Contains(pos);
114114- }
105105+ public bool Contains(Vector2 pos) =>
106106+ new Triangle(BottomRight, BottomLeft, TopRight).Contains(pos) ||
107107+ new Triangle(TopLeft, TopRight, BottomLeft).Contains(pos);
115108116109 public float Area => new Triangle(BottomRight, BottomLeft, TopRight).Area + new Triangle(TopLeft, TopRight, BottomLeft).Area;
117110···135128 }
136129 }
137130138138- public bool Intersects(IConvexPolygon other)
139139- {
140140- return (this as IConvexPolygon).Intersects(other);
141141- }
131131+ public bool Intersects(IConvexPolygon other) => (this as IConvexPolygon).Intersects(other);
142132143143- public bool Equals(Quad other)
144144- {
145145- return
146146- TopLeft == other.TopLeft &&
147147- TopRight == other.TopRight &&
148148- BottomLeft == other.BottomLeft &&
149149- BottomRight == other.BottomRight;
150150- }
133133+ public bool Equals(Quad other) =>
134134+ TopLeft == other.TopLeft &&
135135+ TopRight == other.TopRight &&
136136+ BottomLeft == other.BottomLeft &&
137137+ BottomRight == other.BottomRight;
151138152152- public bool AlmostEquals(Quad other)
153153- {
154154- return
155155- Precision.AlmostEquals(TopLeft.X, other.TopLeft.X) &&
156156- Precision.AlmostEquals(TopLeft.Y, other.TopLeft.Y) &&
157157- Precision.AlmostEquals(TopRight.X, other.TopRight.X) &&
158158- Precision.AlmostEquals(TopRight.Y, other.TopRight.Y) &&
159159- Precision.AlmostEquals(BottomLeft.X, other.BottomLeft.X) &&
160160- Precision.AlmostEquals(BottomLeft.Y, other.BottomLeft.Y) &&
161161- Precision.AlmostEquals(BottomRight.X, other.BottomRight.X) &&
162162- Precision.AlmostEquals(BottomRight.Y, other.BottomRight.Y);
163163- }
139139+ public bool AlmostEquals(Quad other) =>
140140+ Precision.AlmostEquals(TopLeft.X, other.TopLeft.X) &&
141141+ Precision.AlmostEquals(TopLeft.Y, other.TopLeft.Y) &&
142142+ Precision.AlmostEquals(TopRight.X, other.TopRight.X) &&
143143+ Precision.AlmostEquals(TopRight.Y, other.TopRight.Y) &&
144144+ Precision.AlmostEquals(BottomLeft.X, other.BottomLeft.X) &&
145145+ Precision.AlmostEquals(BottomLeft.Y, other.BottomLeft.Y) &&
146146+ Precision.AlmostEquals(BottomRight.X, other.BottomRight.X) &&
147147+ Precision.AlmostEquals(BottomRight.Y, other.BottomRight.Y);
164148165149 public override string ToString() => $"{TopLeft} {TopRight} {BottomLeft} {BottomRight}";
166150 }
+9-12
osu.Framework/Graphics/Primitives/RectangleF.cs
···3344using System;
55using System.ComponentModel;
66+using System.Diagnostics.CodeAnalysis;
67using System.Globalization;
78using System.Runtime.InteropServices;
89using osuTK;
···134135 {
135136 if (!(obj is RectangleF))
136137 return false;
138138+137139 RectangleF ef = (RectangleF)obj;
138140 return ef.X == X && ef.Y == Y && ef.Width == Width && ef.Height == Height;
139141 }
···186188 /// <summary>Gets the hash code for this <see cref="T:System.Drawing.RectangleF"></see> structure. For information about the use of hash codes, see Object.GetHashCode.</summary>
187189 /// <returns>The hash code for this <see cref="T:System.Drawing.RectangleF"></see>.</returns>
188190 /// <filterpriority>1</filterpriority>
189189- public override int GetHashCode()
190190- {
191191- // ReSharper disable NonReadonlyMemberInGetHashCode
192192- return
193193- (int)((uint)X ^ (uint)Y << 13 | (uint)Y >> 0x13 ^
194194- (uint)Width << 0x1a | (uint)Width >> 6 ^
195195- (uint)Height << 7 | (uint)Height >> 0x19);
196196- // ReSharper restore NonReadonlyMemberInGetHashCode
197197- }
191191+ [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
192192+ public override int GetHashCode() =>
193193+ (int)(((uint)X ^ ((uint)Y << 13)) | (((uint)Y >> 0x13) ^ ((uint)Width << 0x1a)) | (((uint)Width >> 6) ^ ((uint)Height << 7)) | ((uint)Height >> 0x19));
198194199195 /// <summary>Gets the Area of this <see cref="RectangleF"/>.</summary>
200196 public float Area => Width * Height;
···294290 float num4 = Math.Min(a.Y + a.Height, b.Y + b.Height);
295291 if (num2 >= x && num4 >= y)
296292 return new RectangleF(x, y, num2 - x, num4 - y);
293293+297294 return Empty;
298295 }
299296···374371 /// <filterpriority>1</filterpriority>
375372 /// <PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" /></PermissionSet>
376373 public override string ToString() => $"X={Math.Round(X, 3).ToString(CultureInfo.CurrentCulture)}, "
377377- + $"Y={Math.Round(Y, 3).ToString(CultureInfo.CurrentCulture)}, "
378378- + $"Width={Math.Round(Width, 3).ToString(CultureInfo.CurrentCulture)}, "
379379- + $"Height={Math.Round(Height, 3).ToString(CultureInfo.CurrentCulture)}";
374374+ + $"Y={Math.Round(Y, 3).ToString(CultureInfo.CurrentCulture)}, "
375375+ + $"Width={Math.Round(Width, 3).ToString(CultureInfo.CurrentCulture)}, "
376376+ + $"Height={Math.Round(Height, 3).ToString(CultureInfo.CurrentCulture)}";
380377381378 public bool Equals(RectangleF other) => X == other.X && Y == other.Y && Width == other.Width && Height == other.Height;
382379 }
+10-20
osu.Framework/Graphics/Primitives/RectangleI.cs
···3344using System;
55using System.ComponentModel;
66+using System.Diagnostics.CodeAnalysis;
67using System.Globalization;
78using System.Runtime.InteropServices;
89using osuTK;
···4142 /// <returns>A <see cref="osuTK.Vector2"/> that represents the upper-left corner of this <see cref="T:System.Drawing.RectangleI"></see> structure.</returns>
4243 /// <filterpriority>1</filterpriority>
4344 [Browsable(false)]
4444- public Vector2I Location
4545- {
4646- get { return new Vector2I(X, Y); }
4747- }
4545+ public Vector2I Location => new Vector2I(X, Y);
48464947 /// <summary>Gets or sets the size of this <see cref="T:System.Drawing.RectangleI"></see>.</summary>
5048 /// <returns>A <see cref="osuTK.Vector2"/> that represents the width and height of this <see cref="T:System.Drawing.RectangleI"></see> structure.</returns>
5149 /// <filterpriority>1</filterpriority>
5250 [Browsable(false)]
5353- public Vector2I Size
5454- {
5555- get { return new Vector2I(Width, Height); }
5656- }
5151+ public Vector2I Size => new Vector2I(Width, Height);
57525853 /// <summary>Gets the y-coordinate of the top edge of this <see cref="T:System.Drawing.RectangleI"></see> structure.</summary>
5954 /// <returns>The y-coordinate of the top edge of this <see cref="T:System.Drawing.RectangleI"></see> structure.</returns>
···105100 {
106101 if (!(obj is RectangleI))
107102 return false;
103103+108104 RectangleI ef = (RectangleI)obj;
109105 return ef.X == X && ef.Y == Y && ef.Width == Width && ef.Height == Height;
110106 }
···147143 /// <summary>Gets the hash code for this <see cref="T:System.Drawing.RectangleI"></see> structure. For information about the use of hash codes, see Object.GetHashCode.</summary>
148144 /// <returns>The hash code for this <see cref="T:System.Drawing.RectangleI"></see>.</returns>
149145 /// <filterpriority>1</filterpriority>
150150- public override int GetHashCode()
151151- {
152152- // ReSharper disable NonReadonlyMemberInGetHashCode
153153- return
154154- (int)((uint)X ^ (uint)Y << 13 | (uint)Y >> 0x13 ^
155155- (uint)Width << 0x1a | (uint)Width >> 6 ^
156156- (uint)Height << 7 | (uint)Height >> 0x19);
157157- // ReSharper restore NonReadonlyMemberInGetHashCode
158158- }
146146+ [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
147147+ public override int GetHashCode() => (int)(((uint)X ^ ((uint)Y << 13)) | (((uint)Y >> 0x13) ^ ((uint)Width << 0x1a)) | (((uint)Width >> 6) ^ ((uint)Height << 7)) | ((uint)Height >> 0x19));
159148160149 public int Area => Width * Height;
161150···223212 int num4 = Math.Min(a.Y + a.Height, b.Y + b.Height);
224213 if (num2 >= x && num4 >= y)
225214 return new RectangleI(x, y, num2 - x, num4 - y);
215215+226216 return Empty;
227217 }
228218···261251 /// <filterpriority>1</filterpriority>
262252 /// <PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" /></PermissionSet>
263253 public override string ToString() => $"X={X.ToString(CultureInfo.CurrentCulture)}, "
264264- + $"Y={Y.ToString(CultureInfo.CurrentCulture)}, "
265265- + $"Width={Width.ToString(CultureInfo.CurrentCulture)}, "
266266- + $"Height={Height.ToString(CultureInfo.CurrentCulture)}";
254254+ + $"Y={Y.ToString(CultureInfo.CurrentCulture)}, "
255255+ + $"Width={Width.ToString(CultureInfo.CurrentCulture)}, "
256256+ + $"Height={Height.ToString(CultureInfo.CurrentCulture)}";
267257268258 public bool Equals(RectangleI other) => X == other.X && Y == other.Y && Width == other.Width && Height == other.Height;
269259 }
+6-7
osu.Framework/Graphics/Primitives/Vector2I.cs
···3344using osuTK;
55using System;
66+using System.Diagnostics.CodeAnalysis;
67using System.Runtime.InteropServices;
7889namespace osu.Framework.Graphics.Primitives
···1314 public int X;
1415 public int Y;
15161616- public Vector2I(int val) : this(val, val)
1717+ public Vector2I(int val)
1818+ : this(val, val)
1719 {
1820 }
1921···4345 {
4446 if (!(obj is Vector2I))
4547 return false;
4848+4649 return Equals((Vector2I)obj);
4750 }
48514949- public override int GetHashCode()
5050- {
5151- // ReSharper disable NonReadonlyMemberInGetHashCode
5252- return (int)((uint)X ^ (uint)Y << 13 | (uint)Y >> 0x13);
5353- // ReSharper restore NonReadonlyMemberInGetHashCode
5454- }
5252+ [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
5353+ public override int GetHashCode() => (int)(((uint)X ^ ((uint)Y << 13)) | ((uint)Y >> 0x13));
5554 }
5655}
+2-4
osu.Framework/Graphics/Shaders/Shader.cs
···9090 int location = GL.GetUniformLocation(this, name);
91919292 if (GlobalPropertyManager.CheckGlobalExists(name)) return new GlobalUniform<T>(this, name, location);
9393+9394 return new Uniform<T>(this, name, location);
9495 }
9596···178179 return (Uniform<T>)Uniforms[name];
179180 }
180181181181- public static implicit operator int(Shader shader)
182182- {
183183- return shader.programID;
184184- }
182182+ public static implicit operator int(Shader shader) => shader.programID;
185183186184 #region Disposal
187185
+1
osu.Framework/Graphics/Shaders/ShaderManager.cs
···4545 name = shader_prefix + name;
4646 if (name.EndsWith(ending, StringComparison.Ordinal))
4747 return name;
4848+4849 return name + ending;
4950 }
5051
···2626 var tex = base.TextureGL;
2727 if (tex.ReferenceCount <= 0)
2828 throw new InvalidOperationException($"Attempting to access a {nameof(TextureWithRefCount)}'s underlying texture after all references are lost.");
2929+2930 return tex;
3031 }
3132 }
···48494950 if (isDisposed)
5051 return;
5252+5153 isDisposed = true;
52545355 base.TextureGL.Dereference();
+2-4
osu.Framework/Graphics/TransformableExtensions.cs
···125125 /// </summary>
126126 /// <returns>A <see cref="TransformSequence{T}"/> which has a delay waiting for all transforms to be completed.</returns>
127127 public static TransformSequence<T> DelayUntilTransformsFinished<T>(this T transformable)
128128- where T : Transformable
129129- {
130130- return transformable.Delay(Math.Max(0, transformable.LatestTransformEndTime - transformable.Time.Current));
131131- }
128128+ where T : Transformable =>
129129+ transformable.Delay(Math.Max(0, transformable.LatestTransformEndTime - transformable.Time.Current));
132130133131 /// <summary>
134132 /// Append a looping <see cref="TransformSequence{T}"/> to this <see cref="TransformSequence{T}"/>.
···4545 {
4646 if (usingItemSource)
4747 throw new InvalidOperationException($"Cannot manually set {nameof(Items)} when an {nameof(ItemSource)} is bound.");
4848+4849 setItems(value);
4950 }
5051 }
···101102 {
102103 if (usingItemSource)
103104 throw new InvalidOperationException($"Cannot manually add dropdown items when an {nameof(ItemSource)} is bound.");
105105+104106 addDropdownItem(text, value);
105107 }
106108···129131 {
130132 if (usingItemSource)
131133 throw new InvalidOperationException($"Cannot manually remove items when an {nameof(ItemSource)} is bound.");
134134+132135 return removeDropdownItem(value);
133136 }
134137···240243 {
241244 if (usingItemSource)
242245 throw new InvalidOperationException($"Cannot manually clear items when an {nameof(ItemSource)} is bound.");
246246+243247 clearItems();
244248 }
245249···340344 {
341345 if (selected == value)
342346 return;
347347+343348 selected = value;
344349345350 OnSelectChange();
+15
osu.Framework/Graphics/UserInterface/Menu.cs
···161161 }
162162163163 private float maxWidth = float.MaxValue;
164164+164165 /// <summary>
165166 /// Gets or sets the maximum allowable width by this <see cref="Menu"/>.
166167 /// </summary>
···171172 {
172173 if (Precision.AlmostEquals(maxWidth, value))
173174 return;
175175+174176 maxWidth = value;
175177176178 sizeCache.Invalidate();
···178180 }
179181180182 private float maxHeight = float.PositiveInfinity;
183183+181184 /// <summary>
182185 /// Gets or sets the maximum allowable height by this <see cref="Menu"/>.
183186 /// </summary>
···188191 {
189192 if (Precision.AlmostEquals(maxHeight, value))
190193 return;
194194+191195 maxHeight = value;
192196193197 sizeCache.Invalidate();
···195199 }
196200197201 private MenuState state = MenuState.Closed;
202202+198203 /// <summary>
199204 /// Gets or sets the current state of this <see cref="Menu"/>.
200205 /// </summary>
···211216212217 if (state == value)
213218 return;
219219+214220 state = value;
215221216222 updateState();
···373379 protected virtual void UpdateSize(Vector2 newSize) => Size = newSize;
374380375381 #region Hover/Focus logic
382382+376383 private void menuItemClicked(DrawableMenuItem item)
377384 {
378385 // We only want to close the sub-menu if we're not a sub menu - if we are a sub menu
···446453 }
447454448455 private ScheduledDelegate openDelegate;
456456+449457 private void menuItemHovered(DrawableMenuItem item)
450458 {
451459 // If we're not a sub-menu, then hover shouldn't display a sub-menu unless an item is clicked
···534542 protected virtual DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableMenuItem(item);
535543536544 #region DrawableMenuItem
545545+537546 // must be public due to mono bug(?) https://github.com/ppy/osu/issues/1204
538547 public class DrawableMenuItem : CompositeDrawable, IStateful<MenuItemState>
539548 {
···606615 }
607616608617 private Color4 backgroundColour = Color4.DarkSlateGray;
618618+609619 /// <summary>
610620 /// Gets or sets the default background colour.
611621 /// </summary>
···620630 }
621631622632 private Color4 foregroundColour = Color4.White;
633633+623634 /// <summary>
624635 /// Gets or sets the default foreground colour.
625636 /// </summary>
···634645 }
635646636647 private Color4 backgroundColourHover = Color4.DarkGray;
648648+637649 /// <summary>
638650 /// Gets or sets the background colour when this <see cref="DrawableMenuItem"/> is hovered.
639651 /// </summary>
···648660 }
649661650662 private Color4 foregroundColourHover = Color4.White;
663663+651664 /// <summary>
652665 /// Gets or sets the foreground colour when this <see cref="DrawableMenuItem"/> is hovered.
653666 /// </summary>
···662675 }
663676664677 private MenuItemState state;
678678+665679 public MenuItemState State
666680 {
667681 get => state;
···763777 Font = new FontUsage(size: 17),
764778 };
765779 }
780780+766781 #endregion
767782 }
768783
···47474848 if (lastRawState != null && rawState.Equals(lastRawState))
4949 return;
5050+5051 lastRawState = rawState;
51525253 var newState = new TkKeyboardState(rawState);
+11-31
osu.Framework/Input/InputManager.cs
···376376 hoverEventsUpdated = true;
377377 }
378378379379- private bool isModifierKey(Key k)
380380- {
381381- return k == Key.LControl || k == Key.RControl
382382- || k == Key.LAlt || k == Key.RAlt
383383- || k == Key.LShift || k == Key.RShift
384384- || k == Key.LWin || k == Key.RWin;
385385- }
379379+ private bool isModifierKey(Key k) =>
380380+ k == Key.LControl || k == Key.RControl
381381+ || k == Key.LAlt || k == Key.RAlt
382382+ || k == Key.LShift || k == Key.RShift
383383+ || k == Key.LWin || k == Key.RWin;
386384387385 protected virtual void HandleKeyboardKeyStateChange(ButtonStateChangeEvent<Key> keyboardKeyStateChange)
388386 {
···475473 manager.HandleButtonStateChange(e.State, e.Kind, Time.Current);
476474 }
477475478478- private bool handleMouseMove(InputState state, Vector2 lastPosition)
479479- {
480480- return PropagateBlockableEvent(PositionalInputQueue, new MouseMoveEvent(state, lastPosition));
481481- }
476476+ private bool handleMouseMove(InputState state, Vector2 lastPosition) => PropagateBlockableEvent(PositionalInputQueue, new MouseMoveEvent(state, lastPosition));
482477483483- private bool handleScroll(InputState state, Vector2 lastScroll, bool isPrecise)
484484- {
485485- return PropagateBlockableEvent(PositionalInputQueue, new ScrollEvent(state, state.Mouse.Scroll - lastScroll, isPrecise));
486486- }
478478+ private bool handleScroll(InputState state, Vector2 lastScroll, bool isPrecise) => PropagateBlockableEvent(PositionalInputQueue, new ScrollEvent(state, state.Mouse.Scroll - lastScroll, isPrecise));
487479488488- private bool handleKeyDown(InputState state, Key key, bool repeat)
489489- {
490490- return PropagateBlockableEvent(NonPositionalInputQueue, new KeyDownEvent(state, key, repeat));
491491- }
480480+ private bool handleKeyDown(InputState state, Key key, bool repeat) => PropagateBlockableEvent(NonPositionalInputQueue, new KeyDownEvent(state, key, repeat));
492481493493- private bool handleKeyUp(InputState state, Key key)
494494- {
495495- return PropagateBlockableEvent(NonPositionalInputQueue, new KeyUpEvent(state, key));
496496- }
482482+ private bool handleKeyUp(InputState state, Key key) => PropagateBlockableEvent(NonPositionalInputQueue, new KeyUpEvent(state, key));
497483498498- private bool handleJoystickPress(InputState state, JoystickButton button)
499499- {
500500- return PropagateBlockableEvent(NonPositionalInputQueue, new JoystickPressEvent(state, button));
501501- }
484484+ private bool handleJoystickPress(InputState state, JoystickButton button) => PropagateBlockableEvent(NonPositionalInputQueue, new JoystickPressEvent(state, button));
502485503503- private bool handleJoystickRelease(InputState state, JoystickButton button)
504504- {
505505- return PropagateBlockableEvent(NonPositionalInputQueue, new JoystickReleaseEvent(state, button));
506506- }
486486+ private bool handleJoystickRelease(InputState state, JoystickButton button) => PropagateBlockableEvent(NonPositionalInputQueue, new JoystickReleaseEvent(state, button));
507487508488 /// <summary>
509489 /// Triggers events on drawables in <paramref cref="drawables"/> until it is handled.
+1
osu.Framework/Input/InputResampler.cs
···6464 float realMovementDistance = realDiff.Length;
6565 if (realMovementDistance < 1)
6666 return Array.Empty<Vector2>();
6767+6768 lastActualPosition = position;
68696970 // don't update when it moved less than 10 pixels from the last position in a straight fashion
+1
osu.Framework/Input/PassThroughInputManager.cs
···3434 set
3535 {
3636 if (useParentInput == value) return;
3737+3738 useParentInput = value;
38393940 if (UseParentInput)
+1-4
osu.Framework/Input/StateChanges/ButtonInput.cs
···6060 /// <param name="state">The <see cref="InputState"/> which changed.</param>
6161 /// <param name="button">The <see cref="TButton"/> that changed.</param>
6262 /// <param name="kind">The type of change that occurred on <paramref name="button"/>.</param>
6363- protected virtual ButtonStateChangeEvent<TButton> CreateEvent(InputState state, TButton button, ButtonStateChangeKind kind)
6464- {
6565- return new ButtonStateChangeEvent<TButton>(state, this, button, kind);
6666- }
6363+ protected virtual ButtonStateChangeEvent<TButton> CreateEvent(InputState state, TButton button, ButtonStateChangeKind kind) => new ButtonStateChangeEvent<TButton>(state, this, button, kind);
67646865 public void Apply(InputState state, IInputStateChangeHandler handler)
6966 {
+2-8
osu.Framework/Input/States/ButtonStates.cs
···5555 /// Enumerates the differences between ourselves and a previous <see cref="ButtonStates{TButton}"/>.
5656 /// </summary>
5757 /// <param name="lastButtons">The previous <see cref="ButtonStates{TButton}"/>.</param>
5858- public ButtonStateDifference EnumerateDifference(ButtonStates<TButton> lastButtons)
5959- {
6060- return new ButtonStateDifference(lastButtons.Except(this).ToArray(), this.Except(lastButtons).ToArray());
6161- }
5858+ public ButtonStateDifference EnumerateDifference(ButtonStates<TButton> lastButtons) => new ButtonStateDifference(lastButtons.Except(this).ToArray(), this.Except(lastButtons).ToArray());
62596360 /// <summary>
6461 /// Copies the state of another <see cref="ButtonStates{TButton}"/> to ourselves.
···7067 pressedButtons.AddRange(other.pressedButtons);
7168 }
72697373- public override string ToString()
7474- {
7575- return $@"{GetType().ReadableName()}({String.Join(" ", pressedButtons)})";
7676- }
7070+ public override string ToString() => $@"{GetType().ReadableName()}({String.Join(" ", pressedButtons)})";
77717872 public IEnumerator<TButton> GetEnumerator() => ((IEnumerable<TButton>)pressedButtons).GetEnumerator();
7973 IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
+1
osu.Framework/Input/UserInputManager.cs
···3838 case MouseScrollChangeEvent _:
3939 if (Host.Window != null && !Host.Window.CursorInWindow)
4040 return;
4141+4142 break;
4243 }
4344
+1
osu.Framework/Lists/SortedList.cs
···8787 int index = IndexOf(item);
8888 if (index < 0)
8989 return false;
9090+9091 RemoveAt(index);
9192 return true;
9293 }
···192192 /// </summary>
193193 /// <param name="target">The logging target.</param>
194194 /// <returns>The logger responsible for the given logging target.</returns>
195195- public static Logger GetLogger(LoggingTarget target = LoggingTarget.Runtime)
196196- {
197197- // there can be no name conflicts between LoggingTarget-based Loggers and named loggers because
198198- // every name that would coincide with a LoggingTarget-value is reserved and cannot be used (see ctor).
199199- return GetLogger(target.ToString());
200200- }
195195+ public static Logger GetLogger(LoggingTarget target = LoggingTarget.Runtime) => GetLogger(target.ToString());
201196202197 /// <summary>
203198 /// For classes that regularly log to the same target, this method may be preferred over the static Log method.
···387382 private void ensureHeader()
388383 {
389384 if (headerAdded) return;
385385+390386 headerAdded = true;
391387392388 add("----------------------------------------------------------", outputToListeners: false);
+14-4
osu.Framework/MathUtils/Interpolation.cs
···8181 w[i] *= points[i].X - points[j].X;
8282 w[i] = 1.0 / w[i];
8383 }
8484+8485 return w;
8586 }
8687···128129 };
129130 }
130131131131- public static EdgeEffectParameters ValueAt(double time, EdgeEffectParameters startParams, EdgeEffectParameters endParams, double startTime, double endTime, Easing easing = Easing.None)
132132- {
133133- return new EdgeEffectParameters
132132+ public static EdgeEffectParameters ValueAt(double time, EdgeEffectParameters startParams, EdgeEffectParameters endParams, double startTime, double endTime, Easing easing = Easing.None) =>
133133+ new EdgeEffectParameters
134134 {
135135 Type = startParams.Type,
136136 Hollow = startParams.Hollow,
···139139 Radius = ValueAt(time, startParams.Radius, endParams.Radius, startTime, endTime, easing),
140140 Roundness = ValueAt(time, startParams.Roundness, endParams.Roundness, startTime, endTime, easing),
141141 };
142142- }
143142144143 public static SRGBColour ValueAt(double time, SRGBColour startColour, SRGBColour endColour, double startTime, double endTime, Easing easing = Easing.None) =>
145144 ValueAt(time, (Color4)startColour, (Color4)endColour, startTime, endTime, easing);
···263262 return time * (2 - time);
264263 case Easing.InOutQuad:
265264 if (time < .5) return time * time * 2;
265265+266266 return --time * time * -2 + 1;
267267268268 case Easing.InCubic:
···271271 return --time * time * time + 1;
272272 case Easing.InOutCubic:
273273 if (time < .5) return time * time * time * 4;
274274+274275 return --time * time * time * 4 + 1;
275276276277 case Easing.InQuart:
···279280 return 1 - --time * time * time * time;
280281 case Easing.InOutQuart:
281282 if (time < .5) return time * time * time * time * 8;
283283+282284 return --time * time * time * time * -8 + 1;
283285284286 case Easing.InQuint:
···287289 return --time * time * time * time * time + 1;
288290 case Easing.InOutQuint:
289291 if (time < .5) return time * time * time * time * time * 16;
292292+290293 return --time * time * time * time * time * 16 + 1;
291294292295 case Easing.InSine:
···302305 return -Math.Pow(2, -10 * time) + 1;
303306 case Easing.InOutExpo:
304307 if (time < .5) return .5 * Math.Pow(2, 20 * time - 10);
308308+305309 return 1 - .5 * Math.Pow(2, -20 * time + 10);
306310307311 case Easing.InCirc:
···310314 return Math.Sqrt(1 - --time * time);
311315 case Easing.InOutCirc:
312316 if ((time *= 2) < 1) return .5 - .5 * Math.Sqrt(1 - time * time);
317317+313318 return .5 * Math.Sqrt(1 - (time -= 2) * time) + .5;
314319315320 case Easing.InElastic:
···323328 case Easing.InOutElastic:
324329 if ((time *= 2) < 1)
325330 return -.5 * Math.Pow(2, -10 + 10 * time) * Math.Sin((1 - elastic_const2 * 1.5 - time) * elastic_const / 1.5);
331331+326332 return .5 * Math.Pow(2, -10 * --time) * Math.Sin((time - elastic_const2 * 1.5) * elastic_const / 1.5) + 1;
327333328334 case Easing.InBack:
···331337 return --time * time * ((back_const + 1) * time + back_const) + 1;
332338 case Easing.InOutBack:
333339 if ((time *= 2) < 1) return .5 * time * time * ((back_const2 + 1) * time - back_const2);
340340+334341 return .5 * ((time -= 2) * time * ((back_const2 + 1) * time + back_const2) + 2);
335342336343 case Easing.InBounce:
···341348 return 1 - (7.5625 * (time -= 1.5 * bounce_const) * time + .75);
342349 if (time < 2.5 * bounce_const)
343350 return 1 - (7.5625 * (time -= 2.25 * bounce_const) * time + .9375);
351351+344352 return 1 - (7.5625 * (time -= 2.625 * bounce_const) * time + .984375);
345353 case Easing.OutBounce:
346354 if (time < bounce_const)
···349357 return 7.5625 * (time -= 1.5 * bounce_const) * time + .75;
350358 if (time < 2.5 * bounce_const)
351359 return 7.5625 * (time -= 2.25 * bounce_const) * time + .9375;
360360+352361 return 7.5625 * (time -= 2.625 * bounce_const) * time + .984375;
353362 case Easing.InOutBounce:
354363 if (time < .5) return .5 - .5 * ApplyEasing(Easing.OutBounce, 1 - time * 2);
364364+355365 return ApplyEasing(Easing.OutBounce, (time - .5) * 2) * .5 + .5;
356366357367 case Easing.OutPow10:
···77{
88 public class LinuxClipboard : Clipboard
99 {
1010- public override string GetText()
1111- {
1212- return string.Empty;
1313- // return System.Windows.Forms.Clipboard.GetText(TextDataFormat.UnicodeText);
1414- }
1010+ public override string GetText() => string.Empty;
15111612 public override void SetText(string selectedText)
1713 {
+1
osu.Framework/Platform/MacOS/Native/Class.cs
···2222 var id = objc_getClass(name);
2323 if (id == IntPtr.Zero)
2424 throw new ArgumentException("Unknown class: " + name);
2525+2526 return id;
2627 }
2728
+3-12
osu.Framework/Platform/MacOS/Native/Cocoa.cs
···7878 FoundationLibrary = (IntPtr)type_cocoa.GetField("FoundationLibrary").GetValue(null);
7979 }
80808181- public static string FromNSString(IntPtr handle)
8282- {
8383- return (string)method_cocoa_from_ns_string.Invoke(null, new object[] { handle });
8484- }
8181+ public static string FromNSString(IntPtr handle) => (string)method_cocoa_from_ns_string.Invoke(null, new object[] { handle });
85828686- public static IntPtr ToNSString(string str)
8787- {
8888- return (IntPtr)method_cocoa_to_ns_string.Invoke(null, new object[] { str });
8989- }
8383+ public static IntPtr ToNSString(string str) => (IntPtr)method_cocoa_to_ns_string.Invoke(null, new object[] { str });
90849191- public static IntPtr GetStringConstant(IntPtr handle, string symbol)
9292- {
9393- return (IntPtr)method_cocoa_get_string_constant.Invoke(null, new object[] { handle, symbol });
9494- }
8585+ public static IntPtr GetStringConstant(IntPtr handle, string symbol) => (IntPtr)method_cocoa_get_string_constant.Invoke(null, new object[] { handle, symbol });
9586 }
9687}
+3-4
osu.Framework/Platform/NativeStorage.cs
···4646 return paths.Select(Path.GetFullPath).Select(path =>
4747 {
4848 if (!path.StartsWith(basePath)) throw new ArgumentException($"\"{path}\" does not start with \"{basePath}\" and is probably malformed");
4949+4950 return path.Substring(basePath.Length).TrimStart(Path.DirectorySeparatorChar);
5051 });
5152 }
···7677 {
7778 case FileAccess.Read:
7879 if (!File.Exists(path)) return null;
8080+7981 return File.Open(path, FileMode.Open, access, FileShare.Read);
8082 default:
8183 return File.Open(path, mode, access);
8284 }
8385 }
84868585- public override string GetDatabaseConnectionString(string name)
8686- {
8787- return string.Concat("Data Source=", GetFullPath($@"{name}.db", true));
8888- }
8787+ public override string GetDatabaseConnectionString(string name) => string.Concat("Data Source=", GetFullPath($@"{name}.db", true));
89889089 public override void DeleteDatabase(string name) => Delete($@"{name}.db");
9190 }
···5757 /// </summary>
5858 public bool Enabled
5959 {
6060- get { return enabled; }
6060+ get => enabled;
6161 set
6262 {
6363 if (value == enabled || targetThread == null) return;
+3-12
osu.Framework/Threading/AtomicCounter.cs
···99 {
1010 private long count;
11111212- public long Increment()
1313- {
1414- return Interlocked.Increment(ref count);
1515- }
1212+ public long Increment() => Interlocked.Increment(ref count);
16131717- public long Add(long value)
1818- {
1919- return Interlocked.Add(ref count, value);
2020- }
1414+ public long Add(long value) => Interlocked.Add(ref count, value);
21152222- public long Reset()
2323- {
2424- return Interlocked.Exchange(ref count, 0);
2525- }
1616+ public long Reset() => Interlocked.Exchange(ref count, 0);
26172718 public long Value
2819 {
+1
osu.Framework/Threading/AudioThread.cs
···4545 {
4646 if (managers.Contains(manager))
4747 throw new InvalidOperationException($"{manager} was already registered");
4848+4849 managers.Add(manager);
4950 }
5051 }
+1-4
osu.Framework/Threading/ThreadedTaskScheduler.cs
···7272 /// <param name="task">The task to be executed.</param>
7373 /// <param name="taskWasPreviouslyQueued">Whether the task was previously queued.</param>
7474 /// <returns>true if the task was successfully inlined; otherwise, false.</returns>
7575- protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
7676- {
7777- return threads.Contains(Thread.CurrentThread) && TryExecuteTask(task);
7878- }
7575+ protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued) => threads.Contains(Thread.CurrentThread) && TryExecuteTask(task);
79768077 /// <summary>Gets the maximum concurrency level supported by this scheduler.</summary>
8178 public override int MaximumConcurrencyLevel => threads.Length;