Пример #1
0
        private string FormatDescription(string input, int maxWidth)
        {
            int    maxPixelsPerLine = maxWidth;
            int    aggregatePixels  = 0;
            string output           = "";

            string[] words = input.Split(' ');
            foreach (string word in words)
            {
                Function.Call((Hash)0x54CE8AC98E120CAB, "jamyfafi");
                UIResText.AddLongString(word);
                int         screenw = Game.ScreenResolution.Width;
                int         screenh = Game.ScreenResolution.Height;
                const float height  = 1080f;
                float       ratio   = (float)screenw / screenh;
                var         width   = height * ratio;
                int         offset  = Convert.ToInt32(Function.Call <float>((Hash)0x85F061DA64ED2F67, 0) * width * 0.38f);

                aggregatePixels += Convert.ToInt32(offset);
                if (aggregatePixels > maxPixelsPerLine)
                {
                    output         += "\n" + word + " ";
                    aggregatePixels = Convert.ToInt32(offset);
                }
                else
                {
                    output += word + " ";
                }
            }
            return(output);
        }
Пример #2
0
        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();
        }
Пример #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;
            }
        }
Пример #4
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();
        }
Пример #5
0
        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();
        }
Пример #6
0
        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();
        }
Пример #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();
        }
Пример #8
0
        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();
        }
Пример #9
0
        public ClassicChat()
        {
            CurrentInput   = "";
            _mainScaleform = new Scaleform("multiplayer_chat");
            _messages      = new List <Tuple <string, Color> >();


            _inputboxRectangle       = new UIResRectangle(new Point(20, 280), new Size(600, 35), Color.FromArgb(150, 60, 60, 60));
            _inputboxBorderRectangle = new UIResRectangle(new Point(20 - borderWidth, 280 - borderWidth), new Size(600 + borderWidth * 2, 35 + borderWidth * 2), Color.FromArgb(200, 0, 0, 0));
            _inputboxText            = new UIResText("", new Point(24, 282), 0.45f, Color.White);
        }
Пример #10
0
 public CameraController(Vector3 pivotOffset, Vector3 cameraOffset, float fieldOfView)
 {
     _pivot = World.CreateProp("prop_cs_dildo_01", Game.Player.Character.Position + pivotOffset, GameplayCamera.Rotation, false, false);
     _pivot.HasCollision = false;
     _pivot.IsPersistent = true;
     _pivot.IsVisible    = false;
     _camera             = World.CreateCamera(Game.Player.Character.Position, GameplayCamera.Rotation, fieldOfView);
     _camera.AttachTo(_pivot, cameraOffset);
     PivotOffset         = pivotOffset;
     _artificalCrosshair = new UIResText("+", new Point(), 0.3f);
 }
Пример #11
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();
            });
        }
Пример #12
0
        public Helptip(string text, int duration)
        {
            _timeStarted = DateTime.Now;
            Time         = duration;

            Point safe = UIMenu.GetSafezoneBounds();

            _text = new UIResText(FormatDescription(text, 400), new Point(safe.X + 10, safe.Y + 5), 0.38f);

            _bg = new UIResRectangle(new Point(safe.X, safe.Y), new Size(410, 37), Color.FromArgb(200, 0, 0, 0));

            Visible = true;
        }
Пример #13
0
        protected override void populateDestructibleElements()
        {
            base.populateDestructibleElements();

            if (activatedEscort)
            {
                escortDistance = 30f;
                initializeEscort(startPosition);
            }

            if (activatedSpeedCounter)
            {
                speedCounterText   = new UIResText("", new Point(330, Game.ScreenResolution.Height - 70), 0.7f, Color.WhiteSmoke, GTA.Font.ChaletComprimeCologne, UIResText.Alignment.Left);
                speedCounterShadow = new UIResText("", new Point(332, Game.ScreenResolution.Height - 68), 0.7f, Color.Black, GTA.Font.ChaletComprimeCologne, UIResText.Alignment.Left);
            }

            bus          = World.CreateVehicle(VehicleHash.Bus, Tools.GetSafeRoadPos(startPosition));
            bus.Rotation = new Vector3(0, 0, 90);
            Game.Player.Character.SetIntoVehicle(bus, VehicleSeat.Driver);

            int passengersNumber = (int)Math.Round((decimal)bus.PassengerSeats / 2);

            for (int i = 0; i < passengersNumber; i++)
            {
                Ped passenger = World.CreatePed(PedHash.Business01AFY, Game.Player.Character.Position);
                if (passenger != null && passenger.Exists())
                {
                    passenger.DrivingStyle = DrivingStyle.AvoidTrafficExtremely;
                    passenger.SetIntoVehicle(bus, VehicleSeat.Any);
                    passengers.Add(passenger);
                }
                else
                {
                    Tools.log("Passenger not created");
                }
            }

            foreach (Vector3 checkpoint in checkPoints)
            {
                GoToPositionInVehicle goToFirstCheckpointObjective = new GoToPositionInVehicle(checkpoint);
                goToFirstCheckpointObjective.OnStarted += (sender) =>
                {
                    goToFirstCheckpointObjective.setVehicle(bus);
                };
                addObjective(goToFirstCheckpointObjective);
            }
        }
Пример #14
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();
        }
Пример #15
0
        public GangWarManager()
        {
            instance          = this;
            this.Tick        += OnTick;
            this.Aborted     += OnAbort;
            enemySpawnPoints  = new Vector3[3];
            alliedSpawnPoints = new Vector3[3];


            alliedNumText = new UIResText("400", new Point(), 0.5f, Color.CadetBlue);
            enemyNumText  = new UIResText("400", new Point(), 0.5f, Color.Red);

            alliedNumText.Outline = true;
            enemyNumText.Outline  = true;

            alliedNumText.TextAlignment = UIResText.Alignment.Centered;
            enemyNumText.TextAlignment  = UIResText.Alignment.Centered;
        }
Пример #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);
            }
        }
Пример #17
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();
 }
Пример #18
0
        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++;
            }
        }