Esempio n. 1
0
        public void DrawInsideImage(Buff.Base baseInfo, string displayText, RectangleF imageRec)
        {
            // TODO: Fix this issue
            // Bandaid fix for int.MaxValue problem from permanent duration buffs
            if (displayText == "-2147483648" || displayText == "2147483648")
            {
                displayText = "∞";
            }

            var textSize         = InnerToBuffSize(baseInfo.Settings.Size);
            var measureText      = Graphics.MeasureText(displayText, textSize);
            var minimumTextWidth = Graphics.MeasureText("00", textSize).Width;

            if (measureText.Width < minimumTextWidth) // set a minim box size of 2 characters
            {
                measureText.Width = minimumTextWidth;
            }
            var newBox   = new RectangleF(imageRec.X, imageRec.Y, measureText.Width * 1.07f, measureText.Height * 1.02f);
            var position = new Vector2(newBox.Center.X, newBox.Center.Y);

            Graphics.DrawText(displayText, textSize, position, baseInfo.Settings.Colors.Text, FontDrawFlags.Center | FontDrawFlags.VerticalCenter);
            Graphics.DrawBox(newBox, baseInfo.Settings.Colors.TextBackground);
        }
Esempio n. 2
0
        public void DrawAboveImage(Buff.Base baseInfo, string displayText, RectangleF imageRec)
        {
            // TODO: Fix this issue
            // Bandaid fix for int.MaxValue problem from permanent duration buffs
            if (displayText == "-2147483648" || displayText == "2147483648")
            {
                displayText = "∞";
            }

            var textSize    = UpperBuffSize(baseInfo.Settings.Size);
            var measureText = Graphics.MeasureText(displayText, textSize);
            var newBox      = new RectangleF(imageRec.X, imageRec.Y, imageRec.Width, -measureText.Height);
            var position    = new Vector2(newBox.Center.X, newBox.Center.Y);

            if (baseInfo.Settings.Colors.Text.A > 0)
            {
                Graphics.DrawText(displayText, textSize, position, baseInfo.Settings.Colors.Text, FontDrawFlags.Center | FontDrawFlags.VerticalCenter);
            }
            if (baseInfo.Settings.Colors.TextBackground.A > 0)
            {
                Graphics.DrawBox(newBox, baseInfo.Settings.Colors.TextBackground);
            }
        }
Esempio n. 3
0
        public void DrawBuffIcon(Profile profile, Buff.Base buffToDraw)
        {
            var profilePath = $"{profile.ImageFolder}{buffToDraw.Settings.Image}.png";
            var backUpPath  = $@"{PluginDirectory}\images\{buffToDraw.Settings.Image}.png";
            var imageFile   = string.Empty;

            if (File.Exists(profilePath))
            {
                imageFile = profilePath;
            }
            if (imageFile == string.Empty && File.Exists(backUpPath))
            {
                imageFile = backUpPath;
            }

            if (imageFile == string.Empty)
            {
                return;
            }

            var readyImage = new RectangleF(buffToDraw.Settings.Location.X, buffToDraw.Settings.Location.Y, buffToDraw.Settings.Size, buffToDraw.Settings.Size);

            switch (buffToDraw.DisposableData.WasFound)
            {
            case true:

                switch (buffToDraw.Settings.ShowImage)
                {
                case true:
                    Graphics.DrawPluginImage(imageFile, readyImage);
                    break;

                case false:
                    break;
                }

                // Start the text drawing process
                switch (buffToDraw.Settings.Type)    // have seperate draw logic per type, more types can easily be added this way
                {
                case Buff.BuffType.Duration:         // Draw above the icon
                    DrawAboveImage(buffToDraw, buffToDraw.DisposableData.DurationData.DisplayText, readyImage);
                    break;

                case Buff.BuffType.Charge:         // Draw top left of the icon
                    DrawInsideImage(buffToDraw, buffToDraw.DisposableData.ChargeData.DisplayText, readyImage);
                    break;

                case Buff.BuffType.BuffCount:         // Draw top left of the icon
                    DrawInsideImage(buffToDraw, buffToDraw.DisposableData.BuffCountData.DisplayText, readyImage);
                    break;

                case Buff.BuffType.DurationAndCharge:
                    DrawAboveImage(buffToDraw, buffToDraw.DisposableData.DurationData.DisplayText, readyImage);
                    DrawInsideImage(buffToDraw, buffToDraw.DisposableData.ChargeData.DisplayText, readyImage);
                    break;

                case Buff.BuffType.DurationAndCount:
                    DrawAboveImage(buffToDraw, buffToDraw.DisposableData.DurationData.DisplayText, readyImage);
                    DrawInsideImage(buffToDraw, buffToDraw.DisposableData.BuffCountData.DisplayText, readyImage);
                    break;

                case Buff.BuffType.ImageOnly:
                    // Do nothing, we only want the image
                    break;
                }

                break;

            case false:
                // TODO: Learn how to change the images saturation to black & white
                // Define the image and draw it - INACTIVE

                switch (buffToDraw.Settings.ShowImage)
                {
                case true:
                    Graphics.DrawPluginImage($"{profile.ImageFolder}{buffToDraw.Settings.Image}.png", readyImage, new Color(255, 255, 255, 201));
                    Graphics.DrawBox(readyImage, new Color(0, 0, 0, 201));         // drawing a black box over the imagewith 201 transperency
                    break;

                case false:
                    break;
                }
                break;
            }
        }
Esempio n. 4
0
        public void DrawProfilesTable(Profile profile)
        {
            var buffsToRemove = new List <int>();

            ImGui.Separator();
            ImGui.Columns(8, $"EditColums{profile.Name}", true);
            ImGui.Text("Toggles");
            ImGuiExtension.ToolTip("Remove / Status / Show Inactive / Draw an Image", true);
            ImGui.NextColumn();
            ImGui.Text("Colors");
            ImGuiExtension.ToolTip("Text / Text Background", true);
            ImGui.NextColumn();
            ImGui.Text("Buff Name");
            ImGui.NextColumn();
            ImGui.Text("File Name");
            ImGui.NextColumn();
            ImGui.Text("Type");
            ImGui.NextColumn();
            ImGui.Text("Size");
            ImGui.NextColumn();
            ImGui.Text("X");
            ImGui.NextColumn();
            ImGui.Text("Y");
            ImGui.NextColumn();
            if (profile.BuffSettings.BuffList.Count != 0)
            {
                ImGui.Separator();
            }

            var typeSelector = new List <string>
            {
                "Duration",
                "Charge",
                "Count",
                "Duration + Charges",
                "Duration + Count",
                "Image Only"
            };

            for (var i = 0; i < profile.BuffSettings.BuffList.Count; i++)
            {
                // Remove / Status / Show Inactive
                if (ImGui.Button($"X##Delete{profile.Name}{i}"))
                {
                    buffsToRemove.Add(i);
                }
                ImGuiExtension.ToolTip("Remove This Buff", false, true);
                ImGui.SameLine();
                profile.BuffSettings.BuffList[i].Settings.Enabled = PoeHUD.Hud.UI.ImGuiExtension.Checkbox($"##Status{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.Enabled);
                ImGuiExtension.ToolTip("Enable This Buff", false, true);
                ImGui.SameLine();
                profile.BuffSettings.BuffList[i].Settings.ShowInactive = PoeHUD.Hud.UI.ImGuiExtension.Checkbox($"##ShowInactive{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.ShowInactive);
                ImGuiExtension.ToolTip("Show a dimmed verison if the buff is inactive", false, true);
                ImGui.SameLine();
                profile.BuffSettings.BuffList[i].Settings.ShowImage = PoeHUD.Hud.UI.ImGuiExtension.Checkbox($"##ShowImage{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.ShowImage);
                ImGuiExtension.ToolTip("Draw an Image", false, true);
                ImGui.NextColumn();
                // Colors - Text / Text Background
                profile.BuffSettings.BuffList[i].Settings.Colors.Text = PoeHUD.Hud.UI.ImGuiExtension.ColorPicker($"##TextColor{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.Colors.Text);
                ImGuiExtension.ToolTip("Text Color", false, true);
                ImGui.SameLine();
                profile.BuffSettings.BuffList[i].Settings.Colors.TextBackground = PoeHUD.Hud.UI.ImGuiExtension.ColorPicker($"##TextBackgroundColor{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.Colors.TextBackground);
                ImGuiExtension.ToolTip("Text Background Color", false, true);
                ImGui.NextColumn();
                // Buff Name
                ImGui.PushItemWidth(ImGui.GetContentRegionAvailableWidth());
                profile.BuffSettings.BuffList[i].Settings.BuffName = PoeHUD.Hud.UI.ImGuiExtension.InputText($"##BuffName{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.BuffName, 1000, InputTextFlags.EnterReturnsTrue);
                ImGui.PopItemWidth();
                ImGui.NextColumn();
                // Image File
                ImGui.PushItemWidth(ImGui.GetContentRegionAvailableWidth());
                profile.BuffSettings.BuffList[i].Settings.Image = PoeHUD.Hud.UI.ImGuiExtension.InputText($"##Image{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.Image, 1000, InputTextFlags.EnterReturnsTrue);
                ImGui.PopItemWidth();
                ImGui.NextColumn();
                // Buff Type
                ImGui.PushItemWidth(ImGui.GetContentRegionAvailableWidth());
                profile.BuffSettings.BuffList[i].Settings.Type = (Buff.BuffType)ImGuiExtension.ComboBox($"##Type{profile.Name}{i}", (int)profile.BuffSettings.BuffList[i].Settings.Type, typeSelector);
                ImGui.PopItemWidth();
                ImGui.NextColumn();
                // Buff Size
                ImGui.PushItemWidth(ImGui.GetContentRegionAvailableWidth());
                profile.BuffSettings.BuffList[i].Settings.Size = ImGuiExtension.IntDrag($"##Size{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.Size, 1, 300);
                ImGui.PopItemWidth();
                ImGui.NextColumn();
                // X Axis
                ImGui.PushItemWidth(ImGui.GetContentRegionAvailableWidth());
                profile.BuffSettings.BuffList[i].Settings.Location.X = ImGuiExtension.IntDrag($"##X{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.Location.X, 0, (int)GameController.Window.GetWindowRectangle().Width);
                ImGui.PopItemWidth();
                ImGui.NextColumn();
                // Y Axis
                ImGui.PushItemWidth(ImGui.GetContentRegionAvailableWidth());
                profile.BuffSettings.BuffList[i].Settings.Location.Y = ImGuiExtension.IntDrag($"##Y{profile.Name}{i}", profile.BuffSettings.BuffList[i].Settings.Location.Y, 0, (int)GameController.Window.GetWindowRectangle().Height);
                ImGui.PopItemWidth();
                ImGui.NextColumn();
            }

            // Remove items in deleteion queue
            foreach (var i in buffsToRemove)
            {
                profile.BuffSettings.BuffList.Remove(profile.BuffSettings.BuffList[i]);
            }

            ImGui.Separator();
            ImGui.Columns(1, "", false);

            // Make add new button
            if (ImGui.Button($"+##Add{profile.Name}"))
            {
                var newItem = new Buff.Base
                {
                    Settings = new Buff.Settings
                    {
                        Location = new Buff.Location {
                            X = 200, Y = 200
                        },
                        Size         = 64,
                        ShowInactive = false,
                        Image        = "Image",
                        BuffName     = "BuffName",
                        Type         = Buff.BuffType.Duration,
                        Enabled      = false,
                        Colors       = new Colors {
                            Text = Color.White, TextBackground = new Color(0, 0, 0, 220)
                        }
                    },
                    DisposableData = new Buff.DisposableData()
                };
                profile.BuffSettings.BuffList.Add(newItem);
            }
            ImGui.SameLine();
            if (ImGui.Button($"Save##{profile.Name}"))
            {
                SaveBuffSettings(profile);
            }
            ImGui.SameLine();
            if (ImGui.Button($"Reload##{profile.Name}"))
            {
                profile.BuffSettings = LoadBuffSettings(profile);
            }
            ImGui.Separator();
        }