static bool Prefix(WorkshopAdPanel __instance) { LogCalled(); if (!Settings.ConfigUtil.Config.TurnOffSteamPanels) { return(true); } GameObject.DestroyImmediate(__instance.gameObject); return(false); }
//Called by SetStartupOptions() //Used to just break up the function to smaller pieces private static void WorkShopAdPanelEnableWrapper() { try { UIView rootView2 = UIView.GetAView(); if (Mod.IsEnabled) { if (rootView2 != null) { AttemptToReEnableWorkshop(rootView2); } } else { if (DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("Mod Not enabled - Setting DisableWorkshopAdPanel false"); } WorkshopAdPanel tmpWAP = new WorkshopAdPanel(); typeof(WorkshopAdPanel).GetField("dontInitialize", BindingFlags.NonPublic | BindingFlags.Static).SetValue(tmpWAP, false); if (rootView2 != null) { UILabel dl = rootView2.FindUIComponent<UILabel>("DisabledLabel"); if (dl != null) { orgNoWorkshopText = dl.text; dl.text = orgNoWorkshopText; } } } } catch(Exception ex) { Helper.dbgLog("Error: ", ex, true); } }
private static bool AttemptToReEnableWorkshop(UIView rootView) { WorkshopAdPanel tmpWAP; try { if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("Attempting to Renable WorkshopAdPanel"); } List<WorkshopAdPanel> WAPList = new List<WorkshopAdPanel>(); rootView.GetComponentsInChildren<WorkshopAdPanel>(true, WAPList); if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 2) { Helper.dbgLog("Got the list"); } if (WAPList.Count > 0) { if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("Found " + WAPList.Count.ToString() + " WorkshopAdPanels"); } tmpWAP = WAPList[0]; if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 2) { Helper.dbgLog("0= n=" + tmpWAP.component.name + " cn=" + tmpWAP.component.cachedName + " pn=" + tmpWAP.component.parent.name + " pcn=" + tmpWAP.component.parent.cachedName); } typeof(WorkshopAdPanel).GetField("dontInitialize", BindingFlags.NonPublic | BindingFlags.Static).SetValue(tmpWAP, false); if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("WorkshopAdPanel.dontInitialize= set"); } bool retb = (bool)typeof(WorkshopAdPanel).GetField("dontInitialize", BindingFlags.NonPublic | BindingFlags.Static).GetValue(tmpWAP); if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("WorkshopAdPanel.dontInitialize=" + retb.ToString()); } if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("Now going to play with components - WorkshopAdPanels"); } UIScrollablePanel usptmp = tmpWAP.Find<UIScrollablePanel>("Container"); if (usptmp != null) { if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("Found scrollablePanel 'Container' "); } typeof(WorkshopAdPanel).GetField("m_ScrollContainer", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(tmpWAP, usptmp); if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("inserted it into base panel object."); } } UIScrollablePanel usp = (UIScrollablePanel)typeof(WorkshopAdPanel).GetField("m_ScrollContainer", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tmpWAP); if (usp != null) { if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("Scrollable was not null"); } usp.isEnabled = true; usp.isVisible = true; usp.Awake(); } tmpWAP.m_AutoScroll = true; tmpWAP.m_AutoScrollInterval = 20; tmpWAP.enabled = true; tmpWAP.component.isEnabled = true; tmpWAP.component.isVisible = true; tmpWAP.component.Awake(); PlatformService.workshop.QueryItems(); typeof(WorkshopAdPanel).GetField("m_LastTime", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(tmpWAP, Time.realtimeSinceStartup); UILabel tl = rootView.FindUIComponent<UILabel>("DisabledLabel"); if (tl != null) { tl.text = orgNoWorkshopText; tl.isVisible = false; } if (DEBUG_LOG_ON) { Helper.dbgLog("re-enabled WorkshopAdPanel"); } return true; } else { if (DEBUG_LOG_ON) { Helper.dbgLog("No Panels were found to reset. We are likely quiting app from inside an active game."); } } } catch (Exception ex) { Helper.dbgLog("Error: ", ex, true); } try { if (!Singleton<LoadingManager>.instance.m_applicationQuitting) { tmpWAP = new WorkshopAdPanel(); typeof(WorkshopAdPanel).GetField("dontInitialize", BindingFlags.NonPublic | BindingFlags.Static).SetValue(tmpWAP, false); UILabel dl = rootView.FindUIComponent<UILabel>("DisabledLabel"); if (dl != null) { dl.text = orgNoWorkshopText; } } } catch (Exception ex) { if (Mod.DEBUG_LOG_ON) { Helper.dbgLog("Error: Most likey panel was destroyed already during exit\\quit game action", ex, true); } } return false; }
//Called by SetStartupOptions() //Used to just break up the function to smaller pieces private static void WorkShopAdPanelDisableWrapper() { try { UIView rootView = UIView.GetAView(); if (Mod.IsEnabled) { if (rootView != null) { AttemptToDisableWorkshop(rootView); } else { Singleton<TelemetryManager>.instance.StartCoroutine(SetDelayedDisabledLabelText()); } } else //used during bootup process { if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("NotInDisableProcess, Mod.IsEnabled=false - setting static var on WorkshopAdPanels"); } WorkshopAdPanel tmpWAP = new WorkshopAdPanel(); typeof(WorkshopAdPanel).GetField("dontInitialize", BindingFlags.NonPublic | BindingFlags.Static).SetValue(tmpWAP, true); if(rootView !=null) { UILabel dl = rootView.FindUIComponent<UILabel>("DisabledLabel"); if (dl != null) { orgNoWorkshopText = dl.text; dl.text = "Panel disabled via Telemetry Control Mod."; } } } } catch (Exception ex) { Helper.dbgLog("Error: ", ex, true); } }
internal static bool AttemptToDisableWorkshop(UIView rootView) { WorkshopAdPanel tmpWAP; try { if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("Attempting to Disable WorkshopAdPanel"); } List<WorkshopAdPanel> WAPList = new List<WorkshopAdPanel>(); rootView.GetComponentsInChildren<WorkshopAdPanel>(true, WAPList); if (DEBUG_LOG_LEVEL > 2) { Helper.dbgLog("Got the list"); } if (WAPList.Count > 0) { if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("Found " + WAPList.Count.ToString() + " WorkshopAdPanels"); } tmpWAP = WAPList[0]; if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 2) { Helper.dbgLog("0= n=" + tmpWAP.component.name + " cn=" + tmpWAP.component.cachedName + " pn=" + tmpWAP.component.parent.name + " pcn=" + tmpWAP.component.parent.cachedName); } typeof(WorkshopAdPanel).GetField("dontInitialize", BindingFlags.NonPublic | BindingFlags.Static).SetValue(tmpWAP, true); if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("WorkshopAdPanel.dontInitialize= set"); } bool retb = (bool)typeof(WorkshopAdPanel).GetField("dontInitialize", BindingFlags.NonPublic | BindingFlags.Static).GetValue(tmpWAP); if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("WorkshopAdPanel.dontInitialize=" + retb.ToString()); } if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("now going to play with components - WorkshopAdPanels"); } UIScrollablePanel usp = (UIScrollablePanel)typeof(WorkshopAdPanel).GetField("m_ScrollContainer", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tmpWAP); if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("grabbed Scrollable ref via reflection."); } if (usp != null) { if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("Scrollable was not null."); } usp.isEnabled = false; usp.isVisible = false; usp.Awake(); } tmpWAP.m_AutoScroll = false; tmpWAP.m_AutoScrollInterval = 3600; //tmpWAP.component.isEnabled = false; //tmpWAP.component.isVisible = false; tmpWAP.component.Awake(); UILabel tl = rootView.FindUIComponent<UILabel>("DisabledLabel"); if (tl != null) { orgNoWorkshopText = tl.text; tl.text = WORKSHOPADPANEL_REPLACE_TEXT; tl.isVisible = true; if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("DisabledLabel set to " + tl.text + " orginal=" + orgNoWorkshopText); } } return true; } } catch (Exception ex) { Helper.dbgLog("Error: ", ex, true); } try { tmpWAP = new WorkshopAdPanel(); typeof(WorkshopAdPanel).GetField("dontInitialize", BindingFlags.NonPublic | BindingFlags.Static).SetValue(tmpWAP, true); UILabel dl = rootView.FindUIComponent<UILabel>("DisabledLabel"); if (dl != null) { orgNoWorkshopText = dl.text; dl.text = WORKSHOPADPANEL_REPLACE_TEXT; if (DEBUG_LOG_ON && DEBUG_LOG_LEVEL > 1) { Helper.dbgLog("fallthrough - DisabledLabel set to " + dl.text + " orginal=" + orgNoWorkshopText); } } } catch (Exception ex) { Helper.dbgLog("Error: trying to set disabledLabel component during fallthrough", ex, true); } return false; }