A game framework written with osu! in mind.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use new generic objects wherever possible

+27 -27
+4 -4
osu.Framework/Graphics/BufferedDrawNode.cs
··· 136 136 /// </summary> 137 137 /// <param name="frameBuffer">The <see cref="FrameBuffer"/> to bind.</param> 138 138 /// <returns>A token that must be disposed upon finishing use of <paramref name="frameBuffer"/>.</returns> 139 - protected ValueInvokeOnDisposal BindFrameBuffer(FrameBuffer frameBuffer) 139 + protected IDisposable BindFrameBuffer(FrameBuffer frameBuffer) 140 140 { 141 141 // This setter will also take care of allocating a texture of appropriate size within the frame buffer. 142 142 frameBuffer.Size = frameBufferSize; 143 143 144 144 frameBuffer.Bind(); 145 145 146 - return new ValueInvokeOnDisposal(frameBuffer.Unbind); 146 + return new ValueInvokeOnDisposal<FrameBuffer>(frameBuffer, b => b.Unbind()); 147 147 } 148 148 149 - private ValueInvokeOnDisposal establishFrameBufferViewport() 149 + private IDisposable establishFrameBufferViewport() 150 150 { 151 151 // Disable masking for generating the frame buffer since masking will be re-applied 152 152 // when actually drawing later on anyways. This allows more information to be captured ··· 167 167 GLWrapper.PushScissor(new RectangleI(0, 0, (int)frameBufferSize.X, (int)frameBufferSize.Y)); 168 168 GLWrapper.PushScissorOffset(screenSpaceMaskingRect.Location); 169 169 170 - return new ValueInvokeOnDisposal(returnViewport); 170 + return new ValueInvokeOnDisposal<BufferedDrawNode>(this, d => d.returnViewport()); 171 171 } 172 172 173 173 private void returnViewport()
+4 -4
osu.Framework/Graphics/Containers/CompositeDrawable.cs
··· 1188 1188 1189 1189 protected ScheduledDelegate ScheduleAfterChildren(Action action) => SchedulerAfterChildren.AddDelayed(action, TransformDelay); 1190 1190 1191 - public override InvokeOnDisposal BeginAbsoluteSequence(double newTransformStartTime, bool recursive = false) 1191 + public override IDisposable BeginAbsoluteSequence(double newTransformStartTime, bool recursive = false) 1192 1192 { 1193 1193 var baseDisposalAction = base.BeginAbsoluteSequence(newTransformStartTime, recursive); 1194 1194 if (!recursive) 1195 1195 return baseDisposalAction; 1196 1196 1197 - List<InvokeOnDisposal> disposalActions = new List<InvokeOnDisposal>(internalChildren.Count + 1) { baseDisposalAction }; 1197 + List<IDisposable> disposalActions = new List<IDisposable>(internalChildren.Count + 1) { baseDisposalAction }; 1198 1198 foreach (var c in internalChildren) 1199 1199 disposalActions.Add(c.BeginAbsoluteSequence(newTransformStartTime, true)); 1200 1200 1201 - return new InvokeOnDisposal(() => 1201 + return new InvokeOnDisposal<List<IDisposable>>(disposalActions, actions => 1202 1202 { 1203 - foreach (var a in disposalActions) 1203 + foreach (var a in actions) 1204 1204 a.Dispose(); 1205 1205 }); 1206 1206 }
+3 -3
osu.Framework/Graphics/Transforms/ITransformable.cs
··· 1 1 // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 - using osu.Framework.Allocation; 4 + using System; 5 5 using osu.Framework.Timing; 6 6 7 7 namespace osu.Framework.Graphics.Transforms 8 8 { 9 9 public interface ITransformable 10 10 { 11 - InvokeOnDisposal BeginDelayedSequence(double delay, bool recursive = false); 11 + IDisposable BeginDelayedSequence(double delay, bool recursive = false); 12 12 13 - InvokeOnDisposal BeginAbsoluteSequence(double newTransformStartTime, bool recursive = false); 13 + IDisposable BeginAbsoluteSequence(double newTransformStartTime, bool recursive = false); 14 14 15 15 /// <summary> 16 16 /// The current frame's time as observed by this class's <see cref="Transform"/>s.
+12 -12
osu.Framework/Graphics/Transforms/Transformable.cs
··· 358 358 /// <param name="delay">The offset in milliseconds from current time. Note that this stacks with other nested sequences.</param> 359 359 /// <param name="recursive">Whether this should be applied to all children.</param> 360 360 /// <returns>A <see cref="InvokeOnDisposal"/> to be used in a using() statement.</returns> 361 - public InvokeOnDisposal BeginDelayedSequence(double delay, bool recursive = false) 361 + public IDisposable BeginDelayedSequence(double delay, bool recursive = false) 362 362 { 363 363 if (delay == 0) 364 364 return null; ··· 366 366 AddDelay(delay, recursive); 367 367 double newTransformDelay = TransformDelay; 368 368 369 - return new InvokeOnDisposal(() => 369 + return new InvokeOnDisposal<(Transformable transformable, double delay, bool recursive, double newTransformDelay)>((this, delay, recursive, newTransformDelay), sender => 370 370 { 371 - if (!Precision.AlmostEquals(newTransformDelay, TransformDelay)) 371 + if (!Precision.AlmostEquals(sender.newTransformDelay, sender.transformable.TransformDelay)) 372 372 { 373 373 throw new InvalidOperationException( 374 - $"{nameof(TransformStartTime)} at the end of delayed sequence is not the same as at the beginning, but should be. " + 375 - $"(begin={newTransformDelay} end={TransformDelay})"); 374 + $"{nameof(sender.transformable.TransformStartTime)} at the end of delayed sequence is not the same as at the beginning, but should be. " + 375 + $"(begin={sender.newTransformDelay} end={sender.transformable.TransformDelay})"); 376 376 } 377 377 378 - AddDelay(-delay, recursive); 378 + AddDelay(-sender.delay, sender.recursive); 379 379 }); 380 380 } 381 381 ··· 386 386 /// <param name="recursive">Whether this should be applied to all children.</param> 387 387 /// <returns>A <see cref="InvokeOnDisposal"/> to be used in a using() statement.</returns> 388 388 /// <exception cref="InvalidOperationException">Absolute sequences should never be nested inside another existing sequence.</exception> 389 - public virtual InvokeOnDisposal BeginAbsoluteSequence(double newTransformStartTime, bool recursive = false) 389 + public virtual IDisposable BeginAbsoluteSequence(double newTransformStartTime, bool recursive = false) 390 390 { 391 391 double oldTransformDelay = TransformDelay; 392 392 double newTransformDelay = TransformDelay = newTransformStartTime - (Clock?.CurrentTime ?? 0); 393 393 394 - return new InvokeOnDisposal(() => 394 + return new InvokeOnDisposal<(Transformable transformable, double oldTransformDelay, double newTransformDelay)>((this, oldTransformDelay, newTransformDelay), sender => 395 395 { 396 - if (!Precision.AlmostEquals(newTransformDelay, TransformDelay)) 396 + if (!Precision.AlmostEquals(sender.newTransformDelay, sender.transformable.TransformDelay)) 397 397 { 398 398 throw new InvalidOperationException( 399 - $"{nameof(TransformStartTime)} at the end of absolute sequence is not the same as at the beginning, but should be. " + 400 - $"(begin={newTransformDelay} end={TransformDelay})"); 399 + $"{nameof(sender.transformable.TransformStartTime)} at the end of absolute sequence is not the same as at the beginning, but should be. " + 400 + $"(begin={sender.newTransformDelay} end={sender.transformable.TransformDelay})"); 401 401 } 402 402 403 - TransformDelay = oldTransformDelay; 403 + sender.transformable.TransformDelay = sender.oldTransformDelay; 404 404 }); 405 405 } 406 406
+4 -4
osu.Framework/Platform/NativeMemoryTracker.cs
··· 24 24 getStatistic(source).Value += amount; 25 25 GC.AddMemoryPressure(amount); 26 26 27 - return new NativeMemoryLease(() => removeMemory(source, amount)); 27 + return new NativeMemoryLease((source, amount), sender => removeMemory(sender.source, sender.amount)); 28 28 } 29 29 30 30 /// <summary> ··· 43 43 /// <summary> 44 44 /// A leased on a native memory allocation. Should be disposed when the associated memory is freed. 45 45 /// </summary> 46 - public class NativeMemoryLease : InvokeOnDisposal 46 + public class NativeMemoryLease : InvokeOnDisposal<(object source, long amount)> 47 47 { 48 - internal NativeMemoryLease(Action action) 49 - : base(action) 48 + internal NativeMemoryLease((object source, long amount) sender, Action<(object source, long amount)> action) 49 + : base(sender, action) 50 50 { 51 51 } 52 52