Exemplo n.º 1
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()) }))
Exemplo n.º 2
0
        public void DrawFieldTable(
            SortedList <string, FieldInfo> field_list,
            string table_name = "FieldTable"
            )
        {
            if (field_list.Count == 0)
            {
                return;
            }

            if (ImGui.BeginTable(table_name, 2, TableFlags))
            {
                ImGuiEx.TableSetupHeaders("Type", "Name");

                foreach (var fieldPair in field_list)
                {
                    ImGui.TableNextRow();
                    ImGui.TableSetColumnIndex(0);
                    fieldDrawer.DrawType(fieldPair.Value.FieldType);

                    ImGuiEx.TableTextRow(1, fieldPair.Key);
                }
                ImGui.EndTable();
            }
        }
Exemplo n.º 3
0
        public void DrawPropertyTable(
            SortedList <string, PropertyInfo> property_list,
            string table_name = "PropertyTable"
            )
        {
            if (property_list.Count == 0)
            {
                return;
            }

            if (ImGui.BeginTable(table_name, 4, TableFlags))
            {
                ImGuiEx.TableSetupHeaders(
                    "Type",
                    "Name",
                    "Gettable",
                    "Settable");
                foreach (var property in property_list)
                {
                    ImGui.TableNextRow();
                    ImGui.TableSetColumnIndex(0);
                    propertyDrawer.DrawType(property.Value.PropertyType);

                    ImGuiEx.TableTextRow(1, property.Key, property.Value.CanRead.ToString(), property.Value.CanWrite.ToString());
                }
                ImGui.EndTable();
            }
        }
Exemplo n.º 4
0
        public void DrawInstancePropertyTable(
            SortedList <string, PropertyInfo> property_list,
            string table_name = "StaticPropertyTable"
            )
        {
            if (property_list.Count == 0)
            {
                return;
            }

            if (ImGui.BeginTable(table_name, 5, TableFlags))
            {
                ImGuiEx.TableSetupHeaders(
                    "Type",
                    "Name",
                    "Value",
                    "Gettable",
                    "Settable");

                foreach (var propertyPair in property_list)
                {
                    ImGui.TableNextRow();
                    DrawInstanceTableRow(propertyPair);
                }
                ImGui.EndTable();
            }
        }
Exemplo n.º 5
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);
        }
    public static void DrawArrayDataTable(NumberArrayData *array)
    {
        if (ImGui.BeginTable("numbersTable", 6, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg))
        {
            ImGui.TableSetupColumn("#", ImGuiTableColumnFlags.WidthFixed, 50);
            ImGui.TableSetupColumn("Integer");
            ImGui.TableSetupColumn("Shorts");
            ImGui.TableSetupColumn("Bytes");
            ImGui.TableSetupColumn("Hex");
            ImGui.TableSetupColumn("Float");
            ImGui.TableHeadersRow();

            for (var i = 0; i < array->AtkArrayData.Size; i++)
            {
                ImGui.TableNextColumn();
                DebugManager.ClickToCopyText($"{i.ToString().PadLeft(array->AtkArrayData.Size.ToString().Length, '0')}", $"{(ulong)&array->IntArray[i]:X}");
                ImGui.TableNextColumn();
                ImGui.Text($"{array->IntArray[i]}");
                ImGui.TableNextColumn();

                {
                    var a  = (short *)&array->IntArray[i];
                    var w  = ImGui.GetContentRegionAvail().X;
                    var bX = ImGui.GetCursorPosX();
                    for (var bi = 0; bi < 2; bi++)
                    {
                        ImGui.SetCursorPosX(bX + (w / 2) * bi);
                        ImGui.Text(ImGui.GetIO().KeyShift ? $"{a[bi]:X4}" : $"{a[bi]}");
                        if (bi != 1)
                        {
                            ImGui.SameLine();
                        }
                    }
                }


                ImGui.TableNextColumn();

                {
                    var a  = (byte *)&array->IntArray[i];
                    var w  = ImGui.GetContentRegionAvail().X;
                    var bX = ImGui.GetCursorPosX();
                    for (var bi = 0; bi < 4; bi++)
                    {
                        ImGui.SetCursorPosX(bX + (w / 4) * bi);
                        ImGui.Text(ImGui.GetIO().KeyShift ? $"{a[bi]:X2}" : $"{a[bi]}");
                        if (bi != 3)
                        {
                            ImGui.SameLine();
                        }
                    }
                }


                ImGui.TableNextColumn();

                var hexText = $"{array->IntArray[i]:X}";
                ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
                ImGui.TextDisabled("00000000"[..(8 - hexText.Length)]);
Exemplo n.º 7
0
        private void DrawExceptionSelectBox(PlottedGraph plot)
        {
            uint[]? exceptionNodes = plot.InternalProtoGraph.GetExceptionNodes();
            if (exceptionNodes is null || exceptionNodes.Length == 0)
            {
                string caption = $"No exceptions recorded in thread ID {_ActiveGraph?.TID}";
                ImGuiUtils.DrawRegionCenteredText(caption);
                return;
            }

            string[] labels = exceptionNodes.Select(x => x.ToString()).ToArray();
            if (ImGui.BeginTable("##ExceptionsTable", 2, ImGuiTableFlags.ScrollY | ImGuiTableFlags.RowBg, ImGui.GetContentRegionAvail() - new Vector2(10, _activeHighlights.SelectedExceptionNodes.Any() ? 30 : 0)))
            {
                ImGui.TableSetupColumn("Address", ImGuiTableColumnFlags.WidthFixed, 160);
                ImGui.TableSetupColumn("Module");
                ImGui.TableSetupScrollFreeze(0, 1);
                ImGui.TableHeadersRow();

                foreach (uint nodeidx in exceptionNodes)
                {
                    NodeData?n = plot.InternalProtoGraph.GetNode(nodeidx);

                    if (n is not null)
                    {
                        ImGui.TableNextRow();
                        if (ImGui.TableNextColumn())
                        {
                            if (ImGui.Selectable($"0x{n.Address:X}", _activeHighlights.SelectedExceptionNodes.Contains(nodeidx), ImGuiSelectableFlags.SpanAllColumns))
                            {
                                if (_activeHighlights.SelectedExceptionNodes.Contains(nodeidx))
                                {
                                    _activeHighlights.SelectedExceptionNodes.Remove(nodeidx);
                                    plot.RemoveHighlightedNodes(new List <uint> {
                                        nodeidx
                                    }, CONSTANTS.HighlightType.Exceptions);
                                }
                                else
                                {
                                    _activeHighlights.SelectedExceptionNodes.Add(nodeidx);
                                    plot.AddHighlightedNodes(new List <uint> {
                                        nodeidx
                                    }, CONSTANTS.HighlightType.Exceptions);
                                }
                            }
                        }
                        if (ImGui.TableNextColumn())
                        {
                            ImGui.Text(System.IO.Path.GetFileName(plot.InternalProtoGraph.ProcessData.GetModulePath(n.GlobalModuleID)));
                        }
                    }
                }
                ImGui.EndTable();
            }
        }
        public override void Draw()
        {
            Begin("PerformanceMonitor.Draw");

            if (ImGui.SmallButton("Reset All"))
            {
                ClearAll();
            }

            if (ImGui.BeginTable("performanceTable", 7, ImGuiTableFlags.Borders | ImGuiTableFlags.ScrollX))
            {
                ImGui.TableSetupColumn("Reset");
                ImGui.TableSetupColumn("Key");
                ImGui.TableSetupColumn("Last Check");
                ImGui.TableSetupColumn("Average");
                ImGui.TableSetupColumn("Maximum");
                ImGui.TableSetupColumn("");
                ImGui.TableSetupColumn("Average/Sec");

                ImGui.TableHeadersRow();
                ImGui.TableNextColumn();

                foreach (var log in Logs)
                {
                    if (ImGui.SmallButton("Reset"))
                    {
                        log.Value.Clear();
                    }
                    ImGui.TableNextColumn();
                    ImGui.Text($"{log.Key}");
                    ImGui.TableNextColumn();
                    ImGui.Text($"{log.Value.Last}");
                    ImGui.TableNextColumn();
                    ImGui.Text($"{log.Value.Average}");
                    ImGui.TableNextColumn();
                    ImGui.Text($"{log.Value.Max}");
                    ImGui.TableNextColumn();
                    ImGui.TableNextColumn();
                    ImGui.Text($"{log.Value.AveragePerSecond}");

                    ImGui.TableNextColumn();
                }



                ImGui.EndTable();
            }

            End("PerformanceMonitor.Draw");
        }
Exemplo n.º 9
0
        protected override void OnDraw()
        {
            EntityWorld world = EntityWorld.Active;
            StructArray <EntityChunk> chunks = world.EntityManager.GetChunks();

            for (int i = 0; i < chunks.Count; i++)
            {
                ref EntityChunk chunk = ref chunks[i];
                bool            open  = ImGui.TreeNode($"[{i}] Chunk: {chunk.Count}/{chunk.Capacity}");
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip(chunk.Archetype.ToString());
                }
                if (open)
                {
                    ImGuiTableFlags tFlags = ImGuiTableFlags.RowBg | ImGuiTableFlags.Resizable;
                    if (ImGui.BeginTable("Entities", 2, tFlags))
                    {
                        ImGui.TableSetupColumn("Id");
                        ImGui.TableSetupColumn("Version");
                        ImGui.TableHeadersRow();

                        for (int e = 0; e < chunk.Count; e++)
                        {
                            Entity entity = chunk.GetEntity(e);

                            ImGui.TableNextRow();
                            ImGui.TableNextColumn();

                            bool isSelected = ObjectSelections.CurrentObj?.Equals(entity) ?? false;
                            if (ImGui.Selectable($"##{e}", isSelected, ImGuiSelectableFlags.SpanAllColumns))
                            {
                                ObjectSelections.SelectObject(entity);
                            }
                            ImGui.SameLine();
                            ImGui.Text(entity.id.ToString());

                            ImGui.TableNextColumn();
                            ImGui.Text(entity.version.ToString());
                        }
                        ImGui.Separator();
                        ImGui.EndTable();
                    }
                    ImGui.TreePop();
                }
            }
Exemplo n.º 10
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();
        }
    }
Exemplo n.º 11
0
            public void Draw()
            {
                if (!ImGui.BeginTabItem(LabelTab))
                {
                    return;
                }
                var items  = _modManager.Collections.ActiveCollection.Cache?.ChangedItems ?? new Dictionary <string, object?>();
                var forced = _modManager.Collections.ForcedCollection.Cache?.ChangedItems ?? new Dictionary <string, object?>();

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

                ImGui.SetNextItemWidth(-1);
                if (ImGui.InputTextWithHint("##ChangedItemsFilter", "Filter...", ref _filter, 64))
                {
                    _filterLower = _filter.ToLowerInvariant();
                }

                if (!ImGui.BeginTable("##ChangedItemsTable", 1, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY, AutoFillSize))
                {
                    return;
                }

                raii.Push(ImGui.EndTable);

                var list = items.AsEnumerable();

                if (forced.Count > 0)
                {
                    list = list.Concat(forced).OrderBy(kvp => kvp.Key);
                }

                if (_filter.Any())
                {
                    list = list.Where(kvp => kvp.Key.ToLowerInvariant().Contains(_filterLower));
                }

                foreach (var(name, data) in list)
                {
                    ImGui.TableNextRow();
                    ImGui.TableNextColumn();
                    _base.DrawChangedItem(name, data, ImGui.GetStyle().ScrollbarSize);
                }
            }
Exemplo n.º 12
0
        public void DrawMethodTable(
            SortedList <string, MethodInfo> table,
            string TableName = "ClassMethodTable"
            )
        {
            if (table.Count == 0)
            {
                return;
            }

            if (ImGui.BeginTable(TableName, 3, TableFlags))
            {
                ImGuiEx.TableSetupHeaders("Return Type", "Name", "Param");

                foreach (var method in table)
                {
                    ImGui.TableNextRow();
                    DrawTableRow(method);
                }
                ImGui.EndTable();
            }
        }
Exemplo n.º 13
0
        public void DrawInstanceFieldTable(
            SortedList <string, FieldInfo> field_list,
            string table_name = "InstanceFieldTable"
            )
        {
            if (field_list.Count == 0)
            {
                return;
            }

            if (ImGui.BeginTable(table_name, 3, TableFlags))
            {
                ImGuiEx.TableSetupHeaders("Type", "Name", "Value");

                foreach (var fieldPair in field_list)
                {
                    ImGui.TableNextRow();
                    DrawInstanceTableRow(fieldPair);
                }
                ImGui.EndTable();
            }
        }
Exemplo n.º 14
0
        public override void DrawWindowContent()
        {
            if (ImGui.BeginTable("EditorTable", 3, TableFlags))
            {
                ImGuiEx.TableSetupHeaders();

                //Left
                ImGui.TableSetColumnIndex(0);
                DrawLeft();
                DrawConsoleOutput();

                //Middle
                ImGui.TableSetColumnIndex(1);
                DrawEditorTop();
                m_TabBarView.Draw();
                m_NodeEditor.DrawWindowContent();

                //Right
                ImGui.TableSetColumnIndex(2);
                DrawRight();
                ImGui.EndTable();
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Draw a trace selector
        /// </summary>
        /// <param name="trace">Parent trace</param>
        /// <param name="abbreviate">Make the label a bit shorter to fit in the preview pane width</param>
        /// <returns>Selected graph or null</returns>
        public static PlottedGraph?Draw(TraceRecord?trace, bool abbreviate = false)
        {
            if (trace is null)
            {
                if (ImGui.BeginChild(ImGui.GetID("TraceSelect"), new Vector2(ImGui.GetContentRegionAvail().X - 4, ImGui.GetContentRegionAvail().Y)))
                {
                    ImGuiUtils.DrawRegionCenteredText($"No selected trace");
                    ImGui.EndChild();
                }
                return(null);
            }

            PlottedGraph?selectedGraph = null;

            if (ImGui.BeginChild(ImGui.GetID("TraceSelect"), new Vector2(ImGui.GetContentRegionAvail().X - 4, 52)))
            {
                ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(1, 1));
                if (ImGui.BeginTable("#TraceSelectorTable", 2))
                {
                    ImGui.TableSetupColumn("#IconsTraceSel", ImGuiTableColumnFlags.WidthFixed, 35);
                    ImGui.TableNextRow();
                    DrawTraceCombo(trace, abbreviate);

                    ImGui.TableNextRow();
                    DrawThreadSelectorCombo(trace, out selectedGraph, abbreviate);
                    ImGui.EndTable();
                }
                ImGui.PopStyleVar();
                ImGui.EndChild();
            }

            if (selectedGraph is not null)
            {
                rgatState.SetActiveGraph(selectedGraph);
            }
            return(selectedGraph);
        }
Exemplo n.º 16
0
            public void Draw()
            {
                var ret = ImGui.BeginTabItem(LabelTab);

                if (!ret)
                {
                    return;
                }

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

                if (ImGui.BeginTable("##effective_files", 3, flags, AutoFillSize))
                {
                    foreach (var file in _mods.ResolvedFiles)
                    {
                        DrawFileLine(file.Value, file.Key);
                        ImGui.TableNextRow();
                    }

                    ImGui.EndTable();
                }

                ImGui.EndTabItem();
            }
Exemplo n.º 17
0
        private void DrawSelected(int selected)
        {
            LogData log = logs[selected];

            ImGui.Text(log.log.ToString());
            ImGui.Separator();
            ImGui.BeginTable("stacktrace", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.Borders | ImGuiTableFlags.SizingStretchProp);
            ImGui.TableSetupColumn("Depth");
            ImGui.TableSetupColumn("Path");
            ImGui.TableSetupColumn("Method");
            ImGui.TableHeadersRow();

            string stack = log.trace.ToString();

            string[] lines = stack.Split('\n');
            for (int i = 0; i < lines.Length - 1; i++)
            {
                string line    = lines[i].Trim();
                int    atIndex = line.IndexOf("at ");
                int    inIndex = line.IndexOf(" in ");
                string method  = line;
                if (inIndex != -1)
                {
                    method = method[atIndex..inIndex].Remove(0, 3);
    public override void Draw()
    {
        ImGui.Text($"{Name} Debug");
        ImGui.Separator();

        var raptureHotbarModule = Framework.Instance()->GetUiModule()->GetRaptureHotbarModule();

        ImGui.Text("RaptureHotbarModule:");
        ImGui.SameLine();
        DebugManager.ClickToCopyText($"{(ulong)raptureHotbarModule:X}");
        ImGui.SameLine();
        ImGui.Text("ActionManager:");
        ImGui.SameLine();
        DebugManager.ClickToCopyText($"{(ulong)ActionManager.Instance():X}");

        ImGui.Separator();


        if (ImGui.BeginTabBar("##hotbarDebugDisplay"))
        {
            if (ImGui.BeginTabItem("Current Bars"))
            {
                if (ImGui.BeginTabBar($"###{GetType().Name}_debug_tabs"))
                {
                    if (ImGui.BeginTabItem("Normal"))
                    {
                        DrawHotbarType(raptureHotbarModule, HotBarType.Normal);
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Cross"))
                    {
                        DrawHotbarType(raptureHotbarModule, HotBarType.Cross);
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Pet"))
                    {
                        DrawHotbarType(raptureHotbarModule, HotBarType.Pet, "Normal Pet", "Cross Pet");
                    }

                    ImGui.EndTabBar();
                }
                ImGui.EndTabItem();
            }

            if (ImGui.BeginTabItem("Saved Bars"))
            {
                if (ImGui.BeginChild("savedBarsIndexSelect", new Vector2(150, -1) * ImGui.GetIO().FontGlobalScale, true))
                {
                    for (byte i = 0; i < 61; i++)
                    {
                        var cj = Service.Data.Excel.GetSheet <ClassJob>()?.GetRow(i)?.Abbreviation?.RawString;

                        if (i > 41)
                        {
                            cj = Service.Data.Excel.GetSheet <ClassJob>()?.Where(j => j.IsLimitedJob == false && j.JobIndex > 0).Skip(i - 42).FirstOrDefault()?.Abbreviation?.RawString;
                        }

                        if (ImGui.Selectable((i > 40 ? "[PVP] " : "") + (i is 0 or 41 ? "Shared" : cj ?? $"{i}"), selectedSavedIndex == i))
                        {
                            selectedSavedIndex = i;
                        }
                    }
                }
                ImGui.EndChild();
                ImGui.SameLine();
                ImGui.BeginGroup();
                var savedBarClassJob = raptureHotbarModule->SavedClassJob[selectedSavedIndex];
                if (savedBarClassJob != null && ImGui.BeginTabBar("savedClassJobBarSelectType"))
                {
                    void ShowBar(int b)
                    {
                        var savedBar = savedBarClassJob->Bar[b];

                        if (savedBar == null)
                        {
                            ImGui.Text("Bar is Null");
                            return;
                        }

                        if (ImGui.BeginTable("savedClassJobBarSlots", 3))
                        {
                            ImGui.TableSetupColumn("Slot", ImGuiTableColumnFlags.WidthFixed, 50);
                            ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, 80);
                            ImGui.TableSetupColumn("ID", ImGuiTableColumnFlags.WidthFixed, 100);

                            ImGui.TableHeadersRow();

                            for (var i = 0; i < 16; i++)
                            {
                                ImGui.TableNextColumn();
                                ImGui.Text($"{i:00}");
                                ImGui.TableNextColumn();
                                var slot = savedBar->Slot[i];
                                if (slot == null)
                                {
                                    ImGui.TableNextRow();
                                    continue;
                                }
                                ImGui.Text($"{slot->Type}");
                                ImGui.TableNextColumn();
                                ImGui.Text($"{slot->ID}");
                            }

                            ImGui.EndTable();
                        }
                    }

                    if (ImGui.BeginTabItem("Normal"))
                    {
                        if (ImGui.BeginTabBar("savecClassJobBarSelectCross"))
                        {
                            for (var i = 0; i < 10; i++)
                            {
                                if (ImGui.BeginTabItem($"{i + 1:00}"))
                                {
                                    ShowBar(i);
                                    ImGui.EndTabItem();
                                }
                            }
                            ImGui.EndTabBar();
                        }

                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Cross"))
                    {
                        if (ImGui.BeginTabBar("savecClassJobBarSelectCross"))
                        {
                            for (var i = 10; i < 18; i++)
                            {
                                if (ImGui.BeginTabItem($"{i-9:00}"))
                                {
                                    ShowBar(i);
                                    ImGui.EndTabItem();
                                }
                            }
                            ImGui.EndTabBar();
                        }

                        ImGui.EndTabItem();
                    }

                    ImGui.EndTabBar();
                }


                ImGui.EndGroup();

                ImGui.EndTabItem();
            }

            ImGui.EndTabBar();
        }
    }
Exemplo n.º 19
0
        public override void Draw()
        {
            var uiModule = Framework.Instance()->GetUiModule();

            if (uiModule == null)
            {
                ImGui.Text("UIModule unavailable. ");
                return;
            }

            ImGui.Text($"UIModule address - {(long)uiModule:X}");
            var atkArrayDataHolder = &uiModule->RaptureAtkModule.AtkModule.AtkArrayDataHolder;

            ImGui.Text($"AtkArrayDataHolder address - {(long)atkArrayDataHolder:X}");
            ImGui.Text(
                $"ExtendArrayData - array size: {atkArrayDataHolder->ExtendArrayCount} - array ptr: {(long)atkArrayDataHolder->ExtendArrays:X}");
            ImGui.Separator();

            ImGui.BeginChild("arraySelect", new Vector2(230 * ImGui.GetIO().FontGlobalScale, -1), true);

            if (ImGui.BeginTabBar("tabs"))
            {
                if (ImGui.BeginTabItem("Numbers"))
                {
                    ImGui.BeginChild("arraySelectNumbers");

                    for (var i = 0; i < atkArrayDataHolder->NumberArrayCount; i++)
                    {
                        var array = atkArrayDataHolder->NumberArrays[i];
                        if (array == null)
                        {
                            continue;
                        }

                        if (ImGui.Selectable($"Number Array #{i.ToString().PadLeft(atkArrayDataHolder->NumberArrayCount.ToString().Length, '0')} [{array->AtkArrayData.Size}]", selectedArray == i && selectedType == ArrayType.Numbers))
                        {
                            selectedType  = ArrayType.Numbers;
                            selectedArray = i;
                        }
                    }

                    ImGui.EndChild();
                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem("Strings"))
                {
                    ImGui.BeginChild("arraySelectStrings");
                    for (var i = 0; i < atkArrayDataHolder->StringArrayCount; i++)
                    {
                        var array = atkArrayDataHolder->StringArrays[i];
                        if (array == null)
                        {
                            continue;
                        }

                        if (ImGui.Selectable($"String Array #{i.ToString().PadLeft(atkArrayDataHolder->StringArrayCount.ToString().Length, '0')} [{array->AtkArrayData.Size}]", selectedArray == i && selectedType == ArrayType.Strings))
                        {
                            selectedType  = ArrayType.Strings;
                            selectedArray = i;
                        }
                    }
                    ImGui.EndChild();
                    ImGui.EndTabItem();
                }


                ImGui.EndTabBar();
            }

            ImGui.EndChild();

            ImGui.SameLine();

            ImGui.BeginChild("view", new Vector2(-1), true);

            if (selectedArray >= 0)
            {
                switch (selectedType)
                {
                case ArrayType.Numbers: {
                    ImGui.Text($"Number Array #{selectedArray.ToString().PadLeft(atkArrayDataHolder->NumberArrayCount.ToString().Length, '0')}");
                    var array = atkArrayDataHolder->NumberArrays[selectedArray];
                    if (array == null)
                    {
                        ImGui.Text("Null");
                        break;
                    }

                    ImGui.Text("Address:");
                    ImGui.SameLine();
                    DebugManager.ClickToCopyText($"{(ulong)array:X}");

                    ImGui.Separator();
                    ImGui.BeginChild("numbersArrayView", new Vector2(-1));

                    if (ImGui.BeginTable("numbersTable", 4, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg))
                    {
                        ImGui.TableSetupColumn("#", ImGuiTableColumnFlags.WidthFixed, 50);
                        ImGui.TableSetupColumn("Integer");
                        ImGui.TableSetupColumn("Hex");
                        ImGui.TableSetupColumn("Float");
                        ImGui.TableHeadersRow();

                        for (var i = 0; i < array->AtkArrayData.Size; i++)
                        {
                            ImGui.TableNextColumn();
                            ImGui.Text($"{i.ToString().PadLeft(array->AtkArrayData.Size.ToString().Length, '0')}");
                            ImGui.TableNextColumn();
                            ImGui.Text($"{array->IntArray[i]}");
                            ImGui.TableNextColumn();
                            ImGui.Text($"{array->IntArray[i]:X}");
                            ImGui.TableNextColumn();
                            ImGui.Text($"{*(float*)(&array->IntArray[i])}");
                        }

                        ImGui.EndTable();
                    }

                    ImGui.EndChild();
                    break;
                }

                case ArrayType.Strings: {
                    ImGui.Text($"String Array #{selectedArray.ToString().PadLeft(atkArrayDataHolder->StringArrayCount.ToString().Length, '0')}");

                    var array = atkArrayDataHolder->StringArrays[selectedArray];

                    ImGui.Text("Address:");
                    ImGui.SameLine();
                    DebugManager.ClickToCopyText($"{(ulong)array:X}");

                    ImGui.Separator();
                    ImGui.BeginChild("stringArrayView", new Vector2(-1));

                    if (ImGui.BeginTable("stringsTable", 2, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg))
                    {
                        ImGui.TableSetupColumn("#", ImGuiTableColumnFlags.WidthFixed, 50);
                        ImGui.TableSetupColumn("String");
                        ImGui.TableHeadersRow();



                        for (var i = 0; i < array->AtkArrayData.Size; i++)
                        {
                            ImGui.TableNextColumn();
                            ImGui.Text($"{i.ToString().PadLeft(array->AtkArrayData.Size.ToString().Length, '0')}");
                            ImGui.TableNextColumn();

                            var strPtr = array->StringArray[i];
                            if (strPtr == null)
                            {
                                ImGui.TextColored(new Vector4(1, 0, 0, 1), "string is null");
                            }
                            else
                            {
                                try {
                                    var str = MemoryHelper.ReadSeStringNullTerminated(new IntPtr(strPtr));
                                    // ImGui.Text($"{str.TextValue}");

                                    foreach (var p in str.Payloads)
                                    {
                                        ImGui.Text($"{p}");
                                    }
                                } catch (Exception ex) {
                                    ImGui.TextColored(new Vector4(1, 0, 0, 1), ex.ToString());
                                }
                            }
                        }

                        ImGui.EndTable();
                    }

                    ImGui.EndChild();
                    break;
                }
                }
            }

            ImGui.EndChild();
        }
    public override void Draw()
    {
        var config = Framework.Instance()->GetUiModule()->GetConfigModule();

        ImGui.Text("ConfigModule:");
        ImGui.SameLine();
        DebugManager.ClickToCopyText($"{(ulong) config:X}");

        DebugManager.PrintOutObject(config);


        ImGui.Separator();

        if (ImGui.BeginTabBar("ConfigDebugTabs"))
        {
            if (ImGui.BeginTabItem("View"))
            {
                ImGui.InputText("Search Option", ref searchString, 50);

                if (ImGui.BeginTable("configViewTable", 5))
                {
                    ImGui.TableSetupColumn("ID", ImGuiTableColumnFlags.WidthFixed, 50);
                    ImGui.TableSetupColumn("Option Name", ImGuiTableColumnFlags.WidthFixed);
                    ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, 120);
                    ImGui.TableSetupColumn("Value", ImGuiTableColumnFlags.WidthFixed, 120);
                    ImGui.TableSetupColumn("Value2", ImGuiTableColumnFlags.WidthFixed, 120);
                    ImGui.TableHeadersRow();

                    for (short i = 0; i < 2000; i++)
                    {
                        var c = config->GetOptionById(i);
                        if (c == null)
                        {
                            continue;
                        }

                        if (!string.IsNullOrWhiteSpace(searchString))
                        {
                            if (!$"{c->OptionID}".Contains(searchString, StringComparison.OrdinalIgnoreCase))
                            {
                                continue;
                            }
                        }

                        var v = config->GetValue(c->OptionID);
                        ImGui.TableNextColumn();
                        ImGui.Text($"#{i}");
                        ImGui.TableNextColumn();
                        ImGui.Text($"{c->OptionID}");
                        ImGui.TableNextColumn();
                        ImGui.Text($"{v->Type}");
                        ImGui.TableNextColumn();

                        void PrintValue(AtkValue *atkValue)
                        {
                            switch (atkValue->Type)
                            {
                            case ValueType.Int:
                                ImGui.Text($"{atkValue->Int}");
                                break;

                            case ValueType.Bool:
                                ImGui.Text($"{atkValue->Byte == 1}");
                                break;

                            case ValueType.UInt:
                                ImGui.Text($"{atkValue->UInt}");
                                break;

                            case ValueType.Float:
                                ImGui.Text($"{atkValue->Float}");
                                break;

                            case ValueType.AllocatedString:
                            case ValueType.String:
                                var str = MemoryHelper.ReadStringNullTerminated(new IntPtr(atkValue->String));
                                ImGui.Text($"{str}");
                                break;

                            case ValueType.AllocatedVector:
                            case ValueType.Vector:
                                var vec = atkValue->Vector;
                                foreach (var vecValue in vec->Span)
                                {
                                    PrintValue(&vecValue);
                                }
                                break;

                            default:
                                ImGui.Text($"Unknown Value Type: {atkValue->Type}");
                                break;
                            }
                        }

                        PrintValue(v);

                        ImGui.TableNextColumn();
                        var intVal = config->GetIntValue(c->OptionID);
                        ImGui.Text($"{intVal}");
                    }

                    ImGui.EndTable();
                }

                ImGui.EndTabItem();
            }

            if (ImGui.BeginTabItem("Changes"))
            {
                var e = setOptionHook is { IsEnabled : true };

                if (ImGui.Checkbox("Enable Config Change Logging", ref e))
                {
                    if (e)
                    {
                        setOptionHook ??= Common.Hook <SetOption>("E8 ?? ?? ?? ?? C6 47 4D 00", SetOptionDetour);
                        setOptionHook?.Enable();
                    }
                    else
                    {
                        setOptionHook?.Disable();
                    }
                }
                ImGui.Separator();

                foreach (var change in changes)
                {
                    ImGui.Text($"[#{change.Index}] {change.Option} ({(short)change.Option}) => {change.Value}  [{change.a4}, {change.a5}, {change.a6}]");
                }

                ImGui.EndTabItem();
            }



            ImGui.EndTabBar();
        }
    }
Exemplo n.º 21
0
        /// <summary>
        /// Draw the preview graph widget
        /// </summary>
        public void DrawWidget(Vector2 mainWidgetSize)
        {
            bool         showToolTip      = false;
            PlottedGraph?latestHoverGraph = null;
            TraceRecord? activeTrace      = ActiveTrace;

            if (activeTrace == null)
            {
                return;
            }


            float captionHeight = ImGui.CalcTextSize("123456789").Y;

            DrawnPreviewGraphs = activeTrace.GetPlottedGraphs();
            List <int> indexes = GetGraphOrder(trace: activeTrace, graphs: DrawnPreviewGraphs);
            uint       captionBackgroundcolor = Themes.GetThemeColourUINT(Themes.eThemeColour.PreviewTextBackground);

            ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(0, CONSTANTS.UI.PREVIEW_PANE_Y_SEP));

            //Graph drawing loop
            if (ImGui.BeginTable("PrevGraphsTable", 1, ImGuiTableFlags.Borders, new Vector2(CONSTANTS.UI.PREVIEW_PANE_WIDTH, ImGui.GetContentRegionAvail().Y)))
            {
                foreach (int graphIdx in indexes)
                {
                    PlottedGraph plot     = DrawnPreviewGraphs[graphIdx];
                    float        xPadding = CONSTANTS.UI.PREVIEW_PANE_X_PADDING;
                    if (plot == null || plot.GraphNodeCount() == 0)
                    {
                        continue;
                    }

                    ImGui.TableNextRow();
                    ImGui.TableSetColumnIndex(0);

                    if (DrawPreviewGraph(plot, xPadding, captionHeight, captionBackgroundcolor, out bool canHover, mainWidgetSize))
                    {
                        var MainGraphs = plot.InternalProtoGraph.TraceData.GetPlottedGraphs();
                        HandleClickedGraph(MainGraphs[graphIdx]);
                    }

                    if (canHover && ImGui.IsItemHovered(ImGuiHoveredFlags.None) && !(ImGui.IsMouseDown(ImGuiMouseButton.Left)))
                    {
                        latestHoverGraph = plot;
                        showToolTip      = true;
                    }
                }
                ImGui.EndTable();
            }
            ImGui.PopStyleVar();


            ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(5, 5));
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(5, 5));
            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(5, 5));
            ImGui.PushStyleColor(ImGuiCol.Border, 0x77999999);

            HoveredGraph = latestHoverGraph;
            bool showedCtx = HandlePreviewGraphContextMenu();

            bool veryRecentPopup = showedCtx || _lastCtxMenu.AddMilliseconds(250) > DateTime.Now;

            if (showToolTip && !veryRecentPopup && HoveredGraph is not null)
            {
                DrawGraphTooltip(HoveredGraph);
            }
            ImGui.PopStyleVar(3);
            ImGui.PopStyleColor();
        }
Exemplo n.º 22
0
    private void DrawVoidList()
    {
        ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver);
        if (!ImGui.Begin(
                $"{VisibilityPlugin.Instance.Name}: {VisibilityPlugin.Instance.PluginLocalization.VoidListName}",
                ref this.showListWindow[0]))
        {
            ImGui.End();
            return;
        }

        if (ImGui.BeginTable(
                "VoidListTable",
                6,
                ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.Sortable))
        {
            ImGui.TableSetupColumn(VisibilityPlugin.Instance.PluginLocalization.ColumnFirstname);
            ImGui.TableSetupColumn(VisibilityPlugin.Instance.PluginLocalization.ColumnLastname);
            ImGui.TableSetupColumn(VisibilityPlugin.Instance.PluginLocalization.ColumnWorld);
            ImGui.TableSetupColumn(VisibilityPlugin.Instance.PluginLocalization.ColumnDate, ImGuiTableColumnFlags.DefaultSort);
            ImGui.TableSetupColumn(VisibilityPlugin.Instance.PluginLocalization.ColumnReason);
            ImGui.TableSetupColumn(VisibilityPlugin.Instance.PluginLocalization.ColumnAction, ImGuiTableColumnFlags.NoSort);
            ImGui.TableSetupScrollFreeze(0, 1);
            ImGui.TableHeadersRow();

            VoidItem?itemToRemove = null;

            this.sortedContainer[0] ??= this.VoidList;

            var sortSpecs = ImGui.TableGetSortSpecs();

            if (sortSpecs.SpecsDirty)
            {
                this.sortAscending[0] = sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending;

                switch (sortSpecs.Specs.ColumnIndex)
                {
                case 0:
                    this.sortedContainer[0] = SortContainer(
                        this.VoidList,
                        x => x.Firstname,
                        this.sortAscending[0],
                        out this.sortKeySelector[0]);
                    break;

                case 1:
                    this.sortedContainer[0] = SortContainer(
                        this.VoidList,
                        x => x.Lastname,
                        this.sortAscending[0],
                        out this.sortKeySelector[0]);
                    break;

                case 2:
                    this.sortedContainer[0] = SortContainer(
                        this.VoidList,
                        x => x.HomeworldName,
                        this.sortAscending[0],
                        out this.sortKeySelector[0]);
                    break;

                case 3:
                    this.sortedContainer[0] = SortContainer(
                        this.VoidList,
                        x => x.Time,
                        this.sortAscending[0],
                        out this.sortKeySelector[0]);
                    break;

                case 4:
                    this.sortedContainer[0] = SortContainer(
                        this.VoidList,
                        x => x.Reason,
                        this.sortAscending[0],
                        out this.sortKeySelector[0]);
                    break;
                }

                sortSpecs.SpecsDirty = false;
            }

            foreach (var item in this.sortedContainer[0])
            {
                ImGui.TableNextColumn();
                ImGui.TextUnformatted(item.Firstname);
                ImGui.TableNextColumn();
                ImGui.TextUnformatted(item.Lastname);
                ImGui.TableNextColumn();
                ImGui.TextUnformatted(item.HomeworldName);
                ImGui.TableNextColumn();
                ImGui.Text(item.Time.ToString(CultureInfo.CurrentCulture));
                ImGui.TableNextColumn();
                ImGui.TextUnformatted(item.Reason);
                ImGui.TableNextColumn();

                if (ImGui.Button($"{VisibilityPlugin.Instance.PluginLocalization.OptionRemovePlayer}##{item.Name}"))
                {
                    itemToRemove = item;
                }

                ImGui.TableNextRow();
            }

            if (itemToRemove != null)
            {
                if (VisibilityPlugin.ObjectTable
                    .SingleOrDefault(
                        x =>
                        x is PlayerCharacter playerCharacter &&
                        playerCharacter.Name.TextValue.Equals(
                            itemToRemove.Name,
                            StringComparison.Ordinal) &&
                        playerCharacter.HomeWorld.Id == itemToRemove.HomeworldId) is PlayerCharacter a)
                {
                    a.Render();
                }

                this.VoidList.Remove(itemToRemove);
                this.Save();

                this.sortedContainer[0] = SortContainer(
                    this.VoidList,
                    this.sortKeySelector[0],
                    this.sortAscending[0],
                    out this.sortKeySelector[0]);
            }

            var manual = true;

            if (VisibilityPlugin.ClientState.LocalPlayer?.TargetObjectId > 0 &&
                VisibilityPlugin.ObjectTable
                .SingleOrDefault(
                    x => x is PlayerCharacter &&
                    x.ObjectKind != ObjectKind.Companion &&
                    x.ObjectId == VisibilityPlugin.ClientState.LocalPlayer
                    ?.TargetObjectId) is
                PlayerCharacter actor)
            {
                Array.Clear(this.buffer[0], 0, this.buffer[0].Length);
                Array.Clear(this.buffer[1], 0, this.buffer[1].Length);
                Array.Clear(this.buffer[2], 0, this.buffer[2].Length);

                Encoding.Default.GetBytes(actor.GetFirstname()).CopyTo(this.buffer[0], 0);
                Encoding.Default.GetBytes(actor.GetLastname()).CopyTo(this.buffer[1], 0);
                Encoding.Default.GetBytes(actor.HomeWorld.GameData !.Name).CopyTo(this.buffer[2], 0);

                manual = false;
            }

            ImGui.TableNextColumn();
            ImGui.InputText(
                "###playerFirstName",
                this.buffer[0],
                (uint)this.buffer[0].Length,
                ImGuiInputTextFlags.CharsNoBlank);
            ImGui.TableNextColumn();
            ImGui.InputText(
                "###playerLastName",
                this.buffer[1],
                (uint)this.buffer[1].Length,
                ImGuiInputTextFlags.CharsNoBlank);
            ImGui.TableNextColumn();
            ImGui.InputText(
                "###homeworldName",
                this.buffer[2],
                (uint)this.buffer[2].Length,
                ImGuiInputTextFlags.CharsNoBlank);
            ImGui.TableNextColumn();
            ImGui.TableNextColumn();
            ImGui.InputText("###reason", this.buffer[3], (uint)this.buffer[3].Length);
            ImGui.TableNextColumn();

            if (ImGui.Button(VisibilityPlugin.Instance.PluginLocalization.OptionAddPlayer))
            {
                VisibilityPlugin.Instance.VoidPlayer(
                    manual ? "VoidUIManual" : string.Empty,
                    $"{this.buffer[0].ByteToString()} {this.buffer[1].ByteToString()} {this.buffer[2].ByteToString()} {this.buffer[3].ByteToString()}");

                foreach (var item in this.buffer)
                {
                    Array.Clear(item, 0, item.Length);
                }

                this.sortedContainer[0] = SortContainer(
                    this.VoidList,
                    this.sortKeySelector[0],
                    this.sortAscending[0],
                    out this.sortKeySelector[0]);
            }

            ImGui.EndTable();
        }

        ImGui.End();
    }
Exemplo n.º 23
0
        public static void DrawChangesDialog()
        {
            ImGui.PushStyleColor(ImGuiCol.Text, 0xffffffff);
            ImGui.PushStyleColor(ImGuiCol.FrameBg, 0xff000000);
            Version currentVersion = CONSTANTS.PROGRAMVERSION.RGAT_VERSION_SEMANTIC;
            Version newVersion     = GlobalConfig.Settings.Updates.UpdateLastCheckVersion;

            ImGui.Text($"Current Version: {currentVersion}. New Version: {newVersion}");
            ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 5);

            string[] changes = GlobalConfig.Settings.Updates.UpdateLastChanges.Split('\n');

            if (ImGui.BeginTabBar("#ChangesTabs"))
            {
                for (var i = 0; i < changes.Length; i++)
                {
                    string item = changes[i].Trim();
                    if (item.StartsWith("####"))
                    {
                        string category = item.Substring(4, item.Length - 4);
                        if (category.StartsWith("CHANGES"))
                        {
                            continue;
                        }

                        GetChangeIcon(category, out char icon, out WritableRgbaFloat colour);
                        ImGui.PushStyleColor(ImGuiCol.Tab, colour.ToUint(customAlpha: 150));
                        ImGui.PushStyleColor(ImGuiCol.TabHovered, colour.ToUint(customAlpha: 190));
                        ImGui.PushStyleColor(ImGuiCol.TabActive, colour.ToUint(customAlpha: 255));
                        if (ImGui.BeginTabItem($"{icon} {category}##{i}"))
                        {
                            ImGuiTableFlags tableFlags = ImGuiTableFlags.ScrollY | ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg;
                            if (ImGui.BeginTable("#ChangesDlgChild", 1, flags: tableFlags, ImGui.GetContentRegionAvail() - new System.Numerics.Vector2(0, 30)))
                            {
                                i += 1;
                                while (i < changes.Length)
                                {
                                    string text = changes[i].Trim();
                                    if (text.Length < 2)
                                    {
                                        i += 1;
                                        continue;
                                    }

                                    ImGui.TableNextRow();
                                    ImGui.TableNextColumn();
                                    ImGui.Text(text);

                                    i += 1;
                                    if (i < (changes.Length - 1) && changes[i + 1].StartsWith("####"))
                                    {
                                        break;
                                    }
                                }
                                ImGui.EndTable();
                            }
                            ImGui.EndTabItem();
                        }
                        ImGui.PopStyleColor(3);
                    }
                }
                ImGui.EndTabBar();
            }
            ImGui.PopStyleColor(2);

            if (_update_in_progress is false)
            {
                if (ImGui.Button($"{ImGuiController.FA_ICON_DOWNLOAD} Download and Install now"))
                {
                    StartUpdater(delayed_install: false);
                }
                ImGui.SameLine();
                if (ImGui.Button($"{ImGuiController.FA_ICON_CLOCK} Download now, Install on exit"))
                {
                    StartUpdater(delayed_install: true);
                }
            }
            else
            {
                if (_download_complete)
                {
                    if (Updates.PendingInstallPath != null)
                    {
                        ImGui.AlignTextToFramePadding();
                        ImGui.Text("Update will be installed on exit");
                        ImGui.SameLine();
                        if (ImGui.Button("Cancel"))
                        {
                            Updates.PendingInstallPath = null;
                            _update_in_progress        = false;
                        }
                    }
                    else if (_update_style == "ONDOWNLOAD")
                    {
                        ImGui.AlignTextToFramePadding();
                        ImGui.Text("Exiting...");
                    }
                }
                else
                {
                    if (_download_progress != -1)
                    {
                        ImGui.AlignTextToFramePadding();
                        ImGui.Text("Download Progress: ");
                        ImGui.SameLine();
                        ImGui.ProgressBar(_download_progress, new System.Numerics.Vector2(80, 25));
                        ImGui.SameLine();
                        if (ImGui.Button("Cancel", new System.Numerics.Vector2(50, 25)))
                        {
                            _download_progress  = -1;
                            _update_in_progress = false;
                            _download_cancel_tokensrc.Cancel();
                        }
                    }
                }
            }
        }
Exemplo n.º 24
0
        private void DrawAnalysisTab(TraceRecord?activeTrace)
        {
            if (activeTrace == null || !ImGui.BeginTabItem("Timeline") || chart is null)
            {
                return;
            }

            _currentTab = "Timeline";

            float height        = ImGui.GetContentRegionAvail().Y;
            float width         = ImGui.GetContentRegionAvail().X;
            float sidePaneWidth = 300;

            if (height < 50 || width < 50)
            {
                ImGui.EndTabItem();
                return;
            }

            chart !.InitChartFromTrace(activeTrace);

            SandboxChart.ItemNode?selectedNode = chart.GetSelectedNode;
            if (ImGui.BeginTable("#TaTTable", 2, ImGuiTableFlags.Resizable))
            {
                ImGui.TableSetupColumn("#TaTTEntryList", ImGuiTableColumnFlags.None | ImGuiTableColumnFlags.WidthFixed, sidePaneWidth * 2f);
                ImGui.TableSetupColumn("#TaTTChart");

                ImGui.TableNextRow();
                if (ImGui.TableNextColumn())
                {
                    if (ImGui.BeginChild("#ijdcccfgo", ImGui.GetContentRegionAvail() - new Vector2(0, 5)))
                    {
                        TraceSelector.Draw(activeTrace);
                        ImGui.Separator();
                        ImGui.Text("Event Listing");

                        if (ImGui.BeginChild("#iosfjhvs", ImGui.GetContentRegionAvail() - new Vector2(0, selectedNode is null ? 0 : 250)))
                        {
                            DrawEventListTable(activeTrace, selectedNode);
                            ImGui.EndChild();
                        }


                        if (selectedNode is not null)
                        {
                            ImGui.PushStyleColor(ImGuiCol.ChildBg, Themes.GetThemeColourUINT(Themes.eThemeColour.Frame));
                            if (ImGui.BeginChild(ImGui.GetID("#ijdcccfgo"), new Vector2(ImGui.GetContentRegionAvail().X, 245)))
                            {
                                DrawEventInfoPanel(height, activeTrace, selectedNode);
                                ImGui.EndChild();
                            }
                            ImGui.PopStyleColor();
                        }
                        ImGui.EndChild();
                    }
                }

                if (ImGui.TableNextColumn())
                {
                    chart.Draw(_controller !.UnicodeFont);
                }
                ImGui.EndTable();
            }


            ImGui.EndTabItem();
        }
Exemplo n.º 25
0
        private static unsafe void DrawPlayerModelInfo(DalamudCharacter character)
        {
            var name = character.Name.ToString();

            if (!ImGui.CollapsingHeader($"{name}##Draw"))
            {
                return;
            }

            var model = ( CharacterBase * )(( Character * )character.Address)->GameObject.GetDrawObject();

            if (model == null)
            {
                return;
            }

            if (!ImGui.BeginTable($"##{name}DrawTable", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit))
            {
                return;
            }

            using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTable);
            ImGui.TableNextColumn();
            ImGui.TableHeader("Slot");
            ImGui.TableNextColumn();
            ImGui.TableHeader("Imc Ptr");
            ImGui.TableNextColumn();
            ImGui.TableHeader("Imc File");
            ImGui.TableNextColumn();
            ImGui.TableHeader("Model Ptr");
            ImGui.TableNextColumn();
            ImGui.TableHeader("Model File");

            for (var i = 0; i < model->SlotCount; ++i)
            {
                var imc = ( ResourceHandle * )model->IMCArray[i];
                ImGui.TableNextRow();
                ImGui.TableNextColumn();
                ImGui.Text($"Slot {i}");
                ImGui.TableNextColumn();
                ImGui.Text(imc == null ? "NULL" : $"0x{( ulong )imc:X}");
                ImGui.TableNextColumn();
                if (imc != null)
                {
                    ImGui.Text(imc->FileName.ToString());
                }

                var mdl = ( RenderModel * )model->ModelArray[i];
                ImGui.TableNextColumn();
                ImGui.Text(mdl == null ? "NULL" : $"0x{( ulong )mdl:X}");
                if (mdl == null || mdl->ResourceHandle == null || mdl->ResourceHandle->Category != ResourceCategory.Chara)
                {
                    continue;
                }


                ImGui.TableNextColumn();
                if (mdl != null)
                {
                    ImGui.Text(mdl->ResourceHandle->FileName.ToString());
                }
            }
        }
Exemplo n.º 26
0
        private void DrawEventListTable(TraceRecord trace, SandboxChart.ItemNode?selectedNode)
        {
            if (chart is null)
            {
                return;
            }

            ImGui.PushStyleColor(ImGuiCol.Header, Themes.GetThemeColourUINT(Themes.eThemeColour.Emphasis2, 40));
            TIMELINE_EVENT[] events = trace.GetTimeLineEntries();
            if (ImGui.BeginTable("#TaTTFullList", 4, ImGuiTableFlags.Borders | ImGuiTableFlags.ScrollY |
                                 ImGuiTableFlags.Resizable | ImGuiTableFlags.RowBg))
            {
                ImGui.TableSetupScrollFreeze(0, 1);
                ImGui.TableSetupColumn("#", ImGuiTableColumnFlags.WidthFixed, 50);
                ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.WidthFixed, 70);
                ImGui.TableSetupColumn("Module", ImGuiTableColumnFlags.WidthFixed, 70);
                ImGui.TableSetupColumn("Details", ImGuiTableColumnFlags.None);
                ImGui.TableHeadersRow();

                var SelectedEntity   = chart.SelectedEntity;
                var SelectedAPIEvent = chart.SelectedAPIEvent;

                bool ThreadNodeSelected  = selectedNode is not null && Equals(selectedNode.reference.GetType(), typeof(ProtoGraph));
                bool ProcessNodeSelected = selectedNode is not null && Equals(selectedNode.reference.GetType(), typeof(TraceRecord));


                int i = 0;
                foreach (TIMELINE_EVENT TLevent in events)
                {
                    i += 1;

                    ImGui.TableNextRow();
                    if (TLevent.MetaError != null)
                    {
                        ImGui.TableSetBgColor(ImGuiTableBgTarget.RowBg0, Themes.GetThemeColourUINT(Themes.eThemeColour.BadStateColour));
                        ImGui.TableSetBgColor(ImGuiTableBgTarget.RowBg1, Themes.GetThemeColourUINT(Themes.eThemeColour.BadStateColour));
                    }

                    bool   selected  = false;
                    string eventType = "";
                    string module    = "";
                    if (ImGui.TableNextColumn())
                    {
                        switch (TLevent.TimelineEventType)
                        {
                        case eTimelineEvent.ProcessStart:
                        case eTimelineEvent.ProcessEnd:
                            eventType = "Process";

                            if (selectedNode != null)
                            {
                                selected = (ProcessNodeSelected && TLevent.ID == ((TraceRecord)selectedNode.reference).PID);
                            }

                            break;

                        case eTimelineEvent.ThreadStart:
                        case eTimelineEvent.ThreadEnd:
                            eventType = "Thread";
                            if (selectedNode != null)
                            {
                                ProtoGraph currentEntryGraph = (ProtoGraph)TLevent.Item;
                                selected = (ThreadNodeSelected && currentEntryGraph.ThreadID == ((ProtoGraph)selectedNode.reference).ThreadID);
                                selected = selected || (ProcessNodeSelected && currentEntryGraph.TraceData.PID == ((TraceRecord)(selectedNode.reference)).PID);
                            }
                            break;

                        case eTimelineEvent.APICall:
                        {
                            Logging.APICALL call = (Logging.APICALL)(TLevent.Item);
                            selected = TLevent == SelectedAPIEvent;

                            if (call.Node !.IsExternal)
                            {
                                eventType = "API - " + call.APIType();
                                module    = Path.GetFileNameWithoutExtension(trace.DisassemblyData.GetModulePath(call.Node.GlobalModuleID));

                                //api call is selected if it is either directly activated, or interacts with a reference to the active entity
                                //eg: if the file.txt node is selected, writefile to the relevant handle will also be selected
                                selected = selected || (SelectedEntity != null && SelectedEntity == chart.GetInteractedEntity(TLevent));
                                if (!selected && selectedNode != null)
                                {
                                    //select all apis called by selected thread node
                                    selected = selected || (ThreadNodeSelected && call.Graph !.ThreadID == ((ProtoGraph)selectedNode.reference).ThreadID);
                                    //select all apis called by selected process node
                                    selected = selected || (ProcessNodeSelected && call.Graph !.TraceData.PID == ((TraceRecord)selectedNode.reference).PID);
                                }
                                //WinAPIDetails.API_ENTRY = call.APIEntry;
                            }
                            else
                            {
                                eventType = "Internal";
                            }
                        }
                        break;
                        }

                        if (ImGui.Selectable(i.ToString(), selected, ImGuiSelectableFlags.SpanAllColumns) && !selected)
                        {
                            chart.SelectAPIEvent(TLevent);
                        }
                    }
Exemplo n.º 27
0
        private void DrawSplash(rgatSettings.PathRecord[] recentBins, rgatSettings.PathRecord[] recentTraces)
        {
            ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, Vector2.Zero);
            ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
            ImGui.PushStyleVar(ImGuiStyleVar.ItemInnerSpacing, Vector2.Zero);

            float regionHeight     = ImGui.GetContentRegionAvail().Y;
            float regionWidth      = ImGui.GetContentRegionAvail().X;
            float buttonBlockWidth = Math.Min(400f, regionWidth / 2.1f);
            float headerHeight     = ImGui.GetWindowSize().Y / 3;
            float blockHeight      = (regionHeight * 0.95f) - headerHeight;
            float blockStart       = headerHeight + 40f;

            ImFontPtr titleFont = Controller.rgatLargeFont ?? Controller._originalFont !.Value;

            ImGui.PushFont(titleFont);
            Vector2 titleSize = ImGui.CalcTextSize("rgat");

            ImGui.SetCursorScreenPos(new Vector2((ImGui.GetWindowContentRegionMax().X / 2) - (titleSize.X / 2), (ImGui.GetWindowContentRegionMax().Y / 5) - (titleSize.Y / 2)));
            ImGui.Text("rgat");
            ImGui.PopFont();


            //ImGui.PushStyleColor(ImGuiCol.ChildBg, 0xff0000ff);
            //ImGui.PushStyleColor(ImGuiCol.ChildBg, new WritableRgbaFloat(0, 0, 0, 255).ToUint());

            bool boxBorders = false;

            //ImGui.PushStyleColor(ImGuiCol.HeaderHovered, 0x45ffffff);

            _splashHeaderHover = ImGui.GetMousePos().Y < (ImGui.GetWindowSize().Y / 3f);
            //ImGui.PopStyleColor();

            //Run group
            float voidspace     = Math.Max(0, (regionWidth - (2 * buttonBlockWidth)) / 3);
            float runGrpX       = voidspace;
            float iconTableYSep = 18;
            float iconTitleYSep = 10;

            ImGuiTableFlags tblflags = ImGuiTableFlags.NoHostExtendX;

            if (boxBorders)
            {
                tblflags |= ImGuiTableFlags.Borders;
            }

            ImGui.SetCursorPos(new Vector2(runGrpX, blockStart));
            ImGui.PushStyleColor(ImGuiCol.ChildBg, Themes.GetThemeColourUINT(Themes.eThemeColour.WindowBackground));
            if (ImGui.BeginChild("##RunGroup", new Vector2(buttonBlockWidth, blockHeight), boxBorders))
            {
                ImGui.PushFont(Controller.SplashLargeFont ?? Controller._originalFont !.Value);
                float captionHeight = ImGui.CalcTextSize("Load Binary").Y;
                if (ImGui.BeginTable("##LoadBinBtnBox", 3, tblflags))
                {
                    Vector2 LargeIconSize   = Controller.LargeIconSize;
                    float   iconColumnWidth = 200;
                    float   paddingX        = (buttonBlockWidth - iconColumnWidth) / 2;
                    ImGui.TableSetupColumn("##BBSPadL", ImGuiTableColumnFlags.WidthFixed, paddingX);
                    ImGui.TableSetupColumn("##LoadBinBtnIcn", ImGuiTableColumnFlags.WidthFixed, iconColumnWidth);
                    ImGui.TableSetupColumn("##BBSPadR", ImGuiTableColumnFlags.WidthFixed, paddingX);
                    ImGui.TableNextRow();
                    ImGui.TableSetColumnIndex(1);

                    Vector2 selectableSize = new Vector2(iconColumnWidth, captionHeight + LargeIconSize.Y + iconTitleYSep + 12);

                    if (ImGui.Selectable("##Load Binary", false, ImGuiSelectableFlags.None, selectableSize))
                    {
                        ToggleLoadExeWindow();
                    }
                    Controller.PushUnicodeFont();
                    Widgets.SmallWidgets.MouseoverText("Load an executable or DLL for examination. It will not be executed at this stage.");
                    ImGui.PopFont();
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetItemRectSize().Y);
                    ImGuiUtils.DrawHorizCenteredText("Load Binary");
                    ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (iconColumnWidth / 2) - (LargeIconSize.X / 2));
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + iconTitleYSep);

                    Controller.PushBigIconFont();
                    ImGui.Text($"{ImGuiController.FA_ICON_SAMPLE}"); //If you change this be sure to update ImGuiController.BuildFonts
                    ImGui.PopFont();

                    ImGui.EndTable();
                }
                ImGui.PopFont();

                ImGui.SetCursorPosY(ImGui.GetCursorPosY() + iconTableYSep);
                Vector2 tableSz = new Vector2(buttonBlockWidth, ImGui.GetContentRegionAvail().Y - 25);

                ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(0, 2));
                if (ImGui.BeginTable("#RecentBinTableList", 1, ImGuiTableFlags.ScrollY, tableSz))
                {
                    ImGui.Indent(5);
                    ImGui.TableSetupColumn("Recent Binaries" + $"{(rgatState.ConnectedToRemote ? " (Remote Files)" : "")}");
                    ImGui.TableSetupScrollFreeze(0, 1);
                    ImGui.TableHeadersRow();
                    if (recentBins?.Length > 0)
                    {
                        int bincount = Math.Min(GlobalConfig.Settings.UI.MaxStoredRecentPaths, recentBins.Length);
                        for (var bini = 0; bini < bincount; bini++)
                        {
                            var entry = recentBins[bini];
                            ImGui.TableNextRow();
                            if (ImGui.TableNextColumn())
                            {
                                if (DrawRecentPathEntry(entry, menu: false))
                                {
                                    if (File.Exists(entry.Path) || rgatState.ConnectedToRemote)
                                    {
                                        if (!LoadSelectedBinary(entry.Path, rgatState.ConnectedToRemote) && !_badPaths.Contains(entry.Path))
                                        {
                                            _badPaths.Add(entry.Path);
                                        }
                                    }
                                    else if (!_missingPaths.Contains(entry.Path) && rgatState.ConnectedToRemote is false)
                                    {
                                        _scheduleMissingPathCheck = true;
                                        _missingPaths.Add(entry.Path);
                                    }
                                }
                            }
                        }
                    }
                    ImGui.EndTable();
                }
                ImGui.PopStyleVar();

                ImGui.EndChild();
            }

            ImGui.SetCursorPosY(blockStart);
            ImGui.SetCursorPosX(runGrpX + buttonBlockWidth + voidspace);
            if (ImGui.BeginChild("##LoadGroup", new Vector2(buttonBlockWidth, blockHeight), boxBorders))
            {
                ImGui.PushFont(Controller.SplashLargeFont ?? Controller._originalFont !.Value);
                float captionHeight = ImGui.CalcTextSize("Load Trace").Y;
                if (ImGui.BeginTable("##LoadBtnBox", 3, tblflags))
                {
                    Vector2 LargeIconSize   = Controller.LargeIconSize;
                    float   iconColumnWidth = 200;
                    float   paddingX        = (buttonBlockWidth - iconColumnWidth) / 2;
                    ImGui.TableSetupColumn("##LBSPadL", ImGuiTableColumnFlags.WidthFixed, paddingX);
                    ImGui.TableSetupColumn("##LoadBtnIcn", ImGuiTableColumnFlags.WidthFixed, iconColumnWidth);
                    ImGui.TableSetupColumn("##LBSPadR", ImGuiTableColumnFlags.WidthFixed, paddingX);
                    ImGui.TableNextRow();
                    ImGui.TableSetColumnIndex(1);
                    Vector2 selectableSize = new Vector2(iconColumnWidth, captionHeight + LargeIconSize.Y + iconTitleYSep + 12);
                    if (ImGui.Selectable("##Load Trace", false, ImGuiSelectableFlags.None, selectableSize))
                    {
                        ToggleLoadTraceWindow();
                    }
                    Controller.PushUnicodeFont();
                    Widgets.SmallWidgets.MouseoverText("Load a previously generated trace");
                    ImGui.PopFont();
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetItemRectSize().Y);
                    ImGuiUtils.DrawHorizCenteredText("Load Trace");
                    ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (iconColumnWidth / 2) - (LargeIconSize.X / 2) + 8); //shift a bit to the right to balance it
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + iconTitleYSep);

                    Controller.PushBigIconFont();
                    ImGui.Text($"{ImGuiController.FA_ICON_LOADFILE}");//If you change this be sure to update ImGuiController.BuildFonts
                    ImGui.PopFont();

                    ImGui.EndTable();
                }
                ImGui.PopFont();

                ImGui.SetCursorPosY(ImGui.GetCursorPosY() + iconTableYSep);

                Vector2 tableSz = new Vector2(buttonBlockWidth, ImGui.GetContentRegionAvail().Y - 25);


                ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, new Vector2(0, 2));
                if (ImGui.BeginTable("#RecentTraceTableList", 1, ImGuiTableFlags.ScrollY, tableSz))
                {
                    ImGui.Indent(5);
                    ImGui.TableSetupColumn("Recent Traces");
                    ImGui.TableSetupScrollFreeze(0, 1);
                    ImGui.TableHeadersRow();
                    if (recentTraces?.Length > 0)
                    {
                        int traceCount = Math.Min(GlobalConfig.Settings.UI.MaxStoredRecentPaths, recentTraces.Length);
                        for (var traceI = 0; traceI < traceCount; traceI++)
                        {
                            var entry = recentTraces[traceI];
                            ImGui.TableNextRow();
                            if (ImGui.TableNextColumn())
                            {
                                if (DrawRecentPathEntry(entry, false))
                                {
                                    if (File.Exists(entry.Path))
                                    {
                                        System.Threading.Tasks.Task.Run(() => LoadTraceByPath(entry.Path));

                                        /*
                                         * if (!LoadTraceByPath(entry.Path) && !_badPaths.Contains(entry.Path))
                                         * {
                                         *  _badPaths.Add(entry.Path);
                                         * }*/
                                    }
                                    else if (!_missingPaths.Contains(entry.Path))
                                    {
                                        _scheduleMissingPathCheck = true;
                                        _missingPaths.Add(entry.Path);
                                    }
                                }
                            }
                        }
                    }
                    ImGui.EndTable();
                }
                ImGui.PopStyleVar();

                ImGui.EndChild();
            }

            ImGui.PopStyleVar(5);

            ImGui.BeginGroup();
            string versionString = $"rgat {CONSTANTS.PROGRAMVERSION.RGAT_VERSION}";
            float  width         = ImGui.CalcTextSize(versionString).X;

            ImGui.SetCursorPos(ImGui.GetContentRegionMax() - new Vector2(width + 25, 40));
            ImGui.Text(versionString);


            if (GlobalConfig.NewVersionAvailable)
            {
                Version currentVersion = CONSTANTS.PROGRAMVERSION.RGAT_VERSION_SEMANTIC;
                Version newVersion     = GlobalConfig.Settings.Updates.UpdateLastCheckVersion;
                string  updateString;
                if (newVersion.Major > currentVersion.Major ||
                    (newVersion.Major == currentVersion.Major && newVersion.Minor > currentVersion.Minor))
                {
                    updateString = "New version available ";
                }
                else
                {
                    updateString = "Updates available ";
                }
                updateString += $"({newVersion})";

                Vector2 textSize = ImGui.CalcTextSize(updateString);
                ImGui.SetCursorPos(ImGui.GetContentRegionMax() - new Vector2(textSize.X + 25, 55));

                if (ImGui.Selectable(updateString, false, flags: ImGuiSelectableFlags.None, size: new Vector2(textSize.X, textSize.Y)))
                {
                    ImGui.OpenPopup("New Version Available");
                }
                if (ImGui.IsItemHovered())
                {
                    Updates.ChangesCounts(out int changes, out int versions);
                    if (changes > 0)
                    {
                        ImGui.BeginTooltip();
                        ImGui.Text($"Click to see {changes} changes in {versions} newer rgat versions");
                        ImGui.EndTooltip();
                    }
                }
            }
            ImGui.EndGroup();

            ImGui.PopStyleColor();
            if (GlobalConfig.Settings.UI.EnableTortoise)
            {
                _splashRenderer?.Draw();
            }

            if (StartupProgress < 1)
            {
                float originalY = ImGui.GetCursorPosY();
                float ypos      = ImGui.GetWindowSize().Y - 12;
                ImGui.SetCursorPosY(ypos);
                ImGui.ProgressBar((float)StartupProgress, new Vector2(-1, 4f));
                ImGui.SetCursorPosY(originalY);
            }

            if (ImGui.IsPopupOpen("New Version Available"))
            {
                ImGui.SetNextWindowSize(new Vector2(600, 500), ImGuiCond.FirstUseEver);
                ImGui.SetNextWindowPos((ImGui.GetWindowSize() / 2) - new Vector2(600f / 2f, 500f / 2f), ImGuiCond.Appearing);
                bool isopen = true;
                if (ImGui.BeginPopupModal("New Version Available", ref isopen, flags: ImGuiWindowFlags.Modal))
                {
                    Updates.DrawChangesDialog();
                    isopen = isopen && !ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Escape));
                    if (!isopen)
                    {
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.EndPopup();
                }
            }
        }
Exemplo n.º 28
0
        private void DrawWhitelist()
        {
            ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver);
            if (!ImGui.Begin($"{_plugin.Name}: 白名单", ref _showListWindow[1]))
            {
                ImGui.End();
                return;
            }

            if (ImGui.BeginTable("WhitelistTable", 5,
                                 ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.Sortable))
            {
                ImGui.TableSetupColumn("角色名");
                ImGui.TableSetupColumn("服务器");
                ImGui.TableSetupColumn("时间", ImGuiTableColumnFlags.DefaultSort);
                ImGui.TableSetupColumn("原因");
                ImGui.TableSetupColumn("操作", ImGuiTableColumnFlags.NoSort);
                ImGui.TableSetupScrollFreeze(0, 1);
                ImGui.TableHeadersRow();

                VoidItem itemToRemove = null;

                if (_sortedContainer[1] == null)
                {
                    _sortedContainer[1] = Whitelist;
                }

                var sortSpecs = ImGui.TableGetSortSpecs();

                if (sortSpecs.SpecsDirty)
                {
                    _sortAscending[1] = sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending;

                    switch (sortSpecs.Specs.ColumnIndex)
                    {
                    case 0:
                        _sortedContainer[1] = SortContainer(Whitelist, x => x.Charactername,
                                                            _sortAscending[1], out _sortKeySelector[1]);
                        break;

                    case 1:
                        _sortedContainer[1] = SortContainer(Whitelist, x => x.HomeworldName,
                                                            _sortAscending[1], out _sortKeySelector[1]);
                        break;

                    case 2:
                        _sortedContainer[1] = SortContainer(Whitelist, x => x.Time,
                                                            _sortAscending[1], out _sortKeySelector[1]);
                        break;

                    case 3:
                        _sortedContainer[1] = SortContainer(Whitelist, x => x.Reason,
                                                            _sortAscending[1], out _sortKeySelector[1]);
                        break;
                    }

                    sortSpecs.SpecsDirty = false;
                }

                foreach (var item in _sortedContainer[1])
                {
                    ImGui.TableNextColumn();
                    ImGui.TextUnformatted(item.Charactername);
                    ImGui.TableNextColumn();
                    ImGui.TextUnformatted(item.HomeworldName);
                    ImGui.TableNextColumn();
                    ImGui.Text(item.Time.ToString(CultureInfo.CurrentCulture));
                    ImGui.TableNextColumn();
                    ImGui.TextUnformatted(item.Reason);
                    ImGui.TableNextColumn();

                    if (ImGui.Button($"移除##{item.Name}"))
                    {
                        itemToRemove = item;
                    }

                    ImGui.TableNextRow();
                }

                if (itemToRemove != null)
                {
                    Whitelist.Remove(itemToRemove);
                    Save();
                    _sortedContainer[1] = SortContainer(Whitelist, _sortKeySelector[1], _sortAscending[1],
                                                        out _sortKeySelector[1]);
                }

                var manual = true;

                if (_pluginInterface.ClientState.LocalPlayer?.TargetActorID > 0 &&
                    _pluginInterface.ClientState.Actors
                    .SingleOrDefault(x => x is PlayerCharacter &&
                                     x.ObjectKind != ObjectKind.Companion &&
                                     x.ActorId == _pluginInterface.ClientState.LocalPlayer
                                     ?.TargetActorID) is
                    PlayerCharacter actor)
                {
                    Array.Clear(_buffer[4], 0, _buffer[4].Length);
                    //Array.Clear(_buffer[5], 0, _buffer[5].Length);
                    Array.Clear(_buffer[6], 0, _buffer[6].Length);

                    Encoding.UTF8.GetBytes(actor.GetFirstname()).CopyTo(_buffer[4], 0);
                    //Encoding.UTF8.GetBytes(actor.GetLastname()).CopyTo(_buffer[5], 0);
                    Encoding.UTF8.GetBytes(actor.HomeWorld.GameData.Name).CopyTo(_buffer[6], 0);

                    manual = false;
                }

                ImGui.TableNextColumn();
                ImGui.InputText("###playerName", _buffer[4], (uint)_buffer[4].Length,
                                ImGuiInputTextFlags.CharsNoBlank);
                ImGui.TableNextColumn();
                ImGui.InputText("###homeworldName", _buffer[6], (uint)_buffer[6].Length,
                                ImGuiInputTextFlags.CharsNoBlank);
                ImGui.TableNextColumn();
                ImGui.TableNextColumn();
                ImGui.InputText("###reason", _buffer[7], (uint)_buffer[7].Length);
                ImGui.TableNextColumn();

                if (ImGui.Button("添加到白名单"))
                {
                    _plugin.WhitelistPlayer(manual ? "WhitelistUIManual" : string.Empty,
                                            $"{_buffer[4].ByteToString()} {_buffer[6].ByteToString()} {_buffer[7].ByteToString()}");

                    foreach (var item in _buffer)
                    {
                        Array.Clear(item, 0, item.Length);
                    }

                    _sortedContainer[1] = SortContainer(Whitelist, _sortKeySelector[1], _sortAscending[1],
                                                        out _sortKeySelector[1]);
                }

                ImGui.EndTable();
            }

            ImGui.End();
        }
Exemplo n.º 29
0
        public override void Draw()
        {
            var config = Framework.Instance()->GetUiModule()->GetConfigModule();

            ImGui.Text("ConfigModule:");
            ImGui.SameLine();
            DebugManager.ClickToCopyText($"{(ulong) config:X}");

            DebugManager.PrintOutObject(config);



            var oFields = config->GetOption(0)->GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            var vFields = config->GetValue(0)->GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);


            if (ImGui.BeginTable("optionsTable", 3 + oFields.Length + vFields.Length, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.Resizable | ImGuiTableFlags.ScrollY | ImGuiTableFlags.ScrollX, new Vector2(-1, -1)))
            {
                ImGui.TableSetupColumn("Index", ImGuiTableColumnFlags.WidthFixed, 40);
                ImGui.TableSetupColumn("Index", ImGuiTableColumnFlags.WidthFixed, 40);
                ImGui.TableSetupColumn("Address", ImGuiTableColumnFlags.WidthFixed, 90);

                foreach (var f in oFields)
                {
                    ImGui.TableSetupColumn($"{f.Name}");
                }
                foreach (var f in vFields)
                {
                    ImGui.TableSetupColumn($"{f.Name}");
                }

                ImGui.TableSetupScrollFreeze(1, 1);

                ImGui.TableHeadersRow();

                for (uint i = 0; i < ConfigModule.ConfigOptionCount; i++)
                {
                    var option = config->GetOption(i);
                    var value  = config->GetValue(i);
                    ImGui.TableNextColumn();
                    ImGui.Text($"{i}");
                    ImGui.TableNextColumn();
                    ImGui.Text($"{i:X}");
                    ImGui.TableNextColumn();
                    DebugManager.ClickToCopyText($"{(ulong)option:X}");

                    foreach (var f in oFields)
                    {
                        ImGui.TableNextColumn();
                        var v = f.GetValue(*option);
                        if (f.FieldType.IsPointer && v is Pointer p)
                        {
                            var ptr = Pointer.Unbox(p);
                            ImGui.Text($"{(ulong)ptr:X}");
                        }
                        else
                        {
                            ImGui.Text($"{v}");
                        }
                    }
                    foreach (var f in vFields)
                    {
                        ImGui.TableNextColumn();
                        var v = f.GetValue(*value);
                        if (f.FieldType.IsPointer && v is Pointer p)
                        {
                            var ptr = Pointer.Unbox(p);
                            ImGui.Text($"{(ulong)ptr:X}");
                        }
                        else
                        {
                            ImGui.Text($"{v}");
                        }
                    }
                    ImGui.TableNextRow();
                }
                ImGui.EndTable();
            }
        }
Exemplo n.º 30
0
		public unsafe void Draw()
		{
			if (!IsVisible)
				return;

			//var Buttoncolor = *ImGui.GetStyleColorVec4(ImGuiCol.Button);
			//var ButtonHoveredcolor = *ImGui.GetStyleColorVec4(ImGuiCol.ButtonHovered);
			//var ButtonActivecolor = *ImGui.GetStyleColorVec4(ImGuiCol.ButtonActive);
			ImGui.SetNextWindowPos(new Vector2(100, 100), ImGuiCond.FirstUseEver);
			var scaledWidth = 357 * ImGui.GetIO().FontGlobalScale;
			ImGui.SetNextWindowSizeConstraints(new Vector2(scaledWidth, 0), new Vector2(scaledWidth, 10000));

			//ImGui.PushStyleVar(ImGuiStyleVar.WindowTitleAlign, new Vector2(0.5f, 0.5f));

			//uint color = ImGui.GetColorU32(ImGuiCol.TitleBgActive);
			var ensembleModeRunning = EnsembleModeRunning;
			var ensemblePreparing = MetronomeBeatsElapsed < 0;
			var listeningForEvents = DeviceManager.IsListeningForEvents;

			//if (ensembleModeRunning)
			//{
			//	if (ensemblePreparing)
			//	{
			//		color = orange;
			//	}
			//	else
			//	{
			//		color = red;
			//	}
			//}
			//else
			//{
			//	if (isListeningForEvents)
			//	{
			//		color = violet;
			//	}
			//}
			//ImGui.PushStyleColor(ImGuiCol.TitleBgActive, color);

			try
			{
				//var title = string.Format("MidiBard{0}{1}###midibard",
				//	ensembleModeRunning ? " - Ensemble Running" : string.Empty,
				//	isListeningForEvents ? " - Listening Events" : string.Empty);
				var flag = config.miniPlayer ? ImGuiWindowFlags.NoDecoration : ImGuiWindowFlags.None;
				ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(5, 5));

				if (ImGui.Begin("MidiBard", ref IsVisible, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.AlwaysAutoResize | flag))
				{
					void coloredSelectable(uint color, string content)
					{
						ImGui.PushStyleColor(ImGuiCol.Button, color);
						ImGui.PushStyleColor(ImGuiCol.ButtonHovered, color);
						ImGui.Button(content, new Vector2(-1, ImGui.GetFrameHeight()));
						ImGui.PopStyleColor(2);
					}

					ImGui.PushStyleVar(ImGuiStyleVar.SelectableTextAlign, new Vector2(0.5f, 0.5f));
					if (ensembleModeRunning)
					{
						if (ensemblePreparing)
						{
							coloredSelectable(orange, "Ensemble Mode Preparing".Localize());
						}
						else
						{
							coloredSelectable(red, "Ensemble Mode Running".Localize());
						}
					}

					if (listeningForEvents)
					{
						coloredSelectable(violet, "Listening input device: ".Localize() + DeviceManager.CurrentInputDevice.ToDeviceString());
					}

					ImGui.PopStyleVar();

					if (!config.miniPlayer)
					{
						ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 4));
						ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(15, 4));
						{
							if (!_isImportRunning)
							{
								DrawImportButton();
								ToolTip("Import midi file.".Localize());
							}
							else
							{
								DrawImportProgress();
							}

							if (_hasError) DrawFailedImportMessage();

							//ImGui.SameLine();
							//if (ImGui.Button("Remove Selected"))
							//{
							//	PlaylistManager.Remove(PlaylistManager.currentPlaying);
							//}

							ImGui.SameLine();
							if (ImGui.Button("Clear Playlist".Localize())) PlaylistManager.Clear();

							if (localizer.Language == UILang.CN)
							{
								ImGui.PushFont(UiBuilder.IconFont);
								ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize(FontAwesomeIcon.QuestionCircle.ToIconString()).X - ImGui.GetStyle().FramePadding.X * 2 + ImGui.GetCursorPosX());
								if (ImGui.Button(FontAwesomeIcon.QuestionCircle.ToIconString()))
								{
									//config.showHelpWindow ^= true;
								}

								ImGui.PopFont();

								if (ImGui.IsItemHovered())
								{
									var currentwindowpos = ImGui.GetWindowPos();
									ImGui.SetNextWindowPos(currentwindowpos + new Vector2(0,
										ImGui.GetTextLineHeightWithSpacing() + ImGui.GetFrameHeightWithSpacing() +
										ImGui.GetStyle().WindowPadding.Y));
									ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(4, 4));
									if (ImGui.Begin("HelpWindow",
										ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.Tooltip |
										ImGuiWindowFlags.AlwaysAutoResize))
									{
										ImGui.BulletText(
											"如何开始使用MIDIBARD演奏?" +
											"\n MIDIBARD窗口默认在角色进入演奏模式后自动弹出。" +
											"\n 点击窗口左上角的“+”按钮来将乐曲文件导入到播放列表,仅支持.mid格式的乐曲。" +
											"\n 导入时按Ctrl或Shift可以选择多个文件一同导入。" +
											"\n 双击播放列表中要演奏的乐曲后点击播放按钮开始演奏。\n");
										ImGui.BulletText(
											"为什么点击播放之后没有正常演奏?" +
											"\n MIDIBARD仅使用37键演奏模式。" +
											"\n 请在游戏“乐器演奏操作设置”的“键盘操作”类别下启用“全音阶一同显示、设置按键”的选项。\n");
										ImGui.BulletText(
											"如何使用MIDIBARD进行多人合奏?" +
											"\n MIDIBARD使用游戏中的合奏助手来完成合奏,请在合奏时打开游戏的节拍器窗口。" +
											"\n 合奏前在播放列表中双击要合奏的乐曲,播放器下方会出现可供演奏的所有音轨,请为每位合奏成员分别选择其需要演奏的音轨。" +
											"\n 选择音轨后队长点击节拍器窗口的“合奏准备确认”按钮," +
											"\n 并确保合奏准备确认窗口中已勾选“使用合奏助手”选项后点击开始即可开始合奏。" +
											"\n ※节拍器前两小节为准备时间,从第1小节开始会正式开始合奏。" +
											"\n  考虑到不同使用环境乐曲加载速度可能不一致,为了避免切换乐曲导致的不同步,在乐曲结束时合奏会自动停止。\n");
										ImGui.BulletText(
											"如何让MIDIBARD为不同乐曲自动切换音调和乐器?" +
											"\n 在导入前把要指定乐器和移调的乐曲文件名前加入“#<乐器名><移调的半音数量>#”。" +
											"\n 例如:原乐曲文件名为“demo.mid”" +
											"\n 将其重命名为“#中提琴+12#demo.mid”可在演奏到该乐曲时自动切换到中提琴并升调1个八度演奏。" +
											"\n 将其重命名为“#长笛-24#demo.mid”可在演奏到该乐曲时切换到长笛并降调2个八度演奏。" +
											"\n ※可以只添加#+12#或#竖琴#或#harp#,也会有对应的升降调或切换乐器效果。");
										ImGui.BulletText(
											"如何为MIDIBARD配置外部Midi输入(如虚拟Midi接口或Midi键盘)?" +
											"\n 在“输入设备”下拉菜单中选择你的Midi设备,窗口顶端出现“正在监听Midi输入”信息后即可使用外部输入。\n");
										ImGui.BulletText(
											"后台演奏时有轻微卡顿不流畅怎么办?" +
											"\n 在游戏内“系统设置→显示设置→帧数限制”中取消勾选 “程序在游戏窗口处于非激活状态时限制帧数” 的选项并应用设置。\n");
										ImGui.BulletText("讨论及BUG反馈群:260985966");
										ImGui.Spacing();

										ImGui.End();
									}

									ImGui.PopStyleVar();
								}
							}


						}

						ImGui.PopStyleVar(2);


						if (PlaylistManager.Filelist.Count == 0)
						{
							if (ImGui.Button("Import midi files to start performing!".Localize(), new Vector2(-1, ImGui.GetFrameHeight())))
								RunImportTask();
						}
						else
						{
							ImGui.PushStyleColor(ImGuiCol.Button, 0);
							ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0);
							ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0);
							ImGui.PushStyleColor(ImGuiCol.Header, 0x3C60FF8E);
							if (ImGui.BeginTable("##PlaylistTable", 3,
								ImGuiTableFlags.RowBg | ImGuiTableFlags.PadOuterX |
								ImGuiTableFlags.ScrollY | ImGuiTableFlags.NoSavedSettings | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.ContextMenuInBody,
								new Vector2(-1,
									ImGui.GetTextLineHeightWithSpacing() * Math.Min(10,
										PlaylistManager.Filelist.Count)
								)))
							{
								ImGui.TableSetupColumn("\ue035", ImGuiTableColumnFlags.WidthFixed);
								ImGui.TableSetupColumn("##delete", ImGuiTableColumnFlags.WidthFixed);
								ImGui.TableSetupColumn("filename", ImGuiTableColumnFlags.WidthStretch);
								for (var i = 0; i < PlaylistManager.Filelist.Count; i++)
								{
									ImGui.TableNextRow();
									ImGui.TableSetColumnIndex(0);
									if (ImGui.Selectable($"{i + 1:000}##plistitem", PlaylistManager.CurrentPlaying == i,
										ImGuiSelectableFlags.SpanAllColumns | ImGuiSelectableFlags.AllowDoubleClick |
										ImGuiSelectableFlags.AllowItemOverlap))
									{
										if (ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left))
										{
											PlaylistManager.CurrentPlaying = i;

											try
											{
												var wasplaying = IsPlaying;
												currentPlayback?.Dispose();
												currentPlayback = null;

												currentPlayback = PlaylistManager.Filelist[PlaylistManager.CurrentPlaying].GetFilePlayback();
												if (wasplaying) currentPlayback?.Start();
												Task.Run(SwitchInstrument.WaitSwitchInstrument);
											}
											catch (Exception e)
											{
												//
											}
										}
										else
										{
											PlaylistManager.CurrentSelected = i;
										}
									}

									ImGui.TableNextColumn();
									ImGui.PushFont(UiBuilder.IconFont);
									ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
									if (ImGui.Button($"{((FontAwesomeIcon)0xF2ED).ToIconString()}##{i}", new Vector2(ImGui.GetTextLineHeight(), ImGui.GetTextLineHeight())))
									{
										PlaylistManager.Remove(i);
									}
									ImGui.PopStyleVar();
									ImGui.PopFont();
									ImGui.TableNextColumn();
									try
									{
										var item2 = PlaylistManager.Filelist[i].Item2;
										ImGui.TextUnformatted(item2);
										ToolTip(item2);
									}
									catch (Exception e)
									{
										ImGui.TextUnformatted("deleted");
									}

								}

								ImGui.EndTable();
							}

							ImGui.PopStyleColor(4);
						}

						#region old playlist

						//ImGui.BeginListBox("##PlayList1", new Vector2(-1, ImGui.GetTextLineHeightWithSpacing() * maxItems));
						//{
						//	var i = 0;
						//	foreach (var tuple in PlaylistManager.Filelist)
						//	{
						//		if (PlaylistManager.currentPlaying == i)
						//		{
						//			ImGui.PushStyleColor(ImGuiCol.Text, config.ThemeColor);
						//		}

						//		if (ImGui.Selectable($"{tuple.Item2}##{i}", PlaylistManager.currentSelected[i], ImGuiSelectableFlags.AllowDoubleClick))
						//		{

						//		}
						//		if (PlaylistManager.currentPlaying == i)
						//		{
						//			ImGui.PopStyleColor();
						//		}
						//		i++;
						//	}
						//}
						//ImGui.EndListBox();
						//ImGui.Text(sb.ToString());

						//if (ImGui.ListBox("##PlayList", ref PlaylistManager.currentPlaying, items, itemsCount, maxItems))
						//{
						//	var wasplaying = IsPlaying;
						//	currentPlayback?.Dispose();

						//	try
						//	{
						//		currentPlayback = PlaylistManager.Filelist[PlaylistManager.currentPlaying].Item1.GetPlayback();
						//		if (wasplaying) currentPlayback?.Start();
						//	}
						//	catch (Exception e)
						//	{

						//	}
						//}

						#endregion

						ImGui.Spacing();
					}

					DrawCurrentPlaying();

					ImGui.Spacing();

					DrawProgressBar();

					ImGui.Spacing();

					ImGui.PushFont(UiBuilder.IconFont);
					ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 4));
					ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(15, 4));
					{
						DrawButtonPlayPause();
						DrawButtonStop();
						DrawButtonFastForward();
						DrawButtonPlayMode();
						DrawButtonShowPlayerControl();
						DrawButtonShowSettingsPanel();
						DrawButtonMiniPlayer();
					}
					ImGui.PopFont();
					ImGui.PopStyleVar(2);

					if (config.showMusicControlPanel)
					{
						DrawTrackTrunkSelectionWindow();
						ImGui.Separator();
						DrawPanelMusicControl();
					}
					if (config.showSettingsPanel)
					{
						ImGui.Separator();
						DrawPanelGeneralSettings();
					}
					if (Debug) DrawDebugWindow();

					var size = ImGui.GetWindowSize();
					var pos = ImGui.GetWindowPos();
					var vp = ImGui.GetWindowViewport();



					////ImGui.SetNextWindowViewport(vp.ID);
					//ImGui.SetNextWindowPos(pos + new Vector2(size.X + 1, 0));
					////ImGui.SetNextWindowSizeConstraints(Vector2.Zero, size);
					//if (config.showInstrumentSwitchWindow && ImGui.Begin("Instrument".Localize(), ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.AlwaysAutoResize))
					//{
					//	ImGui.SetNextItemWidth(120);
					//	UIcurrentInstrument = Plugin.CurrentInstrument;
					//	if (ImGui.ListBox("##instrumentSwitch", ref UIcurrentInstrument,
					//		InstrumentSheet.Select(i => i.Instrument.ToString()).ToArray(), (int)InstrumentSheet.RowCount,
					//		(int)InstrumentSheet.RowCount))
					//	{
					//		Task.Run(() => SwitchInstrument.SwitchTo((uint)UIcurrentInstrument));
					//	}

					//	//if (ImGui.Button("Quit"))
					//	//{
					//	//	Task.Run(() => SwitchInstrument.SwitchTo(0));
					//	//}
					//	ImGui.End();
					//}

					ImGui.End();
				}
			}
			finally
			{
				ImGui.PopStyleVar();
				//ImGui.PopStyleColor();
			}

		}