public ButterLibSettingsContainer(ILogger <ButterLibSettingsContainer> logger)
        {
            RootFolder = Path.Combine(FSIOHelper.GetConfigPath() !, "ModSettings");

            var prop = new StorageRef <DropdownDefault <string> >(new(new[]
            {
                $"{{=2Tp85Cpa}}{LogLevel.Trace}",
                $"{{=Es0LPYu1}}{LogLevel.Debug}",
                $"{{=fgLroxa7}}{LogLevel.Information}",
                $"{{=yBflFuRG}}{LogLevel.Warning}",
                $"{{=7tpjjYSV}}{LogLevel.Error}",
                $"{{=CarGIPlL}}{LogLevel.Critical}",
                $"{{=T3FtC5hh}}{LogLevel.None}"
            }, 2));
            var displayName = new TextObject("{=ButterLibSettings_Name}ButterLib {VERSION}", new()
            {
                { "VERSION", typeof(ButterLibSubModule).Assembly.GetName().Version?.ToString(3) ?? "ERROR" }
            }).ToString();
            var settings = BaseSettingsBuilder.Create("Options", displayName)?.SetFolderName("ButterLib").SetFormat("json2")
                           .CreateGroup("{=ButterLibSettings_Name_Logging}Logging", builder =>
                                        builder.AddDropdown("MinLogLevel", "{=ButterLibSettings_Name_LogLevel}Log Level", 0, prop, dBuilder =>
                                                            dBuilder.SetOrder(1).SetRequireRestart(true).SetHintText("{=ButterLibSettings_Name_LogLevelDesc}Level of logs to write.")))
                           .AddButterLibSubSystems()
                           .BuildAsGlobal();

            RegisterSettings(settings);
        }
        public void Setup()
        {
            var harmony = new Harmony($"{nameof(DependencyInjectionTests)}.{nameof(Setup)}");

            harmony.Patch(SymbolExtensions.GetMethodInfo(() => FSIOHelper.GetConfigPath()),
                          prefix: new HarmonyMethod(DelegateHelper.GetMethodInfo(MockedGetConfigPath)));
            harmony.Patch(SymbolExtensions2.GetPropertyInfo(() => TWCommon.ConfigName).GetMethod,
                          prefix: new HarmonyMethod(DelegateHelper.GetMethodInfo(MockedGetConfigName)));
            var engineUtilitiesType = Type.GetType("TaleWorlds.Engine.Utilities, TaleWorlds.Engine", false);

            harmony.Patch(engineUtilitiesType?.GetMethod("GetModulesNames", BindingFlags.Public | BindingFlags.Static),
                          prefix: new HarmonyMethod(DelegateHelper.GetMethodInfo(MockedGetModuleNames)));

            var subModule        = new ButterLibSubModule();
            var subModuleWrapper = new MBSubModuleBaseWrapper(subModule);

            subModuleWrapper.SubModuleLoad();
            ExceptionHandlerSubSystem.Instance?.Disable();

            var services = ButterLibSubModule.Instance !.GetServices() !;

            services.AddScoped <CampaignDescriptor, CampaignDescriptorImplementation>();
            services.AddSingleton <ICampaignDescriptorStatic, CampaignDescriptorStaticImplementation>();
            services.AddScoped(typeof(DistanceMatrix <>), typeof(DistanceMatrixImplementation <>));
            services.AddSingleton <IDistanceMatrixStatic, DistanceMatrixStaticImplementation>();
            services.AddSingleton <ICampaignExtensions, CampaignExtensionsImplementation>();
            subModuleWrapper.BeforeInitialModuleScreenSetAsRoot();
        }
Example #3
0
        public void Setup()
        {
            var harmony = new Harmony($"{nameof(JsonSerializationTests)}.{nameof(Setup)}");

            harmony.Patch(SymbolExtensions.GetMethodInfo(() => FSIOHelper.GetConfigPath()),
                          prefix: new HarmonyMethod(DelegateHelper.GetMethodInfo(MockedGetConfigPath)));

            var binFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) !;
            var d1        = Directory.GetFiles(binFolder, "TaleWorlds*.dll");
            var d2        = Directory.GetFiles(binFolder, "StoryMode*.dll");
            var d3        = Directory.GetFiles(binFolder, "SandBox*.dll");

            foreach (string dll in d1.Concat(d2).Concat(d3))
            {
                Assembly.LoadFile(dll);
            }
        }
Example #4
0
        public ButterLibSettingsContainer(ILogger <ButterLibSettingsContainer> logger)
        {
            RootFolder = Path.Combine(FSIOHelper.GetConfigPath(), "ModSettings");

            RegisterSettings(new ButterLibSettings());
        }