Exemple #1
0
        public void Initialize(DalamudPluginInterface pInterface)
        {
            Plugin = this;

            Interface = pInterface;

            Config = (Configuration)Interface.GetPluginConfig() ?? new Configuration();
            Config.Initialize();
            Config.TryBackup(); // Backup on version change

            Interface.Framework.OnUpdateEvent += Update;

            ui = new PluginUI();
            Interface.UiBuilder.OnOpenConfigUi += ToggleConfig;
            Interface.UiBuilder.OnBuildUi      += Draw;

            CheckHideOptOuts();

            commandManager = new PluginCommandManager();

            SetupIPC();

            InitializePointers();

            Task.Run(async() =>
            {
                while (!Config.AlwaysDisplayBars && !ui.configOpen && !IsLoggedIn())
                {
                    await Task.Delay(1000);
                }
                ReadyPlugin();
            });
        }
Exemple #2
0
 public BarUI(QoLBar p, Configuration config, int nbar)
 {
     plugin      = p;
     this.config = config;
     barNumber   = nbar;
     SetupPosition();
 }
Exemple #3
0
        private void RemoveBar(int i)
        {
            if (Config.ExportOnDelete)
            {
                ImGui.SetClipboardText(QoLBar.ExportBar(Config.BarConfigs[i], false));
            }

            bars.RemoveAt(i);
            Config.BarConfigs.RemoveAt(i);
            Config.Save();
            RefreshBarIndexes();
        }
Exemple #4
0
 public bool ToggleBarVisible(int i)
 {
     if (i < 0 || i >= bars.Count)
     {
         QoLBar.PrintError($"Bar #{i + 1} does not exist.");
         return(false);
     }
     else
     {
         bars[i].ToggleVisible();
         return(true);
     }
 }
Exemple #5
0
        public PluginUI(QoLBar p, Configuration config)
        {
            plugin      = p;
            this.config = config;

            bars = new List <BarUI>();
            for (int i = 0; i < config.BarConfigs.Count; i++)
            {
                bars.Add(new BarUI(p, config, i));
            }

            plugin.LoadIcon(46); // Magnifying glass / Search
            plugin.LoadIcon(QoLBar.FrameIconID, "ui/uld/icona_frame.tex");
        }
Exemple #6
0
        private void DeleteFile(FileInfo file)
        {
            try
            {
                if (file.Extension != ".json")
                {
                    throw new InvalidOperationException("File must be json!");
                }

                file.Delete();
                PluginLog.LogInformation($"Deleted file {file.FullName}");
            }
            catch (Exception e)
            {
                QoLBar.PrintError($"Failed to delete: {e.Message}");
            }
        }
Exemple #7
0
        public bool ToggleBarVisible(string name)
        {
            var found = false;

            for (int i = 0; i < bars.Count; ++i)
            {
                if (Config.BarConfigs[i].Title == name)
                {
                    found = ToggleBarVisible(i) || found;
                }
            }
            if (!found)
            {
                QoLBar.PrintError($"Bar \"{name}\" does not exist.");
            }

            return(found);
        }
Exemple #8
0
        private void BackupFile(FileInfo file, string name = "", bool overwrite = false)
        {
            try
            {
                if (file.Extension != ".json")
                {
                    throw new InvalidOperationException("File must be json!");
                }

                if (string.IsNullOrEmpty(name))
                {
                    name = DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss");
                }

                var path = Config.GetPluginBackupPath() + $"\\{name}.json";
                file.CopyTo(path, overwrite);
                PluginLog.LogInformation($"Saved file to {path}");
            }
            catch (Exception e)
            {
                QoLBar.PrintError($"Failed to save: {e.Message}");
            }
        }
Exemple #9
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}");
         }
     }
 }
Exemple #10
0
        public void Draw()
        {
            if (!IsVisible)
            {
                return;
            }

            IconBrowserUI.Draw();

            if (Config.AlwaysDisplayBars || QoLBar.IsLoggedIn())
            {
                foreach (BarUI bar in bars)
                {
                    bar.Draw();
                }
            }
            lastConfigPopupOpen = configPopupOpen;
            configPopupOpen     = false;

            if (configOpen)
            {
                DrawPluginConfig();
            }
        }
Exemple #11
0
 public string ExportBar(int i, bool saveAllValues) => QoLBar.ExportBar(Config.BarConfigs[i], saveAllValues);
Exemple #12
0
        public static Vector4 AnimateColor(Vector4 c)
        {
            float r, g, b, a, x;

            r = g = b = a = 1;
            var t    = QoLBar.GetDrawTime();
            var anim = Math.Round(c.W * 255) - 256;

            switch (anim)
            {
            case 0:     // Slow Rainbow
                ImGui.ColorConvertHSVtoRGB(((t * 15) % 360) / 360, 1, 1, out r, out g, out b);
                break;

            case 1:     // Rainbow
                ImGui.ColorConvertHSVtoRGB(((t * 30) % 360) / 360, 1, 1, out r, out g, out b);
                break;

            case 2:     // Fast Rainbow
                ImGui.ColorConvertHSVtoRGB(((t * 60) % 360) / 360, 1, 1, out r, out g, out b);
                break;

            case 3:     // Slow Fade
                r = c.X; g = c.Y; b = c.Z;
                a = (float)(Math.Sin(((t * 30) % 360) * Math.PI / 180) + 1) / 2;
                break;

            case 4:     // Fade
                r = c.X; g = c.Y; b = c.Z;
                a = (float)(Math.Sin(((t * 60) % 360) * Math.PI / 180) + 1) / 2;
                break;

            case 5:     // Fast Fade
                r = c.X; g = c.Y; b = c.Z;
                a = (float)(Math.Sin(((t * 120) % 360) * Math.PI / 180) + 1) / 2;
                break;

            case 6:     // Red Transition
                x = Math.Abs(((t * 60) % 360) - 180) / 180;
                r = c.X + (1 - c.X) * x;
                g = c.Y + (0 - c.Y) * x;
                b = c.Z + (0 - c.Z) * x;
                break;

            case 7:     // Yellow Transition
                x = Math.Abs(((t * 60) % 360) - 180) / 180;
                r = c.X + (1 - c.X) * x;
                g = c.Y + (1 - c.Y) * x;
                b = c.Z + (0 - c.Z) * x;
                break;

            case 8:     // Green Transition
                x = Math.Abs(((t * 60) % 360) - 180) / 180;
                r = c.X + (0 - c.X) * x;
                g = c.Y + (1 - c.Y) * x;
                b = c.Z + (0 - c.Z) * x;
                break;

            case 9:     // Cyan Transition
                x = Math.Abs(((t * 60) % 360) - 180) / 180;
                r = c.X + (0 - c.X) * x;
                g = c.Y + (1 - c.Y) * x;
                b = c.Z + (1 - c.Z) * x;
                break;

            case 10:     // Blue Transition
                x = Math.Abs(((t * 60) % 360) - 180) / 180;
                r = c.X + (0 - c.X) * x;
                g = c.Y + (0 - c.Y) * x;
                b = c.Z + (1 - c.Z) * x;
                break;

            case 11:     // Purple Transition
                x = Math.Abs(((t * 60) % 360) - 180) / 180;
                r = c.X + (1 - c.X) * x;
                g = c.Y + (0 - c.Y) * x;
                b = c.Z + (1 - c.Z) * x;
                break;

            case 12:     // White Transition
                x = Math.Abs(((t * 60) % 360) - 180) / 180;
                r = c.X + (1 - c.X) * x;
                g = c.Y + (1 - c.Y) * x;
                b = c.Z + (1 - c.Z) * x;
                break;

            case 13:     // Black Transition
                x = Math.Abs(((t * 60) % 360) - 180) / 180;
                r = c.X + (0 - c.X) * x;
                g = c.Y + (0 - c.Y) * x;
                b = c.Z + (0 - c.Z) * x;
                break;
            }

            return(new Vector4(r, g, b, a));
        }