private static void DrawLine(string path, string name) { ImGui.TableNextColumn(); ImGuiCustom.CopyOnClickSelectable(path); ImGui.TableNextColumn(); ImGuiCustom.PrintIcon(FontAwesomeIcon.LongArrowAltLeft); ImGui.SameLine(); ImGuiCustom.CopyOnClickSelectable(name); }
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 void DrawFileSwapTabEdit() { if (!ImGui.BeginTabItem(LabelFileSwapTab)) { return; } using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem); ImGui.SetNextItemWidth(-1); if (!ImGui.BeginListBox(LabelFileSwapHeader, AutoFillSize)) { return; } raii.Push(ImGui.EndListBox); var swaps = Meta.FileSwaps.Keys.ToArray(); ImGui.PushFont(UiBuilder.IconFont); var arrowWidth = ImGui.CalcTextSize(FontAwesomeIcon.LongArrowAltRight.ToIconString()).X; ImGui.PopFont(); var width = (ImGui.GetWindowWidth() - arrowWidth - 4 * ImGui.GetStyle().ItemSpacing.X) / 2; for (var idx = 0; idx < swaps.Length + 1; ++idx) { var key = idx == swaps.Length ? GamePath.GenerateUnchecked("") : swaps[idx]; var value = idx == swaps.Length ? GamePath.GenerateUnchecked("") : Meta.FileSwaps[key]; string keyString = key; string valueString = value; ImGui.SetNextItemWidth(width); if (ImGui.InputTextWithHint($"##swapLhs_{idx}", "Enter new file to be replaced...", ref keyString, GamePath.MaxGamePathLength, ImGuiInputTextFlags.EnterReturnsTrue)) { var newKey = new GamePath(keyString); if (newKey.CompareTo(key) != 0) { if (idx < swaps.Length) { Meta.FileSwaps.Remove(key); } if (newKey != string.Empty) { Meta.FileSwaps[newKey] = value; } _selector.SaveCurrentMod(); _selector.ReloadCurrentMod(); } } if (idx >= swaps.Length) { continue; } ImGui.SameLine(); ImGuiCustom.PrintIcon(FontAwesomeIcon.LongArrowAltRight); ImGui.SameLine(); ImGui.SetNextItemWidth(width); if (ImGui.InputTextWithHint($"##swapRhs_{idx}", "Enter new replacement path...", ref valueString, GamePath.MaxGamePathLength, ImGuiInputTextFlags.EnterReturnsTrue)) { var newValue = new GamePath(valueString); if (newValue.CompareTo(value) != 0) { Meta.FileSwaps[key] = newValue; _selector.SaveCurrentMod(); _selector.Cache.TriggerListReset(); } } } }