static public void FinalizePurchases(Connection connection) { if (Data.mode == DataEarntConsumable.mode) { foreach (NetworkUser networkUser in NetworkUser.readOnlyInstancesList) { if (networkUser.netId.Value == (uint)connection._connectionID) { if (networkUser.isLocalPlayer) { Data.RefreshInfo(networkUser.localUser.userProfile.fileName); DataEarntConsumable.FinalizePurchases(); } break; } } } }
void Start() { startingItemsGUI = this; OnceSetup(); On.RoR2.PreGameController.OnEnable += ((orig, preGameController) => { Data.localUsers.Clear(); Data.SetForcedMode(-1); GameManager.ClearItems(); orig(preGameController); }); UnityEngine.SceneManagement.SceneManager.sceneLoaded += (scene, mode) => { if (scene.name == "title") { Data.localUsers.Clear(); Data.SetForcedMode(-1); GameManager.ClearItems(); SceneLoadSetup(); } }; RoR2.Run.onRunStartGlobal += (run) => { Data.RefreshInfo(); Data.SetForcedMode(Data.mode); foreach (Coroutine coroutine in characterMasterCoroutines) { if (coroutine != null) { StopCoroutine(coroutine); } } characterMasterCoroutines.Clear(); if (NetworkServer.active) { foreach (NetworkUser networkUser in RoR2.NetworkUser.readOnlyInstancesList) { GameManager.status.Add(networkUser.netId.Value, new List <bool>() { false, false, false }); GameManager.items.Add(networkUser.netId.Value, new Dictionary <int, int>()); GameManager.modes.Add(networkUser.netId.Value, -1); characterMasterCoroutines.Add(StartCoroutine(GetMasterController(networkUser))); } } if (NetworkClient.active) { foreach (NetworkUser networkUser in RoR2.NetworkUser.readOnlyInstancesList) { if (networkUser.isLocalPlayer) { Data.localUsers.Add(networkUser.localUser.userProfile.fileName); GameManager.SendItems(networkUser); } } } }; RoR2.Run.onClientGameOverGlobal += (run, runReport) => { DataEarntConsumable.UpdateUserPointsStages(run, runReport); DataEarntPersistent.UpdateUserPointsStages(run, runReport); }; On.RoR2.CharacterBody.OnDeathStart += ((orig, characterBody) => { DataEarntConsumable.UpdateUserPointsBoss(characterBody.name); DataEarntPersistent.UpdateUserPointsBoss(characterBody.name); orig(characterBody); }); On.RoR2.UI.ScrollToSelection.ScrollToRect += (scrollToRect, scrollToSelection, transform) => { scrollToRect(scrollToSelection, transform); ScrollRect scrollRect = scrollToSelection.GetComponent <ScrollRect>(); if (!scrollRect.horizontal || !(bool)(Object)scrollRect.horizontalScrollbar) { return; } Vector3[] targetWorldCorners = new Vector3[4]; Vector3[] viewPortWorldCorners = new Vector3[4]; Vector3[] contentWorldCorners = new Vector3[4]; scrollToSelection.GetComponent <RoR2.UI.MPEventSystemLocator>().eventSystem.currentSelectedGameObject.GetComponent <RectTransform>().GetWorldCorners(targetWorldCorners); scrollRect.viewport.GetWorldCorners(viewPortWorldCorners); scrollRect.content.GetWorldCorners(contentWorldCorners); float x5 = targetWorldCorners[2].x; double x6 = (double)targetWorldCorners[0].x; float x7 = viewPortWorldCorners[2].x; float x8 = viewPortWorldCorners[0].x; float x9 = contentWorldCorners[2].x; float x10 = contentWorldCorners[0].x; float num5 = x5 - x7; double num6 = (double)x8; float num7 = (float)(x6 - num6); float num8 = (x9 - x10) - (x7 - x8); if ((double)num5 > 0.0) { scrollRect.horizontalScrollbar.value += num5 / num8; } if ((double)num7 >= 0.0) { return; } scrollRect.horizontalScrollbar.value += num7 / num8; }; }
static void DrawRecentPanel() { if ((Data.mode == DataEarntConsumable.mode && DataEarntConsumable.userPointsRecent > 0) || (Data.mode == DataEarntPersistent.mode && DataEarntPersistent.userPointsRecent > 0)) { 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 = 350 + 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 + 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 Credit balance has been increased by the following amount:"; List <TMPro.TextMeshProUGUI> creditsText = new List <TMPro.TextMeshProUGUI>(); ElementCreator.SpawnTextSize(creditsText, panelChildTransform.gameObject, new Color(1, 1, 1, 1), 40, 0, new Vector2(0.5f, 1), new Vector2(300, UIConfig.blueButtonHeight - UIConfig.panelPadding * 2), new Vector3(panelChildTransform.rect.width / 2f, -panelChildTransform.rect.height + UIConfig.spacingVertical + UIConfig.blackButtonHeight + UIConfig.spacingVertical + UIConfig.blueButtonHeight, 0)); creditsText[0].text = ""; if (Data.mode == DataEarntConsumable.mode) { creditsText[0].text = DataEarntConsumable.userPointsRecent.ToString(); } else if (Data.mode == DataEarntPersistent.mode) { creditsText[0].text = DataEarntPersistent.userPointsRecent.ToString(); } 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; } if (Data.mode == DataEarntConsumable.mode) { DataEarntConsumable.ClearRecentPoints(); } else if (Data.mode == DataEarntPersistent.mode) { DataEarntPersistent.ClearRecentPoints(); } Data.SaveConfigProfile(); Destroy(background.gameObject); }); backButtonButton.Select(); UIDrawer.rootTransform.GetComponent <CanvasGroup>().interactable = false; } }