Esempio n. 1
0
        bool InstallPlugin(IAbsoluteDirectoryPath gamePath, IContentEngineContent mod, string plugin, bool force)
        {
            if (!gamePath.IsNotNullAndExists())
            {
                throw new ArgumentNullException("Unable to find the Game Install Directory");
            }
            if (mod == null)
            {
                throw new ArgumentNullException(nameof(mod), "Fatal Error Occured: Mod incorrectly registered");
            }
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin), "Fatal Error Occured: Plugin Path was not set");
            }

            if (!mod.IsInstalled || !mod.PathInternal.IsNotNullAndExists())
            {
                throw new InvalidOperationException("The mod is not installed");
            }

            var pluginPath       = mod.PathInternal.GetChildFileWithName(plugin);
            var gamePluginFolder = gamePath;

            return(InstallDll(pluginPath, gamePluginFolder, force));
        }
Esempio n. 2
0
        public void InstallDllPlugin(IContentEngineGame game, IContentEngineContent content, string plugin,
                                     bool force = false)
        {
            var success = TryInstallPlugin(game.WorkingDirectory, content, plugin, force);

            MainLog.Logger.Info("Install Success?: " + success);
        }
Esempio n. 3
0
 async Task LoadModSFromStream(IContentEngineContent content, IContentEngineGame game)
 {
     using (var streamR = new StreamReader(_resourceService.GetResource(GetScriptPath(content.Id)))) {
         var js = streamR.ReadToEnd();
         await HandleCommand(content, game, js).ConfigureAwait(false);
     }
 }
Esempio n. 4
0
        bool InstallPlugin(IAbsoluteDirectoryPath tsPath, IContentEngineContent mod, string plugin, bool force)
        {
            if (!tsPath.IsNotNullAndExists())
            {
                throw new ArgumentNullException("Unable to find the Teamspeak Install Directory");
            }

            if (mod == null)
            {
                throw new ArgumentNullException(nameof(mod), "Fatal Error Occured: Mod incorrectly registered");
            }
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin), "Fatal Error Occured: Plugin Path was not set");
            }

            if (!mod.IsInstalled || !mod.PathInternal.IsNotNullAndExists())
            {
                throw new InvalidOperationException("The mod is not installed");
            }

            var pluginPath     = Path.Combine(mod.PathInternal.ToString(), plugin).ToAbsoluteFilePath();
            var tsPluginFolder = GetPluginPath(tsPath);

            return(InstallDll(pluginPath, tsPluginFolder, force));
        }
Esempio n. 5
0
 public Task LoadModS(IContentEngineContent mod, IContentEngineGame game, bool overrideMod = false)
 {
     if (!ModHasScript(mod))
     {
         throw new Exception("This mod does not have a Script");
     }
     return(LoadModSFromStream(mod, game));
 }
Esempio n. 6
0
        private static void InstallDll(IContentEngineContent content, IContentEngineGame game, InstallDllCommand c)
        {
            var s = new GameFolderService();

            foreach (var f in c.Source)
            {
                s.InstallDllPlugin(game, content, f, c.Options.Force);
            }
        }
 public bool TryGetMod(IContentEngineContent mod, out RegisteredMod registeredMod) {
     try {
         registeredMod = GetMod(mod);
         return true;
     } catch (Exception e) {
         _logger.FormattedWarnException(e, "Failure getting mod");
     }
     registeredMod = null;
     return false;
 }
 bool TryInstallPlugin(IAbsoluteDirectoryPath tsPath, IContentEngineContent mod, string plugin, bool force) {
     try {
         return InstallPlugin(tsPath, mod, plugin, force);
     } catch (PathDoesntExistException e) {
         MainLog.Logger.FormattedWarnException(e, "Path: " + e.Path);
     } catch (Win32Exception e) {
         MainLog.Logger.FormattedWarnException(e);
     } catch (Exception ex) {
         MainLog.Logger.FormattedErrorException(ex);
     }
     return false;
 }
Esempio n. 9
0
 public IModS LoadModS(IContentEngineContent mod, bool overrideMod = false) {
     if (!ModHasScript(mod))
         throw new Exception("This mod does not have a Script");
     RegisteredMod loadedMod;
     if (_scriptRegistry.TryGetMod(mod.NetworkId, out loadedMod)) {
         if (overrideMod)
             loadedMod.Mod = mod;
         return loadedMod.ModScript;
     }
     var modS = LoadModSFromStream(mod.NetworkId);
     FinalizeLoadMod(mod, modS);
     return modS;
 }
Esempio n. 10
0
 bool TryInstallPlugin(IAbsoluteDirectoryPath gamePath, IContentEngineContent mod, string plugin, bool force)
 {
     try {
         return(InstallPlugin(gamePath, mod, plugin, force));
     } catch (PathDoesntExistException e) {
         MainLog.Logger.FormattedWarnException(e, "Path: " + e.Path);
     } catch (Win32Exception e) {
         MainLog.Logger.FormattedWarnException(e);
     } catch (Exception ex) {
         MainLog.Logger.FormattedErrorException(ex);
     }
     return(false);
 }
Esempio n. 11
0
 private static void InstallTeamspeakFiles(IContentEngineContent content, InstallTeamspeakPluginCommand c) {
     var s = new TeamspeakService();
     foreach (var f in c.Files) {
         switch (f.Type) {
         case TsType.Any: {
             foreach (var f2 in f.Source) {
                 var p = Path.Combine(content.PathInternal.ToString(), f2);
                 if (Directory.Exists(p)) {
                     if (s.IsX86Installed())
                         s.InstallX86PluginFolder(content, p, c.Options.Force);
                     if (s.IsX64Installed())
                         s.InstallX64PluginFolder(content, p, c.Options.Force);
                 } else {
                     if (s.IsX86Installed())
                         s.InstallX86Plugin(content, p, c.Options.Force);
                     if (s.IsX64Installed())
                         s.InstallX64Plugin(content, p, c.Options.Force);
                 }
             }
             break;
         }
         case TsType.x86: {
             if (!s.IsX86Installed())
                 return;
             foreach (var f2 in f.Source) {
                 var p = Path.Combine(content.PathInternal.ToString(), f2);
                 if (Directory.Exists(p)) {
                     s.InstallX86PluginFolder(content, p, c.Options.Force);
                 } else {
                     s.InstallX86Plugin(content, p, c.Options.Force);
                 }
             }
             break;
         }
         case TsType.x64: {
             if (!s.IsX64Installed())
                 return;
             foreach (var f2 in f.Source) {
                 var p = Path.Combine(content.PathInternal.ToString(), f2);
                 if (Directory.Exists(p)) {
                     s.InstallX64PluginFolder(content, p, c.Options.Force);
                 } else {
                     s.InstallX64Plugin(content, p, c.Options.Force);
                 }
             }
             break;
         }
         }
     }
 }
        bool InstallPlugin(IAbsoluteDirectoryPath gamePath, IContentEngineContent mod, string plugin, bool force) {
            Contract.Requires<ArgumentNullException>(gamePath.IsNotNullAndExists(),
                "Unable to find the Game Install Directory");
            Contract.Requires<ArgumentNullException>(mod != null, "Fatal Error Occured: Mod incorrectly registered");
            Contract.Requires<ArgumentNullException>(plugin != null, "Fatal Error Occured: Plugin Path was not set");

            if (!mod.IsInstalled || !mod.PathInternal.IsNotNullAndExists())
                throw new InvalidOperationException("The mod is not installed");

            var pluginPath = mod.PathInternal.GetChildFileWithName(plugin);
            var gamePluginFolder = gamePath;

            return InstallDll(pluginPath, gamePluginFolder, force);
        }
Esempio n. 13
0
 private static async Task HandleCommand(IContentEngineContent content, IContentEngineGame game, string js) {
     var bc = js.FromJson<CommandBase>();
     switch (bc.Command) {
     case Commands.installDll: {
         var c = js.FromJson<InstallDllCommand>();
         InstallDll(content, game, c);
         break;
     }
     case Commands.installTeamspeakPlugin: {
         var c = js.FromJson<InstallTeamspeakPluginCommand>();
         InstallTeamspeakFiles(content, c);
         break;
     }
     }
 }
Esempio n. 14
0
        private static async Task HandleCommand(IContentEngineContent content, IContentEngineGame game, string js)
        {
            var bc = js.FromJson <CommandBase>();

            switch (bc.Command)
            {
            case Commands.installDll: {
                var c = js.FromJson <InstallDllCommand>();
                InstallDll(content, game, c);
                break;
            }

            case Commands.installTeamspeakPlugin: {
                var c = js.FromJson <InstallTeamspeakPluginCommand>();
                InstallTeamspeakFiles(content, c);
                break;
            }
            }
        }
Esempio n. 15
0
 public bool ModHasScript(IContentEngineContent mod) => ModHasScript(mod.NetworkId);
Esempio n. 16
0
 async Task LoadModSFromStream(IContentEngineContent content, IContentEngineGame game) {
     using (var streamR = new StreamReader(_resourceService.GetResource(GetScriptPath(content.Id)))) {
         var js = streamR.ReadToEnd();
         await HandleCommand(content, game, js).ConfigureAwait(false);
     }
 }
Esempio n. 17
0
 private static void InstallDll(IContentEngineContent content, IContentEngineGame game, InstallDllCommand c) {
     var s = new GameFolderService();
     foreach (var f in c.Source)
         s.InstallDllPlugin(game, content, f, c.Options.Force);
 }
Esempio n. 18
0
 public Task LoadModS(IContentEngineContent mod, IContentEngineGame game, bool overrideMod = false) {
     if (!ModHasScript(mod))
         throw new Exception("This mod does not have a Script");
     return LoadModSFromStream(mod, game);
 }
        public void InstallX64PluginFolder(IContentEngineContent content, string plugin, bool force = false) {
            var success = TryInstallPluginFolder(TS3_64_Path, content, plugin, force);

            MainLog.Logger.Info("Install Success?: " + success);
        }
Esempio n. 20
0
 public void UnregisterMod(IContentEngineContent mod) {
     UnregisterMod(GetMod(mod));
 }
Esempio n. 21
0
 void FinalizeLoadMod(IContentEngineContent mod, IModS modS) {
     var registeredMod = new RegisteredMod(mod.NetworkId, mod, modS);
     _scriptRegistry.RegisterMod(registeredMod);
 }
Esempio n. 22
0
 public RegisteredMod GetMod(IContentEngineContent mod) {
     return GetMod(mod.Id);
 }
Esempio n. 23
0
 internal RegisteredMod(Guid guid, IContentEngineContent mod, IModS modScript) {
     Guid = guid;
     Mod = mod;
     ModScript = modScript;
     AccessToken = Convert.ToBase64String(Guid.NewGuid().ToByteArray().Combine(guid.ToByteArray()));
     ModScript.setToken(AccessToken);
 }
Esempio n. 24
0
 public bool ModHasScript(IContentEngineContent mod) {
     return ModHasScript(mod.NetworkId);
 }
        public void InstallDllPlugin(IContentEngineGame game, IContentEngineContent content, string plugin,
            bool force = false) {
            var success = TryInstallPlugin(game.WorkingDirectory, content, plugin, force);

            MainLog.Logger.Info("Install Success?: " + success);
        }
Esempio n. 26
0
        public void InstallX64PluginFolder(IContentEngineContent content, string plugin, bool force = false)
        {
            var success = TryInstallPluginFolder(TS3_64_Path, content, plugin, force);

            MainLog.Logger.Info("Install Success?: " + success);
        }
Esempio n. 27
0
 public bool ModHasScript(IContentEngineContent mod) => ModHasScript(mod.NetworkId);
Esempio n. 28
0
        bool InstallPlugin(IAbsoluteDirectoryPath tsPath, IContentEngineContent mod, string plugin, bool force) {
            Contract.Requires<ArgumentNullException>(tsPath.IsNotNullAndExists(),
                "Unable to find the Teamspeak Install Directory");
            Contract.Requires<ArgumentNullException>(mod != null, "Fatal Error Occured: Mod incorrectly registered");
            Contract.Requires<ArgumentNullException>(plugin != null, "Fatal Error Occured: Plugin Path was not set");

            if (!mod.IsInstalled || !mod.PathInternal.IsNotNullAndExists())
                throw new InvalidOperationException("The mod is not installed");

            var pluginPath = Path.Combine(mod.PathInternal.ToString(), plugin).ToAbsoluteFilePath();
            var tsPluginFolder = GetPluginPath(tsPath);

            return InstallDll(pluginPath, tsPluginFolder, force);
        }
Esempio n. 29
0
        private static void InstallTeamspeakFiles(IContentEngineContent content, InstallTeamspeakPluginCommand c)
        {
            var s = new TeamspeakService();

            foreach (var f in c.Files)
            {
                switch (f.Type)
                {
                case TsType.Any: {
                    foreach (var f2 in f.Source)
                    {
                        var p = Path.Combine(content.PathInternal.ToString(), f2);
                        if (Directory.Exists(p))
                        {
                            if (s.IsX86Installed())
                            {
                                s.InstallX86PluginFolder(content, p, c.Options.Force);
                            }
                            if (s.IsX64Installed())
                            {
                                s.InstallX64PluginFolder(content, p, c.Options.Force);
                            }
                        }
                        else
                        {
                            if (s.IsX86Installed())
                            {
                                s.InstallX86Plugin(content, p, c.Options.Force);
                            }
                            if (s.IsX64Installed())
                            {
                                s.InstallX64Plugin(content, p, c.Options.Force);
                            }
                        }
                    }
                    break;
                }

                case TsType.x86: {
                    if (!s.IsX86Installed())
                    {
                        return;
                    }
                    foreach (var f2 in f.Source)
                    {
                        var p = Path.Combine(content.PathInternal.ToString(), f2);
                        if (Directory.Exists(p))
                        {
                            s.InstallX86PluginFolder(content, p, c.Options.Force);
                        }
                        else
                        {
                            s.InstallX86Plugin(content, p, c.Options.Force);
                        }
                    }
                    break;
                }

                case TsType.x64: {
                    if (!s.IsX64Installed())
                    {
                        return;
                    }
                    foreach (var f2 in f.Source)
                    {
                        var p = Path.Combine(content.PathInternal.ToString(), f2);
                        if (Directory.Exists(p))
                        {
                            s.InstallX64PluginFolder(content, p, c.Options.Force);
                        }
                        else
                        {
                            s.InstallX64Plugin(content, p, c.Options.Force);
                        }
                    }
                    break;
                }
                }
            }
        }