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); } }
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); } }
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!"); } }
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}"); } }
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."); }
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!"); }
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."); }
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); }
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); }
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!"); } }
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(); } }
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; } }
internal static void WriteConfig() { if (Helper.SetAllKeyValuesInSection(FILENAME, SECTIONS[0], Section_hotkeys)) { SNLogger.Log($"[{PROGRAM_NAME}] Configuration saved."); } }
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!"); } }
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; }
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); }
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!"); } }
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(); }
private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (scene.name == "Main") { enabled = false; SNLogger.Log("Main scene loaded. Arm registration listener now shutdown."); } }
internal static void WriteConfig() { Helper.SetAllKeyValuesInSection(FILENAME, SECTIONS[0], Section_hotkeys); Helper.SetKeyValue(FILENAME, SECTIONS[1], SECTION_Settings[0], MAXSLOTS.ToString()); Helper.SetKeyValue(FILENAME, SECTIONS[1], SECTION_Settings[1], Modules.GetColorName(TEXTCOLOR)); SNLogger.Log($"[{PROGRAM_NAME}] Configuration saved."); }
internal static void WriteConfig() { foreach (KeyValuePair <string, string> item in program_settings) { ParserHelper.SetKeyValue(FILENAME, "Program", item.Key, item.Value); } SNLogger.Log("LaserCannon", "Configuration saved."); }
internal static void WriteConfig() { foreach (KeyValuePair <string, string> item in program_settings) { Helper.SetKeyValue(FILENAME, "Program", item.Key, item.Value); } SNLogger.Log($"[{PROGRAM_NAME}] Configuration saved."); }
internal static void Postfix(SeaMoth __instance) { string name = __instance.name; int ID = __instance.GetInstanceID(); __instance.gameObject.AddIfNeedComponent <SlotExtender>(); SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] component added to instance: {name} ID: {ID}"); }
private void OnFirstTimeCheckModuleIsExists() { SNLogger.Log($"[CyclopsLaserCannonModule] Trying to enable module..."); if (upgradeHandler.Count > 0) { isModuleInserted = true; LaserCannonSetActive(isModuleInserted); } }
internal static void Config_Write() { SNLogger.Debug("Method call: SEConfig.WriteConfig()"); ParserHelper.SetAllKeyValuesInSection(FILENAME, "Hotkeys", Hotkeys_Config); ParserHelper.SetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[0], MAXSLOTS.ToString()); ParserHelper.SetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[1], ColorHelper.GetColorName(TEXTCOLOR)); ParserHelper.SetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[2], STORAGE_SLOTS_OFFSET.ToString()); ParserHelper.SetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[3], SLOT_LAYOUT.ToString()); SNLogger.Log("Configuration saved."); }
internal static void Config_Init() { SNLogger.Debug("Method call: SEConfig.InitConfig()"); SLOTKEYBINDINGS_Update(); KEYBINDINGS_Set(); SLOTKEYBINDINGS_SyncToAll(); SNLogger.Log("Configuration initialized."); }
internal static void CreateDefaultConfigFile() { SNLogger.Log($"[{PROGRAM_NAME}] Warning! Configuration file is missing or wrong version. Creating a new one."); try { Helper.CreateDefaultConfigFile(FILENAME, PROGRAM_NAME, PROGRAM_VERSION, DEFAULT_CONFIG); } catch { SNLogger.Log($"[{PROGRAM_NAME}] Error! Creating new configuration file has failed!"); } }
public static void Postfix(CyclopsExternalCams __instance) { GameObject CyclopsRoot = __instance.transform.parent.gameObject; if (CyclopsRoot.name.Equals("__LIGHTMAPPED_PREFAB__")) { return; } CyclopsRoot.AddIfNeedComponent <CannonControl>(); SNLogger.Log($"[CyclopsLaserCannonModule] Patch injected on class [CyclopsExternalCams] for this Cyclops instance: {CyclopsRoot.GetInstanceID()}. CannonControl component added."); }
public void ExecuteCommand(object message, object command) { if (message != null) { ErrorMessage.AddMessage(message.ToString()); } if (command != null) { SNLogger.Log((string)command); DevConsole.SendConsoleCommand(command.ToString()); } }
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!"); } }