Exemplo n.º 1
0
        public void Initialize(IManager manager, string ipcIdentifier)
        {
            Console.WriteLine($"Initializing ... ({ipcIdentifier})");
            CurrentPlugin.Initialize();
            EventSubscriber.Initialize();
            Flags.Initialize();
            ModuleManager.Initialize();
            Log.Success("Initialization done!");
            Log.Info(PluginSplashScreen.GetText());

            manager.Menus.AddMenu(MenuDisplayMode.Both, new MenuTree("distancetranslator.main", "LANGUAGE SETTINGS")
            {
                new ListBox <string>(MenuDisplayMode.Both, "distancetranslator.main.interfacelanguage", "INTERFACE LANGUAGE")
                .WithGetter(() => Configuration["InterfaceLanguage"].ToString())
                .WithSetter((value) =>
                {
                    Configuration["InterfaceLanguage"] = value;
                    Configuration.Save();
                    Language.Reload();
                })
                .WithEntries(LanguageFiles),

                new ListBox <string>(MenuDisplayMode.Both, "distancetranslator.main.subtitleslanguage", "SUBTITLES LANGUAGE")
                .WithGetter(() => Configuration["SubtitlesLanguage"].ToString())
                .WithSetter((value) =>
                {
                    Configuration["SubtitlesLanguage"] = value;
                    Configuration.Save();
                    Language.Reload();
                })
                .WithEntries(LanguageFiles)
            });

            try
            {
                Log.Info("Instantiating Harmony Patcher ...");
                HarmonyInstance Harmony = HarmonyInstance.Create("com.REHERC.DistanceTranslator");
                Log.Success("Harmony patcher instantiated!");
                Log.Info("Patching assemblies ...");
                Harmony.PatchAll(Assembly.GetExecutingAssembly());
                Log.Success("Assemblies patched!");
            }
            catch (Exception Archaic)
            {
                Log.Error("Failed to patch the assemblies!");
                Log.Exception(Archaic);
            }

            if (Configuration["Debug"] is true)
            {
                Log.Info("Binding hotkeys actions ...");
                manager.Hotkeys.Bind(Configuration.GetItem <string>("ReloadHotkey"), () => {
                    Language.Reload();
                });
                Log.Success("Hotkeys actions added!");
            }

            //"I love me a good toggle" ~ torcht 2018
        }
Exemplo n.º 2
0
 public void Initialize(IManager manager, string ipcIdentifier)
 {
     Console.WriteLine("Initializing ...");
     CurrentPlugin.initialize();
     CurrentPlugin.Log.Info("Initialization done!");
     try
     {
         CurrentPlugin.Log.Info("Instantiating Harmony Patcher ...");
         var Harmony = HarmonyInstance.Create("com.REHERC.DisableUnplayedCircle");
         CurrentPlugin.Log.Info("Harmony patcher instantiated!");
         CurrentPlugin.Log.Info("Patching assemblies ...");
         Harmony.PatchAll(Assembly.GetExecutingAssembly());
         CurrentPlugin.Log.Info("Assemblies patched!");
     }
     catch (Exception VirusSpirit)
     {
         CurrentPlugin.Log.Error("Failed to patch the assemblies !");
         CurrentPlugin.Log.Exception(VirusSpirit);
     }
 }