fancy settings

This commit is contained in:
azyges
2025-08-31 08:29:23 +09:00
parent dc0265f614
commit c3a6f2c88d
3 changed files with 661 additions and 466 deletions

View File

@@ -214,7 +214,8 @@ public class SettingsUi : WindowMediatorSubscriberBase
private void DrawCurrentTransfers()
{
_lastTab = "Transfers";
_uiShared.BigText("Transfer Settings");
_uiShared.UnderlinedBigText("Transfer Settings", UIColors.Get("LightlessBlue"));
ImGuiHelpers.ScaledDummy(5);
int maxParallelDownloads = _configService.Current.ParallelDownloads;
bool useAlternativeUpload = _configService.Current.UseAlternativeFileUpload;
@@ -263,7 +264,8 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("This will attempt to upload files in one go instead of a stream. Typically not necessary to enable. Use if you have upload issues.");
ImGui.Separator();
_uiShared.BigText("Transfer UI");
_uiShared.UnderlinedBigText("Transfer UI", UIColors.Get("LightlessBlue"));
ImGuiHelpers.ScaledDummy(5);
bool showTransferWindow = _configService.Current.ShowTransferWindow;
if (ImGui.Checkbox("Show separate transfer window", ref showTransferWindow))
@@ -400,7 +402,8 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
ImGui.Separator();
_uiShared.BigText("Current Transfers");
_uiShared.UnderlinedBigText("Current Transfers", UIColors.Get("LightlessBlue"));
ImGuiHelpers.ScaledDummy(5);
if (ImGui.BeginTabBar("TransfersTabBar"))
{
@@ -561,7 +564,8 @@ public class SettingsUi : WindowMediatorSubscriberBase
{
_lastTab = "Debug";
_uiShared.BigText("Debug");
_uiShared.UnderlinedBigText("Debug", UIColors.Get("LightlessYellow"));
ImGuiHelpers.ScaledDummy(10);
#if DEBUG
if (LastCreatedCharacterData != null && ImGui.TreeNode("Last created character data"))
{
@@ -621,13 +625,15 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_uiShared.DrawHelpText("Having modified game files will still mark your logs with UNSUPPORTED and you will not receive support, message shown or not." + UiSharedService.TooltipSeparator
+ "Keeping LOD enabled can lead to more crashes. Use at your own risk.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessYellow"), 2f);
}
private void DrawFileStorageSettings()
{
_lastTab = "FileCache";
_uiShared.BigText("Export MCDF");
_uiShared.UnderlinedBigText("Export MCDF", UIColors.Get("LightlessBlue"));
ImGuiHelpers.ScaledDummy(10);
@@ -646,7 +652,8 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGuiHelpers.ScaledDummy(5);
ImGui.Separator();
_uiShared.BigText("Storage");
_uiShared.UnderlinedBigText("Storage", UIColors.Get("LightlessBlue"));
ImGuiHelpers.ScaledDummy(5);
UiSharedService.TextWrapped("Lightless stores downloaded files from paired people permanently. This is to improve loading performance and requiring less downloads. " +
"The storage governs itself by clearing data beyond the set storage size. Please set the storage size accordingly. It is not necessary to manually clear the storage.");
@@ -759,6 +766,9 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGuiHelpers.ScaledDummy(new Vector2(10, 10));
ImGui.Separator();
if (_uiShared.MediumTreeNode("Storage Validation", UIColors.Get("LightlessYellow")))
{
UiSharedService.TextWrapped("File Storage validation can make sure that all files in your local Lightless Storage are valid. " +
"Run the validation before you clear the Storage for no reason. " + Environment.NewLine +
"This operation, depending on how many files you have in your storage, can take a while and will be CPU and drive intensive.");
@@ -798,9 +808,15 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
}
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
ImGuiHelpers.ScaledDummy(new Vector2(10, 10));
if (_uiShared.MediumTreeNode("Validation", UIColors.Get("DimRed")))
{
ImGui.TextUnformatted("To clear the local storage accept the following disclaimer");
ImGui.Indent();
ImGui.Checkbox("##readClearCache", ref _readClearCache);
@@ -827,6 +843,10 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (!_readClearCache)
ImGui.EndDisabled();
ImGui.Unindent();
_uiShared.ColoredSeparator(UIColors.Get("DimRed"), 1.5f);
ImGui.TreePop();
}
}
private void DrawGeneral()
@@ -840,7 +860,12 @@ public class SettingsUi : WindowMediatorSubscriberBase
//UiSharedService.FontText("Experimental", _uiShared.UidFont);
//ImGui.Separator();
_uiShared.UnderlinedBigText("General Settings", UIColors.Get("LightlessBlue"));
ImGui.Dummy(new Vector2(10));
_uiShared.BigText("Notes");
if (_uiShared.MediumTreeNode("Import & Export", UIColors.Get("LightlessPurple")))
{
if (_uiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Export all your user notes to clipboard"))
{
ImGui.SetClipboardText(UiSharedService.GetNotes(_pairManager.DirectPairs.UnionBy(_pairManager.GroupPairs.SelectMany(p => p.Value), p => p.UserData, UserDataComparer.Instance).ToList()));
@@ -864,8 +889,15 @@ public class SettingsUi : WindowMediatorSubscriberBase
UiSharedService.ColorTextWrapped("Attempt to import notes from clipboard failed. Check formatting and try again", ImGuiColors.DalamudRed);
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
var openPopupOnAddition = _configService.Current.OpenPopupOnAdd;
if (_uiShared.MediumTreeNode("Popup & Auto Fill", UIColors.Get("LightlessPurple")))
{
if (ImGui.Checkbox("Open Notes Popup on user addition", ref openPopupOnAddition))
{
_configService.Current.OpenPopupOnAdd = openPopupOnAddition;
@@ -881,8 +913,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_uiShared.DrawHelpText("This will automatically populate user notes using the first encountered player name if the note was not set prior");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
ImGui.Dummy(new Vector2(10));
_uiShared.BigText("UI");
var showNameInsteadOfNotes = _configService.Current.ShowCharacterNameInsteadOfNotesForVisible;
var showVisibleSeparate = _configService.Current.ShowVisibleUsersSeparately;
var showOfflineSeparate = _configService.Current.ShowOfflineUsersSeparately;
@@ -904,6 +942,9 @@ public class SettingsUi : WindowMediatorSubscriberBase
var groupInVisible = _configService.Current.ShowSyncshellUsersInVisible;
var syncshellOfflineSeparate = _configService.Current.ShowSyncshellOfflineUsersSeparately;
if (_uiShared.MediumTreeNode("Behavior", UIColors.Get("LightlessPurple")))
{
if (ImGui.Checkbox("Enable Game Right Click Menu Entries", ref enableRightClickMenu))
{
_configService.Current.EnableRightClickMenus = enableRightClickMenu;
@@ -999,6 +1040,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
if (_uiShared.MediumTreeNode("Pair List", UIColors.Get("LightlessPurple")))
{
if (ImGui.Checkbox("Show separate Visible group", ref showVisibleSeparate))
{
_configService.Current.ShowVisibleUsersSeparately = showVisibleSeparate;
@@ -1071,6 +1120,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Save();
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
if (_uiShared.MediumTreeNode("Profiles", UIColors.Get("LightlessPurple")))
{
if (ImGui.Checkbox("Show Lightless Profiles on Hover", ref showProfiles))
{
Mediator.Publish(new ClearProfileDataMessage());
@@ -1103,14 +1159,21 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_uiShared.DrawHelpText("Will show profiles that have the NSFW tag enabled");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
ImGui.Dummy(new Vector2(10));
_uiShared.BigText("Notifications");
var disableOptionalPluginWarnings = _configService.Current.DisableOptionalPluginWarnings;
var onlineNotifs = _configService.Current.ShowOnlineNotifications;
var onlineNotifsPairsOnly = _configService.Current.ShowOnlineNotificationsOnlyForIndividualPairs;
var onlineNotifsNamedOnly = _configService.Current.ShowOnlineNotificationsOnlyForNamedPairs;
_uiShared.BigText("Notifications");
if (_uiShared.MediumTreeNode("Display", UIColors.Get("LightlessPurple")))
{
_uiShared.DrawCombo("Info Notification Display##settingsUi", (NotificationLocation[])Enum.GetValues(typeof(NotificationLocation)), (i) => i.ToString(),
(i) =>
{
@@ -1147,6 +1210,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
+ Environment.NewLine + "'Toast' will show Error toast notifications in the bottom right corner"
+ Environment.NewLine + "'Both' will show chat as well as the toast notification");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
if (_uiShared.MediumTreeNode("Toggles", UIColors.Get("LightlessPurple")))
{
if (ImGui.Checkbox("Disable optional plugin warnings", ref disableOptionalPluginWarnings))
{
_configService.Current.DisableOptionalPluginWarnings = disableOptionalPluginWarnings;
@@ -1173,16 +1244,22 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Save();
}
_uiShared.DrawHelpText("Enabling this will only show online notifications (type: Info) for pairs where you have set an individual note.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
}
private void DrawPerformance()
{
_uiShared.BigText("Performance Settings");
_uiShared.UnderlinedBigText("Performance Settings", UIColors.Get("LightlessBlue"));
ImGui.Dummy(new Vector2(10));
UiSharedService.TextWrapped("The configuration options here are to give you more informed warnings and automation when it comes to other performance-intensive synced players.");
ImGui.Dummy(new Vector2(10));
ImGui.Separator();
ImGui.Dummy(new Vector2(10));
bool showPerformanceIndicator = _playerPerformanceConfigService.Current.ShowPerformanceIndicator;
if (_uiShared.MediumTreeNode("Warnings", UIColors.Get("LightlessPurple")))
{
if (ImGui.Checkbox("Show performance indicator", ref showPerformanceIndicator))
{
_playerPerformanceConfigService.Current.ShowPerformanceIndicator = showPerformanceIndicator;
@@ -1232,9 +1309,18 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Limit in approximate used triangles from mods to trigger warning or performance indicator on UI." + UiSharedService.TooltipSeparator
+ "Default: 165 thousand");
}
ImGui.Dummy(new Vector2(10));
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
bool autoPause = _playerPerformanceConfigService.Current.AutoPausePlayersExceedingThresholds;
bool autoPauseEveryone = _playerPerformanceConfigService.Current.AutoPausePlayersWithPreferredPermissionsExceedingThresholds;
if (_uiShared.MediumTreeNode("Auto Pause", UIColors.Get("LightlessPurple")))
{
if (ImGui.Checkbox("Automatically pause players exceeding thresholds", ref autoPause))
{
_playerPerformanceConfigService.Current.AutoPausePlayersExceedingThresholds = autoPause;
@@ -1276,8 +1362,17 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("When a loading in player and their triangle count exceeds this amount, automatically pauses the synced player." + UiSharedService.TooltipSeparator
+ "Default: 250 thousand");
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
ImGui.Dummy(new Vector2(10));
_uiShared.BigText("Whitelisted UIDs");
_uiShared.UnderlinedBigText("Whitelisted UIDs", UIColors.Get("LightlessBlue"));
ImGuiHelpers.ScaledDummy(5);
UiSharedService.TextWrapped("The entries in the list below will be ignored for all warnings and auto pause operations.");
ImGui.Dummy(new Vector2(10));
ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale);
@@ -1328,7 +1423,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
_lastTab = "Service Settings";
if (ApiController.ServerAlive)
{
_uiShared.BigText("Service Actions");
_uiShared.UnderlinedBigText("Service Actions", UIColors.Get("LightlessBlue"));
ImGui.Dummy(new Vector2(10));
if (_uiShared.MediumTreeNode("Deletion", UIColors.Get("DimRed")))
{
ImGuiHelpers.ScaledDummy(new Vector2(5, 5));
if (ImGui.Button("Delete all my files"))
{
@@ -1403,12 +1502,20 @@ public class SettingsUi : WindowMediatorSubscriberBase
UiSharedService.SetScaledWindowSize(325);
ImGui.EndPopup();
}
_uiShared.ColoredSeparator(UIColors.Get("DimRed"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
}
_uiShared.BigText("Service & Character Settings");
ImGuiHelpers.ScaledDummy(new Vector2(5, 5));
ImGui.Dummy(new Vector2(10));
_uiShared.MediumText("Service & Character Settings", UIColors.Get("LightlessPurple"));
ImGui.Dummy(new Vector2(5));
var sendCensus = _serverConfigurationManager.SendCensusData;
if (ImGui.Checkbox("Send Statistical Census Data", ref sendCensus))
{
_serverConfigurationManager.SendCensusData = sendCensus;
@@ -1881,6 +1988,8 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
ImGui.EndTabBar();
}
ImGui.Dummy(new Vector2(10));
}
private int _lastSelectedServerIndex = -1;

View File

@@ -8,9 +8,10 @@ namespace LightlessSync.UI
private static readonly Dictionary<string, string> HexColors = new(StringComparer.OrdinalIgnoreCase)
{
{ "LightlessPurple", "#ad8af5" },
{ "LightlessBlue", "#64c7e8" },
{ "PairBlue", "#4e98b1" },
{ "DimRed", "#bd0000" },
{ "LightlessBlue", "#a6c2ff" },
{ "LightlessYellow", "#ffe97a" },
{ "PairBlue", "#88a2db" },
{ "DimRed", "#d44444" },
};
public static Vector4 Get(string name)

View File

@@ -114,6 +114,15 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
SizePx = 35
}));
});
MediumFont = _pluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e =>
{
e.OnPreBuild(tk => tk.AddDalamudAssetFont(Dalamud.DalamudAsset.NotoSansJpMedium, new()
{
SizePx = 22,
}));
});
GameFont = _pluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(new(GameFontFamilyAndSize.Axis12));
IconFont = _pluginInterface.UiBuilder.IconFontFixedWidthHandle;
}
@@ -133,6 +142,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
public string PlayerName => _dalamudUtil.GetPlayerName();
public IFontHandle UidFont { get; init; }
public IFontHandle MediumFont { get; init; }
public Dictionary<ushort, string> WorldData => _dalamudUtil.WorldData.Value;
public uint WorldId => _dalamudUtil.GetHomeWorldId();
@@ -434,6 +445,79 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
FontText(text, UidFont, color);
}
public void UnderlinedBigText(
string text,
Vector4? textColor = null,
Vector4? underlineColor = null,
float underlineThickness = 2f)
{
using var font = UidFont.Push();
var drawList = ImGui.GetWindowDrawList();
var textSize = ImGui.CalcTextSize(text);
var pos = ImGui.GetCursorScreenPos();
var text_color = textColor ?? ImGuiColors.DalamudWhite;
var line_color = underlineColor ?? text_color;
ImGui.PushStyleColor(ImGuiCol.Text, text_color);
ImGui.TextUnformatted(text);
ImGui.PopStyleColor();
var lineY = pos.Y + textSize.Y + 2f;
drawList.AddLine(
new Vector2(pos.X, lineY),
new Vector2(pos.X + textSize.X, lineY),
ImGui.GetColorU32(line_color),
underlineThickness * ImGuiHelpers.GlobalScale
);
}
public void ColoredSeparator(Vector4? color = null, float thickness = 1f, float indent = 0f)
{
var drawList = ImGui.GetWindowDrawList();
var min = ImGui.GetCursorScreenPos();
var max = new Vector2(min.X + ImGui.GetContentRegionAvail().X, min.Y);
min.X += indent;
max.X -= indent;
drawList.AddLine(
min,
new Vector2(max.X, min.Y),
ImGui.GetColorU32(color ?? ImGuiColors.DalamudGrey),
thickness * ImGuiHelpers.GlobalScale
);
ImGui.Dummy(new Vector2(0, thickness * ImGuiHelpers.GlobalScale));
}
public void MediumText(string text, Vector4? color = null)
{
FontText(text, MediumFont, color);
}
public bool MediumTreeNode(string label, Vector4? textColor = null, float lineWidth = 2f, ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.SpanAvailWidth)
{
using var font = MediumFont.Push();
var lineColor = textColor ?? ImGuiColors.DalamudWhite;
var textSize = ImGui.CalcTextSize(label);
var cursorScreen = ImGui.GetCursorScreenPos();
var cursorLocal = ImGui.GetCursorPos();
ImGui.GetWindowDrawList().AddLine(
new Vector2(cursorScreen.X, cursorScreen.Y),
new Vector2(cursorScreen.X, cursorScreen.Y + textSize.Y),
ImGui.GetColorU32(lineColor),
lineWidth * ImGuiHelpers.GlobalScale
);
ImGui.SetCursorPosX(cursorLocal.X + 6f);
using var color = ImRaii.PushColor(ImGuiCol.Text, lineColor);
return ImGui.TreeNodeEx(label, flags);
}
public void BooleanToColoredIcon(bool value, bool inline = true)
{
using var colorgreen = ImRaii.PushColor(ImGuiCol.Text, UIColors.Get("LightlessBlue"), value);
@@ -1085,6 +1169,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
UidFont.Dispose();
GameFont.Dispose();
MediumFont.Dispose();
}
private static void CenterWindow(float width, float height, ImGuiCond cond = ImGuiCond.None)