예제 #1
0
        static void BindHotkeyPref(KeyValuePair<string, string> kv, KeySettings ks, Widget template, Widget parent)
        {
            var key = template.Clone() as Widget;
            key.Id = kv.Key;
            key.IsVisible = () => true;

            var field = ks.GetType().GetField(kv.Key);
            if (field == null)
                throw new InvalidOperationException("Game.Settings.Keys does not contain {1}".F(kv.Key));

            key.Get<LabelWidget>("FUNCTION").GetText = () => kv.Value + ":";

            var textBox = key.Get<HotkeyEntryWidget>("HOTKEY");
            textBox.Key = (Hotkey)field.GetValue(ks);
            textBox.OnLoseFocus = () =>	field.SetValue(ks, textBox.Key);
            parent.AddChild(key);
        }
예제 #2
0
        Action ResetInputPanel(Widget panel)
        {
            var gs = Game.Settings.Game;
            var ks = Game.Settings.Keys;
            var dgs = new GameSettings();
            var dks = new KeySettings();

            return () =>
            {
                gs.UseClassicMouseStyle = dgs.UseClassicMouseStyle;
                gs.MouseScroll = dgs.MouseScroll;
                gs.ViewportEdgeScroll = dgs.ViewportEdgeScroll;
                gs.ViewportEdgeScrollStep = dgs.ViewportEdgeScrollStep;
                gs.UIScrollSpeed = dgs.UIScrollSpeed;

                foreach (var f in ks.GetType().GetFields())
                {
                    var value = (Hotkey)f.GetValue(dks);
                    f.SetValue(ks, value);
                    panel.Get(f.Name).Get<HotkeyEntryWidget>("HOTKEY").Key = value;
                }

                panel.Get<SliderWidget>("SCROLLSPEED_SLIDER").Value = gs.ViewportEdgeScrollStep;
                panel.Get<SliderWidget>("UI_SCROLLSPEED_SLIDER").Value = gs.UIScrollSpeed;
            };
        }