[Solved] Having Some Problems Altering Existing Panel Properties

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

[Solved] Having Some Problems Altering Existing Panel Properties

Post by Magicono43 » Thu May 21, 2020 2:26 pm

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: 1150
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Having Some Problems Altering Existing Panel Properties

Post by TheLacus » 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.
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

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

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 » Thu May 21, 2020 3:11 pm

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: 270
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 » Thu May 21, 2020 3:38 pm

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: 270
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 » Thu May 21, 2020 3:47 pm

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: 270
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 » Thu May 21, 2020 3:58 pm

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: 270
Joined: Tue Nov 06, 2018 7:06 am

Re: Having Some Problems Altering Existing Panel Properties

Post by Magicono43 » 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.

Post Reply