Example #1
0
        internal static void Config_Load()
        {
            BZLogger.Debug("Method call: SEzConfig.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 = MAXSLOTS - 4;

                TEXTCOLOR = ColorHelper.GetColor(ParserHelper.GetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[1]));

                SLOT_LAYOUT = ParserHelper.GetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[2]) == "Circle" ? SlotLayout.Circle : SlotLayout.Grid;

                isSeatruckArmsExists = BZCommon.ReflectionHelper.IsNamespaceExists("SeaTruckArms");

                isSeatruckScannerModuleExists = BZCommon.ReflectionHelper.IsNamespaceExists("SeaTruckScannerModule");

                BZLogger.Log("Configuration loaded.");
            }
            catch
            {
                BZLogger.Error("An error occurred while loading the configuration file!");
            }
        }
        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!");
            }
        }