public static int ProcessLoop()
        {
            if (!ScreenTools.IsDiabloFocused())
            {
                return(1);
            }
            if (ScreenTools.IsPorting())
            {
                return(3);
            }

            bool inRift = ScreenTools.IsInRift();

            // Conditions for Skill Activation
            if (
                ActiveMode.GetCurrentMode() == ActiveMode.Mode.AlwaysActive ||
                (ActiveMode.GetCurrentMode() == ActiveMode.Mode.Automatic && inRift)
                )
            {
                ProcessSkills();
            }

            // Conditions for Town Actions
            if (ActiveMode.GetCurrentMode() != ActiveMode.Mode.AlwaysActive && !inRift)
            {
                ProcessTown();
            }

            // always process potion
            PotionSkill.Process();
            return(0);
        }
Example #2
0
        private static void Run(SettingsBundle xml)
        {
            // CREATE MAIN FORM
            MainForm mainForm = new MainForm();
            mainForm.FormClosing += (object s, FormClosingEventArgs e) => ShutDown();

            // INITIALIZE
            SetFormRefs(mainForm);
            Init(xml, mainForm);

            // TRY START DIABLO / TURBOHUD
            if (!CheckForStart()) MessageBox.Show("You might have to restart the Helper, after you started Diablo", "Restart Helper");

            // INIT COORDINATES
            Coords.Coords.InitCoords();
            (Dim dim, bool success) = ScreenTools.GetWindowDimensions();
            if (success)
                Coords.Coords.ConvertCoords(dim.Width, dim.Height);

            // INIT KILL COORDS
            SkillCoords.Init();

            // START SKILL LOOP
            StartSkillLoop();

            // START AUTH LOOP
            StartAuthLoop();

            // LAUNCH APPLICATION
            Application.Run(mainForm);
        }
Example #3
0
 private static void SalvageYellows()
 {
     if (ScreenTools.GetPixelColor(SalvageYellowPos.X, SalvageYellowPos.Y).Item1.Equals(SalvageYellowCol))
     {
         HardwareRobot.DoLeftClick(SalvageYellowPos.X, SalvageYellowPos.Y, HardwareRobot.ActionTypes.SIMULATE);
         Confirm();
     }
 }
Example #4
0
#pragma warning disable IDE0060 // Nicht verwendete Parameter entfernen
        public static bool Potion(int skillSlot, Color pxl)
#pragma warning restore IDE0060 // Nicht verwendete Parameter entfernen
        {
            int px = Coords.Coords.PotionSkill.x;
            int py = Coords.Coords.PotionSkill.y;

            if (!ScreenTools.GetPixelColor(px, py).Item1.Equals(PotionColor))
            {
                return(false);
            }
            return(pxl.R < PotionMinRed);
        }
Example #5
0
 private void OnGUI()
 {
     for (int i = 0; i < msgList.Count; ++i)
     {
         string msg = msgList[i].ToString();
         //GUIStyle st=new GUIStyle();
         //st=GUI.skin.GetStyle();
         //st.font.name="STHeiti";
         //st.font.fontNames
         GUI.Label(new Rect(0, 0 + 20 * i, ScreenTools.getLocalX(msg.Length * 16), 20), msg);
     }
 }
Example #6
0
#pragma warning disable IDE0060 // Nicht verwendete Parameter entfernen
        public static bool FullEssence(int skillSlot, Color pxl)
        {
            int   px      = Coords.Coords.ResourceCheck.x;
            int   py      = Coords.Coords.ResourceCheck.y;
            Color essCol1 = ScreenTools.GetPixelColor(px, py).Item1;
            Color essCol2 = ScreenTools.GetPixelColor(px + 10, py).Item1;
            Color essCol3 = ScreenTools.GetPixelColor(px - 10, py).Item1;

            if (Math.Abs(essCol1.R - EssenceBase.R) > EssenceVariance)
            {
                return(false);
            }
            if (Math.Abs(essCol1.G - EssenceBase.G) > EssenceVariance)
            {
                return(false);
            }
            if (Math.Abs(essCol1.B - EssenceBase.B) > EssenceVariance)
            {
                return(false);
            }

            if (Math.Abs(essCol2.R - EssenceBase.R) > EssenceVariance)
            {
                return(false);
            }
            if (Math.Abs(essCol2.G - EssenceBase.G) > EssenceVariance)
            {
                return(false);
            }
            if (Math.Abs(essCol2.B - EssenceBase.B) > EssenceVariance)
            {
                return(false);
            }

            if (Math.Abs(essCol3.R - EssenceBase.R) > EssenceVariance)
            {
                return(false);
            }
            if (Math.Abs(essCol3.G - EssenceBase.G) > EssenceVariance)
            {
                return(false);
            }
            if (Math.Abs(essCol3.B - EssenceBase.B) > EssenceVariance)
            {
                return(false);
            }


            return(true);
        }
        public static Color GetPxlColor(Skill skill)
        {
            int slotId = skill.Slot;

            (Color c, bool success) = ScreenTools.GetPixelColor(skillSlots[slotId].x, skillSlots[slotId].y);
            if (!success)
            {
                return(Color.Transparent);
            }
            else
            {
                return(c);
            }
        }
Example #8
0
 public void Process()
 {
     if (IsActive && AvailableFunctions.Potion(0, ScreenTools.GetPixelColor(Coords.Coords.Potion50.x, Coords.Coords.Potion50.y).Item1))
     {
         if (Key.IsMouse)
         {
             if (Key.CurrentKey == Keys.LButton)
             {
                 HardwareRobot.DoLeftClick();
             }
             else if (Key.CurrentKey == Keys.RButton)
             {
                 HardwareRobot.DoRightClick();
             }
         }
         else
         {
             HardwareRobot.PressKey((char)Key.CurrentKey);
         }
     }
 }
Example #9
0
        public override void Draw()
        {
            if (!Visible)
            {
                return;
            }
            base.Draw();

            var res = ScreenTools.ResolutionMaintainRatio;

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

            var activeWidth  = res.Width - SafeSize.X * 2;
            var submenuWidth = (int)(activeWidth * 0.6818f);
            var itemSize     = new SizeF((int)activeWidth - (submenuWidth + 3), 40);

            for (int i = 0; i < Items.Count; i++)
            {
                var hovering = ScreenTools.IsMouseInBounds(SafeSize.AddPoints(new PointF(0, (itemSize.Height + 3) * i)),
                                                           itemSize);

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

                if (Focused && hovering && Game.IsControlJustPressed(0, Control.CursorAccept))
                {
                    Items[Index].Focused = false;
                    Game.PlaySound("NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                    bool open = Index == i;
                    Index = (1000 - (1000 % Items.Count) + i) % Items.Count;
                    if (open)
                    {
                        if (Items[Index].CanBeFocused && !Items[Index].Focused)
                        {
                            Parent.FocusLevel       = 2;
                            Items[Index].JustOpened = true;
                            Items[Index].Focused    = true;
                        }
                        else
                        {
                            Items[Index].OnActivated();
                        }
                    }
                    else
                    {
                        Parent.FocusLevel = 1;
                    }
                }
            }

            Items[Index].Visible           = true;
            Items[Index].FadeInWhenFocused = true;
            //Items[Index].CanBeFocused = true;
            if (!Items[Index].CanBeFocused)
            {
                Items[Index].Focused = Focused;
            }
            Items[Index].UseDynamicPositionment = false;
            Items[Index].SafeSize    = SafeSize.AddPoints(new PointF((int)activeWidth - submenuWidth, 0));
            Items[Index].TopLeft     = SafeSize.AddPoints(new PointF((int)activeWidth - submenuWidth, 0));
            Items[Index].BottomRight = new PointF((int)res.Width - SafeSize.X, (int)res.Height - SafeSize.Y);
            Items[Index].Draw();
        }
Example #10
0
        public override void Draw()
        {
            if (!Visible)
            {
                return;
            }
            base.Draw();

            var res = ScreenTools.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 SizeF(submenuWidth, 40);

            int i = 0;

            for (int c = _minItem; c < Math.Min(Items.Count, _maxItem); c++)
            {
                var hovering = ScreenTools.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, Colors.White) : Focused && hovering ? Color.FromArgb(100, 50, 50, 50) : Color.FromArgb(blackAlpha, Colors.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) ? Colors.Black : Colors.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) ? Colors.Black : Colors.White),
                                  Font.ChaletLondon, 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 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, Colors.White, Font.ChaletLondon,
                                                   Alignment.Left)
                    {
                        TextAlignment = Alignment.Right
                    };

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

                    var selected = c == Index && Focused;

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

                    itemText.Caption = caption;

                    arrowLeft.Color  = convItem.Enabled ? selected ? Colors.Black : Colors.WhiteSmoke : Color.FromArgb(163, 159, 148);
                    arrowRight.Color = convItem.Enabled ? selected ? Colors.Black : Colors.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)
                    {
                        Game.PlaySound("NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                    }
                    else
                    {
                        if (Items[Index] is UIMenuCheckboxItem)
                        {
                            Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                            ((UIMenuCheckboxItem)Items[Index]).Checked = !((UIMenuCheckboxItem)Items[Index]).Checked;
                            ((UIMenuCheckboxItem)Items[Index]).CheckboxEventTrigger();
                        }
                        else
                        {
                            Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                            Items[Index].ItemActivate(null);
                        }
                    }
                }

                i++;
            }
        }
Example #11
0
        public override void Draw()
        {
            base.Draw();
            if (Heists.Count == 0)
            {
                return;
            }

            var res = ScreenTools.ResolutionMaintainRatio;

            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, Colors.White) : Color.FromArgb(blackAlpha, Colors.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) ? Colors.Black : Colors.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, Colors.Black)).Draw();
            new UIResText(Heists[Index].Name, new PointF((int)res.Width - SafeSize.X - 4, SafeSize.Y + 260), 0.5f, Color.FromArgb(fullAlpha, Colors.White),
                          Font.HouseScript, Alignment.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, Colors.White)).Draw();
                new UIResText(label, new PointF((int)res.Width - SafeSize.X - 6, SafeSize.Y + 260 + 42 + (40 * i)), 0.35f, Color.FromArgb(fullAlpha, Colors.White), Font.ChaletLondon, Alignment.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, Colors.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, Colors.White))
                {
                    Wrap = 508
                }.Draw();
                new UIResRectangle(new PointF((int)res.Width - SafeSize.X - 512, SafeSize.Y + 256 + 44 + 40 * propLen),
                                   new SizeF(512, 45 * (int)(ScreenTools.GetTextWidth(Heists[Index].Description, Font.ChaletLondon, 0.35f) / 500)),
                                   Color.FromArgb(blackAlpha, 0, 0, 0)).Draw();
            }
        }
Example #12
0
        public void Update()
        {
            if (!Visible || TemporarilyHidden)
            {
                return;
            }
            ShowInstructionalButtons();
            API.HideHudAndRadarThisFrame();
            API.ShowCursorThisFrame();


            var res  = ScreenTools.ResolutionMaintainRatio;
            var safe = new PointF(300, 180);

            if (!HideTabs)
            {
                new UIResText(Title, new PointF(safe.X, safe.Y - 80), 1f, Colors.White, Font.ChaletComprimeCologne,
                              Alignment.Left)
                {
                    Shadow = true,
                }.Draw();

                if (Photo == null)
                {
                    new Sprite("char_multiplayer", "char_multiplayer",
                               new PointF((int)res.Width - safe.X - 64, safe.Y - 80), new SizeF(64, 64)).Draw();
                }
                else
                {
                    Photo.Position = new PointF((int)res.Width - safe.X - 100, safe.Y - 80);
                    Photo.Size     = new SizeF(64, 64);
                    Photo.Draw();
                }

                new UIResText(Name, new PointF((int)res.Width - safe.X - 70, safe.Y - 95), 0.7f, Colors.White,
                              Font.ChaletComprimeCologne, Alignment.Right)
                {
                    Shadow = true,
                }.Draw();

                string t = Money;
                if (string.IsNullOrEmpty(Money))
                {
                    t = DateTime.Now.ToString();
                }


                new UIResText(t, new PointF((int)res.Width - safe.X - 70, safe.Y - 60), 0.4f, Colors.White,
                              Font.ChaletComprimeCologne, Alignment.Right)
                {
                    Shadow = true,
                }.Draw();

                string subt = MoneySubtitle;
                if (string.IsNullOrEmpty(MoneySubtitle))
                {
                    subt = "";
                }

                new UIResText(subt, new PointF((int)res.Width - safe.X - 70, safe.Y - 40), 0.4f, Colors.White,
                              Font.ChaletComprimeCologne, Alignment.Right)
                {
                    Shadow = true,
                }.Draw();

                for (int i = 0; i < Tabs.Count; i++)
                {
                    var activeSize = res.Width - 2 * safe.X;
                    activeSize -= 4 * 5;
                    int tabWidth = (int)activeSize / Tabs.Count;
                    Game.EnableControlThisFrame(0, Control.CursorX);
                    Game.EnableControlThisFrame(0, Control.CursorY);

                    var hovering = ScreenTools.IsMouseInBounds(safe.AddPoints(new PointF((tabWidth + 5) * i, 0)),
                                                               new SizeF(tabWidth, 40));

                    var tabColor = Tabs[i].Active
                        ? Colors.White
                        : hovering?Color.FromArgb(100, 50, 50, 50) : Colors.Black;

                    new UIResRectangle(safe.AddPoints(new PointF((tabWidth + 5) * i, 0)), new SizeF(tabWidth, 40),
                                       Color.FromArgb(Tabs[i].Active ? 255 : 200, tabColor)).Draw();

                    new UIResText(Tabs[i].Title.ToUpper(), safe.AddPoints(new PointF((tabWidth / 2) + (tabWidth + 5) * i, 5)),
                                  0.35f,
                                  Tabs[i].Active ? Colors.Black : Colors.White, Font.ChaletLondon, Alignment.Center)
                    .Draw();

                    if (Tabs[i].Active)
                    {
                        new UIResRectangle(safe.SubtractPoints(new PointF(-((tabWidth + 5) * i), 10)),
                                           new SizeF(tabWidth, 10), Colors.DodgerBlue).Draw();
                    }

                    if (hovering && Game.IsControlJustPressed(0, Control.CursorAccept) && !Tabs[i].Active)
                    {
                        Tabs[Index].Active  = false;
                        Tabs[Index].Focused = false;
                        Tabs[Index].Visible = false;
                        Index = (1000 - (1000 % Tabs.Count) + i) % Tabs.Count;
                        Tabs[Index].Active     = true;
                        Tabs[Index].Focused    = true;
                        Tabs[Index].Visible    = true;
                        Tabs[Index].JustOpened = true;

                        if (Tabs[Index].CanBeFocused)
                        {
                            FocusLevel = 1;
                        }
                        else
                        {
                            FocusLevel = 0;
                        }

                        Game.PlaySound("NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                    }
                }
            }
            Tabs[Index].Draw();

            _sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);

            _sc.Render2D();
        }
Example #13
0
        public override void Draw()
        {
            if (!Visible)
            {
                return;
            }
            base.Draw();

            var alpha      = Focused ? 120 : 30;
            var blackAlpha = Focused ? 200 : 100;
            var fullAlpha  = Focused ? 250 : 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 = ScreenTools.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, Colors.White) : Focused && hovering ? Color.FromArgb(100, 50, 50, 50) : Color.FromArgb(blackAlpha, Colors.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) ? Colors.Black : Colors.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) ? Colors.Black : Colors.White),
                                  Font.ChaletLondon, Alignment.Right).Draw();
                }

                if (Items[c] is UIMenuCheckboxItem convItem)
                {
                    convItem.Selected = c == Index && Focused;
                    convItem._checkedSprite.Position    = SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 60, -5 + (itemSize.Height + 3) * i));
                    convItem._checkedSprite.TextureName = convItem.Selected ? (convItem.Checked ? (convItem.Style == UIMenuCheckboxStyle.Tick ? "shop_box_tickb" : "shop_box_crossb") : "shop_box_blankb") : convItem.Checked ? (convItem.Style == UIMenuCheckboxStyle.Tick ? "shop_box_tick" : "shop_box_cross") : "shop_box_blank";
                    convItem._checkedSprite.Draw();
                }
                else if (Items[c] is UIMenuListItem listItem)
                {
                    var yoffset = 5;
                    var basePos =
                        SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 30, yoffset + (itemSize.Height + 3) * i));

                    listItem._arrowLeft.Position     = basePos;
                    listItem._arrowRight.Position    = basePos;
                    listItem._itemText.Position      = basePos;
                    listItem._itemText.Color         = Colors.White;
                    listItem._itemText.Font          = Font.ChaletLondon;
                    listItem._itemText.Alignment     = Alignment.Left;
                    listItem._itemText.TextAlignment = Alignment.Right;

                    string caption = listItem.Items[listItem.Index].ToString();
                    float  offset  = ScreenTools.GetTextWidth(caption, listItem._itemText.Font, listItem._itemText.Scale);

                    var selected = c == Index && Focused;
                    listItem.Selected = selected;

                    listItem._itemText.Color = listItem.Enabled ? listItem.Selected ? Colors.Black : Colors.WhiteSmoke : Color.FromArgb(163, 159, 148);

                    listItem._itemText.Caption = caption;

                    listItem._arrowLeft.Color  = listItem.Enabled ? listItem.Selected ? Colors.Black : Colors.WhiteSmoke : Color.FromArgb(163, 159, 148);
                    listItem._arrowRight.Color = listItem.Enabled ? listItem.Selected ? Colors.Black : Colors.WhiteSmoke : Color.FromArgb(163, 159, 148);

                    listItem._arrowLeft.Position = SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 60 - (int)offset, yoffset + (itemSize.Height + 3) * i));
                    if (listItem.Selected)
                    {
                        listItem._arrowLeft.Draw();
                        listItem._arrowRight.Draw();
                        listItem._itemText.Position = SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 30, yoffset + (itemSize.Height + 3) * i));
                    }
                    else
                    {
                        listItem._itemText.Position = SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 5, yoffset + (itemSize.Height + 3) * i));
                    }
                    listItem._itemText.Draw();
                }
                else if (Items[c] is UIMenuSliderItem sliderItem)
                {
                    var yoffset = 15;
                    var basePos = SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 210, yoffset + (itemSize.Height + 3) * i));
                    sliderItem._rectangleBackground.Position = basePos;
                    sliderItem._rectangleBackground.Size     = new SizeF(200f, 10);

                    sliderItem._rectangleSlider.Position = basePos;
                    sliderItem._rectangleSlider.Size     = new SizeF(100f, 10);

                    sliderItem._rectangleDivider.Position = SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 110, (yoffset - 5) + (itemSize.Height + 3) * i));
                    sliderItem._rectangleDivider.Size     = new SizeF(2, 20);
                    if (sliderItem.Divider)
                    {
                        sliderItem._rectangleDivider.Color = Colors.WhiteSmoke;
                    }
                    sliderItem.Selected = c == Index && Focused;

                    sliderItem._rectangleSlider.Position = new PointF(basePos.X + (sliderItem._value / (float)sliderItem._max * 100f), sliderItem._rectangleSlider.Position.Y);
                    sliderItem._rectangleBackground.Draw();
                    sliderItem._rectangleSlider.Draw();
                    if (sliderItem.Divider)
                    {
                        sliderItem._rectangleDivider.Draw();
                    }
                }
                else if (Items[c] is UIMenuSliderProgressItem sliderProgressItem)
                {
                    var yoffset = 15;
                    var basePos = SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 210, yoffset + (itemSize.Height + 3) * i));
                    sliderProgressItem._rectangleBackground.Position = basePos;
                    sliderProgressItem._rectangleBackground.Size     = new SizeF(200, 10);

                    sliderProgressItem._rectangleSlider.Position = basePos;

                    sliderProgressItem._rectangleDivider.Position = SafeSize.AddPoints(new PointF(BottomRight.X - SafeSize.X - 100, (yoffset - 5) + (itemSize.Height + 3f) * i));
                    sliderProgressItem._rectangleDivider.Size     = new SizeF(2, 20);

                    if (sliderProgressItem.Divider)
                    {
                        sliderProgressItem._rectangleDivider.Color = Colors.WhiteSmoke;
                    }
                    sliderProgressItem.Selected = c == Index && Focused;

                    sliderProgressItem._rectangleBackground.Draw();
                    sliderProgressItem._rectangleSlider.Draw();
                    sliderProgressItem._rectangleDivider.Draw();

                    if (ScreenTools.IsMouseInBounds(new PointF(sliderProgressItem._rectangleBackground.Position.X, sliderProgressItem._rectangleBackground.Position.Y - 5), new SizeF(200f, sliderProgressItem._rectangleBackground.Size.Height)))
                    {
                        if (API.IsDisabledControlPressed(0, 24))
                        {
                            if (!sliderProgressItem.Pressed)
                            {
                                sliderProgressItem.Pressed  = true;
                                sliderProgressItem.Audio.Id = API.GetSoundId();
                                API.PlaySoundFrontend(sliderProgressItem.Audio.Id, sliderProgressItem.Audio.Slider, sliderProgressItem.Audio.Library, true);
                            }
                            float CursorX  = API.GetDisabledControlNormal(0, 239) * Resolution.Width;
                            var   Progress = CursorX - sliderProgressItem._rectangleSlider.Position.X;
                            sliderProgressItem.Value = (int)Math.Round(sliderProgressItem._max * ((Progress >= 0f && Progress <= 200f) ? Progress : (Progress < 0) ? 0 : 200f) / 200f);
                            sliderProgressItem.SliderProgressChanged(sliderProgressItem.Value);
                        }
                        else
                        {
                            API.StopSound(sliderProgressItem.Audio.Id);
                            API.ReleaseSoundId(sliderProgressItem.Audio.Id);
                            sliderProgressItem.Pressed = false;
                        }
                    }
                    else
                    {
                        API.StopSound(sliderProgressItem.Audio.Id);
                        API.ReleaseSoundId(sliderProgressItem.Audio.Id);
                        sliderProgressItem.Pressed = false;
                    }
                }

                if (Focused && hovering && Game.IsControlJustPressed(0, Control.CursorAccept))
                {
                    bool open = Index == c;
                    Index = (1000 - (1000 % Items.Count) + c) % Items.Count;
                    if (!open)
                    {
                        Game.PlaySound("NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                    }
                    else
                    {
                        if (Items[Index] is UIMenuCheckboxItem)
                        {
                            Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                            ((UIMenuCheckboxItem)Items[Index]).Checked = !((UIMenuCheckboxItem)Items[Index]).Checked;
                            ((UIMenuCheckboxItem)Items[Index]).CheckboxEventTrigger();
                        }
                        else
                        {
                            Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                            Items[Index].ItemActivate(null);
                        }
                    }
                }
                i++;
            }
        }
Example #14
0
        public void Draw()
        {
            if (!Visible || TemporarilyHidden)
            {
                return;
            }
            ShowInstructionalButtons();
            API.HideHudAndRadarThisFrame();
            API.ShowCursorThisFrame();


            var safe = new PointF(300, SubTitle != null && SubTitle != ""? 205 : 195);

            if (!HideTabs)
            {
                /*
                 * new UIResText(Title, new PointF(safe.X, safe.Y - 80), 1f, Colors.White, Font.ChaletComprimeCologne, Alignment.Left)
                 * {
                 *  Shadow = true,
                 * }.Draw();
                 *
                 * if (Photo == null)
                 *  new Sprite("char_multiplayer", "char_multiplayer", new PointF((int)Resolution.Width - safe.X - 64, safe.Y - 90), new SizeF(75, 75)).Draw();
                 * else
                 * {
                 *  Photo.Position = new PointF((int)Resolution.Width - safe.X - 100, safe.Y - 90);
                 *  Photo.Size = new SizeF(75, 75);
                 *  Photo.Draw();
                 * }
                 *
                 * new UIResText(Name, new PointF((int)Resolution.Width - safe.X - 106, safe.Y - 98), 0.5f, Colors.White, Font.ChaletComprimeCologne, Alignment.Right)
                 * {
                 *  Shadow = true,
                 * }.Draw();
                 *
                 * string t = Money;
                 * if (string.IsNullOrEmpty(Money))
                 * {
                 *  t = DateTime.Now.ToString();
                 * }
                 *
                 *
                 * new UIResText(t, new PointF((int)Resolution.Width - safe.X - 106, safe.Y - 70), 0.5f, Colors.White,
                 *  Font.ChaletComprimeCologne, Alignment.Right)
                 * {
                 *  Shadow = true,
                 * }.Draw();
                 *
                 * string subt = MoneySubtitle;
                 * if (string.IsNullOrEmpty(MoneySubtitle))
                 * {
                 *  subt = "";
                 * }
                 *
                 * new UIResText(subt, new PointF((int)Resolution.Width - safe.X - 106, safe.Y - 44), 0.5f, Colors.White,
                 *  Font.ChaletComprimeCologne, Alignment.Right)
                 * {
                 *  Shadow = true,
                 * }.Draw();
                 */
                for (int i = 0; i < Tabs.Count; i++)
                {
                    var activeSize = Resolution.Width - 2 * safe.X;
                    activeSize -= 5;
                    float tabWidth = ((int)activeSize / Tabs.Count) - 1.95f;
                    Game.EnableControlThisFrame(0, Control.CursorX);
                    Game.EnableControlThisFrame(0, Control.CursorY);

                    var hovering = ScreenTools.IsMouseInBounds(safe.AddPoints(new PointF((tabWidth + 5) * i, 0)),
                                                               new SizeF(tabWidth, 40));

                    var tabColor = Tabs[i].Active ? Colors.White : hovering?Color.FromArgb(100, 50, 50, 50) : Colors.Black;

                    new UIResRectangle(safe.AddPoints(new PointF((tabWidth + 5) * i, 0)), new SizeF(tabWidth, 40), Color.FromArgb(Tabs[i].Active ? 255 : 200, tabColor)).Draw();
                    if (Tabs[i].Active)
                    {
                        new UIResRectangle(safe.SubtractPoints(new PointF(-((tabWidth + 5) * i), 10)), new SizeF(tabWidth, 10), Colors.DodgerBlue).Draw();
                    }

                    new UIResText(Tabs[i].Title.ToUpper(), safe.AddPoints(new PointF((tabWidth / 2) + (tabWidth + 5) * i, 5)), 0.3f, Tabs[i].Active ? Colors.Black : Colors.White, Font.ChaletLondon, Alignment.Center).Draw();

                    if (hovering && Game.IsControlJustPressed(0, Control.CursorAccept) && !Tabs[i].Active)
                    {
                        Tabs[Index].Active  = false;
                        Tabs[Index].Focused = false;
                        Tabs[Index].Visible = false;
                        Index = (1000 - (1000 % Tabs.Count) + i) % Tabs.Count;
                        Tabs[Index].Active     = true;
                        Tabs[Index].Focused    = true;
                        Tabs[Index].Visible    = true;
                        Tabs[Index].JustOpened = true;

                        if (Tabs[Index].CanBeFocused)
                        {
                            FocusLevel = 1;
                        }
                        else
                        {
                            FocusLevel = 0;
                        }

                        Game.PlaySound("NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                    }
                }
            }
            Tabs[Index].Draw();

            _sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            _sc.Render2D();
            if (DisplayHeader)
            {
                if (!_loaded)
                {
                    ShowHeader();
                }
                API.DrawScaleformMovie(_header.Handle, 0.501f, 0.162f, 0.6782f, 0.145f, 255, 255, 255, 255, 0);
            }
        }