コード例 #1
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();
        }
コード例 #2
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  = (float)((double)num3 + 8.0 + 16.0);
            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  = (float)((double)num3 + 8.0 + 16.0);
            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 = -79f;

            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      = (float)((double)num4 + (double)maxValue - 10.0) + 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;
            this._shiftButton.PaddingBottom   = this._shiftButton.PaddingTop = 0.0f;
            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;
            keyboardButton1.PaddingBottom = keyboardButton1.PaddingTop = 0.0f;
            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();
        }
コード例 #3
0
        // Token: 0x0600108C RID: 4236 RVA: 0x004033E4 File Offset: 0x004015E4
        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     num       = (float)(-5000 * this._edittingSign.ToInt());
            float     num2      = 255f;
            float     precent   = 0f;
            float     num3      = 516f;
            UIElement uIElement = new UIElement();

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

            uIElement2.Width.Pixels  = num3 + 8f + 16f;
            uIElement2.Top.Precent   = precent;
            uIElement2.Top.Pixels    = num2;
            uIElement2.Height.Pixels = 266f;
            uIElement2.HAlign        = 0.5f;
            uIElement2.SetPadding(0f);
            this.outerLayer2 = uIElement2;
            UIPanel uIPanel = new UIPanel();

            uIPanel.Width.Precent   = 1f;
            uIPanel.Height.Pixels   = 225f;
            uIPanel.BackgroundColor = new Color(23, 33, 69) * 0.7f;
            uIElement.Append(uIPanel);
            float num4 = -79f;

            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      = num4 + num2 - 10f + num;
            this._textBox.Top.Precent     = precent;
            this._textBox.Height.Pixels   = 37f;
            base.Append(this._textBox);
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    int index = j * 10 + i;
                    UITextPanel <object> uITextPanel = this.CreateKeyboardButton("1234567890qwertyuiopasdfghjkl'zxcvbnm,.?"[index].ToString(), i, j, 1, true);
                    uITextPanel.OnClick += new UIElement.MouseEvent(this.TypeText);
                    uIPanel.Append(uITextPanel);
                }
            }
            this._shiftButton                 = this.CreateKeyboardButton("", 0, 4, 1, false);
            this._shiftButton.PaddingLeft     = 0f;
            this._shiftButton.PaddingRight    = 0f;
            this._shiftButton.PaddingBottom   = (this._shiftButton.PaddingTop = 0f);
            this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            this._shiftButton.BorderColor     = this._internalBorderColor * 0.7f;
            this._shiftButton.OnMouseOver    += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                this._shiftButton.BorderColor = this._internalBorderColorSelected;
                if (this._keyState != UIVirtualKeyboard.KeyState.Shift)
                {
                    this._shiftButton.BackgroundColor = new Color(73, 94, 171);
                }
            };
            this._shiftButton.OnMouseOut += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                this._shiftButton.BorderColor = this._internalBorderColor * 0.7f;
                if (this._keyState != UIVirtualKeyboard.KeyState.Shift)
                {
                    this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
                }
            };
            this._shiftButton.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                this.SetKeyState((this._keyState == UIVirtualKeyboard.KeyState.Shift) ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Shift);
            };
            UIImage uIImage = new UIImage(this._textureShift);

            uIImage.HAlign     = 0.5f;
            uIImage.VAlign     = 0.5f;
            uIImage.ImageScale = 0.85f;
            this._shiftButton.Append(uIImage);
            uIPanel.Append(this._shiftButton);
            this._symbolButton                 = this.CreateKeyboardButton("@%", 1, 4, 1, false);
            this._symbolButton.PaddingLeft     = 0f;
            this._symbolButton.PaddingRight    = 0f;
            this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
            this._symbolButton.BorderColor     = this._internalBorderColor * 0.7f;
            this._symbolButton.OnMouseOver    += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                this._symbolButton.BorderColor = this._internalBorderColorSelected;
                if (this._keyState != UIVirtualKeyboard.KeyState.Symbol)
                {
                    this._symbolButton.BackgroundColor = new Color(73, 94, 171);
                }
            };
            this._symbolButton.OnMouseOut += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                this._symbolButton.BorderColor = this._internalBorderColor * 0.7f;
                if (this._keyState != UIVirtualKeyboard.KeyState.Symbol)
                {
                    this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
                }
            };
            this._symbolButton.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                this.SetKeyState((this._keyState == UIVirtualKeyboard.KeyState.Symbol) ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Symbol);
            };
            uIPanel.Append(this._symbolButton);
            this.BuildSpaceBarArea(uIPanel);
            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   = 0f;
            this._submitButton.PaddingRight  = 0f;
            this.ValidateText();
            this._submitButton.OnMouseOver += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                this.ValidateText();
            };
            this._submitButton.OnMouseOut += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                this.ValidateText();
            };
            this._submitButton.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                string text = this.Text.Trim();
                if (text.Length > 0 || this._edittingSign || this._edittingChest || this._allowEmpty)
                {
                    Main.PlaySound(10, -1, -1, 1, 1f, 0f);
                    this._submitAction(text);
                }
            };
            uIElement.Append(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      += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                Main.PlaySound(11, -1, -1, 1, 1f, 0f);
                this._cancelAction();
            };
            uIElement.Append(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        = 0f;
            UIElement arg_750_0 = this._submitButton2;

            arg_750_0.OnMouseOver += (a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.85f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.White;
            };
            UIElement arg_77A_0 = this._submitButton2;

            arg_77A_0.OnMouseOut += (a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.72f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver;
            };
            this._submitButton2.Top.Pixels   = 50f;
            this._submitButton2.PaddingLeft  = 0f;
            this._submitButton2.PaddingRight = 0f;
            this.ValidateText();
            this._submitButton2.OnMouseOver += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                this.ValidateText();
            };
            this._submitButton2.OnMouseOut += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                this.ValidateText();
            };
            this._submitButton2.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                string text = this.Text.Trim();
                if (text.Length > 0 || this._edittingSign || this._edittingChest || this._allowEmpty)
                {
                    Main.PlaySound(10, -1, -1, 1, 1f, 0f);
                    this._submitAction(text);
                }
            };
            this.outerLayer2.Append(this._submitButton2);
            this._cancelButton2           = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.72f, true);
            this._cancelButton2.TextColor = Color.Silver;
            this._cancelButton2.DrawPanel = false;
            UIElement arg_86C_0 = this._cancelButton2;

            arg_86C_0.OnMouseOver += (a, b) =>
            {
                ((UITextPanel <LocalizedText>)b).TextScale = 0.85f;
                ((UITextPanel <LocalizedText>)b).TextColor = Color.White;
            };
            UIElement arg_896_0 = this._cancelButton2;

            arg_896_0.OnMouseOut += (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        = 0f;
            this._cancelButton2.HAlign        = 0.5f;
            this._cancelButton2.OnClick      += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                Main.PlaySound(11, -1, -1, 1, 1f, 0f);
                this._cancelAction();
            };
            this.outerLayer2.Append(this._cancelButton2);
            UITextPanel <object> uITextPanel2 = this.CreateKeyboardButton("", 8, 4, 2, true);

            uITextPanel2.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement)
            {
                Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                this._textBox.Backspace();
                this.ValidateText();
            };
            uITextPanel2.PaddingLeft   = 0f;
            uITextPanel2.PaddingRight  = 0f;
            uITextPanel2.PaddingBottom = (uITextPanel2.PaddingTop = 0f);
            uITextPanel2.Append(new UIImage(this._textureBackspace)
            {
                HAlign     = 0.5f,
                VAlign     = 0.5f,
                ImageScale = 0.92f
            });
            uIPanel.Append(uITextPanel2);
            UIText uIText = new UIText(labelText, 0.75f, true);

            uIText.HAlign        = 0.5f;
            uIText.Width.Pixels  = num3;
            uIText.Top.Pixels    = num4 - 37f - 4f + num2 + num;
            uIText.Top.Precent   = precent;
            uIText.Height.Pixels = 37f;
            base.Append(uIText);
            this._label = uIText;
            base.Append(uIElement);
            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();
        }