Skip to content

Commit 8ecd8e6

Browse files
authored
Merge pull request #152 from winnerspiros/android-refresh-input-oboe-fixes-9680005098190217648
Android: Fix refresh rate, input clicking, and Oboe audio
2 parents 8a0a731 + cccb5b8 commit 8ecd8e6

43 files changed

Lines changed: 255 additions & 1123 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cleanup_activity.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

final_cleanup.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

final_fix.py

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
1-
file_path = 'osu.Android/OsuGameActivity.cs'
2-
with open(file_path, 'r') as f:
3-
content = f.read()
1+
import os
42

5-
# Remove duplicate OnConfigurationChanged
6-
import re
7-
pattern = r'public override void OnConfigurationChanged\(Configuration newConfig\)\s+\{\s+base\.OnConfigurationChanged\(newConfig\);\s+updateDeXStatus\(newConfig\);\s+\(game as OsuGameAndroid\)\?\.SelectHighestRefreshRate\(\);\s+\}'
8-
content = re.sub(pattern, '', content, count=1)
3+
def fix_loc():
4+
path = 'osu.Game/Localisation/GraphicsSettingsStrings.cs'
5+
with open(path, 'r') as f:
6+
content = f.read()
97

10-
with open(file_path, 'w') as f:
11-
f.write(content)
8+
# Correct insertion before Resolution
9+
insertion = '\n /// <summary>\n /// "Refresh rate"\n /// </summary>\n public static LocalisableString RefreshRate => new TranslatableString(getKey(@"refresh_rate"), @"Refresh rate");\n'
10+
11+
# We use replace with exact match to ensure indentation is correct (8 spaces)
12+
old_text = ' public static LocalisableString ScreenMode => new TranslatableString(getKey(@"screen_mode"), @"Screen mode");'
13+
new_text = old_text + insertion
14+
15+
if old_text in content and 'RefreshRate' not in content:
16+
with open(path, 'w') as f:
17+
f.write(content.replace(old_text, new_text))
18+
print("Fixed Localisation")
19+
20+
def fix_results():
21+
path = 'osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.cs'
22+
with open(path, 'r') as f:
23+
content = f.read()
24+
25+
# Fix the if-null patterns using regex to preserve indentation exactly
26+
import re
27+
28+
# if (x != null) x.Looping = false; -> x?.Looping = false;
29+
content = re.sub(r'if \((playerScoreTickChannel|opponentScoreTickChannel) != null\) \1\.Looping = false;', r'\1?.Looping = false;', content)
30+
31+
# if (x != null && condition) -> if (condition) \n x?.Looping = false;
32+
# Wait, the original was:
33+
# if (playerScoreTickChannel != null && playerScoreBar.Height >= playerScorePercent)
34+
# playerScoreTickChannel.Looping = false;
35+
36+
content = re.sub(r'if \((playerScoreTickChannel|opponentScoreTickChannel) != null && (.*?)\)\s+(.*?)\.Looping = false;',
37+
r'if (\2)\n \1?.Looping = false;', content)
38+
39+
with open(path, 'w') as f:
40+
f.write(content)
41+
print("Fixed ResultsScreen")
42+
43+
fix_loc()
44+
fix_results()

fix_activity_errors.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

fix_android_fields.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

fix_end_of_file.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

fix_errors.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

fix_final.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os
2+
3+
def fix_loc():
4+
path = 'osu.Game/Localisation/GraphicsSettingsStrings.cs'
5+
with open(path, 'r') as f:
6+
lines = f.readlines()
7+
8+
new_lines = []
9+
seen = set()
10+
for line in lines:
11+
if 'public static LocalisableString RefreshRate' in line:
12+
if 'RefreshRate' in seen:
13+
continue
14+
seen.add('RefreshRate')
15+
new_lines.append(line)
16+
17+
with open(path, 'w') as f:
18+
f.writelines(new_lines)
19+
20+
def fix_results():
21+
path = 'osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.cs'
22+
with open(path, 'r') as f:
23+
lines = f.readlines()
24+
25+
new_lines = []
26+
for line in lines:
27+
# Simplify null checks
28+
if 'if (playerScoreTickChannel != null) playerScoreTickChannel.Looping = false;' in line:
29+
new_lines.append(line.replace('if (playerScoreTickChannel != null) playerScoreTickChannel.Looping = false;', 'playerScoreTickChannel?.Looping = false;'))
30+
elif 'if (opponentScoreTickChannel != null) opponentScoreTickChannel.Looping = false;' in line:
31+
new_lines.append(line.replace('if (opponentScoreTickChannel != null) opponentScoreTickChannel.Looping = false;', 'opponentScoreTickChannel?.Looping = false;'))
32+
elif 'if (playerScoreTickChannel != null && playerScoreBar.Height >= playerScorePercent)' in line:
33+
new_lines.append(line.replace('if (playerScoreTickChannel != null && playerScoreBar.Height >= playerScorePercent)', 'if (playerScoreBar.Height >= playerScorePercent)'))
34+
new_lines.append(line.split('if')[0] + ' playerScoreTickChannel?.Looping = false;\n')
35+
elif 'if (opponentScoreTickChannel != null && opponentScoreBar.Height >= opponentScorePercent)' in line:
36+
new_lines.append(line.replace('if (opponentScoreTickChannel != null && opponentScoreBar.Height >= opponentScorePercent)', 'if (opponentScoreBar.Height >= opponentScorePercent)'))
37+
new_lines.append(line.split('if')[0] + ' opponentScoreTickChannel?.Looping = false;\n')
38+
elif 'playerScoreTickChannel.Looping = false;' in line and 'if' not in line and '?' not in line:
39+
new_lines.append(line.replace('playerScoreTickChannel.Looping = false;', 'playerScoreTickChannel?.Looping = false;'))
40+
elif 'opponentScoreTickChannel.Looping = false;' in line and 'if' not in line and '?' not in line:
41+
new_lines.append(line.replace('opponentScoreTickChannel.Looping = false;', 'opponentScoreTickChannel?.Looping = false;'))
42+
else:
43+
new_lines.append(line)
44+
45+
with open(path, 'w') as f:
46+
f.writelines(new_lines)
47+
48+
fix_loc()
49+
fix_results()

fix_final_v4.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import os
2+
3+
def fix_localisation():
4+
path = 'osu.Game/Localisation/GraphicsSettingsStrings.cs'
5+
with open(path, 'r') as f:
6+
lines = f.readlines()
7+
8+
new_lines = []
9+
skip = False
10+
for i, line in enumerate(lines):
11+
if 'public static LocalisableString ScreenMode' in line:
12+
new_lines.append(line)
13+
new_lines.append('\n')
14+
new_lines.append(' /// <summary>\n')
15+
new_lines.append(' /// "Refresh rate"\n')
16+
new_lines.append(' /// </summary>\n')
17+
new_lines.append(' public static LocalisableString RefreshRate => new TranslatableString(getKey(@"refresh_rate"), @"Refresh rate");\n')
18+
new_lines.append('\n')
19+
skip = True
20+
continue
21+
22+
if skip:
23+
if 'public static LocalisableString Resolution' in line:
24+
new_lines.append(' /// <summary>\n')
25+
new_lines.append(' /// "Resolution"\n')
26+
new_lines.append(' /// </summary>\n')
27+
new_lines.append(line)
28+
skip = False
29+
continue
30+
31+
new_lines.append(line)
32+
33+
with open(path, 'w') as f:
34+
f.writelines(new_lines)
35+
36+
def fix_results():
37+
path = 'osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.cs'
38+
with open(path, 'r') as f:
39+
content = f.read()
40+
41+
# Identify the block to replace
42+
import re
43+
# We want to replace from "// safety timeout" to the end of the scoreBarProgress block
44+
pattern = re.compile(r'// safety timeout to ensure scoreTicks don\'t play forever\s+Scheduler\.AddDelayed\(\(\) =>\s+\{.*?\}\s+scoreBarProgress\.BindValueChanged\(e =>\s+\{.*?\}\);\s+\}\);', re.DOTALL)
45+
46+
# That's too complex. Let's just target the specific lines.
47+
48+
fixed_content = re.sub(r'Scheduler\.AddDelayed\(\(\) =>\s+\{\s+playerScoreTickChannel\?\.Looping = false;\s+opponentScoreTickChannel\?\.Looping = false;\s+opponentScoreTickChannel\?\.Looping = false;\s+scoreBarProgress\.BindValueChanged',
49+
r'Scheduler.AddDelayed(() =>\n {\n playerScoreTickChannel?.Looping = false;\n opponentScoreTickChannel?.Looping = false;\n }, score_text_duration + 500);\n\n scoreBarProgress.BindValueChanged', content)
50+
51+
with open(path, 'w') as f:
52+
f.write(fixed_content)
53+
54+
fix_localisation()
55+
fix_results()

fix_formatting.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
path = 'osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/ResultsScreen.cs'
4+
with open(path, 'r') as f:
5+
lines = f.readlines()
6+
7+
new_lines = []
8+
for line in lines:
9+
# Look for the lines with formatting issues
10+
if '.ResizeTo(cardSize with { Y = 30 }, 600, Easing.OutExpo)' in line:
11+
# Just rewrite it exactly as it was, maybe it was a weird tab/space mix?
12+
# Actually, let's look at the diff.
13+
new_lines.append(line)
14+
else:
15+
new_lines.append(line)
16+
17+
with open(path, 'w') as f:
18+
f.writelines(new_lines)

0 commit comments

Comments
 (0)