Exemple #1
0
        public SizedWord(string word, int fontSize)
        {
            Word     = word;
            FontSize = fontSize;

            WordSize = StringMeasurer.MeasureString(word, fontSize);
        }
Exemple #2
0
        /// <summary>
        /// Draw item.
        /// </summary>
        public override void Draw()
        {
            base.Draw();
            string caption = Collection == null ?
                             (_items.Count > 0 ? _items[Index].ToString() : " ") :
                             (Collection.Count > 0 ? Collection[Index].DisplayText : " ");
            int offset = StringMeasurer.MeasureString(caption);

            _itemText.Color = Enabled ? Selected ? HighlightedForeColor : ForeColor : Color.FromArgb(163, 159, 148);

            _itemText.Caption = caption;

            _arrowLeft.Color  = Enabled ? Selected ? HighlightedForeColor : ForeColor : Color.FromArgb(163, 159, 148);
            _arrowRight.Color = Enabled ? Selected ? HighlightedForeColor : ForeColor : Color.FromArgb(163, 159, 148);

            _arrowLeft.Position = new Point(375 - offset + Offset.X + Parent.WidthOffset, _arrowLeft.Position.Y);
            if (Selected)
            {
                _arrowLeft.Draw();
                _arrowRight.Draw();
                _itemText.Position = new Point(405 + Offset.X + Parent.WidthOffset, _itemText.Position.Y);
            }
            else
            {
                _itemText.Position = new Point(420 + Offset.X + Parent.WidthOffset, _itemText.Position.Y);
            }
            _itemText.Draw();
        }
        public override void Draw()
        {
            base.Draw();
            if (Heists.Count == 0)
            {
                return;
            }

            var res = UIMenu.GetScreenResolutionMaintainRatio();

            var activeWidth = res.Width - SafeSize.X * 2;
            var itemSize    = new SizeF((int)activeWidth - 515, 40);

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

            var counter = 0;

            for (int i = _minItem; i < Math.Min(Heists.Count, _maxItem); i++)
            {
                new UIResRectangle(SafeSize.AddPoints(new PointF(0, (itemSize.Height + 3) * counter)), itemSize, (Index == i && Focused) ? Color.FromArgb(fullAlpha, UnknownColors.White) : Color.FromArgb(blackAlpha, UnknownColors.Black)).Draw();
                new UIResText(Heists[i].Name, SafeSize.AddPoints(new PointF(6, 5 + (itemSize.Height + 3) * counter)), 0.35f, Color.FromArgb(fullAlpha, (Index == i && Focused) ? UnknownColors.Black : UnknownColors.White)).Draw();
                counter++;
            }

            if (Heists[Index].Logo == null || string.IsNullOrEmpty(Heists[Index].Logo.FileName))
            {
                _noLogo.Position = new PointF((int)res.Width - SafeSize.X - 512, SafeSize.Y);
                _noLogo.Color    = Color.FromArgb(blackAlpha, 0, 0, 0);
                _noLogo.Draw();
            }
            else if (Heists[Index].Logo != null && Heists[Index].Logo.FileName != null && !Heists[Index].Logo.IsGameTexture)
            {
                var target = Heists[Index].Logo.FileName;
                //Sprite.DrawTexture(target, new PointF((int)res.Width - SafeSize.X - 512, SafeSize.Y), new SizeF(512, 256));
            }
            else if (Heists[Index].Logo != null && Heists[Index].Logo.FileName != null &&
                     Heists[Index].Logo.IsGameTexture)
            {
                var newLogo = new Sprite(Heists[Index].Logo.DictionaryName, Heists[Index].Logo.FileName, new PointF(), new SizeF(512, 256))
                {
                    Position = new PointF((int)res.Width - SafeSize.X - 512, SafeSize.Y),
                    Color    = Color.FromArgb(blackAlpha, 0, 0, 0)
                };
                newLogo.Draw();
            }

            new UIResRectangle(new PointF((int)res.Width - SafeSize.X - 512, SafeSize.Y + 256), new SizeF(512, 40), Color.FromArgb(fullAlpha, UnknownColors.Black)).Draw();
            new UIResText(Heists[Index].Name, new PointF((int)res.Width - SafeSize.X - 4, SafeSize.Y + 260), 0.5f, Color.FromArgb(fullAlpha, UnknownColors.White),
                          Font.HouseScript, UIResText.ScreenAlignment.Right).Draw();

            for (int i = 0; i < Heists[Index].ValueList.Count; i++)
            {
                new UIResRectangle(new PointF((int)res.Width - SafeSize.X - 512, SafeSize.Y + 256 + 40 + (40 * i)),
                                   new SizeF(512, 40), i % 2 == 0 ? Color.FromArgb(alpha, 0, 0, 0) : Color.FromArgb(blackAlpha, 0, 0, 0)).Draw();
                var text  = Heists[Index].ValueList[i].Item1;
                var label = Heists[Index].ValueList[i].Item2;


                new UIResText(text, new PointF((int)res.Width - SafeSize.X - 506, SafeSize.Y + 260 + 42 + (40 * i)), 0.35f, Color.FromArgb(fullAlpha, UnknownColors.White)).Draw();
                new UIResText(label, new PointF((int)res.Width - SafeSize.X - 6, SafeSize.Y + 260 + 42 + (40 * i)), 0.35f, Color.FromArgb(fullAlpha, UnknownColors.White), Font.ChaletLondon, UIResText.ScreenAlignment.Right).Draw();
            }

            if (!string.IsNullOrEmpty(Heists[Index].Description))
            {
                var propLen = Heists[Index].ValueList.Count;
                new UIResRectangle(new PointF((int)res.Width - SafeSize.X - 512, SafeSize.Y + 256 + 42 + 40 * propLen),
                                   new SizeF(512, 2), Color.FromArgb(fullAlpha, UnknownColors.White)).Draw();
                new UIResText(Heists[Index].Description,
                              new PointF((int)res.Width - SafeSize.X - 508, SafeSize.Y + 256 + 45 + 40 * propLen + 4), 0.35f,
                              Color.FromArgb(fullAlpha, UnknownColors.White))
                {
                    WordWrap = new SizeF(508, 0),
                }.Draw();

                new UIResRectangle(new PointF((int)res.Width - SafeSize.X - 512, SafeSize.Y + 256 + 44 + 40 * propLen),
                                   new SizeF(512, 45 * (int)(StringMeasurer.MeasureString(Heists[Index].Description) / 500)),
                                   Color.FromArgb(blackAlpha, 0, 0, 0)).Draw();
            }
        }
Exemple #4
0
        public override void Draw()
        {
            base.Draw();
            if (Heists.Count == 0)
            {
                return;
            }

            res = UIMenu.GetScreenResolutionMantainRatio();

            var activeWidth = res.Width - SafeSize.X * 2;
            var itemSize    = new Size((int)activeWidth - 515, 40);

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

            var counter = 0;

            for (int i = _minItem; i < Math.Min(Heists.Count, _maxItem); i++)
            {
                ResRectangle.Draw(SafeSize.AddPoints(new Point(0, (itemSize.Height + 3) * counter)), itemSize, (Index == i && Focused) ? Color.FromArgb(fullAlpha, Color.White) : Color.FromArgb(blackAlpha, Color.Black));
                ResText.Draw(Heists[i].Name, SafeSize.AddPoints(new Point(6, 5 + (itemSize.Height + 3) * counter)), 0.35f, Color.FromArgb(fullAlpha, (Index == i && Focused) ? Color.Black : Color.White), Common.EFont.ChaletLondon, false);
                counter++;
            }

            if (Heists[Index].Logo == null || (Heists[Index].Logo.Sprite == null && Heists[Index].Logo.Texture == null))
            {
                drawTexture      = false;
                _noLogo.Position = new Point((int)res.Width - SafeSize.X - 512, SafeSize.Y);
                _noLogo.Color    = Color.FromArgb(blackAlpha, 0, 0, 0);
                _noLogo.Draw();
            }
            else if (Heists[Index].Logo != null && Heists[Index].Logo.Texture != null && !Heists[Index].Logo.IsGameSprite)
            {
                drawTexture = true;
            }
            else if (Heists[Index].Logo != null && Heists[Index].Logo.Sprite != null && Heists[Index].Logo.IsGameSprite)
            {
                drawTexture = false;
                Sprite sprite = Heists[Index].Logo.Sprite;
                sprite.Position = new Point((int)res.Width - SafeSize.X - 512, SafeSize.Y);
                sprite.Color    = Color.FromArgb(blackAlpha, 0, 0, 0);
                sprite.Draw();
            }
            else
            {
                drawTexture = false;
            }

            ResRectangle.Draw(new Point((int)res.Width - SafeSize.X - 512, SafeSize.Y + 256), new Size(512, 40), Color.FromArgb(fullAlpha, Color.Black));
            ResText.Draw(Heists[Index].Name, new Point((int)res.Width - SafeSize.X - 4, SafeSize.Y + 260), 0.5f, Color.FromArgb(fullAlpha, Color.White), Common.EFont.HouseScript, ResText.Alignment.Right, false, false, Size.Empty);

            for (int i = 0; i < Heists[Index].ValueList.Count; i++)
            {
                ResRectangle.Draw(new Point((int)res.Width - SafeSize.X - 512, SafeSize.Y + 256 + 40 + (40 * i)), new Size(512, 40), i % 2 == 0 ? Color.FromArgb(alpha, 0, 0, 0) : Color.FromArgb(blackAlpha, 0, 0, 0));
                var text  = Heists[Index].ValueList[i].Item1;
                var label = Heists[Index].ValueList[i].Item2;


                ResText.Draw(text, new Point((int)res.Width - SafeSize.X - 506, SafeSize.Y + 260 + 42 + (40 * i)), 0.35f, Color.FromArgb(fullAlpha, Color.White), Common.EFont.ChaletLondon, false);
                ResText.Draw(label, new Point((int)res.Width - SafeSize.X - 6, SafeSize.Y + 260 + 42 + (40 * i)), 0.35f, Color.FromArgb(fullAlpha, Color.White), Common.EFont.ChaletLondon, ResText.Alignment.Right, false, false, Size.Empty);
            }

            if (!string.IsNullOrEmpty(Heists[Index].Description))
            {
                var propLen = Heists[Index].ValueList.Count;
                ResRectangle.Draw(new Point((int)res.Width - SafeSize.X - 512, SafeSize.Y + 256 + 42 + 40 * propLen), new Size(512, 2), Color.FromArgb(fullAlpha, Color.White));
                ResText.Draw(Heists[Index].Description, new Point((int)res.Width - SafeSize.X - 508, SafeSize.Y + 256 + 45 + 40 * propLen + 4), 0.35f, Color.FromArgb(fullAlpha, Color.White), Common.EFont.ChaletLondon, ResText.Alignment.Left, false, false, new Size(508, 0));

                ResRectangle.Draw(new Point((int)res.Width - SafeSize.X - 512, SafeSize.Y + 256 + 44 + 40 * propLen), new Size(512, 45 * (StringMeasurer.MeasureString(Heists[Index].Description) / 500)), Color.FromArgb(blackAlpha, 0, 0, 0));
            }
        }
Exemple #5
0
        public override void Draw()
        {
            base.Draw();

            if (!Focused)
            {
                DrawSprite("minimap_sea_2_0", "minimap_sea_2_0", new Point(BottomRight.X - 1024, TopLeft.Y), new Size(1024, 1024));

                if (Game.IsControlJustPressed(Control.Attack))
                {
                    Focused           = true;
                    _justOpened_mouse = true;
                    _justOpened_kb    = true;
                    Audio.PlaySoundFrontend("accept", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                }
            }
            else
            {
                Game.EnableControlThisFrame(Control.CursorX);
                Game.EnableControlThisFrame(Control.CursorY);
                var res    = UIMenu.GetScreenResolutionMantainRatio();
                var mouseX = Function.Call <float>(Hash.GET_CONTROL_NORMAL, 0, (int)Control.CursorX) * res.Width;
                var mouseY = Function.Call <float>(Hash.GET_CONTROL_NORMAL, 0, (int)Control.CursorY) * res.Height;
                var center = new Point((int)(res.Width / 2), (int)(res.Height / 2));


                if (Math.Abs(mouseX - _lastMouseInput.X) > 1f || Math.Abs(mouseY - _lastMouseInput.Y) > 1f)
                {
                    _wasMouseInput = true;
                }

                if (Game.IsControlJustPressed(Control.CursorAccept))
                {
                    _isHeldDown       = true;
                    _heldDownPoint    = new PointF(mouseX, mouseY);
                    _mapPosAtHelddown = Position;
                    _holdDownTime     = DateTime.Now;
                }
                else if (Game.IsControlJustReleased(Control.CursorAccept))
                {
                    if (_justOpened_mouse)
                    {
                        _justOpened_mouse = false;
                        _justOpened_kb    = false;
                    }
                    else
                    {
                        Position = _mapPosAtHelddown +
                                   new SizeF((_heldDownPoint.X - mouseX) / Zoom, (_heldDownPoint.Y - mouseY) / Zoom);
                        _isHeldDown = false;

                        if (DateTime.Now.Subtract(_holdDownTime).TotalMilliseconds < 100)
                        {
                            if (Function.Call <bool>(Hash.IS_WAYPOINT_ACTIVE))
                            {
                                Function.Call(Hash.SET_WAYPOINT_OFF);
                                Audio.PlaySoundFrontend("CANCEL", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                            }
                            else
                            {
                                var wpyPos  = new PointF(center.X - Position.X * Zoom, center.Y - Position.Y * Zoom);
                                var ourShit = new SizeF(mouseX - wpyPos.X, mouseY - wpyPos.Y);
                                var realPos = Map2DToWorld3d(wpyPos, wpyPos + ourShit);
                                Function.Call(Hash.SET_NEW_WAYPOINT, realPos.X, realPos.Y * -1f);
                                Audio.PlaySoundFrontend("WAYPOINT_SET", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                            }
                        }
                    }
                }

                if (Game.IsControlJustReleased(Control.FrontendAccept))
                {
                    if (_justOpened_kb)
                    {
                        _justOpened_kb    = false;
                        _justOpened_mouse = false;
                    }
                    else
                    {
                        if (Function.Call <bool>(Hash.IS_WAYPOINT_ACTIVE))
                        {
                            Function.Call(Hash.SET_WAYPOINT_OFF);
                            Audio.PlaySoundFrontend("CANCEL", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                        }
                        else
                        {
                            var wpyPos  = new PointF(center.X - Position.X * Zoom, center.Y - Position.Y * Zoom);
                            var ourShit = new SizeF(center.X - wpyPos.X, center.Y - wpyPos.Y);
                            var realPos = Map2DToWorld3d(wpyPos, wpyPos + ourShit);
                            Function.Call(Hash.SET_NEW_WAYPOINT, realPos.X, realPos.Y * -1f);
                            Audio.PlaySoundFrontend("WAYPOINT_SET", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                        }
                    }
                }

                if (_isHeldDown)
                {
                    Position = _mapPosAtHelddown + new SizeF((_heldDownPoint.X - mouseX) / Zoom, (_heldDownPoint.Y - mouseY) / Zoom);
                }

                var newPos  = new PointF(center.X - Position.X * Zoom, center.Y - Position.Y * Zoom);
                var newSize = new SizeF(1024.5f * Zoom, 1024.5f * Zoom);

                DrawSprite("minimap_sea_0_0", "minimap_sea_0_0", newPos, newSize);
                DrawSprite("minimap_sea_0_1", "minimap_sea_0_1", newPos + new SizeF(1024 * Zoom, 0), newSize);

                DrawSprite("minimap_sea_1_0", "minimap_sea_1_0", newPos + new SizeF(0, 1024 * Zoom), newSize);
                DrawSprite("minimap_sea_1_1", "minimap_sea_1_1", newPos + new SizeF(1024 * Zoom, 1024 * Zoom), newSize);

                DrawSprite("minimap_sea_2_0", "minimap_sea_2_0", newPos + new SizeF(0, 2048 * Zoom), newSize);
                DrawSprite("minimap_sea_2_1", "minimap_sea_2_1", newPos + new SizeF(1024 * Zoom, 2048 * Zoom), newSize);

                _crosshair.Size     = new Size(256, 3);
                _crosshair.Position = center + new Size(10, 0);
                _crosshair.Heading  = 0;
                _crosshair.Draw();

                _crosshair.Position = center - new Size(266, 0);
                _crosshair.Heading  = 180;
                _crosshair.Draw();

                _crosshair.Size     = new Size(3, 256);
                _crosshair.Heading  = 90;
                _crosshair.Position = center + new Size(0, 10);
                _crosshair.Draw();

                _crosshair.Position = center - new Size(0, 266);
                _crosshair.Heading  = 270;
                _crosshair.Draw();

                const float playerScale = 0.8f;

                Ped PlayerChar = Game.Player.Character;
                Util.Util.DxDrawTexture(0, BLIP_PATH + "player.png",
                                        newPos.X + World3DToMap2D(PlayerChar.Position).Width,
                                        newPos.Y + World3DToMap2D(PlayerChar.Position).Height, 32 * playerScale, 32 * playerScale,
                                        -PlayerChar.Rotation.Z, 255, 255, 255, 255, true);



                var blipList  = new List <string>();
                var localCopy = new List <IStreamedItem>(Main.NetEntityHandler.ClientMap.Values);

                foreach (var blip in Util.Util.GetAllBlips())
                {
                    if (File.Exists(BLIP_PATH + ((int)blip.Sprite) + ".png"))
                    {
                        var blipInfo = Main.NetEntityHandler.EntityToStreamedItem(blip.Handle) as RemoteBlip;

                        float scale = 1f;

                        if (blipInfo != null)
                        {
                            scale = blipInfo.Scale;
                        }

                        var fname = BLIP_PATH + ((int)blip.Sprite) + ".png";
                        var pos   = newPos + World3DToMap2D(blip.Position);
                        var siz   = new Size((int)(scale * 32), (int)(scale * 32));
                        var col   = GetBlipcolor(blip.Color, blip.Alpha);

                        if (pos.X > 0 && pos.Y > 0 && pos.X < res.Width && pos.Y < res.Height)
                        {
                            Util.Util.DxDrawTexture(blipList.Count, fname, pos.X, pos.Y, siz.Width, siz.Height, 0f, col.R, col.G, col.B, col.A, true);
                        }

                        var len      = scale * 32;
                        var halfLen  = len / 2;
                        var hoverPos = new PointF(mouseX, mouseY);

                        if (!_wasMouseInput)
                        {
                            hoverPos = center;
                        }

                        if (!string.IsNullOrEmpty(blipInfo?.Name) && hoverPos.X > pos.X - halfLen && hoverPos.Y > pos.Y - halfLen && hoverPos.X < pos.X + halfLen && hoverPos.Y < pos.Y + halfLen)                     // hovering over blip
                        {
                            var labelPos = pos - new Size(-32, 14);

                            new Sprite("mplobby", "mp_arrowsmall", new Point((int)labelPos.X - 19, (int)labelPos.Y - 15),
                                       new Size(20, 60), 180f, Color.Black).Draw();
                            new UIResRectangle(new Point((int)labelPos.X, (int)labelPos.Y), new Size(15 + StringMeasurer.MeasureString(blipInfo.Name), 30), Color.Black).Draw();
                            new UIResText(blipInfo.Name, new Point((int)labelPos.X + 5, (int)labelPos.Y), 0.35f).Draw();
                        }
                    }
                }

                foreach (var blip in localCopy.Where(item => item is RemoteBlip && !item.StreamedIn && (item.Dimension == Main.LocalDimension || item.Dimension == 0)).Cast <RemoteBlip>()) // draw the unstreamed blips
                {
                    if (File.Exists(BLIP_PATH + ((int)blip.Sprite) + ".png"))
                    {
                        var fname = BLIP_PATH + ((int)blip.Sprite) + ".png";
                        var pos   = newPos + World3DToMap2D(blip.Position.ToVector());
                        var scale = blip.Scale;
                        var siz   = new Size((int)(scale * 32), (int)(scale * 32));
                        var col   = GetBlipcolor((BlipColor)blip.Color, blip.Alpha);

                        if (pos.X > 0 && pos.Y > 0 && pos.X < res.Width && pos.Y < res.Height)
                        {
                            Util.Util.DxDrawTexture(blipList.Count, fname, pos.X, pos.Y, siz.Width, siz.Height, 0f, col.R, col.G, col.B, col.A, true);
                        }
                    }
                }

                foreach (var opp in Main.NetEntityHandler.ClientMap.Where(item => item.Value is SyncPed && (item.Value.Dimension == Main.LocalDimension || item.Value.Dimension == 0)).Select(pair => pair.Value).Cast <SyncPed>())
                {
                    if (opp.Character?.AttachedBlip == null || string.IsNullOrWhiteSpace(opp.Name) || opp.Character.AttachedBlip.Alpha == 0)
                    {
                        continue;
                    }

                    var blip = opp.Character.AttachedBlip;

                    var pos = newPos + World3DToMap2D(blip.Position) - new Size(-32, 14);

                    new Sprite("mplobby", "mp_arrowsmall", new Point((int)pos.X - 19, (int)pos.Y - 15) + offsetP,
                               new Size(20, 60) + offsetS, 180f, Color.Black).Draw();
                    new UIResRectangle(new Point((int)pos.X, (int)pos.Y), new Size(15 + StringMeasurer.MeasureString(opp.Name), 30), Color.Black).Draw();
                    new UIResText(opp.Name, new Point((int)pos.X + 5, (int)pos.Y), 0.35f).Draw();
                }



                var p1        = new PointF(center.X - Position.X * Zoom, center.Y - Position.Y * Zoom);
                var p2        = new SizeF(center.X - p1.X, center.Y - p1.Y);
                var centerPos = Map2DToWorld3d(p1, p1 + p2);

                centerPos = new Vector2(centerPos.X, centerPos.Y * -1f);

                var zone = World.GetZoneDisplayName(centerPos);

                if (!string.IsNullOrEmpty(zone))
                {
                    new UIResRectangle(new Point(30, (int)res.Height - 50),
                                       new Size(15 + StringMeasurer.MeasureString(zone), 30), Color.Black).Draw();
                    new UIResText(zone, new Point(35, (int)res.Height - 50), 0.35f).Draw();
                }

                /*
                 *
                 * foreach (var blipHandle in Main.NetEntityHandler.Blips)
                 *  {
                 *      var blip = new Blip(blipHandle);
                 *      if (!blip.Exists()) continue;
                 *
                 *      if (File.Exists(BLIP_PATH + ((int)blip.Sprite) + ".png"))
                 *      {
                 *          var fname = BLIP_PATH + ((int)blip.Sprite) + ".png";
                 *          var pos = newPos + World3DToMap2D(blip.Position) - new Size(16, 16);
                 *          var siz = new Size(32, 32);
                 *          var col = GetBlipcolor(blip.Color, blip.Alpha);
                 *          var ident = fname +
                 *                      (blipList.Count(k => k == fname) > 0
                 *                          ? blipList.Count(k => k == fname).ToString()
                 *                          : "");
                 *          Util.DxDrawTexture(blipList.Count, fname, pos.X, pos.Y, siz.Width, siz.Height, 0f, col.R, col.G, col.B, col.A);
                 *          blipList.Add(((int)blip.Sprite) + ".png");
                 *      }
                 *  }
                 *
                 *
                 * foreach (var blipHandle in Main.BlipCleanup)
                 * {
                 *  var blip = new Blip(blipHandle);
                 *  if (!blip.Exists()) continue;
                 *
                 *  if (File.Exists(BLIP_PATH + ((int)blip.Sprite) + ".png"))
                 *  {
                 *      var fname = BLIP_PATH + ((int)blip.Sprite) + ".png";
                 *      var pos = newPos + World3DToMap2D(blip.Position) - new Size(16, 16);
                 *      var siz = new Size(32, 32);
                 *      var col = GetBlipcolor(blip.Color, blip.Alpha);
                 *      var ident = fname +
                 *                  (blipList.Count(k => k == fname) > 0
                 *                      ? blipList.Count(k => k == fname).ToString()
                 *                      : "");
                 *      Util.DxDrawTexture(blipList.Count, fname, pos.X, pos.Y, siz.Width, siz.Height, 0f, col.R, col.G, col.B, col.A);
                 *      blipList.Add(((int)blip.Sprite) + ".png");
                 *  }
                 * }*/
            }
        }
Exemple #6
0
        public override void Draw()
        {
            if (!Visible)
            {
                return;
            }
            base.Draw();

            var res = UIMenu.GetScreenResolutionMaintainRatio();

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

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

            int i = 0;

            for (int c = _minItem; c < Math.Min(Items.Count, _maxItem); c++)
            {
                var hovering = UIMenu.IsMouseInBounds(SafeSize.AddPoints(new PointF(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 PointF(0, (itemSize.Height + 3) * i)), itemSize, (Index == c && Focused) ? Color.FromArgb(fullAlpha, UnknownColors.White) : Focused && hovering ? Color.FromArgb(100, 50, 50, 50) : Color.FromArgb(blackAlpha, UnknownColors.Black)).Draw();
                new UIResText(Items[c].Text, SafeSize.AddPoints(new PointF((hasBothBadges ? 60 : hasAnyBadge ? 30 : 6), 5 + (itemSize.Height + 3) * i)), 0.35f, Color.FromArgb(fullAlpha, (Index == c && Focused) ? UnknownColors.Black : UnknownColors.White)).Draw();

                if (hasLeftBadge && !hasRightBadge)
                {
                    new Sprite(UIMenuItem.BadgeToSpriteLib(Items[c].LeftBadge),
                               UIMenuItem.BadgeToSpriteName(Items[c].LeftBadge, (Index == c && Focused)), SafeSize.AddPoints(new PointF(-2, 1 + (itemSize.Height + 3) * i)), new SizeF(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 PointF(-2, 1 + (itemSize.Height + 3) * i)), new SizeF(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 PointF(-2, 1 + (itemSize.Height + 3) * i)), new SizeF(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 PointF(25, 1 + (itemSize.Height + 3) * i)), new SizeF(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 PointF(BottomRight.X - SafeSize.X - 5, 5 + (itemSize.Height + 3) * i)),
                                  0.35f, Color.FromArgb(fullAlpha, (Index == c && Focused) ? UnknownColors.Black : UnknownColors.White),
                                  Font.ChaletLondon, UIResText.ScreenAlignment.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 PointF(BottomRight.X - SafeSize.X - 60, -5 + (itemSize.Height + 3) * i)), new SizeF(50, 50)).Draw();
                }
                else if (Items[c] is UIMenuListItem convItem)
                {
                    var yoffset = 5;
                    var basePos =
                        SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 30, yoffset + (itemSize.Height + 3) * i));

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

                    string caption = convItem.IndexToItem(convItem.Index).ToString();
                    float  offset  = StringMeasurer.MeasureString(caption);

                    var selected = c == Index && Focused;

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

                    itemText.Caption = caption;

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

                    arrowLeft.Position =
                        SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 60 - (int)offset, yoffset + (itemSize.Height + 3) * i));
                    if (selected)
                    {
                        arrowLeft.Draw();
                        arrowRight.Draw();
                        itemText.Position = SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 30, yoffset + (itemSize.Height + 3) * i));
                    }
                    else
                    {
                        itemText.Position = SafeSize.AddPoints(new PointF(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)
                    {
                        PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", true);
                    }
                    else
                    {
                        if (Items[Index] is UIMenuCheckboxItem)
                        {
                            PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", true);
                            ((UIMenuCheckboxItem)Items[Index]).Checked = !((UIMenuCheckboxItem)Items[Index]).Checked;
                            ((UIMenuCheckboxItem)Items[Index]).CheckboxEventTrigger();
                        }
                        else
                        {
                            PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", true);
                            Items[Index].ItemActivate(null);
                        }
                    }
                }

                i++;
            }
        }
Exemple #7
0
        public override void Draw()
        {
            if (!Visible)
            {
                return;
            }

            base.Draw();

            int blackAlpha = Focused ? 200 : 100;
            int fullAlpha  = Focused ? 255 : 150;

            int  subMenuWidth = (BottomRight.X - TopLeft.X);
            Size itemSize     = new Size(subMenuWidth, 40);

            int i = 0;

            for (int c = minItem; c < Math.Min(Items.Count, maxItem); c++)
            {
                //bool hovering = UIMenu.IsMouseInBounds(SafeSize.AddPoints(new Point(0, (itemSize.Height + 3) * i)), itemSize);

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

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

                ResRectangle.Draw(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));
                ResText.Draw(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), Common.EFont.ChaletLondon, false);

                if (hasLeftBadge && !hasRightBadge)
                {
                    Sprite.Draw(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)));
                }

                if (!hasLeftBadge && hasRightBadge)
                {
                    Sprite.Draw(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)));
                }

                if (hasLeftBadge && hasRightBadge)
                {
                    Sprite.Draw(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)));

                    Sprite.Draw(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)));
                }

                if (!String.IsNullOrEmpty(Items[c].RightLabel))
                {
                    ResText.Draw(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),
                                 Common.EFont.ChaletLondon, ResText.Alignment.Right, false, false, Size.Empty);
                }

                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";
                    }
                    Sprite.Draw("commonmenu", textureName, SafeSize.AddPoints(new Point(BottomRight.X - SafeSize.X - 60, -5 + (itemSize.Height + 3) * i)), new Size(50, 50), 0f, Color.White);
                }
                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 ResText("", basePos, 0.35f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Right);

                    string caption = (convItem.Collection == null ? convItem.IndexToItem(convItem.Index) : convItem.Collection[convItem.Index]).ToString();
                    int    offset  = StringMeasurer.MeasureString(caption);

                    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 - 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 && (Common.IsDisabledControlJustPressed(0, GameControl.CursorAccept) || Game.IsControlJustPressed(0, GameControl.CursorAccept)))
                //{
                //    bool open = Index == c;
                //    Index = (1000 - (1000 % Items.Count) + c) % Items.Count;
                //    if (!open)
                //        Common.PlaySound("NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                //    else
                //    {
                //        if (Items[Index] is UIMenuCheckboxItem)
                //        {
                //            Common.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                //            UIMenuCheckboxItem cb = (UIMenuCheckboxItem)Items[Index];
                //            cb.Checked = !cb.Checked;
                //            cb.CheckboxEventTrigger();
                //        }
                //        else
                //        {
                //            Common.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                //            Items[Index].ItemActivate(null);
                //        }
                //    }
                //}

                i++;
            }
        }
Exemple #8
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);
        }
Exemple #9
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);
        }