예제 #1
0
        // Save keybind for a single mod to config file.
        public static void SaveModBinds(Mod mod)
        {
            KeybindList list = new KeybindList();
            string      path =
                Path.Combine(ModLoader.GetModSettingsFolder(mod), "keybinds.json");

            Keybind[] binds = Keybind.Get(mod).ToArray();
            for (int i = 0; i < binds.Length; i++)
            {
                if (binds[i].ID == null || binds[i].Vals != null)
                {
                    continue;
                }
                Keybinds keybinds = new Keybinds {
                    ID       = binds[i].ID, Key = binds[i].Key,
                    Modifier = binds[i].Modifier
                };

                list.keybinds.Add(keybinds);
            }

            string serializedData = JsonConvert.SerializeObject(list, Formatting.Indented);

            File.WriteAllText(path, serializedData);
        }
예제 #2
0
        // Save keybind for a single mod to config file.
        public static void SaveModBinds(Mod mod)
        {
            KeybindList list = new KeybindList();

            foreach (Keybind bind in Keybind.Get(mod))
            {
                if (bind.ID == null || bind.Vals != null)
                {
                    continue;
                }

                Keybinds keybinds = new Keybinds
                {
                    ID       = bind.ID,
                    Key      = bind.Key,
                    Modifier = bind.Modifier
                };

                list.keybinds.Add(keybinds);
            }

            if (list.keybinds.Count > 0)
            {
                File.WriteAllText(Path.Combine(ModLoader.GetModSettingsFolder(mod), "keybinds.json"), Newtonsoft.Json.JsonConvert.SerializeObject(list, Newtonsoft.Json.Formatting.Indented));
            }
        }
예제 #3
0
        // Save keybind for a single mod to config file.
        public static void SaveModBinds(Mod mod)
        {
            KeybindList list = new KeybindList();
            string      path = Path.Combine(ModLoader.GetModSettingsFolder(mod), "keybinds.json");

            foreach (Keybind bind in Keybind.Get(mod))
            {
                Keybinds keybinds = new Keybinds
                {
                    ID       = bind.ID,
                    Key      = bind.Key,
                    Modifier = bind.Modifier
                };

                list.keybinds.Add(keybinds);
            }

            string serializedData = JsonConvert.SerializeObject(list, Formatting.Indented);

            File.WriteAllText(path, serializedData);
        }