Example #1
0
        public Menu()
        {
            Width = new StyleDimension {
                Percent = 1f
            };
            Height = new StyleDimension {
                Percent = 1f
            };

            UIPanel panel = new UIPanel
            {
                Width   = { Percent = 0.5f },
                Height  = { Percent = 0.5f },
                X       = { Percent = 0.5f },
                Y       = { Percent = 0.5f },
                Padding = new Padding(8f)
            };

            Append(panel);

            UIButton button = new UIButton
            {
                Width  = { Percent = 1f },
                Height = { Pixels = 40f },
                Y      = { Percent = 1f },
                Text   = new Translation("SaveAndQuit")
            };

            button.OnClick += () =>
            {
                GameLayer.Instance.Save();
                Game.Instance.Exit();
            };
            panel.Append(button);

            UISwitchButton buttonLanguage = new UISwitchButton("Czech", "English")
            {
                Width   = { Percent = 1f },
                Height  = { Pixels = 40f },
                Padding = new Padding(8f),
                Text    = new Translation("ChangeLanguage")
            };

            buttonLanguage.OnClick += () =>
            {
                buttonLanguage.Next();
                Localization.SetLanguage(buttonLanguage.choices[buttonLanguage.index] == "Czech" ? Language.Czech : Language.English);
            };
            panel.Append(buttonLanguage);
        }
Example #2
0
        public Sidebar()
        {
            Width = new StyleDimension {
                Percent = 0.2f
            };
            Height = new StyleDimension {
                Percent = 1f
            };
            X = new StyleDimension {
                Percent = 1f
            };
            MinWidth = 200f;
            Padding  = new Padding(8f);

            UIPanel panel = new UIPanel
            {
                Width           = { Percent = 1f },
                Height          = { Percent = 1f },
                BackgroundColor = new Color4(20, 20, 20, 255),
                Padding         = new Padding(8f)
            };

            Append(panel);

            UIGrid grid = new UIGrid
            {
                Width  = { Percent = 1f },
                Height = { Percent = 1f }
            };

            panel.Append(grid);

            foreach (Type type in Assembly.GetEntryAssembly().GetTypes().Where(x => !x.IsAbstract && x.IsSubclassOf(typeof(BaseElement))))
            {
                UIOpticalElement b = new UIOpticalElement(type)
                {
                    Width = { Percent = 0.5f, Pixels = -4f }
                };
                grid.Append(b);
            }
        }