Example #1
0
 internal static void Postfix(VirtualScroll __state)
 {
     if (__state != null)
     {
         __state.Rebuild();
     }
 }
Example #2
0
        internal static void Prefix(ModsScreen __instance, ref VirtualScroll __state)
        {
            var entryList = __instance.entryParent;

            if (entryList != null && entryList.TryGetComponent(out VirtualScroll vs))
            {
                vs.OnBuild();
                __state = vs;
            }
            else
            {
                __state = null;
            }
        }
Example #3
0
        /// <summary>
        /// Applied before Initialize runs.
        /// </summary>
        internal static void Prefix(ReceptacleSideScreen __instance,
                                    ref VirtualScroll __state)
        {
            var obj = __instance.requestObjectList;

            if (obj != null && obj.TryGetComponent(out VirtualScroll vs))
            {
                vs.OnBuild();
                __state = vs;
            }
            else
            {
                __state = null;
            }
        }
Example #4
0
        /// <summary>
        /// Applied after Initialize runs.
        /// </summary>
        internal static void Postfix(ReceptacleSideScreen __instance, VirtualScroll __state)
        {
            var        entryList = __instance.requestObjectList;
            GameObject go;

            if (__state != null)
            {
                __state.Rebuild();
            }
            else if ((go = entryList.gameObject) != null)
            {
                // Add if first load
                var vs = go.AddComponent <VirtualScroll>();
                vs.freezeLayout = true;
                vs.Initialize();
            }
        }
Example #5
0
        /// <summary>
        /// Applied before UpdateAvailableAmounts runs.
        /// </summary>
        internal static bool Prefix(ReceptacleSideScreen __instance, ref bool __result)
        {
            bool result = false, changed = false, hide = !DebugHandler.InstantBuildMode &&
                                                         __instance.hideUndiscoveredEntities;
            var           inst     = DiscoveredResources.Instance;
            var           selected = __instance.selectedEntityToggle;
            var           obj      = __instance.requestObjectList;
            var           text     = CACHED_BUILDER;
            VirtualScroll vs       = null;

            if (obj != null)
            {
                obj.TryGetComponent(out vs);
            }
            foreach (var pair in __instance.depositObjectMap)
            {
                var  key     = pair.Key;
                var  display = pair.Value;
                var  go      = key.gameObject;
                bool active  = go.activeSelf;
                Tag  tag     = display.tag;
                // Hide undiscovered entities in some screens (like pedestal)
                if (hide && !inst.IsDiscovered(tag))
                {
                    if (active)
                    {
                        if (!changed && vs != null)
                        {
                            vs.OnBuild();
                            changed = true;
                        }
                        go.SetActive(active = false);
                    }
                }
                else if (!active)
                {
                    if (!changed && vs != null)
                    {
                        vs.OnBuild();
                        changed = true;
                    }
                    go.SetActive(active = true);
                }
                if (active)
                {
                    var toggle = key.toggle;
                    // Do not update amounts of inactive items
                    float availableAmount = __instance.GetAvailableAmount(tag);
                    if (display.lastAmount != availableAmount)
                    {
                        result = true;
                        // Update display only if it actually changed
                        display.lastAmount = availableAmount;
                        text.Clear();
                        availableAmount.ToRyuSoftString(text, 2);
                        key.amount.SetText(text);
                    }
                    if (!__instance.ValidRotationForDeposit(display.direction) ||
                        availableAmount <= 0.0f)
                    {
                        // Disable items which cannot fit in this orientation or are missing
                        if (selected != key)
                        {
                            SetImageToggleState(__instance, toggle, ITState.Disabled);
                        }
                        else
                        {
                            SetImageToggleState(__instance, toggle, ITState.DisabledActive);
                        }
                    }
                    else if (selected != key)
                    {
                        SetImageToggleState(__instance, toggle, ITState.Inactive);
                    }
                    else
                    {
                        SetImageToggleState(__instance, toggle, ITState.Active);
                    }
                }
            }
            // Null was already checked
            if (changed)
            {
                vs.Rebuild();
            }
            __result = result;
            return(false);
        }