Exemplo n.º 1
0
        public void Enable(bool force = false)
        {
            if (!force && _config.AlarmsEnabled)
            {
                return;
            }

            UpdateNodes();
            _config.AlarmsEnabled        = true;
            _pi.Framework.OnUpdateEvent += OnUpdate;
            _pi.SavePluginConfig(_config);
        }
Exemplo n.º 2
0
        private void UiBuilder_OnBuildUi()
        {
            if (!_isMainConfigWindowDrawing)
            {
                return;
            }
            ImGui.SetNextWindowSize(new Vector2(500, 200));

            if (ImGui.Begin("Owofy Config", ref _isMainConfigWindowDrawing,
                            ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar))
            {
                ImGui.Text(_owofyConfigWelcome);
                ImGui.Separator();

                ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(1, 3));

                ImGui.Checkbox(Config.OwofySystemMessages ? Owofy(_owofySystemMessage) : _owofySystemMessage,
                               ref Config.OwofySystemMessages);
                ImGui.Checkbox(Config.OwofyPlayerChats ? Owofy(_owofyPlayerMessage) : _owofyPlayerMessage,
                               ref Config.OwofyPlayerChats);
                ImGui.Checkbox(Config.OwofyEmotes ? "Owofy emeowets" : "Owofy emotes", ref Config.OwofyEmotes);

                ImGui.PopStyleVar();

                if (ImGui.Button("Save and Close"))
                {
                    _isMainConfigWindowDrawing = false;
                    _pi.SavePluginConfig(Config);
                }

                ImGui.End();
            }
        }
Exemplo n.º 3
0
 private void SaveConfig()
 {
     _configuration.Enabled   = _enabled;
     _configuration.SlideTime = _slideTime;
     _configuration.SlideCol  = _slideCol;
     _pI.SavePluginConfig(_configuration);
 }
Exemplo n.º 4
0
    private static Configuration GetAndMigrateConfig(DalamudPluginInterface pi)
    {
        var config = pi.GetPluginConfig() as Configuration ?? new Configuration();

        switch (config.Version)
        {
        case 0: {
            SimpleLog.Debug("Migrate configuration 0 to version 1:");
            SimpleLog.Debug($"HideInCombat: ${config.HideInCombat}");
            config.Visibility = config.HideInCombat ? CompassVisibility.NotInCombat : CompassVisibility.Always;
            config.Version    = 1;
            pi.SavePluginConfig(config);
            break;
        }
        }

        // NOTE: Technical debt; This array is order-sensitive as it is used in combination with
        //  Configuration.ShouldHideOnUiObjectSerializer. There were problems serializing a Dictionary,
        //  but apart from that I am unsure why _this_ was the solution I came up with. Oh well.
        config.ShouldHideOnUiObject = Constant.InitialUiObjectArray;
        for (var i = 0; i < config.ShouldHideOnUiObjectSerializer.Length; i++)
        {
            config.ShouldHideOnUiObject[i].disable = config.ShouldHideOnUiObjectSerializer[i];
        }
        if (config.ShouldHideOnUiObjectSerializer.Length < config.ShouldHideOnUiObject.Length)
        {
            Array.Resize(ref config.ShouldHideOnUiObjectSerializer, config.ShouldHideOnUiObject.Length);
        }

        return(config);
    }
Exemplo n.º 5
0
    private void CommandHandler(string _command, string args)
    {
        switch (args)
        {
        case "toggle":
            _config.ImGuiCompassEnable ^= true;
            _compass.UpdateCachedVariables();
            break;

        case "on":
            _config.ImGuiCompassEnable = true;
            _compass.UpdateCachedVariables();
            break;

        case "off":
            _config.ImGuiCompassEnable = false;
            break;

        case "togglep":
            _config.ImGuiCompassEnable ^= true;
            _compass.UpdateCachedVariables();
            _pluginInterface.SavePluginConfig(_config);
            break;

        case "onp":
            _config.ImGuiCompassEnable = true;
            _compass.UpdateCachedVariables();
            _pluginInterface.SavePluginConfig(_config);
            break;

        case "offp":
            _config.ImGuiCompassEnable = false;
            _pluginInterface.SavePluginConfig(_config);
            break;

        default:
            OnOpenConfigUi();
            break;
        }
    }
Exemplo n.º 6
0
 private void SaveConfig()
 {
     _configuration.Enabled   = _enabled;
     _configuration.Combat    = _combat;
     _configuration.Circle    = _circle;
     _configuration.Instance  = _instance;
     _configuration.Col       = _col;
     _configuration.Col2      = _col2;
     _configuration.ColRing   = _colRing;
     _configuration.Thickness = _thickness;
     _configuration.Segments  = _segments;
     _configuration.Ring      = _ring;
     _configuration.Radius    = _radius;
     _pluginInterface.SavePluginConfig(_configuration);
 }
Exemplo n.º 7
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            _pi     = pluginInterface;
            _config = (Config)_pi.GetPluginConfig() ?? new Config();
            _pi.SavePluginConfig(_config);

            _pi.CommandManager.AddHandler(CommandName, PluginCommand());

            _ui = new Ui(this, _pi, _config);

            _pi.UiBuilder.OnBuildUi      += _ui.BuildUi;
            _pi.UiBuilder.OnOpenConfigUi += _ui.OnOpenConfigUI;

            _watcher = new Watcher(_pi, _config.Items);

            _pi.Framework.OnUpdateEvent += _watcher.FrameworkUpdateEvent;

            PluginLog.Log($"{Name} loaded");
        }
Exemplo n.º 8
0
        private void UiBuilder_OnBuildUi()
        {
            if (!_isMainConfigWindowDrawing)
            {
                return;
            }
            ImGui.SetNextWindowSize(new Vector2(750, 520));

            if (ImGui.Begin("RichPresence Config", ref _isMainConfigWindowDrawing,
                            ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar))
            {
                ImGui.Text("This window allows you to configure Discord Rich Presence.");
                ImGui.Text("Please make sure Discord is not running as admin and you have game activity enabled.");
                ImGui.Separator();

                ImGui.BeginChild("scrolling", new Vector2(0, 400), true, ImGuiWindowFlags.HorizontalScrollbar);

                ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(1, 3));

                ImGui.Checkbox("Show name", ref Config.ShowName);
                ImGui.Checkbox("Show world", ref Config.ShowWorld);
                ImGui.Separator();
                ImGui.Checkbox("Show start time", ref Config.ShowStartTime);
                ImGui.Checkbox("Reset start time when changing zones", ref Config.ResetTimeWhenChangingZones);

                ImGui.PopStyleVar();

                ImGui.EndChild();

                ImGui.Separator();

                if (ImGui.Button("Save and Close"))
                {
                    _isMainConfigWindowDrawing = false;
                    _pi.SavePluginConfig(Config);
                    PluginLog.Log("RP saved.");
                }

                ImGui.End();
            }
        }
Exemplo n.º 9
0
        private void UiBuilder_OnBuildUi()
        {
            if (!isImguiTitleEditOpen)
            {
                return;
            }

            ImGui.SetNextWindowSize(new Vector2(600, 250));

            ImGui.Begin("Title Editing", ref isImguiTitleEditOpen,
                        ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar);

            ImGui.Text("This window allows you to change what title screen plays when you start the game.");
            ImGui.Separator();

            ImGui.BeginChild("scrolling", new Vector2(0, 150), true, ImGuiWindowFlags.HorizontalScrollbar);

            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 3));

            ImGui.Combo("Title screen expac to use", ref ExpacNum, ExpacNames, ExpacNames.Length);

            ImGui.PopStyleVar();

            ImGui.EndChild();

            ImGui.Separator();

            if (ImGui.Button("Save and Close"))
            {
                UpdateConfig();
                pluginInterface.SavePluginConfig(Configuration);

                SetNewConfig();
                isImguiTitleEditOpen = false;
            }

            ImGui.Spacing();
            ImGui.End();
        }
Exemplo n.º 10
0
 public void Save(bool failed = false)
 {
     try
     {
         pluginInterface.SavePluginConfig(this);
     }
     catch
     {
         if (!failed)
         {
             PluginLog.LogError("Failed to save! Retrying...");
             Save(true);
         }
         else
         {
             PluginLog.LogError("Failed to save again :(");
             var chat = pluginInterface.Framework.Gui.Chat;
             chat.PrintChat(new XivChatEntry {
                 MessageBytes = Encoding.UTF8.GetBytes("[QoLBar] Error saving config, is something else writing to it?")
             });
         }
     }
 }
Exemplo n.º 11
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            commandManager.Dispose();
            pluginInterface.SavePluginConfig(config);

            pluginInterface.UiBuilder.OnOpenConfigUi -= ToggleConfig;
            pluginInterface.UiBuilder.OnBuildUi      -= ui.Draw;
            pluginInterface.ClientState.OnLogin      -= InitCommands;

            pluginInterface.Dispose();

            ui.Dispose();

            foreach (var t in textureDictionary)
            {
                t.Value?.Dispose();
            }
        }
Exemplo n.º 12
0
 internal void SaveConfiguration() => Interface.SavePluginConfig(Configuration);
Exemplo n.º 13
0
 private void SaveSettings()
 {
     saveDebounceTimer?.Dispose();
     saveDebounceTimer = null;
     pluginInterface.SavePluginConfig(Config);
 }
Exemplo n.º 14
0
        private void UiBuilder_OnBuildUi()
        {
            if (_showRestartMessage)
            {
                ImGui.SetNextWindowSize(new Vector2(600, 400));

                ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
                if (_showRestartMessage && ImGui.Begin("Character Sync Message",
                                                       ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoTitleBar))
                {
                    ImGui.Image(_warningTex.ImGuiHandle, new Vector2(600, 400));
                }
                ImGui.PopStyleVar();
            }

            if (_isMainConfigWindowDrawing)
            {
                ImGui.SetNextWindowSize(new Vector2(750, 520));

                if (_isMainConfigWindowDrawing && ImGui.Begin("Character Sync Config", ref _isMainConfigWindowDrawing,
                                                              ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar))
                {
                    ImGui.Text("This window allows you to configure Character Sync.");
                    ImGui.Text("Click the button below while being logged in on your main character - all logins from now on will use this character's save data!");
                    ImGui.Text("None of your save data will be modified.");
                    ImGui.Text("Please note that it is recommended to restart your game after changing these settings.");
                    ImGui.Separator();

                    if (_pi.ClientState.LocalPlayer == null)
                    {
                        ImGui.Text("Please log in before using this plugin.");
                    }
                    else
                    {
                        if (ImGui.Button("Set save data to current character"))
                        {
                            Config.Cid     = _pi.ClientState.LocalContentId;
                            Config.SetName = $"{_pi.ClientState.LocalPlayer.Name} on {_pi.ClientState.LocalPlayer.HomeWorld.GameData.Name}";
                            _pi.SavePluginConfig(Config);
                            PluginLog.Log("CS saved.");
                        }

                        if (Config.Cid == 0)
                        {
                            ImGui.Text("No character was set as main character yet.");
                            ImGui.Text("Please click the button above while being logged in on your main character.");
                        }
                        else
                        {
                            ImGui.Text($"Currently set to {Config.SetName}(FFXIV_CHR{Config.Cid:X16})");
                        }

                        ImGui.Dummy(new Vector2(5, 5));

                        ImGui.Text($"The logged in character is {_pi.ClientState.LocalPlayer.Name} on {_pi.ClientState.LocalPlayer.HomeWorld.GameData.Name}(FFXIV_CHR{_pi.ClientState.LocalContentId:X16})");

                        ImGui.Dummy(new Vector2(20, 20));

                        ImGui.Checkbox("Sync Hotbars", ref Config.SyncHotbars);
                        ImGui.Checkbox("Sync Macros", ref Config.SyncMacro);
                        ImGui.Checkbox("Sync Keybinds", ref Config.SyncKeybind);
                        ImGui.Checkbox("Sync Chatlog Settings", ref Config.SyncLogfilter);
                        ImGui.Checkbox("Sync Character Settings", ref Config.SyncCharSettings);
                        ImGui.Checkbox("Sync Keyboard Settings", ref Config.SyncKeyboardSettings);
                        ImGui.Checkbox("Sync Gamepad Settings", ref Config.SyncGamepadSettings);
                        ImGui.Checkbox("Sync Card Sets and Verminion Settings", ref Config.SyncCardSets);
                    }

                    ImGui.Separator();

                    if (ImGui.Button("Save"))
                    {
                        _isMainConfigWindowDrawing = false;
                        _pi.SavePluginConfig(Config);
                        PluginLog.Log("CS saved.");
                    }

                    ImGui.End();
                }
            }
        }
        private void DrawWindow()
        {
            if (!_showSettings)
            {
                return;
            }
            var scale = ImGui.GetIO().FontGlobalScale;

            ImGui.SetNextWindowSize(new Vector2(325 * scale, 200 * scale), ImGuiCond.Appearing);
            if (ImGui.Begin("BetterProfanityFilter", ref _showSettings, ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoScrollbar))
            {
                // enabled toggle
                var enabled = _configuration.Enabled;
                if (ImGui.Checkbox("Enabled", ref enabled))
                {
                    _configuration.Enabled = enabled;
                    _pluginInterface.SavePluginConfig(_configuration);
                }

                // use defaults
                var useDefaults = _configuration.UseDefaults;
                if (ImGui.Checkbox("Use Default Words", ref useDefaults))
                {
                    _configuration.UseDefaults = useDefaults;
                    _pluginInterface.SavePluginConfig(_configuration);
                    InitProfanityFilter();
                }

                // add word
                ImGui.Spacing();
                //ImGui.SetNextItemWidth(ImGui.GetWindowSize().X / 2 * scale);
                ImGui.InputTextWithHint("###BetterProfanityFilter_AddWord_Input",
                                        "Add word", ref _wordInput, 30);
                ImGui.SameLine();
                if (ImGui.Button("Allow") && !string.IsNullOrEmpty(_wordInput))
                {
                    _configuration.AllowedWords.Add(_wordInput);
                    _wordInput = string.Empty;
                    _pluginInterface.SavePluginConfig(_configuration);
                    InitProfanityFilter();
                }
                ImGui.SameLine();
                if (ImGui.Button("Block") && !string.IsNullOrEmpty(_wordInput))
                {
                    _configuration.BlockedWords.Add(_wordInput);
                    _wordInput = string.Empty;
                    _pluginInterface.SavePluginConfig(_configuration);
                    InitProfanityFilter();
                }
                ImGui.Spacing();

                // reset
                if (ImGui.Button("Reset To Defaults"))
                {
                    _configuration = new Config();
                    _wordInput     = string.Empty;
                    _pluginInterface.SavePluginConfig(_configuration);
                    InitProfanityFilter();
                }
                ImGui.Spacing();
            }
            ImGui.End();
        }
Exemplo n.º 16
0
        private void UiBuilder_OnBuildUi()
        {
            if (!isImguiMoSetupOpen)
            {
                return;
            }

            var values            = Enum.GetValues(typeof(MOActionPreset)).Cast <MOActionPreset>();
            var orderedByClassJob = values
                                    .Where(x => x != MOActionPreset.None && x.GetAttribute <MoActionInfoAttribute>() != null)
                                    .OrderBy(x => x.GetAttribute <MoActionInfoAttribute>().ClassJob).ToArray();

            var flagsSelected = new bool[orderedByClassJob.Length];

            for (var i = 0; i < orderedByClassJob.Length; i++)
            {
                flagsSelected[i] = Configuration.MoPresets.HasFlag(orderedByClassJob[i]);
            }

            ImGui.SetNextWindowSize(new Vector2(740, 490));

            ImGui.Begin("MouseOver action setup", ref isImguiMoSetupOpen,
                        ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar);

            ImGui.Text("This window allows you to enable and disable custom combos to your liking.");
            ImGui.Separator();

            ImGui.BeginChild("scrolling", new Vector2(0, 400), true, ImGuiWindowFlags.HorizontalScrollbar);

            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 3));

            var lastClassJob = -1;

            for (var i = 0; i < orderedByClassJob.Length; i++)
            {
                var flag     = orderedByClassJob[i];
                var flagInfo = flag.GetAttribute <MoActionInfoAttribute>();

                ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 14));

                if (lastClassJob != flagInfo.ClassJob)
                {
                    ImGui.Separator();

                    lastClassJob = flagInfo.ClassJob;
                    ImGui.TextColored(new Vector4(0.0f, 0.4f, 0.7f, 1.0f), ClassJobToName(flagInfo.ClassJob));
                }

                ImGui.PopStyleVar();

                ImGui.PushID("moCheck" + i);

                ImGui.Checkbox(flagInfo.Name, ref flagsSelected[i]);
                ImGui.SameLine();
                ImGui.TextColored(new Vector4(1f, 0, 0, 1.0f),
                                  flagInfo.IsPvP ? " PvP" : string.Empty);

                ImGui.PopID();

                ImGui.Spacing();
            }

            ImGui.PopStyleVar();

            ImGui.EndChild();

            ImGui.Separator();

            if (ImGui.Button("Enable All"))
            {
                for (var i = 0; i < flagsSelected.Length; i++)
                {
                    flagsSelected[i] = true;
                }
            }

            ImGui.SameLine();

            if (ImGui.Button("Disable All"))
            {
                for (var i = 0; i < flagsSelected.Length; i++)
                {
                    flagsSelected[i] = false;
                }
            }

            ImGui.Spacing();

            for (var i = 0; i < orderedByClassJob.Length; i++)
            {
                if (flagsSelected[i])
                {
                    Configuration.MoPresets |= orderedByClassJob[i];
                }
                else
                {
                    Configuration.MoPresets &= ~orderedByClassJob[i];
                }
            }

            if (ImGui.Button("Save and Close"))
            {
                pluginInterface.SavePluginConfig(Configuration);
                SetNewConfig();
                isImguiMoSetupOpen = false;
            }

            ImGui.End();
        }
Exemplo n.º 17
0
 public void Save()
 {
     pluginInterface.SavePluginConfig(this);
 }
Exemplo n.º 18
0
        public void OnMacroCommandHandler(string command, string args)
        {
            try {
                if (macroBasePtr != IntPtr.Zero && macroPtr != IntPtr.Zero)
                {
                    var argSplit = args.Split(' ');

                    switch (argSplit[0])
                    {
                    case "start": {
                        if (IsServerStarted)
                        {
                            pluginInterface.Framework.Gui.Chat.PrintError($"The HTTP Server is already Started.");
                        }
                        else
                        {
                            OnStartServer();
                            pluginInterface.Framework.Gui.Chat.PrintError($"The HTTP Server is Started.");
                        }
                        break;
                    }

                    case "stop": {
                        if (IsServerStarted)
                        {
                            OnStopServer();
                            pluginInterface.Framework.Gui.Chat.PrintError($"The HTTP Server is Stoped.");
                        }
                        else
                        {
                            pluginInterface.Framework.Gui.Chat.PrintError($"The HTTP Server is NOT Started.");
                        }
                        break;
                    }

                    case "restart": {
                        if (IsServerStarted)
                        {
                            OnStopServer();
                        }
                        else
                        {
                            OnStopServer();
                            OnStartServer();
                        }
                        pluginInterface.Framework.Gui.Chat.PrintError($"The HTTP Server Restarted.");
                        pluginInterface.Framework.Gui.Chat.Print($"The URL is http://localhost:{Port}/macro.");
                        break;
                    }

                    case "port": {
                        int.TryParse(argSplit[1], out Port);
                        Configuration.Port = Port;
                        pluginInterface.SavePluginConfig(Configuration);
                        pluginInterface.Framework.Gui.Chat.PrintError($"The HTTP Port is {Port}.\n Restart HTTP Server to Finish Setting.");
                        break;
                    }

                    default: {
                        pluginInterface.Framework.Gui.Chat.Print($"Send a Post request to execute the command.");
                        pluginInterface.Framework.Gui.Chat.Print($"The URL is http://localhost:{Port}/command.");
                        pluginInterface.Framework.Gui.Chat.Print($"The URL is http://localhost:{Port}/sendkey.");
                        pluginInterface.Framework.Gui.Chat.Print($"Marco is splited by '|'.");
                        pluginInterface.Framework.Gui.Chat.Print($"e.g.");
                        pluginInterface.Framework.Gui.Chat.Print($"/e Hello Dalamud|/e By HTTPAction");
                        pluginInterface.Framework.Gui.Chat.Print($"e.g.");
                        pluginInterface.Framework.Gui.Chat.Print($"Send a Post request to execute the macro.");
                        pluginInterface.Framework.Gui.Chat.Print($"/macrohttp start : Start Http Server");
                        pluginInterface.Framework.Gui.Chat.Print($"/macrohttp start : Stop Http Server");
                        pluginInterface.Framework.Gui.Chat.Print($"/macrohttp start : Restart Http Server");
                        pluginInterface.Framework.Gui.Chat.Print($"/macrohttp port [port] : Change the HTTP Port");
                        break;
                    }
                    }
                }
                else
                {
                    pluginInterface.Framework.Gui.Chat.PrintError("HTTPAction is not ready.\nExecute a macro to finish setup.");
                }
            }
            catch (Exception ex) {
                PluginLog.LogError(ex.ToString());
            }
        }