Update HttpApi.cs allows external applications to tell penumbra about a mod package to unpack

This commit is contained in:
Sebastina 2023-04-07 09:40:14 -05:00
parent 69ce929c5e
commit eddbd2b14f

View file

@ -16,6 +16,8 @@ public class HttpApi : IDisposable
[Route( HttpVerbs.Post, "/redraw" )] public partial Task Redraw(); [Route( HttpVerbs.Post, "/redraw" )] public partial Task Redraw();
[Route( HttpVerbs.Post, "/redrawAll" )] public partial void RedrawAll(); [Route( HttpVerbs.Post, "/redrawAll" )] public partial void RedrawAll();
[Route( HttpVerbs.Post, "/reloadmod" )] public partial Task ReloadMod(); [Route( HttpVerbs.Post, "/reloadmod" )] public partial Task ReloadMod();
[Route( HttpVerbs.Post, "/unpackmod" )] public partial Task UnpackMod();
[Route( HttpVerbs.Post, "/openwindow")] public partial Task OpenWindow();
// @formatter:on // @formatter:on
} }
@ -110,6 +112,23 @@ public class HttpApi : IDisposable
// Reload the mod by path or name, which will also remove no-longer existing mods. // Reload the mod by path or name, which will also remove no-longer existing mods.
_api.ReloadMod( data.Path, data.Name ); _api.ReloadMod( data.Path, data.Name );
} }
public async partial Task UnpackMod()
{
var data = await HttpContext.GetRequestDataAsync< ModUnpackData >();
Penumbra.Log.Debug( $"[HTTP] {nameof( UnpackMod )} triggered with {data}." );
// Unpack the mod package if its valid.
if( data.Path.Length != 0 )
{
_api.UnpackMod( data.Path );
}
}
public async partial Task OpenWindow()
{
Penumbra.Log.Debug($"[HTTP] {nameof(OpenWindow)} triggered.");
// Open the penumbra window
_api.OpenMainWindow(TabType.Mods, "", "");
}
private record ModReloadData( string Path, string Name ) private record ModReloadData( string Path, string Name )
{ {
@ -117,6 +136,11 @@ public class HttpApi : IDisposable
: this( string.Empty, string.Empty ) : this( string.Empty, string.Empty )
{ } { }
} }
private record ModUnpackData( string Path)
{
public ModUnpackData()
: this( string.Empty) { }
}
private record RedrawData( string Name, RedrawType Type, int ObjectTableIndex ) private record RedrawData( string Name, RedrawType Type, int ObjectTableIndex )
{ {