about summary refs log tree commit diff stats
path: root/data/maps/the_revitalized/rooms/Too Room.txtpb
blob: 819c3cfbb26f26c2032e15b37ba76c9c92f2f2a0 (plain) (blame)
1
2
3
4
5
6
7
8
name: "Too Room"
panels {
  name: "TOO"
  path: "Panels/panel_6"
  clue: "too"
  answer: "two"
  symbols: ZERO
}
ghlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using AnodyneSharp.Input;
using AnodyneSharp.Sounds;
using AnodyneSharp.States;
using AnodyneSharp.UI;
using Microsoft.Xna.Framework;

namespace AnodyneArchipelago.Menu
{
    internal class TextEntry : State
    {
        public delegate void CommitChange(string value);

        private readonly string _header;
        private readonly CommitChange _commitFunc;

        private string _value;

        private UILabel _headerLabel;
        private UILabel _valueLabel;
        private UIEntity _bgBox;

        public TextEntry(string header, string value, CommitChange commitFunc)
        {
            _header = header;
            _value = value;
            _commitFunc = commitFunc;

            _headerLabel = new(new Vector2(20f, 44f), false, _header, new Color(226, 226, 226), AnodyneSharp.Drawing.DrawOrder.TEXT);
            _valueLabel = new(new Vector2(20f, 52f), false, "", new Color(), AnodyneSharp.Drawing.DrawOrder.TEXT);
            _bgBox = new UIEntity(new Vector2(16f, 40f), "pop_menu", 16, 16, AnodyneSharp.Drawing.DrawOrder.TEXTBOX);

            UpdateDisplay();
        }

        public override void Update()
        {
            string inputtedCharacter = InputHandler.ReturnCharacter();
            if (inputtedCharacter.Length > 0)
            {
                _value += inputtedCharacter;
                UpdateDisplay();
            }
            else if (KeyInput.JustPressedKey(Microsoft.Xna.Framework.Input.Keys.Back))
            {
                if (_value.Length > 0)
                {
                    _value = _value.Substring(0, _value.Length - 1);
                    UpdateDisplay();
                }
            }
            else if (KeyInput.JustPressedKey(Microsoft.Xna.Framework.Input.Keys.Escape) || (KeyInput.ControllerMode && KeyInput.JustPressedRebindableKey(KeyFunctions.Cancel)))
            {
                SoundManager.PlaySoundEffect("menu_select");
                this.Exit = true;
            }
            else if (KeyInput.JustPressedKey(Microsoft.Xna.Framework.Input.Keys.Enter) || (KeyInput.ControllerMode && KeyInput.JustPressedRebindableKey(KeyFunctions.Accept)))
            {
                SoundManager.PlaySoundEffect("menu_select");
                _commitFunc(_value);
                this.Exit = true;
            }
        }

        public override void DrawUI()
        {
            _bgBox.Draw();
            _headerLabel.Draw();
            _valueLabel.Draw();
        }

        private void UpdateDisplay()
        {
            if (_value.Length == 0)
            {
                _valueLabel.SetText("[empty]");
                _valueLabel.Color = new Color(116, 140, 144);
            }
            else
            {
                string finalText = "";
                string tempText = _value;

                while (tempText.Length > 18)
                {
                    finalText += tempText.Substring(0, 18);
                    finalText += "\n";
                    tempText = tempText.Substring(18);
                }

                finalText += tempText;

                _valueLabel.SetText(finalText);
                _valueLabel.Color = new Color(184, 32, 0);
            }

            float innerHeight = 8f + _valueLabel.Writer.TotalTextHeight();

            _bgBox = new UIEntity(new Vector2(16f, 40f), "pop_menu", 136, (int)innerHeight + 8, AnodyneSharp.Drawing.DrawOrder.TEXTBOX);
        }
    }
}