Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plugins to specify their settings in IViewer? #1493

Open
KamilDev opened this issue Dec 6, 2024 · 4 comments
Open

Allow plugins to specify their settings in IViewer? #1493

KamilDev opened this issue Dec 6, 2024 · 4 comments
Milestone

Comments

@KamilDev
Copy link
Contributor

KamilDev commented Dec 6, 2024

It looks like currently, the plugin developers must manually tell the users in a README which settings are available for the plugin, and users have to modify a config file.

I propose to add in IViewer an optional property to implement that gives information about all the available settings for the plugin.

Example:
In IViewer.cs:

/// <summary>
///     Get metadata about the settings available for this plugin.
///     This is used by the settings UI to display and manage plugin-specific settings.
/// </summary>
/// <returns>An array of setting metadata objects describing each available setting</returns>
PluginSettingMetadata[] GetSettings() => [];
public class PluginSettingMetadata
{
    public string SettingId { get; set; }
    public string DisplayName { get; set; }
    public string Description { get; set; }
    public Type SettingType { get; set; }
    public object DefaultValue { get; set; }
    public object[] PossibleValues { get; set; }  // Optional: for settings that have a fixed set of possible values
}

However, there seems to be a problem that we can't specify optional implementations. The code editor will give an error:

Target runtime doesn't support default interface implementation.

I believe we would have to upgrade to .NET 5, or figure out a workaround.


If implemented, this would enable the creation of a user-friendly settings interface. It could display the installed plugins, allowing you to click on one to easily view and modify all its available settings.

@emako
Copy link
Member

emako commented Dec 6, 2024

Your idea should be similar to CurvaLauncher settings page.
Welcome PR, but please continue to use net462 and are not considering upgrading to .NET5+ at the moment, which will directly break a lot of dependencies of plugins.

@KamilDev
Copy link
Contributor Author

KamilDev commented Dec 6, 2024

If you have any ideas on the cleanest workaround to making it an optional property, please let me know. It cannot be required because I believe it will break plugins that aren't updated to implement it.

@emako
Copy link
Member

emako commented Dec 6, 2024

I think using the ExportAttribute is the cleanest approach.

Show the settings if the plugin dll is impled from some interface and auto create the Settings UI.

We can also refer to CurvaLauncher’s approach
image

@emako emako modified the milestones: 4.0.0, 5.0.0 Jan 5, 2025
@emako
Copy link
Member

emako commented Jan 5, 2025

Plan to add Settings Page in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants