Esempio n. 1
0
 public XpRatePlugin(GameController gameController, Graphics graphics, XpRateSettings settings, SettingsHub settingsHub)
     : base(gameController, graphics, settings)
 {
     this.settingsHub = settingsHub;
     GameController.Area.OnAreaChange += area => AreaChange();
 }
Esempio n. 2
0
        public override void Render()
        {
            try
            {
                if (!holdKey && WinApi.IsKeyDown(Keys.F10))
                {
                    holdKey = true;
                    Settings.Enable.Value = !Settings.Enable.Value;
                    SettingsHub.Save(settingsHub);
                }
                else if (holdKey && !WinApi.IsKeyDown(Keys.F10))
                {
                    holdKey = false;
                }
                if (!Settings.Enable)
                {
                    return;
                }

                DateTime nowTime     = DateTime.Now;
                TimeSpan elapsedTime = nowTime - lastTime;
                if (elapsedTime.TotalSeconds > 1)
                {
                    CalculateXp(nowTime);
                    partyXpPenalty = PartyXpPenalty();
                    lastTime       = nowTime;
                }

                bool showInTown =
                    !Settings.ShowInTown && GameController.Area.CurrentArea.IsTown ||
                    !Settings.ShowInTown && GameController.Area.CurrentArea.IsHideout;
                Vector2 position      = StartDrawPointFunc();
                string  fps           = $"fps:({GameController.Game.IngameState.CurFps})";
                string  areaName      = $"{GameController.Area.CurrentArea.DisplayName}";
                Color   AreaNameColor = PreloadAlertPlugin.AreaNameColor;

                if (Settings.OnlyAreaName)
                {
                    if (!showInTown)
                    {
                        var    areaNameSize = Graphics.MeasureText(areaName, Settings.TextSize);
                        float  boxHeight    = areaNameSize.Height;
                        float  boxWidth     = MathHepler.Max(areaNameSize.Width);
                        var    bounds       = new RectangleF(position.X - 84 - boxWidth, position.Y - 5, boxWidth + 90, boxHeight + 12);
                        string latency      = $"({GameController.Game.IngameState.CurLatency})";
                        Graphics.DrawText(areaName, Settings.TextSize, new Vector2(bounds.X + 84, position.Y), AreaNameColor);
                        Graphics.DrawImage("preload-start.png", bounds, Settings.BackgroundColor);
                        Graphics.DrawImage("preload-end.png", bounds, Settings.BackgroundColor);
                        if (Settings.ShowLatency)
                        {
                            Graphics.DrawText(latency, Settings.TextSize, new Vector2(bounds.X + 35, position.Y), Settings.LatencyTextColor);
                        }
                        Size   = bounds.Size;
                        Margin = new Vector2(0, 5);
                    }
                }

                if (!Settings.OnlyAreaName)
                {
                    if (!showInTown)
                    {
                        var     xpReceiving     = levelXpPenalty * partyXpPenalty;
                        var     xpReceivingText = $"{xpRate}  *{xpReceiving:p0}";
                        string  ping            = $"ping:({GameController.Game.IngameState.CurLatency})";
                        Size2   areaNameSize    = Graphics.DrawText(areaName, Settings.TextSize, position - 1, AreaNameColor, FontDrawFlags.Right);
                        Vector2 secondLine      = position.Translate(-1, areaNameSize.Height + 2);
                        Size2   xpRateSize      = Graphics.DrawText(timeLeft, Settings.TextSize, secondLine, Settings.TimeLeftColor, FontDrawFlags.Right);
                        Vector2 thirdLine       = secondLine.Translate(-1, xpRateSize.Height + 2);
                        Size2   xpLeftSize      = Graphics.DrawText(xpReceivingText, Settings.TextSize, thirdLine, Settings.TimeLeftColor, FontDrawFlags.Right);
                        string  timer           = AreaInstance.GetTimeString(nowTime - GameController.Area.CurrentArea.TimeEntered);
                        Size2   timerSize       = Graphics.MeasureText(timer, Settings.TextSize);

                        float boxWidth  = MathHepler.Max(xpRateSize.Width + 40, xpLeftSize.Width + 40, areaNameSize.Width + 20, timerSize.Width);
                        float boxHeight = xpRateSize.Height + xpLeftSize.Height + areaNameSize.Height;
                        var   bounds    = new RectangleF(position.X - boxWidth - 104, position.Y - 7, boxWidth + 110, boxHeight + 18);

                        Size2 timeFpsSize = Graphics.MeasureText(fps, Settings.TextSize);
                        var   dif         = bounds.Width - (12 + timeFpsSize.Width + xpRateSize.Width);
                        if (dif < 0)
                        {
                            bounds.X += dif; bounds.Width -= dif;
                        }

                        Graphics.DrawText(timer, Settings.TextSize, new Vector2(bounds.X + 70, position.Y), Settings.TimerTextColor);
                        Graphics.DrawText(fps, Settings.TextSize, new Vector2(bounds.X + 70, secondLine.Y), Settings.FpsTextColor);
                        Graphics.DrawText(ping, Settings.TextSize, new Vector2(bounds.X + 70, thirdLine.Y), Settings.LatencyTextColor);
                        Graphics.DrawImage("preload-start.png", bounds, Settings.BackgroundColor);
                        Graphics.DrawImage("preload-end.png", bounds, Settings.BackgroundColor);
                        Size   = bounds.Size;
                        Margin = new Vector2(0, 5);
                    }
                }
            }
            catch
            {
                // do nothing
            }
        }
Esempio n. 3
0
 public PreloadAlertPlugin(GameController gameController, Graphics graphics, PreloadAlertSettings settings, SettingsHub settingsHub)
     : base(gameController, graphics, settings)
 {
     this.settingsHub = settingsHub;
     alerts           = new HashSet <PreloadConfigLine>();
     alertStrings     = LoadConfig("config/preload_alerts.txt");
     GameController.Area.OnAreaChange += OnAreaChange;
     AreaNameColor = Settings.AreaTextColor;
 }
Esempio n. 4
0
 public DebugPlugin(GameController gameController, Graphics graphics, DebugPluginSettings settings, SettingsHub settingsHub)
     : base(gameController, graphics, settings)
 {
     _settingsHub = settingsHub;
 }
 public AdvancedTooltipPlugin(GameController gameController, Graphics graphics, AdvancedTooltipSettings settings, SettingsHub settingsHub)
     : base(gameController, graphics, settings)
 {
     this.settingsHub = settingsHub;
 }
Esempio n. 6
0
 private void OnClosing(object sender, FormClosingEventArgs e)
 {
     SettingsHub.Save(settings);
     plugins.ForEach(plugin => plugin.Dispose());
     graphics.Dispose();
 }
Esempio n. 7
0
        public override void Render()
        {
            try
            {
                if (!holdKey && WinApi.IsKeyDown(Keys.F9))
                {
                    holdKey = true;
                    Settings.ItemMods.Enable.Value = !Settings.ItemMods.Enable.Value;
                    if (!Settings.ItemMods.Enable.Value)
                    {
                        SettingsHub.Save(settingsHub);
                    }
                }
                else if (holdKey && !WinApi.IsKeyDown(Keys.F9))
                {
                    holdKey = false;
                }
                Element uiHover           = GameController.Game.IngameState.UIHover;
                var     inventoryItemIcon = uiHover.AsObject <HoverItemIcon>();

                Element tooltip   = inventoryItemIcon.Tooltip;
                Entity  poeEntity = inventoryItemIcon.Item;

                if (tooltip == null || poeEntity.Address == 0 || !poeEntity.IsValid)
                {
                    return;
                }
                RectangleF tooltipRect = tooltip.GetClientRect();



                var  modsComponent = poeEntity.GetComponent <Mods>();
                long id            = 0;
                if (inventoryItemIcon.ToolTipType == ToolTipType.InventoryItem)
                {
                    id = poeEntity.InventoryId;
                }
                else
                {
                    id = poeEntity.Id;
                }

                if (itemEntity == null || itemEntity.Id != id)
                {
                    List <ItemMod> itemMods = modsComponent.ItemMods;
                    mods = itemMods.Select(item => new ModValue(item, GameController.Files, modsComponent.ItemLevel,
                                                                GameController.Files.BaseItemTypes.Translate(poeEntity.Path))).ToList();
                    itemEntity = poeEntity;
                }

                int t1 = 0;
                foreach (string tier in from item in mods where item.CouldHaveTiers() && item.Tier == 1 select " \u2605 ")
                {
                    Graphics.DrawText(tier, 18, tooltipRect.TopLeft.Translate(0 + 14 * t1++, 56), Settings.ItemMods.T1Color);
                }

                int t2 = 0;
                foreach (string tier in from item in mods where item.CouldHaveTiers() && item.Tier == 2 select " \u2605 ")
                {
                    Graphics.DrawText(tier, 18, tooltipRect.TopLeft.Translate(t1 * 14 + 14 * t2++, 56), Settings.ItemMods.T2Color);
                }

                if (Settings.ItemLevel.Enable)
                {
                    string itemLevel = Convert.ToString(modsComponent.ItemLevel);
                    var    imageSize = Settings.ItemLevel.TextSize + 10;
                    Graphics.DrawText(itemLevel, Settings.ItemLevel.TextSize, tooltipRect.TopLeft.Translate(2, 2), Settings.ItemLevel.TextColor);
                    Graphics.DrawImage("menu-colors.png", new RectangleF(tooltipRect.TopLeft.X - 2, tooltipRect.TopLeft.Y - 2, imageSize, imageSize), Settings.ItemLevel.BackgroundColor);
                }

                if (Settings.ItemMods.Enable)
                {
                    float bottomTooltip = tooltipRect.Bottom + 5;
                    var   modPosition   = new Vector2(tooltipRect.X + 50, bottomTooltip + 4);
                    float height        = mods.Aggregate(modPosition, (position, item) => DrawMod(item, position)).Y - bottomTooltip;
                    if (height > 4)
                    {
                        var modsRect = new RectangleF(tooltipRect.X + 1, bottomTooltip, tooltipRect.Width, height);
                        Graphics.DrawBox(modsRect, Settings.ItemMods.BackgroundColor);
                    }
                }

                if (Settings.WeaponDps.Enable && poeEntity.HasComponent <Weapon>())
                {
                    DrawWeaponDps(tooltipRect);
                }
            }
            catch
            { }
        }
Esempio n. 8
0
        public override void Render()
        {
            if (!holdKey && WinApi.IsKeyDown(Keys.F9))
            {
                holdKey = true;
                Settings.ItemMods.Enable.Value = !Settings.ItemMods.Enable.Value;
                if (!Settings.ItemMods.Enable.Value)
                {
                    SettingsHub.Save(settingsHub);
                }
            }
            else if (holdKey && !WinApi.IsKeyDown(Keys.F9))
            {
                holdKey = false;
            }

            if (!Settings.Enable)
            {
                return;
            }

            Element uiHover           = GameController.Game.IngameState.UIHover;
            var     inventoryItemIcon = uiHover.AsObject <InventoryItemIcon>();
            Element tooltip           = GetTooltip(inventoryItemIcon);
            Entity  poeEntity         = inventoryItemIcon.Item;

            if (tooltip == null || poeEntity.Address == 0 || !poeEntity.IsValid)
            {
                return;
            }

            RectangleF tooltipRect   = tooltip.GetClientRect();
            var        modsComponent = poeEntity.GetComponent <Mods>();

            if (itemEntity == null || itemEntity.Id != poeEntity.Id)
            {
                List <ItemMod> itemMods = modsComponent.ItemMods;
                mods       = itemMods.Select(item => new ModValue(item, GameController.Files, modsComponent.ItemLevel)).ToList();
                itemEntity = poeEntity;
            }

            if (Settings.ItemLevel.Enable)
            {
                string itemLevel = Convert.ToString(modsComponent.ItemLevel);
                Graphics.DrawText(itemLevel, Settings.ItemLevel.TextSize, tooltipRect.TopLeft.Translate(1, -3), Color.Yellow);
            }

            if (Settings.ItemMods.Enable)
            {
                float bottomTooltip = tooltipRect.Bottom + 5;
                var   modPosition   = new Vector2(tooltipRect.X + 50, bottomTooltip + 4);
                float height        = mods.Aggregate(modPosition, (position, item) => DrawMod(item, position)).Y - bottomTooltip;
                if (height > 4)
                {
                    var modsRect = new RectangleF(tooltipRect.X + 1, bottomTooltip, tooltipRect.Width, height);
                    Graphics.DrawBox(modsRect, Settings.ItemMods.BackgroundColor);
                }
            }

            if (Settings.WeaponDps.Enable && poeEntity.HasComponent <Weapon>())
            {
                DrawWeaponDps(tooltipRect);
            }
        }
Esempio n. 9
0
 public ItemAlertPlugin(GameController gameController, Graphics graphics, ItemAlertSettings settings, SettingsHub settingsHub)
     : base(gameController, graphics, settings)
 {
     this.settingsHub  = settingsHub;
     playedSoundsCache = new HashSet <long>();
     currentAlerts     = new Dictionary <EntityWrapper, AlertDrawStyle>();
     currentLabels     = new Dictionary <long, LabelOnGround>();
     currencyNames     = LoadCurrency();
     craftingBases     = LoadCraftingBases();
     GameController.Area.OnAreaChange += OnAreaChange;
     PoeFilterInit(settings.FilePath);
     settings.FilePath.OnFileChanged += () => PoeFilterInit(settings.FilePath);
 }
Esempio n. 10
0
        public override void Render()
        {
            if (!holdKey && WinApi.IsKeyDown(Keys.F10))
            {
                holdKey = true;
                Settings.Enable.Value = !Settings.Enable.Value;
                SettingsHub.Save(settingsHub);
            }
            else if (holdKey && !WinApi.IsKeyDown(Keys.F10))
            {
                holdKey = false;
            }
            if (!Settings.Enable)
            {
                return;
            }

            if (Settings.Enable)
            {
                var pos = GameController.Player.GetComponent <Positioned>();

                var       playerPos     = pos.GridPos;
                var       position      = StartDrawPointFunc();
                const int BOTTOM_MARGIN = 2;
                var       shouldUpdate  = false;

                var validAlerts = currentAlerts.ToList().Where(
                    x => x.Key != null && x.Key.Address != 0 && x.Key.IsValid);

                foreach (KeyValuePair <EntityWrapper, AlertDrawStyle> kv in validAlerts)
                {
                    if (string.IsNullOrEmpty(kv.Value.Text))
                    {
                        continue;
                    }

                    LabelOnGround entityLabel;
                    if (!currentLabels.TryGetValue(kv.Key.Address, out entityLabel))
                    {
                        shouldUpdate = true;
                    }
                    else
                    {
                        if (Settings.BorderSettings.Enable)
                        {
                            DrawBorder(entityLabel);
                        }

                        if (Settings.ShowText)
                        {
                            if (entityLabel.CanPickUp || entityLabel.MaxTimeForPickUp.TotalSeconds == 0)
                            {
                                position = DrawText(playerPos, position, BOTTOM_MARGIN, kv, kv.Value.Text);
                            }
                            else if (!Settings.HideOthers)
                            {
                                // get current values
                                Color TextColor       = kv.Value.TextColor;
                                Color BorderColor     = kv.Value.BorderColor;
                                Color BackgroundColor = kv.Value.BackgroundColor;

                                if (Settings.DimOtherByPercentToggle)
                                {
                                    // edit values to new ones
                                    double ReduceByPercent = (double)Settings.DimOtherByPercent / 100;

                                    TextColor       = ReduceNumbers(TextColor, ReduceByPercent);
                                    BorderColor     = ReduceNumbers(BorderColor, ReduceByPercent);
                                    BackgroundColor = ReduceNumbers(BackgroundColor, ReduceByPercent);

                                    // backgrounds with low alpha start to look a little strange when dark so im adding an alpha threshold
                                    if (BackgroundColor.A < 210)
                                    {
                                        BackgroundColor.A = 210;
                                    }
                                }

                                // Complete new KeyValuePair with new stuff
                                AlertDrawStyle ModifiedDrawStyle = new AlertDrawStyle(kv.Value.Text, TextColor, kv.Value.BorderWidth, BorderColor, BackgroundColor, kv.Value.IconIndex);
                                KeyValuePair <EntityWrapper, AlertDrawStyle> NewKV = new KeyValuePair <EntityWrapper, AlertDrawStyle>(kv.Key, ModifiedDrawStyle);

                                position = DrawText(playerPos, position, BOTTOM_MARGIN, NewKV, kv.Value.Text);
                            }
                        }
                    }
                }
                Size = new Size2F(0, position.Y); //bug absent width

                if (shouldUpdate)
                {
                    currentLabels = GameController.Game.IngameState.IngameUi.ItemsOnGroundLabels
                                    .GroupBy(y => y.ItemOnGround.Address).ToDictionary(y => y.Key, y => y.First());
                }
            }
        }
Esempio n. 11
0
        public MainMenuWindow(CoreSettings settings, SettingsHub settingsHub)
        {
            Settings    = settings;
            SettingsHub = settingsHub;
            Instance    = this;

            //https://stackoverflow.com/questions/826777/how-to-have-an-auto-incrementing-version-number-visual-studio
            Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            //DateTime buildDate = new DateTime(2000, 1, 1).AddDays(version.Build).AddSeconds(version.Revision * 2);
            PoeHUDVersion = $"v{version.Major}.{version.Minor}.{version.Build}";

            if (Settings.MenuWindowSize == ImGuiVector2.Zero)
            {
                Settings.MenuWindowSize  = new ImGuiVector2(500, 800);
                Settings.MenuWindowPos.X = GameController.Instance.Window.GetWindowRectangle().X - Settings.MenuWindowSize.X / 2;
            }

            CoreMenu = new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Core", settingsHub.MenuSettings)
            };
            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Health bars", settingsHub.HealthBarSettings),
                Childs = new List <InbuildPluginMenu>()
                {
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Players", settingsHub.HealthBarSettings.Players)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Minions", settingsHub.HealthBarSettings.Minions)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("NormalEnemy", settingsHub.HealthBarSettings.NormalEnemy)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("MagicEnemy", settingsHub.HealthBarSettings.MagicEnemy)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("RareEnemy", settingsHub.HealthBarSettings.RareEnemy)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("UniqueEnemy", settingsHub.HealthBarSettings.UniqueEnemy)
                    },
                }
            });

            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Advanced Tooltip", settingsHub.AdvancedTooltipSettings),
                Childs = new List <InbuildPluginMenu>()
                {
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Item level", settingsHub.AdvancedTooltipSettings.ItemLevel)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Item mods", settingsHub.AdvancedTooltipSettings.ItemMods)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Weapon Dps", settingsHub.AdvancedTooltipSettings.WeaponDps)
                    },
                }
            });

            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Item alert", settingsHub.ItemAlertSettings),
                Childs = new List <InbuildPluginMenu>()
                {
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Border Settings", settingsHub.ItemAlertSettings.BorderSettings)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Quality Armour Settings", settingsHub.ItemAlertSettings.QualityItems.Armour)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Quality Flask", settingsHub.ItemAlertSettings.QualityItems.Flask)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Quality SkillGem", settingsHub.ItemAlertSettings.QualityItems.SkillGem)
                    },
                    new InbuildPluginMenu()
                    {
                        Plugin = new PluginHolder("Quality Weapon", settingsHub.ItemAlertSettings.QualityItems.Weapon)
                    }
                }
            });

            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Xph & area", settingsHub.XpRateSettings)
            });
            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Preload alert", settingsHub.PreloadAlertSettings)
            });
            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Monster alert", settingsHub.MonsterTrackerSettings)
            });
            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Monster kills", settingsHub.KillCounterSettings)
            });
            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Show dps", settingsHub.DpsMeterSettings)
            });
            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Map Icons", settingsHub.MapIconsSettings)
            });
            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Map Icons Size", settingsHub.PoiTrackerSettings)
            });
            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = new PluginHolder("Perfomance", settingsHub.PerformanceSettings)
            });



            var themeEditorDraw = new ThemeEditor();

            themeEditorDraw.CanBeEnabledInOptions = false;
            CoreMenu.Childs.Add(new InbuildPluginMenu()
            {
                Plugin = themeEditorDraw
            });
        }
Esempio n. 12
0
        public override void Render()
        {
            if (Settings.ReloadButton.PressedOnce()) // do a full refresh if F5 is hit
            {
                DebugPlug.DebugPlugin.LogMsg("Looking for new preloads.", 1);
                ResetArea();
                Parse();
            }

            var UIHover = GameController.Game.IngameState.UIHover;
            var miniMap = GameController.Game.IngameState.IngameUi.Map.SmallMinimap;

            if (Settings.Enable.Value && UIHover.Address != 0x00 && UIHover.Tooltip.Address != 0x00 &&
                UIHover.Tooltip.IsVisible && UIHover.Tooltip.GetClientRect().Intersects(miniMap.GetClientRect()))
            {
                autoHide = true;
                Settings.Enable.Value = false;
            }
            if (autoHide && (UIHover.Address == 0x00 || UIHover.Tooltip.Address == 0x00 ||
                             !UIHover.Tooltip.IsVisible))
            {
                autoHide = false;
                Settings.Enable.Value = true;
            }

            if (!holdKey && WinApi.IsKeyDown(Keys.F10))
            {
                holdKey = true;
                Settings.Enable.Value = !Settings.Enable.Value;
                SettingsHub.Save(settingsHub);
            }
            else if (holdKey && !WinApi.IsKeyDown(Keys.F10))
            {
                holdKey = false;
            }
            if (!Settings.Enable || GameController.Area.CurrentArea.IsTown)
            {
                Size = new Size2F();
                return;
            }

            if (alerts.Count <= 0)
            {
                Size = new Size2F();
                return;
            }

            /* if (isAreaChanged)
             * {
             *   ResetArea();
             *   Parse();
             *   isAreaChanged = false;
             * }*/
            Vector2 startPosition = StartDrawPointFunc();
            Vector2 position      = startPosition;
            int     maxWidth      = 0;

            foreach (Size2 size in alerts
                     .Select(preloadConfigLine => Graphics
                             .DrawText(preloadConfigLine.Text, Settings.TextSize, position, preloadConfigLine.FastColor?
                                       .Invoke() ?? preloadConfigLine.Color ?? Settings.DefaultTextColor, FontDrawFlags.Right)))
            {
                maxWidth    = Math.Max(size.Width, maxWidth);
                position.Y += size.Height;
            }
            if (maxWidth <= 0)
            {
                return;
            }
            var bounds = new RectangleF(startPosition.X - maxWidth - 45, startPosition.Y - 5,
                                        maxWidth + 50, position.Y - startPosition.Y + 10);

            Graphics.DrawImage("preload-start.png", bounds, Settings.BackgroundColor);
            Graphics.DrawImage("preload-end.png", bounds, Settings.BackgroundColor);
            Size   = bounds.Size;
            Margin = new Vector2(0, 5);
        }
Esempio n. 13
0
        public PreloadAlertPlugin(GameController gameController, Graphics graphics, PreloadAlertSettings settings, SettingsHub settingsHub)
            : base(gameController, graphics, settings)
        {
            this.settingsHub = settingsHub;
            alerts           = new HashSet <PreloadConfigLine>();
            alertStrings     = LoadConfig(PRELOAD_ALERTS);

            if (File.Exists(PRELOAD_ALERTS_PERSONAL))
            {
                alertStrings = alertStrings.MergeLeft(LoadConfig(PRELOAD_ALERTS_PERSONAL));
            }
            else
            {
                File.WriteAllText(PRELOAD_ALERTS_PERSONAL, string.Empty);
            }

            GameController.Area.AreaChange += OnAreaChange;
            AreaNameColor = Settings.AreaTextColor;
            SetupPredefinedConfigs();
        }
Esempio n. 14
0
        public override void Render()
        {
            if (!holdKey && WinApi.IsKeyDown(Keys.F10))
            {
                holdKey = true;
                Settings.Enable.Value = !Settings.Enable.Value;
                SettingsHub.Save(settingsHub);
            }
            else if (holdKey && !WinApi.IsKeyDown(Keys.F10))
            {
                holdKey = false;
            }
            if (!Settings.Enable)
            {
                return;
            }

            if (Settings.Enable)
            {
                Positioned pos = GameController.Player.GetComponent <Positioned>();
                if (pos == null)
                {
                    return;
                }
                Vector2   playerPos     = pos.GridPos;
                Vector2   position      = StartDrawPointFunc();
                const int BOTTOM_MARGIN = 2;
                bool      shouldUpdate  = false;

                if (Settings.BorderSettings.Enable)
                {
                    Dictionary <EntityWrapper, AlertDrawStyle> tempCopy = new Dictionary <EntityWrapper, AlertDrawStyle>(currentAlerts);
                    var keyValuePairs = tempCopy.AsParallel().Where(x => x.Key != null && x.Key.Address != 0 && x.Key.IsValid).ToList();
                    foreach (var kv in keyValuePairs)
                    {
                        if (DrawBorder(kv.Key.Address) && !shouldUpdate)
                        {
                            shouldUpdate = true;
                        }
                    }
                }

                foreach (KeyValuePair <EntityWrapper, AlertDrawStyle> kv in currentAlerts.Where(x => x.Key != null && x.Key.Address != 0 && x.Key.IsValid))
                {
                    string text = GetItemName(kv);
                    if (text == null)
                    {
                        continue;
                    }

                    ItemsOnGroundLabelElement entityLabel;
                    if (!currentLabels.TryGetValue(kv.Key.Address, out entityLabel))
                    {
                        shouldUpdate = true;
                    }
                    else
                    {
                        if (Settings.ShowText) // && (!Settings.HideOthers || entityLabel.CanPickUp || entityLabel.MaxTimeForPickUp.TotalSeconds == 0))
                        {
                            position = DrawText(playerPos, position, BOTTOM_MARGIN, kv, text);
                        }
                    }
                }
                Size = new Size2F(0, position.Y); //bug absent width

                if (shouldUpdate)
                {
                    currentLabels = GameController.Game.IngameState.IngameUi.ItemsOnGroundLabels
                                    .GroupBy(y => y.ItemOnGround.Address).ToDictionary(y => y.Key, y => y.First());
                }
            }
        }
Esempio n. 15
0
        private void KeyboardMouseEvents_KeyDown(object sender, KeyEventArgs e)
        {
            if (isPoeGameVisible)
            {
                if (HandleForKeySelector)
                {
                    HandledForKeySelectorKey = e.KeyCode;
                    e.Handled            = true;
                    HandleForKeySelector = false;
                    return;
                }

                if (e.KeyCode == Settings.MainMenuKeyToggle)
                {
                    Settings.Enable.Value = !Settings.Enable.Value;
                    SettingsHub.Save(settingsHub);
                    e.Handled = true;
                }
                if (Settings.Enable.Value)
                {
                    if (Settings.CloseOnEsc.Value && e.KeyCode == Keys.Escape)
                    {
                        Settings.Enable.Value = !Settings.Enable.Value;
                        e.Handled             = true;
                        return;
                    }
                    if (Settings.CloseOnSpace.Value && e.KeyCode == Keys.Space)
                    {
                        Settings.Enable.Value = !Settings.Enable.Value;
                        e.Handled             = true;
                        return;
                    }
                }
            }

            var io = ImGui.GetIO();

            io.CtrlPressed = e.Control || e.KeyCode == Keys.LControlKey || e.KeyCode == Keys.RControlKey;
            // Don't know why but Alt is LMenu/RMenu
            io.AltPressed   = e.Alt || e.KeyCode == Keys.LMenu || e.KeyCode == Keys.RMenu;
            io.ShiftPressed = e.Shift || e.KeyCode == Keys.LShiftKey || e.KeyCode == Keys.RShiftKey;

            if (io.AltPressed)
            {
                return;
            }

            unsafe
            {
                if (ImGuiWantTextInput(io))
                {
                    io.KeysDown[e.KeyValue] = true;
                    if (e.KeyCode != Keys.Capital &&
                        e.KeyCode != Keys.LShiftKey && e.KeyCode != Keys.RShiftKey &&
                        e.KeyCode != Keys.LControlKey && e.KeyCode != Keys.RControlKey &&
                        e.KeyCode != Keys.LWin && e.KeyCode != Keys.Apps)
                    {
                        e.Handled = true;
                    }
                }
            }
        }