예제 #1
0
        public static void OnChange(Entity sender, Int32PropertyChangeEventArgs args)
        {
            var hero = sender as Hero;

            if (hero == null)
            {
                return;
            }
            if (hero.Team != Members.MyHero.Team || hero.IsIllusion())
            {
                return;
            }
            if (args.PropertyName != "m_iTaggedAsVisibleByTeam")
            {
                return;
            }
            DelayAction.Add(50, () =>
            {
                var visible = args.NewValue == 0x1E;
                var player  = hero.Player;
                RectangleStruct st;
                if (!RectDictionary.TryGetValue(player, out st))
                {
                    var newRect =
                        new Rectangle(
                            new Vector2((float)HudInfoNew.GetTopPanelSizeX(hero), (float)HUDInfo.GetTopPanelSizeY(hero)),
                            Clr)
                    {
                        Position = HudInfoNew.GetTopPanelPosition(hero)
                    };
                    st = new RectangleStruct(newRect, eventArgs => newRect.Render());
                    RectDictionary.Add(player, st);
                    //Log.Info($"Init new player {player.Name}({hero.GetRealName()})");
                }
                var rect = st.Rect;
                var draw = st.Draw;
                if (visible)
                {
                    if (IsEnable)
                    {
                        if (!rect.IsInitialized)
                        {
                            rect.Initialize();
                            rect.Color          = Clr; //new ColorBGRA(0,155,255,10);
                            Drawing.OnEndScene += draw;
                        }
                    }
                }
                else
                {
                    if (rect.IsInitialized)
                    {
                        rect.Dispose();
                        Drawing.OnEndScene -= draw;
                    }
                }
            });
        }
예제 #2
0
        private static void DrawNetWorthBar()
        {
            var startPos = HudInfoNew.GetFakeTopPanelPosition(0, Team.Radiant) +
                           new Vector2((float)HudInfoNew.GetTopPanelSizeX() * 5, (float)HudInfoNew.GetTopPanelSizeY());
            var endPos = HudInfoNew.GetFakeTopPanelPosition(5, Team.Dire);
            var size   = new Vector2(endPos.X - startPos.X,
                                     Members.Menu.Item("netWorthBar.Size").GetValue <Slider>().Value *Percent);

            DrawNetWorthBarStageOne(startPos, size);
        }
예제 #3
0
 public static Vector2 GetTopPanelPosition(Hero v)
 {
     try
     {
         Vector2 pos;
         if (Members.TopPanelPostiion.TryGetValue(v.StoredName(), out pos))
         {
             return(pos);
         }
         Members.TopPanelPostiion.Add(v.StoredName(), HudInfoNew.GetTopPanelPosition(v));
         //Members.TopPanelPostiion.Add(v.StoredName(), HUDInfo.GetTopPanelPosition(v));
         return(HudInfoNew.GetTopPanelPosition(v));
         //return HUDInfo.GetTopPanelPosition(v);
     }
     catch (Exception e)
     {
         Printer.Print("GetTopPanelPosition: " + e.Message);
         return(new Vector2());
     }
 }
예제 #4
0
        private static void DrawTopPanel(int type)
        {
            List <Hero> selectedHeroes = null;

            switch (type)
            {
            case 0:
                selectedHeroes = Manager.HeroManager.GetHeroes();
                break;

            case 1:
                selectedHeroes = Members.AllyHeroes;
                break;

            case 2:
                selectedHeroes = Members.EnemyHeroes;
                break;
            }
            if (selectedHeroes == null)
            {
                return;
            }
            if (Members.Menu.Item("toppanel.Status.Enable").GetValue <bool>() ||
                Members.Menu.Item("toppanel.Health.Enable").GetValue <bool>() ||
                Members.Menu.Item("toppanel.Mana.Enable").GetValue <bool>())
            {
                foreach (var v in selectedHeroes)
                {
                    try
                    {
                        var pos = Helper.GetTopPanelPosition(v) +
                                  new Vector2(Members.Menu.Item("extraPos.X").GetValue <Slider>().Value,
                                              Members.Menu.Item("extraPos.Y").GetValue <Slider>().Value);
                        var temp = HudInfoNew.GetTopPanelSize(v);
                        //var temp = HUDInfo.GetTopPanelSize(v);
                        var size        = new Vector2((float)temp[0], (float)temp[1]);
                        var healthDelta = new Vector2(v.Health * size.X / v.MaximumHealth, 0);
                        var manaDelta   = new Vector2(v.Mana * size.X / v.MaximumMana, 0);
                        DrawHealthPanel(pos, size, healthDelta);
                        DrawManaPanel(pos, size, manaDelta);
                        DrawStatus(pos, v, size);
                    }
                    catch (Exception)
                    {
                        Printer.Print($"[DrawTopPanel: selectedHeroes] --> {v!=null && v.IsValid}");
                    }
                }
            }
            if (!Members.Menu.Item("ultimate.Enable").GetValue <bool>())
            {
                return;
            }

            /*if (!Members.Menu.Item("ultimate.Icon.Enable").GetValue<bool>() &&
             *  !Members.Menu.Item("ultimate.Info").GetValue<bool>() &&
             *  !Members.Menu.Item("ultimate.InfoAlways").GetValue<bool>()) return;*/
            foreach (var v in Members.EnemyHeroes)
            {
                var ablist = Manager.HeroManager.GetAbilityList(v);
                if (ablist == null)
                {
                    continue;
                }
                try
                {
                    Ability ultimate;
                    if (!Ultimate.TryGetValue(v.StoredName(), out ultimate))
                    {
                        var spell = ablist.FirstOrDefault(x => x.IsAbilityType(AbilityType.Ultimate));
                        if (spell != null)
                        {
                            Ultimate.Remove(v.StoredName());
                            Ultimate.Add(v.StoredName(), spell);
                        }
                        continue;
                    }
                    if (ultimate == null || !ultimate.IsValid || ultimate.Level <= 0)
                    {
                        continue;
                    }
                    float lastTime;
                    if (v.IsVisible)
                    {
                        if (!LastTimeDictionary.TryGetValue(v.Handle, out lastTime))
                        {
                            LastTimeDictionary.Add(v.Handle, Game.RawGameTime);
                        }
                        else
                        {
                            LastTimeDictionary[v.Handle] = Game.RawGameTime;
                        }
                    }
                    else
                    {
                        LastTimeDictionary.TryGetValue(v.Handle, out lastTime);
                    }
                    var pos = Helper.GetTopPanelPosition(v) +
                              new Vector2(Members.Menu.Item("extraPos.X").GetValue <Slider>().Value,
                                          Members.Menu.Item("extraPos.Y").GetValue <Slider>().Value);
                    var tempS = HudInfoNew.GetTopPanelSize(v);
                    //var tempS = HUDInfo.GetTopPanelSize(v);
                    var    size   = new Vector2((float)tempS[0], (float)tempS[1]);
                    var    ultPos = pos + new Vector2(size[0] / 2 - 5, size[1] + 1);
                    string path;

                    switch (ultimate.AbilityState)
                    {
                    case AbilityState.NotEnoughMana:
                        path = "materials/ensage_ui/other/ulti_nomana.vmat";
                        break;

                    case AbilityState.OnCooldown:
                        path = "materials/ensage_ui/other/ulti_cooldown.vmat";
                        break;

                    default:
                        path = "materials/ensage_ui/other/ulti_ready.vmat";
                        break;
                    }
                    if (Members.Menu.Item("ultimate.Icon.Enable").GetValue <bool>())
                    {
                        Drawing.DrawRect(ultPos, new Vector2(14, 14), Drawing.GetTexture(path));
                    }
                    var cooldown = v.IsVisible ? ultimate.Cooldown : ultimate.Cooldown - Game.RawGameTime + lastTime;
                    cooldown = Math.Max(0, cooldown);
                    if (Members.Menu.Item("ultimate.Type").GetValue <StringList>().SelectedIndex == 0 &&
                        Members.Menu.Item("ultimate.Info").GetValue <bool>() &&
                        (Members.Menu.Item("ultimate.InfoAlways").GetValue <bool>() && (
                             ultimate.AbilityState == AbilityState.OnCooldown ||
                             ultimate.AbilityState == AbilityState.NotEnoughMana) ||
                         Utils.IsUnderRectangle(Game.MouseScreenPosition, ultPos.X, ultPos.Y, 15, 15)))
                    {
                        var texturename = $"materials/ensage_ui/spellicons/{ultimate.StoredName()}.vmat";
                        pos = Helper.GetTopPanelPosition(v) +
                              new Vector2(Members.Menu.Item("extraPos.X").GetValue <Slider>().Value,
                                          Members.Menu.Item("extraPos.Y").GetValue <Slider>().Value);
                        var startPos = pos + new Vector2(0, 7 * 4 + size.Y);
                        size = new Vector2(size.X, size.Y + 15);
                        Drawing.DrawRect(startPos,
                                         size,
                                         Textures.GetTexture(texturename));
                        string  ultimateCd;
                        Vector2 textSize;
                        Vector2 textPos;

                        switch (ultimate.AbilityState)
                        {
                        case AbilityState.OnCooldown:
                            ultimateCd =
                                ((int)Math.Min(cooldown, 999)).ToString(CultureInfo.InvariantCulture);
                            textSize = Drawing.MeasureText(ultimateCd, "Arial",
                                                           new Vector2((float)(size.Y * .50), size.Y / 2), FontFlags.AntiAlias);
                            //Print(v.Name + " cd: " + ultimateCd);
                            textPos = startPos + new Vector2(0, size.Y - textSize.Y);
                            Drawing.DrawRect(textPos - new Vector2(0, 0),
                                             new Vector2(textSize.X, textSize.Y),
                                             new Color(0, 0, 0, 200));
                            Drawing.DrawText(
                                ultimateCd,
                                textPos,
                                new Vector2(textSize.Y, 0),
                                Color.White,
                                FontFlags.AntiAlias | FontFlags.StrikeOut);
                            if (Members.Menu.Item("ultimate.Icon.Extra.Enable").GetValue <bool>() &&
                                ultimate.ManaCost > v.Mana)
                            {
                                ultimateCd =
                                    ((int)Math.Min(Math.Abs(v.Mana - ultimate.ManaCost), 999)).ToString(
                                        CultureInfo.InvariantCulture);
                                textSize = Drawing.MeasureText(ultimateCd, "Arial",
                                                               new Vector2((float)(size.Y * .50), size.Y / 2), FontFlags.AntiAlias);
                                textPos = startPos + new Vector2(size.X - textSize.X, 0);
                                Drawing.DrawRect(textPos - new Vector2(0, 0),
                                                 new Vector2(textSize.X, textSize.Y),
                                                 new Color(0, 0, 0, 200));
                                Drawing.DrawText(
                                    ultimateCd,
                                    textPos,
                                    new Vector2(textSize.Y, 0),
                                    Color.White,
                                    FontFlags.AntiAlias | FontFlags.StrikeOut);
                                Drawing.DrawRect(startPos,
                                                 new Vector2(size.X, size.Y),
                                                 new Color(0, 50, 155, 100));
                            }
                            break;

                        case AbilityState.NotEnoughMana:
                            ultimateCd =
                                ((int)Math.Min(Math.Abs(v.Mana - ultimate.ManaCost), 999)).ToString(
                                    CultureInfo.InvariantCulture);
                            textSize = Drawing.MeasureText(ultimateCd, "Arial",
                                                           new Vector2((float)(size.Y * .50), size.Y / 2), FontFlags.AntiAlias);
                            textPos = startPos + new Vector2(size.X - textSize.X, 0);
                            Drawing.DrawRect(textPos - new Vector2(0, 0),
                                             new Vector2(textSize.X, textSize.Y),
                                             new Color(0, 0, 0, 200));
                            Drawing.DrawText(
                                ultimateCd,
                                textPos,
                                new Vector2(textSize.Y, 0),
                                Color.White,
                                FontFlags.AntiAlias | FontFlags.StrikeOut);
                            Drawing.DrawRect(startPos,
                                             new Vector2(size.X, size.Y),
                                             new Color(0, 50, 155, 100));
                            break;
                        }
                    }
                    else if (ultimate.AbilityState == AbilityState.OnCooldown)
                    {
                        pos = Helper.GetTopPanelPosition(v) +
                              new Vector2(Members.Menu.Item("extraPos.X").GetValue <Slider>().Value,
                                          Members.Menu.Item("extraPos.Y").GetValue <Slider>().Value);
                        var startPos  = pos + new Vector2(0, 7 * 4 + size.Y);
                        var cd        = cooldown;
                        var manaDelta = new Vector2(cd * size.X / ultimate.CooldownLength, 0);
                        //size = new Vector2(manaDelta.X, 7);
                        DrawUltimatePanel(startPos, size, manaDelta, (int)cd,
                                          Members.Menu.Item("ultimate.Line.Size").GetValue <Slider>().Value);

                        /*Drawing.DrawRect(startPos,
                         *  size, Color.Yellow);*/
                    }
                }
                catch (Exception)
                {
                    Printer.Print("[DrawTopPanel:ultimate] " + v.StoredName() + " Type: " + type);
                }
            }
        }
예제 #5
0
        private static void Drawing_OnEndScene(EventArgs args)
        {
            try
            {
                if (!Checker.IsActive())
                {
                    return;
                }
                if (!Members.Menu.Item("odp.Enable").GetValue <bool>())
                {
                    return;
                }
            }
            catch (Exception)
            {
                // ignored
            }

            if (Drawing.Direct3DDevice9 == null || Drawing.Direct3DDevice9.IsDisposed)
            {
                return;
            }
            if (Check)
            {
                var newlist = PlayerInfoList.ToList();
                foreach (var playerInfo in newlist)
                {
                    var id             = playerInfo.Id;
                    var startXPosition = HeroPickStageScreenHelper.GetPlayerPosition(id);
                    var position       = new Vector2(startXPosition, 35);
                    var size           = HudInfoNew.GetTopPanelSizeY();
                    position += new Vector2(0, (float)size * 1.8f);
                    var defClr = Color.White;
                    DrawShadowText(playerInfo.Name, (int)position.X, (int)position.Y, defClr);
                    position.Y += 15;
                    DrawShadowText(playerInfo.Wr, (int)position.X, (int)position.Y, defClr);
                    position.Y += 15;
                    DrawShadowText(
                        playerInfo.Solo == 0 ? $"Estimated: {playerInfo.PossibleMmr}" : $"Solo: {playerInfo.Solo}",
                        (int)position.X, (int)position.Y, defClr);
                    if (playerInfo.Party > 0)
                    {
                        position.Y += 15;
                        DrawShadowText($"Party: {playerInfo.Party}", (int)position.X, (int)position.Y, defClr);
                    }
                    var gameHistorySize = playerInfo.Matches.Length - 2;
                    if (gameHistorySize >= 1)
                    {
                        position.Y += 15;
                        for (var i = 0; i < gameHistorySize; i++)
                        {
                            var isTrue = playerInfo.Matches[i + 1] == '+';
                            var clr    = isTrue ? Color.Green : Color.Red;
                            position.X += 10;
                            var text = '⬤';//●
                            DrawShadowText($"{text}", (int)position.X, (int)position.Y, clr);
                        }
                    }
                    if (playerInfo.Country.Length > 0)
                    {
                        try
                        {
                            var n = Convert.ToInt32(playerInfo.Country);
                            if (n > 0)
                            {
                                position.Y += 15;
                                DrawShadowText($"[{playerInfo.Country}]", (int)position.X, (int)position.Y, defClr);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                    if (playerInfo.TotalGames.Length > 0)
                    {
                        try
                        {
                            var n = Convert.ToInt32(playerInfo.TotalGames);
                            if (n == 0)
                            {
                                continue;
                            }
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                        var totalGames = Convert.ToInt32(playerInfo.TotalGames);
                        var wins       = Convert.ToInt32(playerInfo.Wins);
                        var loses      = totalGames - wins;
                        var wr         = playerInfo.WrOnCurrentHero;
                        position.Y += 15;
                        position.X  = startXPosition;
                        DrawShadowText($"[{playerInfo.Hero?.GetRealName()}: {wins}/{loses} ({wr}%)]", (int)position.X, (int)position.Y, defClr);
                    }
                }
            }
        }