[Solved] Having Some Problems Altering Existing Panel Properties

Discuss modding questions and implementation details.
Post Reply
User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

[Solved] Having Some Problems Altering Existing Panel Properties

Post by Magicono43 »

So i'm adding a custom UI graphic that is replacing an already existing one, specifically the pop-up window for the merchant "repair/talk/sell/exit" asset. After hours of fiddling I was able to get my custom asset to replace this graphic, when I started trying to edit the properties from the base class though I started to run into some problems. The primary one being that some properties have internal access modifiers, which won't allow me to change properties such as the panel Size (which I want 9 pixels taller, otherwise is squashes my custom asset slightly).

From "BaseScreenComponent.cs":

Code: Select all

/// <summary>
        /// Gets position relative to parent panel.
        /// </summary>
        public virtual Vector2 Position
        {
            get { return position; }
            internal set { position = value; }
        }

        /// <summary>
        /// Gets size of component.
        /// </summary>
        public virtual Vector2 Size
        {
            get { return size; }
            internal set { size = value; }
        }
They are both set as virtual, so I tried to override them in my derived class, but it can't seem to find the method:

Code: Select all

/*Vector2 size;

        public override Vector2 Size
        {
            get { return size; }
            set { size = value; }
        }*/
But "Size" is throwing "No suitable method found to override", so i'm not sure how to properly override that.

Oh yeah, and the reason that the internal part is not allowing my derived class to access that set is because of this apparently, "The Internal modifier means that the symbol can only be accessed from within the same assembly. Only code that is compiled into the same DLL as your code can access your properties or methods that are tagged with internal."

As noted in this post: https://stackoverflow.com/questions/444 ... n-assembly


Sorry if this is a bit dis-organized, but hopefully what i'm asking makes sense and what i'm having issues with in this regard, thanks for your time.
Last edited by Magicono43 on Thu May 21, 2020 4:39 pm, edited 1 time in total.

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Having Some Problems Altering Existing Panel Properties

Post by TheLacus »

This could be changed to protected internal to be accessible from both internal code and derived classes, if needed. But i would expect size and position to be set by the utilizer of the UI component, so maybe it should actually be public.

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 »

TheLacus wrote: Thu May 21, 2020 3:08 pm This could be changed to protected internal to be accessible from both internal code and derived classes, if needed. But i would expect size and position to be set by the utilizer of the UI component, so maybe it should actually be public.
That's something I was likely going to bring up, but was afraid that it was like that for a stability reason or something. I'll put the protected in there and if it works, i'll try and put a PR up for that if appropriate.

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 »

So tried changing those to protected internal, and it compiles fine, but I get the same error "no access" for when I try to set those properties. I guess my mod is still not derived technically since the base class is derived of a derived of a derived of something else? Not sure exactly how that works, lol.

Tried just protected and am immediately given that error, but in the base class this time.

So far the only one that worked was removing the access modifier entirely, but not sure if that's a good idea, because it must have been put there for a reason, I guess at least.

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 »

Yeah, so far the only variant that has worked so far has been this:

[code]/// <summary>
/// Gets position relative to parent panel.
/// </summary>
public virtual Vector2 Position
{
get { return position; }
set { position = value; }
}

/// <summary>
/// Gets size of component.
/// </summary>
public virtual Vector2 Size
{
get { return size; }
set { size = value; }
}[/code]

But excuse my ignorance here, but it's strange to me that this works, when the default for a no modifier is normally "private" as far as I know, but somehow that allows my modded properties access, lol, very strange.

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 »

My mistake for being dumb there, lol. Was mistaking the access modifier for the actual property for the setting part specifically.

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 »

So yeah, from what you originally suggested until I threw myself in a wrong direction, I will probably make a PR at some point removing that internal modifier and just have those properties as public. Not sure of the possible problems that might cause, but it seems reasonable enough since basically all the other properties are public as well.

User avatar
jefetienne
Posts: 170
Joined: Thu Jan 16, 2020 8:14 pm
Location: Gallomont, Wayrest
Contact:

Re: Having Some Problems Altering Existing Panel Properties

Post by jefetienne »

Magicono43 wrote: Thu May 21, 2020 4:04 pm So yeah, from what you originally suggested until I threw myself in a wrong direction, I will probably make a PR at some point removing that internal modifier and just have those properties as public. Not sure of the possible problems that might cause, but it seems reasonable enough since basically all the other properties are public as well.
Was just writing a mod, fell into the same situation. :lol:
El jefe, Etienne
Nexus Mods | GitHub

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 »

jefetienne wrote: Sat May 30, 2020 7:00 am Was just writing a mod, fell into the same situation. :lol:
Currently changing a bunch of parts of the "core" code-base classes to hopefully make modding a bit easier in this sense, mostly by changing the access properties to protected and protected virtual instead of private, where appropriate. Not sure if my PR will get through for all the changes, but hopefully it will, basically trying to get ahead of the modders so they (and myself) won't have to wait every-time for the next live-release to "officially" release their mod to the public.

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: [Solved] Having Some Problems Altering Existing Panel Properties

Post by Magicono43 »

Here is my Pull Request btw, it has the change for this thread as well as a bunch of other UIWindow related stuff.

https://github.com/Interkarma/daggerfal ... /pull/1833

Post Reply