Пример #1
0
        /// <summary>
        /// Add custom attack button and squad list
        /// </summary>
        public static void SetupPanel(CharacterOverviewUI panel)
        {
            const string AttackLbl = "Attack";
            const string MoveToLbl = "Move To";
            const string ListItemFormat = "{0} ({1})";

            var controls = panel.Controls.Where(c => c is ClipBox).Single().Controls;
            var oldAttackBtn = controls.Where(c => c.Text == AttackLbl).SingleOrDefault();

            if (oldAttackBtn == null)
                return;

            panel.Remove(oldAttackBtn);
            oldAttackBtn = null;

            var target = (Character)panelTarget.GetValue(panel);
            var moveToBtn = controls.Where(c => c.Text == MoveToLbl).SingleOrDefault();
            var squadNames = GnomanEmpire.Instance.Fortress.Military.Squads.Select((s, i) => new
                                                                                             {
                                                                                                 Index = i,
                                                                                                 Text = string.Format(ListItemFormat, s.Name, s.Members.Count(m => m != null)),
                                                                                                 CanAttack = s.Formation.CarryOutAttackOrders
                                                                                             })
                                                                           .Where(s => s.CanAttack)
                                                                           .OrderBy(s => s.Text);

            var newAttackBtn = new Button(panel.Manager);
            newAttackBtn.Init();
            newAttackBtn.Margins = new Margins(4, 0, 4, 0);
            newAttackBtn.Left = moveToBtn.Left + moveToBtn.Width + moveToBtn.Margins.Right + newAttackBtn.Margins.Left;
            newAttackBtn.Top = moveToBtn.Top;
            newAttackBtn.Text = "Attack";
            newAttackBtn.Width = 125;

            LoweredPanel loweredPanel = new LoweredPanel(panel.Manager);
            loweredPanel.Init();
            loweredPanel.Left = newAttackBtn.Left + newAttackBtn.Width + newAttackBtn.Margins.Right + loweredPanel.Margins.Left;
            loweredPanel.Top = moveToBtn.Top;
            loweredPanel.Width = 235;
            loweredPanel.Height = panel.ClientHeight - loweredPanel.Top - loweredPanel.Margins.Bottom;
            loweredPanel.Anchor = Anchors.Vertical | Anchors.Horizontal;
            loweredPanel.AutoScroll = true;
            loweredPanel.Passive = true;
            loweredPanel.CanFocus = false;

            CheckBoxTree tree = new CheckBoxTree(panel.Manager);
            tree.Init();
            tree.Left = tree.Margins.Left;
            tree.Top = tree.Margins.Top;
            tree.Expanded = true;
            tree.Width = loweredPanel.Width;
            tree.Anchor = Anchors.Top | Anchors.Horizontal;
            tree.Text = Military.AllSquadsDisplay;

            foreach (var squad in squadNames)
                tree.AddChild(CreateCheckbox(panel.Manager, squad.Text, squad.Index));

            tree.EvaluateState();
            panel.Add(loweredPanel);
            loweredPanel.Add(tree);

            newAttackBtn.Click += (object sender, Game.GUI.Controls.EventArgs e) =>
            {
                GnomanEmpire.Instance.Fortress.Military.AddAttackTarget(target);    // For save compatibility
                var checkBoxes = tree.Controls.Where(c => c is ClipBox).Single().Controls.Where(c => c is CheckBox && ((CheckBox)c).Checked && c.Tag != null);
                military.AddTarget(checkBoxes.Select(c => (int)c.Tag), target);
            };

            panel.Add(newAttackBtn);
        }
Пример #2
0
        public AboutModsPanel(Panel containingPanel, IModManager modManager, int desiredHeight = 500, int desiredWidth = 750)
        {
            _modManager = modManager;

            ModListBox = new ListBox(containingPanel.Manager);
            ModListBox.Init();
            ModListBox.Top = ModListBox.Margins.Top;
            ModListBox.Left = ModListBox.Margins.Left;
            ModListBox.Width = 250;
            ModListBox.Height = desiredHeight - containingPanel.ClientMargins.Vertical - ModListBox.Top - ModListBox.Margins.Bottom;
            ModListBox.HideSelection = false;

            ModListBox.c81fb310624c15a101535d14adc9ec383.Add("Gnomodia");
            ModListBox.ItemIndexChanged += ModListBoxOnItemIndexChanged;

            foreach (var modMetadata in modManager.ModMetadata)
            {
                ModListBox.c81fb310624c15a101535d14adc9ec383.Add(modMetadata.Name);
            }

            containingPanel.Add(ModListBox);

            ModInfoPanel = new LoweredPanel(containingPanel.Manager);
            ModInfoPanel.Init();
            ModInfoPanel.Left = ModListBox.Left + ModListBox.Width + ModListBox.Margins.Right + ModInfoPanel.Margins.Left;
            ModInfoPanel.Top = ModInfoPanel.Margins.Top;
            ModInfoPanel.Width = desiredWidth - ModInfoPanel.Left - ModInfoPanel.Margins.Right;
            ModInfoPanel.Height = desiredHeight - containingPanel.ClientMargins.Vertical - ModInfoPanel.Top - ModInfoPanel.Margins.Bottom;
            ModInfoPanel.AutoScroll = true;
            ModInfoPanel.HorizontalScrollBarEnabled = false;
            ModInfoPanel.VerticalScrollBarShow = true;
            containingPanel.Add(this.ModInfoPanel);

            _titleLabel = new Label(containingPanel.Manager);
            _titleLabel.Init();
            _titleLabel.Top = _titleLabel.Margins.Top;
            _titleLabel.Left = _titleLabel.Margins.Left;
            _titleLabel.Height = 14;
            _titleLabel.Width = ModInfoPanel.ClientWidth - _titleLabel.Margins.Horizontal;
            _titleLabel.Text = "";
            ModInfoPanel.Add(_titleLabel);

            _versionLabel = new Label(containingPanel.Manager);
            _versionLabel.Init();
            _versionLabel.Left = _versionLabel.Margins.Left;
            _versionLabel.Height = 14;
            _versionLabel.Width = ModInfoPanel.Width - _versionLabel.Margins.Horizontal;
            _versionLabel.Top = _titleLabel.Top + _titleLabel.Height + _titleLabel.Margins.Bottom + _versionLabel.Margins.Top;
            _versionLabel.Text = "";
            ModInfoPanel.Add(_versionLabel);

            _authorLabel = new Label(containingPanel.Manager);
            _authorLabel.Init();
            _authorLabel.Left = _authorLabel.Margins.Left;
            _authorLabel.Height = 14;
            _authorLabel.Width = ModInfoPanel.Width - _authorLabel.Margins.Horizontal;
            _authorLabel.Top = _versionLabel.Top + _versionLabel.Height + _versionLabel.Margins.Bottom + _authorLabel.Margins.Top;
            _authorLabel.Text = "";
            ModInfoPanel.Add(_authorLabel);

            _infoLabel = new MultilineLabel(containingPanel.Manager);
            _infoLabel.Left = _infoLabel.Margins.Left;
            _infoLabel.Height = 0;
            _infoLabel.Top = _authorLabel.Top + _authorLabel.Height + _authorLabel.Margins.Bottom + _infoLabel.Margins.Top;
            _infoLabel.Width = ModInfoPanel.ClientWidth - _infoLabel.Margins.Horizontal;
            _infoLabel.Anchor = Anchors.Top | Anchors.Left | Anchors.Right;
            _infoLabel.Alignment = Alignment.TopLeft;
            ModInfoPanel.Add(_infoLabel);

            ModListBox.ItemIndex = 0;
        }
Пример #3
0
        public AboutModsPanel(Panel containingPanel, IModManager modManager, int desiredHeight = 500, int desiredWidth = 750)
        {
            _modManager = modManager;

            ModListBox = new ListBox(containingPanel.Manager);
            ModListBox.Init();
            ModListBox.Top           = ModListBox.Margins.Top;
            ModListBox.Left          = ModListBox.Margins.Left;
            ModListBox.Width         = 250;
            ModListBox.Height        = desiredHeight - containingPanel.ClientMargins.Vertical - ModListBox.Top - ModListBox.Margins.Bottom;
            ModListBox.HideSelection = false;

            ModListBox.c81fb310624c15a101535d14adc9ec383.Add("Gnomodia");
            ModListBox.ItemIndexChanged += ModListBoxOnItemIndexChanged;

            foreach (var modMetadata in modManager.ModMetadata)
            {
                ModListBox.c81fb310624c15a101535d14adc9ec383.Add(modMetadata.Name);
            }

            containingPanel.Add(ModListBox);

            ModInfoPanel = new LoweredPanel(containingPanel.Manager);
            ModInfoPanel.Init();
            ModInfoPanel.Left       = ModListBox.Left + ModListBox.Width + ModListBox.Margins.Right + ModInfoPanel.Margins.Left;
            ModInfoPanel.Top        = ModInfoPanel.Margins.Top;
            ModInfoPanel.Width      = desiredWidth - ModInfoPanel.Left - ModInfoPanel.Margins.Right;
            ModInfoPanel.Height     = desiredHeight - containingPanel.ClientMargins.Vertical - ModInfoPanel.Top - ModInfoPanel.Margins.Bottom;
            ModInfoPanel.AutoScroll = true;
            ModInfoPanel.HorizontalScrollBarEnabled = false;
            ModInfoPanel.VerticalScrollBarShow      = true;
            containingPanel.Add(this.ModInfoPanel);

            _titleLabel = new Label(containingPanel.Manager);
            _titleLabel.Init();
            _titleLabel.Top    = _titleLabel.Margins.Top;
            _titleLabel.Left   = _titleLabel.Margins.Left;
            _titleLabel.Height = 14;
            _titleLabel.Width  = ModInfoPanel.ClientWidth - _titleLabel.Margins.Horizontal;
            _titleLabel.Text   = "";
            ModInfoPanel.Add(_titleLabel);

            _versionLabel = new Label(containingPanel.Manager);
            _versionLabel.Init();
            _versionLabel.Left   = _versionLabel.Margins.Left;
            _versionLabel.Height = 14;
            _versionLabel.Width  = ModInfoPanel.Width - _versionLabel.Margins.Horizontal;
            _versionLabel.Top    = _titleLabel.Top + _titleLabel.Height + _titleLabel.Margins.Bottom + _versionLabel.Margins.Top;
            _versionLabel.Text   = "";
            ModInfoPanel.Add(_versionLabel);

            _authorLabel = new Label(containingPanel.Manager);
            _authorLabel.Init();
            _authorLabel.Left   = _authorLabel.Margins.Left;
            _authorLabel.Height = 14;
            _authorLabel.Width  = ModInfoPanel.Width - _authorLabel.Margins.Horizontal;
            _authorLabel.Top    = _versionLabel.Top + _versionLabel.Height + _versionLabel.Margins.Bottom + _authorLabel.Margins.Top;
            _authorLabel.Text   = "";
            ModInfoPanel.Add(_authorLabel);

            _infoLabel           = new MultilineLabel(containingPanel.Manager);
            _infoLabel.Left      = _infoLabel.Margins.Left;
            _infoLabel.Height    = 0;
            _infoLabel.Top       = _authorLabel.Top + _authorLabel.Height + _authorLabel.Margins.Bottom + _infoLabel.Margins.Top;
            _infoLabel.Width     = ModInfoPanel.ClientWidth - _infoLabel.Margins.Horizontal;
            _infoLabel.Anchor    = Anchors.Top | Anchors.Left | Anchors.Right;
            _infoLabel.Alignment = Alignment.TopLeft;
            ModInfoPanel.Add(_infoLabel);

            ModListBox.ItemIndex = 0;
        }
Пример #4
0
        /// <summary>
        /// Add custom attack button and squad list
        /// </summary>
        public static void SetupPanel(CharacterOverviewUI panel)
        {
            const string AttackLbl      = "Attack";
            const string MoveToLbl      = "Move To";
            const string ListItemFormat = "{0} ({1})";

            var controls     = panel.Controls.Where(c => c is ClipBox).Single().Controls;
            var oldAttackBtn = controls.Where(c => c.Text == AttackLbl).SingleOrDefault();

            if (oldAttackBtn == null)
            {
                return;
            }

            panel.Remove(oldAttackBtn);
            oldAttackBtn = null;

            var target     = (Character)panelTarget.GetValue(panel);
            var moveToBtn  = controls.Where(c => c.Text == MoveToLbl).SingleOrDefault();
            var squadNames = GnomanEmpire.Instance.Fortress.Military.Squads.Select((s, i) => new
            {
                Index     = i,
                Text      = string.Format(ListItemFormat, s.Name, s.Members.Count(m => m != null)),
                CanAttack = s.Formation.CarryOutAttackOrders
            })
                             .Where(s => s.CanAttack)
                             .OrderBy(s => s.Text);

            var newAttackBtn = new Button(panel.Manager);

            newAttackBtn.Init();
            newAttackBtn.Margins = new Margins(4, 0, 4, 0);
            newAttackBtn.Left    = moveToBtn.Left + moveToBtn.Width + moveToBtn.Margins.Right + newAttackBtn.Margins.Left;
            newAttackBtn.Top     = moveToBtn.Top;
            newAttackBtn.Text    = "Attack";
            newAttackBtn.Width   = 125;

            LoweredPanel loweredPanel = new LoweredPanel(panel.Manager);

            loweredPanel.Init();
            loweredPanel.Left       = newAttackBtn.Left + newAttackBtn.Width + newAttackBtn.Margins.Right + loweredPanel.Margins.Left;
            loweredPanel.Top        = moveToBtn.Top;
            loweredPanel.Width      = 235;
            loweredPanel.Height     = panel.ClientHeight - loweredPanel.Top - loweredPanel.Margins.Bottom;
            loweredPanel.Anchor     = Anchors.Vertical | Anchors.Horizontal;
            loweredPanel.AutoScroll = true;
            loweredPanel.Passive    = true;
            loweredPanel.CanFocus   = false;

            CheckBoxTree tree = new CheckBoxTree(panel.Manager);

            tree.Init();
            tree.Left     = tree.Margins.Left;
            tree.Top      = tree.Margins.Top;
            tree.Expanded = true;
            tree.Width    = loweredPanel.Width;
            tree.Anchor   = Anchors.Top | Anchors.Horizontal;
            tree.Text     = Military.AllSquadsDisplay;

            foreach (var squad in squadNames)
            {
                tree.AddChild(CreateCheckbox(panel.Manager, squad.Text, squad.Index));
            }

            tree.EvaluateState();
            panel.Add(loweredPanel);
            loweredPanel.Add(tree);

            newAttackBtn.Click += (object sender, Game.GUI.Controls.EventArgs e) =>
            {
                GnomanEmpire.Instance.Fortress.Military.AddAttackTarget(target);    // For save compatibility
                var checkBoxes = tree.Controls.Where(c => c is ClipBox).Single().Controls.Where(c => c is CheckBox && ((CheckBox)c).Checked && c.Tag != null);
                military.AddTarget(checkBoxes.Select(c => (int)c.Tag), target);
            };

            panel.Add(newAttackBtn);
        }