コード例 #1
0
        public static IConfigurationTemplate FromJsonProtoTemplate(IDictionary<string, dynamic> protoTemplate, EmulatorBridge bridge)
        {
            var booleanMapping = new BooleanMapping((string)protoTemplate["boolean"]["true"], (string)protoTemplate["boolean"]["false"]);
            var entries = new List<IConfigurationEntry>();
            string fileName = protoTemplate["filename"];
            string configName = protoTemplate["templateid"];
            string stringTemplate = bridge.GetStringResource($"{configName}.template");
            IDictionary<string, dynamic> defaults = new Dictionary<string, dynamic>();

            foreach (var value in protoTemplate["keys"])
            {
                entries.Add(new ConfigurationEntry((string)value.Value.description, (string)value.Name, (object)value.Value.defaultValue.Value));
            }

            return new ConfigurationTemplate(stringTemplate, entries, booleanMapping, fileName, configName);
        }
コード例 #2
0
ファイル: InputTemplate.cs プロジェクト: faint32/snowflake-1
        public static IInputTemplate FromJsonProtoTemplate(IDictionary<string, dynamic> protoTemplate, EmulatorBridge bridge)
        {
            IList<string> templateKeys = protoTemplate["templatekeys"].ToObject<IList<string>>();
            string nobind = protoTemplate["nobind"];
            string name = protoTemplate["name"];
            string template = bridge.GetStringResource($"{name}.template");
            IDictionary<string, IGamepadMapping> gamepadMappings = new Dictionary<string, IGamepadMapping>();
            IDictionary<string, IKeyboardMapping> keyboardMappings = new Dictionary<string, IKeyboardMapping>();

            foreach(var gamepadMapping in protoTemplate["gamepad"])
            {
                gamepadMappings.Add(gamepadMapping.Name, (IGamepadMapping)new GamepadMapping(gamepadMapping.Value.ToObject<IDictionary<string, string>>()));
            }
            foreach (var keyboardMapping in protoTemplate["keyboard"])
            {
                 keyboardMappings.Add(keyboardMapping.Name, (IKeyboardMapping)new KeyboardMapping(keyboardMapping.Value.ToObject<IDictionary<string, string>>()));
            }

            return new InputTemplate(name, template, templateKeys, nobind, gamepadMappings, keyboardMappings);
        }