Merge branch 'master' into agent-sigs

This commit is contained in:
pohky 2021-04-13 12:39:59 +02:00 committed by GitHub
commit ac536b033c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 193 additions and 5 deletions

View file

@ -112,6 +112,11 @@ namespace Dalamud.Configuration
/// </summary> /// </summary>
public bool IsDocking { get; set; } public bool IsDocking { get; set; }
/// <summary>
/// Gets or sets a value indicating whether viewports should always be disabled.
/// </summary>
public bool IsNeverViewport { get; set; }
/// <summary> /// <summary>
/// Load a configuration from the provided path. /// Load a configuration from the provided path.
/// </summary> /// </summary>

View file

@ -47,7 +47,7 @@ namespace Dalamud.Game.Internal.Gui {
ToggleUiHide = sig.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 0F B6 B9 ?? ?? ?? ?? B8 ?? ?? ?? ??"); ToggleUiHide = sig.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 0F B6 B9 ?? ?? ?? ?? B8 ?? ?? ?? ??");
GetBaseUIObject = sig.ScanText("E8 ?? ?? ?? ?? 41 B8 01 00 00 00 48 8D 15 ?? ?? ?? ?? 48 8B 48 20 E8 ?? ?? ?? ?? 48 8B CF"); GetBaseUIObject = sig.ScanText("E8 ?? ?? ?? ?? 41 B8 01 00 00 00 48 8D 15 ?? ?? ?? ?? 48 8B 48 20 E8 ?? ?? ?? ?? 48 8B CF");
GetUIObjectByName = sig.ScanText("E8 ?? ?? ?? ?? 48 8B CF 48 89 87 ?? ?? 00 00 E8 ?? ?? ?? ?? 41 B8 01 00 00 00"); GetUIObjectByName = sig.ScanText("E8 ?? ?? ?? ?? 48 8B CF 48 89 87 ?? ?? 00 00 E8 ?? ?? ?? ?? 41 B8 01 00 00 00");
GetUIModule = sig.ScanText("E8 ?? ?? ?? ?? 83 3B 01"); GetUIModule = sig.ScanText("E8 ?? ?? ?? ?? 48 8B C8 48 85 C0 75 2D");
var uiModuleVtableSig = sig.GetStaticAddressFromSig("48 8D 05 ?? ?? ?? ?? 4C 89 61 28"); var uiModuleVtableSig = sig.GetStaticAddressFromSig("48 8D 05 ?? ?? ?? ?? 4C 89 61 28");
this.GetAgentModule = Marshal.ReadIntPtr(uiModuleVtableSig, 34 * IntPtr.Size); this.GetAgentModule = Marshal.ReadIntPtr(uiModuleVtableSig, 34 * IntPtr.Size);

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using ImGuiNET; using ImGuiNET;
@ -13,6 +14,7 @@ namespace Dalamud.Interface.Components
internal class ComponentDemoWindow : Window internal class ComponentDemoWindow : Window
{ {
private readonly List<KeyValuePair<string, Action>> componentDemos; private readonly List<KeyValuePair<string, Action>> componentDemos;
private Vector4 defaultColor = ImGuiColors.DalamudOrange;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ComponentDemoWindow"/> class. /// Initializes a new instance of the <see cref="ComponentDemoWindow"/> class.
@ -27,6 +29,8 @@ namespace Dalamud.Interface.Components
Demo("Test", ImGuiComponents.Test), Demo("Test", ImGuiComponents.Test),
Demo("HelpMarker", HelpMarkerDemo), Demo("HelpMarker", HelpMarkerDemo),
Demo("IconButton", IconButtonDemo), Demo("IconButton", IconButtonDemo),
Demo("TextWithLabel", TextWithLabelDemo),
Demo("ColorPickerWithPalette", this.ColorPickerWithPaletteDemo),
}; };
} }
@ -72,9 +76,21 @@ namespace Dalamud.Interface.Components
ImGui.EndPopup(); ImGui.EndPopup();
} }
private static void TextWithLabelDemo()
{
ImGuiComponents.TextWithLabel("Label", "Hover to see more", "more");
}
private static KeyValuePair<string, Action> Demo(string name, Action func) private static KeyValuePair<string, Action> Demo(string name, Action func)
{ {
return new KeyValuePair<string, Action>(name, func); return new KeyValuePair<string, Action>(name, func);
} }
private void ColorPickerWithPaletteDemo()
{
ImGui.Text("Click on the color button to use the picker.");
ImGui.SameLine();
this.defaultColor = ImGuiComponents.ColorPickerWithPalette(1, "ColorPickerWithPalette Demo", this.defaultColor);
}
} }
} }

View file

@ -0,0 +1,70 @@
using System.Numerics;
using ImGuiNET;
namespace Dalamud.Interface.Components
{
/// <summary>
/// Class containing various methods providing ImGui components.
/// </summary>
public static partial class ImGuiComponents
{
/// <summary>
/// ColorPicker with palette.
/// </summary>
/// <param name="id">Id for the color picker.</param>
/// <param name="description">The description of the color picker.</param>
/// <param name="originalColor">The current color.</param>
/// <returns>Selected color.</returns>
public static Vector4 ColorPickerWithPalette(int id, string description, Vector4 originalColor)
{
const ImGuiColorEditFlags flags = ImGuiColorEditFlags.NoSidePreview | ImGuiColorEditFlags.NoSmallPreview;
return ColorPickerWithPalette(id, description, originalColor, flags);
}
/// <summary>
/// ColorPicker with palette with color picker options.
/// </summary>
/// <param name="id">Id for the color picker.</param>
/// <param name="description">The description of the color picker.</param>
/// <param name="originalColor">The current color.</param>
/// <param name="flags">Flags to customize color picker.</param>
/// <returns>Selected color.</returns>
public static Vector4 ColorPickerWithPalette(int id, string description, Vector4 originalColor, ImGuiColorEditFlags flags)
{
var existingColor = originalColor;
var selectedColor = originalColor;
var colorPalette = ImGuiHelpers.DefaultColorPalette(36);
if (ImGui.ColorButton($"{description}###ColorPickerButton{id}", originalColor))
{
ImGui.OpenPopup($"###ColorPickerPopup{id}");
}
if (ImGui.BeginPopup($"###ColorPickerPopup{id}"))
{
if (ImGui.ColorPicker4($"###ColorPicker{id}", ref existingColor, flags))
{
selectedColor = existingColor;
}
for (var i = 0; i < 4; i++)
{
ImGui.Spacing();
for (var j = i * 9; j < (i * 9) + 9; j++)
{
if (ImGui.ColorButton($"###ColorPickerSwatch{id}{i}{j}", colorPalette[j]))
{
selectedColor = colorPalette[j];
}
ImGui.SameLine();
}
}
ImGui.EndPopup();
}
return selectedColor;
}
}
}

View file

@ -0,0 +1,32 @@
using ImGuiNET;
namespace Dalamud.Interface.Components
{
/// <summary>
/// Class containing various methods providing ImGui components.
/// </summary>
public static partial class ImGuiComponents
{
/// <summary>
/// TextWithLabel component to show labeled text.
/// </summary>
/// <param name="label">The label for text.</param>
/// <param name="value">The text value.</param>
/// <param name="hint">The hint to show on hover.</param>
public static void TextWithLabel(
string label, string value, string hint = "")
{
ImGui.Text(label + ": ");
ImGui.SameLine();
if (string.IsNullOrEmpty(hint))
{
ImGui.Text(value);
}
else
{
ImGui.Text(value + "*");
if (ImGui.IsItemHovered()) ImGui.SetTooltip(hint);
}
}
}
}

View file

@ -34,7 +34,7 @@ namespace Dalamud.Interface
private string[] dataKinds = new[] private string[] dataKinds = new[]
{ {
"ServerOpCode", "Address", "Actor Table", "Font Test", "Party List", "Plugin IPC", "Condition", "ServerOpCode", "Address", "Actor Table", "Font Test", "Party List", "Plugin IPC", "Condition",
"Gauge", "Command", "Addon", "Addon Inspector", "StartInfo", "Target", "Toast", "Gauge", "Command", "Addon", "Addon Inspector", "StartInfo", "Target", "Toast", "ImGui"
}; };
private bool drawActors = false; private bool drawActors = false;
@ -117,7 +117,7 @@ namespace Dalamud.Interface
var copy = ImGui.Button("Copy all"); var copy = ImGui.Button("Copy all");
ImGui.SameLine(); ImGui.SameLine();
ImGui.Combo("Data kind", ref this.currentKind, dataKinds, dataKinds.Length); ImGui.Combo("Data kind", ref this.currentKind, this.dataKinds, this.dataKinds.Length);
ImGui.Checkbox("Resolve GameData", ref this.resolveGameData); ImGui.Checkbox("Resolve GameData", ref this.resolveGameData);
@ -339,6 +339,12 @@ namespace Dalamud.Interface
this.dalamud.Framework.Gui.Toast.ShowError(this.inputTextToast); this.dalamud.Framework.Gui.Toast.ShowError(this.inputTextToast);
} }
break;
// ImGui
case 14:
ImGui.Text("Monitor count: " + ImGui.GetPlatformIO().Monitors.Size);
break; break;
} }
} }

View file

@ -309,7 +309,7 @@ namespace Dalamud.Interface
{ {
if (ImGui.MenuItem("Export localizable")) if (ImGui.MenuItem("Export localizable"))
{ {
Loc.ExportLocalizable(); this.dalamud.LocalizationManager.ExportLocalizable();
} }
if (ImGui.BeginMenu("Load language...")) if (ImGui.BeginMenu("Load language..."))

View file

@ -37,6 +37,7 @@ namespace Dalamud.Interface
this.doToggleUiHideDuringGpose = this.dalamud.Configuration.ToggleUiHideDuringGpose; this.doToggleUiHideDuringGpose = this.dalamud.Configuration.ToggleUiHideDuringGpose;
this.doDocking = this.dalamud.Configuration.IsDocking; this.doDocking = this.dalamud.Configuration.IsDocking;
this.doViewport = !this.dalamud.Configuration.IsNeverViewport;
this.doPluginTest = this.dalamud.Configuration.DoPluginTest; this.doPluginTest = this.dalamud.Configuration.DoPluginTest;
this.thirdRepoList = this.dalamud.Configuration.ThirdRepoList.Select(x => x.Clone()).ToList(); this.thirdRepoList = this.dalamud.Configuration.ThirdRepoList.Select(x => x.Clone()).ToList();
@ -130,6 +131,7 @@ namespace Dalamud.Interface
private bool doToggleUiHideDuringCutscenes; private bool doToggleUiHideDuringCutscenes;
private bool doToggleUiHideDuringGpose; private bool doToggleUiHideDuringGpose;
private bool doDocking; private bool doDocking;
private bool doViewport;
private List<ThirdRepoSetting> thirdRepoList; private List<ThirdRepoSetting> thirdRepoList;
private bool printPluginsWelcomeMsg; private bool printPluginsWelcomeMsg;
@ -215,6 +217,9 @@ namespace Dalamud.Interface
ImGui.Dummy(new Vector2(10f, 16f) * ImGui.GetIO().FontGlobalScale); ImGui.Dummy(new Vector2(10f, 16f) * ImGui.GetIO().FontGlobalScale);
ImGui.Checkbox(Loc.Localize("DalamudSettingToggleViewports", "Enable multi-monitor windows"), ref this.doViewport);
ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleViewportsHint", "This will allow you move plugin windows onto other monitors.\nWill only work in Borderless Window or Windowed mode."));
ImGui.Checkbox(Loc.Localize("DalamudSettingToggleDocking", "Enable window docking"), ref this.doDocking); ImGui.Checkbox(Loc.Localize("DalamudSettingToggleDocking", "Enable window docking"), ref this.doDocking);
ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleDockingHint", "This will allow you to fuse and tab plugin windows.")); ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingToggleDockingHint", "This will allow you to fuse and tab plugin windows."));
@ -369,6 +374,9 @@ namespace Dalamud.Interface
this.dalamud.Configuration.IsDocking = this.doDocking; this.dalamud.Configuration.IsDocking = this.doDocking;
// This is applied every frame in InterfaceManager::CheckViewportState()
this.dalamud.Configuration.IsNeverViewport = !this.doViewport;
// Apply docking flag // Apply docking flag
if (!this.dalamud.Configuration.IsDocking) if (!this.dalamud.Configuration.IsDocking)
{ {

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using ImGuiNET; using ImGuiNET;
@ -57,6 +58,23 @@ namespace Dalamud.Interface
string name, Vector2 position, ImGuiCond condition = ImGuiCond.None) string name, Vector2 position, ImGuiCond condition = ImGuiCond.None)
=> ImGui.SetWindowPos(position + MainViewport.Pos, condition); => ImGui.SetWindowPos(position + MainViewport.Pos, condition);
/// <summary>
/// Creates default color palette for use with color pickers.
/// </summary>
/// <param name="swatchCount">The total number of swatches to use.</param>
/// <returns>Default color palette.</returns>
public static List<Vector4> DefaultColorPalette(int swatchCount = 32)
{
var colorPalette = new List<Vector4>();
for (var i = 0; i < swatchCount; i++)
{
ImGui.ColorConvertHSVtoRGB(i / 31.0f, 0.7f, 0.8f, out var r, out var g, out var b);
colorPalette.Add(new Vector4(r, g, b, 1.0f));
}
return colorPalette;
}
/// <summary> /// <summary>
/// Get data needed for each new frame. /// Get data needed for each new frame.
/// </summary> /// </summary>

View file

@ -282,11 +282,25 @@ namespace Dalamud.Interface
// Process information needed by ImGuiHelpers each frame. // Process information needed by ImGuiHelpers each frame.
ImGuiHelpers.NewFrame(); ImGuiHelpers.NewFrame();
// Check if we can still enable viewports without any issues.
this.CheckViewportState();
this.scene.Render(); this.scene.Render();
return this.presentHook.Original(swapChain, syncInterval, presentFlags); return this.presentHook.Original(swapChain, syncInterval, presentFlags);
} }
private void CheckViewportState()
{
if (this.dalamud.Configuration.IsNeverViewport || this.scene.SwapChain.IsFullScreen || ImGui.GetPlatformIO().Monitors.Size == 1)
{
ImGui.GetIO().ConfigFlags &= ~ImGuiConfigFlags.ViewportsEnable;
return;
}
ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.ViewportsEnable;
}
public static ImFontPtr DefaultFont { get; private set; } public static ImFontPtr DefaultFont { get; private set; }
public static ImFontPtr IconFont { get; private set; } public static ImFontPtr IconFont { get; private set; }

View file

@ -29,6 +29,8 @@ namespace Dalamud.Plugin
private readonly Type interfaceType = typeof(IDalamudPlugin); private readonly Type interfaceType = typeof(IDalamudPlugin);
private readonly List<BannedPlugin> bannedPlugins;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PluginManager"/> class. /// Initializes a new instance of the <see cref="PluginManager"/> class.
/// </summary> /// </summary>
@ -48,6 +50,9 @@ namespace Dalamud.Plugin
this.pluginConfigs = new PluginConfigurations(Path.Combine(Path.GetDirectoryName(dalamud.StartInfo.ConfigurationPath), "pluginConfigs")); this.pluginConfigs = new PluginConfigurations(Path.Combine(Path.GetDirectoryName(dalamud.StartInfo.ConfigurationPath), "pluginConfigs"));
this.bannedPlugins = JsonConvert.DeserializeObject<List<BannedPlugin>>(
File.ReadAllText(Path.Combine(this.dalamud.StartInfo.AssetDirectory, "UIRes", "bannedplugin.json")));
// Try to load missing assemblies from the local directory of the requesting assembly // Try to load missing assemblies from the local directory of the requesting assembly
// This would usually be implicit when using Assembly.Load(), but Assembly.LoadFile() doesn't do it... // This would usually be implicit when using Assembly.Load(), but Assembly.LoadFile() doesn't do it...
// This handler should only be invoked on things that fail regular lookups, but it *is* global to this appdomain // This handler should only be invoked on things that fail regular lookups, but it *is* global to this appdomain
@ -317,6 +322,13 @@ namespace Dalamud.Plugin
DalamudApiLevel = DalamudApiLevel, DalamudApiLevel = DalamudApiLevel,
}; };
if (this.bannedPlugins.Any(x => x.Name == pluginDef.InternalName &&
x.AssemblyVersion == pluginDef.AssemblyVersion))
{
Log.Error($"[PLUGINM] Banned plugin {pluginDef.InternalName} with {pluginDef.AssemblyVersion}");
return false;
}
if (pluginDef.InternalName == "PingPlugin" && pluginDef.AssemblyVersion == "1.11.0.0") if (pluginDef.InternalName == "PingPlugin" && pluginDef.AssemblyVersion == "1.11.0.0")
{ {
Log.Error("Banned PingPlugin"); Log.Error("Banned PingPlugin");
@ -366,5 +378,12 @@ namespace Dalamud.Plugin
this.UnloadPlugins(); this.UnloadPlugins();
this.LoadPlugins(); this.LoadPlugins();
} }
private class BannedPlugin
{
public string Name { get; set; }
public string AssemblyVersion { get; set; }
}
} }
} }

@ -1 +1 @@
Subproject commit 020033197d6802f64c794d8a44029bd75662ad33 Subproject commit b836ec8ecb5a2292bca03f4746da33ae0e144190