Exemple #1
0
        private void showSpeedCounter()
        {
            if (activatedSpeedCounter && speedCounterText != null)
            {
                if (Game.Player.Character.IsInVehicle())
                {
                    if (trapStarted)
                    {
                        if (Tools.getSpeedInKmh(lastVehicle.Speed) < bombTriggerSpeedInKmh + 5)
                        {
                            speedCounterText.Color = Color.Red;
                        }
                        else if (Tools.getSpeedInKmh(lastVehicle.Speed) < bombTriggerSpeedInKmh + 10)
                        {
                            speedCounterText.Color = Color.Orange;
                        }
                        else
                        {
                            speedCounterText.Color = Color.Green;
                        }
                    }
                    else
                    {
                        speedCounterText.Color = Color.WhiteSmoke;
                    }

                    speedCounterShadow.Caption = Tools.getVehicleSpeedInKmh(Game.Player.Character.CurrentVehicle);
                    speedCounterShadow.Draw();

                    speedCounterText.Caption = Tools.getVehicleSpeedInKmh(Game.Player.Character.CurrentVehicle);
                    speedCounterText.Draw();
                }
            }
        }
Exemple #2
0
 private static void OnTick(object sender, EventArgs e)
 {
     if (Main.IsConnected())
     {
         VersionLabel.Draw(new Size());
     }
 }
Exemple #3
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;
            }
        }
        private void DrawPlayerName(Player player, float x, float y)
        {
            UIResText playerNameText = new UIResText(player.Name, new PointF(x, y), 0.45f);

            playerNameText.DropShadow = true;
            playerNameText.Draw();
        }
        private void DrawPlayerLevel(Player player, float x, float y)
        {
            int       playerLVL      = Level.GetPlayerLVL(player);
            UIResText playerNameText = new UIResText($"LVL {playerLVL}", new PointF(x, y), 0.45f, Color.FromArgb(255, 102, 178, 255));

            playerNameText.DropShadow = true;
            playerNameText.Draw();
        }
        private void DrawMoneyText()
        {
            UIResText moneyText = new UIResText($"{MONEY} $", new PointF(320f, 1024f), 0.7f, Color.FromArgb(255, 0, 153, 0),
                                                Font.ChaletComprimeCologne, UIResText.Alignment.Left);

            moneyText.DropShadow = true;
            moneyText.Draw();
        }
Exemple #7
0
        private void DrawLevelText()
        {
            UIResText levelText = new UIResText($"{Strings.LEVEL} {LVL}", new PointF(320f, 863f), 0.6f, Color.FromArgb(255, 102, 178, 255),
                                                Font.ChaletComprimeCologne, UIResText.Alignment.Left);

            levelText.DropShadow = true;
            levelText.Draw();
        }
Exemple #8
0
        public static void DrawSimpleText(String text, int x, int y, float scale = .4f, Color?_color = null)
        {
            var   pt    = new Point(x, y);
            Color color = (_color.HasValue) ? _color.Value : Color.White;
            var   ui    = new UIResText(text, pt, scale, color);

            ui.Draw();
        }
        private void DrawTitle()
        {
            UIResRectangle titleRec = new UIResRectangle(new PointF(POS_X, POS_Y), new SizeF(SCOREBOARD_LENGTH, TITLE_HEIGHT), Color.FromArgb(220, 0, 0, 0));

            titleRec.Draw();

            int       playerAmount = Players.Count();
            UIResText titleText    = new UIResText($"{playerAmount} Players", new PointF(POS_X + 5f, POS_Y + 2f), 0.4f);

            titleText.Draw();
        }
Exemple #10
0
        public Missions()
        {
            startMission();

            Tick += new Func <Task>(async delegate
            {
                await Task.FromResult(0);
                Vector3 pos       = Game.PlayerPed.Position;
                UIResText posText = new UIResText($"{pos.X} {pos.Y} {pos.Z}", new PointF(1280, 3), 0.5f);
                posText.Draw();
            });
        }
Exemple #11
0
        public void Draw()
        {
            if (!Visible)
            {
                return;
            }
            if (DateTime.Now.Subtract(_timeStarted).TotalMilliseconds >= Time)
            {
                Visible = false;
                return;
            }
            _bg.Size = new Size(410, 45 + 30 * (_text.Caption.Split('\n').Length - 1));

            _bg.Draw();
            _text.Draw();
        }
Exemple #12
0
        private void DrawMoneyChangeText()
        {
            UIResText moneyChangeText = new UIResText("", new PointF(320f, 995f), 0.5f, Color.Empty,
                                                      Font.Pricedown, UIResText.Alignment.Left);

            if (moneyChangeTextAmount > 0)
            {
                moneyChangeText.Caption = $"+ {moneyChangeTextAmount}$";
                moneyChangeText.Color   = Color.FromArgb(255, 0, 153, 0);
            }
            else
            {
                moneyChangeText.Caption = $"- {moneyChangeTextAmount * -1}$";
                moneyChangeText.Color   = Color.FromArgb(255, 153, 0, 0);
            }

            moneyChangeText.Draw();
        }
        public void Update(bool invert, float minX, float maxX, float sensitivity)
        {
            if ((Game.Player.IsAiming || Game.Player.Character.IsShooting) && Rendering)
            {
                _artificalCrosshair.Position = new Point((int)(UIMenu.GetScreenResolutionMantainRatio().Width / 2) - 5,
                                                         (int)(UIMenu.GetScreenResolutionMantainRatio().Height / 2) - 15);
                _artificalCrosshair.Draw();
            }

            if (Game.Player.Character.CurrentVehicle != null)
            {
                _pivot.SetNoCollision(Game.Player.Character.CurrentVehicle, true);
            }

            // Move with the target.
            _pivot.Position = Game.Player.Character.Position + Game.Player.Character.Quaternion * PivotOffset;

            // Get the mouse x input axes.
            var xInput = Game.GetControlNormal(2, Control.LookUpDown);

            // NOTE: You could even go as far as to implement your own z axis rotation, as shown for the xInput axis.

            // Use the default sensitivity.
            _x -= xInput * sensitivity * Game.LastFrameTime;

            // Invert if we choose.
            if (invert)
            {
                _x = -_x;
            }

            // Clamp the x axis.
            _x = Mathf.Clamp(_x, minX, maxX);

            // Get the rotation.
            var rotation = new Vector3(_x, 0, GameplayCamera.Rotation.Z);

            // Rotate the pivot.
            _pivot.Rotation = rotation;

            _camera.Rotation = _pivot.Rotation;
        }
Exemple #14
0
 private void drawPosText()
 {
     Vector3 pos = Game.PlayerPed.Position;
     UIResText posText = new UIResText($"{pos.X} {pos.Y} {pos.Z}", new PointF(1280, 3), 0.5f);
     posText.Draw();
 }
        public override void Draw()
        {
            if (!Visible)
            {
                return;
            }
            base.Draw();

            var res = Screen.ResolutionMaintainRatio;

            var alpha      = Focused ? 120 : 30;
            var blackAlpha = Focused ? 200 : 100;
            var fullAlpha  = Focused ? 255 : 150;

            var submenuWidth = (BottomRight.X - TopLeft.X);
            var itemSize     = new Size(submenuWidth, 40);

            int i = 0;

            for (int c = _minItem; c < Math.Min(Items.Count, _maxItem); c++)
            {
                var hovering = Screen.IsMouseInBounds(SafeSize.AddPoints(new Point(0, (itemSize.Height + 3) * i)),
                                                      itemSize);

                var hasLeftBadge  = Items[c].LeftBadge != UIMenuItem.BadgeStyle.None;
                var hasRightBadge = Items[c].RightBadge != UIMenuItem.BadgeStyle.None;

                var hasBothBadges = hasRightBadge && hasLeftBadge;
                var hasAnyBadge   = hasRightBadge || hasLeftBadge;

                new UIResRectangle(SafeSize.AddPoints(new Point(0, (itemSize.Height + 3) * i)), itemSize, (Index == c && Focused) ? Color.FromArgb(fullAlpha, Color.White) : Focused && hovering ? Color.FromArgb(100, 50, 50, 50) : Color.FromArgb(blackAlpha, Color.Black)).Draw();
                new UIResText(Items[c].Text, SafeSize.AddPoints(new Point((hasBothBadges ? 60 : hasAnyBadge ? 30 : 6), 5 + (itemSize.Height + 3) * i)), 0.35f, Color.FromArgb(fullAlpha, (Index == c && Focused) ? Color.Black : Color.White)).Draw();

                if (hasLeftBadge && !hasRightBadge)
                {
                    new Sprite(UIMenuItem.BadgeToSpriteLib(Items[c].LeftBadge),
                               UIMenuItem.BadgeToSpriteName(Items[c].LeftBadge, (Index == c && Focused)), SafeSize.AddPoints(new Point(-2, 1 + (itemSize.Height + 3) * i)), new Size(40, 40), 0f,
                               UIMenuItem.BadgeToColor(Items[c].LeftBadge, (Index == c && Focused))).Draw();
                }

                if (!hasLeftBadge && hasRightBadge)
                {
                    new Sprite(UIMenuItem.BadgeToSpriteLib(Items[c].RightBadge),
                               UIMenuItem.BadgeToSpriteName(Items[c].RightBadge, (Index == c && Focused)), SafeSize.AddPoints(new Point(-2, 1 + (itemSize.Height + 3) * i)), new Size(40, 40), 0f,
                               UIMenuItem.BadgeToColor(Items[c].RightBadge, (Index == c && Focused))).Draw();
                }

                if (hasLeftBadge && hasRightBadge)
                {
                    new Sprite(UIMenuItem.BadgeToSpriteLib(Items[c].LeftBadge),
                               UIMenuItem.BadgeToSpriteName(Items[c].LeftBadge, (Index == c && Focused)), SafeSize.AddPoints(new Point(-2, 1 + (itemSize.Height + 3) * i)), new Size(40, 40), 0f,
                               UIMenuItem.BadgeToColor(Items[c].LeftBadge, (Index == c && Focused))).Draw();

                    new Sprite(UIMenuItem.BadgeToSpriteLib(Items[c].RightBadge),
                               UIMenuItem.BadgeToSpriteName(Items[c].RightBadge, (Index == c && Focused)), SafeSize.AddPoints(new Point(25, 1 + (itemSize.Height + 3) * i)), new Size(40, 40), 0f,
                               UIMenuItem.BadgeToColor(Items[c].RightBadge, (Index == c && Focused))).Draw();
                }

                if (!string.IsNullOrEmpty(Items[c].RightLabel))
                {
                    new UIResText(Items[c].RightLabel,
                                  SafeSize.AddPoints(new Point(BottomRight.X - SafeSize.X - 5, 5 + (itemSize.Height + 3) * i)),
                                  0.35f, Color.FromArgb(fullAlpha, (Index == c && Focused) ? Color.Black : Color.White),
                                  Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                }

                if (Items[c] is UIMenuCheckboxItem)
                {
                    string textureName = "";
                    if (c == Index && Focused)
                    {
                        textureName = ((UIMenuCheckboxItem)Items[c]).Checked ? "shop_box_tickb" : "shop_box_blankb";
                    }
                    else
                    {
                        textureName = ((UIMenuCheckboxItem)Items[c]).Checked ? "shop_box_tick" : "shop_box_blank";
                    }
                    new Sprite("commonmenu", textureName, SafeSize.AddPoints(new Point(BottomRight.X - SafeSize.X - 60, -5 + (itemSize.Height + 3) * i)), new Size(50, 50)).Draw();
                }
                else if (Items[c] is UIMenuListItem)
                {
                    var convItem = (UIMenuListItem)Items[c];

                    var yoffset = 5;
                    var basePos =
                        SafeSize.AddPoints(new Point(BottomRight.X - SafeSize.X - 30, yoffset + (itemSize.Height + 3) * i));

                    var arrowLeft  = new Sprite("commonmenu", "arrowleft", basePos, new Size(30, 30));
                    var arrowRight = new Sprite("commonmenu", "arrowright", basePos, new Size(30, 30));
                    var itemText   = new UIResText("", basePos, 0.35f, Color.White, Font.ChaletLondon,
                                                   UIResText.Alignment.Left)
                    {
                        TextAlignment = UIResText.Alignment.Right
                    };

                    string caption = convItem.Items[convItem.Index].ToString();
                    float  offset  = Screen.GetTextWidth(caption, itemText.Font, itemText.Scale);

                    var selected = c == Index && Focused;

                    itemText.Color = convItem.Enabled ? selected ? Color.Black : Color.WhiteSmoke : Color.FromArgb(163, 159, 148);

                    itemText.Caption = caption;

                    arrowLeft.Color  = convItem.Enabled ? selected ? Color.Black : Color.WhiteSmoke : Color.FromArgb(163, 159, 148);
                    arrowRight.Color = convItem.Enabled ? selected ? Color.Black : Color.WhiteSmoke : Color.FromArgb(163, 159, 148);

                    arrowLeft.Position =
                        SafeSize.AddPoints(new Point(BottomRight.X - SafeSize.X - 60 - (int)offset, yoffset + (itemSize.Height + 3) * i));
                    if (selected)
                    {
                        arrowLeft.Draw();
                        arrowRight.Draw();
                        itemText.Position = SafeSize.AddPoints(new Point(BottomRight.X - SafeSize.X - 30, yoffset + (itemSize.Height + 3) * i));
                    }
                    else
                    {
                        itemText.Position = SafeSize.AddPoints(new Point(BottomRight.X - SafeSize.X - 5, yoffset + (itemSize.Height + 3) * i));
                    }

                    itemText.Draw();
                }

                if (Focused && hovering && Game.IsControlJustPressed(0, Control.CursorAccept))
                {
                    bool open = Index == c;
                    Index = (1000 - (1000 % Items.Count) + c) % Items.Count;
                    if (!open)
                    {
                        Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1);
                    }
                    else
                    {
                        if (Items[Index] is UIMenuCheckboxItem)
                        {
                            Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1);
                            ((UIMenuCheckboxItem)Items[Index]).Checked = !((UIMenuCheckboxItem)Items[Index]).Checked;
                            ((UIMenuCheckboxItem)Items[Index]).CheckboxEventTrigger();
                        }
                        else
                        {
                            Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1);
                            Items[Index].ItemActivate(null);
                        }
                    }
                }

                i++;
            }
        }
Exemple #16
0
        private void TickEvent(List <Events.TickNametagData> nametags)
        {
            // Get the current time
            var dateTime = DateTime.UtcNow;

            // Check if the player is connected
            if (playerLogged)
            {
                // Disable reloading
                Pad.DisableControlAction(0, 140, true);

                if (Vehicles.lastPosition != null)
                {
                    if (Player.LocalPlayer.Vehicle == null)
                    {
                        Vehicles.RemoveSpeedometerEvent(null);
                    }
                    else
                    {
                        Vehicles.UpdateSpeedometer();
                    }
                }

                // Update the player's money each 450ms
                if (dateTime.Ticks - lastTimeChecked.Ticks >= 4500000)
                {
                    // Check if the player is loaded
                    var money = Player.LocalPlayer.GetSharedData(Constants.HAND_MONEY);

                    if (money != null)
                    {
                        playerMoney     = Convert.ToInt32(money) + "$";
                        lastTimeChecked = dateTime;
                    }
                }

                if (Fishing.fishingState > 0)
                {
                    Fishing.DrawFishingMinigame();
                }

                // Draw the money
                UIResText.Draw(playerMoney, 1900, 60, Font.Pricedown, 0.5f, Color.DarkOliveGreen,
                               UIResText.Alignment.Right, true, true, 0);

                // Check if the player
                if (Pad.IsControlJustPressed(0, (int)Control.VehicleSubPitchDownOnly) &&
                    Player.LocalPlayer.Vehicle != null)
                {
                    Trucker.CheckPlayerStoredCrate();
                }

                // Check if the player is handcuffed
                if (Police.handcuffed)
                {
                    Pad.DisableControlAction(0, 12, true);
                    Pad.DisableControlAction(0, 13, true);
                    Pad.DisableControlAction(0, 14, true);
                    Pad.DisableControlAction(0, 15, true);
                    Pad.DisableControlAction(0, 16, true);
                    Pad.DisableControlAction(0, 17, true);
                    Pad.DisableControlAction(0, 22, true);
                    Pad.DisableControlAction(0, 24, true);
                    Pad.DisableControlAction(0, 25, true);
                }
            }

            // Detect if a key has been pressed
            var key = Keys.DetectPressedKey(dateTime.Ticks);

            if (key >= 0)
            {
                Keys.FireKeyPressed(key);
            }
        }