mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add redraw route to http api
This commit is contained in:
parent
bf40c2a3cb
commit
6fa79c62c4
2 changed files with 37 additions and 1 deletions
35
Penumbra/Api/RedrawController.cs
Normal file
35
Penumbra/Api/RedrawController.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using EmbedIO;
|
||||||
|
using EmbedIO.Routing;
|
||||||
|
using EmbedIO.WebApi;
|
||||||
|
using Penumbra.GameData.Enums;
|
||||||
|
|
||||||
|
namespace Penumbra.Api
|
||||||
|
{
|
||||||
|
public class RedrawController : WebApiController
|
||||||
|
{
|
||||||
|
private readonly Penumbra _penumbra;
|
||||||
|
|
||||||
|
public RedrawController( Penumbra penumbra )
|
||||||
|
=> _penumbra = penumbra;
|
||||||
|
|
||||||
|
[Route( HttpVerbs.Post, "/redraw" )]
|
||||||
|
public async Task Redraw()
|
||||||
|
{
|
||||||
|
RedrawData data = await HttpContext.GetRequestDataAsync<RedrawData>();
|
||||||
|
_penumbra.Api.RedrawObject( data.Name, data.Type );
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route( HttpVerbs.Post, "/redrawAll" )]
|
||||||
|
public void RedrawAll()
|
||||||
|
{
|
||||||
|
_penumbra.Api.RedrawAll(RedrawType.WithoutSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RedrawData
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public RedrawType Type { get; set; } = RedrawType.WithSettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -166,7 +166,8 @@ public class Penumbra : IDalamudPlugin
|
||||||
.WithMode( HttpListenerMode.EmbedIO ) )
|
.WithMode( HttpListenerMode.EmbedIO ) )
|
||||||
.WithCors( prefix )
|
.WithCors( prefix )
|
||||||
.WithWebApi( "/api", m => m
|
.WithWebApi( "/api", m => m
|
||||||
.WithController( () => new ModsController( this ) ) );
|
.WithController( () => new ModsController( this ) )
|
||||||
|
.WithController( () => new RedrawController( this ) ) );
|
||||||
|
|
||||||
_webServer.StateChanged += ( _, e ) => PluginLog.Information( $"WebServer New State - {e.NewState}" );
|
_webServer.StateChanged += ( _, e ) => PluginLog.Information( $"WebServer New State - {e.NewState}" );
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue