mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
HTTP Api formatting.
This commit is contained in:
parent
31c9b22b9b
commit
bfb630d317
1 changed files with 39 additions and 49 deletions
|
|
@ -30,10 +30,8 @@ public class HttpApi : IDisposable
|
|||
{
|
||||
_api = api;
|
||||
if (Penumbra.Config.EnableHttpApi)
|
||||
{
|
||||
CreateWebServer();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
=> _server != null;
|
||||
|
|
@ -79,18 +77,12 @@ public class HttpApi : IDisposable
|
|||
var data = await HttpContext.GetRequestDataAsync<RedrawData>();
|
||||
Penumbra.Log.Debug($"[HTTP] {nameof(Redraw)} triggered with {data}.");
|
||||
if (data.ObjectTableIndex >= 0)
|
||||
{
|
||||
_api.RedrawObject(data.ObjectTableIndex, data.Type);
|
||||
}
|
||||
else if (data.Name.Length > 0)
|
||||
{
|
||||
_api.RedrawObject(data.Name, data.Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
_api.RedrawAll(data.Type);
|
||||
}
|
||||
}
|
||||
|
||||
public partial void RedrawAll()
|
||||
{
|
||||
|
|
@ -105,29 +97,25 @@ public class HttpApi : IDisposable
|
|||
// Add the mod if it is not already loaded and if the directory name is given.
|
||||
// AddMod returns Success if the mod is already loaded.
|
||||
if (data.Path.Length != 0)
|
||||
{
|
||||
_api.AddMod(data.Path);
|
||||
}
|
||||
|
||||
// Reload the mod by path or name, which will also remove no-longer existing mods.
|
||||
_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, "", "");
|
||||
_api.OpenMainWindow(TabType.Mods, string.Empty, string.Empty);
|
||||
}
|
||||
|
||||
private record ModReloadData(string Path, string Name)
|
||||
|
|
@ -136,10 +124,12 @@ public class HttpApi : IDisposable
|
|||
: this(string.Empty, string.Empty)
|
||||
{ }
|
||||
}
|
||||
|
||||
private record ModUnpackData(string Path)
|
||||
{
|
||||
public ModUnpackData()
|
||||
: this( string.Empty) { }
|
||||
: this(string.Empty)
|
||||
{ }
|
||||
}
|
||||
|
||||
private record RedrawData(string Name, RedrawType Type, int ObjectTableIndex)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue