コード例 #1
0
        private static bool Config_Check()
        {
            SNLogger.Debug("CyclopsLaserCannon", "Method call: LaserCannonConfig.Config_Check()");

            if (!File.Exists(FILENAME))
            {
                SNLogger.Error("CyclopsLaserCannon", "Configuration file open error!");
                return(false);
            }

            CONFIG_VERSION = ParserHelper.GetKeyValue(FILENAME, "LaserCannon", "Version");

            if (!CONFIG_VERSION.Equals(PROGRAM_VERSION))
            {
                SNLogger.Error("CyclopsLaserCannon", "Configuration file version error!");
                return(false);
            }

            if (!ParserHelper.CheckSectionKeys(FILENAME, "Hotkeys", SECTION_PROGRAM))
            {
                SNLogger.Error("CyclopsLaserCannon", "Configuration file [Program] section error!");
                return(false);
            }

            if (!ParserHelper.CheckSectionKeys(FILENAME, "Settings", SECTION_LANGUAGE))
            {
                SNLogger.Error("CyclopsLaserCannon", "Configuration file [Language] section error!");
                return(false);
            }

            return(true);
        }
コード例 #2
0
        internal static void KEYBINDINGS_Set()
        {
            SNLogger.Debug("Method call: SEConfig.SetKeyBindings()");

            KEYBINDINGS = new Dictionary <string, KeyCode>();

            bool sync = false;

            foreach (KeyValuePair <string, string> kvp in Hotkeys_Config)
            {
                try
                {
                    KEYBINDINGS.Add(kvp.Key, InputHelper.GetInputNameAsKeyCode(kvp.Value));
                }
                catch (ArgumentException)
                {
                    SNLogger.Warn($"[{kvp.Value}] is not a valid KeyCode! Setting default value!");

                    for (int i = 0; i < DEFAULT_CONFIG.Count; i++)
                    {
                        if (DEFAULT_CONFIG[i].Key.Equals(kvp.Key))
                        {
                            KEYBINDINGS.Add(kvp.Key, InputHelper.GetInputNameAsKeyCode(DEFAULT_CONFIG[i].Value));
                            sync = true;
                        }
                    }
                }
            }

            if (sync)
            {
                KEYBINDINGS_ToConfig();
            }
        }
コード例 #3
0
        internal static void SLOTKEYBINDINGS_Update()
        {
            SNLogger.Debug("Method call: SEConfig.Update_SLOTKEYBINDINGS()");

            SLOTKEYBINDINGS.Clear();
            SLOTKEYSLIST.Clear();

            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_1, GameInput.GetBindingName(GameInput.Button.Slot1, GameInput.BindingSet.Primary));
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_2, GameInput.GetBindingName(GameInput.Button.Slot2, GameInput.BindingSet.Primary));
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_3, GameInput.GetBindingName(GameInput.Button.Slot3, GameInput.BindingSet.Primary));
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_4, GameInput.GetBindingName(GameInput.Button.Slot4, GameInput.BindingSet.Primary));
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_5, GameInput.GetBindingName(GameInput.Button.Slot5, GameInput.BindingSet.Primary));
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_6, Hotkeys_Config[SlotConfigID.Slot_6.ToString()]);
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_7, Hotkeys_Config[SlotConfigID.Slot_7.ToString()]);
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_8, Hotkeys_Config[SlotConfigID.Slot_8.ToString()]);
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_9, Hotkeys_Config[SlotConfigID.Slot_9.ToString()]);
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_10, Hotkeys_Config[SlotConfigID.Slot_10.ToString()]);
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_11, Hotkeys_Config[SlotConfigID.Slot_11.ToString()]);
            SLOTKEYBINDINGS.Add(SlotConfigID.Slot_12, Hotkeys_Config[SlotConfigID.Slot_12.ToString()]);
            SLOTKEYBINDINGS.Add(SlotConfigID.SeamothArmLeft, Hotkeys_Config[SlotConfigID.SeamothArmLeft.ToString()]);
            SLOTKEYBINDINGS.Add(SlotConfigID.SeamothArmRight, Hotkeys_Config[SlotConfigID.SeamothArmRight.ToString()]);

            foreach (KeyValuePair <SlotConfigID, string> kvp in SLOTKEYBINDINGS)
            {
                SLOTKEYSLIST.Add(kvp.Value);
            }
        }
コード例 #4
0
        internal static void ExpandSlotMapping()
        {
            if (!SlotMappingExpanded)
            {
                foreach (string slotID in NewSeamothSlotIDs)
                {
                    if (slotID.Equals("SeamothArmLeft"))
                    {
                        Equipment.slotMapping.Add(slotID, (EquipmentType)NewEquipmentType.SeamothArm);
                    }
                    else if (slotID.Equals("SeamothArmRight"))
                    {
                        Equipment.slotMapping.Add(slotID, (EquipmentType)NewEquipmentType.SeamothArm);
                    }
                    else
                    {
                        Equipment.slotMapping.Add(slotID, EquipmentType.SeamothModule);
                    }
                }

                foreach (string slotID in NewExosuitSlotIDs)
                {
                    Equipment.slotMapping.Add(slotID, EquipmentType.ExosuitModule);
                }

                SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] Equipment slot mapping Patched!");
                SlotMappingExpanded = true;
            }
        }
コード例 #5
0
        internal static void Postfix(uGUI_MainMenu __instance)
        {
            if (Main.helperRoot != null)
            {
                Object.DestroyImmediate(Main.helperRoot);
            }

            Main.helperRoot = new GameObject("ModdedArmsHelper");

            Main.helperRoot.transform.SetParent(uGUI.main.transform, false);

            SNLogger.Debug("'ModdedArmsHelper' child gameObject created in 'uGUI.main'");

            Main.helperRoot.AddComponent <ArmRegistrationListener>();

            SNLogger.Debug("'RegistrationListener' attached to 'ModdedArmsHelper'");

            if (Main.graphicsRoot != null)
            {
                Object.DestroyImmediate(Main.graphicsRoot);
            }

            Main.graphicsRoot = new GameObject("GraphicsRoot");

            Main.graphicsRoot.transform.SetParent(Main.helperRoot.transform, false);

            Main.graphicsRoot.AddComponent <ArmsGraphics>();

            SNLogger.Debug("'GraphicsRoot' child gameObject created in 'ModdedArmsHelper'");
        }
コード例 #6
0
        private IEnumerator GetItemsContainer(string slotName)
        {
            SNLogger.Log($"[SeamothArms] GetItemsContainer coroutine started for this Seamoth: {ThisSeamoth.GetInstanceID()}");

            while (container == null)
            {
                container = ThisSeamoth.GetStorageInSlot(ThisSeamoth.GetSlotIndex(slotName), SeamothTorpedoArmPrefab.TechTypeID);

                SNLogger.Log($"[SeamothArms] ItemsContainer is not ready for this Seamoth: {ThisSeamoth.GetInstanceID()}");
                yield return(null);
            }

            SNLogger.Log($"[SeamothArms] ItemsContainer is ready for this Seamoth: {ThisSeamoth.GetInstanceID()}");
            SNLogger.Log($"[SeamothArms] GetItemsContainer coroutine stopped for this Seamoth: {ThisSeamoth.GetInstanceID()}");

            if (container != null)
            {
                container.SetAllowedTechTypes(GetTorpedoTypes());
                container.onAddItem    += OnAddItem;
                container.onRemoveItem += OnRemoveItem;
                UpdateVisuals();
            }

            yield break;
        }
コード例 #7
0
        internal static void LoadConfig()
        {
            PROGRAM_VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;

            if (!CheckConfig())
            {
                CreateDefaultConfigFile();
            }

            try
            {
                Section_hotkeys = ParserHelper.GetAllKeyValuesFromSection(FILENAME, SECTIONS[0], SECTION_Hotkeys);

                int.TryParse(ParserHelper.GetKeyValue(FILENAME, SECTIONS[1], SECTION_Settings[0]), out int result);
                MAXSLOTS = result < 5 || result > 12 ? 12 : result;

                TEXTCOLOR = ColorHelper.GetColor(ParserHelper.GetKeyValue(FILENAME, SECTIONS[1], SECTION_Settings[1]));

                SNLogger.Log("Configuration loaded.");
            }
            catch
            {
                SNLogger.Log("An error occurred while loading the configuration file!");
            }
        }
コード例 #8
0
        public static void DebugComponent(this Component component)
        {
            List <string> keywords = new List <string>();

            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreReturn;

            keywords.Add("Properties:");

            foreach (PropertyInfo propertyInfo in component.GetType().GetProperties(bindingFlags))
            {
                keywords.Add($"{propertyInfo.Name}  [{propertyInfo.GetValue(component, bindingFlags, null, null, null).ToString()}]");
            }

            keywords.Add("Fields:");

            foreach (FieldInfo fieldInfo in component.GetType().GetFields(bindingFlags))
            {
                keywords.Add($"{fieldInfo.Name}  [{fieldInfo.GetValue(component).ToString()}]");
            }

            foreach (string key in keywords)
            {
                SNLogger.Log($"{key}");
            }
        }
コード例 #9
0
        public static void GetResourceMaterial(string gameObjectPath, string meshName, int materialIndex, out Material material)
        {
            GameObject gameObject = Resources.Load <GameObject>(gameObjectPath);

            if (gameObject == null)
            {
                material = null;

                SNLogger.Error(Assembly.GetCallingAssembly().GetName().Name, $"GameObject not found in Resources at path [{gameObjectPath}]");

                return;
            }

            foreach (MeshRenderer meshRenderer in gameObject.GetComponentsInChildren <MeshRenderer>(true))
            {
                if (meshRenderer.name.Equals(meshName, StringComparison.CurrentCultureIgnoreCase))
                {
                    material = UnityEngine.Object.Instantiate(meshRenderer.materials[materialIndex]) as Material;

                    return;
                }
            }

            SNLogger.Error(Assembly.GetCallingAssembly().GetName().Name, $"Mesh not found in gameobject [{meshName}]");

            material = null;
        }
コード例 #10
0
 internal static void WriteConfig()
 {
     if (Helper.SetAllKeyValuesInSection(FILENAME, SECTIONS[0], Section_hotkeys))
     {
         SNLogger.Log($"[{PROGRAM_NAME}] Configuration saved.");
     }
 }
コード例 #11
0
        internal static void LoadConfig()
        {
            PROGRAM_VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;

            if (!File.Exists(FILENAME))
            {
                CreateDefaultConfigFile();
            }
            else
            {
                CONFIG_VERSION = Helper.GetKeyValue(FILENAME, PROGRAM_NAME, "Version");

                if (CONFIG_VERSION.Equals(PROGRAM_VERSION))
                {
                    SNLogger.Log($"[{PROGRAM_NAME}] Configuration version match with program version.");
                }
                else
                {
                    CreateDefaultConfigFile();
                }
            }

            Section_hotkeys = Helper.GetAllKeyValuesFromSection(FILENAME, SECTIONS[0], SECTION_HOTKEYS);

            int.TryParse(Helper.GetKeyValue(FILENAME, SECTIONS[1], SECTION_SETTINGS[0]), out int result);
            MAXSLOTS = result < 5 || result > 12 ? 12 : result;

            TEXTCOLOR = Modules.GetColor(Helper.GetKeyValue(FILENAME, SECTIONS[1], SECTION_SETTINGS[1]));

            SNLogger.Log($"[{PROGRAM_NAME}] Configuration loaded.");
        }
コード例 #12
0
        public static void Load()
        {
            //load and init config from file
            QSEConfig.LoadConfig();

            isExists_SlotExtender = ReflectionHelper.IsNamespaceExists("SlotExtender");

            if (isExists_SlotExtender)
            {
                SNLogger.Log("SlotExtender found! trying to work together..");
            }

            try
            {
                Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Subnautica.QuickSlotExtender.mod");

                SNLogger.Debug("Harmony Patches installed");

                SceneManager.sceneLoaded += new UnityAction <Scene, LoadSceneMode>(OnSceneLoaded);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }
コード例 #13
0
        internal static void LoadConfig()
        {
            PROGRAM_VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;

            if (!File.Exists(FILENAME))
            {
                CreateDefaultConfigFile();
            }
            else
            {
                CONFIG_VERSION = Helper.GetKeyValue(FILENAME, PROGRAM_NAME, "Version");


                if (CONFIG_VERSION.Equals(PROGRAM_VERSION))
                {
                    SNLogger.Log($"[{PROGRAM_NAME}] Configuration version match with program version.");
                }
                else
                {
                    CreateDefaultConfigFile();
                }
            }

            ReadConfig();
        }
コード例 #14
0
ファイル: Main.cs プロジェクト: Senna7608/SennaSubnauticaMods
        internal static void GameInput_OnBindingsChanged()
        {
            SNLogger.Debug("Method call: Main.GameInput_OnBindingsChanged()");

            // SlotExtender Update() method now disabled until all keybinding updates are complete
            isKeyBindigsUpdate = true;

            // updating slot key bindings
            SEConfig.SLOTKEYBINDINGS_Update();

            // synchronizing keybindings to config file
            SEConfig.SLOTKEYBINDINGS_SyncToAll();

            // updating ALLSLOTS dictionary
            SlotHelper.ALLSLOTS_Update();

            // updating SlotTextHandler
            if (uGUI_SlotTextHandler.Instance != null)
            {
                uGUI_SlotTextHandler.Instance.UpdateSlotText();
            }

            // SlotExtender Update() method now enabled
            isKeyBindigsUpdate = false;
        }
コード例 #15
0
        internal static void CreateDefaultConfigFile()
        {
            SNLogger.Log($"[{PROGRAM_NAME}] Warning! Configuration file is missing or wrong version. Trying to create a new one.");

            try
            {
                Helper.CreateDefaultConfigFile(FILENAME, PROGRAM_NAME, PROGRAM_VERSION, DEFAULT_CONFIG);

                var configParser = new Parser(FILENAME);

                foreach (string language in Languages)
                {
                    if (!configParser.AddNewSection(language))
                    {
                        continue;
                    }

                    foreach (string item in SECTION_LANGUAGE)
                    {
                        configParser.SetKeyValueInSection(language, item, "");
                    }
                }

                SNLogger.Log($"[{PROGRAM_NAME}] The new configuration file was successfully created.");
            }
            catch
            {
                SNLogger.Log($"[{PROGRAM_NAME}] An error occured while creating the new configuration file!");
            }
        }
コード例 #16
0
        internal static void SetKeyBindings()
        {
            KEYBINDINGS = new Dictionary <string, KeyCode>();

            bool sync = false;

            foreach (KeyValuePair <string, string> kvp in Section_hotkeys)
            {
                try
                {
                    KEYBINDINGS.Add(kvp.Key, InputHelper.GetInputNameAsKeyCode(kvp.Value));
                }
                catch (ArgumentException)
                {
                    SNLogger.Log($"[{PROGRAM_NAME}] Warning! ({kvp.Value}) is not a valid KeyCode! Setting default value!");

                    for (int i = 0; i < DEFAULT_CONFIG.Count; i++)
                    {
                        if (DEFAULT_CONFIG[i].Key.Equals(kvp.Key))
                        {
                            KEYBINDINGS.Add(kvp.Key, InputHelper.GetInputNameAsKeyCode(DEFAULT_CONFIG[i].Value));
                            sync = true;
                        }
                    }
                }
            }

            if (sync)
            {
                SyncConfig();
            }
        }
コード例 #17
0
        internal static void ReadConfig()
        {
            try
            {
                program_settings = Helper.GetAllKeyValuesFromSection(FILENAME, "Program", SECTION_PROGRAM);

                for (int i = 0; i < Modules.Colors.ColorNames.Length; i++)
                {
                    if (Modules.Colors.ColorNames[i].Equals(program_settings["BeamColor"]))
                    {
                        beamColor = i;
                    }
                }

                language_settings = Helper.GetAllKeyValuesFromSection(FILENAME, program_settings["Language"], SECTION_LANGUAGE);

                colorNames.Clear();

                foreach (KeyValuePair <string, string> item in language_settings)
                {
                    if (item.Key.StartsWith("Option_Color_"))
                    {
                        colorNames.Add(item.Value.ToString());
                    }
                }

                SNLogger.Log($"[{PROGRAM_NAME}] Configuration loaded.");
            }
            catch
            {
                SNLogger.Log($"[{PROGRAM_NAME}] An error occurred while loading the configuration file!");
            }
        }
コード例 #18
0
        private static bool CheckConfig()
        {
            if (!File.Exists(FILENAME))
            {
                SNLogger.Log($"[{PROGRAM_NAME}] Configuration file open error!");
                return(false);
            }

            CONFIG_VERSION = Helper.GetKeyValue(FILENAME, PROGRAM_NAME, "Version");

            if (!CONFIG_VERSION.Equals(PROGRAM_VERSION))
            {
                SNLogger.Log($"[{PROGRAM_NAME}] Configuration file version error!");
                return(false);
            }

            if (!Helper.CheckSectionKeys(FILENAME, SECTIONS[0], SECTION_Hotkeys))
            {
                SNLogger.Log($"[{PROGRAM_NAME}] Configuration {SECTIONS[0]} section error!");
                return(false);
            }

            if (!Helper.CheckSectionKeys(FILENAME, SECTIONS[1], SECTION_Settings))
            {
                SNLogger.Log($"[{PROGRAM_NAME}] Configuration {SECTIONS[1]} section error!");
                return(false);
            }

            return(true);
        }
コード例 #19
0
        private static bool CheckConfig()
        {
            if (!File.Exists(FILENAME))
            {
                SNLogger.Error("Configuration file open error!");
                return(false);
            }

            CONFIG_VERSION = ParserHelper.GetKeyValue(FILENAME, "QuickSlotExtender", "Version");

            if (!CONFIG_VERSION.Equals(PROGRAM_VERSION))
            {
                SNLogger.Error("Configuration file version error!");
                return(false);
            }

            if (!ParserHelper.CheckSectionKeys(FILENAME, SECTIONS[0], SECTION_Hotkeys))
            {
                SNLogger.Error($"Configuration {SECTIONS[0]} section error!");
                return(false);
            }

            if (!ParserHelper.CheckSectionKeys(FILENAME, SECTIONS[1], SECTION_Settings))
            {
                SNLogger.Error($"Configuration {SECTIONS[1]} section error!");
                return(false);
            }

            return(true);
        }
コード例 #20
0
        internal static void Config_CreateDefault()
        {
            SNLogger.Debug("LaserCannon", "Method call: LaserCannonConfig.Config_CreateDefault()");

            SNLogger.Warn("LaserCannon", "Configuration file is missing or wrong version. Trying to create a new one.");

            try
            {
                ParserHelper.CreateDefaultConfigFile(FILENAME, "LaserCannon", PROGRAM_VERSION, DEFAULT_CONFIG);

                var configParser = new Parser(FILENAME);

                foreach (string language in Languages)
                {
                    if (!configParser.AddNewSection(language))
                    {
                        continue;
                    }

                    foreach (string item in SECTION_LANGUAGE)
                    {
                        configParser.SetKeyValueInSection(language, item, "");
                    }
                }

                SNLogger.Log("LaserCannon", "The new configuration file was successfully created.");
            }
            catch
            {
                SNLogger.Error("LaserCannon", "An error occured while creating the new configuration file!");
            }
        }
コード例 #21
0
        private IEnumerator AssignKey(object keyName)
        {
            waitingForKey = true;

            yield return(WaitForKey());

            int isFirst  = 0;
            int keyCount = 0;

            for (int i = 0; i < hotkeyButtons.Count; i++)
            {
                if (hotkeyButtons[i].Equals(newKey))
                {
                    if (keyCount == 0)
                    {
                        isFirst = i;
                    }

                    keyCount++;
                }
            }

            if (keyCount > 0 && isFirst != selected)
            {
                SNLogger.Warn("Duplicate keybind found, swapping keys...");
                hotkeyButtons[isFirst]        = hotkeyButtons[selected];
                guiItem_Buttons[isFirst].Name = hotkeyButtons[selected];
            }

            hotkeyButtons[selected]        = newKey;
            guiItem_Buttons[selected].Name = hotkeyButtons[selected];
            selected = -1;

            yield return(null);
        }
コード例 #22
0
        internal void Awake()
        {
            //get this SlotExtender instance
            Instance = GetComponent <SlotExtender>();

            if (Instance.GetComponent <SeaMoth>())
            {
                //this Vehicle type is SeaMoth
                ThisVehicle = Instance.GetComponent <SeaMoth>();

                //add extra slots
                foreach (string slotID in SlotHelper.NewSeamothSlotIDs)
                {
                    ThisVehicle.modules.AddSlot(slotID);
                }
            }
            else if (Instance.GetComponent <Exosuit>())
            {
                //this Vehicle type is Exosuit
                ThisVehicle = Instance.GetComponent <Exosuit>();

                //add extra slots
                foreach (string slotID in SlotHelper.NewExosuitSlotIDs)
                {
                    ThisVehicle.modules.AddSlot(slotID);
                }
            }
            else
            {
                SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] Unknown Vehicle type error! Instance destroyed!");
                Destroy(Instance);
            }
        }
コード例 #23
0
        public override GameObject GetGameObject()
        {
            if (GameResourceFileName == null)
            {
                try
                {
                    _GameObject = Object.Instantiate(CraftData.GetPrefabForTechType(PrefabTemplate));
                }
                catch
                {
                    SNLogger.Warn(NameID, "Cannot instantiate prefab from TechType!");
                }
            }
            else
            {
                try
                {
                    _GameObject = Object.Instantiate(Resources.Load <GameObject>(GameResourceFileName));
                }
                catch
                {
                    SNLogger.Warn(NameID, "Cannot instantiate prefab from resource!");
                }
            }

            _GameObject.name = NameID;

            return(_GameObject);
        }
コード例 #24
0
        public static void ExpandSlotMapping()
        {
            SNLogger.Debug("Method call: SlotHelper.ExpandSlotMapping()");

            foreach (SlotData slotData in NewChipSlots)
            {
                Equipment.slotMapping.Add(slotData.SlotID, EquipmentType.Chip);
            }

            foreach (SlotData slotData in SessionSeamothSlots)
            {
                switch (slotData.SlotType)
                {
                case SlotType.CloneNormal:
                    Equipment.slotMapping.Add(slotData.SlotID, EquipmentType.SeamothModule);
                    break;

                case SlotType.CloneArmLeft:
                case SlotType.CloneArmRight:
                    Equipment.slotMapping.Add(slotData.SlotID, (EquipmentType)ModdedEquipmentType.SeamothArm);
                    break;
                }
            }

            foreach (SlotData slotData in SessionExosuitSlots)
            {
                if (slotData.SlotType == SlotType.CloneNormal)
                {
                    Equipment.slotMapping.Add(slotData.SlotID, EquipmentType.ExosuitModule);
                }
            }

            SNLogger.Log("Equipment slot mapping Patched!");
        }
コード例 #25
0
        private IEnumerator AssignKey(object keyName)
        {
            waitingForKey = true;

            yield return(WaitForKey());

            int isFirst  = 0;
            int keyCount = 0;

            for (int i = 0; i < HotkeyButtons.Count; i++)
            {
                if (HotkeyButtons[i].Equals(newKey.ToString()))
                {
                    if (keyCount == 0)
                    {
                        isFirst = i;
                    }

                    keyCount++;
                }
            }

            if (keyCount > 0 && isFirst != selected)
            {
                SNLogger.Log("CheatManager", "Error! Duplicate keybind found, swapping keys...");
                HotkeyButtons[isFirst]   = HotkeyButtons[selected];
                buttonInfo[isFirst].Name = HotkeyButtons[selected];
            }

            HotkeyButtons[selected]   = newKey.ToString();
            buttonInfo[selected].Name = HotkeyButtons[selected];
            selected = -1;
            yield return(null);
        }
コード例 #26
0
        internal static void LoadConfig()
        {
            PROGRAM_VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;

            TitleText = $"Runtime Helper v.{PROGRAM_VERSION}";

            if (!File.Exists(FILENAME))
            {
                CreateDefaultConfigFile();
            }
            else
            {
                CONFIG_VERSION = ParserHelper.GetKeyValue(FILENAME, "RuntimeHelper", "Version");

                if (CONFIG_VERSION.Equals(PROGRAM_VERSION))
                {
                    SNLogger.Log("RuntimeHelper", "Configuration file version match with program version.");
                }
                else
                {
                    CreateDefaultConfigFile();
                }
            }

            Section_hotkeys = ParserHelper.GetAllKeyValuesFromSection(FILENAME, SECTIONS[1], SECTION_HOTKEYS);

            string autostart = ParserHelper.GetKeyValue(FILENAME, SECTIONS[0], SECTION_SETTINGS[0]);

            if (!bool.TryParse(autostart, out AUTOSTART))
            {
                AUTOSTART = false;
            }

            SNLogger.Log("RuntimeHelper", "Configuration loaded.");
        }
コード例 #27
0
        private static bool Config_Check()
        {
            SNLogger.Debug("Method call: SEConfig.Config_Check()");

            if (!File.Exists(FILENAME))
            {
                SNLogger.Error("Configuration file open error!");
                return(false);
            }

            CONFIG_VERSION = ParserHelper.GetKeyValue(FILENAME, "SlotExtender", "Version");

            if (!CONFIG_VERSION.Equals(PROGRAM_VERSION))
            {
                SNLogger.Error("Configuration file version error!");
                return(false);
            }

            if (!ParserHelper.CheckSectionKeys(FILENAME, "Hotkeys", SECTION_HOTKEYS))
            {
                SNLogger.Error("Configuration file [Hotkeys] section error!");
                return(false);
            }

            if (!ParserHelper.CheckSectionKeys(FILENAME, "Settings", SECTION_SETTINGS))
            {
                SNLogger.Error("Configuration file [Settings] section error!");
                return(false);
            }

            return(true);
        }
コード例 #28
0
        private IEnumerator AssignKey(object keyName)
        {
            waitingForKey = true;

            yield return(WaitForKey());

            int isFirst  = 0;
            int keyCount = 0;

            for (int i = 0; i < buttons.Count; i++)
            {
                if (buttons[i].Equals(newKey))
                {
                    if (keyCount == 0)
                    {
                        isFirst = i;
                    }

                    keyCount++;
                }
            }

            if (keyCount > 0 && isFirst != selected)
            {
                SNLogger.Log($"[{QSEConfig.PROGRAM_NAME}] Error! Duplicate keybind found, swapping keys...");
                buttons[isFirst]         = buttons[selected];
                buttonInfo[isFirst].Name = buttons[selected];
            }

            buttons[selected]         = newKey;
            buttonInfo[selected].Name = buttons[selected];
            selected = -1;

            yield return(null);
        }
コード例 #29
0
        internal static void SetKeyBindings()
        {
            KEYBINDINGS = new Dictionary <string, KeyCode>();

            bool sync = false;

            foreach (KeyValuePair <string, string> kvp in Section_hotkeys)
            {
                try
                {
                    KeyCode keyCode = (KeyCode)Enum.Parse(typeof(KeyCode), kvp.Value);
                    KEYBINDINGS.Add(kvp.Key, keyCode);
                }
                catch (ArgumentException)
                {
                    SNLogger.Warn("CheatManager", $"({kvp.Value}) is not a valid KeyCode! Setting default value!");

                    for (int i = 0; i < DEFAULT_CONFIG.Count; i++)
                    {
                        if (DEFAULT_CONFIG[i].Key.Equals(kvp.Key))
                        {
                            KEYBINDINGS.Add(kvp.Key, (KeyCode)Enum.Parse(typeof(KeyCode), DEFAULT_CONFIG[i].Value, true));
                            sync = true;
                        }
                    }
                }
            }

            if (sync)
            {
                SyncConfig();
            }
        }
コード例 #30
0
        private bool CheckConfig()
        {
            if (!File.Exists(FILENAME))
            {
                SNLogger.Error(ProgramName, "Configuration file does not exists!");
                return(false);
            }

            CONFIG_VERSION = ParserHelper.GetKeyValue(FILENAME, ProgramName, "Version");

            if (!CONFIG_VERSION.Equals(PROGRAM_VERSION))
            {
                SNLogger.Error(ProgramName, "Configuration file version error!");
                return(false);
            }

            foreach (ConfigDataNew configData in DEFAULT_CONFIG)
            {
                if (!ParserHelper.CheckSectionKeys(FILENAME, configData.Section, configData.Keys))
                {
                    SNLogger.Error(ProgramName, $"Configuration file [{configData.Section}] section error!");
                    return(false);
                }
            }

            return(true);
        }