Exemple #1
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();
            }
        }
        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);
        }
        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();
            }
        }
Exemple #4
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);
        }
        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!");
            }
        }
Exemple #6
0
 internal static void Postfix(SeaMoth __instance, bool docked, Vehicle.DockType dockType)
 {
     if (__instance.gameObject.TryGetComponent(out SeamothArmManager manager))
     {
         manager.onDockedChanged?.Trigger(docked);
     }
     else
     {
         SNLogger.Warn("Seamoth Arm Manager is not ready!");
     }
 }
        internal static void CreateDefaultConfigFile()
        {
            SNLogger.Warn("RuntimeHelper", "Configuration file is missing or wrong version. Trying to create a new one.");

            try
            {
                ParserHelper.CreateDefaultConfigFile(FILENAME, "RuntimeHelper", PROGRAM_VERSION, DEFAULT_CONFIG);
                SNLogger.Log("RuntimeHelper", "The new configuration file was successfully created.");
            }
            catch
            {
                SNLogger.Error("RuntimeHelper", "An error occured while creating the new configuration file!");
            }
        }
        internal static void CreateDefaultConfigFile()
        {
            SNLogger.Warn("Configuration file is missing or wrong version. Trying to create a new one.");

            try
            {
                ParserHelper.CreateDefaultConfigFile(FILENAME, "QuickSlotExtender", PROGRAM_VERSION, DEFAULT_CONFIG);
                ParserHelper.AddInfoText(FILENAME, "TextColor possible values", "LightBlue, Red, Green, Blue, Yellow, White, Magenta, Cyan, Orange, Lime, Amethyst");

                SNLogger.Log("The new configuration file was successfully created.");
            }
            catch
            {
                SNLogger.Error("An error occured while creating the new configuration file!");
            }
        }
Exemple #9
0
        internal static void Config_CreateDefault()
        {
            SNLogger.Debug("CheatManager", "Method call: CmConfig.Config_CreateDefault()");

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

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

                ParserHelper.AddInfoText(FILENAME, "OverPowerMultiplier and HungerAndThirstInterval possible values", "1 to 10");

                SNLogger.Log("CheatManager", "The new configuration file was successfully created.");
            }
            catch
            {
                SNLogger.Error("CheatManager", "An error occured while creating the new configuration file!");
            }
        }
Exemple #10
0
        public static bool Prefix(Vehicle __instance)
        {
            if (__instance.GetType() == typeof(SeaMoth))
            {
                if (__instance.gameObject.TryGetComponent(out SeamothArmManager manager))
                {
                    if (manager.IsArmSlotSelected)
                    {
                        manager.SlotArmUp();
                        return(false);
                    }
                }
                else
                {
                    SNLogger.Warn("Seamoth Arm Manager is not ready!");
                }
            }

            return(true);
        }
        internal static void Config_CreateDefault()
        {
            SNLogger.Debug("Method call: SEConfig.Config_CreateDefault()");

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

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

                ParserHelper.AddInfoText(FILENAME, "MaxSlots possible values", "5 to 12");
                ParserHelper.AddInfoText(FILENAME, "TextColor possible values", "Red, Green, Blue, Yellow, White, Magenta, Cyan, Orange, Lime, Amethyst, LightBlue");
                ParserHelper.AddInfoText(FILENAME, "SeamothStorageSlotsOffset possible values", "0 to 8");
                ParserHelper.AddInfoText(FILENAME, "SlotLayout possible values", "Grid, Circle");


                SNLogger.Log("The new configuration file was successfully created.");
            }
            catch
            {
                SNLogger.Error("An error occured while creating the new configuration file!");
            }
        }