IHost Interface Documentation
The IHost
interface provides plugins with access to
Melon's core services and functionalities. It acts as a gateway to
interact with various aspects of the application.
Interface Definition
public interface IHost
{
string Version { get; }
IMelonAPI MelonAPI { get; }
IStorageAPI Storage { get; }
IMelonScanner MelonScanner { get; }
IStateManager StateManager { get; }
IDisplayManager DisplayManager { get; }
IMelonUI MelonUI { get; }
ISettingsUI SettingsUI { get; }
}
Properties and Sub-Interfaces
Version
- Type:
string
- Description: Gets the current version of the Plugin Interface.
IMelonAPI
Provides access to database functionalities. Limited, and will likely include track/album/artist search soon.
IMelonAPI Interface
public interface IMelonAPI
{
List<Track> ShuffleTracks(List<Track> tracks, string UserId, ShuffleType type, bool fullRandom = false, bool enableTrackLinks = true);
}
-
Methods:
-
ShuffleTracks:
-
Parameters:
tracks
: List of tracks to shuffle.-
UserId
: ID of the user requesting the shuffle. -
type
: The type of shuffle algorithm to use. -
fullRandom
: If true, shuffles tracks completely randomly. -
enableTrackLinks
: If true, considers track links when shuffling.
- Returns: A shuffled list of tracks.
-
Parameters:
-
ShuffleTracks:
IStorageAPI
Interface for loading and saving configuration files.
IStorageAPI Interface
public interface IStorageAPI
{
T LoadConfigFile<T>(string filename, string[] protectedProperties, out bool converted);
void SaveConfigFile<T>(string filename, T config, string[] protectedProperties);
}
-
Methods:
-
LoadConfigFile:
-
Parameters:
-
filename
: Name of the config file (without extension). -
protectedProperties
: Properties to exclude from serialization. -
converted
: Out parameter indicating if the file was converted from an older format.
-
-
Returns: Deserialized config object of type
T
.
-
Parameters:
-
SaveConfigFile:
-
Parameters:
-
filename
: Name of the config file (without extension). config
: The config object to save.-
protectedProperties
: Properties to exclude from serialization.
-
- Saves the config object to a file.
-
Parameters:
-
LoadConfigFile:
IMelonScanner
Access to the media library scanner.
IMelonScanner Interface
public interface IMelonScanner
{
string CurrentFolder { get; set; }
string CurrentFile { get; set; }
string CurrentStatus { get; set; }
double ScannedFiles { get; set; }
double FoundFiles { get; set; }
long averageMilliseconds { get; set; }
bool Indexed { get; set; }
bool endDisplay { get; set; }
bool Scanning { get; set; }
void StartScan(bool skip);
void UpdateCollections();
void ResetDB();
}
- Properties: Provide real-time status of the scanner.
-
Methods:
- StartScan: Initiates a scan of the media library.
- UpdateCollections: Updates dynamic collections.
- ResetDB: Resets the database.
IStateManager
Access to application state and settings.
IStateManager Interface
public interface IStateManager
{
string melonPath { get; }
ShortSettings MelonSettings { get; }
Flags MelonFlags { get; }
ResourceManager StringsManager { get; }
List<IPlugin> Plugins { get; }
Dictionary<string, string> LaunchArgs { get; }
byte[] GetDefaultImage();
}
-
Properties:
- melonPath: The path where Melon is installed.
- MelonSettings: Current settings.
- MelonFlags: Debug flags.
- StringsManager: Manages localized strings.
- Plugins: List of loaded plugins.
- LaunchArgs: Command-line arguments set when launching Melon.
-
Methods:
- GetDefaultImage: Returns the default image as a byte array. This is used when no album/artist/track art is set.
IDisplayManager
Manage UI elements and menu options.
IDisplayManager Interface
public interface IDisplayManager
{
OrderedDictionary MenuOptions { get; set; }
OrderedDictionary UIExtensions { get; set; }
}
-
Properties:
- MenuOptions: Main menu options.
- UIExtensions: Additional UI elements or extensions. This is intended for popup messages after menu flows, for example after starting a download leaving a message on the main menu that says "download started". UI extensions should be cleaned up properly by removing the extension from within the extension's function.
IMelonUI
Access to UI components like input methods and display functions.
IMelonUI Interface
public interface IMelonUI
{
void BreadCrumbBar(List<string> list);
void ClearConsole();
void ClearConsole(int left, int top, int width, int height);
Color ColorPicker(Color CurColor);
string HiddenInput();
void DisplayProgressBar(double count, double max, char foreground, char background);
void ShowIndeterminateProgress();
void HideIndeterminateProgress();
string OptionPicker(List<string> Choices);
string StringInput(bool UsePred, bool AutoCorrect, bool FreeInput, bool ShowChoices, List<string> Choices = null);
void ChecklistDisplayToggle();
void SetChecklistItems(string[] list);
void InsertInChecklist(string item, int place, bool check);
void UpdateChecklist(int place, bool check);
}
-
Methods:
- BreadCrumbBar: Displays navigation breadcrumbs.
- ClearConsole: Clears the console screen.
- ColorPicker: Opens a color selection interface.
- HiddenInput: Reads input without displaying it.
- DisplayProgressBar: Shows a progress bar.
- OptionPicker: Presents a list of options to the user.
- StringInput: Reads a string input with optional features. (Experimental)
- Checklist Methods: Manage checklist UI elements.
ISettingsUI
Manage settings menu options.
ISettingsUI Interface
public interface ISettingsUI
{
OrderedDictionary MenuOptions { get; set; }
}
-
Properties:
- MenuOptions: Options available in the settings menu.