Skip to content

Commit c1b1979

Browse files
karghoff-ekarghoff-e
andauthored
On OneClick save WIP song to CustomWIPLevels directory (#386)
Co-authored-by: karghoff-e <[email protected]>
1 parent ffb5a0f commit c1b1979

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ModAssistant/Classes/External Interfaces/BeatSaver.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class BeatSaver
1616
{
1717
private const string BeatSaverURLPrefix = "https://api.beatsaver.com";
1818
private static readonly string CustomSongsFolder = Path.Combine("Beat Saber_Data", "CustomLevels");
19+
private static readonly string CustomWIPSongsFolder = Path.Combine("Beat Saber_Data", "CustomWIPLevels");
1920
private const bool BypassDownloadCounter = false;
2021

2122
public static async Task<BeatSaverMap> GetFromKey(string Key, bool showNotification = true)
@@ -139,19 +140,23 @@ public static async Task<string> InstallMap(BeatSaverMap Map, bool showNotificat
139140
throw new Exception("Could not find map version.");
140141
}
141142

142-
string zip = Path.Combine(Utils.BeatSaberPath, CustomSongsFolder, Map.HashToDownload) + ".zip";
143+
string state = responseMap.versions[0].state;
144+
string targetSongDirectory = state.Equals("Published") ? CustomSongsFolder : CustomWIPSongsFolder;
145+
146+
string zip = Path.Combine(Utils.BeatSaberPath, targetSongDirectory, Map.HashToDownload) + ".zip";
143147
string mapName = string.Concat(($"{responseMap.id} ({responseMap.metadata.songName} - {responseMap.metadata.levelAuthorName})")
144148
.Split(ModAssistant.Utils.Constants.IllegalCharacters));
145-
string directory = Path.Combine(Utils.BeatSaberPath, CustomSongsFolder, mapName);
149+
150+
string directory = Path.Combine(Utils.BeatSaberPath, targetSongDirectory, mapName);
146151

147152
#pragma warning disable CS0162 // Unreachable code detected
148153
if (BypassDownloadCounter)
149154
{
150-
await Utils.DownloadAsset(mapVersion.downloadURL, CustomSongsFolder, Map.HashToDownload + ".zip", mapName, showNotification, true);
155+
await Utils.DownloadAsset(mapVersion.downloadURL, targetSongDirectory, Map.HashToDownload + ".zip", mapName, showNotification, true);
151156
}
152157
else
153158
{
154-
await Utils.DownloadAsset(mapVersion.downloadURL, CustomSongsFolder, Map.HashToDownload + ".zip", mapName, showNotification, true);
159+
await Utils.DownloadAsset(mapVersion.downloadURL, targetSongDirectory, Map.HashToDownload + ".zip", mapName, showNotification, true);
155160
}
156161
#pragma warning restore CS0162 // Unreachable code detected
157162

0 commit comments

Comments
 (0)