Exemplo n.º 1
0
        public UIVirtualKeyboard(string labelText, string startingText, UIVirtualKeyboard.KeyboardSubmitEvent submitAction, Action cancelAction, int inputMode = 0, bool allowEmpty = false)
        {
            this._keyboardContext              = inputMode;
            this._allowEmpty                   = allowEmpty;
            UIVirtualKeyboard.OffsetDown       = 0;
            this._lastOffsetDown               = 0;
            this._edittingSign                 = this._keyboardContext == 1;
            this._edittingChest                = this._keyboardContext == 2;
            UIVirtualKeyboard._currentInstance = this;
            this._submitAction                 = submitAction;
            this._cancelAction                 = cancelAction;
            this._textureShift                 = TextureManager.Load("Images/UI/VK_Shift");
            this._textureBackspace             = TextureManager.Load("Images/UI/VK_Backspace");
            this.Top.Pixels = (float)this._lastOffsetDown;
            float     num1     = (float)(-5000 * this._edittingSign.ToInt());
            float     maxValue = (float)byte.MaxValue;
            float     num2     = 0.0f;
            float     num3     = 516f;
            UIElement element  = new UIElement();

            element.Width.Pixels  = 540f;
            element.Top.Precent   = num2;
            element.Top.Pixels    = maxValue;
            element.Height.Pixels = 266f;
            element.HAlign        = 0.5f;
            element.SetPadding(0.0f);
            this.outerLayer1 = element;
            UIElement uiElement = new UIElement();

            uiElement.Width.Pixels  = 540f;
            uiElement.Top.Precent   = num2;
            uiElement.Top.Pixels    = maxValue;
            uiElement.Height.Pixels = 266f;
            uiElement.HAlign        = 0.5f;
            uiElement.SetPadding(0.0f);
            this.outerLayer2 = uiElement;
            UIPanel mainPanel = new UIPanel();

            mainPanel.Width.Precent   = 1f;
            mainPanel.Height.Pixels   = 225f;
            mainPanel.BackgroundColor = new Color(23, 33, 69) * 0.7f;
            element.Append((UIElement)mainPanel);
            float num4 = -49f;

            this._textBox = new UITextBox("", 0.78f, true);
            this._textBox.BackgroundColor = Color.Transparent;
            this._textBox.BorderColor     = Color.Transparent;
            this._textBox.HAlign          = 0.5f;
            this._textBox.Width.Pixels    = num3;
            this._textBox.Top.Pixels      = 196f + num1;
            this._textBox.Top.Precent     = num2;
            this._textBox.Height.Pixels   = 37f;
            this.Append((UIElement)this._textBox);
            for (int x = 0; x < 10; ++x)
            {
                for (int y = 0; y < 4; ++y)
                {
                    UITextPanel <object> keyboardButton = this.CreateKeyboardButton((object)"1234567890qwertyuiopasdfghjkl'zxcvbnm,.?"[y * 10 + x].ToString(), x, y, 1, true);
                    keyboardButton.OnClick += new UIElement.MouseEvent(this.TypeText);
                    mainPanel.Append((UIElement)keyboardButton);
                }
            }
            this._shiftButton              = this.CreateKeyboardButton((object)"", 0, 4, 1, false);
            this._shiftButton.PaddingLeft  = 0.0f;
            this._shiftButton.PaddingRight = 0.0f;
            UITextPanel <object> shiftButton1 = this._shiftButton;
            UITextPanel <object> shiftButton2 = this._shiftButton;
            double num5 = 0.0;
            float  num6 = 0.0f;

            shiftButton2.PaddingTop = (float)num5;
            double num7 = (double)num6;

            shiftButton1.PaddingBottom        = (float)num7;
            this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            this._shiftButton.BorderColor     = this._internalBorderColor * 0.7f;
            this._shiftButton.OnMouseOver    += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                this._shiftButton.BorderColor = this._internalBorderColorSelected;
                if (this._keyState == UIVirtualKeyboard.KeyState.Shift)
                {
                    return;
                }
                this._shiftButton.BackgroundColor = new Color(73, 94, 171);
            });
            this._shiftButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                this._shiftButton.BorderColor = this._internalBorderColor * 0.7f;
                if (this._keyState == UIVirtualKeyboard.KeyState.Shift)
                {
                    return;
                }
                this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            });
            this._shiftButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(12, -1, -1, 1, 1f, 0.0f);
                this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Shift ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Shift);
            });
            UIImage uiImage1 = new UIImage(this._textureShift);

            uiImage1.HAlign     = 0.5f;
            uiImage1.VAlign     = 0.5f;
            uiImage1.ImageScale = 0.85f;
            this._shiftButton.Append((UIElement)uiImage1);
            mainPanel.Append((UIElement)this._shiftButton);
            this._symbolButton                 = this.CreateKeyboardButton((object)"@%", 1, 4, 1, false);
            this._symbolButton.PaddingLeft     = 0.0f;
            this._symbolButton.PaddingRight    = 0.0f;
            this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            this._symbolButton.BorderColor     = this._internalBorderColor * 0.7f;
            this._symbolButton.OnMouseOver    += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                this._symbolButton.BorderColor = this._internalBorderColorSelected;
                if (this._keyState == UIVirtualKeyboard.KeyState.Symbol)
                {
                    return;
                }
                this._symbolButton.BackgroundColor = new Color(73, 94, 171);
            });
            this._symbolButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                this._symbolButton.BorderColor = this._internalBorderColor * 0.7f;
                if (this._keyState == UIVirtualKeyboard.KeyState.Symbol)
                {
                    return;
                }
                this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            });
            this._symbolButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(12, -1, -1, 1, 1f, 0.0f);
                this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Symbol ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Symbol);
            });
            mainPanel.Append((UIElement)this._symbolButton);
            this.BuildSpaceBarArea(mainPanel);
            this._submitButton = new UITextPanel <LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.4f, true);
            this._submitButton.Height.Pixels = 37f;
            this._submitButton.Width.Precent = 0.4f;
            this._submitButton.HAlign        = 1f;
            this._submitButton.VAlign        = 1f;
            this._submitButton.PaddingLeft   = 0.0f;
            this._submitButton.PaddingRight  = 0.0f;
            this.ValidateText();
            this._submitButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText());
            this._submitButton.OnMouseOut  += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText());
            this._submitButton.OnClick     += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                string text = this.Text.Trim();
                if (text.Length <= 0 && !this._edittingSign && (!this._edittingChest && !this._allowEmpty))
                {
                    return;
                }
                Main.PlaySound(10, -1, -1, 1, 1f, 0.0f);
                this._submitAction(text);
            });
            element.Append((UIElement)this._submitButton);
            this._cancelButton = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.4f, true);
            this.StyleKey <LocalizedText>(this._cancelButton, true);
            this._cancelButton.Height.Pixels = 37f;
            this._cancelButton.Width.Precent = 0.4f;
            this._cancelButton.VAlign        = 1f;
            this._cancelButton.OnClick      += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(11, -1, -1, 1, 1f, 0.0f);
                this._cancelAction();
            });
            element.Append((UIElement)this._cancelButton);
            this._submitButton2               = new UITextPanel <LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.72f, true);
            this._submitButton2.TextColor     = Color.Silver;
            this._submitButton2.DrawPanel     = false;
            this._submitButton2.Height.Pixels = 60f;
            this._submitButton2.Width.Precent = 0.4f;
            this._submitButton2.HAlign        = 0.5f;
            this._submitButton2.VAlign        = 0.0f;
            this._submitButton2.OnMouseOver  += (UIElement.MouseEvent)((a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.85f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.White;
            });
            this._submitButton2.OnMouseOut += (UIElement.MouseEvent)((a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.72f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver;
            });
            this._submitButton2.Top.Pixels   = 50f;
            this._submitButton2.PaddingLeft  = 0.0f;
            this._submitButton2.PaddingRight = 0.0f;
            this.ValidateText();
            this._submitButton2.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText());
            this._submitButton2.OnMouseOut  += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText());
            this._submitButton2.OnClick     += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                string text = this.Text.Trim();
                if (text.Length <= 0 && !this._edittingSign && (!this._edittingChest && !this._allowEmpty))
                {
                    return;
                }
                Main.PlaySound(10, -1, -1, 1, 1f, 0.0f);
                this._submitAction(text);
            });
            this.outerLayer2.Append((UIElement)this._submitButton2);
            this._cancelButton2              = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.72f, true);
            this._cancelButton2.TextColor    = Color.Silver;
            this._cancelButton2.DrawPanel    = false;
            this._cancelButton2.OnMouseOver += (UIElement.MouseEvent)((a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.85f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.White;
            });
            this._cancelButton2.OnMouseOut += (UIElement.MouseEvent)((a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.72f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver;
            });
            this._cancelButton2.Height.Pixels = 60f;
            this._cancelButton2.Width.Precent = 0.4f;
            this._cancelButton2.Top.Pixels    = 114f;
            this._cancelButton2.VAlign        = 0.0f;
            this._cancelButton2.HAlign        = 0.5f;
            this._cancelButton2.OnClick      += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(11, -1, -1, 1, 1f, 0.0f);
                this._cancelAction();
            });
            this.outerLayer2.Append((UIElement)this._cancelButton2);
            UITextPanel <object> keyboardButton1 = this.CreateKeyboardButton((object)"", 8, 4, 2, true);

            keyboardButton1.OnClick += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                Main.PlaySound(12, -1, -1, 1, 1f, 0.0f);
                this._textBox.Backspace();
                this.ValidateText();
            });
            keyboardButton1.PaddingLeft  = 0.0f;
            keyboardButton1.PaddingRight = 0.0f;
            UITextPanel <object> uiTextPanel1 = keyboardButton1;
            UITextPanel <object> uiTextPanel2 = keyboardButton1;
            double num8 = 0.0;
            float  num9 = 0.0f;

            uiTextPanel2.PaddingTop = (float)num8;
            double num10 = (double)num9;

            uiTextPanel1.PaddingBottom = (float)num10;
            UIImage uiImage2 = new UIImage(this._textureBackspace);

            uiImage2.HAlign     = 0.5f;
            uiImage2.VAlign     = 0.5f;
            uiImage2.ImageScale = 0.92f;
            keyboardButton1.Append((UIElement)uiImage2);
            mainPanel.Append((UIElement)keyboardButton1);
            UIText uiText = new UIText(labelText, 0.75f, true);

            uiText.HAlign        = 0.5f;
            uiText.Width.Pixels  = num3;
            uiText.Top.Pixels    = (float)((double)num4 - 37.0 - 4.0) + maxValue + num1;
            uiText.Top.Precent   = num2;
            uiText.Height.Pixels = 37f;
            this.Append((UIElement)uiText);
            this._label = uiText;
            this.Append(element);
            this._textBox.SetTextMaxLength(this._edittingSign ? 99999 : 20);
            this.Text = startingText;
            if (this.Text.Length == 0)
            {
                this.SetKeyState(UIVirtualKeyboard.KeyState.Shift);
            }
            UIVirtualKeyboard.OffsetDown = 9999;
            this.UpdateOffsetDown();
        }
Exemplo n.º 2
0
 protected override void DrawSelf(SpriteBatch spriteBatch)
 {
     if (Main.gameMenu)
     {
         if (PlayerInput.UsingGamepad)
         {
             this.outerLayer2.Remove();
             if (!this.Elements.Contains(this.outerLayer1))
             {
                 this.Append(this.outerLayer1);
             }
             this.outerLayer1.Activate();
             this.outerLayer2.Deactivate();
             this.Recalculate();
             this.RecalculateChildren();
             if ((double)this._labelHeight != 0.0)
             {
                 this._textBox.Top.Pixels = this._textBoxHeight;
                 this._label.Top.Pixels   = this._labelHeight;
                 this._textBox.Recalculate();
                 this._label.Recalculate();
                 double num1 = 0.0;
                 float  num2 = 0.0f;
                 this._textBoxHeight = (float)num1;
                 this._labelHeight   = num2;
                 UserInterface.ActiveInstance.ResetLasts();
             }
         }
         else
         {
             this.outerLayer1.Remove();
             if (!this.Elements.Contains(this.outerLayer2))
             {
                 this.Append(this.outerLayer2);
             }
             this.outerLayer2.Activate();
             this.outerLayer1.Deactivate();
             this.Recalculate();
             this.RecalculateChildren();
             if ((double)this._textBoxHeight == 0.0)
             {
                 this._textBoxHeight       = this._textBox.Top.Pixels;
                 this._labelHeight         = this._label.Top.Pixels;
                 this._textBox.Top.Pixels += 50f;
                 this._label.Top.Pixels   += 50f;
                 this._textBox.Recalculate();
                 this._label.Recalculate();
                 UserInterface.ActiveInstance.ResetLasts();
             }
         }
     }
     if (!Main.editSign && this._edittingSign)
     {
         IngameFancyUI.Close();
     }
     else if (!Main.editChest && this._edittingChest)
     {
         IngameFancyUI.Close();
     }
     else
     {
         base.DrawSelf(spriteBatch);
         this.UpdateOffsetDown();
         UIVirtualKeyboard.OffsetDown = 0;
         this.SetupGamepadPoints(spriteBatch);
         PlayerInput.WritingText = true;
         string inputText = Main.GetInputText(this.Text);
         if (this._edittingSign && Main.inputTextEnter)
         {
             inputText += (string)(object)'\n';
         }
         else
         {
             if (this._edittingChest && Main.inputTextEnter)
             {
                 ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]);
                 IngameFancyUI.Close();
                 return;
             }
             if (Main.inputTextEnter && UIVirtualKeyboard.CanSubmit)
             {
                 UIVirtualKeyboard.Submit();
             }
             else if (Main.inputTextEscape)
             {
                 if (this._edittingSign)
                 {
                     Main.InputTextSignCancel();
                 }
                 if (this._edittingChest)
                 {
                     ChestUI.RenameChestCancel();
                 }
                 IngameFancyUI.Close();
                 return;
             }
         }
         if (IngameFancyUI.CanShowVirtualKeyboard(this._keyboardContext))
         {
             if (inputText != this.Text)
             {
                 this.Text = inputText;
             }
             if (this._edittingSign)
             {
                 this.CopyTextToSign();
             }
             if (this._edittingChest)
             {
                 this.CopyTextToChest();
             }
         }
         byte  num   = (byte)(((int)byte.MaxValue + (int)Main.tileColor.R * 2) / 3);
         Color color = new Color((int)num, (int)num, (int)num, (int)byte.MaxValue);
         this._textBox.TextColor = Color.Lerp(Color.White, color, 0.2f);
         this._label.TextColor   = Color.Lerp(Color.White, color, 0.2f);
     }
 }
Exemplo n.º 3
0
        // Token: 0x06001094 RID: 4244 RVA: 0x00404304 File Offset: 0x00402504
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            if (Main.gameMenu)
            {
                if (PlayerInput.UsingGamepad)
                {
                    this.outerLayer2.Remove();
                    if (!this.Elements.Contains(this.outerLayer1))
                    {
                        base.Append(this.outerLayer1);
                    }
                    this.outerLayer1.Activate();
                    this.outerLayer2.Deactivate();
                    this.Recalculate();
                    this.RecalculateChildren();
                    if (this._labelHeight != 0f)
                    {
                        this._textBox.Top.Pixels = this._textBoxHeight;
                        this._label.Top.Pixels   = this._labelHeight;
                        this._textBox.Recalculate();
                        this._label.Recalculate();
                        this._labelHeight = (this._textBoxHeight = 0f);
                        UserInterface.ActiveInstance.ResetLasts();
                    }
                }
                else
                {
                    this.outerLayer1.Remove();
                    if (!this.Elements.Contains(this.outerLayer2))
                    {
                        base.Append(this.outerLayer2);
                    }
                    this.outerLayer2.Activate();
                    this.outerLayer1.Deactivate();
                    this.Recalculate();
                    this.RecalculateChildren();
                    if (this._textBoxHeight == 0f)
                    {
                        this._textBoxHeight = this._textBox.Top.Pixels;
                        this._labelHeight   = this._label.Top.Pixels;
                        UITextBox expr_16C_cp_0_cp_0 = this._textBox;
                        expr_16C_cp_0_cp_0.Top.Pixels = expr_16C_cp_0_cp_0.Top.Pixels + 50f;
                        UIText expr_185_cp_0_cp_0 = this._label;
                        expr_185_cp_0_cp_0.Top.Pixels = expr_185_cp_0_cp_0.Top.Pixels + 50f;
                        this._textBox.Recalculate();
                        this._label.Recalculate();
                        UserInterface.ActiveInstance.ResetLasts();
                    }
                }
            }
            if (!Main.editSign && this._edittingSign)
            {
                IngameFancyUI.Close();
                return;
            }
            if (!Main.editChest && this._edittingChest)
            {
                IngameFancyUI.Close();
                return;
            }
            base.DrawSelf(spriteBatch);
            this.UpdateOffsetDown();
            UIVirtualKeyboard.OffsetDown = 0;
            this.SetupGamepadPoints(spriteBatch);
            PlayerInput.WritingText = true;
            Main.instance.HandleIME();
            Vector2 position = new Vector2((float)(Main.screenWidth / 2), (float)(this._textBox.GetDimensions().ToRectangle().Bottom + 32));

            Main.instance.DrawWindowsIMEPanel(position, 0.5f);
            string text = Main.GetInputText(this.Text);

            if (this._edittingSign && Main.inputTextEnter)
            {
                text += "\n";
            }
            else
            {
                if (this._edittingChest && Main.inputTextEnter)
                {
                    ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]);
                    IngameFancyUI.Close();
                    return;
                }
                if (Main.inputTextEnter && UIVirtualKeyboard.CanSubmit)
                {
                    UIVirtualKeyboard.Submit();
                }
                else if (Main.inputTextEscape)
                {
                    if (this._edittingSign)
                    {
                        Main.InputTextSignCancel();
                    }
                    if (this._edittingChest)
                    {
                        ChestUI.RenameChestCancel();
                    }
                    IngameFancyUI.Close();
                    return;
                }
            }
            if (IngameFancyUI.CanShowVirtualKeyboard(this._keyboardContext))
            {
                if (text != this.Text)
                {
                    this.Text = text;
                }
                if (this._edittingSign)
                {
                    this.CopyTextToSign();
                }
                if (this._edittingChest)
                {
                    this.CopyTextToChest();
                }
            }
            byte  b     = (byte)((255 + Main.tileColor.R * 2) / 3);
            Color value = new Color((int)b, (int)b, (int)b, 255);

            this._textBox.TextColor = Color.Lerp(Color.White, value, 0.2f);
            this._label.TextColor   = Color.Lerp(Color.White, value, 0.2f);
            position = new Vector2((float)(Main.screenWidth / 2), (float)(this._textBox.GetDimensions().ToRectangle().Bottom + 32));
            Main.instance.DrawWindowsIMEPanel(position, 0.5f);
        }
Exemplo n.º 4
0
        public UIVirtualKeyboard(string labelText, string startingText, KeyboardSubmitEvent submitAction, Action cancelAction, int inputMode = 0, bool allowEmpty = false)
        {
            _keyboardContext  = inputMode;
            _allowEmpty       = allowEmpty;
            OffsetDown        = 0;
            ShouldHideText    = false;
            _lastOffsetDown   = 0;
            _edittingSign     = _keyboardContext == 1;
            _edittingChest    = _keyboardContext == 2;
            _currentInstance  = this;
            _submitAction     = submitAction;
            _cancelAction     = cancelAction;
            _textureShift     = Main.Assets.Request <Texture2D>("Images/UI/VK_Shift", Main.content, (AssetRequestMode)1);
            _textureBackspace = Main.Assets.Request <Texture2D>("Images/UI/VK_Backspace", Main.content, (AssetRequestMode)1);
            Top.Pixels        = _lastOffsetDown;
            float num  = 0.5f;
            float num2 = -20f;
            float num3 = -5000 * _edittingSign.ToInt();

            num2 = 270f;
            num  = 0f;
            float     num4      = 516f;
            UIElement uIElement = new UIElement();

            uIElement.Width.Pixels  = num4 + 8f + 16f;
            uIElement.Top.Precent   = num;
            uIElement.Top.Pixels    = num2;
            uIElement.Height.Pixels = 266f;
            uIElement.HAlign        = 0.5f;
            uIElement.SetPadding(0f);
            outerLayer1 = uIElement;
            UIElement uIElement2 = new UIElement();

            uIElement2.Width.Pixels  = num4 + 8f + 16f;
            uIElement2.Top.Precent   = num;
            uIElement2.Top.Pixels    = num2;
            uIElement2.Height.Pixels = 266f;
            uIElement2.HAlign        = 0.5f;
            uIElement2.SetPadding(0f);
            outerLayer2 = uIElement2;
            UIPanel uIPanel = new UIPanel
            {
                Width =
                {
                    Precent = 1f
                },
                Height =
                {
                    Pixels = 225f
                },
                BackgroundColor = new Color(23, 33, 69) * 0.7f
            };

            uIElement.Append(uIPanel);
            float num5 = -50f;

            _textBox = new UITextBox("", 0.78f, large: true);
            _textBox.BackgroundColor = Color.Transparent;
            _textBox.BorderColor     = Color.Transparent;
            _textBox.HAlign          = 0.5f;
            _textBox.Width.Pixels    = num4;
            _textBox.Top.Pixels      = num5 + num2 - 10f + num3;
            _textBox.Top.Precent     = num;
            _textBox.Height.Pixels   = 37f;
            Append(_textBox);
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    int index = j * 10 + i;
                    UITextPanel <object> uITextPanel = CreateKeyboardButton("1234567890qwertyuiopasdfghjkl'zxcvbnm,.?"[index].ToString(), i, j);
                    uITextPanel.OnClick += TypeText;
                    uIPanel.Append(uITextPanel);
                }
            }
            _shiftButton                 = CreateKeyboardButton("", 0, 4, 1, style: false);
            _shiftButton.PaddingLeft     = 0f;
            _shiftButton.PaddingRight    = 0f;
            _shiftButton.PaddingBottom   = (_shiftButton.PaddingTop = 0f);
            _shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            _shiftButton.BorderColor     = _internalBorderColor * 0.7f;
            _shiftButton.OnMouseOver    += delegate
            {
                _shiftButton.BorderColor = _internalBorderColorSelected;
                if (_keyState != KeyState.Shift)
                {
                    _shiftButton.BackgroundColor = new Color(73, 94, 171);
                }
            };
            _shiftButton.OnMouseOut += delegate
            {
                _shiftButton.BorderColor = _internalBorderColor * 0.7f;
                if (_keyState != KeyState.Shift)
                {
                    _shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
                }
            };
            _shiftButton.OnClick += delegate
            {
                SoundEngine.PlaySound(12);
                SetKeyState((_keyState != KeyState.Shift) ? KeyState.Shift : KeyState.Default);
            };
            UIImage element = new UIImage(_textureShift)
            {
                HAlign     = 0.5f,
                VAlign     = 0.5f,
                ImageScale = 0.85f
            };

            _shiftButton.Append(element);
            uIPanel.Append(_shiftButton);
            _symbolButton                 = CreateKeyboardButton("@%", 1, 4, 1, style: false);
            _symbolButton.PaddingLeft     = 0f;
            _symbolButton.PaddingRight    = 0f;
            _symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            _symbolButton.BorderColor     = _internalBorderColor * 0.7f;
            _symbolButton.OnMouseOver    += delegate
            {
                _symbolButton.BorderColor = _internalBorderColorSelected;
                if (_keyState != KeyState.Symbol)
                {
                    _symbolButton.BackgroundColor = new Color(73, 94, 171);
                }
            };
            _symbolButton.OnMouseOut += delegate
            {
                _symbolButton.BorderColor = _internalBorderColor * 0.7f;
                if (_keyState != KeyState.Symbol)
                {
                    _symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
                }
            };
            _symbolButton.OnClick += delegate
            {
                SoundEngine.PlaySound(12);
                SetKeyState((_keyState != KeyState.Symbol) ? KeyState.Symbol : KeyState.Default);
            };
            uIPanel.Append(_symbolButton);
            BuildSpaceBarArea(uIPanel);
            _submitButton = new UITextPanel <LocalizedText>((_edittingSign || _edittingChest) ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.4f, large: true);
            _submitButton.Height.Pixels = 37f;
            _submitButton.Width.Precent = 0.4f;
            _submitButton.HAlign        = 1f;
            _submitButton.VAlign        = 1f;
            _submitButton.PaddingLeft   = 0f;
            _submitButton.PaddingRight  = 0f;
            ValidateText();
            _submitButton.OnMouseOver += FadedMouseOver;
            _submitButton.OnMouseOut  += FadedMouseOut;
            _submitButton.OnMouseOver += delegate
            {
                ValidateText();
            };
            _submitButton.OnMouseOut += delegate
            {
                ValidateText();
            };
            _submitButton.OnClick += delegate
            {
                Submit();
            };
            uIElement.Append(_submitButton);
            _cancelButton = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.4f, large: true);
            StyleKey(_cancelButton, external: true);
            _cancelButton.Height.Pixels = 37f;
            _cancelButton.Width.Precent = 0.4f;
            _cancelButton.VAlign        = 1f;
            _cancelButton.OnClick      += delegate
            {
                SoundEngine.PlaySound(11);
                _cancelAction();
            };
            _cancelButton.OnMouseOver += FadedMouseOver;
            _cancelButton.OnMouseOut  += FadedMouseOut;
            uIElement.Append(_cancelButton);
            _submitButton2               = new UITextPanel <LocalizedText>((_edittingSign || _edittingChest) ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.72f, large: true);
            _submitButton2.TextColor     = Color.Silver;
            _submitButton2.DrawPanel     = false;
            _submitButton2.Height.Pixels = 60f;
            _submitButton2.Width.Precent = 0.4f;
            _submitButton2.HAlign        = 0.5f;
            _submitButton2.VAlign        = 0f;
            _submitButton2.OnMouseOver  += delegate(UIMouseEvent a, UIElement b)
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.85f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.White;
            };
            _submitButton2.OnMouseOut += delegate(UIMouseEvent a, UIElement b)
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.72f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver;
            };
            _submitButton2.Top.Pixels   = 50f;
            _submitButton2.PaddingLeft  = 0f;
            _submitButton2.PaddingRight = 0f;
            ValidateText();
            _submitButton2.OnMouseOver += delegate
            {
                ValidateText();
            };
            _submitButton2.OnMouseOut += delegate
            {
                ValidateText();
            };
            _submitButton2.OnMouseOver += FadedMouseOver;
            _submitButton2.OnMouseOut  += FadedMouseOut;
            _submitButton2.OnClick     += delegate
            {
                string text = Text.Trim();
                if (text.Length > 0 || _edittingSign || _edittingChest || _allowEmpty)
                {
                    SoundEngine.PlaySound(10);
                    _submitAction(text);
                }
            };
            outerLayer2.Append(_submitButton2);
            _cancelButton2              = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.72f, large: true);
            _cancelButton2.TextColor    = Color.Silver;
            _cancelButton2.DrawPanel    = false;
            _cancelButton2.OnMouseOver += delegate(UIMouseEvent a, UIElement b)
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.85f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.White;
            };
            _cancelButton2.OnMouseOut += delegate(UIMouseEvent a, UIElement b)
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.72f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver;
            };
            _cancelButton2.Height.Pixels = 60f;
            _cancelButton2.Width.Precent = 0.4f;
            _cancelButton2.Top.Pixels    = 114f;
            _cancelButton2.VAlign        = 0f;
            _cancelButton2.HAlign        = 0.5f;
            _cancelButton2.OnClick      += delegate
            {
                SoundEngine.PlaySound(11);
                _cancelAction();
            };
            outerLayer2.Append(_cancelButton2);
            UITextPanel <object> uITextPanel2 = CreateKeyboardButton("", 8, 4, 2);

            uITextPanel2.OnClick += delegate
            {
                SoundEngine.PlaySound(12);
                _textBox.Backspace();
                ValidateText();
            };
            uITextPanel2.PaddingLeft   = 0f;
            uITextPanel2.PaddingRight  = 0f;
            uITextPanel2.PaddingBottom = (uITextPanel2.PaddingTop = 0f);
            uITextPanel2.Append(new UIImage(_textureBackspace)
            {
                HAlign     = 0.5f,
                VAlign     = 0.5f,
                ImageScale = 0.92f
            });
            uIPanel.Append(uITextPanel2);
            UIText uIText = new UIText(labelText, 0.75f, large: true)
            {
                HAlign = 0.5f,
                Width  =
                {
                    Pixels = num4
                },
                Top =
                {
                    Pixels  = num5 - 37f - 4f + num2 + num3,
                    Precent = num
                },
                Height =
                {
                    Pixels = 37f
                }
            };

            Append(uIText);
            _label = uIText;
            Append(uIElement);
            int textMaxLength = (_edittingSign ? 1200 : 20);

            _textBox.SetTextMaxLength(textMaxLength);
            Text = startingText;
            if (Text.Length == 0)
            {
                SetKeyState(KeyState.Shift);
            }
            ShouldHideText = true;
            OffsetDown     = 9999;
            UpdateOffsetDown();
        }
Exemplo n.º 5
0
 protected override void DrawSelf(SpriteBatch spriteBatch)
 {
     if (Main.gameMenu)
     {
         if (PlayerInput.UsingGamepad)
         {
             this.outerLayer2.Remove();
             if (!this.Elements.Contains(this.outerLayer1))
             {
                 this.Append(this.outerLayer1);
             }
             this.outerLayer1.Activate();
             this.outerLayer2.Deactivate();
             this.Recalculate();
             this.RecalculateChildren();
             if ((double)this._labelHeight != 0.0)
             {
                 this._textBox.Top.Pixels = this._textBoxHeight;
                 this._label.Top.Pixels   = this._labelHeight;
                 this._textBox.Recalculate();
                 this._label.Recalculate();
                 this._labelHeight = this._textBoxHeight = 0.0f;
                 UserInterface.ActiveInstance.ResetLasts();
             }
         }
         else
         {
             this.outerLayer1.Remove();
             if (!this.Elements.Contains(this.outerLayer2))
             {
                 this.Append(this.outerLayer2);
             }
             this.outerLayer2.Activate();
             this.outerLayer1.Deactivate();
             this.Recalculate();
             this.RecalculateChildren();
             if ((double)this._textBoxHeight == 0.0)
             {
                 this._textBoxHeight       = this._textBox.Top.Pixels;
                 this._labelHeight         = this._label.Top.Pixels;
                 this._textBox.Top.Pixels += 50f;
                 this._label.Top.Pixels   += 50f;
                 this._textBox.Recalculate();
                 this._label.Recalculate();
                 UserInterface.ActiveInstance.ResetLasts();
             }
         }
     }
     if (!Main.editSign && this._edittingSign)
     {
         IngameFancyUI.Close();
     }
     else if (!Main.editChest && this._edittingChest)
     {
         IngameFancyUI.Close();
     }
     else
     {
         base.DrawSelf(spriteBatch);
         this.UpdateOffsetDown();
         UIVirtualKeyboard.OffsetDown = 0;
         this.SetupGamepadPoints(spriteBatch);
         PlayerInput.WritingText = true;
         Main.instance.HandleIME();
         Vector2 position;
         // ISSUE: explicit reference operation
         // ISSUE: variable of a reference type
         Vector2&  local1     = @position;
         double    num1       = (double)(Main.screenWidth / 2);
         Rectangle rectangle1 = this._textBox.GetDimensions().ToRectangle();
         // ISSUE: explicit reference operation
         double num2 = (double)(((Rectangle)@rectangle1).get_Bottom() + 32);
         ((Vector2)local1).\u002Ector((float)num1, (float)num2);
         Main.instance.DrawWindowsIMEPanel(position, 0.5f);
         string inputText = Main.GetInputText(this.Text);
         if (this._edittingSign && Main.inputTextEnter)
         {
             inputText += (string)(object)'\n';
         }
         else
         {
             if (this._edittingChest && Main.inputTextEnter)
             {
                 ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]);
                 IngameFancyUI.Close();
                 return;
             }
             if (Main.inputTextEnter && UIVirtualKeyboard.CanSubmit)
             {
                 UIVirtualKeyboard.Submit();
             }
             else if (Main.inputTextEscape)
             {
                 if (this._edittingSign)
                 {
                     Main.InputTextSignCancel();
                 }
                 if (this._edittingChest)
                 {
                     ChestUI.RenameChestCancel();
                 }
                 IngameFancyUI.Close();
                 return;
             }
         }
         if (IngameFancyUI.CanShowVirtualKeyboard(this._keyboardContext))
         {
             if (inputText != this.Text)
             {
                 this.Text = inputText;
             }
             if (this._edittingSign)
             {
                 this.CopyTextToSign();
             }
             if (this._edittingChest)
             {
                 this.CopyTextToChest();
             }
         }
         // ISSUE: explicit reference operation
         byte  num3 = (byte)(((int)byte.MaxValue + (int)((Color)@Main.tileColor).get_R() * 2) / 3);
         Color color;
         // ISSUE: explicit reference operation
         ((Color)@color).\u002Ector((int)num3, (int)num3, (int)num3, (int)byte.MaxValue);
         this._textBox.TextColor = Color.Lerp(Color.get_White(), color, 0.2f);
         this._label.TextColor   = Color.Lerp(Color.get_White(), color, 0.2f);
         // ISSUE: explicit reference operation
         // ISSUE: variable of a reference type
         Vector2&  local2     = @position;
         double    num4       = (double)(Main.screenWidth / 2);
         Rectangle rectangle2 = this._textBox.GetDimensions().ToRectangle();
         // ISSUE: explicit reference operation
         double num5 = (double)(((Rectangle)@rectangle2).get_Bottom() + 32);
         ((Vector2)local2).\u002Ector((float)num4, (float)num5);
         Main.instance.DrawWindowsIMEPanel(position, 0.5f);
     }
 }