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!"); } }
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; }
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(); } }
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!"); }
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); }
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 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); } }
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'"); }
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); }
internal static void KEYBINDINGS_ToConfig() { SNLogger.Debug("Method call: SEConfig.SyncConfig()"); foreach (string key in SECTION_HOTKEYS) { Hotkeys_Config[key] = InputHelper.GetKeyCodeAsInputName(KEYBINDINGS[key]); } Config_Write(); }
internal static void Config_Init() { SNLogger.Debug("Method call: SEConfig.InitConfig()"); SLOTKEYBINDINGS_Update(); KEYBINDINGS_Set(); SLOTKEYBINDINGS_SyncToAll(); SNLogger.Log("Configuration initialized."); }
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."); }
public static void Postfix(CyclopsExternalCams __instance) { GameObject CyclopsRoot = __instance.transform.parent.gameObject; if (CyclopsRoot.name.Equals("__LIGHTMAPPED_PREFAB__")) { return; } CyclopsRoot.EnsureComponent <CannonControl>(); SNLogger.Debug("CyclopsLaserCannonModule", $"Patch injected on class [CyclopsExternalCams] for this Cyclops instance: {CyclopsRoot.GetInstanceID()}. CannonControl component added."); }
private static void DebugAllSlots() { SNLogger.Debug("Listing Dictionary: ALLSLOTS...\n"); foreach (KeyValuePair <string, SlotData> kvp in ALLSLOTS) { SNLogger.Log( $"SlotID: {kvp.Value.SlotID}\n" + $"InternalSlotID: {kvp.Value.SlotConfigIDName}\n" + $"SlotPOS: {kvp.Value.SlotPos}\n" + $"SlotType: {kvp.Value.SlotType}\n" + $"KeyCodeName: {kvp.Value.KeyCodeName}\n"); } }
public static bool IsExtendedSeamothSlot(string slotName) { SNLogger.Debug($"Method call: SlotHelper.IsExtendedSeamothSlot({slotName})"); foreach (string slot in SessionNewSeamothSlotIDs) { if (slotName.Equals(slot)) { return(true); } } return(false); }
internal static void Config_Load() { SNLogger.Debug("Method call: SEConfig.Config_Load()"); PROGRAM_VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; if (!Config_Check()) { Config_CreateDefault(); } try { Hotkeys_Config = ParserHelper.GetAllKeyValuesFromSection(FILENAME, "Hotkeys", SECTION_HOTKEYS); int.TryParse(ParserHelper.GetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[0]), out int result); MAXSLOTS = result < 5 || result > 12 ? 12 : result; EXTRASLOTS = SEConfig.MAXSLOTS - 4; TEXTCOLOR = ColorHelper.GetColor(ParserHelper.GetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[1])); if (ReflectionHelper.IsNamespaceExists("SeamothStorageSlots")) { STORAGE_SLOTS_OFFSET = 0; // don't patch storages stuff if SeamothStorageSlots mod is active const string msg = "<i>SeamothStorageSlots</i> mod is now merged into SlotExtender, you can safely delete it."; Type qmmServices = Type.GetType("QModManager.API.QModServices, QModInstaller", false); MethodInfo qmmMain = qmmServices?.GetProperty("Main")?.GetGetMethod(); qmmServices?.GetMethod("AddCriticalMessage")?.Invoke(qmmMain.Invoke(null, null), new object[] { msg, 25, "yellow", true }); } else { int.TryParse(ParserHelper.GetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[2]), out result); STORAGE_SLOTS_OFFSET = result < 3 ? 0 : result > 8 ? 8 : result; } SLOT_LAYOUT = ParserHelper.GetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[3]) == "Circle"? SlotLayout.Circle : SlotLayout.Grid; isSeamothArmsExists = ReflectionHelper.IsNamespaceExists("SeamothArms"); SNLogger.Log("Configuration loaded."); } catch { SNLogger.Error("An error occurred while loading the configuration file!"); } }
public static void Load() { SNLogger.Debug("Method call: Main.Load()"); try { SEConfig.Config_Load(); SlotHelper.InitSlotIDs(); SlotHelper.ExpandSlotMapping(); hInstance = new Harmony("Subnautica.SlotExtender.mod"); SNLogger.Debug($"Main.Load(): Harmony Instance created, Name = [{hInstance.Id}]"); hInstance.PatchAll(Assembly.GetExecutingAssembly()); SceneManager.sceneLoaded += new UnityAction <Scene, LoadSceneMode>(OnSceneLoaded); SNLogger.Debug("Main.Load(): Added OnSceneLoaded method to SceneManager.sceneLoaded event."); //add console commad for configuration window commandRoot = new CommandRoot("SEConfigGO"); commandRoot.AddCommand <SECommand>(); IngameMenuHandler.Main.RegisterOnQuitEvent(OnQuitEvent); } catch (Exception ex) { Debug.LogException(ex); } // check MoreQuickSlots namespace is exists if (ReflectionHelper.IsNamespaceExists("MoreQuickSlots")) { SNLogger.Log("MoreQuickSlots namespace is exist! Trying to install a Cross-MOD patch..."); // if yes construct a Harmony patch if (MQS_Patches.InitPatch(hInstance)) { SNLogger.Log("MoreQuickSlots Cross-MOD patch installed!"); } else { SNLogger.Error("MoreQuickSlots Cross-MOD patch install failed!"); } } }
public static void GetConstructorInfo(ConstructorInfo constructorInfo) { ParameterInfo[] pInfos = constructorInfo.GetParameters(); if (pInfos.Length == 0) { SNLogger.Debug("", $"this constructor [{constructorInfo.Name}] has no parameters."); } else { SNLogger.Debug("", $"listing constructor parameters..."); foreach (ParameterInfo pInfo in pInfos) { SNLogger.Debug("", $"ctor parameter[{pInfo.Position}] = [{pInfo.ToString()}]"); } } }
public static void InitSlotIDs() { SNLogger.Debug("Method call: SlotHelper.InitSlotIDs()"); for (int i = 0; i < SEConfig.EXTRASLOTS; i++) { SessionSeamothSlots.Add(NewSeamothSlots[i]); SessionExosuitSlots.Add(NewExosuitSlots[i]); } if (SEConfig.isSeamothArmsExists) { foreach (SlotData slotData in NewSeamothSlots) { SlotType slotType = slotData.SlotType; if (slotType == SlotType.CloneArmLeft || slotType == SlotType.CloneArmRight) { SessionSeamothSlots.Add(slotData); } } } NewChipSlotIDs = new string[NewChipSlots.Count]; for (int i = 0; i < NewChipSlotIDs.Length; i++) { NewChipSlotIDs[i] = NewChipSlots[i].SlotID; } SessionSeamothSlotIDs = new string[SessionSeamothSlots.Count]; for (int i = 0; i < SessionSeamothSlotIDs.Length; i++) { SessionSeamothSlotIDs[i] = SessionSeamothSlots[i].SlotID; } SessionExosuitSlotIDs = new string[SessionExosuitSlots.Count]; for (int i = 0; i < SessionExosuitSlotIDs.Length; i++) { SessionExosuitSlotIDs[i] = SessionExosuitSlots[i].SlotID; } }
private static bool Config_Check() { SNLogger.Debug("CheatManager", "Method call: CmConfig.Config_Check()"); if (!File.Exists(FILENAME)) { SNLogger.Error("CheatManager", "Configuration file open error!"); return(false); } CONFIG_VERSION = ParserHelper.GetKeyValue(FILENAME, "CheatManager", "Version"); if (!CONFIG_VERSION.Equals(PROGRAM_VERSION)) { SNLogger.Error("CheatManager", "Configuration file version error!"); return(false); } if (!ParserHelper.CheckSectionKeys(FILENAME, "Hotkeys", SECTION_HOTKEYS)) { SNLogger.Error("CheatManager", "Configuration file [Hotkeys] section error!"); return(false); } if (!ParserHelper.CheckSectionKeys(FILENAME, "Program", SECTION_PROGRAM)) { SNLogger.Error("CheatManager", "Configuration file [Program] section error!"); return(false); } if (!ParserHelper.CheckSectionKeys(FILENAME, "Settings", SECTION_SETTINGS)) { SNLogger.Error("CheatManager", "Configuration file [Settings] section error!"); return(false); } if (!ParserHelper.CheckSectionKeys(FILENAME, "ToggleButtons", SECTION_TOGGLEBUTTONS)) { SNLogger.Error("CheatManager", "Configuration file [ToggleButtons] section error!"); return(false); } return(true); }
public static void CloneFieldsInto <T>(this T original, T copy, BindingFlags bindingFlags = BindingFlags.Default) { FieldInfo[] fieldsInfo = original.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | bindingFlags); foreach (FieldInfo fieldInfo in fieldsInfo) { if (fieldInfo.GetType().IsClass) { fieldInfo.GetValue(original).CloneFieldsInto(fieldInfo.GetValue(copy)); SNLogger.Debug($"Cloned class: [{fieldInfo.Name}], type: [{fieldInfo.GetType()}]"); } else { var value = fieldInfo.GetValue(original); fieldInfo.SetValue(copy, value); SNLogger.Debug($"Cloned field: [{fieldInfo.Name}], type: [{fieldInfo.GetType()}]"); } } }
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!"); } }
public void ReadSlotExtenderConfig() { SLOTEXTENDER_SLOTKEYSLIST.Clear(); try { slotextender_SLOTKEYSLIST = Main.GetAssemblyClassPublicField("SlotExtender.Configuration.SEConfig", "SLOTKEYSLIST", BindingFlags.Static); foreach (string item in (List <string>)slotextender_SLOTKEYSLIST) { SLOTEXTENDER_SLOTKEYSLIST.Add(item); } SNLogger.Debug("QuickSlotExtender", $"SLOTEXTENDER_SLOTKEYSLIST.Count = [{SLOTEXTENDER_SLOTKEYSLIST.Count}]"); } catch (Exception ex) { Debug.LogException(ex); } }
internal static void SLOTKEYBINDINGS_SyncToAll() { SNLogger.Debug("Method call: SEConfig.SyncSlotKeyBindings()"); foreach (KeyValuePair <SlotConfigID, string> kvp in SLOTKEYBINDINGS) { SNLogger.Debug($"key: {kvp.Key.ToString()}, Value: {kvp.Value}"); string key = kvp.Key.ToString(); if (Hotkeys_Config.ContainsKey(key)) { Hotkeys_Config[key] = kvp.Value; } KEYBINDINGS[key] = InputHelper.GetInputNameAsKeyCode(kvp.Value); } Config_Write(); }
public static void InitSessionAllSlots() { SNLogger.Debug($"Method call: SlotHelper.InitSessionAllSlots()"); ALLSLOTS.Clear(); foreach (SlotData slotData in SessionSeamothSlots) { SEConfig.SLOTKEYBINDINGS.TryGetValue(slotData.SlotConfigID, out string result); slotData.KeyCodeName = result; ALLSLOTS.Add(slotData.SlotID, slotData); } foreach (SlotData slotData in SessionExosuitSlots) { SEConfig.SLOTKEYBINDINGS.TryGetValue(slotData.SlotConfigID, out string result); slotData.KeyCodeName = result; ALLSLOTS.Add(slotData.SlotID, slotData); } DebugAllSlots(); }
private IEnumerator GetMCUHandler() { SNLogger.Debug("CyclopsLaserCannonModule", $"GetMCUHandler coroutine started for this Cyclops: {This_Cyclops_Root.GetInstanceID()}"); while (upgradeHandler == null) { upgradeHandler = MCUServices.Find.CyclopsUpgradeHandler(subroot, CannonPrefab.TechTypeID); SNLogger.Debug("CyclopsLaserCannonModule", $"MCU UpgradeHandler is not ready for this Cyclops: {This_Cyclops_Root.GetInstanceID()}"); yield return(null); } SNLogger.Debug("CyclopsLaserCannonModule", $"MCU UpgradeHandler is ready for this Cyclops: {This_Cyclops_Root.GetInstanceID()}"); upgradeHandler.OnFinishedUpgrades = OnFinishedUpgrades; upgradeHandler.OnClearUpgrades = OnClearUpgrades; OnFirstTimeCheckModuleIsExists(); SNLogger.Debug("CyclopsLaserCannonModule", $"GetMCUHandler coroutine stopped for this Cyclops: {This_Cyclops_Root.GetInstanceID()}"); yield break; }
public void GetModdedTechTypes(ref List <TechTypeData>[] TechnologyMatrix) { ModdedTechTypeHelper mHelper = new ModdedTechTypeHelper(); foreach (KeyValuePair <string, TechType> kvp in mHelper.FoundModdedTechTypes) { EquipmentType equipmentType = mHelper.TypeDefCache[kvp.Value]; switch (equipmentType) { case EquipmentType.CyclopsModule: case EquipmentType.ExosuitArm: case EquipmentType.ExosuitModule: case EquipmentType.SeamothModule: case EquipmentType.VehicleModule: case (EquipmentType)100: TechnologyMatrix[(int)TechCategory.Upgrades].Add(new TechTypeData(kvp.Value, Language.main.Get(TechTypeExtensions.AsString(kvp.Value, false)))); break; } } SNLogger.Debug("CheatManager", "Modded TechTypes checked and added."); }
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!"); } }
/* * public override string ProgramName => "CheatManager"; * public override List<ConfigDataNew> DEFAULT_CONFIG => DEFAULT; * * private static List<ConfigDataNew> DEFAULT = new List<ConfigDataNew> * { * new ConfigDataNew("Hotkeys", * new Dictionary<string, string> * { * { "ToggleWindow", KeyCode.F5.ToString() }, * { "ToggleMouse", KeyCode.F4.ToString() }, * { "ToggleConsole", KeyCode.Delete.ToString() } * }), * * new ConfigDataNew("Program", * new Dictionary<string, string> * { * { "EnableConsole", false.ToString() }, * { "EnableInfoBar", false.ToString() } * }), * * new ConfigDataNew("Settings", * new Dictionary<string, string> * { * { "OverPowerMultiplier", 2.ToString() }, * { "HungerAndThirstInterval", 1.ToString() } * }), * * new ConfigDataNew("ToggleButtons", * new Dictionary<string, string> * { * { "fastbuild", false.ToString() }, * { "fastscan", false.ToString() }, * { "fastgrow", false.ToString() }, * { "fasthatch", false.ToString() }, * { "filterfast", false.ToString() }, * { "radiation", false.ToString() }, * { "invisible", false.ToString() }, * { "nodamage", false.ToString() }, * { "alwaysday", false.ToString() }, * { "noinfect", false.ToString() }, * { "overpower", false.ToString() } * }), * * new ConfigDataNew("UserWarpTargets", * new Dictionary<string, string> * { * { string.Empty, string.Empty }, * }), * }; */ internal static void Config_Load() { SNLogger.Debug("SlotExtender", "Method call: SEConfig.LoadConfig()"); PROGRAM_VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; if (!Config_Check()) { Config_CreateDefault(); } isConsoleEnabled = bool.Parse(ParserHelper.GetKeyValue(FILENAME, SECTIONS[1], SECTION_PROGRAM[0])); isInfoBarEnabled = bool.Parse(ParserHelper.GetKeyValue(FILENAME, SECTIONS[1], SECTION_PROGRAM[1])); Section_hotkeys = ParserHelper.GetAllKeyValuesFromSection(FILENAME, SECTIONS[0], SECTION_HOTKEYS); Section_settings = ParserHelper.GetAllKeyValuesFromSection(FILENAME, SECTIONS[2], SECTION_SETTINGS); Section_toggleButtons = ParserHelper.GetAllKeyValuesFromSection(FILENAME, SECTIONS[3], SECTION_TOGGLEBUTTONS); Section_userWarpTargets = ParserHelper.GetAllKVPFromSection(FILENAME, SECTIONS[4]); int.TryParse(Section_settings[SECTION_SETTINGS[0]], out overPowerMultiplier); if (overPowerMultiplier < 0 && overPowerMultiplier > 10) { overPowerMultiplier = 10; ParserHelper.SetKeyValue(FILENAME, SECTIONS[1], Section_settings[SECTION_SETTINGS[0]], 2.ToString()); } int.TryParse(Section_settings[SECTION_SETTINGS[1]], out hungerAndThirstInterval); if (hungerAndThirstInterval < 0 && hungerAndThirstInterval > 10) { hungerAndThirstInterval = 10; ParserHelper.SetKeyValue(FILENAME, SECTIONS[1], Section_settings[SECTION_SETTINGS[1]], 2.ToString()); } SetKeyBindings(); }
public void Awake() { SNLogger.Debug("CheatManager", "Awake started."); DontDestroyOnLoad(this); useGUILayout = false; gameObject.AddComponent <AlwaysDayConsoleCommand>(); gameObject.AddComponent <OverPowerConsoleCommand>(); gameObject.AddComponent <NoInfectConsoleCommand>(); SNLogger.Debug("CheatManager", "Console commands added."); UpdateTitle(); warpSound = ScriptableObject.CreateInstance <FMODAsset>(); warpSound.path = "event:/tools/gravcannon/fire"; SNLogger.Debug("CheatManager", "Warpsound created."); techMatrix = new TechnologyMatrix(); tMatrix = new List <TechTypeData> [techMatrix.baseTechMatrix.Count]; techMatrix.InitTechMatrixList(ref tMatrix); SNLogger.Debug("CheatManager", "Base Tech matrix created."); if (CmConfig.Section_userWarpTargets.Count > 0) { foreach (KeyValuePair <string, string> kvp in CmConfig.Section_userWarpTargets) { WarpTargets_User.Add(new IntVector(kvp.Key), kvp.Value); } SNLogger.Debug("CheatManager", "User warp targets added."); } techMatrix.GetModdedTechTypes(ref tMatrix); techMatrix.SortTechLists(ref tMatrix); buttonText = new ButtonText(); drawRect = SNWindow.InitWindowRect(windowRect, true); List <Rect> commandRects = drawRect.SetGridItemsRect(4, 2, ITEMSIZE, SPACE, SPACE, true, true); commands.CreateGuiItemsGroup(buttonText.Buttons, commandRects, GuiItemType.NORMALBUTTON, new GuiItemColor()); commands.SetGuiItemsGroupLabel("Commands", commandRects.GetLast(), new GuiItemColor(GuiColor.White)); List <Rect> toggleCommandRects = new Rect(drawRect.x, SNWindow.GetNextYPos(ref commandRects), drawRect.width, drawRect.height).SetGridItemsRect(4, 5, ITEMSIZE, SPACE, SPACE, true, true); toggleCommands.CreateGuiItemsGroup(buttonText.ToggleButtons, toggleCommandRects, GuiItemType.TOGGLEBUTTON, new GuiItemColor(GuiColor.Red, GuiColor.Green)); toggleCommands.SetGuiItemsGroupLabel("Toggle Commands", toggleCommandRects.GetLast(), new GuiItemColor(GuiColor.White)); List <Rect> daynightTabrects = new Rect(drawRect.x, SNWindow.GetNextYPos(ref toggleCommandRects), drawRect.width, drawRect.height).SetGridItemsRect(6, 1, ITEMSIZE, SPACE, SPACE, true, true); daynightTab.CreateGuiItemsGroup(buttonText.DayNightTab, daynightTabrects, GuiItemType.TAB, new GuiItemColor()); daynightTab.SetGuiItemsGroupLabel("Day/Night Speed:", daynightTabrects.GetLast(), new GuiItemColor(GuiColor.White)); List <Rect> categoriesTabrects = new Rect(drawRect.x, SNWindow.GetNextYPos(ref daynightTabrects), drawRect.width, drawRect.height).SetGridItemsRect(4, 5, ITEMSIZE, SPACE, SPACE, true, true); categoriesTab.CreateGuiItemsGroup(buttonText.CategoriesTab, categoriesTabrects, GuiItemType.TAB, new GuiItemColor(GuiColor.Gray, GuiColor.Green, GuiColor.White)); categoriesTab.SetGuiItemsGroupLabel("Categories:", categoriesTabrects.GetLast(), new GuiItemColor(GuiColor.White)); float nextYpos = SNWindow.GetNextYPos(ref categoriesTabrects); scrollRect = new Rect(drawRect.x + SPACE, nextYpos, drawRect.width - (SPACE * 2), drawRect.height - nextYpos); List <Rect>[] scrollItemRects = new List <Rect> [tMatrix.Length + 1]; for (int i = 0; i < tMatrix.Length; i++) { float width = drawRect.width; if (i == 0 && tMatrix[0].Count > MAXSHOWITEMS) { width -= 20; } if (tMatrix[i].Count * (ITEMSIZE + SPACE) > scrollRect.height) { width -= 20; } scrollItemRects[i] = SNWindow.SetGridItemsRect(new Rect(0, 0, width, tMatrix[i].Count * (ITEMSIZE + SPACE)), 1, tMatrix[i].Count, ITEMSIZE, SPACE, 2, false, false, true); } int warpCounts = WarpTargets_Internal.Count + WarpTargets_User.Count; scrollItemRects[tMatrix.Length] = SNWindow.SetGridItemsRect(new Rect(0, 0, drawRect.width - 20, warpCounts * (ITEMSIZE + SPACE)), 1, warpCounts, ITEMSIZE, SPACE, 2, false, false, true); scrollItemsList = new List <GuiItem> [tMatrix.Length + 1]; for (int i = 0; i < tMatrix.Length; i++) { scrollItemsList[i] = new List <GuiItem>(); CreateTechGroup(tMatrix[i], scrollItemRects[i], GuiItemType.NORMALBUTTON, ref scrollItemsList[i], new GuiItemColor(GuiColor.Gray, GuiColor.Green, GuiColor.White), GuiItemState.NORMAL, true, FontStyle.Normal, TextAnchor.MiddleLeft); } scrollItemsList[tMatrix.Length] = new List <GuiItem>(); AddListToGroup(GetWarpTargetNames(), scrollItemRects[tMatrix.Length], GuiItemType.NORMALBUTTON, ref scrollItemsList[tMatrix.Length], new GuiItemColor(GuiColor.Gray, GuiColor.Green, GuiColor.White), GuiItemState.NORMAL, true, FontStyle.Normal, TextAnchor.MiddleLeft); var searchSeaGlide = new TechnologyMatrix.TechTypeSearch(TechType.Seaglide); string seaglideName = tMatrix[1][tMatrix[1].FindIndex(searchSeaGlide.EqualsWith)].Name; var searchSeamoth = new TechnologyMatrix.TechTypeSearch(TechType.Seamoth); seamothName = tMatrix[0][tMatrix[0].FindIndex(searchSeamoth.EqualsWith)].Name; var searchExosuit = new TechnologyMatrix.TechTypeSearch(TechType.Exosuit); exosuitName = tMatrix[0][tMatrix[0].FindIndex(searchExosuit.EqualsWith)].Name; var searchCyclops = new TechnologyMatrix.TechTypeSearch(TechType.Cyclops); cyclopsName = tMatrix[0][tMatrix[0].FindIndex(searchCyclops.EqualsWith)].Name; string[] vehicleSetButtons = { $"{seamothName} Can Fly", $"{seaglideName} Speed Fast" }; float scrollRectheight = 5 * (scrollItemsList[0][0].Rect.height + 2); float y = scrollRect.y + scrollRectheight + SPACE; List <Rect> vehicleSettingsRects = new Rect(drawRect.x, y, drawRect.width, drawRect.height).SetGridItemsRect(2, 1, ITEMSIZE, SPACE, SPACE, false, true); vehicleSettings.CreateGuiItemsGroup(vehicleSetButtons, vehicleSettingsRects, GuiItemType.TOGGLEBUTTON, new GuiItemColor(GuiColor.Red, GuiColor.Green)); vehicleSettings.SetGuiItemsGroupLabel("Vehicle settings:", vehicleSettingsRects.GetLast(), new GuiItemColor(GuiColor.White)); string[] sliderLabels = { $"{seamothName} speed multiplier:", $"{exosuitName} speed multiplier:", $"{cyclopsName} speed multiplier:" }; List <Rect> slidersRects = new Rect(drawRect.x, SNWindow.GetNextYPos(ref vehicleSettingsRects), drawRect.width, drawRect.height).SetGridItemsRect(1, 3, SLIDERHEIGHT, SPACE, SPACE, false, false); sliders.CreateGuiItemsGroup(sliderLabels, slidersRects, GuiItemType.HORIZONTALSLIDER, new GuiItemColor()); sliders[0].OnChangedEvent = onSeamothSpeedValueChanged; sliders[1].OnChangedEvent = onExosuitSpeedValueChanged; sliders[2].OnChangedEvent = onCyclopsSpeedValueChanged; string[] warpExtrasButtons = { "Add current position to list", "Remove selected from list" }; scrollRectheight = 11 * (scrollItemsList[0][0].Rect.height + 2); y = scrollRect.y + scrollRectheight + SPACE + 2; List <Rect> warpExtrasRects = new Rect(drawRect.x, y, drawRect.width, drawRect.height).SetGridItemsRect(2, 1, ITEMSIZE, SPACE, SPACE, false, false); warpExtras.CreateGuiItemsGroup(warpExtrasButtons, warpExtrasRects, GuiItemType.NORMALBUTTON, new GuiItemColor()); commands[(int)Commands.BackWarp].Enabled = false; commands[(int)Commands.BackWarp].State = GuiItemState.PRESSED; daynightTab.SetStateInverseTAB(4); categoriesTab[0].State = GuiItemState.PRESSED; seamothSpeedMultiplier = 1; exosuitSpeedMultiplier = 1; cyclopsSpeedMultiplier = 1; SNLogger.Debug("CheatManager", "Awake completed."); }