private void DrawFileListTab() { if (!ImGui.BeginTabItem(LabelFileListTab)) { return; } using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem); ImGuiCustom.HoverTooltip(TooltipFilesTab); ImGui.SetNextItemWidth(-1); if (ImGui.BeginListBox(LabelFileListHeader, AutoFillSize)) { raii.Push(ImGui.EndListBox); UpdateFilenameList(); using var colorRaii = new ImGuiRaii.Color(); foreach (var(name, _, color, _) in _fullFilenameList !) { colorRaii.Push(ImGuiCol.Text, color); ImGui.Selectable(name.FullName); colorRaii.Pop(); } } else { _fullFilenameList = null; } }
private void DrawAboutTab() { if (!_editMode && Meta.Description.Length == 0) { return; } if (!ImGui.BeginTabItem(LabelAboutTab)) { return; } using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem); var desc = Meta.Description; var flags = _editMode ? ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CtrlEnterForNewLine : ImGuiInputTextFlags.ReadOnly; if (_editMode) { if (ImGui.InputTextMultiline(LabelDescEdit, ref desc, 1 << 16, AutoFillSize, flags)) { Meta.Description = desc; _selector.SaveCurrentMod(); } ImGuiCustom.HoverTooltip(TooltipAboutEdit); } else { ImGui.TextWrapped(desc); } }
private void DrawChangedItemsTab() { if (Mod.Data.ChangedItems.Count == 0 || !ImGui.BeginTabItem(LabelChangedItemsTab)) { return; } using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem); if (!ImGui.BeginListBox(LabelChangedItemsHeader, AutoFillSize)) { return; } raii.Push(ImGui.EndListBox); foreach (var(name, data) in Mod.Data.ChangedItems) { _base.DrawChangedItem(name, data); } }
private void DrawConflictTab() { if (!Mod.Cache.Conflicts.Any() || !ImGui.BeginTabItem(LabelConflictsTab)) { return; } using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem); ImGui.SetNextItemWidth(-1); if (!ImGui.BeginListBox(LabelConflictsHeader, AutoFillSize)) { return; } raii.Push(ImGui.EndListBox); using var indent = ImGuiRaii.PushIndent(0); foreach (var(mod, (files, manipulations)) in Mod.Cache.Conflicts) { if (ImGui.Selectable(mod.Data.Meta.Name)) { _selector.SelectModByDir(mod.Data.BasePath.Name); } ImGui.SameLine(); ImGui.Text($"(Priority {mod.Settings.Priority})"); indent.Push(15f); foreach (var file in files) { ImGui.Selectable(file); } foreach (var manip in manipulations) { ImGui.Text(manip.IdentifierString()); } indent.Pop(15f); } }
private void DrawFileSwapTab() { if (_editMode) { DrawFileSwapTabEdit(); return; } if (!Meta.FileSwaps.Any() || !ImGui.BeginTabItem(LabelFileSwapTab)) { return; } using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem); const ImGuiTableFlags flags = ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX; ImGui.SetNextItemWidth(-1); if (!ImGui.BeginTable(LabelFileSwapHeader, 3, flags, AutoFillSize)) { return; } raii.Push(ImGui.EndTable); foreach (var(source, target) in Meta.FileSwaps) { ImGui.TableNextColumn(); ImGuiCustom.CopyOnClickSelectable(source); ImGui.TableNextColumn(); ImGuiCustom.PrintIcon(FontAwesomeIcon.LongArrowAltRight); ImGui.TableNextColumn(); ImGuiCustom.CopyOnClickSelectable(target); ImGui.TableNextRow(); } }
private static unsafe void SubmitUI() { // Demo code adapted from the official Dear ImGui demo program: // https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx11/main.cpp#L172 // 1. Show a simple window. // Tip: if we don't call ImGui.BeginWindow()/ImGui.EndWindow() the widgets automatically appears in a window called "Debug". { ImGui.Text("Hello, world!"); // Display some text (you can use a format string too) ImGui.SliderFloat("float", ref _f, 0, 1, _f.ToString("0.000")); // Edit 1 float using a slider from 0.0f to 1.0f //ImGui.ColorEdit3("clear color", ref _clearColor); // Edit 3 floats representing a color ImGui.Text($"Mouse position: {ImGui.GetMousePos()}"); ImGui.Checkbox("Demo Window", ref _showDemoWindow); // Edit bools storing our windows open/close state ImGui.Checkbox("Another Window", ref _showAnotherWindow); ImGui.Checkbox("Memory Editor", ref _showMemoryEditor); if (ImGui.Button("Button")) // Buttons return true when clicked (NB: most widgets return true when edited/activated) { _counter++; } ImGui.SameLine(0, -1); ImGui.Text($"counter = {_counter}"); ImGui.DragInt("Draggable Int", ref _dragInt); float framerate = ImGui.GetIO().Framerate; ImGui.Text($"Application average {1000.0f / framerate:0.##} ms/frame ({framerate:0.#} FPS)"); } // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows. if (_showAnotherWindow) { ImGui.Begin("Another Window", ref _showAnotherWindow); ImGui.Text("Hello from another window!"); if (ImGui.Button("Close Me")) { _showAnotherWindow = false; } ImGui.End(); } // 3. Show the ImGui demo window. Most of the sample code is in ImGui.ShowDemoWindow(). Read its code to learn more about Dear ImGui! if (_showDemoWindow) { // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. // Here we just want to make the demo initial state a bit more friendly! ImGui.SetNextWindowPos(new Vector2(650, 20), ImGuiCond.FirstUseEver); ImGui.ShowDemoWindow(ref _showDemoWindow); } if (ImGui.TreeNode("Tabs")) { if (ImGui.TreeNode("Basic")) { ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None; if (ImGui.BeginTabBar("MyTabBar", tab_bar_flags)) { if (ImGui.BeginTabItem("Avocado")) { ImGui.Text("This is the Avocado tab!\nblah blah blah blah blah"); ImGui.EndTabItem(); } if (ImGui.BeginTabItem("Broccoli")) { ImGui.Text("This is the Broccoli tab!\nblah blah blah blah blah"); ImGui.EndTabItem(); } if (ImGui.BeginTabItem("Cucumber")) { ImGui.Text("This is the Cucumber tab!\nblah blah blah blah blah"); ImGui.EndTabItem(); } ImGui.EndTabBar(); } ImGui.Separator(); ImGui.TreePop(); } if (ImGui.TreeNode("Advanced & Close Button")) { // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0). ImGui.CheckboxFlags("ImGuiTabBarFlags_Reorderable", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.Reorderable); ImGui.CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.AutoSelectNewTabs); ImGui.CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.NoCloseWithMiddleMouseButton); if ((s_tab_bar_flags & (uint)ImGuiTabBarFlags.FittingPolicyMask) == 0) { s_tab_bar_flags |= (uint)ImGuiTabBarFlags.FittingPolicyDefault; } if (ImGui.CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.FittingPolicyResizeDown)) { s_tab_bar_flags &= ~((uint)ImGuiTabBarFlags.FittingPolicyMask ^ (uint)ImGuiTabBarFlags.FittingPolicyResizeDown); } if (ImGui.CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", ref s_tab_bar_flags, (uint)ImGuiTabBarFlags.FittingPolicyScroll)) { s_tab_bar_flags &= ~((uint)ImGuiTabBarFlags.FittingPolicyMask ^ (uint)ImGuiTabBarFlags.FittingPolicyScroll); } // Tab Bar string[] names = { "Artichoke", "Beetroot", "Celery", "Daikon" }; for (int n = 0; n < s_opened.Length; n++) { if (n > 0) { ImGui.SameLine(); } ImGui.Checkbox(names[n], ref s_opened[n]); } // Passing a bool* to BeginTabItem() is similar to passing one to Begin(): the underlying bool will be set to false when the tab is closed. if (ImGui.BeginTabBar("MyTabBar", (ImGuiTabBarFlags)s_tab_bar_flags)) { for (int n = 0; n < s_opened.Length; n++) { if (s_opened[n] && ImGui.BeginTabItem(names[n], ref s_opened[n])) { ImGui.Text($"This is the {names[n]} tab!"); if ((n & 1) != 0) { ImGui.Text("I am an odd tab."); } ImGui.EndTabItem(); } } ImGui.EndTabBar(); } ImGui.Separator(); ImGui.TreePop(); } ImGui.TreePop(); } ImGuiIOPtr io = ImGui.GetIO(); SetThing(out io.DeltaTime, 2f); if (_showMemoryEditor) { _memoryEditor.Draw("Memory Editor", _memoryEditorData, _memoryEditorData.Length); } }