feat: port Dalamud windows to WindowSystem

This commit is contained in:
goat 2021-04-05 23:22:41 +02:00
parent 65fb949c61
commit c21e7efab7
10 changed files with 252 additions and 247 deletions

View file

@ -231,17 +231,12 @@ namespace Dalamud
Log.Verbose("[START] PREPO OK!");
this.DalamudUi = new DalamudInterface(this);
Log.Verbose("[START] DUI OK!");
var isInterfaceLoaded = false;
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") ?? "false"))
{
try
{
this.InterfaceManager = new InterfaceManager(this, this.SigScanner);
this.InterfaceManager.OnDraw += this.DalamudUi.Draw;
this.InterfaceManager.Enable();
isInterfaceLoaded = true;
@ -313,6 +308,11 @@ namespace Dalamud
this.ClientState.Enable();
Log.Verbose("[START] CS ENABLE!");
this.DalamudUi = new DalamudInterface(this);
this.InterfaceManager.OnDraw += this.DalamudUi.Draw;
Log.Verbose("[START] DUI OK!");
this.IsReady = true;
Troubleshooting.LogTroubleshooting(this, isInterfaceLoaded);
@ -373,18 +373,20 @@ namespace Dalamud
Log.Error(ex, "Plugin unload failed.");
}
this.Framework.Dispose();
this.ClientState.Dispose();
this.DalamudUi?.Dispose();
this.unloadSignal.Dispose();
this.Framework?.Dispose();
this.ClientState?.Dispose();
this.WinSock2.Dispose();
this.unloadSignal?.Dispose();
this.SigScanner.Dispose();
this.WinSock2?.Dispose();
this.Data.Dispose();
this.SigScanner?.Dispose();
this.AntiDebug.Dispose();
this.Data?.Dispose();
this.AntiDebug?.Dispose();
Log.Debug("Dalamud::Dispose() OK!");
}

View file

@ -2,35 +2,32 @@ using System;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using ImGuiNET;
using Lumina.Data.Parsing.Layer;
namespace Dalamud.Interface {
class DalamudChangelogWindow : IDisposable {
class DalamudChangelogWindow : Window {
private readonly Dalamud dalamud;
private string assemblyVersion = Util.AssemblyVersion;
private const bool WarrantsChangelog = true;
public const bool WarrantsChangelog = true;
private const string ChangeLog =
@"* Various behind-the-scenes changes to improve stability
* Faster startup times
If you note any issues or need help, please make sure to ask on our discord server.";
public DalamudChangelogWindow(Dalamud dalamud) {
public DalamudChangelogWindow(Dalamud dalamud)
: base("What's new in XIVLauncher?", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoResize)
{
this.dalamud = dalamud;
this.Namespace = "DalamudChangelogWindow";
}
public bool Draw() {
var doDraw = true;
if (!WarrantsChangelog)
return false;
ImGui.PushID("DalamudChangelogWindow");
ImGui.Begin("What's new in XIVLauncher?", ref doDraw, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoResize);
public override void Draw() {
ImGui.Text($"The in-game addon has been updated to version D{this.assemblyVersion}.");
ImGui.Dummy(new Vector2(10, 10) * ImGui.GetIO().FontGlobalScale);
@ -84,18 +81,10 @@ If you note any issues or need help, please make sure to ask on our discord serv
ImGui.Dummy(new Vector2(20, 0) * ImGui.GetIO().FontGlobalScale);
ImGui.SameLine();
if (ImGui.Button("Close")) {
doDraw = false;
if (ImGui.Button("Close"))
{
this.IsOpen = false;
}
ImGui.End();
ImGui.PopID();
return doDraw;
}
public void Dispose() {
}
}
}

View file

@ -1,13 +1,16 @@
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using Dalamud.Game.Internal;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using ImGuiScene;
using Serilog;
namespace Dalamud.Interface
{
class DalamudCreditsWindow : IDisposable {
class DalamudCreditsWindow : Window, IDisposable {
private const string CreditsTextTempl = @"
Dalamud
A FFXIV Hooking Framework
@ -101,39 +104,50 @@ Thank you for using XIVLauncher and Dalamud!
private string creditsText;
public DalamudCreditsWindow(Dalamud dalamud, TextureWrap logoTexture, Framework framework) {
public DalamudCreditsWindow(Dalamud dalamud)
: base("Dalamud Credits", ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize, true)
{
this.dalamud = dalamud;
this.logoTexture = logoTexture;
this.framework = framework;
framework.Gui.SetBgm(132);
this.logoTexture = this.dalamud.InterfaceManager.LoadImage(
Path.Combine(this.dalamud.AssetDirectory.FullName, "UIRes", "logo.png"));
this.framework = dalamud.Framework;
var pluginCredits = dalamud.PluginManager.Plugins.Where(x => x.Definition != null).Aggregate(string.Empty, (current, plugin) => current + $"{plugin.Definition.Name} by {plugin.Definition.Author}\n");
this.creditsText =
string.Format(CreditsTextTempl, typeof(Dalamud).Assembly.GetName().Version, pluginCredits);
this.Size = new Vector2(500, 400);
this.SizeCondition = ImGuiCond.Always;
this.PositionCondition = ImGuiCond.Always;
this.BgAlpha = 0.5f;
}
public override void OnOpen()
{
base.OnOpen();
this.framework.Gui.SetBgm(132);
}
public override void OnClose()
{
base.OnClose();
this.framework.Gui.SetBgm(9999);
}
public void Dispose() {
this.logoTexture.Dispose();
}
public bool Draw() {
var windowSize = new Vector2(500, 400) * ImGui.GetIO().FontGlobalScale;
ImGui.SetNextWindowSize(windowSize, ImGuiCond.Always);
var screenSize = ImGui.GetIO().DisplaySize;
ImGui.SetNextWindowPos(new Vector2((screenSize.X / 2) - windowSize.X /2, (screenSize.Y / 2) - windowSize.Y / 2), ImGuiCond.Always);
public override void Draw() {
var screenSize = ImGui.GetMainViewport().Size;
var windowSize = ImGui.GetWindowSize();
var isOpen = true;
ImGui.SetNextWindowBgAlpha(0.5f);
if (!ImGui.Begin("Dalamud Credits", ref isOpen, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoResize))
{
ImGui.End();
return false;
}
this.Position = new Vector2((screenSize.X / 2) - windowSize.X / 2, (screenSize.Y / 2) - windowSize.Y / 2);
ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.NoScrollbar);
@ -151,7 +165,7 @@ Thank you for using XIVLauncher and Dalamud!
foreach (var creditsLine in this.creditsText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)) {
var lineLenX = ImGui.CalcTextSize(creditsLine).X;
ImGui.Dummy(new Vector2((windowX / 2) - lineLenX / 2, 0f));
ImGui.SameLine();
ImGui.TextUnformatted(creditsLine);
@ -159,16 +173,16 @@ Thank you for using XIVLauncher and Dalamud!
ImGui.PopStyleVar();
if (ImGui.GetScrollY() < ImGui.GetScrollMaxY() - 0.2f)
ImGui.SetScrollY(ImGui.GetScrollY() + 0.2f);
var curY = ImGui.GetScrollY();
var maxY = ImGui.GetScrollMaxY();
if (curY < maxY - 1)
{
Log.Information($"{ImGui.GetScrollY()} {ImGui.GetScrollMaxY()}");
ImGui.SetScrollY(curY + 1);
}
ImGui.EndChild();
ImGui.End();
if (!isOpen)
this.framework.Gui.SetBgm(9999);
return isOpen;
}
}
}

View file

@ -11,6 +11,7 @@ using Dalamud.Game.ClientState.Actors.Types.NonPlayer;
using Dalamud.Game.ClientState.Structs.JobGauge;
using Dalamud.Game.Internal;
using Dalamud.Game.Internal.Gui.Addon;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using ImGuiNET;
using Newtonsoft.Json;
@ -21,7 +22,7 @@ namespace Dalamud.Interface
/// <summary>
/// Class responsible for drawing the data/debug window.
/// </summary>
internal class DalamudDataWindow
internal class DalamudDataWindow : Window
{
private readonly Dalamud dalamud;
@ -53,24 +54,22 @@ namespace Dalamud.Interface
/// </summary>
/// <param name="dalamud">The Dalamud instance to access data of.</param>
public DalamudDataWindow(Dalamud dalamud)
: base("Dalamud Data")
{
this.dalamud = dalamud;
this.Size = new Vector2(500, 500);
this.SizeCondition = ImGuiCond.FirstUseEver;
this.Load();
}
/// <summary>
/// Draw the window via ImGui.
/// </summary>
/// <returns>Whether or not the window is open.</returns>
public bool Draw()
public override void Draw()
{
this.copyButtonIndex = 0;
ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.FirstUseEver);
var isOpen = true;
ImGui.Begin("Dalamud Data", ref isOpen);
// Main window
if (ImGui.Button("Force Reload"))
@ -285,9 +284,6 @@ namespace Dalamud.Interface
ImGui.PopStyleVar();
ImGui.EndChild();
ImGui.End();
return isOpen;
}
private void DrawActorTable() {

View file

@ -3,9 +3,11 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using CheapLoc;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using ImGuiNET;
using Serilog;
@ -16,7 +18,7 @@ namespace Dalamud.Interface
/// <summary>
/// Class handling Dalamud core interface.
/// </summary>
internal class DalamudInterface
internal class DalamudInterface : IDisposable
{
private readonly Dalamud dalamud;
@ -30,21 +32,15 @@ namespace Dalamud.Interface
private bool isImguiDrawDevMenu = false;
#endif
private bool isImguiDrawLogWindow = false;
private bool isImguiDrawDataWindow = false;
private bool isImguiDrawPluginWindow = false;
private bool isImguiDrawCreditsWindow = false;
private bool isImguiDrawSettingsWindow = false;
private bool isImguiDrawPluginStatWindow = false;
private bool isImguiDrawChangelogWindow = false;
private readonly DalamudLogWindow logWindow;
private readonly DalamudDataWindow dataWindow;
private readonly DalamudCreditsWindow creditsWindow;
private readonly DalamudSettingsWindow settingsWindow;
private readonly PluginInstallerWindow pluginWindow;
private readonly DalamudPluginStatWindow pluginStatWindow;
private readonly DalamudChangelogWindow changelogWindow;
private DalamudLogWindow logWindow;
private DalamudDataWindow dataWindow;
private DalamudCreditsWindow creditsWindow;
private DalamudSettingsWindow settingsWindow;
private PluginInstallerWindow pluginWindow;
private DalamudPluginStatWindow pluginStatWindow;
private DalamudChangelogWindow changelogWindow;
private readonly WindowSystem windowSystem = new WindowSystem("DalamudCore");
/// <summary>
/// Initializes a new instance of the <see cref="DalamudInterface"/> class.
@ -53,6 +49,51 @@ namespace Dalamud.Interface
public DalamudInterface(Dalamud dalamud)
{
this.dalamud = dalamud;
this.logWindow = new DalamudLogWindow(this.dalamud.CommandManager, this.dalamud.Configuration)
{
IsOpen = false,
};
this.windowSystem.AddWindow(this.logWindow);
this.dataWindow = new DalamudDataWindow(this.dalamud)
{
IsOpen = false,
};
this.windowSystem.AddWindow(this.dataWindow);
this.creditsWindow = new DalamudCreditsWindow(this.dalamud)
{
IsOpen = false,
};
this.windowSystem.AddWindow(this.creditsWindow);
this.settingsWindow = new DalamudSettingsWindow(this.dalamud)
{
IsOpen = false,
};
this.windowSystem.AddWindow(this.settingsWindow);
this.pluginWindow = new PluginInstallerWindow(this.dalamud, this.dalamud.StartInfo.GameVersion)
{
IsOpen = false,
};
this.windowSystem.AddWindow(this.pluginWindow);
this.pluginStatWindow = new DalamudPluginStatWindow(this.dalamud.PluginManager)
{
IsOpen = false,
};
this.windowSystem.AddWindow(this.pluginStatWindow);
this.changelogWindow = new DalamudChangelogWindow(this.dalamud)
{
IsOpen = false,
};
this.windowSystem.AddWindow(this.changelogWindow);
Log.Information("[DUI] Windows added");
if (dalamud.Configuration.LogOpenAtStartup)
this.OpenLog();
}
@ -111,8 +152,7 @@ namespace Dalamud.Interface
if (ImGui.MenuItem("Open Log window"))
{
this.logWindow = new DalamudLogWindow(this.dalamud.CommandManager, this.dalamud.Configuration);
this.isImguiDrawLogWindow = true;
this.OpenLog();
}
if (ImGui.BeginMenu("Set log level..."))
@ -137,8 +177,7 @@ namespace Dalamud.Interface
if (ImGui.MenuItem("Open Data window"))
{
this.dataWindow = new DalamudDataWindow(this.dalamud);
this.isImguiDrawDataWindow = true;
this.OpenData();
}
if (ImGui.MenuItem("Open Credits window"))
@ -202,19 +241,14 @@ namespace Dalamud.Interface
{
if (ImGui.MenuItem("Open Plugin installer"))
{
this.pluginWindow = new PluginInstallerWindow(this.dalamud, this.dalamud.StartInfo.GameVersion);
this.isImguiDrawPluginWindow = true;
this.OpenPluginInstaller();
}
ImGui.Separator();
if (ImGui.MenuItem("Open Plugin Stats"))
{
if (!this.isImguiDrawPluginStatWindow)
{
this.pluginStatWindow = new DalamudPluginStatWindow(this.dalamud.PluginManager);
this.isImguiDrawPluginStatWindow = true;
}
OpenPluginStats();
}
if (ImGui.MenuItem("Print plugin info"))
@ -291,63 +325,10 @@ namespace Dalamud.Interface
if (this.dalamud.Framework.Gui.GameUiHidden)
return;
if (this.isImguiDrawLogWindow)
{
this.isImguiDrawLogWindow = this.logWindow != null && this.logWindow.Draw();
if (this.isImguiDrawLogWindow == false)
{
this.logWindow?.Dispose();
this.logWindow = null;
}
}
if (this.isImguiDrawDataWindow)
{
this.isImguiDrawDataWindow = this.dataWindow != null && this.dataWindow.Draw();
}
if (this.isImguiDrawPluginWindow)
{
this.isImguiDrawPluginWindow = this.pluginWindow != null && this.pluginWindow.Draw();
if (!this.isImguiDrawPluginWindow)
this.pluginWindow = null;
}
if (this.isImguiDrawCreditsWindow)
{
this.isImguiDrawCreditsWindow = this.creditsWindow != null && this.creditsWindow.Draw();
if (this.isImguiDrawCreditsWindow == false)
{
this.creditsWindow?.Dispose();
this.creditsWindow = null;
}
}
if (this.isImguiDrawSettingsWindow)
{
this.isImguiDrawSettingsWindow = this.settingsWindow != null && this.settingsWindow.Draw();
}
this.windowSystem.Draw();
if (this.isImguiDrawDemoWindow)
ImGui.ShowDemoWindow();
if (this.isImguiDrawPluginStatWindow)
{
this.isImguiDrawPluginStatWindow = this.pluginStatWindow != null && this.pluginStatWindow.Draw();
if (!this.isImguiDrawPluginStatWindow)
{
this.pluginStatWindow?.Dispose();
this.pluginStatWindow = null;
}
}
if (this.isImguiDrawChangelogWindow)
{
this.isImguiDrawChangelogWindow = this.changelogWindow != null && this.changelogWindow.Draw();
}
}
/// <summary>
@ -355,8 +336,7 @@ namespace Dalamud.Interface
/// </summary>
internal void OpenPluginInstaller()
{
this.pluginWindow ??= new PluginInstallerWindow(this.dalamud, this.dalamud.StartInfo.GameVersion);
this.isImguiDrawPluginWindow ^= true;
this.pluginWindow.IsOpen ^= true;
}
/// <summary>
@ -364,8 +344,7 @@ namespace Dalamud.Interface
/// </summary>
internal void OpenChangelog()
{
this.changelogWindow = new DalamudChangelogWindow(this.dalamud);
this.isImguiDrawChangelogWindow = true;
this.changelogWindow.IsOpen ^= true;
}
/// <summary>
@ -373,8 +352,7 @@ namespace Dalamud.Interface
/// </summary>
internal void OpenSettings()
{
this.settingsWindow = new DalamudSettingsWindow(this.dalamud);
this.isImguiDrawSettingsWindow ^= true;
this.settingsWindow.IsOpen ^= true;
}
/// <summary>
@ -382,8 +360,15 @@ namespace Dalamud.Interface
/// </summary>
internal void OpenLog()
{
this.logWindow = new DalamudLogWindow(this.dalamud.CommandManager, this.dalamud.Configuration);
this.isImguiDrawLogWindow = true;
this.logWindow.IsOpen ^= true;
}
/// <summary>
/// Open the data window.
/// </summary>
internal void OpenData()
{
this.dataWindow.IsOpen ^= true;
}
/// <summary>
@ -391,11 +376,24 @@ namespace Dalamud.Interface
/// </summary>
internal void OpenCredits()
{
var logoGraphic =
this.dalamud.InterfaceManager.LoadImage(
Path.Combine(this.dalamud.AssetDirectory.FullName, "UIRes", "logo.png"));
this.creditsWindow = new DalamudCreditsWindow(this.dalamud, logoGraphic, this.dalamud.Framework);
this.isImguiDrawCreditsWindow = true;
this.creditsWindow.IsOpen ^= true;
}
/// <summary>
/// Open the stats window.
/// </summary>
internal void OpenPluginStats()
{
this.pluginStatWindow.IsOpen ^= true;
}
public void Dispose()
{
this.windowSystem.RemoveAllWindows();
this.dalamud?.Dispose();
this.logWindow?.Dispose();
this.creditsWindow?.Dispose();
}
}
}

View file

@ -7,13 +7,14 @@ using System.Threading.Tasks;
using Dalamud.Configuration;
using Dalamud.Game.Command;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using Serilog;
using Serilog.Events;
namespace Dalamud.Interface
{
class DalamudLogWindow : IDisposable {
class DalamudLogWindow : Window, IDisposable {
private readonly CommandManager commandManager;
private readonly DalamudConfiguration configuration;
private bool autoScroll;
@ -24,12 +25,17 @@ namespace Dalamud.Interface
private string commandText = string.Empty;
public DalamudLogWindow(CommandManager commandManager, DalamudConfiguration configuration) {
public DalamudLogWindow(CommandManager commandManager, DalamudConfiguration configuration)
: base("Dalamud LOG")
{
this.commandManager = commandManager;
this.configuration = configuration;
this.autoScroll = configuration.LogAutoScroll;
this.openAtStartup = configuration.LogOpenAtStartup;
SerilogEventSink.Instance.OnLogLine += Serilog_OnLogLine;
this.Size = new Vector2(500, 400);
this.SizeCondition = ImGuiCond.FirstUseEver;
}
public void Dispose() {
@ -64,17 +70,7 @@ namespace Dalamud.Interface
}
}
public bool Draw() {
ImGui.SetNextWindowSize(new Vector2(500, 400), ImGuiCond.FirstUseEver);
var isOpen = true;
if (!ImGui.Begin("Dalamud LOG", ref isOpen, ImGuiWindowFlags.NoCollapse))
{
ImGui.End();
return false;
}
public override void Draw() {
// Options menu
if (ImGui.BeginPopup("Options"))
{
@ -130,9 +126,6 @@ namespace Dalamud.Interface
ImGui.SetScrollHereY(1.0f);
ImGui.EndChild();
ImGui.End();
return isOpen;
}
}
}

View file

@ -3,23 +3,23 @@ using System.Linq;
using System.Reflection;
using Dalamud.Game.Internal;
using Dalamud.Hooking;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using ImGuiNET;
namespace Dalamud.Interface {
internal class DalamudPluginStatWindow : IDisposable {
internal class DalamudPluginStatWindow : Window {
private readonly PluginManager pluginManager;
private bool showDalamudHooks;
public DalamudPluginStatWindow(PluginManager pluginManager) {
public DalamudPluginStatWindow(PluginManager pluginManager)
: base("Plugin Statistics###DalamudPluginStatWindow")
{
this.pluginManager = pluginManager;
}
public bool Draw() {
bool doDraw = true;
ImGui.PushID("DalamudPluginStatWindow");
ImGui.Begin("Plugin Statistics", ref doDraw);
public override void Draw() {
ImGui.BeginTabBar("Stat Tabs");
if (ImGui.BeginTabItem("Draw times")) {
@ -188,15 +188,6 @@ namespace Dalamud.Interface {
}
ImGui.EndTabBar();
ImGui.End();
ImGui.PopID();
return doDraw;
}
public void Dispose() {
}
}
}

View file

@ -8,16 +8,23 @@ using System.Windows.Forms.VisualStyles;
using CheapLoc;
using Dalamud.Configuration;
using Dalamud.Game.Text;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using Serilog;
namespace Dalamud.Interface
{
internal class DalamudSettingsWindow {
internal class DalamudSettingsWindow : Window {
private readonly Dalamud dalamud;
public DalamudSettingsWindow(Dalamud dalamud) {
public DalamudSettingsWindow(Dalamud dalamud)
: base(Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings2", ImGuiWindowFlags.NoCollapse)
{
this.dalamud = dalamud;
this.Size = new Vector2(740, 500);
this.SizeCondition = ImGuiCond.FirstUseEver;
this.dalamudMessagesChatType = this.dalamud.Configuration.GeneralChatType;
this.doCfTaskBarFlash = this.dalamud.Configuration.DutyFinderTaskbarFlash;
@ -35,8 +42,10 @@ namespace Dalamud.Interface
this.autoUpdatePlugins = this.dalamud.Configuration.AutoUpdatePlugins;
this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray();
try {
if (string.IsNullOrEmpty(this.dalamud.Configuration.LanguageOverride)) {
try
{
if (string.IsNullOrEmpty(this.dalamud.Configuration.LanguageOverride))
{
var currentUiLang = CultureInfo.CurrentUICulture;
if (Localization.ApplicableLangCodes.Any(x => currentUiLang.TwoLetterISOLanguageName == x))
@ -44,31 +53,62 @@ namespace Dalamud.Interface
else
this.langIndex = 0;
}
else {
else
{
this.langIndex = Array.IndexOf(this.languages, this.dalamud.Configuration.LanguageOverride);
}
} catch (Exception) {
}
catch (Exception)
{
this.langIndex = 0;
}
try {
try
{
List<string> locLanguagesList = new List<string>();
string locLanguage;
foreach (var language in this.languages) {
if (language != "ko") {
foreach (var language in this.languages)
{
if (language != "ko")
{
locLanguage = CultureInfo.GetCultureInfo(language).NativeName;
locLanguagesList.Add(char.ToUpper(locLanguage[0]) + locLanguage.Substring(1));
} else {
}
else
{
locLanguagesList.Add("Korean");
}
}
this.locLanguages = locLanguagesList.ToArray();
}
catch (Exception) {
catch (Exception)
{
this.locLanguages = this.languages; // Languages not localized, only codes.
}
}
public override void OnOpen()
{
base.OnOpen();
Log.Information("OnOpen start");
Log.Information("OnOpen end");
}
public override void OnClose()
{
base.OnClose();
Log.Information("OnClose start");
ImGui.GetIO().FontGlobalScale = this.dalamud.Configuration.GlobalUiScale;
this.thirdRepoList = this.dalamud.Configuration.ThirdRepoList.Select(x => x.Clone()).ToList();
Log.Information("OnClose end");
}
private string[] languages;
private string[] locLanguages;
private int langIndex;
@ -100,16 +140,7 @@ namespace Dalamud.Interface
#endregion
public bool Draw() {
ImGui.SetNextWindowSize(new Vector2(740, 500) * ImGui.GetIO().FontGlobalScale, ImGuiCond.FirstUseEver);
var isOpen = true;
if (!ImGui.Begin(Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings2", ref isOpen, ImGuiWindowFlags.NoCollapse)) {
ImGui.End();
return false;
}
public override void Draw() {
var windowSize = ImGui.GetWindowSize();
ImGui.BeginChild("scrolling", new Vector2(windowSize.X - 5 - (5 * ImGui.GetIO().FontGlobalScale), windowSize.Y - 35 - (35 * ImGui.GetIO().FontGlobalScale)), false, ImGuiWindowFlags.HorizontalScrollbar);
@ -299,22 +330,16 @@ namespace Dalamud.Interface
ImGui.EndChild();
if (!isOpen) {
ImGui.GetIO().FontGlobalScale = this.dalamud.Configuration.GlobalUiScale;
this.thirdRepoList = this.dalamud.Configuration.ThirdRepoList.Select(x => x.Clone()).ToList();
}
if (ImGui.Button(Loc.Localize("Save", "Save"))) {
Save();
}
ImGui.SameLine();
if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close"))) {
Save();
isOpen = false;
this.IsOpen = false;
}
ImGui.End();
return isOpen;
}
private void Save() {

View file

@ -1,5 +1,6 @@
using System.Numerics;
using ImGuiNET;
using Serilog;
namespace Dalamud.Interface
{
@ -32,6 +33,8 @@ namespace Dalamud.Interface
return mainViewportId;
}
public static Vector2 MainWindowPos { get; set; }
/// <summary>
/// Create a dummy scaled by the global Dalamud scale.
/// </summary>
@ -52,6 +55,7 @@ namespace Dalamud.Interface
internal static void NewFrame()
{
GlobalScale = ImGui.GetIO().FontGlobalScale;
MainWindowPos = ImGui.GetMainViewport().Pos;
}
}
}

View file

@ -7,6 +7,7 @@ using System.Threading.Tasks;
using CheapLoc;
using Dalamud.Interface;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using Serilog;
@ -15,7 +16,7 @@ namespace Dalamud.Plugin
/// <summary>
/// Class responsible for drawing the plugin installer.
/// </summary>
internal class PluginInstallerWindow
internal class PluginInstallerWindow : Window
{
private readonly Dalamud dalamud;
private readonly Vector4 colorGrey = new Vector4(0.70f, 0.70f, 0.70f, 1.00f);
@ -45,10 +46,16 @@ namespace Dalamud.Plugin
/// <param name="dalamud">The relevant Dalamud instance.</param>
/// <param name="gameVersion">The version of the game.</param>
public PluginInstallerWindow(Dalamud dalamud, string gameVersion)
: base(
Loc.Localize("InstallerHeader", "Plugin Installer") + (dalamud.Configuration.DoPluginTest ? " (TESTING)" : string.Empty) + "###XlPluginInstaller",
ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar)
{
this.dalamud = dalamud;
this.gameVersion = gameVersion;
this.Size = new Vector2(810, 520);
this.SizeCondition = ImGuiCond.Always;
if (this.dalamud.PluginRepository.State != PluginRepository.InitializationState.InProgress)
this.dalamud.PluginRepository.ReloadPluginMasterAsync();
}
@ -71,18 +78,8 @@ namespace Dalamud.Plugin
/// <summary>
/// Draw the plugin installer view ImGui.
/// </summary>
/// <returns>Whether or not the plugin installer window is open.</returns>
public bool Draw()
public override void Draw()
{
var windowOpen = true;
ImGui.SetNextWindowSize(new Vector2(810, 520) * ImGui.GetIO().FontGlobalScale);
ImGui.Begin(
Loc.Localize("InstallerHeader", "Plugin Installer") + (this.dalamud.Configuration.DoPluginTest ? " (TESTING)" : string.Empty) + "###XlPluginInstaller",
ref windowOpen,
ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar);
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - (5 * ImGui.GetIO().FontGlobalScale));
var descriptionText = Loc.Localize("InstallerHint", "This window allows you to install and remove in-game plugins.\nThey are made by third-party developers.");
ImGui.Text(descriptionText);
@ -224,7 +221,7 @@ namespace Dalamud.Plugin
ImGui.SameLine(ImGui.GetWindowWidth() - ImGui.CalcTextSize(closeText).X - (16 * ImGui.GetIO().FontGlobalScale));
if (ImGui.Button(closeText))
{
windowOpen = false;
this.IsOpen = false;
this.dalamud.Configuration.Save();
}
@ -269,10 +266,6 @@ namespace Dalamud.Plugin
ImGui.OpenPopup(Loc.Localize("InstallerError", "Installer failed"));
this.errorModalOnNextFrame = false;
}
ImGui.End();
return windowOpen;
}
private void RefetchPlugins()