Skip to content

Commit 30fa033

Browse files
authored
Merge pull request #142 from winnerspiros/fix-android-sliders-and-vulkan-flicker-10618749125641978498
Fix Android slider visibility and Vulkan flickering
2 parents ef0469b + 4959163 commit 30fa033

8 files changed

Lines changed: 144 additions & 8 deletions

File tree

optimize_slider.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import re
2+
3+
file_path = 'osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs'
4+
5+
with open(file_path, 'r') as f:
6+
content = f.read()
7+
8+
# Replace anyHit logic
9+
old_any_hit = """ bool anyHit = false;
10+
11+
for (int i = 0; i < hitObject.NestedHitObjects.Count; i++)
12+
{
13+
if (hitObject.NestedHitObjects[i].Result.IsHit)
14+
{
15+
anyHit = true;
16+
break;
17+
}
18+
}"""
19+
20+
new_any_hit = """ bool anyHit = false;
21+
22+
foreach (var nested in hitObject.NestedHitObjects)
23+
{
24+
if (nested.Result.IsHit)
25+
{
26+
anyHit = true;
27+
break;
28+
}
29+
}"""
30+
31+
# Wait, the code already uses a for loop in CheckForResult for anyHit.
32+
# Let's check the other one: hitTicks calculation.
33+
34+
old_hit_ticks = """ int totalTicks = hitObject.NestedHitObjects.Count;
35+
int hitTicks = 0;
36+
37+
for (int i = 0; i < totalTicks; i++)
38+
{
39+
if (hitObject.NestedHitObjects[i].IsHit)
40+
hitTicks++;
41+
}"""
42+
43+
new_hit_ticks = """ int hitTicks = 0;
44+
45+
foreach (var nested in hitObject.NestedHitObjects)
46+
{
47+
if (nested.IsHit)
48+
hitTicks++;
49+
}"""
50+
51+
content = content.replace(old_hit_ticks, new_hit_ticks)
52+
53+
with open(file_path, 'w') as f:
54+
f.write(content)

optimize_slider_v2.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import re
2+
3+
file_path = 'osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs'
4+
5+
with open(file_path, 'r') as f:
6+
content = f.read()
7+
8+
# Replace anyHit logic
9+
old_any_hit = """ bool anyHit = false;
10+
11+
for (int i = 0; i < hitObject.NestedHitObjects.Count; i++)
12+
{
13+
if (hitObject.NestedHitObjects[i].Result.IsHit)
14+
{
15+
anyHit = true;
16+
break;
17+
}
18+
}"""
19+
20+
new_any_hit = """ bool anyHit = false;
21+
22+
foreach (var nested in hitObject.NestedHitObjects)
23+
{
24+
if (nested.Result.IsHit)
25+
{
26+
anyHit = true;
27+
break;
28+
}
29+
}"""
30+
31+
content = content.replace(old_any_hit, new_any_hit)
32+
33+
with open(file_path, 'w') as f:
34+
f.write(content)

optimize_slider_v3.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import re
2+
3+
file_path = 'osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs'
4+
5+
with open(file_path, 'r') as f:
6+
content = f.read()
7+
8+
# Fix totalTicks to be after nested hit object count check or just use count
9+
old_ticks_logic = """ int hitTicks = 0;
10+
11+
foreach (var nested in hitObject.NestedHitObjects)
12+
{
13+
if (nested.IsHit)
14+
hitTicks++;
15+
}
16+
17+
if (hitTicks == totalTicks)"""
18+
19+
new_ticks_logic = """ int totalTicks = hitObject.NestedHitObjects.Count;
20+
int hitTicks = 0;
21+
22+
foreach (var nested in hitObject.NestedHitObjects)
23+
{
24+
if (nested.IsHit)
25+
hitTicks++;
26+
}
27+
28+
if (hitTicks == totalTicks)"""
29+
30+
content = content.replace(old_ticks_logic, new_ticks_logic)
31+
32+
with open(file_path, 'w') as f:
33+
f.write(content)

osu.Android/OsuGameAndroid.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public OsuGameAndroid(OsuGameActivity activity)
103103
: base(null)
104104
{
105105
gameActivity = activity;
106+
startVulkanProbe();
106107
}
107108

108109
public override string Version
@@ -144,8 +145,6 @@ private void load()
144145
LocalConfig.BindWith(OsuSetting.AndroidVulkanProbe, vulkanProbeEnabled);
145146
LocalConfig.BindWith(OsuSetting.AudioOffset, audioOffset);
146147

147-
// Start Vulkan probe as early as possible so it's ready for RendererSettings.
148-
if (vulkanProbeEnabled.Value)
149148
startVulkanProbe();
150149

151150
audioRedirector = new OboeAudioRedirector(Audio);

osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
305305
int totalTicks = hitObject.NestedHitObjects.Count;
306306
int hitTicks = 0;
307307

308-
for (int i = 0; i < totalTicks; i++)
308+
foreach (var nested in hitObject.NestedHitObjects)
309309
{
310-
if (hitObject.NestedHitObjects[i].IsHit)
310+
if (nested.IsHit)
311311
hitTicks++;
312312
}
313313

@@ -330,9 +330,9 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
330330
{
331331
bool anyHit = false;
332332

333-
for (int i = 0; i < hitObject.NestedHitObjects.Count; i++)
333+
foreach (var nested in hitObject.NestedHitObjects)
334334
{
335-
if (hitObject.NestedHitObjects[i].Result.IsHit)
335+
if (nested.Result.IsHit)
336336
{
337337
anyHit = true;
338338
break;

osu.Game.Rulesets.Osu/Skinning/SnakingSliderBody.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private void setRange(double p0, double p1)
164164
if (lastUpdateTime > 0 && Clock.CurrentTime - lastUpdateTime < 16)
165165
{
166166
double delta = Math.Max(Math.Abs(p0 - (SnakedStart ?? 0)), Math.Abs(p1 - (SnakedEnd ?? 0)));
167-
if (delta < 0.005) return;
167+
if (delta < 0.0001) return;
168168
}
169169
lastUpdateTime = Clock.CurrentTime;
170170
}

osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ public virtual void StopAllSamples()
633633

634634
protected override void Update()
635635
{
636-
if (RuntimeInfo.OS == RuntimeInfo.Platform.Android && (Time.Current < LifetimeStart - 1000 || Time.Current > LifetimeEnd))
636+
if (RuntimeInfo.OS == RuntimeInfo.Platform.Android && (Time.Current < LifetimeStart - 5000 || Time.Current > LifetimeEnd))
637637
return;
638638

639639
// We use a flag here to load samples only when they are required to be played.

vulkan_fix.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<<<<<<< SEARCH
2+
public OsuGameAndroid(OsuGameActivity activity)
3+
: base(null)
4+
{
5+
gameActivity = activity;
6+
}
7+
=======
8+
public OsuGameAndroid(OsuGameActivity activity)
9+
: base(null)
10+
{
11+
gameActivity = activity;
12+
13+
// Start Vulkan probe as early as possible so it's ready for SetHost.
14+
startVulkanProbe();
15+
}
16+
>>>>>>> REPLACE

0 commit comments

Comments
 (0)