private void Continue_Handler(object sender, EventArgs e) { IGameOption SelectedOptions = null; FlorineSkiaOptionSet OptionSet = PrimaryOptions as FlorineSkiaOptionSet; if (null != OptionSet) { SelectedOptions = OptionSet.Selected; } IPage Next = _controller.UserOption(SelectedOptions); Content = _foundry.RenderPage(_controller.CurrentState); }
/* Option Set Transformations ===================================================================== */ private IGameOptionSet _renderOptionSet(IGameOptionSet opts) { if (null == opts) { return(null); } FlorineSkiaOptionSet newSet = new FlorineSkiaOptionSet() { SelectionLimit = opts.SelectionLimit, }; if (opts.Finalizer != null) { newSet.Finalizer = _renderOption(opts.Finalizer, newSet); } foreach (IGameOption opt in opts) { newSet.Add(_renderOption(opt, newSet)); } return(newSet); }
private void _readyIPage(IPage Source, GameState gameState) { if (null != Source.Background) { SKCanvasView Header = new SKCanvasView(); IFlorineSkiaConnectable iconn = Source.Background as IFlorineSkiaConnectable; if (null != iconn) { iconn.ConnectCanvasView(Header); } _components.Add( new PageComponent( _inc(PageComponentType.Background), Header ) ); } if (null != Source.Title) { SKCanvasView Message = new SKCanvasView(); ImageText itconn = new ImageText(Source.Title); itconn.ConnectCanvasView(Message); _components.Add( new PageComponent( _inc(PageComponentType.Title), Message ) ); } if (null != Source.Message && "" != Source.Message) { SKCanvasView Message = new SKCanvasView(); ImageText itconn = new ImageText(Source.Message) { Overflow = ImageText.WrapType.WordWrap, FontSize = 48.0f, AutoBackground = ( Source.MainType == GameState.PageType.Summarize_Activity ) }; itconn.ConnectCanvasView(Message); _components.Add( new PageComponent( _inc(PageComponentType.Message), Message ) ); } IGameOptionSet DescriptionSet = Source.AppliedOptions; _readyOptionSet( PageComponentType.PickedOption, Source.AppliedOptions ); PrimaryOptions = Source.PrimaryOptions; _readyOptionSet( PageComponentType.Option, PrimaryOptions ); if (null != Source.PrimaryOptions) { if (PrimaryOptions.Count > 0) { DescriptionSet = PrimaryOptions; } _readyOption( PageComponentType.Footer, Source.PrimaryOptions.Finalizer, Continue_Handler ); } if (null != DescriptionSet) { FlorineSkiaOptionSet FSO = DescriptionSet as FlorineSkiaOptionSet; if (FSO != null) { SKCanvasView Desc = new SKCanvasView(); FSO.UpdaterHook.ConnectCanvasView(Desc); _components.Add( new PageComponent( _inc(PageComponentType.Description), Desc ) ); } } SourcePage = Source; if (null != gameState.Player) { SKCanvasView avatar = new SKCanvasView(); IFlorineSkiaConnectable itconn = gameState.Player.Avatar.Picture as IFlorineSkiaConnectable; itconn.ConnectCanvasView(avatar); _components.Add( new PageComponent( _inc(PageComponentType.Player), avatar ) ); } }
private IGameOption _renderOption(IGameOption opt, FlorineSkiaOptionSet Container) { FlorineSkiaOption newOpt = new FlorineSkiaOption(opt, Container); if (null != newOpt.SubOptions) { newOpt.SubOptions = _renderOptionSet(opt.SubOptions); } // Absurdly Hackity String pathType = "food"; if (opt is Activity) { //Activity newOpt.Description = ((Activity)opt).Description; Container.SelectionModel = FlorineSkiaOptionSet.SelectionType.SELECT_MOVE; pathType = "activities"; string tokenName = opt.OptionName; SKImage ResultImage = ResourceLoader.LoadImage("Images/" + pathType + "/" + tokenName.ToLower() + ".png"); newOpt.Picture = new SelectableOptionImage() { FoodImage = ((null == ResultImage) ? (IFlorineSkiaDrawable)(new ImageText(tokenName)) : (IFlorineSkiaDrawable)(new FlOval() { mainImage = ResultImage, backgroundColor = new SKPaint() { Color = new SKColor(230, 230, 230) } })) }; } else { // Food FlorineSkiaOption SourceOpt = opt as FlorineSkiaOption; Food.FoodOption food_data = opt as Food.FoodOption; if (null == food_data && SourceOpt != null) { food_data = SourceOpt.SourceOpt as Food.FoodOption; } if (null != food_data) { newOpt.Description = food_data.Parent.Description; } else { newOpt.Description = "Desc Missing"; } List <Tuple <float, SKColor> > MacroNuts = new List <Tuple <float, SKColor> >(); List <Tuple <float, SKColor> > MicroNuts = new List <Tuple <float, SKColor> >(); if (null != food_data && food_data.Parent.IsKnown) { // Populate nutrient info bars. // List<Tuple<float, SKColor>> foreach (KeyValuePair <Nutrient, NutrientAmount> kvp in food_data.Parent.Nutrients) { FlorineSkiaNutrient AdjNut = new FlorineSkiaNutrient(kvp.Key); float RelativeAmount = kvp.Key.RatioRDV(kvp.Value); //45 * ((float)(kvp.Value) / (float)(kvp.Key.DailyTarget)); //if (RelativeAmount > 45.0f) { RelativeAmount = 45.0f; } if (kvp.Key.Class == Nutrient.NutrientType.Macro) { RelativeAmount *= 180f / 4f; MacroNuts.Add(new Tuple <float, SKColor>( RelativeAmount, AdjNut.RingColor )); } else { if (RelativeAmount > 1f) { RelativeAmount = 1f; } RelativeAmount *= 180 / 6f; MicroNuts.Add(new Tuple <float, SKColor>( RelativeAmount, AdjNut.RingColor )); } } } string tokenName = opt.OptionName; switch (tokenName) { case "Grilled Cheese": tokenName = "grilledcheese"; break; case "Pancakes": tokenName = "pancakes"; break; case "Fruit": tokenName = "fruit"; break; case "Eggs": tokenName = "eggs"; break; case "Cereal": tokenName = "cereal"; break; case "Toaster Pastry": tokenName = "toastedpastry"; break; case "Toast": case "White Toast": case "Wheat Toast": case "Multigrain Toast": tokenName = "toast"; break; case "Strawberry Yogurt": tokenName = "yogurt"; break; case "Eggs, Bacon, and Toast": tokenName = "toasteggsbacon"; break; case "Hamburger": tokenName = "hamburger"; break; case "Chocolate Ice Cream": tokenName = "icecream"; break; case "Instant Noodles": tokenName = "instantnoodles"; break; case "Lamb Chops": tokenName = "lambchops"; break; case "Meatball Sub": tokenName = "meatballhero"; break; case "Peanut Butter & Jelly": tokenName = "pbj"; break; case "Pepperoni Pizza Slice": tokenName = "pizza"; break; case "Vegetable Soup": tokenName = "soup"; break; case "Spaghetti": tokenName = "spaghetti"; break; case "Spaghetti w/ Meatballs": tokenName = "spaghettiwmeatball"; break; case "Sushi Serving": tokenName = "sushi"; break; case "Tacos": tokenName = "tacos"; break; case "Donuts": tokenName = "donuts"; break; case "Cinnamon Roll": tokenName = "cinnamonroll"; break; case "Hamburger Combo": tokenName = "hamburgercombo"; break; case "Turkey Sandwich": tokenName = "sandwich"; break; case "Sandwich with Chips": tokenName = "sandwichwchips"; break; case "Salad": tokenName = "salad"; break; case "Fruit Smoothie": tokenName = "fruitsmoothie"; break; } SKImage ResultImage = ResourceLoader.LoadImage("Images/" + pathType + "/" + tokenName + ".png"); if (opt is FlorineHardCodedData.HardCodedDataFoundry.NoSelectFoodOption) { newOpt.Picture = new SelectableOptionImage() { FoodImage = new LayeredImage() { Layers = { new ImageText(opt.OptionName) { Overflow = ImageText.WrapType.DiamondWrap, FontSize = 32f }, new FlOval() { mainImage = null, backgroundColor = new SKPaint() { Color = new SKColor(212, 175, 5) }, RightRing = MicroNuts, LeftRing = MacroNuts, } } } }; } else { newOpt.Picture = new SelectableOptionImage() { FoodImage = ((null == ResultImage) ? (IFlorineSkiaDrawable)(new ImageText(opt.OptionName)) : (IFlorineSkiaDrawable)(new FlOval() { mainImage = ResultImage, backgroundColor = new SKPaint() { Color = new SKColor(230, 230, 230) }, RightRing = MicroNuts, LeftRing = MacroNuts, })) }; } } return(newOpt); }
public FlorineSkiaOption(IGameOption Parent, FlorineSkiaOptionSet Container) { _parent = Parent; _container = Container; }