-Mari-

Need Help: Reformatting EffectFlags plugin to EffectOptions

Recommended Posts

I am trying to change the output of the CopySelectionCoords plugin from 
 

left, top, width, height

to

{ "X": left, "Y": top, "Width": width, "Height": height }

I've come across a few issues, but most of it boils down to me not knowing how to properly convert EffectFlags to EffectOptions. I've read this thread and downloaded and looked through OptionBasedLibrary v0.7.9. I've read through all the CodeLab tutorials and searched through the forum using GetPaint's custom search page. I'm a C# novice and I'm trying to use Visual Studio 2019 to edit this plugin for my own use; I've tried using CodeLab, but I'm not sure how to use it to get the output I need.

 

I would greatly appreciate some help since I'm obviously in over my head.

Share this post


Link to post
Share on other sites
: base(StaticName, StaticIcon, SubmenuName, EffectFlags.None)

To:

: base(StaticName, StaticIcon, SubmenuName, new EffectOptions { Flags = EffectFlags.None })

 

Share this post


Link to post
Share on other sites

For the output string change:

string selectionCoords = $"{selection.Left}, {selection.Top}, {selection.Width}, {selection.Height}";

To:

string selectionCoords = $"X: {selection.Left}, Y: {selection.Top}, Width: {selection.Width}, Height: {selection.Height}";

 

Share this post


Link to post
Share on other sites

If you want to switch to CodeLab, all you need is this:

 

void PreRender(Surface dst, Surface src)
{
    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    string selectionCoords = "X: " + selection.Left + ", Y: " + selection.Top + ", Width: " + selection.Width + ", Height: " + selection.Height;

    Services.GetService<IClipboardService>().SetText(selectionCoords);
}

void Render(Surface dst, Surface src, Rectangle rect)
{
    dst.CopySurface(src, rect.Location, rect);
}

 

Share this post


Link to post
Share on other sites

Thank you! I tried your first solution, but I thought I'd done something incorrectly. After looking at your original plugin, I think that I must've misunderstood what its purpose was. I was trying to make a selection and have the (x,y) of the top left corner of that selection and the width and height of the selection shown in the output. I appreciate your time.

Share this post


Link to post
Share on other sites
3 minutes ago, -Mari- said:

I was trying to make a selection and have the (x,y) of the top left corner of that selection and the width and height of the selection shown in the output.

 

Um, that's exactly what the plugin does.

Share this post


Link to post
Share on other sites

I thought so, too, but maybe I'm doing something else incorrectly. No matter what selection I make it only outputs 0, 0, 800, 600.

Share this post


Link to post
Share on other sites

I figured out what I was messing up. I was selecting the effect then making my selection instead of making my selection and then choosing the effect. Selection -> Copy Selection. I don't know what I was thinking. Thank you so much for your help and for writing the original plugin.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.