Example #1
0
        /// <summary>
        /// Show all properties and fields of the provided object via ImGui.
        /// </summary>
        /// <param name="obj">The object to show.</param>
        public static void ShowObject(object obj)
        {
            var type = obj.GetType();

            ImGui.Text($"Object Dump({type.Name}) for {obj}({obj.GetHashCode()})");

            ImGuiHelpers.ScaledDummy(5);

            ImGui.TextColored(ImGuiColors.DalamudOrange, "-> Properties:");

            ImGui.Indent();

            foreach (var propertyInfo in type.GetProperties())
            {
                ImGui.TextColored(ImGuiColors.DalamudOrange, $"    {propertyInfo.Name}: {propertyInfo.GetValue(obj)}");
            }

            ImGui.Unindent();

            ImGuiHelpers.ScaledDummy(5);

            ImGui.TextColored(ImGuiColors.HealerGreen, "-> Fields:");

            ImGui.Indent();

            foreach (var fieldInfo in type.GetFields())
            {
                ImGui.TextColored(ImGuiColors.HealerGreen, $"    {fieldInfo.Name}: {fieldInfo.GetValue(obj)}");
            }

            ImGui.Unindent();
        }
Example #2
0
        private void DrawTex()
        {
            ImGui.InputText("Tex Path", ref this.inputTexPath, 255);
            ImGui.InputFloat2("UV0", ref this.inputTexUv0);
            ImGui.InputFloat2("UV1", ref this.inputTexUv1);
            ImGui.InputFloat4("Tint", ref this.inputTintCol);
            ImGui.InputFloat2("Scale", ref this.inputTexScale);

            if (ImGui.Button("Load Tex"))
            {
                try
                {
                    this.debugTex      = this.dalamud.Data.GetImGuiTexture(this.inputTexPath);
                    this.inputTexScale = new Vector2(this.debugTex.Width, this.debugTex.Height);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Could not load tex.");
                }
            }

            ImGuiHelpers.ScaledDummy(10);

            if (this.debugTex != null)
            {
                ImGui.Image(this.debugTex.ImGuiHandle, this.inputTexScale, this.inputTexUv0, this.inputTexUv1, this.inputTintCol);
                ImGuiHelpers.ScaledDummy(5);
                Util.ShowObject(this.debugTex);
            }
        }
Example #3
0
    internal static (bool shouldBuildConfigUi, bool changedConfig) Draw(Configuration config)
    {
        var shouldBuildConfigUi = true;
        var changed             = false;
        var scale = ImGui.GetIO().FontGlobalScale;

        ImGuiHelpers.ForceNextWindowMainViewport();
        ImGui.SetNextWindowSize(new Vector2(400 * scale, 420 * scale), ImGuiCond.FirstUseEver);
        ImGui.SetNextWindowSizeConstraints(new Vector2(410 * scale, 200 * scale),
                                           new Vector2(float.MaxValue, float.MaxValue));
        if (!ImGui.Begin($"{Plugin.PluginName} Configuration", ref shouldBuildConfigUi,
                         ImGuiWindowFlags.NoCollapse))
        {
            ImGui.End();
            return(shouldBuildConfigUi, changed);
        }

        if (config.FreshInstall)
        {
            DrawFreshInstallNotice(config, scale);
        }

        if (ImGui.BeginTabBar("ConfigTabBar", ImGuiTabBarFlags.NoTooltip))
        {
            changed |= DrawGeneralConfigurationTab(config, scale);
            changed |= DrawFilterTab(config, scale);
            changed |= DrawOnAddonHideTab(config, scale);
            DrawHelpTab();
            ImGui.EndTabBar();
        }

        ImGui.End();
        return(shouldBuildConfigUi, changed);
    }
Example #4
0
    private static void DrawFreshInstallNotice(Configuration config, float scale)
    {
        ImGui.OpenPopup("Compass Note");
        var contentSize   = ImGuiHelpers.MainViewport.Size;
        var modalSize     = new Vector2(400 * scale, 175 * scale);
        var modalPosition = new Vector2(contentSize.X / 2 - modalSize.X / 2, contentSize.Y / 2 - modalSize.Y / 2);

        ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always);
        ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always);
        if (!ImGui.BeginPopupModal("Compass Note"))
        {
            return;
        }
        ImGui.PushTextWrapPos(ImGui.GetFontSize() * 22f);
        ImGui.TextWrapped(i18n.fresh_install_note);
        ImGui.PopTextWrapPos();
        ImGui.Spacing();
        if (ImGui.Button($"${i18n.fresh_install_note_confirm_button}###Compass_FreshInstallPopUp"))
        {
            config.FreshInstall = false;
            ImGui.CloseCurrentPopup();
        }

        ImGui.EndPopup();
    }
Example #5
0
        public void Draw()
        {
            if (!ForceDraw && (Dalamud.Conditions.Any() || _base._menu.Visible))
            {
                return;
            }

            using var color = ImGuiRaii.PushColor(ImGuiCol.Button, 0xFF0000C8, ForceDraw);

            var ss = ImGui.GetMainViewport().Size + ImGui.GetMainViewport().Pos;

            ImGui.SetNextWindowViewport(ImGui.GetMainViewport().ID);

            var windowSize = ImGuiHelpers.ScaledVector2(Width, Height);

            ImGui.SetNextWindowPos(ss - windowSize - Penumbra.Config.ManageModsButtonOffset * ImGuiHelpers.GlobalScale, ImGuiCond.Always);

            if (ImGui.Begin(MenuButtonsName, ButtonFlags) &&
                ImGui.Button(MenuButtonLabel, windowSize))
            {
                _base.FlipVisibility();
            }

            ImGui.End();
        }
Example #6
0
        private void PlayerCustomize()
        {
            if (this.SelectedPlayer == null)
            {
                return;
            }
            const float sameLineOffset = 70f;

            if (this.SelectedPlayer.Customize != null)
            {
                ImGui.Text(Loc.Localize("Gender", "Gender"));
                ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
                ImGui.Text(this.SelectedPlayer.CharaCustomizeData.Gender == 0
                               ? Loc.Localize("GenderMale", "Male")
                               : Loc.Localize("GenderFemale", "Female"));

                ImGui.Text(Loc.Localize("Race", "Race"));
                ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
                ImGui.Text(PlayerTrackPlugin.DataManager.Race(this.SelectedPlayer.CharaCustomizeData.Race, this.SelectedPlayer.CharaCustomizeData.Gender));

                ImGui.Text(Loc.Localize("Tribe", "Tribe"));
                ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
                ImGui.Text(PlayerTrackPlugin.DataManager.Tribe(this.SelectedPlayer.CharaCustomizeData.Tribe, this.SelectedPlayer.CharaCustomizeData.Gender));

                ImGui.Text(Loc.Localize("Height", "Height"));
                ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
                ImGui.Text(string.Format(
                               Loc.Localize("PlayerHeightValue", "{0} in"),
                               CharHeightUtil.CalcInches(this.SelectedPlayer.CharaCustomizeData.Height, this.SelectedPlayer.CharaCustomizeData.Race, this.SelectedPlayer.CharaCustomizeData.Tribe, this.SelectedPlayer.CharaCustomizeData.Gender)));

                ImGuiHelpers.ScaledDummy(5f);
                if (this.SelectedPlayer.Customize is { Length : > 0 })
Example #7
0
            public static void DrawPopup(ConfigWindow window)
            {
                if (_mod == null)
                {
                    return;
                }

                using var popup = ImRaii.Popup(PopupName);
                if (!popup)
                {
                    return;
                }

                if (ImGui.IsWindowAppearing())
                {
                    ImGui.SetKeyboardFocusHere();
                }

                ImGui.InputTextMultiline("##editDescription", ref _newDescription, 4096, ImGuiHelpers.ScaledVector2(800, 800));
                ImGui.Dummy(window._defaultSpace);

                var buttonSize = ImGuiHelpers.ScaledVector2(100, 0);
                var width      = 2 * buttonSize.X
                                 + 4 * ImGui.GetStyle().FramePadding.X
                                 + ImGui.GetStyle().ItemSpacing.X;

                ImGui.SetCursorPosX((800 * ImGuiHelpers.GlobalScale - width) / 2);

                var oldDescription = _newDescriptionIdx == Input.Description
                    ? _mod.Description
                    : _mod.Groups[_newDescriptionIdx].Description;

                var tooltip = _newDescription != oldDescription ? string.Empty : "No changes made yet.";

                if (ImGuiUtil.DrawDisabledButton("Save", buttonSize, tooltip, tooltip.Length > 0))
                {
                    switch (_newDescriptionIdx)
                    {
                    case Input.Description:
                        Penumbra.ModManager.ChangeModDescription(_mod.Index, _newDescription);
                        break;

                    case >= 0:
                        Penumbra.ModManager.ChangeGroupDescription(_mod, _newDescriptionIdx, _newDescription);
                        break;
                    }

                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();
                if (ImGui.Button("Cancel", buttonSize) ||
                    ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.Escape)))
                {
                    _newDescriptionIdx = Input.None;
                    _newDescription    = string.Empty;
                    ImGui.CloseCurrentPopup();
                }
            }
Example #8
0
            private void DrawDeleteModal()
            {
                if (_deleteIndex == null)
                {
                    return;
                }

                ImGui.OpenPopup(DialogDeleteMod);

                var _ = true;

                ImGui.SetNextWindowPos(ImGui.GetMainViewport().GetCenter(), ImGuiCond.Appearing, Vector2.One / 2);
                var ret = ImGui.BeginPopupModal(DialogDeleteMod, ref _, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoDecoration);

                if (!ret)
                {
                    return;
                }

                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndPopup);

                if (Mod == null)
                {
                    _deleteIndex = null;
                    ImGui.CloseCurrentPopup();
                    return;
                }

                ImGui.Text("Are you sure you want to delete the following mod:");
                var halfLine = new Vector2(ImGui.GetTextLineHeight() / 2);

                ImGui.Dummy(halfLine);
                ImGui.TextColored(DeleteModNameColor, Mod.Data.Meta.Name);
                ImGui.Dummy(halfLine);

                var buttonSize = ImGuiHelpers.ScaledVector2(120, 0);

                if (ImGui.Button(ButtonYesDelete, buttonSize))
                {
                    ImGui.CloseCurrentPopup();
                    var mod = Mod;
                    Cache.RemoveMod(mod);
                    _modManager.DeleteMod(mod.Data.BasePath);
                    ModFileSystem.InvokeChange();
                    ClearSelection();
                }

                ImGui.SameLine();

                if (ImGui.Button(ButtonNoDelete, buttonSize))
                {
                    ImGui.CloseCurrentPopup();
                    _deleteIndex = null;
                }
            }
Example #9
0
        private static void DrawFreeCamButton()
        {
            ImGuiHelpers.ForceNextWindowMainViewport();
            var size = new Vector2(50) * ImGuiHelpers.GlobalScale;

            ImGui.SetNextWindowSize(size, ImGuiCond.Always);
            ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Vector2(ImGuiHelpers.MainViewport.Size.X - size.X, 0), ImGuiCond.Always);
            ImGui.Begin("FreeCam Button", ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoFocusOnAppearing);

            if (ImGui.IsWindowHovered() && ImGui.IsMouseReleased(ImGuiMouseButton.Left))
            {
                FreeCam.Toggle();
            }

            ImGui.End();
        }
Example #10
0
        /// <inheritdoc/>
        public override void Draw()
        {
            var screenSize = ImGui.GetMainViewport().Size;
            var windowSize = ImGui.GetWindowSize();

            this.Position = (screenSize - windowSize) / 2;

            ImGui.BeginChild("scrolling", Vector2.Zero, false, ImGuiWindowFlags.NoScrollbar);

            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);

            ImGuiHelpers.ScaledDummy(0, 340f);
            ImGui.Text(string.Empty);

            ImGui.SameLine(150f);
            ImGui.Image(this.logoTexture.ImGuiHandle, ImGuiHelpers.ScaledVector2(190f, 190f));

            ImGuiHelpers.ScaledDummy(0, 20f);

            var windowX = ImGui.GetWindowSize().X;

            foreach (var creditsLine in this.creditsText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
            {
                var lineLenX = ImGui.CalcTextSize(creditsLine).X;

                ImGui.Dummy(new Vector2((windowX / 2) - (lineLenX / 2), 0f));
                ImGui.SameLine();
                ImGui.TextUnformatted(creditsLine);
            }

            ImGui.PopStyleVar();

            if (this.creditsThrottler.Elapsed.TotalMilliseconds > (1000.0f / CreditFPS))
            {
                var curY = ImGui.GetScrollY();
                var maxY = ImGui.GetScrollMaxY();

                if (curY < maxY - 1)
                {
                    ImGui.SetScrollY(curY + 1);
                }
            }

            ImGui.EndChild();
        }
Example #11
0
    public void ChangeMod(Mod mod)
    {
        if (mod == _mod)
        {
            return;
        }

        _editor?.Dispose();
        _editor         = new Mod.Editor(mod, -1, 0);
        _mod            = mod;
        WindowName      = $"{mod.Name}{WindowBaseLabel}";
        SizeConstraints = new WindowSizeConstraints
        {
            MinimumSize = ImGuiHelpers.ScaledVector2(1000, 600),
            MaximumSize = 4000 * Vector2.One,
        };
        _selectedFiles.Clear();
    }
        private static bool DrawRisksWarning(Configuration config, ref bool shouldDrawConfigUi, float scale)
        {
            if (config.OnboardingStep == Onboarding.TellAboutRisk)
            {
                ImGui.OpenPopup("Warning");
            }
            var contentSize   = ImGuiHelpers.MainViewport.Size;
            var modalSize     = new Vector2(500 * scale, 215 * scale);
            var modalPosition = new Vector2(contentSize.X / 2 - modalSize.X / 2, contentSize.Y / 2 - modalSize.Y / 2);

            ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always);
            ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always);
            if (!ImGui.BeginPopupModal("Warning"))
            {
                return(false);
            }
            ImGui.Text("This plugin allows you to directly use the motors of your controller.");
            ImGui.Text("Irresponsible usage has a probability of permanent hardware damage.");
            ImGui.Text("The author cannot be held liable for any damage caused by e.g. vibration overuse.");
            ImGui.TextWrapped(
                "Before using this plugin you have to acknowledge the risks and that you are sole responsible for any damage which might occur.");
            ImGui.Text("You can cancel and remove the plugin if you do not consent.");
            ImGui.Text("Responsible usage should come with no risks.");
            ImGui.Spacing();
            var changed = false;

            if (ImGui.Button("Cancel##Risks"))
            {
                shouldDrawConfigUi = false;
                ImGui.CloseCurrentPopup();
            }

            ImGui.SameLine();
            if (ImGui.Button(
                    "I hereby acknowledge the risks"))
            {
                config.OnboardingStep = Onboarding.AskAboutExamplePatterns;
                changed = true;
                ImGui.CloseCurrentPopup();
            }

            ImGui.EndPopup();
            return(changed);
        }
    public override void Draw()
    {
        ImGui.PushStyleVar(ImGuiStyleVar.ChildRounding, 7f);

        var childSize = new Vector2(300, 200);
        var vpSize    = ImGuiHelpers.ViewportSize;

        ImGui.SetNextWindowPos(new Vector2(vpSize.X / 2 - childSize.X / 2, vpSize.Y / 2 - childSize.Y / 2), ImGuiCond.Always);
        ImGui.SetNextWindowBgAlpha(0.4f);

        if (ImGui.BeginChild("###otp", childSize, true, ImGuiWindowFlags.AlwaysAutoResize))
        {
            ImGui.Dummy(new Vector2(40));

            // center text in window
            ImGuiHelpers.CenteredText("Please enter your OTP");

            const int INPUT_WIDTH = 150;
            ImGui.SetNextItemWidth(INPUT_WIDTH);
            ImGuiHelpers.CenterCursorFor(INPUT_WIDTH);

            if (this.appearing)
            {
                ImGui.SetKeyboardFocusHere(0);
                this.appearing = false;
            }

            var doEnter = ImGui.InputText("###otpInput", ref this.otp, 6, ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.EnterReturnsTrue);

            var buttonSize = new Vector2(INPUT_WIDTH, 30);
            ImGuiHelpers.CenterCursorFor(INPUT_WIDTH);

            if (ImGui.Button("OK", buttonSize) || doEnter)
            {
                TryAcceptOtp(this.otp);
            }
        }

        ImGui.EndChild();

        ImGui.PopStyleVar();

        base.Draw();
    }
Example #14
0
            private void DrawForcedCollectionSelector()
            {
                var index = _currentForcedIndex;

                if (ImGui.Combo("##Forced Collection", ref index, _collectionNamesWithNone) && index != _currentForcedIndex)
                {
                    _manager.Collections.SetForcedCollection(_collections[index]);
                    _currentForcedIndex = index;
                }

                ImGuiCustom.HoverTooltip(
                    "Mods in the forced collection are always loaded if not overwritten by anything in the current or character-based collection.\n"
                    + "Please avoid mixing meta-manipulating mods in Forced and other collections, as this will probably not work correctly.");

                ImGui.SameLine();
                ImGuiHelpers.ScaledDummy(24, 0);
                ImGui.SameLine();
                ImGui.Text("Forced Collection");
            }
Example #15
0
            private void DrawDefaultCollectionSelector()
            {
                var index = _currentDefaultIndex;

                if (ImGui.Combo("##Default Collection", ref index, _collectionNamesWithNone) && index != _currentDefaultIndex)
                {
                    _manager.Collections.SetDefaultCollection(_collections[index]);
                    _currentDefaultIndex = index;
                }

                ImGuiCustom.HoverTooltip(
                    "Mods in the default collection are loaded for any character that is not explicitly named in the character collections below.\n"
                    + "They also take precedence before the forced collection.");

                ImGui.SameLine();
                ImGuiHelpers.ScaledDummy(24, 0);
                ImGui.SameLine();
                ImGui.Text("Default Collection");
            }
Example #16
0
        private void Lodestone()
        {
            const float sameLineOffset       = 140f;
            var         isLodestoneAvailable = this.plugin.LodestoneService.IsLodestoneAvailable();
            var         requests             = this.plugin.LodestoneService.GetRequests();

            // heading
            WindowManager.SpacerNoTabs();
            ImGui.TextColored(ImGuiColors.DalamudViolet, Loc.Localize("Lodestone", "Lodestone"));

            // lodestone state
            ImGui.Text(Loc.Localize("LodestoneStatus", "Status"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
            if (isLodestoneAvailable)
            {
                ImGui.TextColored(ImGuiColors.HealerGreen, Loc.Localize("LodestoneAvailable", "Available"));
            }
            else
            {
                ImGui.TextColored(ImGuiColors.DPSRed, Loc.Localize("LodestoneUnavailable", "Unavailable"));
            }

            // total requests
            ImGui.Text(Loc.Localize("LodestoneTotalRequests", "Request Count"));
            ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset);
            ImGui.Text(requests.Length.ToString());

            // requests
            ImGuiHelpers.ScaledDummy(new Vector2(0, 5f));
            ImGui.TextColored(ImGuiColors.DalamudViolet, Loc.Localize("LodestoneRequestsInQueue", "Requests In Queue"));
            if (requests.Any())
            {
                foreach (var request in requests)
                {
                    ImGui.Text(request.PlayerName + " (" + request.WorldName + ")");
                }
            }
            else
            {
                ImGui.Text(Loc.Localize("LodestoneNoRequests", "There are no pending lodestone requests."));
            }
        }
        internal static bool DrawConfigUi(Configuration config, DalamudPluginInterface pi,
                                          Action <IPluginConfiguration> save, IReadOnlyCollection <ClassJob> jobs,
                                          IReadOnlyCollection <FFXIVAction> allActions, ref IEnumerator <VibrationPattern.Step?>?patternEnumerator)
        {
            var shouldDrawConfigUi = true;
            var changed            = false;
            var scale = ImGui.GetIO().FontGlobalScale;

            ImGuiHelpers.ForceNextWindowMainViewport();
            ImGui.SetNextWindowSize(new Vector2(575 * scale, 400 * scale), ImGuiCond.FirstUseEver);
            ImGui.SetNextWindowSizeConstraints(new Vector2(350 * scale, 200 * scale),
                                               new Vector2(float.MaxValue, float.MaxValue));
            if (!ImGui.Begin($"{GentleTouch.PluginName} Configuration", ref shouldDrawConfigUi,
                             ImGuiWindowFlags.NoCollapse))
            {
                ImGui.End();
                return(shouldDrawConfigUi);
            }

            if (config.OnboardingStep != Onboarding.Done)
            {
                changed |= DrawRisksWarning(config, ref shouldDrawConfigUi, scale);
                changed |= DrawOnboarding(config, jobs, allActions, scale);
            }

            ImGui.BeginTabBar("ConfigurationTabs", ImGuiTabBarFlags.NoTooltip);
            changed |= DrawGeneralTab(config, scale);
            changed |= DrawPatternTab(config, scale, ref patternEnumerator);
            changed |= DrawTriggerTab(config, pi, scale, jobs, allActions);
            ImGui.EndTabBar();
            ImGui.End();
            if (!changed)
            {
                return(shouldDrawConfigUi);
            }
#if DEBUG
            PluginLog.Verbose("Config changed, saving...");
#endif
            save(config);
            return(shouldDrawConfigUi);
        }
Example #18
0
            public void Draw()
            {
                if (!ImGui.BeginTabItem("Collections"))
                {
                    return;
                }

                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem)
                                 .Push(ImGui.EndChild);

                if (ImGui.BeginChild("##CollectionHandling", new Vector2(-1, ImGui.GetTextLineHeightWithSpacing() * 6), true))
                {
                    DrawCurrentCollectionSelector(true);

                    ImGuiHelpers.ScaledDummy(0, 10);
                    DrawNewCollectionInput();
                }

                raii.Pop();

                DrawCharacterCollectionSelectors();
            }
Example #19
0
        private void DrawToast()
        {
            ImGui.InputText("Toast text", ref this.inputTextToast, 200);

            ImGui.Combo("Toast Position", ref this.toastPosition, new[] { "Bottom", "Top", }, 2);
            ImGui.Combo("Toast Speed", ref this.toastSpeed, new[] { "Slow", "Fast", }, 2);
            ImGui.Combo("Quest Toast Position", ref this.questToastPosition, new[] { "Centre", "Right", "Left" }, 3);
            ImGui.Checkbox("Quest Checkmark", ref this.questToastCheckmark);
            ImGui.Checkbox("Quest Play Sound", ref this.questToastSound);
            ImGui.InputInt("Quest Icon ID", ref this.questToastIconId);

            ImGuiHelpers.ScaledDummy(new Vector2(10, 10));

            if (ImGui.Button("Show toast"))
            {
                this.dalamud.Framework.Gui.Toast.ShowNormal(this.inputTextToast, new ToastOptions
                {
                    Position = (ToastPosition)this.toastPosition,
                    Speed    = (ToastSpeed)this.toastSpeed,
                });
            }

            if (ImGui.Button("Show Quest toast"))
            {
                this.dalamud.Framework.Gui.Toast.ShowQuest(this.inputTextToast, new QuestToastOptions
                {
                    Position         = (QuestToastPosition)this.questToastPosition,
                    DisplayCheckmark = this.questToastCheckmark,
                    IconId           = (uint)this.questToastIconId,
                    PlaySound        = this.questToastSound,
                });
            }

            if (ImGui.Button("Show Error toast"))
            {
                this.dalamud.Framework.Gui.Toast.ShowError(this.inputTextToast);
            }
        }
        /// <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);
        }
Example #21
0
    /// <inheritdoc/>
    public override void Draw()
    {
        ImGui.Text($"The in-game addon has been updated to version D{this.assemblyVersion}.");

        ImGuiHelpers.ScaledDummy(10);

        ImGui.Text("The following changes were introduced:");
        ImGui.TextWrapped(ChangeLog);

        ImGuiHelpers.ScaledDummy(5);

        ImGui.TextColored(ImGuiColors.DalamudRed, " !!! ATTENTION !!!");

        ImGui.TextWrapped(UpdatePluginsInfo);

        ImGuiHelpers.ScaledDummy(10);

        ImGui.Text("Thank you for using our tools!");

        ImGuiHelpers.ScaledDummy(10);

        ImGui.PushFont(UiBuilder.IconFont);

        if (ImGui.Button(FontAwesomeIcon.Download.ToIconString()))
        {
            Service <DalamudInterface> .Get().OpenPluginInstaller();
        }

        if (ImGui.IsItemHovered())
        {
            ImGui.PopFont();
            ImGui.SetTooltip("Open Plugin Installer");
            ImGui.PushFont(UiBuilder.IconFont);
        }

        ImGui.SameLine();

        if (ImGui.Button(FontAwesomeIcon.LaughBeam.ToIconString()))
        {
            Process.Start("https://discord.gg/3NMcUV5");
        }

        if (ImGui.IsItemHovered())
        {
            ImGui.PopFont();
            ImGui.SetTooltip("Join our Discord server");
            ImGui.PushFont(UiBuilder.IconFont);
        }

        ImGui.SameLine();

        if (ImGui.Button(FontAwesomeIcon.Globe.ToIconString()))
        {
            Process.Start("https://github.com/goatcorp/FFXIVQuickLauncher");
        }

        if (ImGui.IsItemHovered())
        {
            ImGui.PopFont();
            ImGui.SetTooltip("See our GitHub repository");
            ImGui.PushFont(UiBuilder.IconFont);
        }

        ImGui.PopFont();

        ImGui.SameLine();
        ImGuiHelpers.ScaledDummy(20, 0);
        ImGui.SameLine();

        if (ImGui.Button("Close"))
        {
            this.IsOpen = false;
        }
    }
Example #22
0
 /// <summary>
 /// Create a dummy scaled for use with tabs.
 /// </summary>
 public static void SpacerWithTabs()
 {
     ImGuiHelpers.ScaledDummy(1f);
 }
Example #23
0
        /// <inheritdoc/>
        public override void Draw()
        {
            ImGui.Text($"Dalamud has been updated to version D{this.assemblyVersion}.");

            ImGuiHelpers.ScaledDummy(10);

            ImGui.Text("The following changes were introduced:");

            ImGui.SameLine();
            ImGuiHelpers.ScaledDummy(0);
            var imgCursor = ImGui.GetCursorPos();

            ImGui.TextWrapped(ChangeLog);

            /*
             * ImGuiHelpers.ScaledDummy(5);
             *
             * ImGui.TextColored(ImGuiColors.DalamudRed, " !!! ATTENTION !!!");
             *
             * ImGui.TextWrapped(UpdatePluginsInfo);
             */

            ImGuiHelpers.ScaledDummy(10);

            ImGui.Text("Thank you for using our tools!");

            ImGuiHelpers.ScaledDummy(10);

            ImGui.PushFont(UiBuilder.IconFont);

            if (ImGui.Button(FontAwesomeIcon.Download.ToIconString()))
            {
                Service <DalamudInterface> .Get().OpenPluginInstaller();
            }

            if (ImGui.IsItemHovered())
            {
                ImGui.PopFont();
                ImGui.SetTooltip("Open Plugin Installer");
                ImGui.PushFont(UiBuilder.IconFont);
            }

            ImGui.SameLine();

            if (ImGui.Button(FontAwesomeIcon.LaughBeam.ToIconString()))
            {
                Util.OpenLink("https://discord.gg/3NMcUV5");
            }

            if (ImGui.IsItemHovered())
            {
                ImGui.PopFont();
                ImGui.SetTooltip("Join our Discord server");
                ImGui.PushFont(UiBuilder.IconFont);
            }

            ImGui.SameLine();

            if (ImGui.Button(FontAwesomeIcon.Globe.ToIconString()))
            {
                Util.OpenLink("https://goatcorp.github.io/faq/");
            }

            if (ImGui.IsItemHovered())
            {
                ImGui.PopFont();
                ImGui.SetTooltip("See the FAQ");
                ImGui.PushFont(UiBuilder.IconFont);
            }

            ImGui.SameLine();

            if (ImGui.Button(FontAwesomeIcon.Heart.ToIconString()))
            {
                Util.OpenLink("https://goatcorp.github.io/faq/support");
            }

            if (ImGui.IsItemHovered())
            {
                ImGui.PopFont();
                ImGui.SetTooltip("Support what we care about");
                ImGui.PushFont(UiBuilder.IconFont);
            }

            ImGui.PopFont();

            ImGui.SameLine();
            ImGuiHelpers.ScaledDummy(20, 0);
            ImGui.SameLine();

            if (ImGui.Button("Close"))
            {
                this.IsOpen = false;
            }

            imgCursor.X += 750;
            imgCursor.Y -= 30;
            ImGui.SetCursorPos(imgCursor);

            ImGui.Image(this.logoTexture.ImGuiHandle, new Vector2(100));
        }
        private void PlayerEncounters()
        {
            if (this.SelectedPlayer == null)
            {
                return;
            }
            const float sameLineOffset1 = 60f;
            const float sameLineOffset2 = 130f;
            const float sameLineOffset3 = 170f;
            const float sameLineOffset4 = 200f;

            if (this.SelectedEncounters != null && this.SelectedEncounters.Any())
            {
                ImGui.TextColored(ImGuiColors.DalamudViolet, Loc.Localize("Time", "Time"));
                ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset1);
                ImGui.TextColored(ImGuiColors.DalamudViolet, Loc.Localize("Duration", "Duration"));
                ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset2);
                ImGui.TextColored(ImGuiColors.DalamudViolet, Loc.Localize("Job", "Job"));
                ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset3);
                ImGui.TextColored(ImGuiColors.DalamudViolet, Loc.Localize("Lvl", "Lvl"));
                ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset4);
                ImGui.TextColored(ImGuiColors.DalamudViolet, Loc.Localize("Location", "Location"));

                foreach (var encounter in this.SelectedEncounters)
                {
                    ImGui.BeginGroup();
                    ImGui.Text(encounter.Created.ToTimeSpan());
                    ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset1);
                    ImGui.Text((encounter.Updated - encounter.Created).ToDuration());
                    ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset2);
                    ImGui.Text(encounter.JobCode);
                    ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset3);
                    ImGui.Text(encounter.JobLvl.ToString());
                    ImGuiHelpers.ScaledRelativeSameLine(sameLineOffset4);
                    ImGui.Text(encounter.LocationName);
                    ImGui.EndGroup();
                    if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
                    {
                        ImGui.OpenPopup("###PlayerTrack_Encounter_Popup_" + encounter.Id);
                    }

                    if (ImGui.BeginPopup("###PlayerTrack_Encounter_Popup_" + encounter.Id))
                    {
                        ImGui.Text(Loc.Localize("Delete", "Delete"));
                        if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
                        {
                            this.plugin.EncounterService.DeleteEncounter(encounter);
                            this.SelectedEncounters = this.plugin.EncounterService.GetEncountersByPlayer(this.SelectedPlayer.Key).OrderByDescending(enc => enc.Created).ToList();
                        }

                        ImGui.EndPopup();
                    }
                }
            }
            else
            {
                ImGui.TextColored(ImGuiColors.DalamudYellow, Loc.Localize("NoEncounters", "No encounters found for this player."));
                ImGui.TextWrapped(Loc.Localize(
                                      "NoEncountersExplanation",
                                      "This can happen for characters manually added or if all the encounters have been deleted."));
            }
        }
Example #25
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);
            }
        }
Example #26
0
        public override void Draw()
        {
            if (ImGui.BeginPopupModal("Choose Path"))
            {
                ImGui.Text("Enter path:\n\n");

                ImGui.InputText("###ScratchPathInput", ref this.pathInput, 1000);

                if (ImGui.Button("OK", new Vector2(120, 0)))
                {
                    ImGui.CloseCurrentPopup();
                    this.watcher.Load(this.pathInput);
                    this.pathInput = string.Empty;
                }

                ImGui.SetItemDefaultFocus();
                ImGui.SameLine();
                if (ImGui.Button("Cancel", new Vector2(120, 0)))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }

            if (ImGui.BeginMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Load & Watch"))
                    {
                        ImGui.OpenPopup("Choose Path");
                    }

                    ImGui.EndMenu();
                }

                ImGui.EndMenuBar();
            }

            var flags = ImGuiTabBarFlags.Reorderable | ImGuiTabBarFlags.TabListPopupButton |
                        ImGuiTabBarFlags.FittingPolicyScroll;

            if (ImGui.BeginTabBar("ScratchDocTabBar", flags))
            {
                if (ImGui.TabItemButton("+", ImGuiTabItemFlags.Trailing | ImGuiTabItemFlags.NoTooltip))
                {
                    this.documents.Add(new ScratchpadDocument());
                }

                var docs = this.documents.Concat(this.watcher.TrackedScratches).ToArray();

                for (var i = 0; i < docs.Length; i++)
                {
                    var isOpen = true;

                    if (ImGui.BeginTabItem(docs[i].Title + (docs[i].HasUnsaved ? "*" : string.Empty) + "###ScratchItem" + i, ref isOpen))
                    {
                        if (ImGui.InputTextMultiline("###ScratchInput" + i, ref docs[i].Content, 20000,
                                                     new Vector2(-1, -34), ImGuiInputTextFlags.AllowTabInput))
                        {
                            docs[i].HasUnsaved = true;
                        }

                        ImGuiHelpers.ScaledDummy(3);

                        if (ImGui.Button("Compile & Reload"))
                        {
                            docs[i].Status = this.Execution.RenewScratch(docs[i]);
                        }

                        ImGui.SameLine();

                        if (ImGui.Button("Dispose all"))
                        {
                            this.Execution.DisposeAllScratches();
                        }

                        ImGui.SameLine();

                        if (ImGui.Button("Dump processed code"))
                        {
                            try
                            {
                                var code = this.Execution.MacroProcessor.Process(docs[i].Content);
                                Log.Information(code);
                                ImGui.SetClipboardText(code);
                            }
                            catch (Exception ex)
                            {
                                Log.Error(ex, "Could not process macros");
                            }
                        }

                        ImGui.SameLine();

                        if (ImGui.Button("Toggle Log"))
                        {
                            this.dalamud.DalamudUi.ToggleLog();
                        }

                        ImGui.SameLine();

                        ImGui.Checkbox("Use Macros", ref docs[i].IsMacro);

                        ImGui.SameLine();

                        switch (docs[i].Status)
                        {
                        case ScratchLoadStatus.Unknown:
                            ImGui.TextColored(ImGuiColors.DalamudGrey, "Compile scratch to see status");
                            break;

                        case ScratchLoadStatus.FailureCompile:
                            ImGui.TextColored(ImGuiColors.DalamudRed, "Error during compilation");
                            break;

                        case ScratchLoadStatus.FailureInit:
                            ImGui.TextColored(ImGuiColors.DalamudRed, "Error during init");
                            break;

                        case ScratchLoadStatus.Success:
                            ImGui.TextColored(ImGuiColors.HealerGreen, "OK!");
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }

                        ImGui.SameLine();

                        ImGui.TextColored(ImGuiColors.DalamudGrey, docs[i].Id.ToString());

                        ImGui.EndTabItem();
                    }
                }

                ImGui.EndTabBar();
            }
        }
        private static bool DrawOnboarding(Configuration config, IEnumerable <ClassJob> jobs,
                                           IEnumerable <FFXIVAction> allActions, float scale)
        {
            var contentSize   = ImGuiHelpers.MainViewport.Size;
            var modalSize     = new Vector2(300 * scale, 100 * scale);
            var modalPosition = new Vector2(contentSize.X / 2 - modalSize.X / 2, contentSize.Y / 2 - modalSize.Y / 2);

            if (config.OnboardingStep == Onboarding.AskAboutExamplePatterns)
            {
                ImGui.OpenPopup("Create Example Patterns");
            }
            var changed = false;

            ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always);
            ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always);
            if (ImGui.BeginPopupModal("Create Example Patterns"))
            {
                ImGui.Text($"No vibration patterns found." +
                           $"\nCreate some example patterns?");

                if (ImGui.Button("No##ExamplePatterns"))
                {
                    config.OnboardingStep = Onboarding.Done;
                    changed = true;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();
                if (ImGui.Button(
                        "Yes##ExamplePatterns"))
                {
                    #region Example Patterns

                    var bothStrong = new VibrationPattern
                    {
                        Steps = new[]
                        {
                            new VibrationPattern.Step(100, 100, 300),
                        },
                        Cycles   = 1,
                        Infinite = false,
                        Name     = "Both Strong"
                    };
                    var lightPulse = new VibrationPattern
                    {
                        Steps = new[]
                        {
                            new VibrationPattern.Step(25, 25, 300),
                            new VibrationPattern.Step(0, 0, 400)
                        },
                        Infinite = true,
                        Name     = "Light pulse"
                    };
                    var leftStrong = new VibrationPattern
                    {
                        Steps = new[]
                        {
                            new VibrationPattern.Step(100, 0, 300),
                        },
                        Infinite = false,
                        Cycles   = 1,
                        Name     = "Left Strong"
                    };
                    var rightStrong = new VibrationPattern
                    {
                        Steps = new[]
                        {
                            new VibrationPattern.Step(0, 100, 300),
                        },
                        Infinite = false,
                        Cycles   = 1,
                        Name     = "Right Strong"
                    };
                    var simpleRhythmic = new VibrationPattern
                    {
                        Steps = new[]
                        {
                            new VibrationPattern.Step(75, 75, 200),
                            new VibrationPattern.Step(0, 0, 200),
                        },
                        Infinite = false,
                        Cycles   = 3,
                        Name     = "Simple Rhythmic"
                    };
                    config.Patterns.Add(lightPulse);
                    config.Patterns.Add(bothStrong);
                    config.Patterns.Add(leftStrong);
                    config.Patterns.Add(rightStrong);
                    config.Patterns.Add(simpleRhythmic);

                    #endregion

                    config.OnboardingStep = Onboarding.AskAboutExampleCooldownTriggers;
                    changed = true;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }

            if (config.OnboardingStep == Onboarding.AskAboutExampleCooldownTriggers)
            {
                ImGui.OpenPopup("Create Example Cooldown Triggers");
            }
            ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always);
            ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always);
            if (ImGui.BeginPopupModal("Create Example Cooldown Triggers"))
            {
                ImGui.Text($"No cooldown triggers found." +
                           $"\nCreate some example triggers (Ninja and Paladin)?");

                if (ImGui.Button("No##ExampleTriggers"))
                {
                    config.OnboardingStep = Onboarding.Done;
                    changed = true;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();
                if (ImGui.Button(
                        "Yes##ExampleTriggers"))
                {
                    #region Example Triggers

                    config.CooldownTriggers.Add(new CooldownTrigger(
                                                    30, "Dream Within a Dream", 3566, 16, 0, config.Patterns[1]));
                    config.CooldownTriggers.Add(new CooldownTrigger(
                                                    30, "Mug", 2248, 18, 2, config.Patterns[3]));
                    config.CooldownTriggers.Add(new CooldownTrigger(
                                                    19, "Fight or Flight", 20, 14, 3, config.Patterns[1]));

                    #endregion

                    config.OnboardingStep = Onboarding.AskAboutGCD;
                    changed = true;
                    ImGui.CloseCurrentPopup();
                    ImGui.OpenPopup("Create GCD Cooldown Triggers");
                }

                ImGui.EndPopup();
            }

            if (config.OnboardingStep == Onboarding.AskAboutGCD)
            {
                ImGui.OpenPopup("Create GCD Cooldown Triggers");
            }
            ImGui.SetNextWindowSize(modalSize, ImGuiCond.Always);
            ImGuiHelpers.SetNextWindowPosRelativeMainViewport(modalPosition, ImGuiCond.Always);
            if (ImGui.BeginPopupModal("Create GCD Cooldown Triggers"))
            {
                ImGui.Text($"No GCD cooldown trigger found." +
                           $"\nCreate a GCD trigger for each job?");

                if (ImGui.Button("No##ExampleGCD"))
                {
                    config.OnboardingStep = Onboarding.Done;
                    changed = true;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();
                if (ImGui.Button(
                        "Yes##ExampleGCD"))
                {
                    var gcdActionsCollection =
                        allActions.Where(a => a.CooldownGroup == CooldownTrigger.GCDCooldownGroup);
                    var gcdActions = gcdActionsCollection as FFXIVAction[] ?? gcdActionsCollection.ToArray();
                    foreach (var job in jobs)
                    {
                        var action      = gcdActions.First(a => a.ClassJobCategory.Value.HasClass(job.RowId));
                        var lastTrigger = config.CooldownTriggers.LastOrDefault();
                        config.CooldownTriggers.Add(
                            new CooldownTrigger(
                                job.RowId,
                                action.Name,
                                action.RowId,
                                action.CooldownGroup,
                                lastTrigger?.Priority + 1 ?? 0,
                                config.Patterns[0]
                                ));
                    }

                    config.OnboardingStep = Onboarding.Done;
                    changed = true;
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }

            return(changed);
        }
Example #28
0
        private void DrawUnitBase(AtkUnitBase *atkUnitBase)
        {
            var isVisible = (atkUnitBase->Flags & 0x20) == 0x20;
            var addonName = Marshal.PtrToStringAnsi(new IntPtr(atkUnitBase->Name));
            var agent     = Service <GameGui> .Get().FindAgentInterface(atkUnitBase);

            ImGui.Text($"{addonName}");
            ImGui.SameLine();
            ImGui.PushStyleColor(ImGuiCol.Text, isVisible ? 0xFF00FF00 : 0xFF0000FF);
            ImGui.Text(isVisible ? "Visible" : "Not Visible");
            ImGui.PopStyleColor();

            ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - 25);
            if (ImGui.SmallButton("V"))
            {
                atkUnitBase->Flags ^= 0x20;
            }

            ImGui.Separator();
            ImGuiHelpers.ClickToCopyText($"Address: {(ulong)atkUnitBase:X}", $"{(ulong)atkUnitBase:X}");
            ImGuiHelpers.ClickToCopyText($"Agent: {(ulong)agent:X}", $"{(ulong)agent:X}");
            ImGui.Separator();

            ImGui.Text($"Position: [ {atkUnitBase->X} , {atkUnitBase->Y} ]");
            ImGui.Text($"Scale: {atkUnitBase->Scale * 100}%%");
            ImGui.Text($"Widget Count {atkUnitBase->UldManager.ObjectCount}");

            ImGui.Separator();

            object addonObj = *atkUnitBase;

            Util.ShowStruct(addonObj, (ulong)atkUnitBase);

            ImGui.Dummy(new Vector2(25 * ImGui.GetIO().FontGlobalScale));
            ImGui.Separator();
            if (atkUnitBase->RootNode != null)
            {
                this.PrintNode(atkUnitBase->RootNode);
            }

            if (atkUnitBase->UldManager.NodeListCount > 0)
            {
                ImGui.Dummy(new Vector2(25 * ImGui.GetIO().FontGlobalScale));
                ImGui.Separator();
                ImGui.PushStyleColor(ImGuiCol.Text, 0xFFFFAAAA);
                if (ImGui.TreeNode($"Node List##{(ulong)atkUnitBase:X}"))
                {
                    ImGui.PopStyleColor();

                    for (var j = 0; j < atkUnitBase->UldManager.NodeListCount; j++)
                    {
                        this.PrintNode(atkUnitBase->UldManager.NodeList[j], false, $"[{j}] ");
                    }

                    ImGui.TreePop();
                }
                else
                {
                    ImGui.PopStyleColor();
                }
            }
        }
Example #29
0
    /// <inheritdoc />
    public override void Draw()
    {
        var config = Service <DalamudConfiguration> .Get();

        var renameModalTitle = Loc.Localize("RenameStyleModalTitle", "Rename Style");

        var workStyle = config.SavedStyles[this.currentSel];

        workStyle.BuiltInColors ??= StyleModelV1.DalamudStandard.BuiltInColors;

        var appliedThisFrame = false;

        var styleAry = config.SavedStyles.Select(x => x.Name).ToArray();

        ImGui.Text(Loc.Localize("StyleEditorChooseStyle", "Choose Style:"));
        if (ImGui.Combo("###styleChooserCombo", ref this.currentSel, styleAry, styleAry.Length))
        {
            var newStyle = config.SavedStyles[this.currentSel];
            newStyle.Apply();
            appliedThisFrame = true;
        }

        if (ImGui.Button(Loc.Localize("StyleEditorAddNew", "Add new style")))
        {
            this.SaveStyle();

            var newStyle = StyleModelV1.DalamudStandard;
            newStyle.Name = GetRandomName();
            config.SavedStyles.Add(newStyle);

            this.currentSel = config.SavedStyles.Count - 1;

            newStyle.Apply();
            appliedThisFrame = true;

            config.Save();
        }

        ImGui.SameLine();

        if (ImGuiComponents.IconButton(FontAwesomeIcon.Trash) && this.currentSel != 0)
        {
            this.currentSel--;
            var newStyle = config.SavedStyles[this.currentSel];
            newStyle.Apply();
            appliedThisFrame = true;

            config.SavedStyles.RemoveAt(this.currentSel + 1);

            config.Save();
        }

        if (ImGui.IsItemHovered())
        {
            ImGui.SetTooltip(Loc.Localize("StyleEditorDeleteStyle", "Delete current style"));
        }

        ImGui.SameLine();

        if (ImGuiComponents.IconButton(FontAwesomeIcon.Pen) && this.currentSel != 0)
        {
            var newStyle = config.SavedStyles[this.currentSel];
            this.renameText = newStyle.Name;

            this.renameModalDrawing = true;
            ImGui.OpenPopup(renameModalTitle);
        }

        if (ImGui.IsItemHovered())
        {
            ImGui.SetTooltip(Loc.Localize("StyleEditorRenameStyle", "Rename style"));
        }

        ImGui.SameLine();

        ImGuiHelpers.ScaledDummy(5);
        ImGui.SameLine();

        if (ImGuiComponents.IconButton(FontAwesomeIcon.FileExport))
        {
            var selectedStyle = config.SavedStyles[this.currentSel];
            var newStyle      = StyleModelV1.Get();
            newStyle.Name = selectedStyle.Name;
            ImGui.SetClipboardText(newStyle.Serialize());
        }

        if (ImGui.IsItemHovered())
        {
            ImGui.SetTooltip(Loc.Localize("StyleEditorCopy", "Copy style to clipboard for sharing"));
        }

        ImGui.SameLine();

        if (ImGuiComponents.IconButton(FontAwesomeIcon.FileImport))
        {
            this.SaveStyle();

            var styleJson = ImGui.GetClipboardText();

            try
            {
                var newStyle = StyleModel.Deserialize(styleJson);

                newStyle.Name ??= GetRandomName();

                if (config.SavedStyles.Any(x => x.Name == newStyle.Name))
                {
                    newStyle.Name = $"{newStyle.Name} ({GetRandomName()} Mix)";
                }

                config.SavedStyles.Add(newStyle);
                newStyle.Apply();
                appliedThisFrame = true;

                this.currentSel = config.SavedStyles.Count - 1;

                config.Save();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Could not import style");
            }
        }

        if (ImGui.IsItemHovered())
        {
            ImGui.SetTooltip(Loc.Localize("StyleEditorImport", "Import style from clipboard"));
        }

        ImGui.Separator();

        ImGui.PushItemWidth(ImGui.GetWindowWidth() * 0.50f);

        if (this.currentSel < 2)
        {
            ImGui.TextColored(ImGuiColors.DalamudRed, Loc.Localize("StyleEditorNotAllowed", "You cannot edit built-in styles. Please add a new style first."));
        }
        else if (appliedThisFrame)
        {
            ImGui.Text(Loc.Localize("StyleEditorApplying", "Applying style..."));
        }
        else if (ImGui.BeginTabBar("StyleEditorTabs"))
        {
            var style = ImGui.GetStyle();

            if (ImGui.BeginTabItem(Loc.Localize("StyleEditorVariables", "Variables")))
            {
                ImGui.BeginChild($"ScrollingVars", ImGuiHelpers.ScaledVector2(0, -32), true, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground);

                ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 5);

                ImGui.SliderFloat2("WindowPadding", ref style.WindowPadding, 0.0f, 20.0f, "%.0f");
                ImGui.SliderFloat2("FramePadding", ref style.FramePadding, 0.0f, 20.0f, "%.0f");
                ImGui.SliderFloat2("CellPadding", ref style.CellPadding, 0.0f, 20.0f, "%.0f");
                ImGui.SliderFloat2("ItemSpacing", ref style.ItemSpacing, 0.0f, 20.0f, "%.0f");
                ImGui.SliderFloat2("ItemInnerSpacing", ref style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
                ImGui.SliderFloat2("TouchExtraPadding", ref style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
                ImGui.SliderFloat("IndentSpacing", ref style.IndentSpacing, 0.0f, 30.0f, "%.0f");
                ImGui.SliderFloat("ScrollbarSize", ref style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
                ImGui.SliderFloat("GrabMinSize", ref style.GrabMinSize, 1.0f, 20.0f, "%.0f");
                ImGui.Text("Borders");
                ImGui.SliderFloat("WindowBorderSize", ref style.WindowBorderSize, 0.0f, 1.0f, "%.0f");
                ImGui.SliderFloat("ChildBorderSize", ref style.ChildBorderSize, 0.0f, 1.0f, "%.0f");
                ImGui.SliderFloat("PopupBorderSize", ref style.PopupBorderSize, 0.0f, 1.0f, "%.0f");
                ImGui.SliderFloat("FrameBorderSize", ref style.FrameBorderSize, 0.0f, 1.0f, "%.0f");
                ImGui.SliderFloat("TabBorderSize", ref style.TabBorderSize, 0.0f, 1.0f, "%.0f");
                ImGui.Text("Rounding");
                ImGui.SliderFloat("WindowRounding", ref style.WindowRounding, 0.0f, 12.0f, "%.0f");
                ImGui.SliderFloat("ChildRounding", ref style.ChildRounding, 0.0f, 12.0f, "%.0f");
                ImGui.SliderFloat("FrameRounding", ref style.FrameRounding, 0.0f, 12.0f, "%.0f");
                ImGui.SliderFloat("PopupRounding", ref style.PopupRounding, 0.0f, 12.0f, "%.0f");
                ImGui.SliderFloat("ScrollbarRounding", ref style.ScrollbarRounding, 0.0f, 12.0f, "%.0f");
                ImGui.SliderFloat("GrabRounding", ref style.GrabRounding, 0.0f, 12.0f, "%.0f");
                ImGui.SliderFloat("LogSliderDeadzone", ref style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
                ImGui.SliderFloat("TabRounding", ref style.TabRounding, 0.0f, 12.0f, "%.0f");
                ImGui.Text("Alignment");
                ImGui.SliderFloat2("WindowTitleAlign", ref style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
                var windowMenuButtonPosition = (int)style.WindowMenuButtonPosition + 1;
                if (ImGui.Combo("WindowMenuButtonPosition", ref windowMenuButtonPosition, "None\0Left\0Right\0"))
                {
                    style.WindowMenuButtonPosition = (ImGuiDir)(windowMenuButtonPosition - 1);
                }
                ImGui.SliderFloat2("ButtonTextAlign", ref style.ButtonTextAlign, 0.0f, 1.0f, "%.2f");
                ImGui.SameLine();
                ImGuiComponents.HelpMarker("Alignment applies when a button is larger than its text content.");
                ImGui.SliderFloat2("SelectableTextAlign", ref style.SelectableTextAlign, 0.0f, 1.0f, "%.2f");
                ImGui.SameLine();
                ImGuiComponents.HelpMarker("Alignment applies when a selectable is larger than its text content.");
                ImGui.SliderFloat2("DisplaySafeAreaPadding", ref style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f");
                ImGui.SameLine();
                ImGuiComponents.HelpMarker(
                    "Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
                ImGui.EndTabItem();

                ImGui.EndChild();

                ImGui.EndTabItem();
            }

            if (ImGui.BeginTabItem(Loc.Localize("StyleEditorColors", "Colors")))
            {
                ImGui.BeginChild("ScrollingColors", ImGuiHelpers.ScaledVector2(0, -30), true, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground);

                ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 5);

                if (ImGui.RadioButton("Opaque", this.alphaFlags == ImGuiColorEditFlags.None))
                {
                    this.alphaFlags = ImGuiColorEditFlags.None;
                }
                ImGui.SameLine();
                if (ImGui.RadioButton("Alpha", this.alphaFlags == ImGuiColorEditFlags.AlphaPreview))
                {
                    this.alphaFlags = ImGuiColorEditFlags.AlphaPreview;
                }
                ImGui.SameLine();
                if (ImGui.RadioButton("Both", this.alphaFlags == ImGuiColorEditFlags.AlphaPreviewHalf))
                {
                    this.alphaFlags = ImGuiColorEditFlags.AlphaPreviewHalf;
                }
                ImGui.SameLine();

                ImGuiComponents.HelpMarker(
                    "In the color list:\n" +
                    "Left-click on color square to open color picker,\n" +
                    "Right-click to open edit options menu.");

                foreach (var imGuiCol in Enum.GetValues <ImGuiCol>())
                {
                    if (imGuiCol == ImGuiCol.COUNT)
                    {
                        continue;
                    }

                    ImGui.PushID(imGuiCol.ToString());

                    ImGui.ColorEdit4("##color", ref style.Colors[(int)imGuiCol], ImGuiColorEditFlags.AlphaBar | this.alphaFlags);

                    ImGui.SameLine(0.0f, style.ItemInnerSpacing.X);
                    ImGui.TextUnformatted(imGuiCol.ToString());

                    ImGui.PopID();
                }

                ImGui.Separator();

                foreach (var property in typeof(DalamudColors).GetProperties(BindingFlags.Public | BindingFlags.Instance))
                {
                    ImGui.PushID(property.Name);

                    var colorVal = property.GetValue(workStyle.BuiltInColors);
                    if (colorVal == null)
                    {
                        colorVal = property.GetValue(StyleModelV1.DalamudStandard.BuiltInColors);
                        property.SetValue(workStyle.BuiltInColors, colorVal);
                    }

                    var color = (Vector4)colorVal;

                    if (ImGui.ColorEdit4("##color", ref color, ImGuiColorEditFlags.AlphaBar | this.alphaFlags))
                    {
                        property.SetValue(workStyle.BuiltInColors, color);
                        workStyle.BuiltInColors?.Apply();
                    }

                    ImGui.SameLine(0.0f, style.ItemInnerSpacing.X);
                    ImGui.TextUnformatted(property.Name);

                    ImGui.PopID();
                }

                ImGui.EndChild();

                ImGui.EndTabItem();
            }

            ImGui.EndTabBar();
        }

        ImGui.PopItemWidth();

        ImGui.Separator();

        if (ImGui.Button(Loc.Localize("Close", "Close")))
        {
            this.IsOpen = false;
        }

        ImGui.SameLine();

        if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close")))
        {
            this.SaveStyle();

            config.ChosenStyle = config.SavedStyles[this.currentSel].Name;
            Log.Verbose("ChosenStyle = {ChosenStyle}", config.ChosenStyle);

            this.didSave = true;

            this.IsOpen = false;
        }

        if (ImGui.BeginPopupModal(renameModalTitle, ref this.renameModalDrawing, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar))
        {
            ImGui.Text(Loc.Localize("StyleEditorEnterName", "Please enter the new name for this style."));
            ImGui.Spacing();

            ImGui.InputText("###renameModalInput", ref this.renameText, 255);

            const float buttonWidth = 120f;
            ImGui.SetCursorPosX((ImGui.GetWindowWidth() - buttonWidth) / 2);

            if (ImGui.Button("OK", new Vector2(buttonWidth, 40)))
            {
                config.SavedStyles[this.currentSel].Name = this.renameText;
                config.Save();

                ImGui.CloseCurrentPopup();
            }

            ImGui.EndPopup();
        }
    }
Example #30
0
 /// <summary>
 /// Create a dummy scaled for use without tabs.
 /// </summary>
 public static void SpacerNoTabs()
 {
     ImGuiHelpers.ScaledDummy(28f);
 }