Exemplo n.º 1
0
 // Check if the list is from an older version that uses modifiers instead of actual keys (causes problems with current input code)
 private static bool MappingListOutdated(ActionMappingList testlist)
 {
     foreach (ActionKeyMapping action in testlist.ActionKeyMappings)
     {
         if (action.MainKey == Keys.Control || action.AltKey == Keys.Control || action.Modifiers == Keys.Control)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 2
0
        private static ActionMappingList CreateMappingList(ActionKeyMapping[] defaultKeyMappings)
        {
            ActionMappingList mappingList = new ActionMappingList();

            mappingList.ActionKeyMappings = new List <ActionKeyMapping>();

            foreach (ActionKeyMapping defaultMapping in defaultKeyMappings)
            {
                mappingList.ActionKeyMappings.Add(defaultMapping);
            }

            return(mappingList);
        }
Exemplo n.º 3
0
        public static ActionMappingList Load(string path, ActionKeyMapping[] defaultKeyMappings)
        {
            if (File.Exists(path))
            {
                return(IniSerializer.Deserialize <ActionMappingList>(path));
            }
            else
            {
                ActionMappingList mappingList = new ActionMappingList();
                mappingList.ActionKeyMappings = new List <ActionKeyMapping>();

                foreach (ActionKeyMapping defaultMapping in defaultKeyMappings)
                {
                    mappingList.ActionKeyMappings.Add(defaultMapping);
                }

                return(mappingList);
            }
        }
Exemplo n.º 4
0
        public static ActionMappingList Load(string path, ActionKeyMapping[] defaultKeyMappings)
        {
            ActionMappingList result = new ActionMappingList();

            if (File.Exists(path))
            {
                ActionMappingList testlist = IniSerializer.Deserialize <ActionMappingList>(path);
                if (MappingListOutdated(testlist))
                {
                    result = CreateMappingList(defaultKeyMappings);
                }
                else
                {
                    result = testlist;
                }

                // Check if new actions were added to the default list
                foreach (ActionKeyMapping map_def in defaultKeyMappings)
                {
                    bool found = false;
                    foreach (ActionKeyMapping map_act in result.ActionKeyMappings)
                    {
                        if (map_act.Name == map_def.Name)
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        result.ActionKeyMappings.Add(map_def);
                    }
                }
                return(result);
            }
            else
            {
                return(CreateMappingList(defaultKeyMappings));
            }
        }