コード例 #1
0
        private void UpdateGUIPosition()
        {
            const int SECTION_PADDING = 50;
            const int OPTION_PADDING  = 10;
            const int LABEL_PADDING   = 3;


            _lblTitle.Position = new Vector2i(_boundingArea.Left + 10, _boundingArea.Top + 10);
            _lblTitle.Update(0);

            _lstResolution.Position = new Vector2i(_boundingArea.Left + SECTION_PADDING,
                                                   _lblTitle.Position.Y + _lblTitle.ClientArea.Height + SECTION_PADDING);
            _lstResolution.Update(0);

            _chkFullscreen.Position = new Vector2i(_lstResolution.Position.X,
                                                   _lstResolution.Position.Y + _lstResolution.ClientArea.Height + SECTION_PADDING);
            _chkFullscreen.Update(0);
            _lblFullscreen.Position = new Vector2i(_chkFullscreen.Position.X + _chkFullscreen.ClientArea.Width + LABEL_PADDING,
                                                   _chkFullscreen.Position.Y);
            _lblFullscreen.Update(0);

            _chkVsync.Position = new Vector2i(_lblFullscreen.Position.X,
                                              _lblFullscreen.Position.Y + _lblFullscreen.ClientArea.Height + OPTION_PADDING);
            _chkVsync.Update(0);
            _lblVsync.Position = new Vector2i(_chkVsync.Position.X + _chkVsync.ClientArea.Width + LABEL_PADDING,
                                              _chkVsync.Position.Y);
            _lblVsync.Update(0);

            _btnApply.Position = new Vector2i((_boundingArea.Left + _boundingArea.Width) - (_btnApply.ClientArea.Width + SECTION_PADDING),
                                              (_boundingArea.Top + _boundingArea.Height) - (_btnApply.ClientArea.Height + SECTION_PADDING));
            _btnApply.Update(0);
            _btnBack.Position = new Vector2i(_btnApply.Position.X - (_btnBack.ClientArea.Width + OPTION_PADDING), _btnApply.Position.Y);
            _btnBack.Update(0);
        }
コード例 #2
0
        public void AddLine(string text, Color color)
        {
            bool  atBottom = scrollbarV.Value >= scrollbarV.max;
            Label newLabel = new Label(text, "CALIBRI", this._resourceManager)
            {
                Position  = new Vector2i(5, last_y),
                TextColor = color
            };

            newLabel.Update(0);
            last_y = newLabel.ClientArea.Bottom();
            components.Add(newLabel);
            if (atBottom)
            {
                Update(0);
                scrollbarV.Value = scrollbarV.max;
            }
        }
コード例 #3
0
        public override void Update(float frameTime)
        {
            const int x_inner   = 4;
            const int y_inner   = 25;
            const int dec_inner = 7;

            panelBG.Position            = new Vector2f(Position.X, Position.Y);
            healthMeterBg.Position      = new Vector2f(Position.X + x_inner, Position.Y + y_inner);
            healthMeterOverlay.Position = new Vector2f(Position.X + x_inner, Position.Y + y_inner);
            healthMeterGrid.Position    = new Vector2f(Position.X + x_inner, Position.Y + y_inner);

            var panelBounds = panelBG.GetLocalBounds();

            ClientArea = new FloatRect(panelBounds.Left, panelBounds.Top, panelBounds.Width, panelBounds.Height).Round();

            var healthMeterBounds = healthMeterOverlay.GetLocalBounds();

            healthMeterInner = new IntRect(Position.X + x_inner + dec_inner, Position.Y + y_inner + dec_inner,
                                           (int)(healthMeterBounds.Width - (2 * dec_inner)),
                                           (int)(healthMeterBounds.Height - (2 * dec_inner)));
            healthPc.Position = new Vector2i(healthMeterInner.Left + 5,
                                             (int)
                                             (healthMeterInner.Top + (healthMeterInner.Height / 2f) -
                                              (healthPc.ClientArea.Height / 2f)) - 2);
            healthPc.Update(frameTime);

            IEntity entity = _playerManager.ControlledEntity;

            if (entity != null && entity.HasComponent(ComponentFamily.Damageable))
            {
                var comp = (HealthComponent)entity.GetComponent(ComponentFamily.Damageable);

                healthPct = comp.GetHealth() / comp.GetMaxHealth();
                if (float.IsNaN(healthPct))
                {
                    healthPct = 1;                         //This can happen when the components are not ready yet.
                }
                interpCol          = ColorUtils.InterpolateBetween(ColCritical, ColHealthy, healthPct);
                healthPc.Text.Text = Math.Round((healthPct * 100)).ToString() + "%";
            }

            blipTime += frameTime;
        }
コード例 #4
0
        public void AddLine(string message, ChatChannel channel)
        {
            if (_disposing)
            {
                return;
            }

            int lineHeight = 12;

            bool atBottom = scrollbarV.Value >= scrollbarV.max;

            foreach (string content in CheckInboundMessage(message))
            {
                var label = new Label(content, "CALIBRI", _resourceManager)
                {
                    Position = new Vector2i(5, last_y),
                    Text     =
                    {
                        Size  = new Vector2i(ClientArea.Width - 10, lineHeight),
                        Color = _chatColors[channel],
                    }
                };
                label.Update(0);
                last_y = label.ClientArea.Bottom();
                components.Add(label);

                // If the message had newlines adjust the bottom to fix the extra lines
                if (message.Split('\n').Length > 0)
                {
                    last_y += lineHeight * (message.Split('\n').Length - 1);
                }
            }

            if (atBottom)
            {
                Update(0);
                scrollbarV.Value = scrollbarV.max;
            }
        }
コード例 #5
0
        private void BuildTileList(string searchStr = null)
        {
            int maxWidth = 0;
            int yOffset  = 5;

            _tileList.components.Clear();
            _tileList.ResetScrollbars();

            var tileDefs = IoCManager.Resolve <ITileDefinitionManager>().Select(td => td.Name);

            if (!string.IsNullOrEmpty(searchStr))
            {
                tileDefs = tileDefs.Where(s => s.IndexOf(searchStr, StringComparison.InvariantCultureIgnoreCase) >= 0);
                _clearLabel.BackgroundColor = new SFML.Graphics.Color(211, 211, 211);
            }

            foreach (string entry in tileDefs)
            {
                var tileLabel = new Label(entry, "CALIBRI", _resourceManager);
                _tileList.components.Add(tileLabel);
                tileLabel.Position       = new Vector2i(5, yOffset);
                tileLabel.DrawBackground = true;
                tileLabel.DrawBorder     = true;
                tileLabel.Update(0);
                yOffset           += 5 + tileLabel.ClientArea.Height;
                tileLabel.Clicked += TileLabelClicked;
                if (tileLabel.ClientArea.Width > maxWidth)
                {
                    maxWidth = tileLabel.ClientArea.Width;
                }
            }

            foreach (GuiComponent curr in _tileList.components.Where(curr => curr.GetType() == typeof(Label)))
            {
                ((Label)curr).FixedWidth = maxWidth;
            }
        }