/// <summary>
        /// Shows the scoreboard.
        /// </summary>
        /// <returns></returns>
        private async Task ShowScoreboard()
        {
            if (maxClients != -1)
            {
                if (!ScaleSetup)
                {
                    await LoadScale();

                    ScaleSetup = true;
                }
                if (currentPage > 0)
                {
                    float safezone = GetSafeZoneSize();
                    float change   = (safezone - 0.89f) / 0.11f;
                    float x        = 50f;
                    x -= change * 78f;
                    float y = 50f;
                    y -= change * 50f;

                    var width  = 400f;
                    var height = 490f;
                    if (scale != null)
                    {
                        if (scale.IsLoaded)
                        {
                            scale.Render2DScreenSpace(new System.Drawing.PointF(x, y), new System.Drawing.PointF(width, height));
                        }
                    }
                }
            }
        }
Example #2
0
        private void DrawChatboxInput()
        {
            if (Main.PlayerSettings.UseClassicChat)
            {
                var pos = GetInputboxPos(Main.PlayerSettings.ScaleChatWithSafezone);
                _mainScaleform.Render2DScreenSpace(
                    new PointF(pos.X + Main.PlayerSettings.ChatboxXOffset, pos.Y + Main.PlayerSettings.ChatboxYOffset),
                    new PointF(GTA.UI.Screen.Width, GTA.UI.Screen.Height));
                return;
            }

            //float realSize = StringMeasurer.MeasureString(CurrentInput ?? "");
            float realSize = UIResText.MeasureStringWidth(CurrentInput ?? "", Font.ChaletLondon, 0.45f);

            //realSize /= 0.35f;

            _inputboxBorderRectangle.Size = new SizeF(Math.Max(600 + borderWidth * 2, borderWidth * 2 + realSize + 20),
                                                      35 + borderWidth * 2);
            _inputboxBorderRectangle.Draw();

            _inputboxRectangle.Size = new SizeF(Math.Max(600, realSize + 20), 35);
            _inputboxRectangle.Draw();

            _inputboxText.Caption = (CurrentInput ?? "") + (_tick ? "|" : "");
            _inputboxText.Draw();

            if (DateTime.Now.Subtract(_lastTick).TotalMilliseconds > 800)
            {
                _lastTick = DateTime.Now;
                _tick     = !_tick;
            }
        }
Example #3
0
        /// <summary>
        /// Draws menu to screen, if any are open. Activated with interaction menu
        /// </summary>
        protected override void DrawMenu(List <Events.TickNametagData> nametags)
        {
            if (Pad.IsControlJustPressed(0, (int)Control.InteractionMenu))
            {
                if (_debug)
                {
                    Chat.Output("Player just pressed interactive key");
                }

                if (!_ply.IsSittingInAnyVehicle())
                {
                    if (!MenuPool.IsAnyMenuOpen())
                    {
                        if (_instructionLayer != null)
                        {
                            _instructionLayer.Dispose();
                            _instructionLayer = null;
                        }
                        OnShowSkinSelector(null);
                    }
                }
                else
                {
                    Chat.Output("Try outside of the vehicle");
                }
            }

            if (MenuPool.IsAnyMenuOpen())
            {
                MenuPool.ProcessMenus();
            }
            else
            {
                if (_instructionLayer != null)
                {
                    int x = 0; int y = 0;
                    RAGE.Game.Graphics.GetScreenResolution(ref x, ref y);
                    var size = new System.Drawing.Point(x, y);

                    //Needs minus values if you want to move the buttons elsewhere on screen
                    //var point = new System.Drawing.Point(-(int)(x * 0.9), -(int)(y * 0.5));

                    //Should be bottom right
                    var point = new System.Drawing.Point(0, 0);
                    _instructionLayer.Render2DScreenSpace(point, size);
                }
            }
        }
Example #4
0
        private void OnTick(List <Events.TickNametagData> nametags)
        {
            var veh = _ply.Vehicle;

            if (_ply.Vehicle != null)
            {
                UpdateScreenRes();

                var sizeX = _screenRes.X / 3;
                var sizeY = _screenRes.Y / 3;


                _dialPosition.X = (_screenRes.X - sizeX);
                _dialPosition.Y = (_screenRes.Y - sizeY) - 30;

                _dialSize.X = sizeX;
                _dialSize.Y = sizeY;

                _dashBoard.Render2DScreenSpace(_dialPosition, _dialSize);
            }
        }
Example #5
0
        public void Tick()
        {
            if (!Main.IsOnServer())
            {
                return;
            }

            var timePassed = Math.Min(DateTime.Now.Subtract(_focusStart).TotalMilliseconds, DateTime.Now.Subtract(_lastMsg).TotalMilliseconds);

            int alpha = 100;

            if (timePassed > 60000 && !_isFocused)
            {
                alpha = (int)MiscExtensions.QuadraticEasingLerp(100f, 0f, (int)Math.Min(timePassed - 60000, 2000), 2000);
            }
            if (timePassed < 300 && _lastFadedOut)
            {
                alpha = (int)MiscExtensions.QuadraticEasingLerp(0f, 100f, (int)Math.Min(timePassed, 300), 300);
            }


            var pos = GetInputboxPos(Main.PlayerSettings.ScaleChatWithSafezone);

            _mainScaleform.Render2DScreenSpace(new PointF(pos.X, pos.Y), new PointF(UI.WIDTH, UI.HEIGHT));

            var textAlpha = (alpha / 100f) * 126 + 126;
            var c         = 0;

            if (_messages.Any())
            {
                for (int indx = Math.Min(_messagesPerPage + _pagingIndex, _messages.Count - 1); indx >= (_messages.Count <= _messagesPerPage ? 0 : _pagingIndex); indx--)
                {
                    var msg = _messages[indx];

                    string output = msg.Item1;
                    var    limit  = UIMenu.GetScreenResolutionMantainRatio().Width - UIMenu.GetSafezoneBounds().X;
                    while (StringMeasurer.MeasureString(output) > limit)
                    {
                        output = output.Substring(0, output.Length - 5);
                    }

                    if (Main.PlayerSettings.ScaleChatWithSafezone)
                    {
                        new UIResText(output, UIMenu.GetSafezoneBounds() + new Size(0, 25 * c), 0.35f,
                                      Color.FromArgb((int)textAlpha, msg.Item2))
                        {
                            Outline = true,
                        }.Draw();
                    }
                    else
                    {
                        new UIResText(output, new Point(0, 25 * c), 0.35f,
                                      Color.FromArgb((int)textAlpha, msg.Item2))
                        {
                            Outline = true,
                        }.Draw();
                    }
                    c++;
                }
            }

            if (_pagingIndex != 0 && _messages.Count > _messagesPerPage)
            {
                Point start = UIMenu.GetSafezoneBounds();
                if (!Main.PlayerSettings.ScaleChatWithSafezone)
                {
                    start = new Point();
                }
                start = new Point(start.X - 15, start.Y);
                var chatHeight       = 25 * (_messagesPerPage + 1);
                var availableChoices = _messages.Count - _messagesPerPage;
                var barHeight        = (1f / availableChoices) * chatHeight;

                new UIResRectangle(start, new Size(10, chatHeight), Color.FromArgb(50, 0, 0, 0)).Draw();
                new UIResRectangle(start + new Size(0, (int)(chatHeight - chatHeight * ((_pagingIndex + 1) / (float)availableChoices))), new Size(10, (int)barHeight), Color.FromArgb(150, 0, 0, 0)).Draw();
            }

            if (!IsFocused)
            {
                return;
            }

            if (!Main.CanOpenChatbox)
            {
                IsFocused = false;
            }

            Game.DisableControlThisFrame(0, Control.NextCamera);
            Game.DisableAllControlsThisFrame(0);
        }
Example #6
0
        public void Tick()
        {
            if (!Main.IsOnServer())
            {
                return;
            }

            var timePassed = Math.Min(DateTime.Now.Subtract(_focusStart).TotalMilliseconds, DateTime.Now.Subtract(_lastMsg).TotalMilliseconds);

            int alpha = 100;

            if (timePassed > 60000 && !_isFocused)
            {
                alpha = (int)MiscExtensions.QuadraticEasingLerp(100f, 0f, (int)Math.Min(timePassed - 60000, 2000), 2000);
            }
            if (timePassed < 300 && _lastFadedOut)
            {
                alpha = (int)MiscExtensions.QuadraticEasingLerp(0f, 100f, (int)Math.Min(timePassed, 300), 300);
            }


            var pos = GetInputboxPos(Main.PlayerSettings.ScaleChatWithSafezone);

            _mainScaleform.Render2DScreenSpace(new PointF(pos.X, pos.Y), new PointF(UI.WIDTH, UI.HEIGHT));

            var textAlpha = (alpha / 100f) * 126 + 126;
            var c         = 0;

            foreach (var msg in _messages)
            {
                string output = msg.Item1;
                var    limit  = UIMenu.GetScreenResolutionMaintainRatio().Width - UIMenu.GetSafezoneBounds().X;
                while (StringMeasurer.MeasureString(output) > limit)
                {
                    output = output.Substring(0, output.Length - 5);
                }

                if (Main.PlayerSettings.ScaleChatWithSafezone)
                {
                    new UIResText(output, UIMenu.GetSafezoneBounds() + new Size(0, 25 * c), 0.35f,
                                  Color.FromArgb((int)textAlpha, msg.Item2))
                    {
                        Outline = true,
                    }.Draw();
                }
                else
                {
                    new UIResText(output, new Point(0, 25 * c), 0.35f,
                                  Color.FromArgb((int)textAlpha, msg.Item2))
                    {
                        Outline = true,
                    }.Draw();
                }
                c++;
            }

            if (!IsFocused)
            {
                return;
            }
            Game.DisableControlThisFrame(0, Control.NextCamera);
            Game.DisableAllControlsThisFrame(0);
            Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, 0);
        }