Plugin API v93: web panel table fields and SDK wrappers (number provisional)
Four appended table slots (WebPanelOpen/Navigate/Close/GetState), native structs and code enums in engine and SDK, a WebPanelApi stub answering Unavailable (CoreCLR flavour only; AOT leaves the slots zero), SDK OpenWebPanel/NavigateWebPanel/CloseWebPanel/GetWebPanelState with HasWebPanel gated on Version >= 93, parity tests in PluginManifestTests. Also adds the missing System usings to the Task 1 WebPanel files, which did not compile in the engine project (no ImplicitUsings). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0d5b9700db
commit
28d480c90a
11 changed files with 437 additions and 3 deletions
|
|
@ -1069,6 +1069,74 @@ internal struct RynthCoreAPI
|
|||
/// reading, 0 without (never read; *ratio = -1, *ageMs = 0xFFFFFFFF). Either pointer may be null.
|
||||
/// Read-only, any thread, no game calls. Requires API v93+.</summary>
|
||||
public IntPtr GetMonsterHealthFn;
|
||||
|
||||
//── v93: a WebView2 web panel over the game window (WebPanel\WebPanelApi.cs) ──
|
||||
// No call blocks its caller (AC's main thread, the plugin pump and ImGui draws all call these).
|
||||
|
||||
/// <summary>v93: <c>int WebPanelOpen(WebPanelOpenNative* open)</c>: opens (or replaces) the web panel.
|
||||
/// Returns a handle > 0, or BadArgs / UrlNotAllowed / NoGameWindow / Unavailable / ShuttingDown
|
||||
/// (WebPanelCode). Requires API v93+ (provisional number).</summary>
|
||||
public IntPtr WebPanelOpenFn;
|
||||
/// <summary>v93: <c>int WebPanelNavigate(int handle, byte* url)</c>: 1 queued; -2 off the allowlist
|
||||
/// (opened in the system browser when it is browser-safe); -6 stale handle.</summary>
|
||||
public IntPtr WebPanelNavigateFn;
|
||||
/// <summary>v93: <c>int WebPanelClose(int handle)</c>: 1 queued, 0 already closed, -6 stale handle.</summary>
|
||||
public IntPtr WebPanelCloseFn;
|
||||
/// <summary>v93: <c>int WebPanelGetState(int handle, WebPanelStateNative* state)</c>: the WebPanelStatusCode
|
||||
/// (a handle that is not the live one reads 6 Superseded), -1 bad args.</summary>
|
||||
public IntPtr WebPanelGetStateFn;
|
||||
}
|
||||
|
||||
/// <summary>v93 WebPanelOpen argument (Pack 4; 48 bytes on x86). Mirrors RynthCore.PluginSdk/WebPanelTypes.cs.</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
internal unsafe struct WebPanelOpenNative
|
||||
{
|
||||
/// <summary>sizeof the caller's struct; the engine accepts Size >= OffsetOf(Reserved) (32 on x86).</summary>
|
||||
public uint Size;
|
||||
/// <summary>WebPanelFlags; unknown bits ignored.</summary>
|
||||
public uint Flags;
|
||||
/// <summary>UTF-8 NUL-terminated, at most 4096 bytes, must pass the URL policy's IsAllowed.</summary>
|
||||
public byte* Url;
|
||||
/// <summary>UTF-8, '\n'-separated allowlist (WebPanelUrlPolicy.TryParseAllowlist).</summary>
|
||||
public byte* Allowlist;
|
||||
/// <summary>UTF-8, may be null; at most 256 bytes.</summary>
|
||||
public byte* ProfileKey;
|
||||
/// <summary>UTF-8, may be null; at most 128 bytes.</summary>
|
||||
public byte* Title;
|
||||
/// <summary>0 = 88, else 30..100 (only when no remembered layout).</summary>
|
||||
public int WidthPercent;
|
||||
public int HeightPercent;
|
||||
public fixed uint Reserved[4];
|
||||
}
|
||||
|
||||
/// <summary>v93 WebPanelGetState result (Pack 4; 48 bytes). Mirrors RynthCore.PluginSdk/WebPanelTypes.cs.</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
internal unsafe struct WebPanelStateNative
|
||||
{
|
||||
public uint Size;
|
||||
public int Handle;
|
||||
/// <summary>WebPanelStatusCode.</summary>
|
||||
public int Status;
|
||||
/// <summary>1 Visible, 2 Focused, 4 OpenedInBrowser.</summary>
|
||||
public uint Flags;
|
||||
/// <summary>0 or a negative WebPanelCode (RuntimeMissing / CreateFailed / ProcessFailed).</summary>
|
||||
public int Error;
|
||||
public int LastHttpStatus;
|
||||
public uint NavigationCount;
|
||||
public fixed uint Reserved[5];
|
||||
}
|
||||
|
||||
/// <summary>v93 return codes of the web panel calls. Append only.</summary>
|
||||
internal enum WebPanelCode
|
||||
{
|
||||
Queued = 1, AlreadyClosed = 0, BadArgs = -1, UrlNotAllowed = -2, NoGameWindow = -3,
|
||||
Unavailable = -4, ShuttingDown = -5, StaleHandle = -6, RuntimeMissing = -7, CreateFailed = -8, ProcessFailed = -9,
|
||||
}
|
||||
|
||||
/// <summary>v93 WebPanelStateNative.Status values. Append only.</summary>
|
||||
internal enum WebPanelStatusCode
|
||||
{
|
||||
None = 0, Starting = 1, Loading = 2, Ready = 3, Closed = 4, Failed = 5, Superseded = 6,
|
||||
}
|
||||
|
||||
/// <summary>v89 GetUiColor tokens. Append only: plugins compiled against these numbers keep them.</summary>
|
||||
|
|
@ -1930,6 +1998,18 @@ internal unsafe delegate int GetAmbientLightCallbackDelegate(uint* client, uint*
|
|||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate int GetMonsterHealthCallbackDelegate(uint id, float* ratio, uint* ageMs);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate int WebPanelOpenCallbackDelegate(WebPanelOpenNative* open);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate int WebPanelNavigateCallbackDelegate(int handle, byte* url);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate int WebPanelCloseCallbackDelegate(int handle);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate int WebPanelGetStateCallbackDelegate(int handle, WebPanelStateNative* state);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate uint VendorBuyCallbackDelegate(uint vendorId, VendorTradeEntryNative* entries, int count);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,5 +47,8 @@ internal static class PluginContractVersion
|
|||
// any thread (feature/hud-health-for-plugins, 2026-11-07). Note: feature/reload-state,
|
||||
// feature/engine-events and the branches built on them (unmerged) also use 93 and 94; whichever
|
||||
// merges second renumbers.
|
||||
// v93: WebPanelOpen, WebPanelNavigate, WebPanelClose and WebPanelGetState: a WebView2 web panel over the
|
||||
// game window (WebPanel\WebPanelApi.cs; DreamWeave's in-game market and tools). The number is
|
||||
// PROVISIONAL: upstream may take 93 first, in which case this renumbers on merge.
|
||||
public const uint Current = 93;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,6 +304,12 @@ internal static partial class PluginManager
|
|||
private static SetAmbientLightFloorCallbackDelegate? _setAmbientLightFloorCallback; // v91
|
||||
private static GetAmbientLightCallbackDelegate? _getAmbientLightCallback; // v91
|
||||
private static GetMonsterHealthCallbackDelegate? _getMonsterHealthCallback; // v93
|
||||
#if ENGINE_CORECLR
|
||||
private static WebPanelOpenCallbackDelegate? _webPanelOpenCallback; // v93
|
||||
private static WebPanelNavigateCallbackDelegate? _webPanelNavigateCallback; // v93
|
||||
private static WebPanelCloseCallbackDelegate? _webPanelCloseCallback; // v93
|
||||
private static WebPanelGetStateCallbackDelegate? _webPanelGetStateCallback; // v93
|
||||
#endif
|
||||
private static ForceResetBusyCountCallbackDelegate? _forceResetBusyCountCallback;
|
||||
private static GetObjectSpellIdsCallbackDelegate? _getObjectSpellIdsCallback;
|
||||
private static GetObjectSkillLevelCallbackDelegate? _getObjectSkillBuffedCallback;
|
||||
|
|
@ -3254,6 +3260,13 @@ internal static partial class PluginManager
|
|||
_setAmbientLightFloorCallback ??= AmbientLight.SetFloor; // v91
|
||||
unsafe { _getAmbientLightCallback ??= AmbientLight.Get; }
|
||||
unsafe { _getMonsterHealthCallback ??= GetMonsterHealthAction; } // v93
|
||||
#if ENGINE_CORECLR
|
||||
// v93: the AOT engine leaves these slots zero, so HasWebPanel is false there.
|
||||
unsafe { _webPanelOpenCallback ??= WebPanel.WebPanelApi.Open; }
|
||||
unsafe { _webPanelNavigateCallback ??= WebPanel.WebPanelApi.Navigate; }
|
||||
_webPanelCloseCallback ??= WebPanel.WebPanelApi.Close;
|
||||
unsafe { _webPanelGetStateCallback ??= WebPanel.WebPanelApi.GetState; }
|
||||
#endif
|
||||
|
||||
_api.Version = PluginContractVersion.Current;
|
||||
_api.LogFn = Marshal.GetFunctionPointerForDelegate(_logCallback);
|
||||
|
|
@ -3427,6 +3440,12 @@ internal static partial class PluginManager
|
|||
_api.SetAmbientLightFloorFn = Marshal.GetFunctionPointerForDelegate(_setAmbientLightFloorCallback);
|
||||
_api.GetAmbientLightFn = Marshal.GetFunctionPointerForDelegate(_getAmbientLightCallback);
|
||||
_api.GetMonsterHealthFn = Marshal.GetFunctionPointerForDelegate(_getMonsterHealthCallback);
|
||||
#if ENGINE_CORECLR
|
||||
_api.WebPanelOpenFn = Marshal.GetFunctionPointerForDelegate(_webPanelOpenCallback!);
|
||||
_api.WebPanelNavigateFn = Marshal.GetFunctionPointerForDelegate(_webPanelNavigateCallback!);
|
||||
_api.WebPanelCloseFn = Marshal.GetFunctionPointerForDelegate(_webPanelCloseCallback!);
|
||||
_api.WebPanelGetStateFn = Marshal.GetFunctionPointerForDelegate(_webPanelGetStateCallback!);
|
||||
#endif
|
||||
RouteApiThroughLoader();
|
||||
}
|
||||
|
||||
|
|
|
|||
19
src/RynthCore.Engine/WebPanel/WebPanelApi.cs
Normal file
19
src/RynthCore.Engine/WebPanel/WebPanelApi.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using RynthCore.Engine.Plugins;
|
||||
|
||||
namespace RynthCore.Engine.WebPanel;
|
||||
|
||||
/// <summary>
|
||||
/// The engine side of the v93 web panel calls (PluginContract.cs WebPanelOpenFn..WebPanelGetStateFn).
|
||||
/// Task 2 stub: every call answers Unavailable; the WebView2 host arrives in a later task.
|
||||
/// No call here may block its caller (AC's main thread, the plugin pump and ImGui draws all call these).
|
||||
/// </summary>
|
||||
internal static class WebPanelApi
|
||||
{
|
||||
public static unsafe int Open(WebPanelOpenNative* open) => (int)WebPanelCode.Unavailable;
|
||||
|
||||
public static unsafe int Navigate(int handle, byte* url) => (int)WebPanelCode.Unavailable;
|
||||
|
||||
public static int Close(int handle) => (int)WebPanelCode.Unavailable;
|
||||
|
||||
public static unsafe int GetState(int handle, WebPanelStateNative* state) => (int)WebPanelCode.Unavailable;
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RynthCore.Engine.WebPanel;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
namespace RynthCore.Engine.WebPanel;
|
||||
|
||||
internal readonly record struct PanelRect(int Left, int Top, int Right, int Bottom)
|
||||
|
|
|
|||
Loading…
Reference in a new issue