Beispiel #1
0
        /// <summary>
        /// Generic Subscreen handler.
        /// </summary>
        public static void Handler()
        {
            //TODO: add more things, such as a status bar and a window with the exact results.
            if (Subscreens.FirstDraw)
            {
                UIManager.Initialize();
                Subscreens.FirstDraw = false;
                NoxicoGame.ClearKeys();
                Subscreens.Redraw = true;
            }
            if (Subscreens.Redraw)
            {
                Subscreens.Redraw = false;
                recipes           = GetPossibilities(Carrier);
                var h = recipes.Count < 40 ? recipes.Count : 40;
                if (h == 0)
                {
                    h++;
                }
                recipeWindow = new UIWindow(string.Empty)
                {
                    Top = 2, Left = 2, Width = 76, Height = h + 2
                };
                recipeList = new UIList(string.Empty, null, recipes.Select(r => r.Display))
                {
                    Top = 3, Left = 3, Width = 74, Height = h
                };
                recipeList.Enter = (s, e) =>
                {
                    if (recipes.Count == 0)
                    {
                        return;
                    }
                    var i = recipeList.Index;
                    recipes[i].Apply();
                    //Redetermine the possibilities and update the UI accordingly.
                    recipes = GetPossibilities(Carrier);
                    if (recipes.Count > 0)
                    {
                        recipeList.Items = recipes.Select(r => r.Display).ToList();
                        if (i >= recipeList.Items.Count)
                        {
                            i = recipeList.Items.Count - 1;
                        }
                        recipeList.Index = i;
                        h = recipes.Count < 40 ? recipes.Count : 40;
                    }
                    else
                    {
                        h = 1;
                        recipeList.Hidden = true;
                    }
                    recipeWindow.Height = h + 2;
                    recipeList.Height   = h;
                    NoxicoGame.Me.CurrentBoard.Redraw();
                    NoxicoGame.Me.CurrentBoard.Draw();
                    UIManager.Draw();
                };
                UIManager.Elements.Add(recipeWindow);
                UIManager.Elements.Add(new UILabel(i18n.GetString("craft_nothing"))
                {
                    Left = 3, Top = 3
                });
                UIManager.Elements.Add(recipeList);
                UIManager.Highlight = recipeList;
                UIManager.Draw();
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.Back) || NoxicoGame.IsKeyDown(KeyBinding.Items) || Vista.Triggers == XInputButtons.B)
            {
                NoxicoGame.ClearKeys();
                NoxicoGame.Immediate = true;
                NoxicoGame.Me.CurrentBoard.Redraw();
                NoxicoGame.Me.CurrentBoard.Draw(true);
                NoxicoGame.Mode      = UserMode.Walkabout;
                Subscreens.FirstDraw = true;
            }
            else
            {
                UIManager.CheckKeys();
            }
        }