protected void CreateCommand(object sender, ItemEditedEventArgs <Command> e) { if (e.Result) { McMod mod = SessionContext.SelectedMod; CodeGenerationService.CreateCustomScript(mod, e.ActualItem); } new FileInfo(tempFilePath).Delete(); }
protected void OnSoundEdited(object sender, ItemEditedEventArgs <Sound> args) { if (args.Result) { ForceJsonFileUpdate(); } else { args.ActualItem.CopyValues(args.CachedItem); } args.ActualItem.IsDirty = false; }
protected void CreateRecipe(object sender, ItemEditedEventArgs <RecipeCreator> e) { if (e.Result) { if (e.ActualItem.Validate().IsValid) { Recipe recipe = e.ActualItem.Create(); string json = RecipeSerializer.Serialize(recipe, true); string path = Path.Combine(ModPaths.RecipesFolder(SessionContext.SelectedMod.ModInfo.Name, SessionContext.SelectedMod.Modid), recipe.Name + ".json"); if (File.Exists(path)) { throw new IOException($"File {path} already exists"); } File.AppendAllText(path, json); } } FileInfo tempFile = new FileInfo(tempFilePath); if (tempFile.Exists) { tempFile.Delete(); } }