Beispiel #1
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;
        }
        protected override void OnPrefabInit()
        {
            Color      backColour = new Color(0.998f, 0.998f, 0.998f);
            RectOffset rectOffset = new RectOffset(8, 8, 8, 8);

            PPanel moveTitle_panel = new PPanel("MovespeedTitleRow");

            moveTitle_panel.BackColor = backColour;
            moveTitle_panel.Alignment = TextAnchor.MiddleCenter;
            moveTitle_panel.Direction = PanelDirection.Horizontal;
            moveTitle_panel.Spacing   = 10;
            moveTitle_panel.Margin    = rectOffset;
            moveTitle_panel.FlexSize  = Vector2.right;
            PLabel moveTitle_label = new PLabel("MovespeedTitleLabel");

            moveTitle_label.TextAlignment = TextAnchor.MiddleRight;
            moveTitle_label.Text          = SweepyStrings.MoveSpeedTitleName;
            moveTitle_label.ToolTip       = SweepyStrings.MoveSpeedTitleTooltip;
            moveTitle_label.TextStyle     = PUITuning.Fonts.TextDarkStyle;
            PTextField moveTitle_textField = new PTextField("MovespeedSliderTextField")
            {
                Text      = SweepyConfigChecker.BaseMovementSpeed.ToString("0.00"),
                MaxLength = 10,
            };

            moveTitle_textField.OnTextChanged = this.ChangeTextFieldMovespeed;
            moveTitle_textField.OnRealize    += (PUIDelegates.OnRealize)(obj => this.MoveSpeedText = obj);

            PPanel moveTitle_components = moveTitle_panel.AddChild((IUIComponent)moveTitle_label);

            moveTitle_components = moveTitle_panel.AddChild((IUIComponent)moveTitle_textField);
            moveTitle_components.AddTo(this.gameObject, -2);

            PPanel moveSlider_panel = new PPanel("MovespeedSliderRow");

            moveSlider_panel.BackColor = backColour;
            moveSlider_panel.ImageMode = Image.Type.Sliced;
            moveSlider_panel.Alignment = TextAnchor.MiddleCenter;
            moveSlider_panel.Direction = PanelDirection.Horizontal;
            moveSlider_panel.Spacing   = 10;
            moveSlider_panel.Margin    = new RectOffset(8, 8, 6, 32);
            moveSlider_panel.FlexSize  = Vector2.right;

            PLabel moveSliderMin_label = new PLabel("MovespeedSliderMinLabel");

            moveSliderMin_label.Text      = Mathf.RoundToInt(SweepyConfigChecker.MinSpeedSliderValue).ToString();
            moveSliderMin_label.TextStyle = PUITuning.Fonts.TextDarkStyle;

            PPanel moveSlider_components = moveSlider_panel.AddChild((IUIComponent)moveSliderMin_label);

            PSliderSingle moveSpeedSlider = new PSliderSingle("Movespeed")
            {
                Direction       = Slider.Direction.LeftToRight,
                HandleColor     = PUITuning.Colors.ButtonPinkStyle,
                HandleSize      = 16.0f,
                InitialValue    = SweepyConfigChecker.BaseMovementSpeed,
                IntegersOnly    = false,
                MaxValue        = SweepyConfigChecker.MaxSpeedSliderValue,
                MinValue        = SweepyConfigChecker.MinSpeedSliderValue,
                PreferredLength = 140.0f,
                TrackSize       = 16.0f,
            };

            moveSpeedSlider.OnRealize     += (PUIDelegates.OnRealize)(obj => this.MoveSpeedSlider = obj);
            moveSpeedSlider.OnValueChanged = ChangeMovespeed;
            moveSlider_components.AddChild(moveSpeedSlider);

            PLabel moveSliderMax_label = new PLabel("MovespeedSliderMaxLabel");

            moveSliderMax_label.Text      = Mathf.RoundToInt(SweepyConfigChecker.MaxSpeedSliderValue).ToString();
            moveSliderMax_label.TextStyle = PUITuning.Fonts.TextDarkStyle;
            moveSlider_components.AddChild(moveSliderMax_label);

            moveSlider_components.AddTo(this.gameObject, -2);



            PPanel probingTitle_panel = new PPanel("ProbingRadiusTitleRow");

            probingTitle_panel.BackColor = backColour;
            probingTitle_panel.Alignment = TextAnchor.MiddleCenter;
            probingTitle_panel.Direction = PanelDirection.Horizontal;
            probingTitle_panel.Spacing   = 10;
            probingTitle_panel.Margin    = rectOffset;
            probingTitle_panel.FlexSize  = Vector2.right;
            PLabel probingTitle_label = new PLabel("ProbingRadiusTitleLabel");

            probingTitle_label.TextAlignment = TextAnchor.MiddleRight;
            probingTitle_label.Text          = SweepyStrings.ProbingRadiusTitleName;
            probingTitle_label.ToolTip       = SweepyStrings.ProbingRadiusTitleTooltip;
            probingTitle_label.TextStyle     = PUITuning.Fonts.TextDarkStyle;
            PTextField probingTitle_TextField = new PTextField("ProbingSliderTextField")
            {
                Text      = SweepyConfigChecker.BaseProbingRadius.ToString("0"),
                MaxLength = 8,
            };

            probingTitle_TextField.OnTextChanged = this.ChangeTextFieldProbingRadius;
            probingTitle_TextField.OnRealize    += (PUIDelegates.OnRealize)(obj => this.ProbingRadiusText = obj);

            PPanel probingTitle_components = probingTitle_panel.AddChild((IUIComponent)probingTitle_label);

            probingTitle_components = probingTitle_panel.AddChild((IUIComponent)probingTitle_TextField);
            probingTitle_components.AddTo(this.gameObject, -2);

            PPanel probingSlider_panel = new PPanel("ProbingRadiusSliderRow");

            probingSlider_panel.BackColor = backColour;
            probingSlider_panel.ImageMode = Image.Type.Sliced;
            probingSlider_panel.Alignment = TextAnchor.MiddleCenter;
            probingSlider_panel.Direction = PanelDirection.Horizontal;
            probingSlider_panel.Spacing   = 10;
            probingSlider_panel.Margin    = new RectOffset(8, 8, 6, 32);
            probingSlider_panel.FlexSize  = Vector2.right;

            PLabel probingSliderMin_label = new PLabel("ProbingSliderMinLabel");

            probingSliderMin_label.Text      = Mathf.RoundToInt(SweepyConfigChecker.MinProbingSliderValue).ToString();
            probingSliderMin_label.TextStyle = PUITuning.Fonts.TextDarkStyle;

            PPanel probingSlider_components = probingSlider_panel.AddChild((IUIComponent)probingSliderMin_label);

            PSliderSingle probingSpeedSlider = new PSliderSingle("Probing Radius")
            {
                Direction       = Slider.Direction.LeftToRight,
                HandleColor     = PUITuning.Colors.ButtonPinkStyle,
                HandleSize      = 16.0f,
                InitialValue    = SweepyConfigChecker.BaseProbingRadius,
                IntegersOnly    = true,
                MaxValue        = SweepyConfigChecker.MaxProbingSliderValue,
                MinValue        = SweepyConfigChecker.MinProbingSliderValue,
                PreferredLength = 140.0f,
                TrackSize       = 16.0f,
            };

            probingSpeedSlider.OnRealize     += (PUIDelegates.OnRealize)(obj => this.ProbingRadiusSlider = obj);
            probingSpeedSlider.OnValueChanged = ChangeProbingRadius;
            probingSlider_components.AddChild(probingSpeedSlider);

            PLabel probingSliderMax_label = new PLabel("ProbingSliderMaxLabel");

            probingSliderMax_label.Text      = Mathf.RoundToInt(SweepyConfigChecker.MaxProbingSliderValue).ToString();
            probingSliderMax_label.TextStyle = PUITuning.Fonts.TextDarkStyle;
            probingSlider_components.AddChild(probingSliderMax_label);

            probingSlider_components.AddTo(this.gameObject, -2);



            PPanel bottomRow_panel = new PPanel("BottomRow");

            bottomRow_panel.BackColor = backColour;
            bottomRow_panel.Alignment = TextAnchor.MiddleCenter;
            bottomRow_panel.Direction = PanelDirection.Horizontal;
            bottomRow_panel.Margin    = rectOffset;
            bottomRow_panel.Spacing   = 10;

            PButton findButton = new PButton();

            findButton.Color      = PUITuning.Colors.ButtonBlueStyle;
            findButton.Margin     = new RectOffset(16, 16, 8, 8);
            findButton.TextStyle  = PUITuning.Fonts.TextLightStyle;
            findButton.OnClick    = new PUIDelegates.OnButtonPressed(this.FindSweepyBot);
            findButton.Text       = SweepyStrings.FindSweepyButtonText;
            findButton.ToolTip    = SweepyStrings.FindSweepyButtonTooltip;
            findButton.OnRealize += (PUIDelegates.OnRealize)(obj => this.FindSweepyButton = obj);

            PButton resetButton = new PButton();

            resetButton.Color      = PUITuning.Colors.ButtonBlueStyle;
            resetButton.Margin     = new RectOffset(16, 16, 8, 8);
            resetButton.TextStyle  = PUITuning.Fonts.TextLightStyle;
            resetButton.OnClick    = new PUIDelegates.OnButtonPressed(this.ResetSweepyBot);
            resetButton.Text       = SweepyStrings.ResetSweepyButtonText;
            resetButton.ToolTip    = SweepyStrings.ResetSweepyButtonTooltip;
            resetButton.OnRealize += (PUIDelegates.OnRealize)(obj => this.ResetSweepyButton = obj);

            bottomRow_panel.AddChild(findButton);
            bottomRow_panel.AddChild(resetButton);
            bottomRow_panel.AddTo(this.gameObject, -2);


            this.ContentContainer = this.gameObject;
            base.OnPrefabInit();
            this.SetTarget(this.target.gameObject);
        }