Add prototypes for advanced API.

This commit is contained in:
Ottermandias 2022-06-16 17:04:15 +02:00
parent 787c19a170
commit 0f2266963d
2 changed files with 122 additions and 0 deletions

View file

@ -1,9 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using Dalamud.Configuration;
using Dalamud.Game.ClientState.Objects.Types;
using Lumina.Data;
using OtterGui.Classes;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Enums;
using Penumbra.Meta.Manipulations;
using Penumbra.Mods;
namespace Penumbra.Api;
@ -16,6 +21,22 @@ public interface IPenumbraApiBase
public delegate void ChangedItemHover( object? item );
public delegate void ChangedItemClick( MouseButton button, object? item );
public enum PenumbraApiEc
{
Okay = 0,
NothingChanged = 1,
CollectionMissing = 2,
ModMissing = 3,
OptionGroupMissing = 4,
SettingMissing = 5,
CharacterCollectionExists = 6,
LowerPriority = 7,
InvalidGamePath = 8,
FileMissing = 9,
InvalidManipulation = 10,
}
public interface IPenumbraApi : IPenumbraApiBase
{
// Obtain the currently set mod directory from the configuration.
@ -77,4 +98,64 @@ public interface IPenumbraApi : IPenumbraApiBase
// Obtain a list of all installed mods. The first string is their directory name, the second string is their mod name.
public IList< (string, string) > GetModList();
// ############## Mod Settings #################
// Obtain the potential settings of a mod specified by its directory name first or mod name second.
// Returns null if the mod could not be found.
public Dictionary< string, (string[], SelectType) >? GetAvailableModSettings( string modDirectory, string modName );
// Obtain the enabled state, the priority, the settings of a mod specified by its directory name first or mod name second,
// and whether these settings are inherited, or null if the collection does not set them at all.
// If allowInheritance is false, only the collection itself will be checked.
public (PenumbraApiEc, (bool, int, Dictionary< string, string[] >, bool)?) GetCurrentModSettings( string collectionName,
string modDirectory, string modName, bool allowInheritance );
// Try to set the inheritance state in the given collection of a mod specified by its directory name first or mod name second.
// Returns Okay, NothingChanged, CollectionMissing or ModMissing.
public PenumbraApiEc TryInheritMod( string collectionName, string modDirectory, string modName, bool inherit );
// Try to set the enabled state in the given collection of a mod specified by its directory name first or mod name second. Also removes inheritance.
// Returns Okay, NothingChanged, CollectionMissing or ModMissing.
public PenumbraApiEc TrySetMod( string collectionName, string modDirectory, string modName, bool enabled );
// Try to set the priority in the given collection of a mod specified by its directory name first or mod name second. Also removes inheritance.
// Returns Okay, NothingChanged, CollectionMissing or ModMissing.
public PenumbraApiEc TrySetModPriority( string collectionName, string modDirectory, string modName, int priority );
// Try to set a specific option group in the given collection of a mod specified by its directory name first or mod name second. Also removes inheritance.
// If the group is a Single Selection group, options should be a single string, otherwise the array of enabled options.
// Returns Okay, NothingChanged, CollectionMissing or ModMissing, OptionGroupMissing or SettingMissing.
// If any setting can not be found, it will not change anything.
public PenumbraApiEc TrySetModSetting( string collectionName, string modDirectory, string modName, string optionGroupName, string option );
public PenumbraApiEc TrySetModSetting( string collectionName, string modDirectory, string modName, string optionGroupName,
string[] options );
// Create a temporary collection without actual settings but with a cache.
// If character is non-zero and either no character collection for this character exists or forceOverwriteCharacter is true,
// associate this collection to a specific character.
// Can return Okay, CharacterCollectionExists or NothingChanged.
public PenumbraApiEc CreateTemporaryCollection( string collectionName, string? character, bool forceOverwriteCharacter );
// Remove a temporary collection if it exists.
// Can return Okay or NothingChanged.
public PenumbraApiEc RemoveTemporaryCollection( string collectionName );
// Set or remove a specific file redirection or meta manipulation under the name of Tag and with a given priority
// for a given collection, which may be temporary.
// Can return Okay, CollectionMissing, InvalidPath, FileMissing, LowerPriority, or NothingChanged.
public PenumbraApiEc SetFileRedirection( string tag, string collectionName, string gamePath, string fullPath, int priority );
// Can return Okay, CollectionMissing, InvalidManipulation, LowerPriority, or NothingChanged.
public PenumbraApiEc SetMetaManipulation( string tag, string collectionName, string manipulationBase64, int priority );
// Can return Okay, CollectionMissing, InvalidPath, or NothingChanged.
public PenumbraApiEc RemoveFileRedirection( string tag, string collectionName, string gamePath );
// Can return Okay, CollectionMissing, InvalidManipulation, or NothingChanged.
public PenumbraApiEc RemoveMetaManipulation( string tag, string collectionName, string manipulationBase64 );
}

View file

@ -11,6 +11,7 @@ using Newtonsoft.Json;
using Penumbra.Collections;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Enums;
using Penumbra.Mods;
namespace Penumbra.Api;
@ -208,4 +209,44 @@ public class PenumbraApi : IDisposable, IPenumbraApi
CheckInitialized();
return Penumbra.ModManager.Select( m => ( m.ModPath.Name, m.Name.Text ) ).ToArray();
}
public Dictionary< string, (string[], SelectType) >? GetAvailableModSettings( string modDirectory, string modName )
=> throw new NotImplementedException();
public (PenumbraApiEc, (bool, int, Dictionary< string, string[] >, bool)?) GetCurrentModSettings( string collectionName, string modDirectory, string modName,
bool allowInheritance )
=> throw new NotImplementedException();
public PenumbraApiEc TryInheritMod( string collectionName, string modDirectory, string modName, bool inherit )
=> throw new NotImplementedException();
public PenumbraApiEc TrySetMod( string collectionName, string modDirectory, string modName, bool enabled )
=> throw new NotImplementedException();
public PenumbraApiEc TrySetModPriority( string collectionName, string modDirectory, string modName, int priority )
=> throw new NotImplementedException();
public PenumbraApiEc TrySetModSetting( string collectionName, string modDirectory, string modName, string optionGroupName, string option )
=> throw new NotImplementedException();
public PenumbraApiEc TrySetModSetting( string collectionName, string modDirectory, string modName, string optionGroupName, string[] options )
=> throw new NotImplementedException();
public PenumbraApiEc CreateTemporaryCollection( string collectionName, string? character, bool forceOverwriteCharacter )
=> throw new NotImplementedException();
public PenumbraApiEc RemoveTemporaryCollection( string collectionName )
=> throw new NotImplementedException();
public PenumbraApiEc SetFileRedirection( string tag, string collectionName, string gamePath, string fullPath, int priority )
=> throw new NotImplementedException();
public PenumbraApiEc SetMetaManipulation( string tag, string collectionName, string manipulationBase64, int priority )
=> throw new NotImplementedException();
public PenumbraApiEc RemoveFileRedirection( string tag, string collectionName, string gamePath )
=> throw new NotImplementedException();
public PenumbraApiEc RemoveMetaManipulation( string tag, string collectionName, string manipulationBase64 )
=> throw new NotImplementedException();
}