X2CommunityCore / X2CommunityHighlander

MIT License
7 stars 3 forks source link

Update UILargeButton to handle all anchors #273

Open robojumper opened 7 years ago

robojumper commented 7 years ago

UILargeButton has a function RefreshLocationBasedOnAnchor that makes it look nice when anchored.

Unfortunately, that's only implemented for Bottom_Right, Middle_Center, Bottom_Center, Top_Center.

simulated function RefreshLocationBasedOnAnchor()
{
    switch( anchor )
    {
    case class'UIUtilities'.const.ANCHOR_BOTTOM_RIGHT:
        SetPosition(-Width - 12 + OffsetX, -Height - 12 + OffsetY); // giving it a little breathing space to edge of screen, aligned with shortcut hud. 
        break;
    case class'UIUtilities'.const.ANCHOR_MIDDLE_CENTER:
        SetPosition(-Width * 0.5 + OffsetX, -Height * 0.5 + OffsetY);
        break;
    case class'UIUtilities'.const.ANCHOR_BOTTOM_CENTER:
        SetPosition(-Width * 0.5 + OffsetX, -Height + OffsetY);
        break;
    case class'UIUtilities'.const.ANCHOR_TOP_CENTER:
        SetPosition(-Width * 0.5 + OffsetX, OffsetY);
        break;
    }
    if(bHideUntilRealized)
        Show();
}

It should be expanded for every anchor.