Wow, I accidentally the whole UI

This commit is contained in:
Ottermandias 2023-03-18 21:39:59 +01:00
parent dd8c910597
commit 651c7410ac
87 changed files with 7571 additions and 7280 deletions

View file

@ -1,144 +1,131 @@
using System;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using OtterGui.Widgets;
using Penumbra.Api.Enums;
using Penumbra.Interop.Services;
using Penumbra.Mods;
using Penumbra.Services;
using Penumbra.UI.Classes;
using Penumbra.UI.Tabs;
using Penumbra.Util;
namespace Penumbra.UI;
public sealed partial class ConfigWindow : Window, IDisposable
public sealed class ConfigWindow : Window
{
private readonly Penumbra _penumbra;
private readonly ModFileSystemSelector _selector;
private readonly ModPanel _modPanel;
public readonly ModEditWindow ModEditPopup;
private readonly Configuration _config;
private readonly DalamudPluginInterface _pluginInterface;
private readonly Configuration _config;
private readonly PerformanceTracker _tracker;
private readonly ValidityChecker _validityChecker;
private readonly Penumbra _penumbra;
private readonly ConfigTabBar _configTabs;
private string? _lastException;
private readonly SettingsTab _settingsTab;
private readonly CollectionsTab _collectionsTab;
private readonly ModsTab _modsTab;
private readonly ChangedItemsTab _changedItemsTab;
private readonly EffectiveTab _effectiveTab;
private readonly DebugTab _debugTab;
private readonly ResourceTab _resourceTab;
private readonly ResourceWatcher _resourceWatcher;
public void SelectTab(TabType tab)
=> _configTabs.SelectTab = tab;
public TabType SelectTab = TabType.None;
public void SelectMod(Mod mod)
=> _selector.SelectByValue(mod);
=> _configTabs.Mods.SelectMod = mod;
public ConfigWindow(Configuration config, CommunicatorService communicator, StartTracker timer, FontReloader fontReloader,
Penumbra penumbra, ResourceWatcher watcher)
: base(GetLabel())
public ConfigWindow(PerformanceTracker tracker, DalamudPluginInterface pi, Configuration config, ValidityChecker checker,
TutorialService tutorial, Penumbra penumbra, ConfigTabBar configTabs)
: base(GetLabel(checker))
{
_penumbra = penumbra;
_pluginInterface = pi;
_config = config;
_resourceWatcher = watcher;
_tracker = tracker;
_validityChecker = checker;
_penumbra = penumbra;
_configTabs = configTabs;
ModEditPopup = new ModEditWindow(communicator);
_settingsTab = new SettingsTab(this, fontReloader);
_selector = new ModFileSystemSelector(communicator, _penumbra.ModFileSystem);
_modPanel = new ModPanel(this);
_modsTab = new ModsTab(_selector, _modPanel, _penumbra);
_selector.SelectionChanged += _modPanel.OnSelectionChange;
_collectionsTab = new CollectionsTab(communicator, this);
_changedItemsTab = new ChangedItemsTab(this);
_effectiveTab = new EffectiveTab();
_debugTab = new DebugTab(this, timer);
_resourceTab = new ResourceTab();
if (Penumbra.Config.FixMainWindow)
Flags |= ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
DalamudServices.PluginInterface.UiBuilder.DisableGposeUiHide = !Penumbra.Config.HideUiInGPose;
DalamudServices.PluginInterface.UiBuilder.DisableCutsceneUiHide = !Penumbra.Config.HideUiInCutscenes;
DalamudServices.PluginInterface.UiBuilder.DisableUserUiHide = !Penumbra.Config.HideUiWhenUiHidden;
RespectCloseHotkey = true;
RespectCloseHotkey = true;
SizeConstraints = new WindowSizeConstraints()
{
MinimumSize = new Vector2(800, 600),
MaximumSize = new Vector2(4096, 2160),
};
UpdateTutorialStep();
tutorial.UpdateTutorialStep();
IsOpen = _config.DebugMode;
}
private ReadOnlySpan<byte> ToLabel(TabType type)
=> type switch
{
TabType.Settings => _settingsTab.Label,
TabType.Mods => _modsTab.Label,
TabType.Collections => _collectionsTab.Label,
TabType.ChangedItems => _changedItemsTab.Label,
TabType.EffectiveChanges => _effectiveTab.Label,
TabType.ResourceWatcher => _resourceWatcher.Label,
TabType.Debug => _debugTab.Label,
TabType.ResourceManager => _resourceTab.Label,
_ => ReadOnlySpan<byte>.Empty,
};
public override void PreDraw()
{
if (_config.FixMainWindow)
Flags |= ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
else
Flags &= ~(ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove);
}
public override void Draw()
{
using var performance = Penumbra.Performance.Measure(PerformanceType.UiMainWindow);
using var timer = _tracker.Measure(PerformanceType.UiMainWindow);
UiHelpers.SetupCommonSizes();
try
{
if (Penumbra.ValidityChecker.ImcExceptions.Count > 0)
{
DrawProblemWindow(_penumbra,
$"There were {Penumbra.ValidityChecker.ImcExceptions.Count} errors while trying to load IMC files from the game data.\n"
DrawProblemWindow(
$"There were {_validityChecker.ImcExceptions.Count} errors while trying to load IMC files from the game data.\n"
+ "This usually means that your game installation was corrupted by updating the game while having TexTools mods still active.\n"
+ "It is recommended to not use TexTools and Penumbra (or other Lumina-based tools) at the same time.\n\n"
+ "Please use the Launcher's Repair Game Files function to repair your client installation.", true);
+ "Please use the Launcher's Repair Game Files function to repair your client installation.");
DrawImcExceptions();
}
else if (!Penumbra.ValidityChecker.IsValidSourceRepo)
{
DrawProblemWindow(_penumbra,
$"You are loading a release version of Penumbra from the repository \"{DalamudServices.PluginInterface.SourceRepository}\" instead of the official repository.\n"
DrawProblemWindow(
$"You are loading a release version of Penumbra from the repository \"{_pluginInterface.SourceRepository}\" instead of the official repository.\n"
+ $"Please use the official repository at {ValidityChecker.Repository}.\n\n"
+ "If you are developing for Penumbra and see this, you should compile your version in debug mode to avoid it.", false);
+ "If you are developing for Penumbra and see this, you should compile your version in debug mode to avoid it.");
}
else if (Penumbra.ValidityChecker.IsNotInstalledPenumbra)
{
DrawProblemWindow(_penumbra,
$"You are loading a release version of Penumbra from \"{DalamudServices.PluginInterface.AssemblyLocation.Directory?.FullName ?? "Unknown"}\" instead of the installedPlugins directory.\n\n"
DrawProblemWindow(
$"You are loading a release version of Penumbra from \"{_pluginInterface.AssemblyLocation.Directory?.FullName ?? "Unknown"}\" instead of the installedPlugins directory.\n\n"
+ "You should not install Penumbra manually, but rather add the plugin repository under settings and then install it via the plugin installer.\n\n"
+ "If you do not know how to do this, please take a look at the readme in Penumbras github repository or join us in discord.\n"
+ "If you are developing for Penumbra and see this, you should compile your version in debug mode to avoid it.", false);
+ "If you are developing for Penumbra and see this, you should compile your version in debug mode to avoid it.");
}
else if (Penumbra.ValidityChecker.DevPenumbraExists)
{
DrawProblemWindow(_penumbra,
$"You are loading a installed version of Penumbra from \"{DalamudServices.PluginInterface.AssemblyLocation.Directory?.FullName ?? "Unknown"}\", "
DrawProblemWindow(
$"You are loading a installed version of Penumbra from \"{_pluginInterface.AssemblyLocation.Directory?.FullName ?? "Unknown"}\", "
+ "but also still have some remnants of a custom install of Penumbra in your devPlugins folder.\n\n"
+ "This can cause some issues, so please go to your \"%%appdata%%\\XIVLauncher\\devPlugins\" folder and delete the Penumbra folder from there.\n\n"
+ "If you are developing for Penumbra, try to avoid mixing versions. This warning will not appear if compiled in Debug mode.",
false);
+ "If you are developing for Penumbra, try to avoid mixing versions. This warning will not appear if compiled in Debug mode.");
}
else
{
SetupSizes();
if (TabBar.Draw(string.Empty, ImGuiTabBarFlags.NoTooltip, ToLabel(SelectTab), _settingsTab, _modsTab, _collectionsTab,
_changedItemsTab, _effectiveTab, _resourceWatcher, _debugTab, _resourceTab))
SelectTab = TabType.None;
_configTabs.Draw();
}
_lastException = null;
}
catch (Exception e)
{
Penumbra.Log.Error($"Exception thrown during UI Render:\n{e}");
if (_lastException != null)
{
var text = e.ToString();
if (text == _lastException)
return;
_lastException = text;
}
Penumbra.Log.Error($"Exception thrown during UI Render:\n{_lastException}");
}
}
private static void DrawProblemWindow(Penumbra penumbra, string text, bool withExceptions)
private static string GetLabel(ValidityChecker checker)
=> checker.Version.Length == 0
? "Penumbra###PenumbraConfigWindow"
: $"Penumbra v{Penumbra.Version}###PenumbraConfigWindow";
private void DrawProblemWindow(string text)
{
using var color = ImRaii.PushColor(ImGuiCol.Text, Colors.RegexWarningBorder);
ImGui.NewLine();
@ -148,47 +135,23 @@ public sealed partial class ConfigWindow : Window, IDisposable
ImGui.NewLine();
ImGui.NewLine();
SettingsTab.DrawDiscordButton(0);
UiHelpers.DrawDiscordButton(0);
ImGui.SameLine();
SettingsTab.DrawSupportButton(penumbra);
UiHelpers.DrawSupportButton(_penumbra);
ImGui.NewLine();
ImGui.NewLine();
}
if (withExceptions)
private void DrawImcExceptions()
{
ImGui.TextUnformatted("Exceptions");
ImGui.Separator();
using var box = ImRaii.ListBox("##Exceptions", new Vector2(-1, -1));
foreach (var exception in _validityChecker.ImcExceptions)
{
ImGui.TextUnformatted("Exceptions");
ImGuiUtil.TextWrapped(exception.ToString());
ImGui.Separator();
using var box = ImRaii.ListBox("##Exceptions", new Vector2(-1, -1));
foreach (var exception in Penumbra.ValidityChecker.ImcExceptions)
{
ImGuiUtil.TextWrapped(exception.ToString());
ImGui.Separator();
ImGui.NewLine();
}
ImGui.NewLine();
}
}
public void Dispose()
{
_selector.Dispose();
_modPanel.Dispose();
_collectionsTab.Dispose();
ModEditPopup.Dispose();
}
private static string GetLabel()
=> Penumbra.Version.Length == 0
? "Penumbra###PenumbraConfigWindow"
: $"Penumbra v{Penumbra.Version}###PenumbraConfigWindow";
private Vector2 _defaultSpace;
private Vector2 _inputTextWidth;
private Vector2 _iconButtonSize;
private void SetupSizes()
{
_defaultSpace = new Vector2(0, 10 * ImGuiHelpers.GlobalScale);
_inputTextWidth = new Vector2(350f * ImGuiHelpers.GlobalScale, 0);
_iconButtonSize = new Vector2(ImGui.GetFrameHeight());
}
}