[Approved] Allow changing width and height of textures in selectbutton (GUISelectButtonControl.cs) (1 Viewer)

pilehave

Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    Currently the width and height of the arrows used in the selectbuttoncontrol is hardcoded to 16 x 16 pixels:

    Code:
          int x1 = 16;
          int y1 = 16;
          GUIGraphicsContext.ScalePosToScreenResolution(ref x1, ref y1);

    To allow skinners using arrows/textures that are bigger (and thereby improve the 10-foot GUI) I have introduced width and height properties for the four textures used:

    Code:
        [XMLSkinElement("textureLeftHeight")] private int _leftTextureHeight = 16;
        [XMLSkinElement("textureLeftWidth")] private int _leftTextureWidth = 16;
        [XMLSkinElement("textureRight")] protected string _rightTextureName = "";
        [XMLSkinElement("textureRightHeight")] private int _rightTextureHeight = 16;
        [XMLSkinElement("textureRightWidth")] private int _rightTextureWidth = 16;
        [XMLSkinElement("textureLeftFocus")] protected string _leftFocusName = "";
        [XMLSkinElement("textureLeftFocusHeight")] private int _leftTextureFocusHeight = 16;
        [XMLSkinElement("textureLeftFocusWidth")] private int _leftTextureFocusWidth = 16;
        [XMLSkinElement("textureRightFocus")] protected string _rightFocusName = "";
        [XMLSkinElement("textureRightFocusHeight")] private int _rightTextureFocusHeight = 16;
        [XMLSkinElement("textureRightFocusWidth")] private int _rightTextureFocusWidth = 16;

    The values are set like this in XML:

    Code:
                <textureLeftHeight>21</textureLeftHeight>
                <textureLeftWidth>21</textureLeftWidth>
                <textureLeftFocus>arrow_round_left_focus.png</textureLeftFocus>
                <textureLeftFocusHeight>21</textureLeftFocusHeight>
                <textureLeftFocusWidth>21</textureLeftFocusWidth>
                <textureRight>arrow_round_right_nofocus.png</textureRight>
                <textureRightHeight>21</textureRightHeight>
                <textureRightWidth>21</textureRightWidth>
                <textureRightFocus>arrow_round_right_focus.png</textureRightFocus>
                <textureRightFocusHeight>21</textureRightFocusHeight>
                <textureRightFocusWidth>21</textureRightFocusWidth>

    These are then used to set the correct width/height for the arrows:

    Code:
          _imageLeft = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _leftTextureWidth, _leftTextureHeight, _leftTextureName);
          _imageLeft.DimColor = DimColor;
          _imageLeft.ParentControl = this;
     
          _imageLeftFocus = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _leftTextureFocusWidth, _leftTextureFocusHeight,
                                                _leftFocusName);
          _imageLeftFocus.ParentControl = this;
          _imageLeftFocus.DimColor = DimColor;
     
          _imageRight = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _rightTextureWidth, _rightTextureHeight, _rightTextureName);
          _imageRight.ParentControl = this;
          _imageRight.DimColor = DimColor;
     
          _imageRightFocus = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _rightTextureFocusWidth, _rightTextureFocusHeight,
                                                  _rightFocusName);
          _imageRightFocus.ParentControl = this;
          _imageRightFocus.DimColor = DimColor;

    Now, for the last 3 months I have tried, and tried, and tried to understand how to use GIT to make my own branch. And not succeeded. Yes, the old SVN-patching could be horrible, but at least it didn't take a major in math-astro-science to submit a small 2 kb patch file. My gut-feeling tells me that the number of new MP-contributers (patch-wise) is lower than ever. I blame GIT ;)

    So, I have attached an entire copy of the code for the control. This hasn't changed much in some time anyway (last change was AFAIK the shadow on text).
     

    Attachments

    • GUISelectButtonControl.zip
      6.5 KB
    Last edited:

    elliottmc

    Retired Team Member
  • Premium Supporter
  • August 7, 2005
    14,927
    6,061
    Cardiff, UK
    Home Country
    United Kingdom United Kingdom
    Could you send a PM to ajp8164 about this? Skin engine seems to be his area at the moment, so he will know if there is any reason why this should not be included in 1.3.0beta.
     

    elliottmc

    Retired Team Member
  • Premium Supporter
  • August 7, 2005
    14,927
    6,061
    Cardiff, UK
    Home Country
    United Kingdom United Kingdom
    Bug fix is applied on branch Bug-3923-Selectbutton_width_height.

    Presumably if Pilehave knows this is a good fix, and you have also confirmed, this is good enough. Then you just need to PM a team manager for approval to merge to master.

    Mark
     

    Users who are viewing this thread

    Top Bottom