Ejemplo n.º 1
0
        public override void Update(float frameTime)
        {
            if (disposing || !IsVisible())
            {
                return;
            }
            base.Update(frameTime);
            if (title == null || gradient == null)
            {
                return;
            }
            int y_pos = ClientArea.Top - (2 * titleBuffer) - title.ClientArea.Height + 1;

            title.Position = new Vector2i(ClientArea.Left + 3, y_pos + titleBuffer);
            titleArea      = Box2i.FromDimensions(ClientArea.Left, y_pos, ClientArea.Width, title.ClientArea.Height + (2 * titleBuffer));
            title.Update(frameTime);
            closeButton.Position = new Vector2i(titleArea.Right - 5 - closeButton.ClientArea.Width,
                                                titleArea.Top + (int)(titleArea.Height / 2f) -
                                                (int)(closeButton.ClientArea.Height / 2f));
            gradient.ClientArea = titleArea;
            gradient.Color1     = TitleColor1;
            gradient.Color2     = TitleColor2;
            gradient.Update(frameTime);
            closeButton.Update(frameTime);
        }
Ejemplo n.º 2
0
        public override void Update(float frameTime)
        {
            if (Disposing || !Visible)
            {
                return;
            }
            base.Update(frameTime);
            if (title == null || gradient == null)
            {
                return;
            }

            var y_pos = ClientArea.Top - 2 * titleBuffer - title.ClientArea.Height + 1;

            title.LocalPosition = Position + new Vector2i(ClientArea.Left + 3, y_pos + titleBuffer);
            titleArea           = Box2i.FromDimensions(ClientArea.Left, y_pos, ClientArea.Width, title.ClientArea.Height + 2 * titleBuffer);
            title.DoLayout();
            title.Update(frameTime);

            closeButton.LocalPosition = Position + new Vector2i(titleArea.Right - 5 - closeButton.ClientArea.Width,
                                                                titleArea.Top + (int)(titleArea.Height / 2f) -
                                                                (int)(closeButton.ClientArea.Height / 2f));
            closeButton.DoLayout();
            gradient.ClientArea = titleArea;
            gradient.Color1     = TitleColor1;
            gradient.Color2     = TitleColor2;
            gradient.Update(frameTime);
            closeButton.Update(frameTime);
        }
Ejemplo n.º 3
0
        public override void Update(float frameTime)
        {
            if (!IsVisible())
            {
                return;
            }
            base.Update(frameTime);
            var bounds = scrollbarButton.GetLocalBounds();

            if (Horizontal)
            {
                ClientArea       = Box2i.FromDimensions(Position, new Vector2i(size, (int)bounds.Height));
                clientAreaButton = Box2i.FromDimensions(Position.X + currentPos, Position.Y,
                                                        (int)bounds.Width, (int)bounds.Height);
                actualSize = size - (int)bounds.Width;
            }
            else
            {
                ClientArea       = Box2i.FromDimensions(Position, new Vector2i((int)bounds.Width, size));
                clientAreaButton = Box2i.FromDimensions(Position.X, Position.Y + currentPos,
                                                        (int)bounds.Width, (int)bounds.Height);
                actualSize = size - (int)bounds.Height;
            }

            stepSize  = (float)max / actualSize;
            actualVal = Math.Max(0, Math.Min((int)Math.Round(currentPos * stepSize), max));

            if (ValueChanged != null && RaiseEvent) //This is a bit ugly.
            {
                RaiseEvent = false;
                ValueChanged((int)actualVal);
            }
        }
Ejemplo n.º 4
0
        protected override void Draw(DrawingHandle handle)
        {
            if (!TryGetHands(out IHandsComponent hands))
            {
                return;
            }

            var leftActive = hands.ActiveIndex == "left";

            handle.DrawStyleBox(handBox, leftActive ? handL : handR);
            handle.DrawStyleBox(inactiveHandBox, leftActive ? handR : handL);

            if (LeftHand.Entity != null && LeftHand.HeldSprite != null)
            {
                var bounds = LeftHand.HeldSprite.Size;
                handle.DrawTextureRect(LeftHand.HeldSprite,
                                       Box2i.FromDimensions(handL.Left + (int)(handL.Width / 2f - bounds.X / 2f),
                                                            handL.Top + (int)(handL.Height / 2f - bounds.Y / 2f),
                                                            (int)bounds.X, (int)bounds.Y), tile: false);
            }

            if (RightHand.Entity != null && RightHand.HeldSprite != null)
            {
                var bounds = RightHand.HeldSprite.Size;
                handle.DrawTextureRect(RightHand.HeldSprite,
                                       Box2i.FromDimensions(handR.Left + (int)(handR.Width / 2f - bounds.Y / 2f),
                                                            handR.Top + (int)(handR.Height / 2f - bounds.Y / 2f),
                                                            (int)bounds.X, (int)bounds.Y), tile: false);
            }
        }
Ejemplo n.º 5
0
        public override void Update(float frameTime)
        {
            var boundsLeft  = _textboxLeft.GetLocalBounds();
            var boundsMain  = _textboxMain.GetLocalBounds();
            var boundsRight = _textboxRight.GetLocalBounds();

            _clientAreaLeft = Box2i.FromDimensions(Position, new Vector2i((int)boundsLeft.Width, (int)boundsLeft.Height));

            _clientAreaMain = Box2i.FromDimensions(_clientAreaLeft.Right, Position.Y,
                                                   Width, (int)boundsMain.Height);
            _clientAreaRight = Box2i.FromDimensions(_clientAreaMain.Right, Position.Y,
                                                    (int)boundsRight.Width, (int)boundsRight.Height);
            ClientArea = Box2i.FromDimensions(Position,
                                              new Vector2i(_clientAreaLeft.Width + _clientAreaMain.Width + _clientAreaRight.Width,
                                                           Math.Max(Math.Max(_clientAreaLeft.Height, _clientAreaRight.Height),
                                                                    _clientAreaMain.Height)));
            Label.Position = new Vector2i(_clientAreaLeft.Right,
                                          Position.Y + (int)(ClientArea.Height / 2f) - (int)(Label.Height / 2f));

            if (Focus)
            {
                blinkCount += 1 * frameTime;
                if (blinkCount > 0.50f)
                {
                    blinkCount = 0;
                }
            }
        }
Ejemplo n.º 6
0
 public override void Update(float frameTime)
 {
     Text.Text     = Math.Round(percent * 100).ToString() + "%";
     Text.Position = new Vector2i(Position.X + (int)(Size.X / 2f - Text.Width / 2f),
                                  Position.Y + (int)(Size.Y / 2f - Text.Height / 2f));
     ClientArea = Box2i.FromDimensions(Position, Size);
     Value++;
 }
Ejemplo n.º 7
0
 public override void Update(float frameTime)
 {
     if (drawingSprite != null)
     {
         var bounds = drawingSprite.GetLocalBounds();
         ClientArea = Box2i.FromDimensions(Position, new Vector2i((int)bounds.Width, (int)bounds.Height));
     }
 }
Ejemplo n.º 8
0
        public void Render(FrameEventArgs e)
        {
            _background.SetTransformToRect(Box2i.FromDimensions(0, 0, (int)CluwneLib.Screen.Size.X, (int)CluwneLib.Screen.Size.Y));
            _background.Draw();

            _ticketBg.SetTransformToRect(_boundingArea);
            _ticketBg.Draw();
            UserInterfaceManager.Render(e);
        }
        /// <inheritdoc />
        protected override void OnCalcRect()
        {
            // ugh...
            ScrollbarH.BarLength = ScrollbarV.Visible ? Size.X - ScrollbarV.ClientArea.Width : Size.X;
            ScrollbarV.BarLength = ScrollbarH.Visible ? Size.Y - ScrollbarH.ClientArea.Height : Size.Y;
            ScrollbarH.BarLength = ScrollbarV.Visible ? Size.X - ScrollbarV.ClientArea.Width : Size.X;

            ClientArea = Box2i.FromDimensions(new Vector2i(), Size);
        }
Ejemplo n.º 10
0
        public Checkbox(IResourceCache resourceCache)
        {
            _resourceCache = resourceCache;
            checkbox       = _resourceCache.GetSprite("checkbox0");
            checkboxCheck  = _resourceCache.GetSprite("checkbox1");

            ClientArea = Box2i.FromDimensions(Position,
                                              new Vector2i((int)checkbox.GetLocalBounds().Width, (int)checkbox.GetLocalBounds().Height));
            Update(0);
        }
Ejemplo n.º 11
0
        protected override void OnCalcRect()
        {
            ClientArea = Box2i.FromDimensions(Position, new Vector2i(Size.X, Size.Y));

            foreach (var kvTab in _tabs)
            {
                kvTab.Key.DoLayout();
                kvTab.Value.DoLayout();
            }
        }
Ejemplo n.º 12
0
        public override void Update(float frameTime)
        {
            base.Update(frameTime);
            var bounds = _iconSprite.GetLocalBounds();

            ClientArea          = Box2i.FromDimensions(Position.X, Position.Y, (int)Size.X, (int)Size.Y);
            _textLabel.Position = new Vector2i(ClientArea.Left + (int)bounds.Width + 6,
                                               ClientArea.Top + (int)(ClientArea.Height / 2f) -
                                               (int)(_textLabel.ClientArea.Height / 2f));
            _textLabel.Update(frameTime);
        }
Ejemplo n.º 13
0
        public override void Update(float frameTime)
        {
            var slotBounds = handSlot.LocalBounds;
            var width      = (int)((slotBounds.Width * 2) + spacing);
            var height     = (int)slotBounds.Height;

            Position   = new Vector2i((int)(CluwneLib.Window.Viewport.Width - width) / 2, (int)CluwneLib.Window.Viewport.Height - height - 10);
            handL      = Box2i.FromDimensions(Position.X, Position.Y, (int)slotBounds.Width, (int)slotBounds.Height);
            handR      = Box2i.FromDimensions(Position.X + (int)slotBounds.Width + spacing, Position.Y, (int)slotBounds.Width, (int)slotBounds.Height);
            ClientArea = Box2i.FromDimensions(Position.X, Position.Y, width, (int)slotBounds.Height);
        }
Ejemplo n.º 14
0
        /// <inheritdoc />
        protected override void OnCalcRect()
        {
            var listboxLeftBounds  = _listboxLeft.LocalBounds;
            var listboxMainBounds  = _listboxMain.LocalBounds;
            var listboxRightBounds = _listboxRight.LocalBounds;

            _clientAreaLeft  = Box2i.FromDimensions(new Vector2i(), new Vector2i((int)listboxLeftBounds.Width, (int)listboxLeftBounds.Height));
            _clientAreaMain  = Box2i.FromDimensions(_clientAreaLeft.Right, 0, _width, (int)listboxMainBounds.Height);
            _clientAreaRight = Box2i.FromDimensions(new Vector2i(_clientAreaMain.Right, 0), new Vector2i((int)listboxRightBounds.Width, (int)listboxRightBounds.Height));

            _clientArea = Box2i.FromDimensions(new Vector2i(), new Vector2i(_clientAreaLeft.Width + _clientAreaMain.Width + _clientAreaRight.Width, Math.Max(Math.Max(_clientAreaLeft.Height, _clientAreaRight.Height), _clientAreaMain.Height)));
        }
Ejemplo n.º 15
0
        public override void Render()
        {
            base.Render();
            var bounds   = _iconSprite.GetLocalBounds();
            var iconRect = Box2i.FromDimensions(ClientArea.Left + 3,
                                                ClientArea.Top + (int)(ClientArea.Height / 2f) - (int)(bounds.Height / 2f),
                                                (int)bounds.Width, (int)bounds.Height);

            CluwneLib.drawRectangle(ClientArea.Left, ClientArea.Top, ClientArea.Width, ClientArea.Height, _currentColor);
            _textLabel.Render();
            _iconSprite.SetTransformToRect(iconRect);
            _iconSprite.Draw();
        }
Ejemplo n.º 16
0
        public ContextMenu(IEntity entity, Vector2 creationPos, IResourceCache resourceCache,
                           IUserInterfaceManager userInterfaceManager, bool showExamine = true)
        {
            _owningEntity         = entity;
            _resourceCache        = resourceCache;
            _userInterfaceManager = userInterfaceManager;

            var entries = new List <ContextMenuEntry>();
            var replies = new List <ComponentReplyMessage>();

            entity.SendMessage(this, ComponentMessageType.ContextGetEntries, replies);

            if (replies.Any())
            {
                entries =
                    (List <ContextMenuEntry>)
                    replies.First(x => x.MessageType == ComponentMessageType.ContextGetEntries).ParamsList[0];
            }

            if (showExamine)
            {
                var examineButton =
                    new ContextMenuButton(
                        new ContextMenuEntry
                {
                    ComponentMessage = "examine", EntryName = "Examine", IconName = "context_eye"
                }, _buttonSize,
                        _resourceCache);
                examineButton.Selected += ContextSelected;
                _buttons.Add(examineButton);
                examineButton.Update(0);
            }

            foreach (ContextMenuEntry entry in entries)
            {
                var newButton = new ContextMenuButton(entry, _buttonSize, _resourceCache);
                newButton.Selected += ContextSelected;
                _buttons.Add(newButton);
                newButton.Update(0);
            }

            float currY = creationPos.Y;

            foreach (ContextMenuButton button in _buttons)
            {
                button.Position = new Vector2i((int)creationPos.X, (int)currY);
                currY          += _buttonSize.Y;
            }
            ClientArea = Box2i.FromDimensions((int)creationPos.X, (int)creationPos.Y, (int)_buttonSize.X,
                                              _buttons.Count() * (int)_buttonSize.Y);
        }
Ejemplo n.º 17
0
        /// <inheritdoc />
        protected override void OnCalcRect()
        {
            var boundsLeft  = _buttonLeft.LocalBounds;
            var boundsMain  = _buttonMain.LocalBounds;
            var boundsRight = _buttonRight.LocalBounds;

            _clientAreaLeft  = Box2i.FromDimensions(new Vector2i(), new Vector2i((int)boundsLeft.Width, (int)boundsLeft.Height));
            _clientAreaMain  = Box2i.FromDimensions(_clientAreaLeft.Right, 0, Label.Width, (int)boundsMain.Height);
            _clientAreaRight = Box2i.FromDimensions(_clientAreaMain.Right, 0, (int)boundsRight.Width, (int)boundsRight.Height);

            _clientArea = Box2i.FromDimensions(new Vector2i(),
                                               new Vector2i(_clientAreaLeft.Width + _clientAreaMain.Width + _clientAreaRight.Width,
                                                            Math.Max(Math.Max(_clientAreaLeft.Height, _clientAreaRight.Height), _clientAreaMain.Height)));
        }
Ejemplo n.º 18
0
        public override sealed void Update(float frameTime)
        {
            if (_drawSprite == null && _buttonNormal != null)
            {
                _drawSprite = _buttonNormal;
            }

            if (_drawSprite != null)
            {
                _drawSprite.Position = new Vector2f(Position.X, Position.Y);
                var bounds = _drawSprite.GetLocalBounds();
                ClientArea = Box2i.FromDimensions(Position,
                                                  new Vector2i((int)bounds.Width, (int)bounds.Height));
            }
        }
Ejemplo n.º 19
0
        public override void Render()
        {
            base.Render();
            if (_entitySprite == null)
            {
                return;
            }

            var bounds     = _entitySprite.GetLocalBounds();
            var spriteRect = Box2i.FromDimensions((int)(ClientArea.Width / 2f - bounds.Width / 2f) + ClientArea.Left,
                                                  10 + ClientArea.Top, (int)bounds.Width, (int)bounds.Height);

            _entitySprite.SetTransformToRect(spriteRect);
            _entitySprite.Draw();
        }
        public override void Update(float frameTime)
        {
            base.Update(frameTime);
            objectSprite.Position = new Vector2f(Position.X + 5, Position.Y + 5);
            var bounds = objectSprite.GetLocalBounds();

            name.Position = new Vector2i((int)(objectSprite.Position.X + bounds.Width + 5), (int)objectSprite.Position.Y);
            ClientArea    = Box2i.FromDimensions(Position,
                                                 new Vector2i(
                                                     fixed_width != -1
                                               ? fixed_width
                                               : ((int)bounds.Width + (int)name.Width + 15),
                                                     ((int)bounds.Height > (int)name.Height
                                                ? (int)bounds.Height
                                                : ((int)name.Height + 5)) + 10));
        }
Ejemplo n.º 21
0
        public override sealed void Update(float frameTime)
        {
            var boundsLeft  = _buttonLeft.GetLocalBounds();
            var boundsMain  = _buttonMain.GetLocalBounds();
            var boundsRight = _buttonRight.GetLocalBounds();

            _clientAreaLeft = Box2i.FromDimensions(Position, new Vector2i((int)boundsLeft.Width, (int)boundsLeft.Height));
            _clientAreaMain = Box2i.FromDimensions(_clientAreaLeft.Right, Position.Y,
                                                   (int)Label.Width, (int)boundsMain.Height);
            _clientAreaRight = Box2i.FromDimensions(_clientAreaMain.Right, Position.Y,
                                                    (int)boundsRight.Width, (int)boundsRight.Height);
            ClientArea = Box2i.FromDimensions(Position,
                                              new Vector2i(_clientAreaLeft.Width + _clientAreaMain.Width + _clientAreaRight.Width,
                                                           Math.Max(Math.Max(_clientAreaLeft.Height, _clientAreaRight.Height), _clientAreaMain.Height)));
            Label.Position = new Vector2i(_clientAreaLeft.Right,
                                          Position.Y + (int)(ClientArea.Height / 2f) - (int)(Label.Height / 2f));
        }
        protected override void OnCalcRect()
        {
            var rect = _sprite.TextureRect; // texture size in px

            var maxDim = rect.Height > rect.Width ? rect.Height : rect.Width;

            _sprite.Scale = new Vector2(IconSize / maxDim, IconSize / maxDim);

            ClientArea = Box2i.FromDimensions(new Vector2i(),
                                              new Vector2i(
                                                  FixedWidth != -1
                        ? FixedWidth
                        : (int)(5 + IconSize + 5 + _name.Width + 5),
                                                  ((int)IconSize > _name.Height
                        ? (int)IconSize
                        : _name.Height + 5) + 10));
        }
Ejemplo n.º 23
0
        public override void Update(float frameTime)
        {
            if (stopwatch != null)
            {
                if (stopwatch.Elapsed.Seconds > max)
                {
                    return;
                }

                Value     = stopwatch.Elapsed.Seconds;
                Text.Text =
                    DateTime.Now.AddSeconds(max - stopwatch.Elapsed.Seconds).Subtract(DateTime.Now).ToString(@"mm\:ss");
            }

            Text.Position = new Vector2i(Position.X + (int)(Size.X / 2f - Text.Width / 2f),
                                         Position.Y + (int)(Size.Y / 2f - Text.Height / 2f));
            ClientArea = Box2i.FromDimensions(Position, Size);
        }
Ejemplo n.º 24
0
        public override void Update(float frameTime)
        {
            ClientArea = Box2i.FromDimensions(Position, Size);

            _buttonRight.Position = new Vector2i(ClientArea.Right - _buttonRight.ClientArea.Width, ClientArea.Top + (int)(ClientArea.Height / 2f - _buttonRight.ClientArea.Height / 2f));
            _buttonRight.Update(frameTime);

            _buttonLeft.Position = new Vector2i(_buttonRight.ClientArea.Left - _buttonRight.ClientArea.Width - _buttonLeft.ClientArea.Width, _buttonRight.ClientArea.Top);

            _buttonLeft.Update(frameTime);

            foreach (var curr in _items)
            {
                curr.Key.Update(frameTime);
            }

            _selectionGlow.Update(frameTime);
        }
Ejemplo n.º 25
0
        public override void Render()
        {
            if (_playerManager?.ControlledEntity == null)
            {
                return;
            }

            IEntity entity = _playerManager.ControlledEntity;

            if (!entity.TryGetComponent <IHandsComponent>(out var hands))
            {
                return;
            }

            var leftActive = hands.ActiveIndex == "left";

            handSlot.Color = Color.White;
            handSlot.SetTransformToRect(leftActive ? handL : handR);
            handSlot.Draw();

            handSlot.Color = _inactiveColor;
            handSlot.SetTransformToRect(leftActive ? handR : handL);
            handSlot.Draw();

            if (LeftHand.Entity != null && LeftHand.HeldSprite != null)
            {
                var bounds = LeftHand.HeldSprite.LocalBounds;
                LeftHand.HeldSprite.SetTransformToRect(
                    Box2i.FromDimensions(handL.Left + (int)(handL.Width / 2f - bounds.Width / 2f),
                                         handL.Top + (int)(handL.Height / 2f - bounds.Height / 2f),
                                         (int)bounds.Width, (int)bounds.Height));
                LeftHand.HeldSprite.Draw();
            }

            if (RightHand.Entity != null && RightHand.HeldSprite != null)
            {
                var bounds = RightHand.HeldSprite.LocalBounds;
                RightHand.HeldSprite.SetTransformToRect(
                    Box2i.FromDimensions(handR.Left + (int)(handR.Width / 2f - bounds.Width / 2f),
                                         handR.Top + (int)(handR.Height / 2f - bounds.Height / 2f),
                                         (int)bounds.Width, (int)bounds.Height));
                RightHand.HeldSprite.Draw();
            }
        }
Ejemplo n.º 26
0
            // glfwGetWindowMonitor only works for fullscreen windows.
            // Picks the monitor with the top-left corner of the window.
            private Monitor *MonitorForWindow(Window *window)
            {
                GLFW.GetWindowPos(window, out var winPosX, out var winPosY);
                var monitors = GLFW.GetMonitorsRaw(out var count);

                for (var i = 0; i < count; i++)
                {
                    var monitor = monitors[i];
                    GLFW.GetMonitorPos(monitor, out var monPosX, out var monPosY);
                    var videoMode = GLFW.GetVideoMode(monitor);

                    var box = Box2i.FromDimensions(monPosX, monPosY, videoMode->Width, videoMode->Height);
                    if (box.Contains(winPosX, winPosY))
                    {
                        return(monitor);
                    }
                }

                // Fallback
                return(GLFW.GetPrimaryMonitor());
            }
Ejemplo n.º 27
0
        public override sealed void Update(float frameTime)
        {
            var listboxLeftBounds  = _listboxLeft.GetLocalBounds();
            var listboxMainBounds  = _listboxMain.GetLocalBounds();
            var listboxRightBounds = _listboxRight.GetLocalBounds();

            _clientAreaLeft = Box2i.FromDimensions(Position, new Vector2i((int)listboxLeftBounds.Width, (int)listboxLeftBounds.Height));
            _clientAreaMain = Box2i.FromDimensions(_clientAreaLeft.Right, Position.Y,
                                                   _width, (int)listboxMainBounds.Height);
            _clientAreaRight = Box2i.FromDimensions(new Vector2i(_clientAreaMain.Right, Position.Y),
                                                    new Vector2i((int)listboxRightBounds.Width, (int)listboxRightBounds.Height));
            ClientArea = Box2i.FromDimensions(Position,
                                              new Vector2i(_clientAreaLeft.Width + _clientAreaMain.Width + _clientAreaRight.Width,
                                                           Math.Max(Math.Max(_clientAreaLeft.Height, _clientAreaRight.Height),
                                                                    _clientAreaMain.Height)));
            _selectedLabel.Position = new Vector2i(_clientAreaLeft.Right,
                                                   Position.Y + (int)(ClientArea.Height / 2f) -
                                                   (int)(_selectedLabel.Height / 2f));
            _dropDown.Position = new Vector2i(ClientArea.Left + (int)((ClientArea.Width - _dropDown.ClientArea.Width) / 2f),
                                              ClientArea.Bottom);
            _dropDown.Update(frameTime);
        }
Ejemplo n.º 28
0
        public override void Update(float frameTime)
        {
            int prevHeight = 0;

            for (int i = _tabs.Count - 1; i >= 0; i--)
            {
                KeyValuePair <ImageButton, TabContainer> curr = _tabs[i];
                curr.Key.Position = new Vector2i(Position.X + TabOffset.X - curr.Key.ClientArea.Width,
                                                 Position.Y + TabOffset.Y - prevHeight);
                prevHeight += curr.Key.ClientArea.Height;

                curr.Value.Position = Position;

                curr.Key.Update(frameTime);
            }

            if (_activeTab != null)
            {
                _activeTab.Update(frameTime);
            }

            ClientArea = Box2i.FromDimensions(Position, new Vector2i((int)size.X, (int)size.Y));
        }
Ejemplo n.º 29
0
        protected override void Draw(DrawingHandle handle)
        {
            if (_playerManager?.LocalPlayer == null)
            {
                return;
            }

            IEntity entity = _playerManager.LocalPlayer.ControlledEntity;

            if (entity == null || !entity.TryGetComponent <IHandsComponent>(out var hands))
            {
                return;
            }

            var leftActive = hands.ActiveIndex == "left";

            handle.DrawStyleBox(handBox, leftActive ? handL : handR);
            handle.DrawStyleBox(inactiveHandBox, leftActive ? handR : handL);

            if (LeftHand.Entity != null && LeftHand.HeldSprite != null)
            {
                var bounds = LeftHand.HeldSprite.Size;
                handle.DrawTextureRect(LeftHand.HeldSprite,
                                       Box2i.FromDimensions(handL.Left + (int)(handL.Width / 2f - bounds.X / 2f),
                                                            handL.Top + (int)(handL.Height / 2f - bounds.Y / 2f),
                                                            (int)bounds.X, (int)bounds.Y), tile: false);
            }

            if (RightHand.Entity != null && RightHand.HeldSprite != null)
            {
                var bounds = RightHand.HeldSprite.Size;
                handle.DrawTextureRect(RightHand.HeldSprite,
                                       Box2i.FromDimensions(handR.Left + (int)(handR.Width / 2f - bounds.Y / 2f),
                                                            handR.Top + (int)(handR.Height / 2f - bounds.Y / 2f),
                                                            (int)bounds.X, (int)bounds.Y), tile: false);
            }
        }
Ejemplo n.º 30
0
        public override void Update(float frameTime)
        {
            if (disposing || !IsVisible())
            {
                return;
            }
            ClientArea = Box2i.FromDimensions(Position, new Vector2i((int)clippingRI.Width, (int)clippingRI.Height));

            if (inner_focus != null && !components.Contains((GuiComponent)inner_focus))
            {
                ClearFocus();
            }

            scrollbarH.Position = new Vector2i(ClientArea.Left, ClientArea.Bottom - scrollbarH.ClientArea.Height);
            scrollbarV.Position = new Vector2i(ClientArea.Right - scrollbarV.ClientArea.Width, ClientArea.Top);

            if (scrollbarV.IsVisible())
            {
                scrollbarH.size = Size.X - scrollbarV.ClientArea.Width;
            }
            else
            {
                scrollbarH.size = Size.X;
            }

            if (scrollbarH.IsVisible())
            {
                scrollbarV.size = Size.Y - scrollbarH.ClientArea.Height;
            }
            else
            {
                scrollbarV.size = Size.Y;
            }

            max_x = 0;
            max_y = 0;

            foreach (GuiComponent component in components)
            {
                if (component.Position.X + component.ClientArea.Width > max_x)
                {
                    max_x = component.Position.X + component.ClientArea.Width;
                }
                if (component.Position.Y + component.ClientArea.Height > max_y)
                {
                    max_y = component.Position.Y + component.ClientArea.Height;
                }
            }

            scrollbarH.max = (int)max_x - ClientArea.Width +
                             (max_y > clippingRI.Height ? scrollbarV.ClientArea.Width : 0);
            if (max_x > clippingRI.Width)
            {
                scrollbarH.SetVisible(true);
            }
            else
            {
                scrollbarH.SetVisible(false);
            }

            scrollbarV.max = (int)max_y - ClientArea.Height +
                             (max_x > clippingRI.Height ? scrollbarH.ClientArea.Height : 0);
            if (max_y > clippingRI.Height)
            {
                scrollbarV.SetVisible(true);
            }
            else
            {
                scrollbarV.SetVisible(false);
            }

            scrollbarH.Update(frameTime);
            scrollbarV.Update(frameTime);
        }