Ejemplo n.º 1
0
        public static KeyBinding Parse(string value)
        {
            if (value == "none")
            {
                return(Empty);
            }

            var keys         = new List <DoomKey>();
            var mouseButtons = new List <DoomMouseButton>();

            var split = value.Split(',').Select(x => x.Trim());

            foreach (var s in split)
            {
                var key = DoomKeyEx.Parse(s);
                if (key != DoomKey.Unknown)
                {
                    keys.Add(key);
                    continue;
                }

                var mouseButton = DoomMouseButtonEx.Parse(s);
                if (mouseButton != DoomMouseButton.Unknown)
                {
                    mouseButtons.Add(mouseButton);
                }
            }

            return(new KeyBinding(keys, mouseButtons));
        }
Ejemplo n.º 2
0
        public override string ToString()
        {
            var keyValues   = keys.Select(key => DoomKeyEx.ToString(key));
            var mouseValues = mouseButtons.Select(button => DoomMouseButtonEx.ToString(button));
            var values      = keyValues.Concat(mouseValues).ToArray();

            if (values.Length > 0)
            {
                return(string.Join(", ", values));
            }
            else
            {
                return("none");
            }
        }