Exemplo n.º 1
0
        private static void CleanBarConfig(BarConfig bar)
        {
            if (bar.DockSide == BarConfig.BarDock.UndockedH || bar.DockSide == BarConfig.BarDock.UndockedV)
            {
                bar.Alignment       = bar.GetDefaultValue(x => x.Alignment);
                bar.RevealAreaScale = bar.GetDefaultValue(x => x.RevealAreaScale);
                bar.Offset          = bar.GetDefaultValue(x => x.Offset);
                bar.Hint            = bar.GetDefaultValue(x => x.Hint);
            }
            else
            {
                bar.LockedPosition  = bar.GetDefaultValue(x => x.LockedPosition);
                bar.Position        = bar.GetDefaultValue(x => x.Position);
                bar.RevealAreaScale = bar.GetDefaultValue(x => x.RevealAreaScale);

                if (bar.Visibility == BarConfig.VisibilityMode.Always)
                {
                    bar.RevealAreaScale = bar.GetDefaultValue(x => x.RevealAreaScale);
                    bar.Hint            = bar.GetDefaultValue(x => x.Hint);
                }
            }
            // Cursed optimization...
            if (bar.CategorySpacing.X == 8 && bar.CategorySpacing.Y == 4)
            {
                bar.CategorySpacing = bar.GetDefaultValue(x => x.CategorySpacing);
            }
            else if (bar.CategorySpacing == Vector2.Zero)
            {
                bar.CategorySpacing = new Vector2(0.1f);
            }

            CleanShortcut(bar.ShortcutList);
        }
Exemplo n.º 2
0
 public static string ExportBar(BarConfig bar, bool saveAllValues)
 {
     if (!saveAllValues)
     {
         bar = CopyObject(bar);
         CleanBarConfig(bar);
     }
     return(ExportObject(bar, saveAllValues));
 }
Exemplo n.º 3
0
 public void ImportBar(string import)
 {
     try
     {
         AddBar(QoLBar.ImportBar(import));
     }
     catch (Exception e) // Try as a shortcut instead
     {
         try
         {
             var sh  = QoLBar.ImportShortcut(ImGui.GetClipboardText());
             var bar = new BarConfig();
             bar.ShortcutList.Add(sh);
             AddBar(bar);
         }
         catch (Exception e2)
         {
             PluginLog.LogError("Invalid import string!");
             PluginLog.LogError($"{e.GetType()}\n{e.Message}");
             PluginLog.LogError($"{e2.GetType()}\n{e2.Message}");
         }
     }
 }
Exemplo n.º 4
0
 private void AddBar(BarConfig bar)
 {
     Config.BarConfigs.Add(bar);
     bars.Add(new BarUI(bars.Count));
     Config.Save();
 }
Exemplo n.º 5
0
        private void DrawPluginConfigWindow()
        {
            ImGui.SetNextWindowSizeConstraints(new Vector2(588, 500), ImGui.GetIO().DisplaySize);
            ImGui.Begin("QoL Bar Configuration", ref configOpen);

            if (ImGui.Checkbox("Export on Delete", ref config.ExportOnDelete))
            {
                config.Save();
            }
            ImGui.SameLine(ImGui.GetWindowWidth() / 2);
            if (ImGui.Checkbox("Resizing Repositions Bars", ref config.ResizeRepositionsBars))
            {
                config.Save();
            }
            if (ImGui.IsItemHovered())
            {
                ImGui.SetTooltip("Undocked bars will automatically readjust if you change resolutions.");
            }
            if (ImGui.Checkbox("Use Hotbar Frames on Icons", ref config.UseIconFrame))
            {
                config.Save();
            }
            if (ImGui.IsItemHovered())
            {
                ImGui.SetTooltip("Might cause lag.");
            }

            ImGui.Spacing();
            ImGui.Spacing();
            ImGui.Spacing();
            ImGui.Spacing();
            ImGui.SameLine(30);
            ImGui.Text("Bar Manager");
            ImGui.Spacing();
            ImGui.Separator();

            Vector2 textsize = new Vector2(-1, 0);
            float   textx    = 0.0f;

            ImGui.Columns(3, "QoLBarsList", false);
            for (int i = 0; i < bars.Count; i++)
            {
                ImGui.PushID(i);

                ImGui.Text($"#{i + 1}");
                ImGui.SameLine();

                textx = ImGui.GetCursorPosX();

                ImGui.SetNextItemWidth(-1);
                if (ImGui.InputText("##Title", ref config.BarConfigs[i].Title, 32))
                {
                    config.Save();
                }

                textsize = ImGui.GetItemRectSize();

                ImGui.NextColumn();

                if (ImGui.Button("O"))
                {
                    ImGui.OpenPopup($"BarConfig##{i}");
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Options");
                }
                bars[i].BarConfigPopup();
                ImGui.SameLine();
                if (ImGui.Button(config.BarConfigs[i].Hidden ? "R" : "H"))
                {
                    bars[i].ToggleVisible();
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip(config.BarConfigs[i].Hidden ? "Reveal" : "Hide");
                }

                ImGui.NextColumn();

                if (ImGui.Button("↑") && i > 0)
                {
                    var b = bars[i];
                    bars.RemoveAt(i);
                    bars.Insert(i - 1, b);

                    var b2 = config.BarConfigs[i];
                    config.BarConfigs.RemoveAt(i);
                    config.BarConfigs.Insert(i - 1, b2);
                    config.Save();
                    RefreshBarIndexes();
                }
                ImGui.SameLine();
                if (ImGui.Button("↓") && i < (bars.Count - 1))
                {
                    var b = bars[i];
                    bars.RemoveAt(i);
                    bars.Insert(i + 1, b);

                    var b2 = config.BarConfigs[i];
                    config.BarConfigs.RemoveAt(i);
                    config.BarConfigs.Insert(i + 1, b2);
                    config.Save();
                    RefreshBarIndexes();
                }
                ImGui.SameLine();
                if (ImGui.Button("Export"))
                {
                    ImGui.SetClipboardText(plugin.ExportBar(config.BarConfigs[i], false));
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Export to clipboard without default settings (May change with updates).\n" +
                                     "Right click to export with every setting (Longer string, doesn't change).");

                    if (ImGui.IsMouseReleased(1))
                    {
                        ImGui.SetClipboardText(plugin.ExportBar(config.BarConfigs[i], true));
                    }
                }

                if (i > 0)
                {
                    ImGui.SameLine();
                    if (ImGui.Button(config.ExportOnDelete ? "Cut" : "Delete"))
                    {
                        plugin.ExecuteCommand("/echo <se> Right click to delete!");
                    }
                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip($"Right click this button to delete bar #{i + 1}!" +
                                         (config.ExportOnDelete ? "\nThe bar will be exported to clipboard first." : ""));

                        if (ImGui.IsMouseReleased(1))
                        {
                            if (config.ExportOnDelete)
                            {
                                ImGui.SetClipboardText(plugin.ExportBar(config.BarConfigs[i], false));
                            }

                            bars.RemoveAt(i);
                            config.BarConfigs.RemoveAt(i);
                            config.Save();
                            RefreshBarIndexes();
                        }
                    }
                }

                ImGui.NextColumn();

                ImGui.PopID();
            }

            ImGui.Separator();
            ImGui.Spacing();
            ImGui.SameLine(textx);
            if (ImGui.Button("+", textsize))
            {
                AddBar(new BarConfig());
            }
            ImGui.NextColumn();
            ImGui.NextColumn();
            if (ImGui.Button("Import", textsize))
            {
                try
                {
                    AddBar(plugin.ImportBar(ImGui.GetClipboardText()));
                }
                catch (Exception e) // Try as a shortcut instead
                {
                    try
                    {
                        var sh  = plugin.ImportShortcut(ImGui.GetClipboardText());
                        var bar = new BarConfig();
                        bar.ShortcutList.Add(sh);
                        AddBar(bar);
                    }
                    catch (Exception e2)
                    {
                        PluginLog.LogError("Invalid import string!");
                        PluginLog.LogError($"{e.GetType()}\n{e.Message}");
                        PluginLog.LogError($"{e2.GetType()}\n{e2.Message}");
                    }
                }
            }
            if (ImGui.IsItemHovered())
            {
                ImGui.SetTooltip("Import a bar from the clipboard,\n" +
                                 "or import a single shortcut as a new bar.");
            }

            ImGui.Columns(1); // I just wanna know who did this and where they live

            ImGui.End();
        }
Exemplo n.º 6
0
 private void AddBar(BarConfig bar)
 {
     config.BarConfigs.Add(bar);
     bars.Add(new BarUI(plugin, config, bars.Count));
     config.Save();
 }
Exemplo n.º 7
0
 public string ExportBar(BarConfig bar, bool saveAllValues)
 {
     CleanBarConfig(bar);
     return(ExportObject(bar, saveAllValues));
 }
Exemplo n.º 8
0
 private void CleanBarConfig(BarConfig bar)
 {
     CleanShortcuts(bar.ShortcutList);
 }