mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Merge pull request #306 from kalilistic/imgui-colors
feat: add imgui color helper
This commit is contained in:
commit
542bda4dfb
6 changed files with 166 additions and 17 deletions
61
Dalamud/Interface/Colors/ColorDemoWindow.cs
Normal file
61
Dalamud/Interface/Colors/ColorDemoWindow.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Colors
|
||||
{
|
||||
/// <summary>
|
||||
/// color Demo Window to view custom ImGui colors.
|
||||
/// </summary>
|
||||
internal class ColorDemoWindow : Window
|
||||
{
|
||||
private readonly List<KeyValuePair<string, Vector4>> colors;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ColorDemoWindow"/> class.
|
||||
/// </summary>
|
||||
public ColorDemoWindow()
|
||||
: base("Dalamud Colors Demo")
|
||||
{
|
||||
this.Size = new Vector2(600, 500);
|
||||
this.SizeCondition = ImGuiCond.FirstUseEver;
|
||||
this.colors = new List<KeyValuePair<string, Vector4>>
|
||||
{
|
||||
Demo("White", ImGuiColors.White),
|
||||
Demo("DalamudRed", ImGuiColors.DalamudRed),
|
||||
Demo("DalamudGrey", ImGuiColors.DalamudGrey),
|
||||
Demo("DalamudGrey2", ImGuiColors.DalamudGrey2),
|
||||
Demo("DalamudGrey3", ImGuiColors.DalamudGrey3),
|
||||
Demo("DalamudWhite", ImGuiColors.DalamudWhite),
|
||||
Demo("DalamudWhite2", ImGuiColors.DalamudWhite2),
|
||||
Demo("DalamudOrange", ImGuiColors.DalamudOrange),
|
||||
Demo("TankBlue", ImGuiColors.TankBlue),
|
||||
Demo("HealerGreen", ImGuiColors.HealerGreen),
|
||||
Demo("DPSRed", ImGuiColors.DPSRed),
|
||||
};
|
||||
this.colors = this.colors.OrderBy(colorDemo => colorDemo.Key).ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Draw()
|
||||
{
|
||||
ImGui.BeginChild("color_scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.AlwaysVerticalScrollbar | ImGuiWindowFlags.HorizontalScrollbar);
|
||||
ImGui.Text("This is a collection of UI colors you can use in your plugin.");
|
||||
ImGui.Separator();
|
||||
foreach (var color in this.colors)
|
||||
{
|
||||
ImGui.TextColored(color.Value, color.Key);
|
||||
}
|
||||
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
||||
private static KeyValuePair<string, Vector4> Demo(string name, Vector4 color)
|
||||
{
|
||||
return new KeyValuePair<string, Vector4>(name, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
65
Dalamud/Interface/Colors/ImGuiColors.cs
Normal file
65
Dalamud/Interface/Colors/ImGuiColors.cs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace Dalamud.Interface.Colors
|
||||
{
|
||||
/// <summary>
|
||||
/// Class containing frequently used colors for easier reference.
|
||||
/// </summary>
|
||||
public static class ImGuiColors
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets white color.
|
||||
/// </summary>
|
||||
public static Vector4 White { get; } = new Vector4(255, 255, 255, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets red used in dalamud.
|
||||
/// </summary>
|
||||
public static Vector4 DalamudRed { get; } = new Vector4(1f, 0f, 0f, 1f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets grey used in dalamud.
|
||||
/// </summary>
|
||||
public static Vector4 DalamudGrey { get; } = new Vector4(0.70f, 0.70f, 0.70f, 1.00f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets grey used in dalamud.
|
||||
/// </summary>
|
||||
public static Vector4 DalamudGrey2 { get; } = new Vector4(0.7f, 0.7f, 0.7f, 1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets grey used in dalamud.
|
||||
/// </summary>
|
||||
public static Vector4 DalamudGrey3 { get; } = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets white used in dalamud.
|
||||
/// </summary>
|
||||
public static Vector4 DalamudWhite { get; } = new Vector4(1f, 1f, 1f, 1f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets white used in dalamud.
|
||||
/// </summary>
|
||||
public static Vector4 DalamudWhite2 { get; } = new Vector4(0.878f, 0.878f, 0.878f, 1f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets orange used in dalamud.
|
||||
/// </summary>
|
||||
public static Vector4 DalamudOrange { get; } = new Vector4(1f, 0.709f, 0f, 1f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets tank blue (UIColor37).
|
||||
/// </summary>
|
||||
public static Vector4 TankBlue { get; } = new Vector4(0, 0.6f, 1, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets healer green (UIColor504).
|
||||
/// </summary>
|
||||
public static Vector4 HealerGreen { get; } = new Vector4(0, 0.8f, 0.1333333f, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets dps red (UIColor545).
|
||||
/// </summary>
|
||||
public static Vector4 DPSRed { get; } = new Vector4(0.7058824f, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ using System.Runtime.CompilerServices;
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
using CheapLoc;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin;
|
||||
|
|
@ -31,6 +32,7 @@ namespace Dalamud.Interface
|
|||
private readonly DalamudPluginStatWindow pluginStatWindow;
|
||||
private readonly DalamudChangelogWindow changelogWindow;
|
||||
private readonly ComponentDemoWindow componentDemoWindow;
|
||||
private readonly ColorDemoWindow colorDemoWindow;
|
||||
|
||||
private readonly WindowSystem windowSystem = new WindowSystem("DalamudCore");
|
||||
|
||||
|
|
@ -100,6 +102,12 @@ namespace Dalamud.Interface
|
|||
};
|
||||
this.windowSystem.AddWindow(this.componentDemoWindow);
|
||||
|
||||
this.colorDemoWindow = new ColorDemoWindow()
|
||||
{
|
||||
IsOpen = false,
|
||||
};
|
||||
this.windowSystem.AddWindow(this.colorDemoWindow);
|
||||
|
||||
Log.Information("[DUI] Windows added");
|
||||
|
||||
if (dalamud.Configuration.LogOpenAtStartup)
|
||||
|
|
@ -208,6 +216,11 @@ namespace Dalamud.Interface
|
|||
this.OpenComponentDemo();
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem("Open Colors Demo"))
|
||||
{
|
||||
this.OpenColorsDemo();
|
||||
}
|
||||
|
||||
ImGui.MenuItem("Draw ImGui demo", string.Empty, ref this.isImguiDrawDemoWindow);
|
||||
|
||||
ImGui.Separator();
|
||||
|
|
@ -420,6 +433,14 @@ namespace Dalamud.Interface
|
|||
this.componentDemoWindow.IsOpen = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open the colors test window.
|
||||
/// </summary>
|
||||
internal void OpenColorsDemo()
|
||||
{
|
||||
this.colorDemoWindow.IsOpen = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggle the Plugin Installer window.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
using Serilog;
|
||||
|
|
@ -46,13 +47,13 @@ namespace Dalamud.Interface
|
|||
{
|
||||
var color = logEvent.level switch
|
||||
{
|
||||
LogEventLevel.Error => new Vector4(1f, 0f, 0f, 1f),
|
||||
LogEventLevel.Verbose => new Vector4(1f, 1f, 1f, 1f),
|
||||
LogEventLevel.Debug => new Vector4(0.878f, 0.878f, 0.878f, 1f),
|
||||
LogEventLevel.Information => new Vector4(1f, 1f, 1f, 1f),
|
||||
LogEventLevel.Warning => new Vector4(1f, 0.709f, 0f, 1f),
|
||||
LogEventLevel.Fatal => new Vector4(1f, 0f, 0f, 1f),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
LogEventLevel.Error => ImGuiColors.DalamudRed,
|
||||
LogEventLevel.Verbose => ImGuiColors.DalamudWhite,
|
||||
LogEventLevel.Debug => ImGuiColors.DalamudWhite2,
|
||||
LogEventLevel.Information => ImGuiColors.DalamudWhite,
|
||||
LogEventLevel.Warning => ImGuiColors.DalamudOrange,
|
||||
LogEventLevel.Fatal => ImGuiColors.DalamudRed,
|
||||
_ => throw new ArgumentOutOfRangeException(),
|
||||
};
|
||||
|
||||
AddLog(logEvent.line, color);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Windows.Forms.VisualStyles;
|
|||
using CheapLoc;
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
using Serilog;
|
||||
|
|
@ -114,8 +115,8 @@ namespace Dalamud.Interface
|
|||
private string[] locLanguages;
|
||||
private int langIndex;
|
||||
|
||||
private Vector4 hintTextColor = new Vector4(0.70f, 0.70f, 0.70f, 1.00f);
|
||||
private Vector4 warnTextColor = new Vector4(1.0f, 0.0f, 0.0f, 1.00f);
|
||||
private Vector4 hintTextColor = ImGuiColors.DalamudGrey;
|
||||
private Vector4 warnTextColor = ImGuiColors.DalamudRed;
|
||||
|
||||
private XivChatType dalamudMessagesChatType;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||
|
||||
using CheapLoc;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
using Serilog;
|
||||
|
|
@ -19,7 +20,6 @@ namespace Dalamud.Plugin
|
|||
internal class PluginInstallerWindow : Window
|
||||
{
|
||||
private readonly Dalamud dalamud;
|
||||
private readonly Vector4 colorGrey = new Vector4(0.70f, 0.70f, 0.70f, 1.00f);
|
||||
|
||||
private string gameVersion;
|
||||
|
||||
|
|
@ -326,7 +326,7 @@ namespace Dalamud.Plugin
|
|||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 5);
|
||||
|
||||
if (statusText != null)
|
||||
ImGui.TextColored(this.colorGrey, statusText);
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, statusText);
|
||||
else
|
||||
this.DrawPluginList(installed ? this.pluginListInstalled : this.pluginListAvailable, installed);
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ namespace Dalamud.Plugin
|
|||
: ", download count unavailable";
|
||||
if (pluginDefinition.RepoNumber != 0)
|
||||
info += $", from custom plugin repository #{pluginDefinition.RepoNumber}";
|
||||
ImGui.TextColored(new Vector4(0.5f, 0.5f, 0.5f, 1.0f), info);
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey3, info);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(pluginDefinition.Description))
|
||||
ImGui.TextWrapped(pluginDefinition.Description);
|
||||
|
|
@ -526,13 +526,13 @@ namespace Dalamud.Plugin
|
|||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(new Vector4(0.5f, 0.5f, 0.5f, 1.0f), $" v{installedPlugin.Definition.AssemblyVersion}");
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey3, $" v{installedPlugin.Definition.AssemblyVersion}");
|
||||
|
||||
if (installedPlugin.IsRaw)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(
|
||||
new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
|
||||
ImGuiColors.DalamudRed,
|
||||
this.dalamud.PluginRepository.PluginMaster.Any(x => x.InternalName == installedPlugin.Definition.InternalName)
|
||||
? " This plugin is available in one of your repos, please remove it from the devPlugins folder."
|
||||
: " To disable this plugin, please remove it from the devPlugins folder.");
|
||||
|
|
@ -557,7 +557,7 @@ namespace Dalamud.Plugin
|
|||
if (installed)
|
||||
{
|
||||
ImGui.TextColored(
|
||||
this.colorGrey,
|
||||
ImGuiColors.DalamudGrey,
|
||||
Loc.Localize(
|
||||
"InstallerNoInstalled",
|
||||
"No plugins are currently installed. You can install them from the Available Plugins tab."));
|
||||
|
|
@ -565,7 +565,7 @@ namespace Dalamud.Plugin
|
|||
else
|
||||
{
|
||||
ImGui.TextColored(
|
||||
this.colorGrey,
|
||||
ImGuiColors.DalamudGrey,
|
||||
Loc.Localize(
|
||||
"InstallerNoCompatible",
|
||||
"No compatible plugins were found :( Please restart your game and try again."));
|
||||
|
|
@ -574,7 +574,7 @@ namespace Dalamud.Plugin
|
|||
else if (!didAnyWithSearch)
|
||||
{
|
||||
ImGui.TextColored(
|
||||
new Vector4(0.7f, 0.7f, 0.7f, 1.0f),
|
||||
ImGuiColors.DalamudGrey2,
|
||||
Loc.Localize("InstallNoMatching", "No plugins were found matching your search."));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue