private void boxOnClick(UIMouseEvent evt, UIElement listeningElement)
        {
            storedVar.Set(!storedVar.storedBool);

            booleanSetting.BackgroundColor = UIColour.darkBackgroundColour;
            booleanSetting.BorderColor     = UIColour.lightborderColour;
            Main.PlaySound(Terraria.ID.SoundID.Unlock);
        }
Example #2
0
        /// <summary>
        /// Use to cancel
        /// </summary>
        internal void SetValueFromText()
        {
            // Shouldn't even do anything if not focussed in
            if (!Focus)
            {
                return;
            }

            Focus           = false;
            Main.hasFocus   = false;
            Main.blockInput = false;

            numberBox.BorderColor     = _defaultBorder;
            numberBox.BackgroundColor = _defaultBackground;
            Main.PlaySound(Terraria.ID.SoundID.MenuClose);

            if (numberBox.Text.Length == 0 || numberBox.Text == "-")
            {
                numberBox.SetText("0");
            }
            if (storedVar.IsWholeNumbers)
            {
                long parsedValue = (long)storedVar.storedValue;
                if (long.TryParse(numberBox.Text, out parsedValue))
                {
                    if ((long)storedVar.storedValue != parsedValue)
                    {
                        storedVar.Set(parsedValue);                                             // SET
                    }
                }
            }
            else if (storedVar.IsDecimalNumbers)
            {
                double parsedValue = (double)storedVar.storedValue;
                if (double.TryParse(numberBox.Text, out parsedValue))
                {
                    if (storedVar.storedValue != parsedValue)
                    {
                        storedVar.Set(parsedValue);                                       // SET
                    }
                }
            }
        }