コード例 #1
0
        public unsafe bool CustomTreeNode(string label)
        {
            var style   = ImGui.GetStyle();
            var storage = ImGui.GetStateStorage();

            uint  id     = ImGui.GetID(label);
            int   opened = storage.GetInt(id, 0);
            float x      = ImGui.GetCursorPosX();

            ImGui.BeginGroup();
            if (ImGui.InvisibleButton(label, new Vector2(-1, ImGui.GetFontSize() + style.FramePadding.Y * 2)))
            {
                opened = storage.GetInt(id, 0);
                //  opened = p_opened == p_opened;
            }
            bool hovered = ImGui.IsItemHovered();
            bool active  = ImGui.IsItemActive();

            if (hovered || active)
            {
                var col = ImGui.GetStyle().Colors[(int)(active ? ImGuiCol.HeaderActive : ImGuiCol.HeaderHovered)];
                ImGui.GetWindowDrawList().AddRectFilled(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), ImGui.ColorConvertFloat4ToU32(col));
            }
            ImGui.SameLine();
            ImGui.ColorButton("color_btn", opened == 1 ? new Vector4(1, 1, 1, 1) : new Vector4(1, 0, 0, 1));
            ImGui.SameLine();
            ImGui.Text(label);
            ImGui.EndGroup();
            if (opened == 1)
            {
                ImGui.TreePush(label);
            }
            return(opened != 0);
        }
コード例 #2
0
ファイル: PluginUI.cs プロジェクト: reiichi001/DiscordRelay
        public void DrawChatChannelEntry(int index)
        {
            this.currentEntry = this.configuration.ChatTypeConfigurations[index];
            ulong guildID = currentEntry.Channel.GuildId;
            // string guildIDInput = guildID.ToString();
            ulong channelID = currentEntry.Channel.ChannelId;

            Dalamud.Game.Chat.XivChatType type     = currentEntry.ChatType;
            Configuration.ChannelType     chanType = currentEntry.Channel.Type;


            // Making colors work is the worst shit.
            byte[] colorvals = BitConverter.GetBytes(currentEntry.Color);

            int red   = (int)(currentEntry.Color >> 16) & 0xFF;
            int green = (int)(currentEntry.Color >> 8) & 0xFF;
            int blue  = (int)currentEntry.Color & 0xFF;

            Vector4 colors = new Vector4(colorvals[2] / 255.0f, colorvals[1] / 255.0f, colorvals[0] / 255.0f, 1.0f);

            ImGui.Separator();

            //ImGui.PushStyleColor(ImGuiCol.Button, buttoncolor);
            //ImGui.ColorButton($"", buttoncolor);
            if (ImGui.ColorButton($"##colorpicker-{type}-{guildID}-{channelID}", colors))
            {
                // currentEntry.Color = ImGui.ColorConvertFloat4ToU32(buttoncolor);
            }
            ImGui.SameLine();
            ImGui.PushItemWidth(-1);
            ImGui.SetNextItemWidth(-100);

            string buttonlabel = $"{type} (Chat type {(int)type}##{index})";

            if (ImGui.Button(buttonlabel, new Vector2((int)Math.Truncate(ImGui.GetScrollMaxY()) != 0 ? ElementSizeX - 16 : ElementSizeX, 25)))
            {
                this.selectedChannelConfig = this.configuration.ChatTypeConfigurations[index];
                channelEditWindowVisible   = true;
            }
            ImGui.PopItemWidth();
            //ImGui.PopStyleColor();

            if (ImGui.BeginPopupContextItem($"Popup item###{buttonlabel}"))
            {
                if (ImGui.Selectable("Delete"))
                {
                    // this.currentNote = note;
                    // this.deletionWindowVisible = true;
                    DeleteConfirmationVisible = true;
                    //DrawDeletionConfirmationWindow();
                    //PluginLog.Information($"Loaded Delete confirm window? {DrawDeletionConfirmationWindow()}");
                    if (DrawDeletionConfirmationWindow())
                    {
                    }
                }
                ImGui.EndPopup();
            }
        }
コード例 #3
0
        public static bool GradientButton(string id, Color4 colA, Color4 colB, Vector2 size, ViewportManager vps, bool gradient)
        {
            if (!gradient)
            {
                return(ImGui.ColorButton(id, colA, ImGuiColorEditFlags.NoAlpha, size));
            }
            ImGui.PushID(id);
            var img    = ImGuiHelper.RenderGradient(vps, colA, colB);
            var retval = ImGui.ImageButton((IntPtr)img, size, new Vector2(0, 1), new Vector2(0, 0), 0);

            ImGui.PopID();
            return(retval);
        }
コード例 #4
0
        private void PlayerOverride_NamePlateColorSwatchRow(int min, int max)
        {
            ImGui.Spacing();
            for (var i = min; i < max; i++)
            {
                if (ImGui.ColorButton("###PlayerTrack_PlayerNamePlateColor_Swatch_" + i, this.colorPalette[i]))
                {
                    this.SelectedPlayer !.NamePlateColor = this.colorPalette[i];
                    this.plugin.PlayerService.UpdatePlayerNamePlateColor(this.SelectedPlayer);
                }

                ImGui.SameLine();
            }
        }
コード例 #5
0
        private void CategoryListColorSwatchRow(Category category, int id, int min, int max)
        {
            ImGui.Spacing();
            for (var i = min; i < max; i++)
            {
                if (ImGui.ColorButton("###PlayerTrack_CategoryListColor_Swatch_" + id + i, this.colorPalette[i]))
                {
                    category.ListColor = this.colorPalette[i];
                    this.Plugin.CategoryService.SaveCategory(category);
                }

                ImGui.SameLine();
            }
        }
コード例 #6
0
        public static void InputFloatsFromColor4Button(string label, object obj, string properyName, ImGuiColorEditFlags flags = ImGuiColorEditFlags.None)
        {
            var input      = obj.GetType().GetProperty(properyName);
            var inputValue = (float[])input.GetValue(obj);
            var vec        = new Vector4(inputValue[0], inputValue[1], inputValue[2], inputValue[3]);

            float size = ImGui.GetFontSize();

            if (ImGui.ColorButton(label, vec, flags, new Vector2(size, size)))
            {
                input.SetValue(obj, new float[4] {
                    vec.X, vec.Y, vec.Z, vec.W
                });
            }
        }
コード例 #7
0
        static bool EditColor(string label, string id, object obj, string properyName)
        {
            var input      = obj.GetType().GetProperty(properyName);
            var inputValue = (STColor)input.GetValue(obj);
            var color      = new Vector4(inputValue.R, inputValue.G, inputValue.B, inputValue.A);

            ImGui.Columns(2);

            var flags = ImGuiColorEditFlags.HDR;

            if (ImGui.ColorButton($"colorBtn{id}", color, flags, new Vector2(200, 22)))
            {
                ImGui.OpenPopup($"colorPicker{id}");
            }

            ImGui.NextColumn();
            ImGui.Text(label);

            ImGui.Columns(1);

            bool edited = false;

            if (ImGui.BeginPopup($"colorPicker{id}"))
            {
                if (ImGui.ColorPicker4("##picker", ref color, flags
                                       | ImGuiColorEditFlags.Float | ImGuiColorEditFlags.DisplayRGB
                                       | ImGuiColorEditFlags.DisplayHex | ImGuiColorEditFlags.DisplayHSV))
                {
                    input.SetValue(obj, new STColor()
                    {
                        R = color.X,
                        G = color.Y,
                        B = color.Z,
                        A = color.W,
                    });
                    edited = true;
                }
                ImGui.EndPopup();
            }
            return(edited);
        }
コード例 #8
0
        void ColorPickerAnimated(InterfaceColor clr)
        {
            var current = clr.GetColor(TimeSpan.FromSeconds(mainWindow.TotalTime));

            ImGui.ColorButton("##preview", current);
            ImGui.Text("Speed: ");
            ImGui.SameLine();
            ImGui.InputFloat("##speed", ref clr.Animation.Speed, 0, 0);
            ImGui.Text("Color 1");
            var v4 = (Vector4)clr.Animation.Color1;

            ImGui.BeginChild("##limiter", new Vector2(250, 235), false);
            ImGui.ColorPicker4("##colorpicker", ref v4, ImGuiColorEditFlags.None);
            ImGui.EndChild();
            clr.Animation.Color1 = v4;
            v4 = clr.Animation.Color2;
            ImGui.Text("Color 2");
            ImGui.BeginChild("##limiter2", new Vector2(250, 235), false);
            ImGui.ColorPicker4("##colorpicker", ref v4, ImGuiColorEditFlags.None);
            ImGui.EndChild();
            clr.Animation.Color2 = v4;
        }
コード例 #9
0
        /// <summary>
        /// ColorPicker with palette with color picker options.
        /// </summary>
        /// <param name="id">Id for the color picker.</param>
        /// <param name="description">The description of the color picker.</param>
        /// <param name="originalColor">The current color.</param>
        /// <param name="flags">Flags to customize color picker.</param>
        /// <returns>Selected color.</returns>
        public static Vector4 ColorPickerWithPalette(int id, string description, Vector4 originalColor, ImGuiColorEditFlags flags)
        {
            var existingColor = originalColor;
            var selectedColor = originalColor;
            var colorPalette  = ImGuiHelpers.DefaultColorPalette(36);

            if (ImGui.ColorButton($"{description}###ColorPickerButton{id}", originalColor))
            {
                ImGui.OpenPopup($"###ColorPickerPopup{id}");
            }

            if (ImGui.BeginPopup($"###ColorPickerPopup{id}"))
            {
                if (ImGui.ColorPicker4($"###ColorPicker{id}", ref existingColor, flags))
                {
                    selectedColor = existingColor;
                }

                for (var i = 0; i < 4; i++)
                {
                    ImGui.Spacing();
                    for (var j = i * 9; j < (i * 9) + 9; j++)
                    {
                        if (ImGui.ColorButton($"###ColorPickerSwatch{id}{i}{j}", colorPalette[j]))
                        {
                            selectedColor = colorPalette[j];
                        }

                        ImGui.SameLine();
                    }
                }

                ImGui.EndPopup();
            }

            return(selectedColor);
        }
コード例 #10
0
        public bool Draw()
        {
            var isOpen = true;

            try {
                var isSearch = false;
                if (triedLoadingItems == false || pluginConfig.SelectedClientLanguage != plugin.LuminaItemsClientLanguage)
                {
                    UpdateItemList(1000);
                }

                if ((selectedItemIndex < 0 && selectedItem != null) || (selectedItemIndex >= 0 && selectedItem == null))
                {
                    // Should never happen, but just incase
                    selectedItemIndex = -1;
                    selectedItem      = null;
                    return(true);
                }

                ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.FirstUseEver);

                PushStyle(ImGuiStyleVar.WindowMinSize, new Vector2(350, 400));

                if (!ImGui.Begin(Loc.Localize("ItemSearchPlguinMainWindowHeader", $"Item Search") + "###itemSearchPluginMainWindow", ref isOpen, ImGuiWindowFlags.NoCollapse))
                {
                    ResetStyle();
                    ImGui.End();
                    return(false);
                }

                if (ImGui.IsWindowAppearing())
                {
                    SearchFilters.ForEach(f => f._ForceVisible = false);
                }

                PopStyle();

                // Main window
                ImGui.AlignTextToFramePadding();

                if (selectedItem != null)
                {
                    var icon = selectedItem.Icon;

                    plugin.DrawIcon(icon, new Vector2(45 * ImGui.GetIO().FontGlobalScale));


                    ImGui.SameLine();
                    ImGui.BeginGroup();

                    if (selectedItem.GenericItemType == GenericItem.ItemType.EventItem)
                    {
                        ImGui.TextDisabled("[Key Item]");
                        ImGui.SameLine();
                    }

                    ImGui.Text(selectedItem.Name);

                    if (pluginConfig.ShowItemID)
                    {
                        ImGui.SameLine();
                        ImGui.Text($"(ID: {selectedItem.RowId}) (Rarity: {selectedItem.Rarity})");
                    }

                    var imGuiStyle    = ImGui.GetStyle();
                    var windowVisible = ImGui.GetWindowPos().X + ImGui.GetWindowContentRegionMax().X;

                    IActionButton[] buttons = this.ActionButtons.Where(ab => ab.ButtonPosition == ActionButtonPosition.TOP).ToArray();

                    for (var i = 0; i < buttons.Length; i++)
                    {
                        var button = buttons[i];

                        if (button.GetShowButton(selectedItem))
                        {
                            var buttonText = button.GetButtonText(selectedItem);
                            ImGui.PushID($"TopActionButton{i}");
                            if (ImGui.Button(buttonText))
                            {
                                button.OnButtonClicked(selectedItem);
                            }

                            if (i < buttons.Length - 1)
                            {
                                var lX2 = ImGui.GetItemRectMax().X;
                                var nbw = ImGui.CalcTextSize(buttons[i + 1].GetButtonText(selectedItem)).X + imGuiStyle.ItemInnerSpacing.X * 2;
                                var nX2 = lX2 + (imGuiStyle.ItemSpacing.X * 2) + nbw;
                                if (nX2 < windowVisible)
                                {
                                    ImGui.SameLine();
                                }
                            }

                            ImGui.PopID();
                        }
                    }

                    ImGui.EndGroup();
                }
                else
                {
                    ImGui.BeginChild("NoSelectedItemBox", new Vector2(-1, 45) * ImGui.GetIO().FontGlobalScale);
                    ImGui.Text(Loc.Localize("ItemSearchSelectItem", "Please select an item."));


                    if (!pluginConfig.HideKofi)
                    {
                        ImGui.PushStyleColor(ImGuiCol.Button, 0xFF5E5BFF);
                        ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xFF5E5BAA);
                        ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xFF5E5BDD);
                        ImGui.SameLine(ImGui.GetWindowWidth() - ImGui.CalcTextSize("Support on Ko-fi").X - ImGui.GetStyle().FramePadding.X * 3);
                        if (ImGui.Button("Support on Ko-Fi"))
                        {
                            Process.Start("https://ko-fi.com/Caraxi");
                        }
                        ImGui.PopStyleColor(3);
                    }

                    ImGui.EndChild();
                }

                ImGui.Separator();

                ImGui.Columns(2);
                var filterNameMax = SearchFilters.Where(x => x.IsEnabled && x.ShowFilter).Select(x => {
                    x._LocalizedName      = Loc.Localize(x.NameLocalizationKey, x.Name);
                    x._LocalizedNameWidth = ImGui.CalcTextSize($"{x._LocalizedName}").X;
                    return(x._LocalizedNameWidth);
                }).Max();

                ImGui.SetColumnWidth(0, filterNameMax + ImGui.GetStyle().ItemSpacing.X * 2);
                var filterInUseColour    = new Vector4(0, 1, 0, 1);
                var filterUsingTagColour = new Vector4(0.4f, 0.7f, 1, 1);

                foreach (var filter in SearchFilters.Where(x => x.IsEnabled && x.ShowFilter))
                {
                    if (!extraFiltersExpanded && filter.CanBeDisabled && !filter.IsSet && !filter._ForceVisible)
                    {
                        continue;
                    }
                    ImGui.SetCursorPosX((filterNameMax + ImGui.GetStyle().ItemSpacing.X) - filter._LocalizedNameWidth);
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3);
                    if (filter.IsSet)
                    {
                        ImGui.TextColored(filter.IsFromTag ? filterUsingTagColour : filterInUseColour, $"{filter._LocalizedName}: ");
                    }
                    else
                    {
                        ImGui.Text($"{filter._LocalizedName}: ");
                    }

                    ImGui.NextColumn();
                    ImGui.BeginGroup();
                    if (filter.IsFromTag && filter.GreyWithTags)
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, 0xFF888888);
                    }
                    filter.DrawEditor();
                    if (filter.IsFromTag && filter.GreyWithTags)
                    {
                        ImGui.PopStyleColor();
                    }
                    ImGui.EndGroup();
                    while (ImGui.GetColumnIndex() != 0)
                    {
                        ImGui.NextColumn();
                    }
                }
                ImGui.Columns(1);

                ImGui.PushFont(UiBuilder.IconFont);
                ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(0, -5 * ImGui.GetIO().FontGlobalScale));
                ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
                if (ImGui.Button($"{(extraFiltersExpanded ? (char) FontAwesomeIcon.CaretUp : (char) FontAwesomeIcon.CaretDown)}", new Vector2(-1, 10 * ImGui.GetIO().FontGlobalScale)))
                {
                    extraFiltersExpanded = !extraFiltersExpanded;
                    SearchFilters.ForEach(f => f._ForceVisible = f.IsEnabled && f.ShowFilter && f.IsSet);
                    pluginConfig.ExpandedFilters = extraFiltersExpanded;
                    pluginConfig.Save();
                }
                ImGui.PopStyleVar(2);
                ImGui.PopFont();

                var windowSize = ImGui.GetWindowSize();
                var childSize  = new Vector2(0, Math.Max(100 * ImGui.GetIO().FontGlobalScale, windowSize.Y - ImGui.GetCursorPosY() - 45 * ImGui.GetIO().FontGlobalScale));
                ImGui.BeginChild("scrolling", childSize, true, ImGuiWindowFlags.HorizontalScrollbar);

                PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));

                if (errorLoadingItems)
                {
                    ImGui.TextColored(new Vector4(1f, 0.1f, 0.1f, 1.00f), Loc.Localize("ItemSearchListLoadFailed", "Error loading item list."));
                    if (ImGui.SmallButton("Retry"))
                    {
                        UpdateItemList();
                    }
                }
                else if (plugin.LuminaItems != null)
                {
                    if (SearchFilters.Any(x => x.IsEnabled && x.ShowFilter && x.IsSet))
                    {
                        showingFavourites = false;
                        isSearch          = true;
                        var scrollTop = false;
                        if (SearchFilters.Any(x => x.IsEnabled && x.ShowFilter && x.HasChanged) || forceReload)
                        {
                            forceReload = false;
                            this.searchCancelTokenSource?.Cancel();
                            this.searchCancelTokenSource = new CancellationTokenSource();
                            var asyncEnum = plugin.LuminaItems.ToAsyncEnumerable();

                            if (!pluginConfig.ShowLegacyItems)
                            {
                                asyncEnum = asyncEnum.Where(x => x.RowId < 100 || x.RowId > 1600);
                            }

                            asyncEnum = SearchFilters.Where(filter => filter.IsEnabled && filter.ShowFilter && filter.IsSet).Aggregate(asyncEnum, (current, filter) => current.Where(filter.CheckFilter));
                            this.selectedItemIndex = -1;
                            selectedItem           = null;
                            this.searchTask        = asyncEnum.ToListAsync(this.searchCancelTokenSource.Token);
                        }

                        if (this.searchTask.IsCompletedSuccessfully)
                        {
                            DrawItemList(this.searchTask.Result, childSize, ref isOpen);
                        }
                    }
                    else
                    {
                        if (pluginConfig.Favorites.Count > 0)
                        {
                            if (!showingFavourites || favouritesList.Count != pluginConfig.Favorites.Count)
                            {
                                showingFavourites      = true;
                                this.selectedItemIndex = -1;
                                selectedItem           = null;
                                favouritesList         = plugin.LuminaItems.Where(i => pluginConfig.Favorites.Contains(i.RowId)).ToList();
                            }

                            DrawItemList(favouritesList, childSize, ref isOpen);
                        }
                        else
                        {
                            ImGui.TextColored(new Vector4(0.86f, 0.86f, 0.86f, 1.00f), Loc.Localize("DalamudItemSelectHint", "Type to start searching..."));
                        }
                    }
                }
                else
                {
                    ImGui.TextColored(new Vector4(0.86f, 0.86f, 0.86f, 1.00f), Loc.Localize("DalamudItemSelectLoading", "Loading item list..."));
                }

                PopStyle();

                ImGui.EndChild();

                // Darken choose button if it shouldn't be clickable
                PushStyle(ImGuiStyleVar.Alpha, this.selectedItemIndex < 0 || selectedItem == null || selectedItem.Icon >= 65000 ? 0.25f : 1);

                if (ImGui.Button(Loc.Localize("Choose", "Choose")))
                {
                    try {
                        if (selectedItem != null && selectedItem.Icon < 65000)
                        {
                            plugin.LinkItem(selectedItem);
                            if (pluginConfig.CloseOnChoose)
                            {
                                isOpen = false;
                            }
                        }
                    } catch (Exception ex) {
                        Log.Error($"Exception in Choose: {ex.Message}");
                    }
                }

                PopStyle();

                if (!pluginConfig.CloseOnChoose)
                {
                    ImGui.SameLine();
                    if (ImGui.Button(Loc.Localize("Close", "Close")))
                    {
                        selectedItem = null;
                        isOpen       = false;
                    }
                }

                if (this.selectedItemIndex >= 0 && this.selectedItem != null && selectedItem.Icon >= 65000)
                {
                    ImGui.SameLine();
                    ImGui.Text(Loc.Localize("DalamudItemNotLinkable", "This item is not linkable."));
                }

                if (pluginConfig.ShowTryOn && pluginInterface.ClientState?.LocalContentId != 0)
                {
                    ImGui.SameLine();
                    if (ImGui.Checkbox(Loc.Localize("ItemSearchTryOnButton", "Try On"), ref autoTryOn))
                    {
                        pluginConfig.TryOnEnabled = autoTryOn;
                        pluginConfig.Save();
                    }

                    ImGui.SameLine();


                    ImGui.PushStyleColor(ImGuiCol.Border, selectedStain != null && selectedStain.Unknown4 ? new Vector4(1, 1, 0, 1) : new Vector4(1, 1, 1, 1));
                    PushStyle(ImGuiStyleVar.FrameBorderSize, 2f);
                    if (ImGui.ColorButton("X", selectedStainColor, ImGuiColorEditFlags.NoTooltip))
                    {
                        showStainSelector = true;
                    }

                    if (ImGui.IsItemClicked(1))
                    {
                        selectedStainColor         = Vector4.Zero;
                        selectedStain              = null;
                        pluginConfig.SelectedStain = 0;
                        pluginConfig.Save();
                    }

                    PopStyle();

                    ImGui.PopStyleColor();

                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
                        ImGui.BeginTooltip();
                        ImGui.Text(selectedStain == null ? "No Dye Selected" : selectedStain.Name);
                        if (selectedStain != null)
                        {
                            ImGui.TextDisabled("Right click to clear selection.");
                        }
                        ImGui.EndTooltip();
                    }
                }
                ImGui.PushFont(UiBuilder.IconFont);
                var configText     = $"{(char)FontAwesomeIcon.Cog}";
                var configTextSize = ImGui.CalcTextSize(configText);
                ImGui.PopFont();
                var itemCountText = isSearch ? string.Format(Loc.Localize("ItemCount", "{0} Items"), this.searchTask.Result.Count) : $"v{plugin.Version}";
                ImGui.SameLine(ImGui.GetWindowWidth() - (configTextSize.X + ImGui.GetStyle().ItemSpacing.X) - (ImGui.CalcTextSize(itemCountText).X + ImGui.GetStyle().ItemSpacing.X *(isSearch ? 3 : 2)));
                if (isSearch)
                {
                    if (ImGui.Button(itemCountText))
                    {
                        PluginLog.Log("Copying results to Clipboard");

                        var sb = new StringBuilder();

                        if (pluginConfig.PrependFilterListWithCopy)
                        {
                            foreach (var f in SearchFilters.Where(f => f.IsSet))
                            {
                                sb.AppendLine($"{f.Name}: {f}");
                            }

                            sb.AppendLine();
                        }

                        foreach (var i in this.searchTask.Result)
                        {
                            sb.AppendLine(i.Name);
                        }
                        ImGui.SetClipboardText(sb.ToString());
                    }

                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip("Copy results to clipboard");
                    }
                }
                else
                {
                    ImGui.Text(itemCountText);
                }

                ImGui.SameLine(ImGui.GetWindowWidth() - (configTextSize.X + ImGui.GetStyle().ItemSpacing.X * 2));
                ImGui.PushFont(UiBuilder.IconFont);
                if (ImGui.Button(configText))
                {
                    plugin.ToggleConfigWindow();
                }
                ImGui.PopFont();

                var mainWindowPos  = ImGui.GetWindowPos();
                var mainWindowSize = ImGui.GetWindowSize();

                ImGui.End();


                if (showStainSelector)
                {
                    ImGui.SetNextWindowSize(new Vector2(210, 180));
                    ImGui.SetNextWindowPos(mainWindowPos + mainWindowSize - new Vector2(0, 180));
                    ImGui.Begin("Select Dye", ref showStainSelector, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove);

                    ImGui.BeginTabBar("stainShadeTabs");

                    var unselectedModifier = new Vector4(0, 0, 0, 0.7f);

                    foreach (var shade in stainShadeHeaders)
                    {
                        ImGui.PushStyleColor(ImGuiCol.TabActive, shade.Value);
                        ImGui.PushStyleColor(ImGuiCol.TabHovered, shade.Value);
                        ImGui.PushStyleColor(ImGuiCol.TabUnfocused, shade.Value);
                        ImGui.PushStyleColor(ImGuiCol.TabUnfocusedActive, shade.Value);
                        ImGui.PushStyleColor(ImGuiCol.Tab, shade.Value - unselectedModifier);

                        if (ImGui.BeginTabItem($"    ###StainShade{shade.Key}"))
                        {
                            var c = 0;

                            PushStyle(ImGuiStyleVar.FrameBorderSize, 2f);
                            foreach (var stain in stains.Where(s => s.Shade == shade.Key && !string.IsNullOrEmpty(s.Name)))
                            {
                                var b = stain.Color & 255;
                                var g = (stain.Color >> 8) & 255;
                                var r = (stain.Color >> 16) & 255;

                                var stainColor = new Vector4(r / 255f, g / 255f, b / 255f, 1f);

                                ImGui.PushStyleColor(ImGuiCol.Border, stain.Unknown4 ? new Vector4(1, 1, 0, 1) : new Vector4(1, 1, 1, 1));

                                if (ImGui.ColorButton($"###stain{stain.RowId}", stainColor, ImGuiColorEditFlags.NoTooltip))
                                {
                                    selectedStain              = stain;
                                    selectedStainColor         = stainColor;
                                    showStainSelector          = false;
                                    pluginConfig.SelectedStain = stain.RowId;
                                    pluginConfig.Save();
                                }

                                ImGui.PopStyleColor(1);

                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
                                    ImGui.SetTooltip(stain.Name);
                                }

                                if (c++ < 5)
                                {
                                    ImGui.SameLine();
                                }
                                else
                                {
                                    c = 0;
                                }
                            }

                            PopStyle(1);

                            ImGui.EndTabItem();
                        }

                        ImGui.PopStyleColor(5);
                    }

                    ImGui.EndTabBar();
                    ImGui.End();
                }


                return(isOpen);
            } catch (Exception ex) {
                ResetStyle();
                PluginLog.LogError(ex.ToString());
                selectedItem      = null;
                selectedItemIndex = -1;
                return(isOpen);
            }
        }
コード例 #11
0
        private void TranslatorConfigUi()
        {
            if (_config)
            {
                ImGui.SetNextWindowSizeConstraints(new Num.Vector2(500, 500), new Num.Vector2(1920, 1080));
                ImGui.Begin("Chat Translator Config", ref _config);
                if (ImGui.BeginTabBar("Tabs", ImGuiTabBarFlags.None))
                {
                    if (ImGui.BeginTabItem("Config"))
                    {
                        if (ImGui.Combo("Language to translate to", ref _languageInt, _languages, _languages.Length))
                        {
                            SaveConfig();
                        }
                        ImGui.SameLine();
                        ImGui.Text("(?)"); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Which language to translate to.");
                        }
                        if (ImGui.Combo("Mode", ref _tranMode, _tranModeOptions, _tranModeOptions.Length))
                        {
                            SaveConfig();
                        }
                        ImGui.SameLine();
                        ImGui.Text("(?)"); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Which method of displaying the translated text.");
                        }
                        var textColour = BitConverter.GetBytes(_textColour[0].Choice);
                        if (ImGui.ColorButton("Translated Text Colour", new Num.Vector4(
                                                  (float)textColour[3] / 255,
                                                  (float)textColour[2] / 255,
                                                  (float)textColour[1] / 255,
                                                  (float)textColour[0] / 255)))
                        {
                            _chooser = _textColour[0];
                            _picker  = true;
                        }
                        ImGui.SameLine();
                        ImGui.Text("Translated text colour");
                        ImGui.SameLine();
                        ImGui.Text("(?)"); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Colour the translated text this colour.");
                        }
                        ImGui.Separator();
                        ImGui.Checkbox("Exclude self", ref _notSelf);
                        ImGui.SameLine();
                        ImGui.Text("(?)"); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Do not translate your own text.");
                        }

                        ImGui.Checkbox("Send Translations to one channel", ref _oneChan);
                        ImGui.SameLine();
                        ImGui.Text("(?)"); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Only works for the 'Additional' mode.'");
                        }
                        if (_oneChan)
                        {
                            if (ImGui.Combo("Channel", ref _oneInt, _orderString, _orderString.Length))
                            {
                                _tranMode = 2;
                                SaveConfig();
                            }
                        }

                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Channels"))
                    {
                        var i = 0;
                        ImGui.Text("Enabled channels:");
                        ImGui.SameLine();
                        ImGui.Text("(?)"); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Which chat channels to translate.");
                        }
                        ImGui.Columns(2);

                        foreach (var e in (XivChatType[])Enum.GetValues(typeof(XivChatType)))
                        {
                            if (_yesNo[i])
                            {
                                var enabled = _channels.Contains(e);
                                if (ImGui.Checkbox($"{e}", ref enabled))
                                {
                                    if (enabled)
                                    {
                                        _channels.Add(e);
                                    }
                                    else
                                    {
                                        _channels.Remove(e);
                                    }
                                    SaveConfig();
                                }
                                ImGui.NextColumn();
                            }
                            i++;
                        }
                        ImGui.Columns(1);
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Whitelist"))
                    {
                        ImGui.Checkbox("Enable Whitelist", ref _whitelist);
                        ImGui.SameLine();
                        ImGui.Text("(?)"); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Only translate languages detected in specific languages");
                        }
                        if (_whitelist)
                        {
                            var remove = -1;
                            for (var j = 0; j < _chosenLanguages.Count; j++)
                            {
                                ImGui.Text($"{j}: {_languages[_chosenLanguages[j]]}");
                                ImGui.SameLine();
                                if (ImGui.Button($"Remove##{j}"))
                                {
                                    remove = j;
                                }
                            }
                            if (ImGui.Combo("Add Language", ref _languageInt2, _languages, _languages.Length))
                            {
                                _chosenLanguages.Add(_languageInt2);
                                SaveConfig();
                            }
                            if (remove != -1)
                            {
                                _chosenLanguages.RemoveAt(remove);
                                SaveConfig();
                            }
                        }
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Blacklist"))
                    {
                        ImGui.Text("Blacklisted messages:");
                        var removeTwo = -1;
                        for (var j = 0; j < _blacklist.Count; j++)
                        {
                            ImGui.Text($"- {_blacklist[j]}");
                            ImGui.SameLine();
                            if (ImGui.Button($"Remove##{j}"))
                            {
                                removeTwo = j;
                            }
                        }

                        if (removeTwo != -1)
                        {
                            _blacklist.RemoveAt(removeTwo);
                            SaveConfig();
                        }

                        ImGui.Separator();
                        ImGui.Text("Recently translated messages");
                        for (var j = 0; j < _lastTranslations.Count; j++)
                        {
                            ImGui.Text($"{j+1}: {_lastTranslations[j]}");
                            ImGui.SameLine();
                            if (ImGui.Button($"Add##{j}"))
                            {
                                _blacklist.Add(_lastTranslations[j]);
                                SaveConfig();
                            }
                        }
                        ImGui.EndTabItem();
                    }
                    ImGui.EndTabBar();
                }


                if (ImGui.Button("Save and Close Config"))
                {
                    SaveConfig();
                    _config = false;
                }

                ImGui.SameLine();
                ImGui.PushStyleColor(ImGuiCol.Button, 0xFF000000 | 0x005E5BFF);
                ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD000000 | 0x005E5BFF);
                ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA000000 | 0x005E5BFF);

                if (ImGui.Button("Buy Haplo a Hot Chocolate"))
                {
                    System.Diagnostics.Process.Start("https://ko-fi.com/haplo");
                }
                ImGui.PopStyleColor(3);

                ImGui.End();
            }

            if (!_picker)
            {
                return;
            }
            ImGui.SetNextWindowSizeConstraints(new Num.Vector2(320, 440), new Num.Vector2(640, 880));
            ImGui.Begin("UIColor Picker", ref _picker);
            ImGui.Columns(10, "##columnsID", false);
            foreach (var z in _uiColours)
            {
                var temp = BitConverter.GetBytes(z.UIForeground);
                if (ImGui.ColorButton(z.RowId.ToString(), new Num.Vector4(
                                          (float)temp[3] / 255,
                                          (float)temp[2] / 255,
                                          (float)temp[1] / 255,
                                          (float)temp[0] / 255)))
                {
                    _chooser.Choice = z.UIForeground;
                    _chooser.Option = z.RowId;
                    _picker         = false;
                    SaveConfig();
                }
                ImGui.NextColumn();
            }
            ImGui.Columns(1);
            ImGui.End();
        }
コード例 #12
0
        public static bool UiColorPicker(string label, ref ushort colourKey, ColorPickerMode mode = ColorPickerMode.ForegroundOnly)
        {
            var modified = false;

            var glowOnly = mode == ColorPickerMode.GlowOnly;

            var colorSheet = Service.Data.Excel.GetSheet <UIColor>();

            if (colorSheet == null)
            {
                var i = (int)colourKey;
                if (ImGui.InputInt(label, ref i))
                {
                    if (i >= ushort.MinValue && i <= ushort.MaxValue)
                    {
                        colourKey = (ushort)i;
                        return(true);
                    }
                }
                return(false);
            }

            var currentColor = colorSheet.GetRow(colourKey);

            if (currentColor == null)
            {
                currentColor = colorSheet.GetRow(0) !;
            }
            if (currentColor == null)
            {
                return(false);
            }
            var id = ImGui.GetID(label);

            ImGui.SetNextItemWidth(24 * ImGui.GetIO().FontGlobalScale);

            ImGui.PushStyleColor(ImGuiCol.FrameBg, Common.UiColorToVector4(glowOnly ? currentColor.UIGlow : currentColor.UIForeground));
            ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, Common.UiColorToVector4(glowOnly ? currentColor.UIGlow : currentColor.UIForeground));
            ImGui.PushStyleColor(ImGuiCol.FrameBgActive, Common.UiColorToVector4(glowOnly ? currentColor.UIGlow : currentColor.UIForeground));

            if (mode == ColorPickerMode.ForegroundAndGlow)
            {
                ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 4);
                ImGui.PushStyleColor(ImGuiCol.Border, Common.UiColorToVector4(currentColor.UIGlow));
            }

            var comboOpen = ImGui.BeginCombo($"{label}##combo", string.Empty, ImGuiComboFlags.NoArrowButton);

            ImGui.PopStyleColor(3);
            if (mode == ColorPickerMode.ForegroundAndGlow)
            {
                ImGui.PopStyleVar();
                ImGui.PopStyleColor();
            }

            if (ImGui.IsItemHovered())
            {
                ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
            }

            if (comboOpen)
            {
                if (uniqueSortedUiForeground == null || uniqueSortedUiGlow == null)
                {
                    BuildUiColorLists();
                }

                var cl = (glowOnly ? uniqueSortedUiGlow : uniqueSortedUiForeground) ?? new List <UIColor>();

                var sqrt = (int)Math.Sqrt(cl.Count);
                ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(1));
                for (var i = 0; i < cl.Count; i++)
                {
                    var c = cl[i];
                    if (i != 0 && i % sqrt != 0)
                    {
                        ImGui.SameLine();
                    }
                    if (ImGui.ColorButton($"##ColorPick_{i}_{c.RowId}", Common.UiColorToVector4(glowOnly ? c.UIGlow : c.UIForeground), ImGuiColorEditFlags.NoTooltip))
                    {
                        colourKey = (ushort)c.RowId;
                        modified  = true;
                        ImGui.CloseCurrentPopup();
                    }
                }
                ImGui.PopStyleVar();


                ImGui.EndCombo();
            }

            return(modified);
        }
コード例 #13
0
        public static bool ImGuiEditorForType <T>(T obj, XMLFieldHandler xmlHandler)
        {
            XMLTypeHandler?typeHandler = xmlHandler.TypeHandler;
            object         value       = xmlHandler.ReflectionInfo.GetValue(obj);

            switch (typeHandler)
            {
            case XMLStringTypeHandler:
            {
                var stringValue = (string)(value ?? "");
                if (ImGui.InputText(xmlHandler.Name, ref stringValue, 1000))
                {
                    xmlHandler.ReflectionInfo.SetValue(obj, stringValue);
                    return(true);
                }

                break;
            }

            case XMLEnumTypeHandler enumHandler:
            {
                string[] enumValueNames = Enum.GetNames(enumHandler.Type);
                int      currentItem    = enumValueNames.IndexOf(value.ToString());
                if (ImGui.Combo(xmlHandler.Name, ref currentItem, enumValueNames, enumValueNames.Length))
                {
                    value = Enum.Parse(enumHandler.Type, enumValueNames[currentItem]);
                    xmlHandler.ReflectionInfo.SetValue(obj, value);
                    return(true);
                }

                break;
            }

            case XMLPrimitiveTypeHandler primitive:
            {
                if (primitive.Type == typeof(int))
                {
                    var intValue = (int)(value ?? 0);
                    if (ImGui.InputInt(xmlHandler.Name, ref intValue))
                    {
                        xmlHandler.ReflectionInfo.SetValue(obj, intValue);
                        return(true);
                    }

                    break;
                }

                if (primitive.Type == typeof(bool))
                {
                    var boolValue = (bool)(value ?? false);
                    if (ImGui.Checkbox(xmlHandler.Name, ref boolValue))
                    {
                        xmlHandler.ReflectionInfo.SetValue(obj, boolValue);
                        return(true);
                    }

                    break;
                }

                if (primitive.Type == typeof(float))
                {
                    var floatVal = (float)value;
                    if (ImGui.InputFloat(xmlHandler.Name, ref floatVal))
                    {
                        xmlHandler.ReflectionInfo.SetValue(obj, floatVal);
                        return(true);
                    }
                }

                break;
            }

            case XMLComplexValueTypeHandler valueType:
            {
                if (valueType.Type == typeof(Vector2))
                {
                    var vec2Value = (Vector2)(value ?? Vector2.Zero);
                    if (ImGui.InputFloat2(xmlHandler.Name, ref vec2Value))
                    {
                        xmlHandler.ReflectionInfo.SetValue(obj, vec2Value);
                        return(true);
                    }

                    break;
                }

                if (valueType.Type == typeof(Vector3))
                {
                    var vec3Value = (Vector3)(value ?? Vector3.Zero);
                    if (ImGui.InputFloat3(xmlHandler.Name, ref vec3Value))
                    {
                        xmlHandler.ReflectionInfo.SetValue(obj, vec3Value);
                        return(true);
                    }

                    break;
                }

                if (valueType.Type == typeof(Color))
                {
                    var     colorValue  = (Color)(value ?? Color.White);
                    Vector4 colorAsVec4 = colorValue.ToVec4();
                    ImGui.Text(xmlHandler.Name);
                    ImGui.SameLine();
                    ImGui.Text($"(RGBA) {colorValue}");
                    ImGui.SameLine();

                    if (ImGui.ColorButton(xmlHandler.Name, colorAsVec4))
                    {
                        ImGui.OpenPopup(xmlHandler.Name);
                    }
                    if (ImGui.BeginPopup(xmlHandler.Name))
                    {
                        if (ImGui.ColorPicker4($"Edit: {xmlHandler.Name}", ref colorAsVec4))
                        {
                            colorValue = new Color(colorAsVec4);
                            xmlHandler.ReflectionInfo.SetValue(obj, colorValue);
                            return(true);
                        }

                        ImGui.EndPopup();
                    }

                    break;
                }

                if (valueType.Type == typeof(Rectangle))
                {
                    var rectValue = (Rectangle)(value ?? Rectangle.Empty);
                    var vec4Value = new Vector4(rectValue.X, rectValue.Y, rectValue.Width, rectValue.Height);
                    if (ImGui.InputFloat4(xmlHandler.Name, ref vec4Value))
                    {
                        var r = new Rectangle(vec4Value.X, vec4Value.Y, vec4Value.Z, vec4Value.W);
                        xmlHandler.ReflectionInfo.SetValue(obj, r);
                        return(true);
                    }
                }

                break;
            }

            default:
            {
                ImGui.Text($"{xmlHandler.Name}: {value}");
                break;
            }
            }

            object defaultVal        = xmlHandler.DefaultValue;
            bool   valueIsNotDefault = value != null && !value.Equals(defaultVal);
            bool   defaultIsNotValue = defaultVal != null && !defaultVal.Equals(value);

            if (valueIsNotDefault || defaultIsNotValue)
            {
                ImGui.PushID(xmlHandler.Name);
                ImGui.SameLine();
                if (ImGui.SmallButton("X"))
                {
                    xmlHandler.ReflectionInfo.SetValue(obj, defaultVal);
                    return(true);
                }

                ImGui.PopID();
            }

            return(false);
        }
コード例 #14
0
        private void CategoryConfig()
        {
            // get sorted categories
            var categories = this.Plugin.CategoryService.GetSortedCategories().ToList();

            // don't display if no categories (shouldn't happen in theory)
            if (!categories.Any())
            {
                return;
            }

            // add category
            if (ImGui.SmallButton(Loc.Localize("AddCategory", "Add Category") + "###PlayerTrack_CategoryAdd_Button"))
            {
                this.Plugin.CategoryService.AddCategory();
            }

            // setup category table
            ImGui.Separator();
            ImGui.Columns(8, "###PlayerTrack_CategoryTable_Columns", true);
            var baseWidth = ImGui.GetWindowSize().X / 4 * ImGuiHelpers.GlobalScale;

            ImGui.SetColumnWidth(0, baseWidth + 20f);                 // name
            ImGui.SetColumnWidth(1, ImGuiHelpers.GlobalScale * 70f);  // isDefault
            ImGui.SetColumnWidth(2, ImGuiHelpers.GlobalScale * 100f); // alerts
            ImGui.SetColumnWidth(3, baseWidth + 80f);                 // list
            ImGui.SetColumnWidth(4, ImGuiHelpers.GlobalScale * 110f); // nameplates
            ImGui.SetColumnWidth(5, ImGuiHelpers.GlobalScale * 100f); // visibility
            ImGui.SetColumnWidth(6, ImGuiHelpers.GlobalScale * 90f);  // fcnamecolor
            ImGui.SetColumnWidth(7, baseWidth + 200f);                // controls

            // add table headings
            ImGui.Text(Loc.Localize("CategoryName", "Name"));
            ImGui.NextColumn();
            ImGui.Text(Loc.Localize("CategoryDefault", "IsDefault"));
            ImGui.NextColumn();
            ImGui.Text(Loc.Localize("CategoryAlerts", "Alerts"));
            ImGui.NextColumn();
            ImGui.Text(Loc.Localize("CategoryList", "List Color/Icon"));
            ImGui.NextColumn();
            ImGui.Text(Loc.Localize("CategoryNamePlates", "NamePlate"));
            ImGui.NextColumn();
            ImGui.Text(Loc.Localize("CategoryVisibility", "Visibility"));
            ImGui.NextColumn();
            ImGui.Text(Loc.Localize("CategoryFCNameColor", "FCNameColor"));
            ImGui.NextColumn();
            ImGui.Text(Loc.Localize("CategoryAction", "Actions"));
            ImGui.NextColumn();
            ImGui.Separator();

            // loop through categories
            for (var i = 0; i < categories.Count; i++)
            {
                var category = categories[i].Value;

                // category name
                var categoryName = category.Name;
                ImGui.SetNextItemWidth(baseWidth);
                if (ImGui.InputText("###PlayerTrack_CategoryName_Input" + i, ref categoryName, 20))
                {
                    category.Name = categoryName;
                    this.Plugin.CategoryService.SaveCategory(category);
                }

                // category default
                ImGui.NextColumn();
                var isDefault = category.IsDefault;
                if (isDefault)
                {
                    ImGui.PushFont(UiBuilder.IconFont);
                    ImGui.Text(FontAwesomeIcon.Check.ToIconString());
                    ImGui.PopFont();
                }
                else
                {
                    if (ImGui.Checkbox(
                            "###PlayerTrack_CategoryDefault_Checkbox" + i,
                            ref isDefault))
                    {
                        var oldDefaultCategory = this.Plugin.CategoryService.GetDefaultCategory();
                        category.IsDefault = isDefault;
                        this.Plugin.CategoryService.SaveCategory(category);
                        oldDefaultCategory.IsDefault = false;
                        this.Plugin.CategoryService.SaveCategory(oldDefaultCategory);
                    }
                }

                // category alerts
                ImGui.NextColumn();
                var lastSeenAlerts = category.IsAlertEnabled;
                if (ImGui.Checkbox(
                        "###PlayerTrack_EnableCategoryAlerts_Checkbox" + i,
                        ref lastSeenAlerts))
                {
                    category.IsAlertEnabled = lastSeenAlerts;
                    this.Plugin.CategoryService.SaveCategory(category);
                }

                if (ImGui.IsItemHovered())
                {
                    ImGui.BeginTooltip();
                    ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35f);
                    ImGui.TextUnformatted(Loc.Localize("CategorySendLastSeenAlert", "send alert with when and where you last saw the player"));
                    ImGui.PopTextWrapPos();
                    ImGui.EndTooltip();
                }

                ImGui.SameLine();
                var sendNameChangeAlert = category.IsNameChangeAlertEnabled;
                if (ImGui.Checkbox(
                        "###PlayerTrack_SendNameChangeAlert_Checkbox" + i,
                        ref sendNameChangeAlert))
                {
                    category.IsNameChangeAlertEnabled = sendNameChangeAlert;
                    this.Plugin.CategoryService.SaveCategory(category);
                }

                if (ImGui.IsItemHovered())
                {
                    ImGui.BeginTooltip();
                    ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35f);
                    ImGui.TextUnformatted(Loc.Localize("CategorySendNameChangeAlert", "send name change alert in chat when detected from lodestone lookup"));
                    ImGui.PopTextWrapPos();
                    ImGui.EndTooltip();
                }

                ImGui.SameLine();
                var sendWorldTransferAlert = category.IsWorldTransferAlertEnabled;
                if (ImGui.Checkbox(
                        "###PlayerTrack_SendWorldTransferAlert_Checkbox" + i,
                        ref sendWorldTransferAlert))
                {
                    category.IsWorldTransferAlertEnabled = sendWorldTransferAlert;
                    this.Plugin.CategoryService.SaveCategory(category);
                }

                if (ImGui.IsItemHovered())
                {
                    ImGui.BeginTooltip();
                    ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35f);
                    ImGui.TextUnformatted(Loc.Localize("CategorySendWorldTransferAlert", "send world transfer alert in chat when detected from lodestone lookup"));
                    ImGui.PopTextWrapPos();
                    ImGui.EndTooltip();
                }

                // category list color
                ImGui.NextColumn();
                var categoryListColor = category.EffectiveListColor();
                if (ImGui.ColorButton("List Color###PlayerTrack_CategoryListColor_Button" + i, categoryListColor))
                {
                    ImGui.OpenPopup("###PlayerTrack_CategoryListColor_Popup" + i);
                }
                if (ImGui.BeginPopup("###PlayerTrack_CategoryListColor_Popup" + i))
                {
                    if (ImGui.ColorPicker4("List Color###PlayerTrack_CategoryListColor_ColorPicker" + i, ref categoryListColor))
                    {
                        category.ListColor = categoryListColor;
                        if (this.plugin.Configuration.DefaultNamePlateColorToListColor)
                        {
                            category.NamePlateColor = categoryListColor;
                        }

                        this.Plugin.CategoryService.SaveCategory(category);
                    }

                    this.CategoryListColorSwatchRow(category, category.Id, 0, 8);
                    this.CategoryListColorSwatchRow(category, category.Id, 8, 16);
                    this.CategoryListColorSwatchRow(category, category.Id, 16, 24);
                    this.CategoryListColorSwatchRow(category, category.Id, 24, 32);
                    ImGui.EndPopup();
                }

                // category icon
                ImGui.SameLine();
                var categoryIcon = category.Icon;
                var namesList    = new List <string> {
                    Loc.Localize("Default", "Default")
                };
                namesList.AddRange(this.Plugin.Configuration.EnabledIcons.ToList()
                                   .Select(icon => icon.ToString()));
                var names     = namesList.ToArray();
                var codesList = new List <int>
                {
                    0,
                };
                codesList.AddRange(this.Plugin.Configuration.EnabledIcons.ToList().Select(icon => (int)icon));
                var codes     = codesList.ToArray();
                var iconIndex = Array.IndexOf(codes, categoryIcon);
                ImGui.SetNextItemWidth(baseWidth);
                if (ImGui.Combo("###PlayerTrack_SelectCategoryIcon_Combo" + i, ref iconIndex, names, names.Length))
                {
                    category.Icon = codes[iconIndex];
                    this.Plugin.CategoryService.SaveCategory(category);
                }

                ImGui.SameLine();
                ImGui.PushFont(UiBuilder.IconFont);
                ImGui.Text(categoryIcon != 0
                               ? ((FontAwesomeIcon)categoryIcon).ToIconString()
                               : FontAwesomeIcon.User.ToIconString());
                ImGui.PopFont();

                // category color nameplates
                ImGui.NextColumn();
                var enableNamePlatesTitle = category.IsNamePlateTitleEnabled;
                if (ImGui.Checkbox(
                        "###PlayerTrack_EnableNamePlatesTitle_Checkbox" + i,
                        ref enableNamePlatesTitle))
                {
                    category.IsNamePlateTitleEnabled = enableNamePlatesTitle;
                    this.Plugin.CategoryService.SaveCategory(category);
                }

                if (ImGui.IsItemHovered())
                {
                    ImGui.BeginTooltip();
                    ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35f);
                    ImGui.TextUnformatted(Loc.Localize("CategoryNamePlateTitleEnabled", "Enable nameplate titles"));
                    ImGui.PopTextWrapPos();
                    ImGui.EndTooltip();
                }

                // category color nameplates
                ImGui.SameLine();
                var enableNamePlatesColor = category.IsNamePlateColorEnabled;
                if (ImGui.Checkbox(
                        "###PlayerTrack_EnableNamePlatesColor_Checkbox" + i,
                        ref enableNamePlatesColor))
                {
                    category.IsNamePlateColorEnabled = enableNamePlatesColor;
                    this.Plugin.CategoryService.SaveCategory(category);
                }

                if (ImGui.IsItemHovered())
                {
                    ImGui.BeginTooltip();
                    ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35f);
                    ImGui.TextUnformatted(Loc.Localize("CategoryNamePlateColor", "Set nameplate color"));
                    ImGui.PopTextWrapPos();
                    ImGui.EndTooltip();
                }

                // category nameplate color
                ImGui.SameLine();
                var categoryNamePlateColor = category.EffectiveNamePlateColor();
                if (ImGui.ColorButton("NamePlate Color###PlayerTrack_CategoryNamePlateColor_Button" + i, categoryNamePlateColor))
                {
                    ImGui.OpenPopup("###PlayerTrack_CategoryNamePlateColor_Popup" + i);
                }
                if (ImGui.BeginPopup("###PlayerTrack_CategoryNamePlateColor_Popup" + i))
                {
                    if (ImGui.ColorPicker4("NamePlate Color###PlayerTrack_CategoryNamePlateColor_ColorPicker" + i, ref categoryNamePlateColor))
                    {
                        category.NamePlateColor = categoryNamePlateColor;
                        this.Plugin.CategoryService.SaveCategory(category);
                        this.plugin.NamePlateManager.ForceRedraw();
                    }

                    this.CategoryNamePlateColorSwatchRow(category, category.Id, 0, 8);
                    this.CategoryNamePlateColorSwatchRow(category, category.Id, 8, 16);
                    this.CategoryNamePlateColorSwatchRow(category, category.Id, 16, 24);
                    this.CategoryNamePlateColorSwatchRow(category, category.Id, 24, 32);
                    ImGui.EndPopup();
                }

                // visibility
                ImGui.NextColumn();
                if (!category.IsDefault)
                {
                    var visibilityType = (int)category.VisibilityType;
                    ImGui.SetNextItemWidth(-1);
                    if (ImGui.Combo(
                            "###PlayerTrack_SelectCategoryVisibilityType_Combo" + i,
                            ref visibilityType,
                            Enum.GetNames(typeof(VisibilityType)),
                            Enum.GetNames(typeof(VisibilityType)).Length))
                    {
                        category.VisibilityType = (VisibilityType)visibilityType;
                        this.Plugin.CategoryService.SaveCategory(category);
                        this.plugin.VisibilityService.SyncWithVisibility();
                    }

                    if (ImGui.IsItemHovered())
                    {
                        ImGui.BeginTooltip();
                        ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35f);
                        ImGui.TextUnformatted(Loc.Localize("IsHiddenInVisibility", "void or whitelist players with visibility"));
                        ImGui.PopTextWrapPos();
                        ImGui.EndTooltip();
                    }
                }

                // category fcnamecolor
                ImGui.NextColumn();
                var overrideFCNameColor = category.OverrideFCNameColor;
                if (ImGui.Checkbox(
                        "###PlayerTrack_CategoryOverrideFCNameColor_Checkbox" + i,
                        ref overrideFCNameColor))
                {
                    category.OverrideFCNameColor = overrideFCNameColor;
                    this.Plugin.CategoryService.SaveCategory(category);
                    this.plugin.FCNameColorService.SyncWithFCNameColor();
                }

                if (ImGui.IsItemHovered())
                {
                    ImGui.BeginTooltip();
                    ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35f);
                    ImGui.TextUnformatted(Loc.Localize(
                                              "CategoryFCNameColorOverride",
                                              "override fcnamecolor nameplate settings for this category by adding players to ignore list"));
                    ImGui.PopTextWrapPos();
                    ImGui.EndTooltip();
                }

                // category actions
                ImGui.NextColumn();
                if (category.Rank != 0)
                {
                    if (ImGuiComponents.IconButton(category.Id + 1, FontAwesomeIcon.ArrowUp))
                    {
                        this.Plugin.CategoryService.IncreaseCategoryRank(category.Id);
                    }

                    ImGui.SameLine();
                }

                if (category.Rank != this.Plugin.CategoryService.MaxRank())
                {
                    if (ImGuiComponents.IconButton(category.Id + 2, FontAwesomeIcon.ArrowDown))
                    {
                        this.Plugin.CategoryService.DecreaseCategoryRank(category.Id);
                    }

                    ImGui.SameLine();
                }

                if (ImGuiComponents.IconButton(category.Id, FontAwesomeIcon.Redo))
                {
                    category.Reset();
                    this.Plugin.CategoryService.SaveCategory(category);
                }

                ImGui.SameLine();

                if (!category.IsDefault)
                {
                    if (ImGuiComponents.IconButton(category.Id + 3, FontAwesomeIcon.Trash))
                    {
                        this.Plugin.CategoryService.DeleteCategory(category.Id);
                    }
                }

                ImGui.NextColumn();
            }

            ImGui.Separator();
        }
コード例 #15
0
ファイル: ImWindow.cs プロジェクト: rahmiy/inVtero.net
        private unsafe void SubmitImGuiStuff()
        {
            ImGui.GetStyle().WindowRounding = 0;

            ImGui.SetNextWindowSize(new System.Numerics.Vector2(_nativeWindow.Width - 10, _nativeWindow.Height - 20), SetCondition.Always);
            ImGui.SetNextWindowPosCenter(SetCondition.Always);
            ImGui.BeginWindow("ImGUI.NET Sample Program", ref _mainWindowOpened, WindowFlags.NoResize | WindowFlags.NoTitleBar | WindowFlags.NoMove);

            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("Help"))
            {
                if (ImGui.MenuItem("About", "Ctrl-Alt-A", false, true))
                {
                }
                ImGui.EndMenu();
            }
            ImGui.EndMainMenuBar();

            ImGui.Text("Hello,");
            ImGui.Text("World!");
            ImGui.Text("From ImGui.NET. ...Did that work?");
            var  pos         = ImGui.GetIO().MousePosition;
            bool leftPressed = ImGui.GetIO().MouseDown[0];

            ImGui.Text("Current mouse position: " + pos + ". Pressed=" + leftPressed);

            if (ImGui.Button("Increment the counter."))
            {
                _pressCount += 1;
            }

            ImGui.Text($"Button pressed {_pressCount} times.", new System.Numerics.Vector4(0, 1, 1, 1));

            ImGui.InputTextMultiline("Input some text:",
                                     _textInputBuffer, (uint)_textInputBufferLength,
                                     new System.Numerics.Vector2(360, 240),
                                     InputTextFlags.Default,
                                     OnTextEdited);

            ImGui.SliderFloat("SlidableValue", ref _sliderVal, -50f, 100f, $"{_sliderVal.ToString("##0.00")}", 1.0f);
            ImGui.DragVector3("Vector3", ref _positionValue, -100, 100);

            if (ImGui.TreeNode("First Item"))
            {
                ImGui.Text("Word!");
                ImGui.TreePop();
            }
            if (ImGui.TreeNode("Second Item"))
            {
                ImGui.ColorButton(_buttonColor, false, true);
                if (ImGui.Button("Push me to change color", new System.Numerics.Vector2(120, 30)))
                {
                    _buttonColor = new System.Numerics.Vector4(_buttonColor.Y + .25f, _buttonColor.Z, _buttonColor.X, _buttonColor.W);
                    if (_buttonColor.X > 1.0f)
                    {
                        _buttonColor.X -= 1.0f;
                    }
                }

                ImGui.TreePop();
            }

            if (ImGui.Button("Press me!", new System.Numerics.Vector2(100, 30)))
            {
                ImGuiNative.igOpenPopup("SmallButtonPopup");
            }

            if (ImGui.BeginPopup("SmallButtonPopup"))
            {
                ImGui.Text("Here's a popup menu.");
                ImGui.Text("With two lines.");

                ImGui.EndPopup();
            }

            if (ImGui.Button("Open Modal window"))
            {
                ImGui.OpenPopup("ModalPopup");
            }
            if (ImGui.BeginPopupModal("ModalPopup"))
            {
                ImGui.Text("You can't press on anything else right now.");
                ImGui.Text("You are stuck here.");
                if (ImGui.Button("OK", new System.Numerics.Vector2(0, 0)))
                {
                }
                ImGui.SameLine();
                ImGui.Dummy(100f, 0f);
                ImGui.SameLine();
                if (ImGui.Button("Please go away", new System.Numerics.Vector2(0, 0)))
                {
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }

            ImGui.Text("I have a context menu.");
            if (ImGui.BeginPopupContextItem("ItemContextMenu"))
            {
                if (ImGui.Selectable("How's this for a great menu?"))
                {
                }
                ImGui.Selectable("Just click somewhere to get rid of me.");
                ImGui.EndPopup();
            }

            ImGui.EndWindow();

            _memoryEditor.Draw("Memory editor", _memoryEditorData, _memoryEditorData.Length);

            if (ImGui.GetIO().AltPressed&& ImGui.GetIO().KeysDown[(int)Key.F4])
            {
                _nativeWindow.Close();
            }
        }
コード例 #16
0
ファイル: FrameItemList.cs プロジェクト: wrightjjw/OpenSAGE
        public void Draw(AptSceneManager manager)
        {
            var maybeNew = FrameItemUtilities.Reset(manager, _utilities);

            if (maybeNew is null)
            {
                return;
            }
            if (!ReferenceEquals(_utilities, maybeNew))
            {
                // if this is a different frame (imply _utilities.Active == true)
                ImGui.SetNextWindowSize(new Vector2(0, 0));
                _utilities = maybeNew;
                ResetCreatePlaceObjectForm();
            }

            if (ImGui.Begin(Name))
            {
                var id = _utilities.GetHashCode();

                // frame label
                ImGui.Text("Frame labels");
                ImGui.Button("New Frame label");
                foreach (var label in _utilities.FrameLabels)
                {
                    using var _ = new ImGuiIDHelper("Frame labels", ref id);
                    ImGui.Text($"{label.FrameId}");
                    ImGui.SameLine();
                    ImGui.TextColored(new Vector4(1, 1, 0, 1), label.Name);
                    ImGui.SameLine();
                    ImGui.Text($"{label.Flags}");
                    ImGui.SameLine(ImGui.GetWindowWidth() - 100);
                    ImGui.Button("Remove");
                    ImGui.NewLine();
                    // TODO: is frame label globally visible?
                }
                ImGui.Separator();

                // background color
                if (!_utilities.BackgroundColors.Any())
                {
                    ImGui.Button("Set background color");
                }
                foreach (var color in _utilities.BackgroundColors)
                {
                    using var _ = new ImGuiIDHelper("Background colors", ref id);
                    ImGui.Text("Background Color");
                    ImGui.SameLine();
                    ImGui.ColorButton("Background color", color.Color.ToColorRgbaF().ToVector4());
                    ImGui.SameLine(ImGui.GetWindowWidth() - 100);
                    ImGui.Button("Remove");
                }
                ImGui.Separator();

                // actions
                ImGui.Button("Add frame Action");
                foreach (var item in _utilities.FrameActions)
                {
                    using var _ = new ImGuiIDHelper("Frame actions", ref id);
                    if (ImGui.Button("Frame Action"))
                    {
                        _currentFrameAction = new InstructionEditor(item.Instructions);
                    }
                }
                ImGui.Separator();

                // initActions
                ImGui.Button("Add InitAction");
                var indexColor = new Vector4(0, 1, 1, 1);
                var typeColor  = new Vector4(0, 1, 0, 1);
                foreach (var item in _utilities.InitActions)
                {
                    using var _ = new ImGuiIDHelper("Init actions", ref id);
                    ImGui.TextColored(indexColor, $"{item.Sprite}");
                    ImGui.SameLine(35, 5);
                    if (ImGui.Button("Sprite InitAction"))
                    {
                        _currentFrameAction = new InstructionEditor(item.Instructions);
                    }
                }
                ImGui.Separator();

                // placeobjects
                ImGui.Text("Place commands");
                DrawCreatePlaceObjectForm();
                ImGui.Separator();
                ImGui.Indent(10);
                int?remove = null;
                foreach (var(depth, placeObject) in _utilities.PlaceObjects)
                {
                    using var _ = new ImGuiIDHelper("PlaceObjects", ref id);
                    ImGui.Text($"Depth: {depth}");
                    ImGui.SameLine();
                    if (ImGui.Button("Remove"))
                    {
                        remove = depth;
                    }

                    if (placeObject is null)
                    {
                        ImGui.Text("Remove character in the current depth.");
                        continue;
                    }

                    ImGui.TextColored(typeColor, "Character");

                    ProcessPlaceCharacter(placeObject);
                    ImGui.Spacing();
                    ProcessTransform(placeObject);
                    ImGui.Spacing();
                    ProcessColorTransform(placeObject);
                    ImGui.Spacing();
                    ProcessRatio(placeObject);
                    ImGui.Spacing();
                    ProcessName(placeObject);
                    ImGui.Spacing();
                    ProcessClipEvents(placeObject);
                    ImGui.Separator();
                }
                ImGui.Unindent();

                if (remove is int removeValue)
                {
                    _utilities.RemovePlaceObject(removeValue);
                }
            }
            ImGui.End();

            // Draw Frame's Action / InitAction
            _currentFrameAction?.Draw(manager);
        }
コード例 #17
0
        public override bool Draw()
        {
            bool doTabs = false;

            foreach (var t in openTabs)
            {
                if (t)
                {
                    doTabs = true; break;
                }
            }
            var contentw = ImGui.GetContentRegionAvailableWidth();

            if (doTabs)
            {
                ImGui.Columns(2, "##panels", true);
                if (firstTab)
                {
                    ImGui.SetColumnWidth(0, contentw * 0.23f);
                    firstTab = false;
                }
                ImGui.BeginChild("##tabchild");
                if (openTabs[0])
                {
                    HierachyPanel();
                }
                if (openTabs[1])
                {
                    AnimationPanel();
                }
                ImGui.EndChild();
                ImGui.NextColumn();
            }
            TabButtons();
            ImGui.BeginChild("##main");
            if (ImGui.ColorButton("Background Color", new Vector4(background.R, background.G, background.B, 1),
                                  ColorEditFlags.NoAlpha, new Vector2(22, 22)))
            {
                ImGui.OpenPopup("Background Color###" + Unique);
                editCol = new System.Numerics.Vector3(background.R, background.G, background.B);
            }
            if (ImGui.BeginPopupModal("Background Color###" + Unique, WindowFlags.AlwaysAutoResize))
            {
                ImGui.ColorPicker3("###a", ref editCol);
                if (ImGui.Button("OK"))
                {
                    background = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Default"))
                {
                    var def = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
                    editCol = new System.Numerics.Vector3(def.R, def.G, def.B);
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            ImGui.SameLine();
            ImGui.AlignTextToFramePadding();
            ImGui.Text("Background");
            ImGui.SameLine();
            ImGui.Checkbox("Wireframe", ref doWireframe);
            ImGui.SameLine();
            ImGui.Text("View Mode:");
            ImGui.SameLine();
            ImGui.PushItemWidth(-1);
            ImGui.Combo("##modes", ref viewMode, viewModes);
            ImGui.PopItemWidth();
            DoViewport();
            ImGui.EndChild();
            return(true);
        }
コード例 #18
0
ファイル: ModelViewer.cs プロジェクト: Hal47/Librelancer
        public override void Draw()
        {
            bool doTabs = false;

            popups.Run();
            HardpointEditor();
            PartEditor();
            foreach (var t in openTabs)
            {
                if (t)
                {
                    doTabs = true; break;
                }
            }
            var contentw = ImGui.GetWindowContentRegionWidth();

            if (doTabs)
            {
                ImGui.Columns(2, "##panels", true);
                if (firstTab)
                {
                    ImGui.SetColumnWidth(0, contentw * 0.23f);
                    firstTab = false;
                }
                ImGui.BeginChild("##tabchild");
                if (openTabs[0])
                {
                    HierarchyPanel();
                }
                if (openTabs[1])
                {
                    AnimationPanel();
                }
                if (openTabs[2])
                {
                    SkeletonPanel();
                }
                if (openTabs[3])
                {
                    RenderPanel();
                }
                ImGui.EndChild();
                ImGui.NextColumn();
            }
            TabButtons();
            ImGui.BeginChild("##main");
            if (ImGui.ColorButton("Background Color", new Vector4(background.R, background.G, background.B, 1),
                                  ImGuiColorEditFlags.NoAlpha, new Vector2(22, 22)))
            {
                ImGui.OpenPopup("Background Color###" + Unique);
                editCol = new System.Numerics.Vector3(background.R, background.G, background.B);
            }
            bool wOpen = true;

            if (ImGui.BeginPopupModal("Background Color###" + Unique, ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.ColorPicker3("###a", ref editCol);
                if (ImGui.Button("OK"))
                {
                    background = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Default"))
                {
                    var def = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
                    editCol = new System.Numerics.Vector3(def.R, def.G, def.B);
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            ImGui.SameLine();
            ImGui.AlignTextToFramePadding();
            ImGui.Text("Background");
            ImGui.SameLine();
            ImGui.Checkbox("Starsphere", ref isStarsphere);
            ImGui.SameLine();
            if (hasVWire)
            {
                ImGui.Checkbox("VMeshWire", ref drawVMeshWire);
                ImGui.SameLine();
            }
            if (cameraPart != null)
            {
                ImGui.Checkbox("Cockpit Cam", ref doCockpitCam);
                ImGui.SameLine();
            }
            ImGui.Checkbox("Wireframe", ref doWireframe);
            ImGui.SameLine();
            ImGui.Text("View Mode:");
            ImGui.SameLine();
            ImGui.PushItemWidth(-1);
            ImGui.Combo("##modes", ref viewMode, viewModes, viewModes.Length);
            ImGui.PopItemWidth();
            DoViewport();
            //
            if (ImGui.Button("Reset Camera (Ctrl+R)"))
            {
                ResetCamera();
            }
            ImGui.SameLine();
            //
            if (!(drawable is SphFile) && !(drawable is DF.DfmFile))
            {
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Level of Detail:");
                ImGui.SameLine();
                ImGui.Checkbox("Use Distance", ref useDistance);
                ImGui.SameLine();
                ImGui.PushItemWidth(-1);
                if (useDistance)
                {
                    ImGui.SliderFloat("Distance", ref levelDistance, 0, maxDistance, "%f", 1);
                }
                else
                {
                    ImGui.Combo("Level", ref level, levels, levels.Length);
                }
                ImGui.PopItemWidth();
            }
            ImGui.EndChild();

            if (_window.Config.ViewButtons)
            {
                ImGui.SetNextWindowPos(new Vector2(_window.Width - viewButtonsWidth, 90));
                ImGui.Begin("viewButtons#" + Unique, ImGuiWindowFlags.AlwaysAutoResize |
                            ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove);
                ImGui.Dummy(new Vector2(120, 2));
                ImGui.Columns(2, "##border", false);
                if (ImGui.Button("Top", new Vector2(55, 0)))
                {
                    modelViewport.GoTop();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Bottom", new Vector2(55, 0)))
                {
                    modelViewport.GoBottom();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Left", new Vector2(55, 0)))
                {
                    modelViewport.GoLeft();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Right", new Vector2(55, 0)))
                {
                    modelViewport.GoRight();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Front", new Vector2(55, 0)))
                {
                    modelViewport.GoFront();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Back", new Vector2(55, -1)))
                {
                    modelViewport.GoBack();
                }
                viewButtonsWidth = ImGui.GetWindowWidth() + 60;
                ImGui.End();
            }
        }
コード例 #19
0
        private void PlayerDisplay()
        {
            if (this.SelectedPlayer == null)
            {
                return;
            }
            const float sameLineOffset = 150f;

            // category
            ImGui.Text(Loc.Localize("PlayerCategory", "Category"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
            var categoryNames   = this.plugin.CategoryService.GetCategoryNames().ToArray();
            var categoryIds     = this.plugin.CategoryService.GetCategoryIds().ToArray();
            var currentCategory = this.plugin.CategoryService.GetCategory(this.SelectedPlayer.CategoryId);
            var categoryIndex   = Array.IndexOf(categoryNames, currentCategory.Name);

            ImGui.SetNextItemWidth(150f * ImGuiHelpers.GlobalScale);
            if (ImGui.Combo(
                    "###PlayerTrack_PlayerCategory_Combo",
                    ref categoryIndex,
                    categoryNames,
                    categoryNames.Length))
            {
                this.SelectedPlayer.CategoryId = categoryIds[categoryIndex];
                this.plugin.PlayerService.UpdatePlayerCategory(this.SelectedPlayer);
                this.plugin.NamePlateManager.ForceRedraw();
            }

            ImGuiHelpers.ScaledDummy(0.5f);
            ImGui.Separator();

            // override warning
            ImGui.TextColored(ImGuiColors.DalamudYellow, Loc.Localize(
                                  "OverrideNote",
                                  "These config will override category config."));
            ImGuiHelpers.ScaledDummy(1f);

            // title
            ImGui.Text(Loc.Localize("Title", "Title"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);

            var title = this.SelectedPlayer.Title;

            ImGui.SetNextItemWidth(150f * ImGuiHelpers.GlobalScale);
            if (ImGui.InputText("###PlayerTrack_PlayerTitle_Input", ref title, 30))
            {
                this.SelectedPlayer.Title = title;
                this.plugin.PlayerService.UpdatePlayerTitle(this.SelectedPlayer);
            }

            ImGui.Spacing();

            // icon
            ImGui.Text(Loc.Localize("Icon", "Icon"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);

            ImGui.SetNextItemWidth(150f * ImGuiHelpers.GlobalScale);
            var iconIndex = this.plugin.IconListIndex(this.SelectedPlayer !.Icon);

            if (ImGui.Combo(
                    "###PlayerTrack_PlayerIcon_Combo",
                    ref iconIndex,
                    this.plugin.IconListNames(),
                    this.plugin.IconListNames().Length))
            {
                this.SelectedPlayer.Icon = this.plugin.IconListCodes()[iconIndex];
                this.plugin.PlayerService.UpdatePlayerIcon(this.SelectedPlayer);
            }

            ImGui.SameLine();
            ImGui.PushFont(UiBuilder.IconFont);
            ImGui.TextColored(
                ImGuiColors.DalamudWhite,
                ((FontAwesomeIcon)this.SelectedPlayer.Icon).ToIconString());
            ImGui.PopFont();
            ImGui.Spacing();

            // visibility
            ImGui.Text(Loc.Localize("VisibilityType", "Visibility"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);

            ImGui.SetNextItemWidth(150f * ImGuiHelpers.GlobalScale);
            var visibilityType = (int)this.SelectedPlayer.VisibilityType;

            if (ImGui.Combo(
                    "###PlayerTrack_VisibilityType_Combo",
                    ref visibilityType,
                    Enum.GetNames(typeof(VisibilityType)),
                    Enum.GetNames(typeof(VisibilityType)).Length))
            {
                this.SelectedPlayer.VisibilityType = (VisibilityType)visibilityType;
                this.plugin.PlayerService.UpdatePlayerVisibilityType(this.SelectedPlayer);
            }

            ImGui.Spacing();

            // list color
            ImGui.Text(Loc.Localize("List", "List"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
            var listColor = this.SelectedPlayer.EffectiveListColor();

            if (ImGui.ColorButton("List Color###PlayerTrack_PlayerListColor_Button", listColor))
            {
                ImGui.OpenPopup("###PlayerTrack_PlayerListColor_Popup");
            }

            if (ImGui.BeginPopup("###PlayerTrack_PlayerListColor_Popup"))
            {
                if (ImGui.ColorPicker4("List Color###PlayerTrack_PlayerListColor_ColorPicker", ref listColor))
                {
                    this.SelectedPlayer.ListColor = listColor;
                    if (this.plugin.Configuration.DefaultNamePlateColorToListColor)
                    {
                        this.SelectedPlayer.NamePlateColor = listColor;
                    }

                    this.plugin.PlayerService.UpdatePlayerListColor(this.SelectedPlayer);
                }

                this.PlayerOverride_ListColorSwatchRow(0, 8);
                this.PlayerOverride_ListColorSwatchRow(8, 16);
                this.PlayerOverride_ListColorSwatchRow(16, 24);
                this.PlayerOverride_ListColorSwatchRow(24, 32);
                ImGui.EndPopup();
            }

            // nameplate color
            ImGui.Spacing();
            ImGui.Text(Loc.Localize("Nameplate", "Nameplate"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
            var namePlateColor = this.SelectedPlayer.EffectiveNamePlateColor();

            if (ImGui.ColorButton("NamePlate Color###PlayerTrack_PlayerNamePlateColor_Button", namePlateColor))
            {
                ImGui.OpenPopup("###PlayerTrack_PlayerNamePlateColor_Popup");
            }

            if (ImGui.BeginPopup("###PlayerTrack_PlayerNamePlateColor_Popup"))
            {
                if (ImGui.ColorPicker4("NamePlate Color###PlayerTrack_PlayerNamePlateColor_ColorPicker", ref namePlateColor))
                {
                    this.SelectedPlayer.NamePlateColor = namePlateColor;
                    this.plugin.PlayerService.UpdatePlayerNamePlateColor(this.SelectedPlayer);
                }

                this.PlayerOverride_NamePlateColorSwatchRow(0, 8);
                this.PlayerOverride_NamePlateColorSwatchRow(8, 16);
                this.PlayerOverride_NamePlateColorSwatchRow(16, 24);
                this.PlayerOverride_NamePlateColorSwatchRow(24, 32);
                ImGui.EndPopup();
            }

            // fc name color
            ImGui.Spacing();
            ImGui.Text(Loc.Localize("OverrideFCNameColor", "Override FCNameColor"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
            var overrideFCNameColor = this.SelectedPlayer.OverrideFCNameColor;

            if (ImGui.Checkbox(
                    "###PlayerTrack_PlayerOverrideFCNameColor_Checkbox",
                    ref overrideFCNameColor))
            {
                this.SelectedPlayer.OverrideFCNameColor = overrideFCNameColor;
                this.plugin.PlayerService.UpdatePlayerOverrideFCNameColor(this.SelectedPlayer);
            }

            // alerts
            ImGui.Spacing();
            ImGui.Text(Loc.Localize("Alerts", "Alerts"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
            var isAlertEnabled = this.SelectedPlayer.IsAlertEnabled;

            if (ImGui.Checkbox(
                    "###PlayerTrack_PlayerAlerts_Checkbox",
                    ref isAlertEnabled))
            {
                this.SelectedPlayer.IsAlertEnabled = isAlertEnabled;
                this.plugin.PlayerService.UpdatePlayerAlert(this.SelectedPlayer);
            }

            // reset
            ImGuiHelpers.ScaledDummy(5f);
            if (ImGui.Button(Loc.Localize("Reset", "Reset") + "###PlayerTrack_PlayerOverrideModalReset_Button"))
            {
                this.SelectedPlayer.Reset();
                this.plugin.PlayerService.ResetPlayerOverrides(this.SelectedPlayer);
            }
        }
コード例 #20
0
        public void Draw()
        {
            if (windowOpen)
            {
                ImGui.Begin("Options", ref windowOpen, ImGuiWindowFlags.AlwaysAutoResize);
                var pastC = cFilter;
                ImGui.Combo("Texture Filter", ref cFilter, filters, filters.Length);
                if (cFilter != pastC)
                {
                    SetTexFilter();
                    config.TextureFilter = cFilter;
                }
                ImGui.Combo("Antialiasing", ref cMsaa, msaaStrings, Math.Min(msaaLevels.Length, msaaStrings.Length));
                config.MSAA = msaaLevels[cMsaa];
                ImGui.Checkbox("View Buttons", ref config.ViewButtons);
                ImGui.Checkbox("Pause When Unfocused", ref config.PauseWhenUnfocused);
                if (ViewerControls.GradientButton("Viewport Background", config.Background, config.Background2, new Vector2(22), vps, config.BackgroundGradient))
                {
                    ImGui.OpenPopup("Viewport Background");
                    editCol  = new Vector3(config.Background.R, config.Background.G, config.Background.B);
                    editCol2 = new Vector3(config.Background2.R, config.Background2.G, config.Background2.B);
                    editGrad = config.BackgroundGradient;
                }
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Viewport Background");
                bool wOpen = true;
                if (ImGui.BeginPopupModal("Viewport Background", ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
                {
                    ImGui.Checkbox("Gradient", ref editGrad);

                    ImGui.ColorPicker3(editGrad ? "Top###a" : "###a", ref editCol);
                    if (editGrad)
                    {
                        ImGui.SameLine();
                        ImGui.ColorPicker3("Bottom###b", ref editCol2);
                    }
                    if (ImGui.Button("OK"))
                    {
                        config.Background         = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                        config.Background2        = new Color4(editCol2.X, editCol2.Y, editCol2.Z, 1);
                        config.BackgroundGradient = editGrad;
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Default"))
                    {
                        var def = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
                        editCol  = new Vector3(def.R, def.G, def.B);
                        editGrad = false;
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Cancel"))
                    {
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.EndPopup();
                }
                if (ImGui.ColorButton("Grid Color", config.GridColor, ImGuiColorEditFlags.NoAlpha, new Vector2(22)))
                {
                    ImGui.OpenPopup("Grid Color");
                    editCol = new Vector3(config.GridColor.R, config.GridColor.G, config.GridColor.B);
                }
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Grid Color");
                if (ImGui.BeginPopupModal("Grid Color", ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
                {
                    ImGui.ColorPicker3("###a", ref editCol);
                    if (ImGui.Button("OK"))
                    {
                        config.GridColor = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Default"))
                    {
                        var def = Color4.CornflowerBlue;
                        editCol  = new Vector3(def.R, def.G, def.B);
                        editGrad = false;
                    }
                    ImGui.EndPopup();
                }
                guiHelper.PauseWhenUnfocused = config.PauseWhenUnfocused;
                ImGui.End();
            }
        }
コード例 #21
0
        public bool Draw()
        {
            var isOpen = true;

            try {
                var isSearch = false;
                if (triedLoadingItems == false || pluginConfig.SelectedClientLanguage != plugin.LuminaItemsClientLanguage)
                {
                    UpdateItemList(1000);
                }


                if ((selectedItemIndex < 0 && selectedItem != null) || (selectedItemIndex >= 0 && selectedItem == null))
                {
                    // Should never happen, but just incase
                    selectedItemIndex = -1;
                    selectedItem      = null;
                    return(true);
                }

                ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.FirstUseEver);

                PushStyle(ImGuiStyleVar.WindowMinSize, new Vector2(350, 400));

                if (!ImGui.Begin(Loc.Localize("ItemSearchPlguinMainWindowHeader", "Item Search") + "###itemSearchPluginMainWindow", ref isOpen, ImGuiWindowFlags.NoCollapse))
                {
                    ResetStyle();
                    ImGui.End();
                    return(false);
                }

                PopStyle();

                // Main window
                ImGui.AlignTextToFramePadding();

                if (selectedItem != null)
                {
                    var icon = selectedItem.Icon;

                    if (icon < 65000)
                    {
                        if (plugin.textureDictionary.ContainsKey(icon))
                        {
                            var tex = plugin.textureDictionary[icon];
                            if (tex == null || tex.ImGuiHandle == IntPtr.Zero)
                            {
                                ImGui.PushStyleColor(ImGuiCol.Border, new Vector4(1, 0, 0, 1));
                                ImGui.BeginChild("FailedTexture", new Vector2(45 * ImGui.GetIO().FontGlobalScale), true);
                                ImGui.Text(icon.ToString());
                                ImGui.EndChild();
                                ImGui.PopStyleColor();
                            }
                            else
                            {
                                ImGui.Image(plugin.textureDictionary[icon].ImGuiHandle, new Vector2(45 * ImGui.GetIO().FontGlobalScale));
                            }
                        }
                        else
                        {
                            ImGui.BeginChild("WaitingTexture", new Vector2(45 * ImGui.GetIO().FontGlobalScale), true);
                            ImGui.EndChild();

                            plugin.textureDictionary[icon] = null;

                            Task.Run(() => {
                                try {
                                    var iconTex = this.data.GetIcon(icon);
                                    var tex     = this.builder.LoadImageRaw(iconTex.GetRgbaImageData(), iconTex.Header.Width, iconTex.Header.Height, 4);
                                    if (tex != null && tex.ImGuiHandle != IntPtr.Zero)
                                    {
                                        plugin.textureDictionary[icon] = tex;
                                    }
                                } catch {
                                    // Ignore
                                }
                            });
                        }
                    }
                    else
                    {
                        ImGui.BeginChild("NoIcon", new Vector2(45 * ImGui.GetIO().FontGlobalScale), true);
                        if (pluginConfig.ShowItemID)
                        {
                            ImGui.Text(icon.ToString());
                        }

                        ImGui.EndChild();
                    }


                    ImGui.SameLine();
                    ImGui.BeginGroup();

                    ImGui.Text(selectedItem.Name);

                    if (pluginConfig.ShowItemID)
                    {
                        ImGui.SameLine();
                        ImGui.Text($"(ID: {selectedItem.RowId}) (Rarity: {selectedItem.Rarity})");
                    }

                    var imGuiStyle    = ImGui.GetStyle();
                    var windowVisible = ImGui.GetWindowPos().X + ImGui.GetWindowContentRegionMax().X;

                    IActionButton[] buttons = this.ActionButtons.Where(ab => ab.ButtonPosition == ActionButtonPosition.TOP).ToArray();

                    for (var i = 0; i < buttons.Length; i++)
                    {
                        var button = buttons[i];

                        if (button.GetShowButton(selectedItem))
                        {
                            var buttonText = button.GetButtonText(selectedItem);
                            ImGui.PushID($"TopActionButton{i}");
                            if (ImGui.Button(buttonText))
                            {
                                button.OnButtonClicked(selectedItem);
                            }

                            if (i < buttons.Length - 1)
                            {
                                var lX2 = ImGui.GetItemRectMax().X;
                                var nbw = ImGui.CalcTextSize(buttons[i + 1].GetButtonText(selectedItem)).X + imGuiStyle.ItemInnerSpacing.X * 2;
                                var nX2 = lX2 + (imGuiStyle.ItemSpacing.X * 2) + nbw;
                                if (nX2 < windowVisible)
                                {
                                    ImGui.SameLine();
                                }
                            }

                            ImGui.PopID();
                        }
                    }

                    ImGui.EndGroup();
                }
                else
                {
                    ImGui.BeginChild("NoSelectedItemBox", new Vector2(-1, 45) * ImGui.GetIO().FontGlobalScale);
                    ImGui.Text(Loc.Localize("ItemSearchSelectItem", "Please select an item."));


                    if (!pluginConfig.HideKofi)
                    {
                        ImGui.PushStyleColor(ImGuiCol.Button, 0xFF5E5BFF);
                        ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xFF5E5BAA);
                        ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xFF5E5BDD);
                        ImGui.SameLine(ImGui.GetWindowWidth() - ImGui.CalcTextSize("Support on Ko-fi").X - ImGui.GetStyle().FramePadding.X * 3);
                        if (ImGui.Button("Support on Ko-Fi"))
                        {
                            Process.Start("https://ko-fi.com/Caraxi");
                        }
                        ImGui.PopStyleColor(3);
                    }

                    ImGui.EndChild();
                }

                ImGui.Separator();

                ImGui.Columns(2);
                var filterNameMax = SearchFilters.Where(x => x.IsEnabled && x.ShowFilter).Select(x => {
                    x._LocalizedName      = Loc.Localize(x.NameLocalizationKey, x.Name);
                    x._LocalizedNameWidth = ImGui.CalcTextSize($"{x._LocalizedName}").X;
                    return(x._LocalizedNameWidth);
                }).Max();

                ImGui.SetColumnWidth(0, filterNameMax + ImGui.GetStyle().ItemSpacing.X * 2);
                var filterInUseColour = new Vector4(0, 1, 0, 1);
                foreach (var filter in SearchFilters.Where(x => x.IsEnabled && x.ShowFilter))
                {
                    ImGui.SetCursorPosX((filterNameMax + ImGui.GetStyle().ItemSpacing.X) - filter._LocalizedNameWidth);
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3);
                    if (filter.IsSet)
                    {
                        ImGui.TextColored(filterInUseColour, $"{filter._LocalizedName}: ");
                    }
                    else
                    {
                        ImGui.Text($"{filter._LocalizedName}: ");
                    }

                    ImGui.NextColumn();
                    filter.DrawEditor();
                    while (ImGui.GetColumnIndex() != 0)
                    {
                        ImGui.NextColumn();
                    }
                }

                ImGui.Columns(1);
                var windowSize = ImGui.GetWindowSize();
                var childSize  = new Vector2(0, Math.Max(100 * ImGui.GetIO().FontGlobalScale, windowSize.Y - ImGui.GetCursorPosY() - 45 * ImGui.GetIO().FontGlobalScale));
                ImGui.BeginChild("scrolling", childSize, true, ImGuiWindowFlags.HorizontalScrollbar);

                PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));

                if (errorLoadingItems)
                {
                    ImGui.TextColored(new Vector4(1f, 0.1f, 0.1f, 1.00f), Loc.Localize("ItemSearchListLoadFailed", "Error loading item list."));
                    if (ImGui.SmallButton("Retry"))
                    {
                        UpdateItemList();
                    }
                }
                else if (plugin.LuminaItems != null)
                {
                    if (SearchFilters.Any(x => x.IsEnabled && x.ShowFilter && x.IsSet))
                    {
                        isSearch = true;
                        if (SearchFilters.Any(x => x.IsEnabled && x.ShowFilter && x.HasChanged) || forceReload)
                        {
                            forceReload = false;
                            this.searchCancelTokenSource?.Cancel();
                            this.searchCancelTokenSource = new CancellationTokenSource();
                            var asyncEnum = plugin.LuminaItems.ToAsyncEnumerable();

                            if (!pluginConfig.ShowLegacyItems)
                            {
                                asyncEnum = asyncEnum.Where(x => x.RowId < 100 || x.RowId > 1600);
                            }

                            asyncEnum = SearchFilters.Where(filter => filter.IsEnabled && filter.ShowFilter && filter.IsSet).Aggregate(asyncEnum, (current, filter) => current.Where(filter.CheckFilter));
                            this.selectedItemIndex = -1;
                            selectedItem           = null;
                            this.searchTask        = asyncEnum.ToListAsync(this.searchCancelTokenSource.Token);
                        }

                        if (this.searchTask.IsCompletedSuccessfully)
                        {
                            var   itemSize   = Vector2.Zero;
                            float cursorPosY = 0;
                            var   scrollY    = ImGui.GetScrollY();
                            var   style      = ImGui.GetStyle();
                            for (var i = 0; i < this.searchTask.Result.Count; i++)
                            {
                                if (i == 0 && itemSize == Vector2.Zero)
                                {
                                    itemSize = ImGui.CalcTextSize(this.searchTask.Result[i].Name);
                                    if (!doSearchScroll)
                                    {
                                        var sizePerItem = itemSize.Y + style.ItemSpacing.Y;
                                        var skipItems   = (int)Math.Floor(scrollY / sizePerItem);
                                        cursorPosY = skipItems * sizePerItem;
                                        ImGui.SetCursorPosY(cursorPosY + style.ItemSpacing.X);
                                        i = skipItems;
                                    }
                                }

                                if (!(doSearchScroll && selectedItemIndex == i) && (cursorPosY < scrollY - itemSize.Y || cursorPosY > scrollY + childSize.Y))
                                {
                                    ImGui.SetCursorPosY(cursorPosY + itemSize.Y + style.ItemSpacing.Y);
                                }
                                else if (ImGui.Selectable(this.searchTask.Result[i].Name, this.selectedItemIndex == i, ImGuiSelectableFlags.AllowDoubleClick))
                                {
                                    this.selectedItem      = this.searchTask.Result[i];
                                    this.selectedItemIndex = i;

                                    if (ImGui.IsMouseDoubleClicked(0))
                                    {
                                        if (this.selectedItem != null && selectedItem.Icon < 65000)
                                        {
                                            try {
                                                plugin.LinkItem(selectedItem);
                                                if (pluginConfig.CloseOnChoose)
                                                {
                                                    isOpen = false;
                                                }
                                            } catch (Exception ex) {
                                                PluginLog.LogError(ex.ToString());
                                            }
                                        }
                                    }

                                    if ((autoTryOn = autoTryOn && pluginConfig.ShowTryOn) && plugin.FittingRoomUI.CanUseTryOn && pluginInterface.ClientState.LocalPlayer != null)
                                    {
                                        if (selectedItem.ClassJobCategory.Row != 0)
                                        {
                                            plugin.FittingRoomUI.TryOnItem(selectedItem, selectedStain?.RowId ?? 0);
                                        }
                                    }
                                }

                                if (doSearchScroll && selectedItemIndex == i)
                                {
                                    doSearchScroll = false;
                                    ImGui.SetScrollHereY(0.5f);
                                }

                                cursorPosY = ImGui.GetCursorPosY();

                                if (cursorPosY > scrollY + childSize.Y && !doSearchScroll)
                                {
                                    var c = this.searchTask.Result.Count - i;
                                    ImGui.BeginChild("###scrollFillerBottom", new Vector2(0, c * (itemSize.Y + style.ItemSpacing.Y)), false);
                                    ImGui.EndChild();
                                    break;
                                }
                            }

                            var keyStateDown = ImGui.GetIO().KeysDown[0x28] || pluginInterface.ClientState.KeyState[0x28];
                            var keyStateUp   = ImGui.GetIO().KeysDown[0x26] || pluginInterface.ClientState.KeyState[0x26];

#if DEBUG
                            // Random up/down if both are pressed
                            if (keyStateUp && keyStateDown)
                            {
                                debounceKeyPress = 0;

                                var r = new Random().Next(0, 5);

                                switch (r)
                                {
                                case 1:
                                    keyStateUp   = true;
                                    keyStateDown = false;
                                    break;

                                case 0:
                                    keyStateUp   = false;
                                    keyStateDown = false;
                                    break;

                                default:
                                    keyStateUp   = false;
                                    keyStateDown = true;
                                    break;
                                }
                            }
#endif

                            var hotkeyUsed = false;
                            if (keyStateUp && !keyStateDown)
                            {
                                if (debounceKeyPress == 0)
                                {
                                    debounceKeyPress = 5;
                                    if (selectedItemIndex > 0)
                                    {
                                        hotkeyUsed         = true;
                                        selectedItemIndex -= 1;
                                    }
                                }
                            }
                            else if (keyStateDown && !keyStateUp)
                            {
                                if (debounceKeyPress == 0)
                                {
                                    debounceKeyPress = 5;
                                    if (selectedItemIndex < searchTask.Result.Count - 1)
                                    {
                                        selectedItemIndex += 1;
                                        hotkeyUsed         = true;
                                    }
                                }
                            }
                            else if (debounceKeyPress > 0)
                            {
                                debounceKeyPress -= 1;
                                if (debounceKeyPress < 0)
                                {
                                    debounceKeyPress = 5;
                                }
                            }

                            if (hotkeyUsed)
                            {
                                doSearchScroll    = true;
                                this.selectedItem = this.searchTask.Result[selectedItemIndex];
                                if ((autoTryOn = autoTryOn && pluginConfig.ShowTryOn) && plugin.FittingRoomUI.CanUseTryOn && pluginInterface.ClientState.LocalPlayer != null)
                                {
                                    if (selectedItem.ClassJobCategory.Row != 0)
                                    {
                                        plugin.FittingRoomUI.TryOnItem(selectedItem, selectedStain?.RowId ?? 0);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        ImGui.TextColored(new Vector4(0.86f, 0.86f, 0.86f, 1.00f), Loc.Localize("DalamudItemSelectHint", "Type to start searching..."));

                        this.selectedItemIndex = -1;
                        selectedItem           = null;
                    }
                }
                else
                {
                    ImGui.TextColored(new Vector4(0.86f, 0.86f, 0.86f, 1.00f), Loc.Localize("DalamudItemSelectLoading", "Loading item list..."));
                }

                PopStyle();

                ImGui.EndChild();

                // Darken choose button if it shouldn't be clickable
                PushStyle(ImGuiStyleVar.Alpha, this.selectedItemIndex < 0 || selectedItem == null || selectedItem.Icon >= 65000 ? 0.25f : 1);

                if (ImGui.Button(Loc.Localize("Choose", "Choose")))
                {
                    try {
                        if (selectedItem != null && selectedItem.Icon < 65000)
                        {
                            plugin.LinkItem(selectedItem);
                            if (pluginConfig.CloseOnChoose)
                            {
                                isOpen = false;
                            }
                        }
                    } catch (Exception ex) {
                        Log.Error($"Exception in Choose: {ex.Message}");
                    }
                }

                PopStyle();

                if (!pluginConfig.CloseOnChoose)
                {
                    ImGui.SameLine();
                    if (ImGui.Button(Loc.Localize("Close", "Close")))
                    {
                        selectedItem = null;
                        isOpen       = false;
                    }
                }

                if (this.selectedItemIndex >= 0 && this.selectedItem != null && selectedItem.Icon >= 65000)
                {
                    ImGui.SameLine();
                    ImGui.Text(Loc.Localize("DalamudItemNotLinkable", "This item is not linkable."));
                }

                if (pluginConfig.ShowTryOn && pluginInterface.ClientState.LocalPlayer != null)
                {
                    ImGui.SameLine();
                    if (ImGui.Checkbox(Loc.Localize("ItemSearchTryOnButton", "Try On"), ref autoTryOn))
                    {
                        pluginConfig.TryOnEnabled = autoTryOn;
                        pluginConfig.Save();
                    }

                    ImGui.SameLine();


                    ImGui.PushStyleColor(ImGuiCol.Border, selectedStain != null && selectedStain.Unknown4 ? new Vector4(1, 1, 0, 1) : new Vector4(1, 1, 1, 1));
                    PushStyle(ImGuiStyleVar.FrameBorderSize, 2f);
                    if (ImGui.ColorButton("X", selectedStainColor, ImGuiColorEditFlags.NoTooltip))
                    {
                        showStainSelector = true;
                    }

                    if (ImGui.IsItemClicked(1))
                    {
                        selectedStainColor = Vector4.Zero;
                        selectedStain      = null;
                    }

                    PopStyle();

                    ImGui.PopStyleColor();

                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
                        ImGui.SetTooltip(selectedStain == null ? "No Dye Selected" : selectedStain.Name);
                    }
                }

                var configText    = Loc.Localize("ItemSearchConfigButton", "Config");
                var itemCountText = isSearch ? string.Format(Loc.Localize("ItemCount", "{0} Items"), this.searchTask.Result.Count) : $"v{plugin.Version}";
                ImGui.SameLine(ImGui.GetWindowWidth() - (ImGui.CalcTextSize(configText).X + ImGui.GetStyle().ItemSpacing.X) - (ImGui.CalcTextSize(itemCountText).X + ImGui.GetStyle().ItemSpacing.X *(isSearch ? 3 : 2)));
                if (isSearch)
                {
                    if (ImGui.Button(itemCountText))
                    {
                        PluginLog.Log("Copying results to Clipboard");

                        var sb = new StringBuilder();

                        if (pluginConfig.PrependFilterListWithCopy)
                        {
                            foreach (var f in SearchFilters.Where(f => f.IsSet))
                            {
                                sb.AppendLine($"{f.Name}: {f}");
                            }

                            sb.AppendLine();
                        }

                        foreach (var i in this.searchTask.Result)
                        {
                            sb.AppendLine(i.Name);
                        }

                        System.Windows.Forms.Clipboard.SetText(sb.ToString());
                    }

                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip("Copy results to clipboard");
                    }
                }
                else
                {
                    ImGui.Text(itemCountText);
                }

                ImGui.SameLine(ImGui.GetWindowWidth() - (ImGui.CalcTextSize(configText).X + ImGui.GetStyle().ItemSpacing.X * 2));
                if (ImGui.Button(configText))
                {
                    plugin.ToggleConfigWindow();
                }

                var mainWindowPos  = ImGui.GetWindowPos();
                var mainWindowSize = ImGui.GetWindowSize();

                ImGui.End();


                if (showStainSelector)
                {
                    ImGui.SetNextWindowSize(new Vector2(210, 180));
                    ImGui.SetNextWindowPos(mainWindowPos + mainWindowSize - new Vector2(0, 180));
                    ImGui.Begin("Select Dye", ref showStainSelector, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove);

                    ImGui.BeginTabBar("stainShadeTabs");

                    var unselectedModifier = new Vector4(0, 0, 0, 0.7f);

                    foreach (var shade in stainShadeHeaders)
                    {
                        ImGui.PushStyleColor(ImGuiCol.TabActive, shade.Value);
                        ImGui.PushStyleColor(ImGuiCol.TabHovered, shade.Value);
                        ImGui.PushStyleColor(ImGuiCol.TabUnfocused, shade.Value);
                        ImGui.PushStyleColor(ImGuiCol.TabUnfocusedActive, shade.Value);
                        ImGui.PushStyleColor(ImGuiCol.Tab, shade.Value - unselectedModifier);

                        if (ImGui.BeginTabItem($"    ###StainShade{shade.Key}"))
                        {
                            var c = 0;

                            PushStyle(ImGuiStyleVar.FrameBorderSize, 2f);
                            foreach (var stain in stains.Where(s => s.Shade == shade.Key && !string.IsNullOrEmpty(s.Name)))
                            {
                                var b = stain.Color & 255;
                                var g = (stain.Color >> 8) & 255;
                                var r = (stain.Color >> 16) & 255;

                                var stainColor = new Vector4(r / 255f, g / 255f, b / 255f, 1f);

                                ImGui.PushStyleColor(ImGuiCol.Border, stain.Unknown4 ? new Vector4(1, 1, 0, 1) : new Vector4(1, 1, 1, 1));

                                if (ImGui.ColorButton($"###stain{stain.RowId}", stainColor, ImGuiColorEditFlags.NoTooltip))
                                {
                                    selectedStain              = stain;
                                    selectedStainColor         = stainColor;
                                    showStainSelector          = false;
                                    pluginConfig.SelectedStain = stain.RowId;
                                    pluginConfig.Save();
                                }

                                ImGui.PopStyleColor(1);

                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
                                    ImGui.SetTooltip(stain.Name);
                                }

                                if (c++ < 5)
                                {
                                    ImGui.SameLine();
                                }
                                else
                                {
                                    c = 0;
                                }
                            }

                            PopStyle(1);

                            ImGui.EndTabItem();
                        }

                        ImGui.PopStyleColor(5);
                    }

                    ImGui.EndTabBar();
                    ImGui.End();
                }


                return(isOpen);
            } catch (Exception ex) {
                ResetStyle();
                PluginLog.LogError(ex.ToString());
                selectedItem      = null;
                selectedItemIndex = -1;
                return(isOpen);
            }
        }