示例#1
0
            private void DrawAboutTab()
            {
                if (!_editMode && Meta.Description.Length == 0)
                {
                    return;
                }

                if (!ImGui.BeginTabItem(LabelAboutTab))
                {
                    return;
                }

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

                var desc  = Meta.Description;
                var flags = _editMode
                    ? ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CtrlEnterForNewLine
                    : ImGuiInputTextFlags.ReadOnly;

                if (_editMode)
                {
                    if (ImGui.InputTextMultiline(LabelDescEdit, ref desc, 1 << 16,
                                                 AutoFillSize, flags))
                    {
                        Meta.Description = desc;
                        _selector.SaveCurrentMod();
                    }

                    ImGuiCustom.HoverTooltip(TooltipAboutEdit);
                }
                else
                {
                    ImGui.TextWrapped(desc);
                }
            }
示例#2
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();
        }
示例#3
0
文件: MenuBar.cs 项目: pmgr/Penumbra
            public void Draw()
            {
                if (!_showDebugBar || !ImGui.BeginMainMenuBar())
                {
                    return;
                }

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

                if (!ImGui.BeginMenu(MenuLabel))
                {
                    return;
                }

                raii.Push(ImGui.EndMenu);

                if (ImGui.MenuItem(MenuItemToggle, SlashCommand, _base._menu.Visible))
                {
                    _base.FlipVisibility();
                }

                if (ImGui.MenuItem(MenuItemRediscover))
                {
                    _base.ReloadMods();
                }
#if DEBUG
                if (ImGui.MenuItem(MenuItemHide))
                {
                    _showDebugBar = false;
                }
#endif
            }
示例#4
0
        private ImGuiRaii?DrawTableHeader(int type)
        {
            const ImGuiTableFlags flags = ImGuiTableFlags.Hideable
                                          | ImGuiTableFlags.BordersOuter
                                          | ImGuiTableFlags.BordersInner
                                          | ImGuiTableFlags.SizingFixedSame;

            var list = type switch
            {
                2 => VisorStateWeaponNames,
                3 => CPoseManager.PoseNames,
                _ => VisorStateNames,
            };

            var imgui = new ImGuiRaii();

            if (!imgui.Begin(() => ImGui.BeginTable($"##table_{type}_{_currentPlayer}", list.Length + 1, flags), ImGui.EndTable))
            {
                return(null);
            }

            ImGui.TableSetupColumn($"Job##empty_{type}_{_currentPlayer}", ImGuiTableColumnFlags.NoHide);
            foreach (var name in list)
            {
                ImGui.TableSetupColumn(name);
            }

            ImGui.TableHeadersRow();
            return(imgui);
        }
示例#5
0
        private static void DrawDebugTabPlayers()
        {
            if (!ImGui.CollapsingHeader("Players##Debug"))
            {
                return;
            }

            var players = Penumbra.PlayerWatcher.WatchedPlayers().ToArray();
            var count   = players.Sum(s => Math.Max(1, s.Item2.Length));

            if (count == 0)
            {
                return;
            }

            if (!ImGui.BeginTable("##ObjectTable", 13, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.ScrollX,
                                  new Vector2(-1, ImGui.GetTextLineHeightWithSpacing() * 4 * count)))
            {
                return;
            }

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

            var identifier = GameData.GameData.GetIdentifier();

            foreach (var(actor, equip) in players.SelectMany(kvp => kvp.Item2.Any()
                ? kvp.Item2
                                                             .Select(x => ($"{kvp.Item1} ({x.Item1})", x.Item2))
                : new[] { (kvp.Item1, new CharacterEquipment()) }))
示例#6
0
            private void DrawVersion()
            {
                if (_editMode)
                {
                    ImGui.BeginGroup();
                    using var raii = ImGuiRaii.DeferredEnd(ImGui.EndGroup);
                    ImGui.Text("(Version ");

                    using var style = ImGuiRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ZeroVector);
                    ImGui.SameLine();
                    var version = Meta !.Version;
                    if (ImGuiCustom.ResizingTextInput(LabelEditVersion, ref version, 16) &&
                        version != Meta.Version)
                    {
                        Meta.Version = version;
                        _selector.SaveCurrentMod();
                    }

                    ImGui.SameLine();
                    ImGui.Text(")");
                }
                else if (Meta !.Version.Length > 0)
                {
                    ImGui.Text($"(Version {Meta.Version})");
                }
            }
示例#7
0
            private void DrawFileListTab()
            {
                if (!ImGui.BeginTabItem(LabelFileListTab))
                {
                    return;
                }

                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem);
                ImGuiCustom.HoverTooltip(TooltipFilesTab);

                ImGui.SetNextItemWidth(-1);
                if (ImGui.BeginListBox(LabelFileListHeader, AutoFillSize))
                {
                    raii.Push(ImGui.EndListBox);
                    UpdateFilenameList();
                    using var colorRaii = new ImGuiRaii.Color();
                    foreach (var(name, _, color, _) in _fullFilenameList !)
                    {
                        colorRaii.Push(ImGuiCol.Text, color);
                        ImGui.Selectable(name.FullName);
                        colorRaii.Pop();
                    }
                }
                else
                {
                    _fullFilenameList = null;
                }
            }
示例#8
0
 // === Help ===
 private void DrawModHelpButton()
 {
     using var raii = ImGuiRaii.PushFont(UiBuilder.IconFont);
     if (ImGui.Button(FontAwesomeIcon.QuestionCircle.ToIconString(), HelpButtonSizes * _selectorScalingFactor))
     {
         ImGui.OpenPopup(LabelModHelpPopup);
     }
 }
示例#9
0
        private static bool DrawPressEnterWarning(string old, float?width = null)
        {
            const uint red = 0xFF202080;

            using var color = ImGuiRaii.PushColor(ImGuiCol.Button, red);
            var w = Vector2.UnitX * (width ?? ImGui.CalcItemWidth());

            return(ImGui.Button($"Press Enter or Click Here to Save (Current Directory: {old})", w));
        }
示例#10
0
            private void DrawWebsite()
            {
                ImGui.BeginGroup();
                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndGroup);
                if (_editMode)
                {
                    ImGui.TextColored(GreyColor, "from");
                    ImGui.SameLine();
                    var website = Meta !.Website;
                    if (ImGuiCustom.ResizingTextInput(LabelEditWebsite, ref website, 512) &&
                        website != Meta.Website)
                    {
                        Meta.Website = website;
                        _selector.SaveCurrentMod();
                    }
                }
                else if (Meta !.Website.Length > 0)
                {
                    if (_currentWebsite != Meta.Website)
                    {
                        _currentWebsite = Meta.Website;
                        _validWebsite   = Uri.TryCreate(Meta.Website, UriKind.Absolute, out var uriResult) &&
                                          (uriResult.Scheme == Uri.UriSchemeHttps || uriResult.Scheme == Uri.UriSchemeHttp);
                    }

                    if (_validWebsite)
                    {
                        if (ImGui.SmallButton(ButtonOpenWebsite))
                        {
                            try
                            {
                                var process = new ProcessStartInfo(Meta.Website)
                                {
                                    UseShellExecute = true,
                                };
                                Process.Start(process);
                            }
                            catch (System.ComponentModel.Win32Exception)
                            {
                                // Do nothing.
                            }
                        }

                        ImGuiCustom.HoverTooltip(Meta.Website);
                    }
                    else
                    {
                        ImGui.TextColored(GreyColor, "from");
                        ImGui.SameLine();
                        ImGui.Text(Meta.Website);
                    }
                }
            }
示例#11
0
            // === Main ===
            private void DrawModsSelectorButtons()
            {
                // Selector controls
                using var style = ImGuiRaii.PushStyle(ImGuiStyleVar.WindowPadding, ZeroVector)
                                  .Push(ImGuiStyleVar.FrameRounding, 0);

                DrawModAddButton();
                ImGui.SameLine();
                DrawModHelpButton();
                ImGui.SameLine();
                DrawModTrashButton();
            }
示例#12
0
            private void DrawModTrashButton()
            {
                using var raii = ImGuiRaii.PushFont(UiBuilder.IconFont);

                if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString(), SelectorButtonSizes * _selectorScalingFactor) && _index >= 0)
                {
                    _deleteIndex = _index;
                }

                raii.Pop();

                ImGuiCustom.HoverTooltip(TooltipDelete);
            }
示例#13
0
            private ImGuiRaii.EndStack DrawMultiSelectorEditBegin(OptionGroup group)
            {
                var groupName = group.GroupName;

                if (ImGuiCustom.BeginFramedGroupEdit(ref groupName))
                {
                    if (_modManager.ChangeModGroup(group.GroupName, groupName, Mod.Data) && Mod.Data.Meta.RefreshHasGroupsWithConfig())
                    {
                        _selector.Cache.TriggerFilterReset();
                    }
                }

                return(ImGuiRaii.DeferredEnd(ImGuiCustom.EndFramedGroup));
            }
示例#14
0
            private void DrawModAddPopup()
            {
                if (!ImGui.BeginPopup(LabelAddModPopup))
                {
                    return;
                }

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

                if (_modAddKeyboardFocus)
                {
                    ImGui.SetKeyboardFocusHere();
                    _modAddKeyboardFocus = false;
                }

                var newName = "";

                if (ImGui.InputTextWithHint("##AddMod", "New Mod Name...", ref newName, 64, ImGuiInputTextFlags.EnterReturnsTrue))
                {
                    try
                    {
                        var newDir = TexToolsImport.CreateModFolder(new DirectoryInfo(Penumbra.Config !.ModDirectory),
                                                                    newName);
                        var modMeta = new ModMeta
                        {
                            Author      = "Unknown",
                            Name        = newName.Replace('/', '\\'),
                            Description = string.Empty,
                        };

                        var metaFile = new FileInfo(Path.Combine(newDir.FullName, "meta.json"));
                        modMeta.SaveToFile(metaFile);
                        _modManager.AddMod(newDir);
                        ModFileSystem.InvokeChange();
                        SelectModOnUpdate(newDir.Name);
                    }
                    catch (Exception e)
                    {
                        PluginLog.Error($"Could not create directory for new Mod {newName}:\n{e}");
                    }

                    ImGui.CloseCurrentPopup();
                }

                if (ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.Escape)))
                {
                    ImGui.CloseCurrentPopup();
                }
            }
示例#15
0
            public void Draw()
            {
                var ret = ImGui.BeginTabItem(LabelTab);

                if (!ret)
                {
                    return;
                }

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

                Selector.Draw();
                ImGui.SameLine();
                ModPanel.Draw();
            }
示例#16
0
            private void DrawModAddButton()
            {
                using var raii = ImGuiRaii.PushFont(UiBuilder.IconFont);

                if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString(), SelectorButtonSizes * _selectorScalingFactor))
                {
                    _modAddKeyboardFocus = true;
                    ImGui.OpenPopup(LabelAddModPopup);
                }

                raii.Pop();

                ImGuiCustom.HoverTooltip(TooltipAdd);

                DrawModAddPopup();
            }
示例#17
0
    private unsafe void DrawResourceMap(string label, StdMap <uint, Pointer <ResourceHandle> > *typeMap)
    {
        if (typeMap == null || !ImGui.TreeNodeEx(label))
        {
            return;
        }

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

        if (typeMap->Count == 0 || !ImGui.BeginTable($"##{label}_table", 4, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg))
        {
            return;
        }

        raii.Push(ImGui.EndTable);

        ImGui.TableSetupColumn("Hash", ImGuiTableColumnFlags.WidthFixed, 100 * ImGuiHelpers.GlobalScale);
        ImGui.TableSetupColumn("Ptr", ImGuiTableColumnFlags.WidthFixed, 100 * ImGuiHelpers.GlobalScale);
        ImGui.TableSetupColumn("Path", ImGuiTableColumnFlags.WidthFixed,
                               ImGui.GetWindowContentRegionWidth() - 300 * ImGuiHelpers.GlobalScale);
        ImGui.TableSetupColumn("Refs", ImGuiTableColumnFlags.WidthFixed, 30 * ImGuiHelpers.GlobalScale);
        ImGui.TableHeadersRow();

        var node = typeMap->SmallestValue;

        while (!node->IsNil)
        {
            ImGui.TableNextRow();
            ImGui.TableNextColumn();
            ImGui.Text($"0x{node->KeyValuePair.Item1:X8}");
            ImGui.TableNextColumn();
            var address = $"0x{( ulong )node->KeyValuePair.Item2.Value:X}";
            ImGui.Text(address);
            if (ImGui.IsItemClicked())
            {
                ImGui.SetClipboardText(address);
            }

            ImGui.TableNextColumn();
            ImGui.Text(node->KeyValuePair.Item2.Value->FileName.ToString());
            ImGui.TableNextColumn();
            ImGui.Text(node->KeyValuePair.Item2.Value->RefCount.ToString());
            node = node->Next();
        }
    }
示例#18
0
    private unsafe void DrawCategoryContainer(ResourceCategory category, ResourceGraph.CategoryContainer container)
    {
        var map = container.MainMap;

        if (map == null || !ImGui.TreeNodeEx($"({( uint )category:D2}) {category} - {map->Count}###{( uint )category}Debug"))
        {
            return;
        }

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

        var node = map->SmallestValue;

        while (!node->IsNil)
        {
            DrawResourceMap(GetNodeLabel(( uint )category, node->KeyValuePair.Item1, node->KeyValuePair.Item2.Value->Count),
                            node->KeyValuePair.Item2.Value);
            node = node->Next();
        }
    }
示例#19
0
            private void DrawChangedItemsTab()
            {
                if (Mod.Data.ChangedItems.Count == 0 || !ImGui.BeginTabItem(LabelChangedItemsTab))
                {
                    return;
                }

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

                if (!ImGui.BeginListBox(LabelChangedItemsHeader, AutoFillSize))
                {
                    return;
                }

                raii.Push(ImGui.EndListBox);
                foreach (var(name, data) in Mod.Data.ChangedItems)
                {
                    _base.DrawChangedItem(name, data);
                }
            }
示例#20
0
            private void DrawConflictTab()
            {
                if (!Mod.Cache.Conflicts.Any() || !ImGui.BeginTabItem(LabelConflictsTab))
                {
                    return;
                }

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

                ImGui.SetNextItemWidth(-1);
                if (!ImGui.BeginListBox(LabelConflictsHeader, AutoFillSize))
                {
                    return;
                }

                raii.Push(ImGui.EndListBox);
                using var indent = ImGuiRaii.PushIndent(0);
                foreach (var(mod, (files, manipulations)) in Mod.Cache.Conflicts)
                {
                    if (ImGui.Selectable(mod.Data.Meta.Name))
                    {
                        _selector.SelectModByDir(mod.Data.BasePath.Name);
                    }

                    ImGui.SameLine();
                    ImGui.Text($"(Priority {mod.Settings.Priority})");

                    indent.Push(15f);
                    foreach (var file in files)
                    {
                        ImGui.Selectable(file);
                    }

                    foreach (var manip in manipulations)
                    {
                        ImGui.Text(manip.IdentifierString());
                    }

                    indent.Pop(15f);
                }
            }
示例#21
0
            private void DrawFileSwapTab()
            {
                if (_editMode)
                {
                    DrawFileSwapTabEdit();
                    return;
                }

                if (!Meta.FileSwaps.Any() || !ImGui.BeginTabItem(LabelFileSwapTab))
                {
                    return;
                }

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

                const ImGuiTableFlags flags = ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX;

                ImGui.SetNextItemWidth(-1);
                if (!ImGui.BeginTable(LabelFileSwapHeader, 3, flags, AutoFillSize))
                {
                    return;
                }

                raii.Push(ImGui.EndTable);

                foreach (var(source, target) in Meta.FileSwaps)
                {
                    ImGui.TableNextColumn();
                    ImGuiCustom.CopyOnClickSelectable(source);

                    ImGui.TableNextColumn();
                    ImGuiCustom.PrintIcon(FontAwesomeIcon.LongArrowAltRight);

                    ImGui.TableNextColumn();
                    ImGuiCustom.CopyOnClickSelectable(target);

                    ImGui.TableNextRow();
                }
            }
示例#22
0
    private unsafe void DrawResourceManagerTab()
    {
        if (!ImGui.BeginTabItem("Resource Manager Tab"))
        {
            return;
        }

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

        var resourceHandler = *( ResourceManager ** )(Dalamud.SigScanner.Module.BaseAddress + 0x1E5B440);

        if (resourceHandler == null)
        {
            return;
        }

        raii.Push(ImGui.EndChild);
        if (!ImGui.BeginChild("##ResourceManagerChild", -Vector2.One, true))
        {
            return;
        }

        DrawCategoryContainer(ResourceCategory.Common, resourceHandler->ResourceGraph->CommonContainer);
        DrawCategoryContainer(ResourceCategory.BgCommon, resourceHandler->ResourceGraph->BgCommonContainer);
        DrawCategoryContainer(ResourceCategory.Bg, resourceHandler->ResourceGraph->BgContainer);
        DrawCategoryContainer(ResourceCategory.Cut, resourceHandler->ResourceGraph->CutContainer);
        DrawCategoryContainer(ResourceCategory.Chara, resourceHandler->ResourceGraph->CharaContainer);
        DrawCategoryContainer(ResourceCategory.Shader, resourceHandler->ResourceGraph->ShaderContainer);
        DrawCategoryContainer(ResourceCategory.Ui, resourceHandler->ResourceGraph->UiContainer);
        DrawCategoryContainer(ResourceCategory.Sound, resourceHandler->ResourceGraph->SoundContainer);
        DrawCategoryContainer(ResourceCategory.Vfx, resourceHandler->ResourceGraph->VfxContainer);
        DrawCategoryContainer(ResourceCategory.UiScript, resourceHandler->ResourceGraph->UiScriptContainer);
        DrawCategoryContainer(ResourceCategory.Exd, resourceHandler->ResourceGraph->ExdContainer);
        DrawCategoryContainer(ResourceCategory.GameScript, resourceHandler->ResourceGraph->GameScriptContainer);
        DrawCategoryContainer(ResourceCategory.Music, resourceHandler->ResourceGraph->MusicContainer);
        DrawCategoryContainer(ResourceCategory.SqpackTest, resourceHandler->ResourceGraph->SqpackTestContainer);
        DrawCategoryContainer(ResourceCategory.Debug, resourceHandler->ResourceGraph->DebugContainer);
    }