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