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

Configure Feed

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

Remove DLW's special lifetime handling

-104
-71
osu.Framework.Tests/Visual/Drawables/TestSceneDelayedLoadWrapper.cs
··· 97 97 AddUntilStep("repeating schedulers removed", () => !scroll.Scheduler.HasPendingTasks); 98 98 } 99 99 100 - [Test] 101 - public void TestLifetimeOutwardsPropagation() 102 - { 103 - Container wrapped = null; 104 - DelayedLoadWrapper wrapper = null; 105 - 106 - AddStep("create child", () => 107 - { 108 - flow.Add(new Container 109 - { 110 - Size = new Vector2(128), 111 - Children = new Drawable[] 112 - { 113 - wrapper = new DelayedLoadWrapper(wrapped = new Container 114 - { 115 - RelativeSizeAxes = Axes.Both, 116 - Children = new Drawable[] 117 - { 118 - new TestBox(() => loaded++) { RelativeSizeAxes = Axes.Both } 119 - } 120 - }), 121 - } 122 - }); 123 - 124 - wrapper.DelayedLoadComplete += content => content.FadeOut(500).Expire(); 125 - }); 126 - 127 - AddAssert("wrapper lifetime equals content lifetime", () => wrapper.LifetimeEnd == wrapped.LifetimeEnd); 128 - 129 - AddUntilStep("wrapper expired", () => !wrapper.IsAlive); 130 - } 131 - 132 - [Test] 133 - public void TestLifetimeInwardsPropagation() 134 - { 135 - Container wrapped = null; 136 - DelayedLoadWrapper wrapper = null; 137 - double lifetimeEnd = 0; 138 - 139 - AddStep("create child", () => 140 - { 141 - flow.Add(new Container 142 - { 143 - Size = new Vector2(128), 144 - Children = new Drawable[] 145 - { 146 - wrapper = new DelayedLoadWrapper(wrapped = new Container 147 - { 148 - // this lifetime will be overwritten by the one on the wrapper. 149 - LifetimeEnd = Time.Current + 4000, 150 - RelativeSizeAxes = Axes.Both, 151 - Children = new Drawable[] 152 - { 153 - new TestBox(() => loaded++) { RelativeSizeAxes = Axes.Both } 154 - } 155 - }) 156 - { 157 - LifetimeEnd = lifetimeEnd = Time.Current + 2000, 158 - } 159 - } 160 - }); 161 - }); 162 - 163 - AddUntilStep("wait for load", () => wrapper.DelayedLoadCompleted); 164 - 165 - AddAssert("wrapper lifetime is correct", () => wrapper.LifetimeEnd == lifetimeEnd); 166 - AddAssert("content lifetime is correct", () => wrapped.LifetimeEnd == lifetimeEnd); 167 - 168 - AddUntilStep("wrapper expired", () => !wrapper.IsAlive); 169 - } 170 - 171 100 [TestCase(false)] 172 101 [TestCase(true)] 173 102 public void TestManyChildrenFunction(bool instant)
-33
osu.Framework/Graphics/Containers/DelayedLoadWrapper.cs
··· 16 16 /// Has the ability to delay the loading until it has been visible on-screen for a specified duration. 17 17 /// In order to benefit from delayed load, we must be inside a <see cref="ScrollContainer{T}"/>. 18 18 /// </summary> 19 - /// <remarks> 20 - /// <see cref="LifetimeStart"/> and <see cref="LifetimeEnd"/> are propagated from the wrapper to the content on content load. 21 - /// After load, the content's lifetime is preferred, meaning any changes to content's lifetime post-load will be respected. 22 - /// </remarks> 23 19 public class DelayedLoadWrapper : CompositeDrawable 24 20 { 25 21 [Resolved] ··· 58 54 59 55 AddLayout(optimisingContainerCache); 60 56 AddLayout(isIntersectingCache); 61 - } 62 - 63 - private double lifetimeStart = double.MinValue; 64 - 65 - public override double LifetimeStart 66 - { 67 - get => Content?.LifetimeStart ?? lifetimeStart; 68 - set 69 - { 70 - if (Content != null) 71 - Content.LifetimeStart = value; 72 - lifetimeStart = value; 73 - } 74 - } 75 - 76 - private double lifetimeEnd = double.MaxValue; 77 - 78 - public override double LifetimeEnd 79 - { 80 - get => Content?.LifetimeEnd ?? lifetimeEnd; 81 - set 82 - { 83 - if (Content != null) 84 - Content.LifetimeEnd = value; 85 - lifetimeEnd = value; 86 - } 87 57 } 88 58 89 59 private Drawable content; ··· 160 130 // This code is running on the game's scheduler, while this DLW may have been async disposed, so the addition is scheduled locally to prevent adding to disposed DLWs. 161 131 scheduledAddition = Schedule(() => 162 132 { 163 - content.LifetimeStart = lifetimeStart; 164 - content.LifetimeEnd = lifetimeEnd; 165 - 166 133 AddInternal(content); 167 134 168 135 DelayedLoadCompleted = true;