private void SetButtonStates(bool enabled)
        {
            if (this.FindSweepyButton != null)
            {
                PButton.SetButtonEnabled(this.FindSweepyButton, enabled);
            }

            if (this.ResetSweepyButton != null)
            {
                PButton.SetButtonEnabled(this.ResetSweepyButton, enabled);
            }

            if (!enabled)
            {
                if ((UnityEngine.Object) this.MoveSpeedText != (UnityEngine.Object)null)
                {
                    PUIElements.SetText(this.MoveSpeedText, "N/A");
                }

                StationaryChoreRangeVisualizer choreRangeVisualizer = this.target.GetComponent <StationaryChoreRangeVisualizer>();

                if ((UnityEngine.Object)choreRangeVisualizer != (UnityEngine.Object)null)
                {
                    choreRangeVisualizer.x     = 0;
                    choreRangeVisualizer.width = 0;
                    Traverse.Create(choreRangeVisualizer).Method("UpdateVisualizers").GetValue();
                }

                if ((UnityEngine.Object) this.ProbingRadiusText != (UnityEngine.Object)null)
                {
                    PUIElements.SetText(this.ProbingRadiusText, "N/A");
                }
            }
        }
Beispiel #2
0
        protected override void OnSpawn()
        {
            base.OnSpawn();
            // One long linear row
            var panel = new PPanel("MoreModActions")
            {
                BackColor = PUITuning.Colors.DialogDarkBackground, Spacing = 6,
                BackImage = PUITuning.Images.BoxBorder, ImageMode = Image.Type.Sliced,
                Direction = PanelDirection.Horizontal, Margin = new RectOffset(6, 6, 6, 6)
            }.AddChild(MakeButton("MoveToFirst", UI.TOOLTIPS.DNI_TOP,
                                  SpriteRegistry.GetTopIcon(), OnMoveFirst, (obj) =>
                                  buttonFirst = obj.GetComponent <KButton>()))
            .AddChild(MakeButton("MoveUpTen", UI.TOOLTIPS.DNI_UP,
                                 Assets.GetSprite("icon_priority_up_2"), OnMoveUp, (obj) =>
                                 buttonUp = obj.GetComponent <KButton>()))
            .AddChild(MakeButton("MoveDownTen", UI.TOOLTIPS.DNI_DOWN,
                                 Assets.GetSprite("icon_priority_down_2"), OnMoveDown, (obj) =>
                                 buttonDown = obj.GetComponent <KButton>()))
            .AddChild(MakeButton("MoveToLast", UI.TOOLTIPS.DNI_BOTTOM,
                                 SpriteRegistry.GetBottomIcon(), OnMoveLast, (obj) =>
                                 buttonLast = obj.GetComponent <KButton>()))
            .AddChild(new PButton("ManageMod")
            {
                Text    = UI.MODSSCREEN.BUTTON_SUBSCRIPTION, DynamicSize = false,
                OnClick = OnManage, ToolTip = "Manage Mod", Margin = DebugUtils.BUTTON_MARGIN
            }.SetKleiBlueStyle().AddOnRealize((obj) => buttonManage = obj))
            .AddChild(new PButton("UnsubMod")
            {
                Text    = UI.MODSSCREEN.BUTTON_UNSUB, DynamicSize = false,
                OnClick = OnUnsub, ToolTip = UI.TOOLTIPS.DNI_UNSUB, Margin = DebugUtils.
                                                                             BUTTON_MARGIN
            }.SetKleiBlueStyle().AddOnRealize((obj) => buttonUnsub = obj.
                                                                     GetComponent <KButton>()));

#if DEBUG
            panel.AddChild(new PButton("ModifyMod")
            {
                Text    = UI.MODSSCREEN.BUTTON_MODIFY, DynamicSize = false,
                OnClick = OnModify, ToolTip = UI.TOOLTIPS.DNI_MODIFY, Margin = DebugUtils.
                                                                               BUTTON_MARGIN
            }.SetKleiPinkStyle().AddOnRealize((obj) => buttonModify = obj.
                                                                      GetComponent <KButton>()));
#endif
            var actionsObj = panel.AddTo(gameObject);
#if DEBUG
            PButton.SetButtonEnabled(buttonModify.gameObject, false);
#endif
            actionsObj.SetActive(false);
            // Blacklist from auto layout
            actionsObj.AddOrGet <LayoutElement>().ignoreLayout = true;
            PUIElements.SetAnchors(actionsObj, PUIAnchoring.End, PUIAnchoring.Center);
            unsubCaller = new CallResult <RemoteStorageUnsubscribePublishedFileResult_t>(
                OnUnsubComplete);
            actionsScreen = actionsObj.AddComponent <ModActionsScreen>();
            callingButton = null;
        }
Beispiel #3
0
        /// <summary>
        /// Adds the mod update date to the mods menu.
        /// </summary>
        /// <param name="modEntry">The entry in the mod menu.</param>
        /// <param name="outdated">The mods which are out of date.</param>
        internal static void AddModUpdateButton(ICollection <ModToUpdate> outdated,
                                                Traverse modEntry)
        {
            int index       = modEntry.GetField <int>("mod_index");
            var rowInstance = modEntry.GetField <RectTransform>("rect_transform")?.gameObject;
            var mods        = Global.Instance.modManager?.mods;

            if (rowInstance != null && mods != null && index >= 0 && index < mods.Count)
            {
                var mod       = mods[index];
                var tooltip   = new StringBuilder(128);
                var localDate = mod.GetLocalLastModified();
                var updated   = ModStatus.Disabled;
                // A nice colorful button with a warning or checkmark icon
                var updButton = new PButton("UpdateMod")
                {
                    Margin = BUTTON_MARGIN, SpriteSize = ICON_SIZE,
                    MaintainSpriteAspect = true
                };
                if (mod.label.distribution_platform == Label.DistributionPlatform.Steam)
                {
                    var modUpdate = new ModToUpdate(mod);
                    updated = AddSteamUpdate(tooltip, modUpdate, localDate, updButton);
                    if (updated == ModStatus.Outdated)
                    {
                        outdated.Add(modUpdate);
                    }
                }
                else
                {
                    tooltip.AppendFormat(UISTRINGS.LOCAL_UPDATE, localDate.ToLocalTime());
                }
                // Icon, color, and tooltip
                updButton.Sprite = (updated == ModStatus.UpToDate || updated == ModStatus.
                                    Disabled) ? PUITuning.Images.Checked : PUITuning.Images.GetSpriteByName(
                    "iconWarning");
                updButton.Color = (updated == ModStatus.Outdated) ? COLOR_OUTDATED :
                                  COLOR_UPDATED;
                updButton.ToolTip = tooltip.ToString();
                // Just before subscription button, and after the Options button
                PButton.SetButtonEnabled(updButton.AddTo(rowInstance, 3), updated != ModStatus.
                                         Disabled);
            }
        }
        /// <summary>
        /// Adds the mod update date to the mods menu.
        /// </summary>
        /// <param name="outdated">The mods which are out of date.</param>
        /// <param name="modEntry">The entry in the mod menu.</param>
        internal static void AddModUpdateButton(ICollection <ModToUpdate> outdated,
                                                object modEntry)
        {
            int index    = -1;
            var type     = modEntry.GetType();
            var indexVal = type.GetFieldSafe("mod_index", false)?.GetValue(modEntry);

            if (indexVal is int intVal)
            {
                index = intVal;
            }
            var rowInstance = (type.GetFieldSafe("rect_transform", false)?.GetValue(
                                   modEntry) as RectTransform)?.gameObject;
            var mods = Global.Instance.modManager?.mods;

            if (rowInstance != null && mods != null && index >= 0 && index < mods.Count)
            {
                var mod       = mods[index];
                var tooltip   = new StringBuilder(128);
                var localDate = mod.GetLocalLastModified();
                var updated   = ModStatus.Disabled;
                // A nice colorful button with a warning or checkmark icon
                var updButton = new PButton("UpdateMod")
                {
                    Margin = BUTTON_MARGIN, SpriteSize = ICON_SIZE,
                    MaintainSpriteAspect = true
                };
                // Format DateTime to the current Klei culture (otherwise it uses
                // CurrentCulture which defaults to the Steam culture)
                if (cultureInfo == null)
                {
                    var langCode = Localization.GetLocale()?.Code;
                    if (string.IsNullOrEmpty(langCode))
                    {
                        langCode = Localization.GetCurrentLanguageCode();
                    }
                    if (string.IsNullOrEmpty(langCode))
                    {
                        cultureInfo = CultureInfo.CurrentCulture;
                    }
                    else
                    {
                        cultureInfo = new CultureInfo(langCode);
                    }
                }
                if (mod.label.distribution_platform == Label.DistributionPlatform.Steam)
                {
                    var modUpdate = new ModToUpdate(mod);
                    updated = AddSteamUpdate(tooltip, modUpdate, localDate, updButton);
                    if (updated == ModStatus.Outdated)
                    {
                        outdated.Add(modUpdate);
                    }
                }
                else
                {
                    tooltip.AppendFormat(cultureInfo, UISTRINGS.LOCAL_UPDATE, localDate.
                                         ToLocalTime());
                }
                // Icon, color, and tooltip
                updButton.Sprite = (updated == ModStatus.UpToDate || updated == ModStatus.
                                    Disabled) ? PUITuning.Images.Checked : PUITuning.Images.GetSpriteByName(
                    "iconWarning");
                updButton.Color = (updated == ModStatus.Outdated) ? COLOR_OUTDATED :
                                  COLOR_UPDATED;
                updButton.ToolTip = tooltip.ToString();
                // Just before subscription button, and after the Options button
                PButton.SetButtonEnabled(updButton.AddTo(rowInstance, 4), updated != ModStatus.
                                         Disabled);
            }
        }