コード例 #1
0
            static void DrawRecentPanel()
            {
                if (DataShop.RecentScrap())
                {
                    Transform background = ElementCreator.SpawnImageOffset(new List <Image>(), UIDrawer.rootTransform.transform.parent.gameObject, null, new Color(0, 0, 0, 0.95f), new Vector2(0.5f, 0.5f), Vector2.zero, Vector2.zero).transform;
                    background.GetComponent <Image>().raycastTarget = true;

                    GameObject    panelOutline   = PanelCreator.CreatePanelSize(background);
                    RectTransform panelTransform = panelOutline.GetComponent <RectTransform>();
                    float         panelWidth     = 600 + UIConfig.panelPadding * 2 + 10;
                    float         panelHeight    = 400 + UIConfig.panelPadding * 2 + 10;
                    panelTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, panelWidth);
                    panelTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, panelHeight);
                    panelTransform.localPosition = new Vector3(-panelWidth / 2f, panelHeight / 2f, 0);
                    RectTransform panelChildTransform = panelTransform.GetChild(0).GetComponent <RectTransform>();

                    List <TMPro.TextMeshProUGUI> text = new List <TMPro.TextMeshProUGUI>();
                    ElementCreator.SpawnTextOffset(text, panelTransform.GetChild(0).gameObject, new Color(1, 1, 1), 24, 0, new Vector2(UIConfig.spacingHorizontal, UIConfig.spacingVertical + UIConfig.blackButtonHeight + UIConfig.spacingVertical * 2 + UIConfig.blueButtonHeight + UIConfig.spacingVertical), new Vector2(-UIConfig.spacingHorizontal, -UIConfig.spacingVertical));
                    text[0].text  = "THANK YOU";
                    text[0].text += "\nFor your (or your kinsman's) continued service. Working to the benefit of UES is working to the benefit of us all.";
                    text[0].text += "\n";
                    text[0].text += "\nYour UES Aptitude Scores have been increased by the following amounts:";

                    float scrapSpacing = 75;
                    List <TMPro.TextMeshProUGUI> scrapTexts = new List <TMPro.TextMeshProUGUI>();
                    for (int tierIndex = 0; tierIndex < DataShop.scrap.Count; tierIndex++)
                    {
                        ElementCreator.SpawnTextSize(scrapTexts, panelChildTransform.gameObject, new Color(1, 1, 1, 1), 30, 0, new Vector2(0.5f, 1), new Vector2(300, UIConfig.blueButtonHeight - UIConfig.panelPadding * 2), new Vector3(panelChildTransform.rect.width / 2f + (-DataShop.scrap.Count / 2f + tierIndex + 0.5f) * scrapSpacing, -panelChildTransform.rect.height + UIConfig.spacingVertical + UIConfig.blackButtonHeight + UIConfig.spacingVertical * 2 + UIConfig.blueButtonHeight, 0));
                        scrapTexts[tierIndex].text = DataShop.scrapRecent[tierIndex].ToString();
                        if (DataShop.scrapRecent[tierIndex] > 0)
                        {
                            scrapTexts[tierIndex].color = UIConfig.tierColours[tierIndex];
                        }
                        else
                        {
                            scrapTexts[tierIndex].color = UIConfig.tierColours[tierIndex] * 0.5f;
                        }
                    }

                    GameObject    backButton          = ButtonCreator.SpawnBlackButton(panelChildTransform.gameObject, new Vector2(UIConfig.blackButtonWidth, UIConfig.blackButtonHeight), "Back", new List <TMPro.TextMeshProUGUI>());
                    RectTransform backButtonTransform = backButton.transform.parent.GetComponent <RectTransform>();
                    backButtonTransform.localPosition = new Vector3(panelChildTransform.rect.width / 2f - UIConfig.blackButtonWidth / 2f, -panelHeight + UIConfig.spacingVertical + UIConfig.blackButtonHeight, backButtonTransform.localPosition.z);

                    RoR2.UI.HGButton previousSelectable = backButton.GetComponent <RoR2.UI.MPEventSystemLocator>().eventSystem.currentSelectedGameObject.GetComponent <RoR2.UI.HGButton>();
                    Button           backButtonButton   = backButton.GetComponent <RoR2.UI.HGButton>();
                    backButtonButton.onClick.AddListener(() => {
                        UIDrawer.rootTransform.GetComponent <CanvasGroup>().interactable = true;
                        if (backButtonButton.GetComponent <RoR2.UI.MPEventSystemLocator>().eventSystem.currentInputSource == RoR2.UI.MPEventSystem.InputSource.Gamepad)
                        {
                            previousSelectable.Select();
                        }
                        else
                        {
                            previousSelectable.enabled = false;
                            previousSelectable.enabled = true;
                        }
                        DataShop.ClearRecentScrap();
                        Data.SaveConfigProfile();
                        Destroy(background.gameObject);
                    });
                    backButtonButton.Select();

                    UIDrawer.rootTransform.GetComponent <CanvasGroup>().interactable = false;
                }
            }