Created
December 19, 2025 22:46
-
-
Save MartinZikmund/0e7b8d1022b0325d478ddfce4b80fd1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static string _localWadPath; | |
| /// <summary> | |
| /// Prepares assets for WebAssembly by downloading them via HTTP | |
| /// </summary> | |
| public static async Task PrepareAssetsAsync() | |
| { | |
| var localFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Wads", CreationCollisionOption.OpenIfExists); | |
| foreach (var name in iwadNames) | |
| { | |
| var assetPath = $"Assets/{name}"; | |
| try | |
| { | |
| var fileFromAssets = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///{assetPath}")); | |
| if (fileFromAssets != null) | |
| { | |
| // Copy to local folder | |
| var existingFile = await localFolder.TryGetItemAsync(name); | |
| if (existingFile != null) | |
| { | |
| _localWadPath = existingFile.Path; | |
| Console.WriteLine($"IWAD {name} already exists in local folder."); | |
| break; | |
| } else | |
| { | |
| var copiedFile = await fileFromAssets.CopyAsync(localFolder, name, NameCollisionOption.ReplaceExisting); | |
| Console.WriteLine($"Copied IWAD {name} to local folder."); | |
| _localWadPath = copiedFile.Path; | |
| } | |
| } | |
| } | |
| catch | |
| { | |
| // Ignore missing assets | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment