public static void LoadCustomAssets(Game p_game) { JKContentManager.LevelTexture = p_game.Content.Load <Texture2D>("mods/level"); //default //JKContentManager.TitleLogo = p_game.Content.Load<Texture2D>("mods/title_logo"); JKContentManager.TitleLogo = SmartLoad(p_game, "title_logo"); JKContentManager.NexileLogo = Sprite.CreateSprite(p_game.Content.Load <Texture2D>("JK_Nexile_Logo")); JKContentManager.NexileLogo.center = Vector2.One / 2f; JKContentManager.SlopeTexture = p_game.Content.Load <Texture2D>("slopes"); JKContentManager.SlopeSprites.LoadSprites(); JKContentManager.GUI.Load(p_game.Content); JKContentManager.Shaders.Mask = new MaskShader(p_game.Content.Load <Effect>("shaders/Mask")); JKContentManager.Shaders.test_mask = p_game.Content.Load <Texture2D>("shaders/test_mask"); //custom screens JKContentManager.m_foregrounds = JKExtensions.UltraContent.LoadCunt <Texture2D>(p_game.Content, "mods/screens/foreground", ".*"); JKContentManager.m_backgrounds = JKExtensions.UltraContent.LoadCunt <Texture2D>(p_game.Content, "mods/screens/midground", ".*"); JKContentManager.m_backbackgrounds = JKExtensions.UltraContent.LoadCunt <Texture2D>(p_game.Content, "mods/screens/background", ".*"); JKContentManager.ScrollingBackgrounds = JKExtensions.UltraContent.LoadCunt <Texture2D>(p_game.Content, "mods/screens/scrolling/textures", ".*"); JKContentManager.m_weather_masks = JKExtensions.UltraContent.LoadCunt <Texture2D>(p_game.Content, "mods/screens/masks", ".*"); JKContentManager.m_scrolling_bg_data = UltraContent.LoadXmlFiles <JumpKing.Level.Data.ScrollingBGdata>(p_game, "mods/screens/scrolling", ".xml"); //modded NPCs.Load(p_game.Content); Raven.Load(p_game.Content); Particles.Load(p_game.Content); Music.Load(p_game.Content); Props.Load(p_game.Content); Fonts.Load(p_game.Content); Endings.Load(p_game.Content); King.Load(p_game.Content); JKContentManager.MiscSettings.CustomLoad(p_game.Content); }
public static Path GetPath(NancyModule module, dynamic parameters, Raven.Client.IDocumentSession session) { var pathId = String.Format("{0}/{1}", module.ModulePath, parameters.id.Value as string); pathId = pathId.Replace("api/", ""); var path = session.Load<Path>(pathId); return path; }
public static void ValidateMenu(Menu menu, string enterpriseId, Raven.Client.IDocumentSession session, Abstract.ILogger _logger) { var allProductIds = menu.Categories.SelectMany(c => c.Products); var productIds = allProductIds as string[] ?? allProductIds.ToArray(); var allProducts = session.Load<Product>(productIds); //Check if all products belongs to this enterprise foreach (var product in allProducts.Where(product => product != null && product.Enterprise != enterpriseId).ToList()) { foreach (var category in from category in menu.Categories from c in category.Products.Where(c => c == product.Id).ToList() select category) { category.Products.Remove(product.Id); } _logger.Warn("Product '{0}' belongs to enterprise: '{1}' was about to be added to '{2}' Code:[hTrsvv563]", product.Id, product.Enterprise, enterpriseId); } //Remove category if it does not have any products foreach (var category in menu.Categories.Where(category => category.Products.Count == 0).ToList()) { menu.Categories.Remove(category); } try { var productDuplicates = productIds.GroupBy(p => p.ToUpper()).SelectMany(grp => grp.Skip(1)); foreach (var productDuplicate in productDuplicates) { _logger.Warn("Duplicate in products found: {0}, Enterprise: {1}", productDuplicate, enterpriseId); } var categoryDuplicates = menu.Categories.GroupBy(c => c.Id.ToUpper()).SelectMany(grp => grp.Skip(1)); foreach (var categoryDuplicate in categoryDuplicates) { _logger.Info("Duplicate in categories found: Name: {0}, Id: {1}, Enterprise: {2}", categoryDuplicate.Name, categoryDuplicate.Id, enterpriseId); categoryDuplicate.Id = GeneralHelper.GetGuid(); } } catch (Exception ex) { _logger.Fatal("ValidateMenu, duplicate check!", ex); } }
public static bool ValidEditableEnterprise(Enterprise enterprise, Raven.Client.IDocumentSession session) { if(enterprise != null) { if (enterprise.OwnedByAccount) { //If enterprise is owned by an account, check if current account is the correct one var account = session.Load<Account>(HttpContext.Current.User.Identity.Name); return (account.Enterprises.Contains(enterprise.Id) || account.IsAdmin) && account.Enabled; } //Add product to a new enterprise if (enterprise.IsNew) return true; //Add product to an enterprise in edit-mode if (!enterprise.LockedFromEdit) return true; } return false; }
public static Result<None> Delete(Raven.Client.IDocumentSession session, string feedId, string blogPostId) { try { var feed = session.Load<BlogFeed>(feedId); if (feed == null) return None.False(new ArgumentException("Feed Id is not found")); var post = session.Load<BlogPost>(blogPostId); if (post == null) return None.False(new ArgumentException("Blog Id is not found")); session.Delete(post); feed.MarkAsUpdated(); session.Store(feed); session.SaveChanges(); return None.True(); } catch (Exception ex) { return None.False(ex); } }