private static Progress[] GetAllProgressFiles(Game.Game game) { var network = game.Network; var results = new List <Progress>(); foreach (var fileName in network.LocalUser.RemoteSaveStore.ListFiles("")) { if (AssetPath.GetExtension(fileName) == "txt" && AssetPath.GetFileNameWithoutExtension(fileName).StartsWith("progress_", StringComparison.InvariantCulture)) { App.Log("Found progress file: {0}", fileName); results.Add(new Progress(network, fileName)); } } return(results.ToArray()); }
private void CreateLevel() { // Determine where to create the new level var assetsPath = m_mod != null?Path.Combine(m_mod.Path, "assets") : Path.Combine(App.AssetPath, "main"); var shortCampaignTitle = AssetPath.GetFileNameWithoutExtension(m_campaign.Path); int i = 1; var levelAssetPath = "levels/" + shortCampaignTitle + "/" + i + ".level"; while (File.Exists(Path.Combine(assetsPath, levelAssetPath))) { levelAssetPath = "levels/" + shortCampaignTitle + "/" + i + ".level"; ++i; } // Add the level to the campaign var newCampaign = m_campaign.Copy(); newCampaign.Levels.Add(levelAssetPath); // Save the campaign var fullCampaignPath = Path.Combine(assetsPath, m_campaign.Path); newCampaign.Save(fullCampaignPath); // Create the Level var fullLevelPath = Path.Combine(assetsPath, levelAssetPath); Directory.CreateDirectory(Path.GetDirectoryName(fullLevelPath)); File.Copy(Path.Combine(App.AssetPath, "base/levels/template.level"), fullLevelPath); // Modify the ID { var kvp = new KeyValuePairFile(fullLevelPath); kvp.Set("id", MathUtils.GenerateLevelID(levelAssetPath)); kvp.Save(); } // Reload and edit the level Assets.Reload(levelAssetPath); Assets.Reload(m_campaign.Path); EditLevel(m_campaign.Levels.Count - 1); }
public static Texture GetLocalised(string path, Language language, bool filter) { // Try the current language and it's fallbacks bool triedEnglish = false; while (language != null) { var specificPath = AssetPath.Combine( AssetPath.GetDirectoryName(path), AssetPath.GetFileNameWithoutExtension(path) + "_" + language.Code + ".png" ); if (Assets.Assets.Exists <Texture>(specificPath)) { return(Texture.Get(specificPath, filter)); } if (language.Code == "en") { triedEnglish = true; } language = language.Fallback; } if (!triedEnglish) { // Try english var englishPath = AssetPath.Combine( AssetPath.GetDirectoryName(path), AssetPath.GetFileNameWithoutExtension(path) + "_en.png" ); if (Assets.Assets.Exists <Texture>(englishPath)) { return(Texture.Get(englishPath, filter)); } } // Try unlocalised return(Texture.Get(path, filter)); }