Create Custom BlockDescriptor for Block with Plugin

I need to create block with parameters with dropdown list like this with it has to load its data from external source like json file.

image

I found some example how to use BlockDescriptor in DescriptorsRepository and HttpRequestBlockDescriptor, but I can’t make it work without rebuild OB2 edit this file DescriptorsRepository.

Ex:
image
image

example_data.zip (564 Bytes)

Can we create a custom BlockDescriptor for Blocks in Plugin and load it without rebuild the source?

Thank you for reading!

Hi, all the blocks created via plugin use the AutoBlockDescriptor. You cannot add any blocks with a custom descriptor without recompiling OB2’s code. For the dropdown you can simply use an enum

Thanks Ruri for your response, I know we can add a dropdown list like that just with using an enum type, but currently I have two problem with using enum:

  1. I have to manually add it like this

    public enum ScreenResolutionInfo
    {
        [EnumMember(Value = "1920x1080")]
        FullHD,
        [EnumMember(Value = "1600x900")]
        HD,
        [EnumMember(Value = "1366x768")]
        Standard
    }

    public enum FULLHD {Width = 1920,Height = 1080, AvailWidth = 1920, AvailHeight = 937}

    public enum HD{

        Width = 1600,
        Height = 900,
        AvailWidth = 1600,
        AvailHeight = 757
    }

    public enum Standard
    {
        Width = 1366,
        Height = 768,
        AvailWidth = 1366,
        AvailHeight = 625
    }
  1. I can’t have enum property started with number like this

image

Can we make RuriLib read enum and and show it as Description or Value like this?

Yes I can add an attribute to do this, please open an issue on github and I will add it (if not too hard to implement, it will be included in 0.2.2). Just a question though, why can’t you just add an underscore in front? It doesn’t look that bad in my opinion.

public enum ScreenResolutionInfo
{
    _1920x1080,
    _1600x900,
    _1366x768
}

UPDATE Ok nevermind don’t open the issue I already did it :sweat_smile: You can use the Description attribute as in the link you posted and it will render the pretty name now.

I know we can put underscore in front to make like others enum, but I think its pretty lame when you open monitor settings or Display resolution in Windows Settings like this
image
and there’s underscore before every pre-set resolution, and it makes me wonder why they have to put underscore like that ?? :grin:

Maybe I am not an easy going for design like this, anyways appreciate for your support and how fast you do it.

About this, is there a way I can import data from external source to display as dropdown list like this without manually set like

With data like this, its okay…

But not with this one,

That would not be an actual enum type then, it would simply be a string with a set of predefined values. I guess this is possible to do as well, even though a bit harder than the other one. Open an issue on github and I will implement it when I have some free time.

Appreciate your considers. I opened issue, I’m trying to do a pull request for this as well

Please discuss with me the approach you would take and what you would change before opening a PR, to make sure we’re on the same page before you start coding, thank you!

of course, we’ll discuss about it here or on github issue