Jump to content

Buttons moving on different screen sizes

Closed 1.1.9 1.2.0

Rose
Rose

Posted

The buttons are not parented to the TC UI and are parented to the screen size.

 

Sometimes the buttons are in the right area and not depending on the users screen size.

 

image.png

image.png

Roger93

Posted

It would be great if that option was available as I have the same problem. 

Roger93

Posted (edited)

Hello! I've spent the entire afternoon reviewing the code to identify potential errors, and I've successfully located and addressed the issue. Below, I outline step by step all the modifications made, accompanied by images illustrating the final state.

To streamline the process, I recommend navigating to the .cs file of your plugin. Keep in mind that these adjustments are tailored for the latest version. It would be fantastic to receive approval from the creator to integrate these changes directly into their code, avoiding the need to modify the original plugin. I took this initiative because some of my players found the previous version inconvenient.

Now, open the AutoBaseUpgrade.cs file and locate the ShowUI function, typically around line 386. Replace the entire content of that function with the code provided below:
 

        private void ShowUI(BasePlayer player, BuildingPrivlidge tc)
        {
            var container = new CuiElementContainer();

            container.Add(new CuiPanel {
                CursorEnabled = false,
                Image = { Color = "1 1 1 1" },
                RectTransform = { AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "0", OffsetMax = "0"}
            }, "Overlay", "Panel_507");

            var text = TCList[tc].isUpgrade ? "<color=#6FBD57>UPGRADE        </color>" : "<color=white>UPGRADE        </color>";
            var textRepair = TCList[tc].isRepair ? "<color=#6FBD57>REPAIR ALL</color>" : "<color=white>REPAIR ALL</color>";


            container.Add(new CuiButton
            {
                Button = { Color = "0.3372549 0.3411765 0.2705882 1", Command = "UI_UPGRADEBASEUP REPAIR" },
                Text =
                {
                    Text = textRepair, Font = "robotocondensed-bold.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter,
                    Color = "1 1 1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "260 621.5", OffsetMax = "350 641.5"
                }
            }, "Panel_507", "Button_6571");


            container.Add(new CuiButton
            {
                Button = { Color = "0.3372549 0.3411765 0.2705882 1", Command = "UI_UPGRADEBASEUP SWITCH" },
                Text =
                {
                    Text = text, Font = "robotocondensed-bold.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter,
                    Color = "1 1 1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "355 621.5", OffsetMax = "445 641.5"
                }
            }, "Panel_507", "Button_6571");

            var grade = TCList[tc].currentGrade;
            var image = grade == BuildingGrade.Enum.Metal ? "metal.fragments" :
                TCList[tc].currentGrade == BuildingGrade.Enum.Stone ? "stones" :
                grade == BuildingGrade.Enum.Wood ? "wood" : "metal.refined";
            container.Add(new CuiElement
            
            {
                Name = "Image_4494",
                Parent = "Panel_507",
                Components =
                {
                    new CuiRawImageComponent { Color = "1 1 1 1", Png = ImageList[image] },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0.5 0", AnchorMax = "0.5 0", OffsetMin = "420 621.5", OffsetMax = "444 641.5"
                    }
                }
            });
            container.Add(new CuiButton
            {
                Button = { Color = "0.3372549 0.3411765 0.2705882 0", Command = "UI_UPGRADEBASEUP CHANGE" },
                Text =
                {
                    Text = "", Font = "robotocondensed-bold.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter,
                    Color = "1 1 1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
            }, "Image_4494", "Button_6571");
            CuiHelper.DestroyUi(player, "Panel_507");
            CuiHelper.AddUi(player, container);
        }

I hope this update proves beneficial. I appreciate your time and consideration. Feel free to reach out if you have any questions or concerns!

I have uploaded two images one with the default scale of rust which is 1.0 and the other with the scale of 0.7 the change would have to be able to adapt to all scales that has the rust


In case the plugin creator does not want to show any changes in his code please delete this message.

And as always, many thanks to @CASHR for their dedication in making these plugins. 

1.0.png

0.7scale.png

Edited by skythirix
CASHR

Posted

Changed Status from Pending to Closed

Changed Fixed In to Next Version

1.4m

Downloads

Total number of downloads.

6.9k

Customers

Total customers served.

102.2k

Files Sold

Total number of files sold.

2m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.