forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_daily_challenge.py
More file actions
120 lines (94 loc) · 4.19 KB
/
Copy pathfix_daily_challenge.py
File metadata and controls
120 lines (94 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import sys
with open('osu.Game/Screens/OnlinePlay/DailyChallenge/DailyChallenge.cs', 'r') as f:
content = f.read()
# Fix presentScore
old_present_score = """ private void presentScore(long id)
{
if (!this.IsCurrentScreen())
var item = playlistItem;
if (item == null) return;
var item = playlistItem;
if (item != null)
this.Push(new PlaylistItemScoreResultsScreen(id, (room.RoomID ?? 0), item));
}"""
new_present_score = """ private void presentScore(long id)
{
if (!this.IsCurrentScreen())
return;
var item = playlistItem;
if (item == null) return;
this.Push(new PlaylistItemScoreResultsScreen(id, (room.RoomID ?? 0), item));
}"""
# Fix updateMods
old_update_mods = """ private void updateMods()
{
var item = playlistItem;
if (item == null) return;
return;
var item = playlistItem;
if (item != null) Mods.Value = userMods.Value.Concat(item.RequiredMods.Select(m => m.ToMod(Ruleset.Value.CreateInstance()))).ToList();
}"""
new_update_mods = """ private void updateMods()
{
if (!this.IsCurrentScreen())
return;
var item = playlistItem;
if (item == null) return;
Mods.Value = userMods.Value.Concat(item.RequiredMods.Select(m => m.ToMod(Ruleset.Value.CreateInstance()))).ToList();
}"""
# Fix startPlay
old_start_play = """ private void startPlay()
{
sampleStart?.Play();
var item = playlistItem; if (item != null) this.Push(new PlayerLoader(() => new DailyChallengePlayer(room, item)
{
Exited = () => Scheduler.AddOnce(() => leaderboard.RefetchScores())
}));
}"""
new_start_play = """ private void startPlay()
{
sampleStart?.Play();
var item = playlistItem;
if (item == null) return;
this.Push(new PlayerLoader(() => new DailyChallengePlayer(room, item)
{
Exited = () => Scheduler.AddOnce(() => leaderboard.RefetchScores())
}));
}"""
# Fix PresentBeatmap
old_present_beatmap = """ public void PresentBeatmap(WorkingBeatmap beatmap, RulesetInfo ruleset)
{
var item = playlistItem;
if (item == null) return;
if (!this.IsCurrentScreen())
return;
var item = playlistItem;
// We can only handle the current daily challenge beatmap.
// If the import was for a different beatmap, pass the duty off to global handling.
if (item?.Beatmap.BeatmapSet != null && beatmap.BeatmapSetInfo.OnlineID != item.Beatmap.BeatmapSet.OnlineID)
{
this.Exit();
game?.PresentBeatmap(beatmap.BeatmapSetInfo, b => b.ID == beatmap.BeatmapInfo.ID);
}
// And if we're handling, we don't really have much to do here.
}"""
new_present_beatmap = """ public void PresentBeatmap(WorkingBeatmap beatmap, RulesetInfo ruleset)
{
if (!this.IsCurrentScreen())
return;
var item = playlistItem;
if (item == null) return;
// We can only handle the current daily challenge beatmap.
// If the import was for a different beatmap, pass the duty off to global handling.
if (item.Beatmap.BeatmapSet != null && beatmap.BeatmapSetInfo.OnlineID == item.Beatmap.BeatmapSet.OnlineID)
return;
this.Exit();
game?.PresentBeatmap(beatmap.BeatmapSetInfo, b => b.ID == beatmap.BeatmapInfo.ID);
// And if we're handling, we don't really have much to do here.
}"""
content = content.replace(old_present_score, new_present_score)
content = content.replace(old_update_mods, new_update_mods)
content = content.replace(old_start_play, new_start_play)
content = content.replace(old_present_beatmap, new_present_beatmap)
with open('osu.Game/Screens/OnlinePlay/DailyChallenge/DailyChallenge.cs', 'w') as f:
f.write(content)