This commit is contained in:
goaaats 2021-10-07 19:08:38 +02:00
commit bc558fb425
No known key found for this signature in database
GPG key ID: F18F057873895461
9 changed files with 130 additions and 73 deletions

View file

@ -213,8 +213,8 @@ namespace Dalamud.Game.Gui.FlyText
var tmpKind = kind;
var tmpVal1 = val1;
var tmpVal2 = val2;
var tmpText1 = MemoryHelper.ReadSeStringNullTerminated(text1);
var tmpText2 = MemoryHelper.ReadSeStringNullTerminated(text2);
var tmpText1 = text1 == IntPtr.Zero ? string.Empty : MemoryHelper.ReadSeStringNullTerminated(text1);
var tmpText2 = text2 == IntPtr.Zero ? string.Empty : MemoryHelper.ReadSeStringNullTerminated(text2);
var tmpColor = color;
var tmpIcon = icon;
var tmpYOffset = yOffset;

View file

@ -51,7 +51,7 @@ namespace Dalamud.Game.Gui.PartyFinder.Internal
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
private readonly byte[] header7; // all zero in every pf I've examined
private readonly uint lastPatchHotfixTimestamp; // last time the servers were restarted?
internal readonly uint LastPatchHotfixTimestamp; // last time the servers were restarted?
internal readonly ushort SecondsRemaining;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]

View file

@ -54,6 +54,7 @@ namespace Dalamud.Game.Gui.PartyFinder.Types
this.MinimumItemLevel = listing.MinimumItemLevel;
this.Parties = listing.NumParties;
this.SlotsAvailable = listing.NumSlots;
this.LastPatchHotfixTimestamp = listing.LastPatchHotfixTimestamp;
this.JobsPresent = listing.JobsPresent
.Select(id => new Lazy<ClassJob>(
() => id == 0
@ -143,6 +144,12 @@ namespace Dalamud.Game.Gui.PartyFinder.Types
/// </summary>
public byte SlotsAvailable { get; }
/// <summary>
/// Gets the time at which the server this listings is on last restarted for a patch/hotfix.
/// Probably.
/// </summary>
public uint LastPatchHotfixTimestamp { get; }
/// <summary>
/// Gets a list of player slots that the Party Finder is accepting.
/// </summary>

View file

@ -10,51 +10,96 @@ namespace Dalamud.Interface.Colors
/// <summary>
/// Gets red used in dalamud.
/// </summary>
public static Vector4 DalamudRed { get; internal set; } = new Vector4(1f, 0f, 0f, 1f);
public static Vector4 DalamudRed { get; internal set; } = new(1f, 0f, 0f, 1f);
/// <summary>
/// Gets grey used in dalamud.
/// </summary>
public static Vector4 DalamudGrey { get; internal set; } = new Vector4(0.7f, 0.7f, 0.7f, 1f);
public static Vector4 DalamudGrey { get; internal set; } = new(0.7f, 0.7f, 0.7f, 1f);
/// <summary>
/// Gets grey used in dalamud.
/// </summary>
public static Vector4 DalamudGrey2 { get; internal set; } = new Vector4(0.7f, 0.7f, 0.7f, 1f);
public static Vector4 DalamudGrey2 { get; internal set; } = new(0.7f, 0.7f, 0.7f, 1f);
/// <summary>
/// Gets grey used in dalamud.
/// </summary>
public static Vector4 DalamudGrey3 { get; internal set; } = new Vector4(0.5f, 0.5f, 0.5f, 1f);
public static Vector4 DalamudGrey3 { get; internal set; } = new(0.5f, 0.5f, 0.5f, 1f);
/// <summary>
/// Gets white used in dalamud.
/// </summary>
public static Vector4 DalamudWhite { get; internal set; } = new Vector4(1f, 1f, 1f, 1f);
public static Vector4 DalamudWhite { get; internal set; } = new(1f, 1f, 1f, 1f);
/// <summary>
/// Gets white used in dalamud.
/// </summary>
public static Vector4 DalamudWhite2 { get; internal set; } = new Vector4(0.878f, 0.878f, 0.878f, 1f);
public static Vector4 DalamudWhite2 { get; internal set; } = new(0.878f, 0.878f, 0.878f, 1f);
/// <summary>
/// Gets orange used in dalamud.
/// </summary>
public static Vector4 DalamudOrange { get; internal set; } = new Vector4(1f, 0.709f, 0f, 1f);
public static Vector4 DalamudOrange { get; internal set; } = new(1f, 0.709f, 0f, 1f);
/// <summary>
/// Gets yellow used in dalamud.
/// </summary>
public static Vector4 DalamudYellow { get; } = new(1f, 1f, .4f, 1f);
/// <summary>
/// Gets violet used in dalamud.
/// </summary>
public static Vector4 DalamudViolet { get; } = new(0.770f, 0.700f, 0.965f, 1.000f);
/// <summary>
/// Gets tank blue (UIColor37).
/// </summary>
public static Vector4 TankBlue { get; internal set; } = new Vector4(0f, 0.6f, 1f, 1f);
public static Vector4 TankBlue { get; internal set; } = new(0f, 0.6f, 1f, 1f);
/// <summary>
/// Gets healer green (UIColor504).
/// </summary>
public static Vector4 HealerGreen { get; internal set; } = new Vector4(0f, 0.8f, 0.1333333f, 1f);
public static Vector4 HealerGreen { get; internal set; } = new(0f, 0.8f, 0.1333333f, 1f);
/// <summary>
/// Gets dps red (UIColor545).
/// </summary>
public static Vector4 DPSRed { get; internal set; } = new Vector4(0.7058824f, 0f, 0f, 1f);
public static Vector4 DPSRed { get; internal set; } = new(0.7058824f, 0f, 0f, 1f);
/// <summary>
/// Gets parsed grey.
/// </summary>
public static Vector4 ParsedGrey { get; } = new(0.4f, 0.4f, 0.4f, 1f);
/// <summary>
/// Gets parsed green.
/// </summary>
public static Vector4 ParsedGreen { get; } = new(0.117f, 1f, 0f, 1f);
/// <summary>
/// Gets parsed blue.
/// </summary>
public static Vector4 ParsedBlue { get; } = new(0f, 0.439f, 1f, 1f);
/// <summary>
/// Gets parsed purple.
/// </summary>
public static Vector4 ParsedPurple { get; } = new(0.639f, 0.207f, 0.933f, 1f);
/// <summary>
/// Gets parsed orange.
/// </summary>
public static Vector4 ParsedOrange { get; } = new(1f, 0.501f, 0f, 1f);
/// <summary>
/// Gets parsed pink.
/// </summary>
public static Vector4 ParsedPink { get; } = new(0.886f, 0.407f, 0.658f, 1f);
/// <summary>
/// Gets parsed gold.
/// </summary>
public static Vector4 ParsedGold { get; } = new(0.898f, 0.8f, 0.501f, 1f);
}
}

View file

@ -149,10 +149,10 @@ namespace Dalamud.Interface.Internal
foreach (var tag in pluginCategoryTags)
{
// only tags from whitelist can be accepted
int matchIdx = Array.FindIndex(this.CategoryList, x => x.Tag.Equals(tag, StringComparison.InvariantCultureIgnoreCase));
var matchIdx = Array.FindIndex(this.CategoryList, x => x.Tag.Equals(tag, StringComparison.InvariantCultureIgnoreCase));
if (matchIdx >= 0)
{
int categoryId = this.CategoryList[matchIdx].CategoryId;
var categoryId = this.CategoryList[matchIdx].CategoryId;
if (categoryId >= FirstTagBasedCategoryId)
{
categoryList.Add(categoryId);
@ -202,7 +202,7 @@ namespace Dalamud.Interface.Internal
{
var groupInfo = this.groupList[this.currentGroupIdx];
bool includeAll = (this.currentCategoryIdx == 0) || (groupInfo.GroupKind != GroupKind.Available);
var includeAll = (this.currentCategoryIdx == 0) || (groupInfo.GroupKind != GroupKind.Available);
if (includeAll)
{
result.AddRange(plugins);
@ -215,7 +215,7 @@ namespace Dalamud.Interface.Internal
{
if (this.mapPluginCategories.TryGetValue(plugin, out var pluginCategoryIds))
{
int matchIdx = Array.IndexOf(pluginCategoryIds, selectedCategoryInfo.CategoryId);
var matchIdx = Array.IndexOf(pluginCategoryIds, selectedCategoryInfo.CategoryId);
if (matchIdx >= 0)
{
result.Add(plugin);

View file

@ -34,9 +34,18 @@ namespace Dalamud.Interface.Internal.Windows
("DalamudWhite", ImGuiColors.DalamudWhite),
("DalamudWhite2", ImGuiColors.DalamudWhite2),
("DalamudOrange", ImGuiColors.DalamudOrange),
("DalamudYellow", ImGuiColors.DalamudYellow),
("DalamudViolet", ImGuiColors.DalamudViolet),
("TankBlue", ImGuiColors.TankBlue),
("HealerGreen", ImGuiColors.HealerGreen),
("DPSRed", ImGuiColors.DPSRed),
("ParsedGrey", ImGuiColors.ParsedGrey),
("ParsedGreen", ImGuiColors.ParsedGreen),
("ParsedBlue", ImGuiColors.ParsedBlue),
("ParsedPurple", ImGuiColors.ParsedPurple),
("ParsedOrange", ImGuiColors.ParsedOrange),
("ParsedPink", ImGuiColors.ParsedPink),
("ParsedGold", ImGuiColors.ParsedGold),
}.OrderBy(colorDemo => colorDemo.Name).ToList();
}

View file

@ -195,7 +195,6 @@ namespace Dalamud.Interface.Internal.Windows
public override void Draw()
{
this.DrawHeader();
// this.DrawPluginTabBar();
this.DrawPluginCategories();
this.DrawFooter();
this.DrawErrorModal();
@ -470,6 +469,7 @@ namespace Dalamud.Interface.Internal.Windows
}
}
/*
private void DrawPluginTabBar()
{
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - (5 * ImGuiHelpers.GlobalScale));
@ -490,7 +490,9 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.PopStyleVar();
}
*/
/*
private void DrawPluginTab(string title, Action drawPluginList)
{
if (ImGui.BeginTabItem(title))
@ -511,6 +513,7 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.EndTabItem();
}
}
*/
private void DrawAvailablePluginList()
{
@ -522,30 +525,38 @@ namespace Dalamud.Interface.Internal.Windows
return;
}
var filteredList = pluginList
var filteredManifests = pluginList
.Where(rm => !this.IsManifestFiltered(rm))
.ToList();
if (filteredList.Count == 0)
if (filteredManifests.Count == 0)
{
ImGui.TextColored(ImGuiColors.DalamudGrey2, Locs.TabBody_SearchNoMatching);
return;
}
var i = 0;
foreach (var manifest in filteredList)
// reset opened list of collapsibles when switching between categories
if (this.categoryManager.IsContentDirty)
{
var (isInstalled, plugin) = this.IsManifestInstalled(manifest);
this.openPluginCollapsibles.Clear();
}
var categoryManifestsList = this.categoryManager.GetCurrentCategoryContent(filteredManifests);
var i = 0;
foreach (var manifest in categoryManifestsList)
{
var remoteManifest = manifest as RemotePluginManifest;
var (isInstalled, plugin) = this.IsManifestInstalled(remoteManifest);
ImGui.PushID($"{manifest.InternalName}{manifest.AssemblyVersion}");
if (isInstalled)
{
this.DrawInstalledPlugin(plugin, i++, true);
}
else
{
this.DrawAvailablePlugin(manifest, i++);
this.DrawAvailablePlugin(remoteManifest, i++);
}
ImGui.PopID();
@ -610,10 +621,10 @@ namespace Dalamud.Interface.Internal.Windows
private void DrawPluginCategories()
{
float useContentHeight = -40; // button height + spacing
float useMenuWidth = 180; // works fine as static value, table can be resized by user
var useContentHeight = -40f; // button height + spacing
var useMenuWidth = 180f; // works fine as static value, table can be resized by user
float useContentWidth = ImGui.GetContentRegionAvail().X;
var useContentWidth = ImGui.GetContentRegionAvail().X;
if (ImGui.BeginChild("InstallerCategories", new Vector2(useContentWidth, useContentHeight * ImGuiHelpers.GlobalScale)))
{
@ -628,12 +639,12 @@ namespace Dalamud.Interface.Internal.Windows
this.DrawPluginCategorySelectors();
ImGui.TableNextColumn();
if (ImGui.BeginChild($"ScrollingPlugins", new Vector2(useContentWidth, 0), false, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground))
if (ImGui.BeginChild("ScrollingPlugins", new Vector2(-1, 0), false, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground))
{
this.DrawPluginCategoryContent();
ImGui.EndChild();
}
ImGui.EndChild();
ImGui.EndTable();
}
@ -654,7 +665,7 @@ namespace Dalamud.Interface.Internal.Windows
}
}
for (int groupIdx = 0; groupIdx < this.categoryManager.GroupList.Length; groupIdx++)
for (var groupIdx = 0; groupIdx < this.categoryManager.GroupList.Length; groupIdx++)
{
var groupInfo = this.categoryManager.GroupList[groupIdx];
var canShowGroup = (groupInfo.GroupKind != PluginCategoryManager.GroupKind.DevTools) || this.hasDevPlugins;
@ -673,11 +684,11 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.Indent();
var categoryItemSize = new Vector2(ImGui.GetContentRegionAvail().X - (5 * ImGuiHelpers.GlobalScale), ImGui.GetTextLineHeight());
for (int categoryIdx = 0; categoryIdx < groupInfo.Categories.Count; categoryIdx++)
for (var categoryIdx = 0; categoryIdx < groupInfo.Categories.Count; categoryIdx++)
{
var categoryInfo = Array.Find(this.categoryManager.CategoryList, x => x.CategoryId == groupInfo.Categories[categoryIdx]);
bool hasSearchHighlight = this.categoryManager.IsCategoryHighlighted(categoryInfo.CategoryId);
var hasSearchHighlight = this.categoryManager.IsCategoryHighlighted(categoryInfo.CategoryId);
if (hasSearchHighlight)
{
ImGui.PushStyleColor(ImGuiCol.Text, colorSearchHighlight);
@ -712,6 +723,8 @@ namespace Dalamud.Interface.Internal.Windows
return;
}
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, ImGuiHelpers.ScaledVector2(1, 3));
var groupInfo = this.categoryManager.GroupList[this.categoryManager.CurrentGroupIdx];
if (groupInfo.GroupKind == PluginCategoryManager.GroupKind.DevTools)
{
@ -737,42 +750,10 @@ namespace Dalamud.Interface.Internal.Windows
}
else
{
var pluginList = this.pluginListAvailable;
if (pluginList.Count > 0)
{
// reset opened list of collapsibles when switching between categories
if (this.categoryManager.IsContentDirty)
{
this.openPluginCollapsibles.Clear();
}
var filteredManifests = pluginList.Where(rm => !this.IsManifestFiltered(rm) && !this.IsManifestInstalled(rm).IsInstalled);
var categoryManifestsList = this.categoryManager.GetCurrentCategoryContent(filteredManifests);
if (categoryManifestsList.Count > 0)
{
var i = 0;
foreach (var manifest in categoryManifestsList)
{
var rmManifest = manifest as RemotePluginManifest;
if (rmManifest != null)
{
ImGui.PushID($"{rmManifest.InternalName}{rmManifest.AssemblyVersion}");
this.DrawAvailablePlugin(rmManifest, i++);
ImGui.PopID();
}
}
}
else
{
ImGui.Text(Locs.TabBody_SearchNoMatching);
}
}
else
{
ImGui.Text(Locs.TabBody_SearchNoCompatible);
}
this.DrawAvailablePluginList();
}
ImGui.PopStyleVar();
}
private void DrawImageTester()
@ -2166,6 +2147,10 @@ namespace Dalamud.Interface.Internal.Windows
if (didAny)
{
Log.Verbose($"Plugin images for {manifest.InternalName} loaded from disk");
if (pluginImages.Contains(null))
pluginImages = pluginImages.Where(image => image != null).ToArray();
this.pluginImagesMap[manifest.InternalName] = pluginImages;
return;
@ -2218,6 +2203,10 @@ namespace Dalamud.Interface.Internal.Windows
if (didAny)
{
Log.Verbose($"Plugin images for {manifest.InternalName} downloaded");
if (pluginImages.Contains(null))
pluginImages = pluginImages.Where(image => image != null).ToArray();
this.pluginImagesMap[manifest.InternalName] = pluginImages;
return;

View file

@ -35,9 +35,10 @@ namespace Dalamud.Plugin
/// Set up the interface and populate all fields needed.
/// </summary>
/// <param name="pluginName">The internal name of the plugin.</param>
/// <param name="assemblyLocation">Location of the assembly.</param>
/// <param name="reason">The reason the plugin was loaded.</param>
/// <param name="isDev">A value indicating whether this is a dev plugin.</param>
internal DalamudPluginInterface(string pluginName, PluginLoadReason reason, bool isDev)
internal DalamudPluginInterface(string pluginName, FileInfo assemblyLocation, PluginLoadReason reason, bool isDev)
{
var configuration = Service<DalamudConfiguration>.Get();
var dataManager = Service<DataManager>.Get();
@ -46,6 +47,7 @@ namespace Dalamud.Plugin
this.UiBuilder = new UiBuilder(pluginName);
this.pluginName = pluginName;
this.AssemblyLocation = assemblyLocation;
this.configs = Service<PluginManager>.Get().PluginConfigs;
this.Reason = reason;
this.IsDev = isDev;
@ -113,6 +115,11 @@ namespace Dalamud.Plugin
/// </summary>
public DirectoryInfo DalamudAssetDirectory => Service<Dalamud>.Get().AssetDirectory;
/// <summary>
/// Gets the location of your plugin assembly.
/// </summary>
public FileInfo AssemblyLocation { get; }
/// <summary>
/// Gets the directory your plugin configurations are stored in.
/// </summary>
@ -165,11 +172,11 @@ namespace Dalamud.Plugin
#region IPC
/// <summary>
/// Gets an IPC publisher.
/// Gets an IPC provider.
/// </summary>
/// <typeparam name="TRet">The return type for funcs. Use object if this is unused.</typeparam>
/// <param name="name">The name of the IPC registration.</param>
/// <returns>An IPC publisher.</returns>
/// <returns>An IPC provider.</returns>
/// <exception cref="IpcTypeMismatchError">This is thrown when the requested types do not match the previously registered types are different.</exception>
public ICallGateProvider<TRet> GetIpcProvider<TRet>(string name)
=> new CallGatePubSub<TRet>(name);
@ -211,7 +218,7 @@ namespace Dalamud.Plugin
/// </summary>
/// <typeparam name="TRet">The return type for funcs. Use object if this is unused.</typeparam>
/// <param name="name">The name of the IPC registration.</param>
/// <returns>An IPC publisher.</returns>
/// <returns>An IPC subscriber.</returns>
public ICallGateSubscriber<TRet> GetIpcSubscriber<TRet>(string name)
=> new CallGatePubSub<TRet>(name);

View file

@ -309,7 +309,7 @@ namespace Dalamud.Plugin.Internal
// Update the location for the Location and CodeBase patches
PluginManager.PluginLocations[this.pluginType.Assembly.FullName] = new(this.DllFile);
this.DalamudInterface = new DalamudPluginInterface(this.pluginAssembly.GetName().Name!, reason, this.IsDev);
this.DalamudInterface = new DalamudPluginInterface(this.pluginAssembly.GetName().Name!, this.DllFile, reason, this.IsDev);
var ioc = Service<ServiceContainer>.Get();
this.instance = ioc.Create(this.pluginType, this.DalamudInterface) as IDalamudPlugin;