Пример #1
0
        ButtonWidget AddSettingsTab(string id, string label)
        {
            var tab        = tabTemplate.Clone() as ButtonWidget;
            var lastButton = buttons.LastOrDefault();

            if (lastButton != null)
            {
                tab.Bounds.X = lastButton.Bounds.X + buttonStride.X;
                tab.Bounds.Y = lastButton.Bounds.Y + buttonStride.Y;
            }

            tab.Id            = id;
            tab.GetText       = () => label;
            tab.IsHighlighted = () => activePanel == id;
            tab.OnClick       = () =>
            {
                needsRestart |= leavePanelActions[activePanel]();
                Game.Settings.Save();
                activePanel = id;
            };

            tabContainer.AddChild(tab);
            buttons.Add(tab);

            return(tab);
        }
Пример #2
0
        void RebuildModList()
        {
            modList.RemoveChildren();

            var width       = modTemplate.Bounds.Width;
            var height      = modTemplate.Bounds.Height;
            var innerMargin = modTemplate.Bounds.Left;
            var outerMargin = (modList.Bounds.Width - Math.Min(5, allMods.Length) * width - 4 * innerMargin) / 2;
            var stride      = width + innerMargin;

            for (var i = 0; i < 5; i++)
            {
                var j = i + modOffset;
                if (j >= allMods.Length)
                {
                    break;
                }

                var mod = allMods[j];

                var item = modTemplate.Clone() as ButtonWidget;
                item.Bounds        = new Rectangle(outerMargin + i * stride, 0, width, height);
                item.IsHighlighted = () => selectedMod == mod;
                item.OnClick       = () => SelectMod(mod);
                item.OnDoubleClick = () => LoadMod(mod);
                item.OnKeyPress    = e =>
                {
                    if (e.MultiTapCount == 2)
                    {
                        LoadMod(mod);
                    }
                    else
                    {
                        SelectMod(mod);
                    }
                };

                item.TooltipText = mod.Title;

                if (j < 9)
                {
                    item.Key = new Hotkey((Keycode)((int)Keycode.NUMBER_1 + j), Modifiers.None);
                }

                Sprite logo = null;
                logos.TryGetValue(mod.Id, out logo);
                item.Get <RGBASpriteWidget>("MOD_LOGO").GetSprite = () => logo;
                item.Get("MOD_NO_LOGO").IsVisible = () => logo == null;

                modList.AddChild(item);
            }
        }
Пример #3
0
        ButtonWidget AddButton(string id, string text)
        {
            var button     = buttonTemplate.Clone() as ButtonWidget;
            var lastButton = buttons.LastOrDefault();

            if (lastButton != null)
            {
                button.Bounds.X = lastButton.Bounds.X + buttonStride.X;
                button.Bounds.Y = lastButton.Bounds.Y + buttonStride.Y;
            }

            button.Id         = id;
            button.IsDisabled = () => leaving;
            button.GetText    = () => text;
            buttonContainer.AddChild(button);
            buttons.Add(button);

            return(button);
        }