示例#1
0
        public override void DoSettingsWindowContents(Rect inRect)
        {
            if (skipFlowInitOnce)
            {
                skipFlowInitOnce = false;
                return;
            }
            if (flow == null)
            {
                List <Pair <string, Action <Flow> > > buttonInstructions = new List <Pair <string, Action <Flow> > >();
                Dictionary <string, PageRenderer>     pages = new Dictionary <string, PageRenderer>();
                pages.Add("menu", new PageRenderer((f => "Menu"), null, null)
                          .AddChild(new FilteredGridListRenderer <Pair <string, Action <Flow> > >(buttonInstructions, -1, -1)
                                    .AddChild(new ButtonTextRenderer(f => ((Pair <string, Action <Flow> >)((IterationItem)f.pageScope["curItem"]).curItem).First, f => ((Pair <string, Action <Flow> >)((IterationItem)f.pageScope["curItem"]).curItem).Second(f), GameFont.Small, 200f))));

                foreach (SettingsProperties props in SettingsStorage.getAllSettingsProperties())
                {
                    if (props.visualization.displayInMenu)
                    {
                        if (props.visualization.displaySelection)
                        {
                            pages.Add("edit" + props.id, editPage(props, "select" + props.id, pages));
                            List <ISettingsInstance> lst = SettingsStorage.generateListForSelection(props);
                            pages.Add("select" + props.id, selectPage(((ISettingsVisualizationSelection)props.visualization).selectPageTitle, "menu", lst, "edit" + props.id));
                            buttonInstructions.Add(new Pair <string, Action <Flow> >(((ISettingsVisualizationMenu)props.visualization).mainMenuButtonLabel, f => f.navigate("select" + props.id)));
                        }
                        else
                        {
                            //editing a singleton object means we pass over selection but set the selected object to the singleton instance
                            pages.Add("edit" + props.id, editPage(props, "menu", pages));
                            ISettingsInstance inst = SettingsStorage.generateSingletonObject(props);
                            buttonInstructions.Add(new Pair <string, Action <Flow> >(((ISettingsVisualizationMenu)props.visualization).mainMenuButtonLabel,
                                                                                     f => { f.flowScope["edit"] = inst; f.navigate("edit" + props.id); }));
                        }
                    }
                }

                flow = new Flow(pages, "menu");
            }
            flow.DoFlowContents(inRect);
        }