This commit is contained in:
Liza 2024-03-20 19:10:35 +01:00
parent 865a608031
commit 3792244261
Signed by: liza
GPG Key ID: 7199F8D727D55F67
8 changed files with 1098 additions and 70 deletions

1017
.editorconfig Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,8 @@ public static class DataManagerExtensions
public static SeString? GetSeString<T>(this IDataManager dataManager, string key) public static SeString? GetSeString<T>(this IDataManager dataManager, string key)
where T : QuestDialogueText where T : QuestDialogueText
{ {
ArgumentNullException.ThrowIfNull(dataManager);
return dataManager.GetExcelSheet<T>()? return dataManager.GetExcelSheet<T>()?
.SingleOrDefault(x => x.Key == key) .SingleOrDefault(x => x.Key == key)
?.Value; ?.Value;
@ -49,6 +51,9 @@ public static class DataManagerExtensions
public static SeString? GetSeString<T>(this IDataManager dataManager, uint rowId, Func<T, SeString?> mapper) public static SeString? GetSeString<T>(this IDataManager dataManager, uint rowId, Func<T, SeString?> mapper)
where T : ExcelRow where T : ExcelRow
{ {
ArgumentNullException.ThrowIfNull(dataManager);
ArgumentNullException.ThrowIfNull(mapper);
var row = dataManager.GetExcelSheet<T>()?.GetRow(rowId); var row = dataManager.GetExcelSheet<T>()?.GetRow(rowId);
if (row == null) if (row == null)
return null; return null;
@ -56,7 +61,8 @@ public static class DataManagerExtensions
return mapper(row); return mapper(row);
} }
public static string? GetString<T>(this IDataManager dataManager, uint rowId, Func<T, SeString?> mapper, IPluginLog? pluginLog = null) public static string? GetString<T>(this IDataManager dataManager, uint rowId, Func<T, SeString?> mapper,
IPluginLog? pluginLog = null)
where T : ExcelRow where T : ExcelRow
{ {
string? text = GetSeString(dataManager, rowId, mapper)?.ToString(); string? text = GetSeString(dataManager, rowId, mapper)?.ToString();
@ -65,7 +71,8 @@ public static class DataManagerExtensions
return text; return text;
} }
public static Regex? GetRegex<T>(this IDataManager dataManager, uint rowId, Func<T, SeString?> mapper, IPluginLog? pluginLog = null) public static Regex? GetRegex<T>(this IDataManager dataManager, uint rowId, Func<T, SeString?> mapper,
IPluginLog? pluginLog = null)
where T : ExcelRow where T : ExcelRow
{ {
SeString? text = GetSeString(dataManager, rowId, mapper); SeString? text = GetSeString(dataManager, rowId, mapper);
@ -83,9 +90,11 @@ public static class DataManagerExtensions
return new Regex(regex); return new Regex(regex);
} }
public static Regex? GetRegex<T>(this T excelRow, Func<T, SeString?> mapper, IPluginLog? pluginLog) public static Regex? GetRegex<T>(this T excelRow, Func<T, SeString?> mapper, IPluginLog? pluginLog)
where T : ExcelRow where T : ExcelRow
{ {
ArgumentNullException.ThrowIfNull(excelRow);
ArgumentNullException.ThrowIfNull(mapper);
SeString? text = mapper(excelRow); SeString? text = mapper(excelRow);
if (text == null) if (text == null)
return null; return null;

View File

@ -8,6 +8,7 @@ namespace LLib.GameUI;
public static class LAddon public static class LAddon
{ {
private const int UnitListCount = 18; private const int UnitListCount = 18;
public static unsafe AtkUnitBase* GetAddonById(uint id) public static unsafe AtkUnitBase* GetAddonById(uint id)
{ {
var unitManagers = &AtkStage.GetSingleton()->RaptureAtkUnitManager->AtkUnitManager.DepthLayerOneList; var unitManagers = &AtkStage.GetSingleton()->RaptureAtkUnitManager->AtkUnitManager.DepthLayerOneList;
@ -30,6 +31,9 @@ public static class LAddon
public static unsafe bool TryGetAddonByName<T>(this IGameGui gameGui, string addonName, out T* addonPtr) public static unsafe bool TryGetAddonByName<T>(this IGameGui gameGui, string addonName, out T* addonPtr)
where T : unmanaged where T : unmanaged
{ {
ArgumentNullException.ThrowIfNull(gameGui);
ArgumentException.ThrowIfNullOrEmpty(addonName);
var a = gameGui.GetAddonByName(addonName); var a = gameGui.GetAddonByName(addonName);
if (a != IntPtr.Zero) if (a != IntPtr.Zero)
{ {

61
ImGui/LWindow.cs Normal file
View File

@ -0,0 +1,61 @@
using System.Diagnostics;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using IG = ImGuiNET.ImGui;
namespace LLib.ImGui;
public abstract class LWindow : Window
{
protected bool ClickedHeaderLastFrame { get; private set; }
protected bool ClickedHeaderCurrentFrame { get; private set; }
protected LWindow(string name, ImGuiWindowFlags flags = ImGuiWindowFlags.None, bool forceMainWindow = false)
: base(name, flags, forceMainWindow)
{
TitleBarButtons.Add(new TitleBarButton
{
Icon = FontAwesomeIcon.Heart,
ShowTooltip = () =>
{
IG.BeginTooltip();
IG.Text("Go to patreon.com/lizac");
IG.EndTooltip();
},
Priority = int.MinValue,
IconOffset = new Vector2(1.5f, 1),
Click = _ =>
{
// when you make a window click-through, `Click` is triggered on each individual frame the mouse button is held down.
ClickedHeaderCurrentFrame = true;
if (ClickedHeaderLastFrame)
return;
try
{
Process.Start(new ProcessStartInfo
{
FileName = "https://www.patreon.com/lizac",
UseShellExecute = true,
Verb = string.Empty,
});
}
catch
{
// not sure what to do anyway
}
},
AvailableClickthrough = true,
});
}
public override void PreDraw()
{
base.PreDraw();
ClickedHeaderLastFrame = ClickedHeaderCurrentFrame;
ClickedHeaderCurrentFrame = false;
}
}

View File

@ -1,63 +0,0 @@
using System.Diagnostics;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Windowing;
using ImGuiNET;
namespace LLib;
public static class LImGui
{
public abstract class LWindow : Window
{
protected bool ClickedHeaderLastFrame;
protected bool ClickedHeaderCurrentFrame;
protected LWindow(string name, ImGuiWindowFlags flags = ImGuiWindowFlags.None, bool forceMainWindow = false)
: base(name, flags, forceMainWindow)
{
TitleBarButtons.Add(new TitleBarButton
{
Icon = FontAwesomeIcon.Heart,
ShowTooltip = () =>
{
ImGui.BeginTooltip();
ImGui.Text("Go to patreon.com/lizac");
ImGui.EndTooltip();
},
Priority = int.MinValue,
IconOffset = new Vector2(1.5f, 1),
Click = _ =>
{
// when you make a window click-through, `Click` is triggered on each individual frame the mouse button is held down.
ClickedHeaderCurrentFrame = true;
if (ClickedHeaderLastFrame)
return;
try
{
Process.Start(new ProcessStartInfo
{
FileName = "https://www.patreon.com/lizac",
UseShellExecute = true,
Verb = string.Empty,
});
}
catch
{
// not sure what to do anyway
}
},
AvailableClickthrough = true,
});
}
public override void PreDraw()
{
base.PreDraw();
ClickedHeaderLastFrame = ClickedHeaderCurrentFrame;
ClickedHeaderCurrentFrame = false;
}
}
}

View File

@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<Version>1.0</Version> <Version>1.0</Version>
<LangVersion>11.0</LangVersion> <LangVersion>12</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>

View File

@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "7.0.0", "version": "8.0.0",
"rollForward": "latestMinor", "rollForward": "latestMinor",
"allowPrerelease": false "allowPrerelease": false
} }

View File

@ -1,6 +1,6 @@
{ {
"version": 1, "version": 1,
"dependencies": { "dependencies": {
"net7.0-windows7.0": {} "net8.0-windows7.0": {}
} }
} }