Пример #1
0
 public void get_plugin_type(string name, Type type)
 {
     PluginConfig c = new PluginConfig(new Config(new ResizerSection()));
     Type t = c.FindPluginType(name);
     Debug.WriteLine(new List<IIssue>(c.GetIssues())[0]);
     Assert.AreEqual<Type>(type, t);
 }
Пример #2
0
 private void DetermineEnabledAPIs(IEnumerable<API> apis, PluginConfig pluginConfig)
 {
     foreach (var api in apis)
     {
         api.Enabled = CheckIfEnabled(api.Assemblies,pluginConfig);                 
     }
 }
Пример #3
0
		protected virtual void SetConfig(PluginConfig value) {
			if (value == null)
				throw new NullReferenceException();

			if (ReferenceEquals(value, _config))
				return;

			_config = value;
		}
Пример #4
0
        public PluginConfig LoadPluginConfig()
        {
            var serializer = new XmlSerializer(typeof(PluginConfig));
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "pluginconfig.xml");
            using (StreamReader reader = new StreamReader(path))
            {
                _pluginConfig = (PluginConfig)serializer.Deserialize(reader);
            }

            return _pluginConfig;
        }
Пример #5
0
        private void LoadData()
        {
            var apis = _dataProvider.LoadAPIs();
            _pluginConfig = _pluginService.LoadPluginConfig();
            DetermineEnabledAPIs(apis, _pluginConfig);

            foreach (var api in apis)
            {
                APIs.Add(api);
            }

            SelectedAPI = APIs.Count > 0 ? APIs.First() : null;

        }
Пример #6
0
        private bool CheckIfEnabled(List<string> assemblies, PluginConfig pluginConfig)
        {
            var enabled = false;
            var publicAssemblies = pluginConfig.Items.OfType<PluginConfigPublicAssemblies>().FirstOrDefault();

            if (publicAssemblies == null) return enabled;

            foreach (var publicAssembly in publicAssemblies.PublicAssembly)
            {
                enabled = assemblies.Contains(publicAssembly.name);
            }

            return enabled;

        }
Пример #7
0
        private PluginConfig AdditionalConfig(PluginConfig config)
        {
            config.WipeEmbed = new DiscordMessageConfig
            {
                Content = config.WipeEmbed?.Content ?? "@everyone",
                Embed   = new EmbedConfig
                {
                    Title       = config.WipeEmbed?.Embed?.Title ?? ServerName,
                    Description = config.WipeEmbed?.Embed?.Description ?? "The server has wiped!",
                    Color       = config.WipeEmbed?.Embed?.Color ?? "#de8732",
                    Image       = config.WipeEmbed?.Embed?.Image ?? MapAttachment,
                    Thumbnail   = config.WipeEmbed?.Embed?.Thumbnail ?? string.Empty,
                    Fields      = config.WipeEmbed?.Embed?.Fields ?? new List <FieldConfig>
                    {
                        new FieldConfig
                        {
                            Title   = "Seed",
                            Value   = $"[{MapSeed}](http://playrust.io/map/?Procedural%20Map_{MapSize}_{MapSeed})",
                            Inline  = true,
                            Order   = 1,
                            Enabled = true
                        },
                        new FieldConfig
                        {
                            Title   = "Size",
                            Value   = $"{MapSize} ({MapSizeSquared}km^2)",
                            Inline  = true,
                            Order   = 2,
                            Enabled = true
                        },
                        new FieldConfig
                        {
                            Title   = "Protocol",
                            Value   = Protocol,
                            Inline  = true,
                            Order   = 3,
                            Enabled = true
                        },
                        new FieldConfig
                        {
                            Title   = "Click & Connect",
                            Value   = $"steam://connect/{ServerIp}:{ServerPort}",
                            Inline  = false,
                            Order   = 4,
                            Enabled = true
                        }
                    },
                    Footer = new FooterConfig
                    {
                        IconUrl = config.WipeEmbed?.Embed?.Footer?.IconUrl ?? string.Empty,
                        Text    = config.WipeEmbed?.Embed?.Footer?.Text ?? string.Empty,
                        Enabled = config.WipeEmbed?.Embed?.Footer?.Enabled ?? true
                    },
                    Enabled = config.WipeEmbed?.Embed?.Enabled ?? true
                }
            };

            config.ProtocolEmbed = new DiscordMessageConfig
            {
                Content = config.ProtocolEmbed?.Content ?? "@everyone",
                Embed   = new EmbedConfig
                {
                    Title       = config.ProtocolEmbed?.Embed?.Title ?? ServerName,
                    Description = config.ProtocolEmbed?.Embed?.Description ?? "The server protocol has changed!",
                    Color       = config.ProtocolEmbed?.Embed?.Color ?? "#de8732",
                    Image       = config.ProtocolEmbed?.Embed?.Image ?? string.Empty,
                    Thumbnail   = config.ProtocolEmbed?.Embed?.Thumbnail ?? string.Empty,
                    Fields      = config.ProtocolEmbed?.Embed?.Fields ?? new List <FieldConfig>
                    {
                        new FieldConfig
                        {
                            Title   = "Protocol",
                            Value   = Protocol,
                            Inline  = true,
                            Order   = 2,
                            Enabled = true
                        },
                        new FieldConfig
                        {
                            Title   = "Previous Protocol",
                            Value   = PreviousProtocol,
                            Inline  = true,
                            Order   = 3,
                            Enabled = true
                        },
                        new FieldConfig
                        {
                            Title   = "Mandatory Client Update",
                            Value   = "This update requires a mandatory client update in order to be able to play on the server",
                            Inline  = false,
                            Order   = 4,
                            Enabled = true
                        },
                        new FieldConfig
                        {
                            Title   = "Click & Connect",
                            Value   = $"steam://connect/{ServerIp}:{ServerPort}",
                            Inline  = false,
                            Order   = 5,
                            Enabled = true
                        }
                    },
                    Footer = new FooterConfig
                    {
                        IconUrl = config.ProtocolEmbed?.Embed?.Footer?.IconUrl ?? string.Empty,
                        Text    = config.ProtocolEmbed?.Embed?.Footer?.Text ?? string.Empty,
                        Enabled = config.ProtocolEmbed?.Embed?.Footer?.Enabled ?? true
                    },
                    Enabled = config.ProtocolEmbed?.Embed?.Enabled ?? true
                }
            };
            return(config);
        }
 protected override void LoadConfig()
 {
     base.LoadConfig();
     _config = Config.ReadObject <PluginConfig>();
 }
Пример #9
0
 public void Construct(PluginConfig pluginConfig, NoteListViewController listViewController)
 {
     _pluginConfig       = pluginConfig;
     _listViewController = listViewController;
 }
Пример #10
0
 protected override void LoadDefaultConfig() => _config = PluginConfig.DefaultConfig();
Пример #11
0
        private void ProcQueue(RegistryProcessStarter queueItem, Object oStarter)
        {
            LocalTheadObjects starter = null;

            StringBuilder tLog = new StringBuilder();

            try
            {
                if ((oStarter != null) && (oStarter is LocalTheadObjects))
                {
                    starter = (LocalTheadObjects)oStarter;
                }

                if (starter == null)
                {
                    throw new Exception("Thread object starts is null");
                }

                if (starter.db == null)
                {
                    throw new Exception("Thread object starts database is null");
                }

                if (queueItem == null)
                {
                    throw new Exception("Queue item is null");
                }

                if (starter.lockRules == null)
                {
                    throw new Exception("Lock rules is null");
                }

                if (starter.ignoreRules == null)
                {
                    throw new Exception("Ignore rules is null");
                }

                if (starter.roleRules == null)
                {
                    throw new Exception("Role rules is null");
                }

                if (licControl == null)
                {
                    throw new Exception("Licence control is null");
                }

                if (entKeys == null)
                {
                    throw new Exception("Enterprise keys is null");
                }

                if (entKeys[queueItem.enterpriseId] == null)
                {
                    throw new Exception("Enterprise key of enterprise " + queueItem.enterpriseId + " is null");
                }

                if (licControl[queueItem.enterpriseId] == null)
                {
                    throw new Exception("Licence control of enterprise " + queueItem.enterpriseId + " is null");
                }

                PluginConfig pluginConfig = null;

                if ((pluginConfig == null) || (pluginConfig.resource_plugin != queueItem.resourcePluginId))
                {
                    if (pluginConfig != null)
                    {
                        pluginConfig.Dispose();
                        pluginConfig = null;
                    }

                    using (DataTable dtContext = starter.db.Select("select p.scheme, rp.* from resource_plugin rp with(nolock) inner join plugin p with(nolock) on rp.plugin_id = p.id where rp.id = " + queueItem.resourcePluginId))
                    {
                        if ((dtContext != null) && (dtContext.Rows.Count > 0))
                        {
                            pluginConfig = new PluginConfig(starter.db.Connection, dtContext.Rows[0]["scheme"].ToString(), (Int64)dtContext.Rows[0]["plugin_id"], (Int64)dtContext.Rows[0]["id"]);
                        }
                    }
                }

                if (pluginConfig == null)
                {
                    throw new Exception("Resource x plugin not found");
                }

                if (starter.debugCallback != null)
                {
                    starter.debugCallback("Package ID: " + queueItem.packageId);
                }

                //Realiza todo o processamento deste registro

                using (RegistryProcess proc = new RegistryProcess(localConfig.SqlServer, localConfig.SqlDb, localConfig.SqlUsername, localConfig.SqlPassword, pluginConfig, queueItem))
                {
                    RegistryProcess.ProccessLog log = new RegistryProcess.ProccessLog(delegate(String text)
                    {
                        tLog.AppendLine(text);
                    });


                    proc.OnLog += log;
                    RegistryProcessStatus status = proc.Process((EnterpriseKeyConfig)entKeys[queueItem.enterpriseId].Clone(), starter.lockRules, starter.ignoreRules, starter.roleRules, licControl[queueItem.enterpriseId]);
                    proc.OnLog -= log;

                    starter.db.AddUserLog(LogKey.Import, null, "Engine", (status == RegistryProcessStatus.Error ? UserLogLevel.Error : UserLogLevel.Info), 0, 0, 0, queueItem.resourceId, queueItem.pluginId, proc.EntityId, proc.IdentityId, "Import processed", tLog.ToString());

                    if (status == RegistryProcessStatus.OK)
                    {
                        Console.Write(".");

                        if (proc.NewUser)
                        {
                            newUsers++;
                        }
                    }
                    else if (status == RegistryProcessStatus.Ignored)
                    {
                        ignored++;
                    }
                    else
                    {
                        Console.Write("!");
                        errors++;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write("!");
                errors++;


                if (starter.debugCallback != null)
                {
                    starter.debugCallback("\tError processing package (" + queueItem.packageId + "): " + ex.Message);
                }

//#if !DEBUG
                try
                {
                    tLog.AppendLine("Package: " + queueItem.package);
                }
                catch { }

                tLog.AppendLine("StackTrace: " + ex.StackTrace);
//#endif


                starter.db.AddUserLog(LogKey.Import, null, "Engine", UserLogLevel.Error, 0, 0, 0, queueItem.resourceId, queueItem.pluginId, 0, 0, ex.Message, tLog.ToString());
                starter.db.ExecuteNonQuery("update collector_imports set status = 'E' where status = 'F' and resource_plugin_id = '" + queueItem.resourcePluginId + "' and  import_id = '" + queueItem.importId + "' and package_id = '" + queueItem.packageId + "'", CommandType.Text, null);
            }
            finally
            {
                tLog = null;

                atualReg++;

                percent = ((Double)(atualReg) / (Double)totalReg) * 100F;

                if (iPercent != (Int32)percent)
                {
                    iPercent = (Int32)percent;
                    TextLog.Log("Engine", "Importer", "\t" + iPercent + "% -> New users: " + newUsers + ", Ignored: " + ignored + ", Errors: " + errors + ", Updated: " + (atualReg - errors - ignored - newUsers));

                    Console.Write(" " + iPercent + "% ");

                    Taskbar.TaskbarProgress.SetProgressValue((Int32)atualReg, (Int32)totalReg, System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
                }
            }
        }
Пример #12
0
        public RegistryProcess(String server, String dbName, String username, String password, PluginConfig pluginConfig, RegistryProcessStarter starter)
        {
            this.db    = new IAMDatabase(server, dbName, username, password);
            this.dbAux = new IAMDatabase(server, dbName, username, password);

            iRegistryProcess(pluginConfig, starter);
        }
Пример #13
0
        /// <summary>
        /// Handle updates and additions to configuration.
        /// Only needed if new settings shouldn't be set to default values in (some) existing config files
        /// </summary>
        private static void UpdateConfig()
        {
            // Get latest version from default config values
            int latestVersion = new PluginConfig().ConfigVersion;

            // Do nothing if config is already up to date
            if (ConfigVersion == latestVersion)
            {
                return;
            }

            // v1/v2 -> v3: Added enable/disable options for trail and scale modifications
            // Updating v2 as well because of a beta build that is floating around with v2 already being used
            if (ConfigVersion == 1 || ConfigVersion == 2)
            {
                // Due to changes in Beat Saber 1.12.2, just reset trail settings to default for these old config files
                Trail.TweakEnabled = false;

                // Check scale modifications and disable tweak if settings are default
                if (ScaleCfg.Length == 100 && ScaleCfg.Girth == 100)
                {
                    Scale.TweakEnabled = false;
                }
                else
                {
                    // else enable tweak and hitbox scaling to preserve existing settings
                    Scale.TweakEnabled = true;
                    Scale.ScaleHitBox  = true;
                }
                ConfigVersion = 3;
            }

            if (ConfigVersion == 3)
            {
                // v3 -> v4: Added enable/disable option for saber grip, disabled by default, will override base game option
                // For existing configurations: Enable, if non-default settings are present
                bool gripAdjPresent = false;
                if (GripCfg.PosLeft != Int3.zero || GripCfg.RotLeft != Int3.zero ||
                    GripCfg.PosRight != Int3.zero || GripCfg.RotRight != Int3.zero)
                {
                    gripAdjPresent = true;
                }

                Grip.IsGripModEnabled = gripAdjPresent;
                ConfigVersion         = 4;
            }

            if (ConfigVersion == 4)
            {
                // v4 -> v5: Added toggle to change adjustment mode (switch between SaberTailor or base game adjustment mode)
                // For existing configuration: Enable, if non-default settings are present
                bool gripAdjPresent = false;
                if (GripCfg.PosLeft != Int3.zero || GripCfg.RotLeft != Int3.zero ||
                    GripCfg.PosRight != Int3.zero || GripCfg.RotRight != Int3.zero)
                {
                    gripAdjPresent = true;
                }

                Grip.UseBaseGameAdjustmentMode = !gripAdjPresent;
                ConfigVersion = 5;
            }

            // Updater done - set to latest version and save
            ConfigVersion = latestVersion;
            Save();
        }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigPage" /> class.
 /// </summary>
 /// <param name="HS">The hs.</param>
 /// <param name="pluginConfig">The plugin configuration.</param>
 public ConfigPage(IHSApplication HS, PluginConfig pluginConfig) : base(HS, pluginConfig, Name)
 {
 }
Пример #15
0
 internal ShaderManager(ShaderAssetLoader shaderAssetLoader, PluginConfig pluginConfig)
 {
     _shaderAssetLoader = shaderAssetLoader;
     _pluginConfig      = pluginConfig;
 }
Пример #16
0
 public NuisanceManager([InjectOptional] Submission submission, PluginConfig pluginConfig, DSAssetLoader assetLoader)
 {
     _submission   = submission;
     _pluginConfig = pluginConfig;
     _assetLoader  = assetLoader;
 }
 public void RaiseConfigChenged(PluginConfig Config)
 {
     OnConfigChenged?.Invoke(this, new PluginConfigChengedEventArgs(Config));
 }
Пример #18
0
 public void OnApplicationQuit()
 {
     PluginConfig.SaveConfig();
 }
Пример #19
0
        private IEnumerator SetupUI()
        {
            if (initialized)
            {
                yield break;
            }

            RectTransform mainMenu = (Resources.FindObjectsOfTypeAll <MainMenuViewController>().First().rectTransform);

            var downloaderSubMenu = SettingsUI.CreateSubMenu("Downloader");

            var disableDeleteButton = downloaderSubMenu.AddBool("Disable delete button");

            disableDeleteButton.GetValue += delegate { return(PluginConfig.disableDeleteButton); };
            disableDeleteButton.SetValue += delegate(bool value) { PluginConfig.disableDeleteButton = value; PluginConfig.SaveConfig(); };

            var deleteToRecycleBin = downloaderSubMenu.AddBool("Delete to Recycle Bin");

            deleteToRecycleBin.GetValue += delegate { return(PluginConfig.deleteToRecycleBin); };
            deleteToRecycleBin.SetValue += delegate(bool value) { PluginConfig.deleteToRecycleBin = value; PluginConfig.SaveConfig(); };

            var enableSongIcons = downloaderSubMenu.AddBool("Enable additional song icons");

            enableSongIcons.GetValue += delegate { return(PluginConfig.enableSongIcons); };
            enableSongIcons.SetValue += delegate(bool value) { PluginConfig.enableSongIcons = value; PluginConfig.SaveConfig(); };

            var maxSimultaneousDownloads = downloaderSubMenu.AddInt("Max simultaneous downloads", 1, 10, 1);

            maxSimultaneousDownloads.GetValue += delegate { return(PluginConfig.maxSimultaneousDownloads); };
            maxSimultaneousDownloads.SetValue += delegate(int value) { PluginConfig.maxSimultaneousDownloads = value; PluginConfig.SaveConfig(); };

            _moreSongsButton = MenuButtonUI.AddButton("More songs", "Download more songs from BeatSaver.com!", BeatSaverButtonPressed);
            _moreSongsButton.interactable = SongLoader.AreSongsLoaded;

            MenuButtonUI.AddButton("More playlists", PlaylistsButtonPressed);

            yield return(null);


            initialized = true;
        }
Пример #20
0
 public CustomNotesGameInstaller(PluginConfig pluginConfig, NoteAssetLoader noteAssetLoader, GameplayCoreSceneSetupData gameplayCoreSceneSetupData)
 {
     _pluginConfig               = pluginConfig;
     _noteAssetLoader            = noteAssetLoader;
     _gameplayCoreSceneSetupData = gameplayCoreSceneSetupData;
 }
 private PluginAppInstaller(Logger logger, PluginConfig config, PluginMetadata metadata)
 {
     _logger   = logger;
     _config   = config;
     _metadata = metadata;
 }
Пример #22
0
        private IEnumerator SetupUI()
        {
            if (initialized)
            {
                yield break;
            }

            var downloaderSubMenu = SettingsUI.CreateSubMenu("Downloader");

            var disableDeleteButton = downloaderSubMenu.AddBool("Disable delete button");

            disableDeleteButton.GetValue += delegate { return(PluginConfig.disableDeleteButton); };
            disableDeleteButton.SetValue += delegate(bool value) { PluginConfig.disableDeleteButton = value; PluginConfig.SaveConfig(); };

            var deleteToRecycleBin = downloaderSubMenu.AddBool("Delete to Recycle Bin");

            deleteToRecycleBin.GetValue += delegate { return(PluginConfig.deleteToRecycleBin); };
            deleteToRecycleBin.SetValue += delegate(bool value) { PluginConfig.deleteToRecycleBin = value; PluginConfig.SaveConfig(); };

            var enableSongIcons = downloaderSubMenu.AddBool("Enable additional song icons");

            enableSongIcons.GetValue += delegate { return(PluginConfig.enableSongIcons); };
            enableSongIcons.SetValue += delegate(bool value) { PluginConfig.enableSongIcons = value; PluginConfig.SaveConfig(); };

            var rememberLastPackAndSong = downloaderSubMenu.AddBool("Remember last pack and song");

            rememberLastPackAndSong.GetValue += delegate { return(PluginConfig.rememberLastPackAndSong); };
            rememberLastPackAndSong.SetValue += delegate(bool value) { PluginConfig.rememberLastPackAndSong = value; PluginConfig.SaveConfig(); };

            var maxSimultaneousDownloads = downloaderSubMenu.AddInt("Max simultaneous downloads", 1, 10, 1);

            maxSimultaneousDownloads.GetValue += delegate { return(PluginConfig.maxSimultaneousDownloads); };
            maxSimultaneousDownloads.SetValue += delegate(int value) { PluginConfig.maxSimultaneousDownloads = value; PluginConfig.SaveConfig(); };

            var fastScrollSpeed = downloaderSubMenu.AddInt("Fast scroll speed", 2, 20, 1);

            fastScrollSpeed.GetValue += delegate { return(PluginConfig.fastScrollSpeed); };
            fastScrollSpeed.SetValue += delegate(int value) { PluginConfig.fastScrollSpeed = value; PluginConfig.SaveConfig(); };

            _moreSongsButton = MenuButtonUI.AddButton("More songs", "Download more songs from BeatSaver.com!", BeatSaverButtonPressed);
            //bananbread songloader loaded menubutton
            _moreSongsButton.interactable = SongCore.Loader.AreSongsLoaded;

            MenuButtonUI.AddButton("More playlists", PlaylistsButtonPressed);

            yield return(null);

            initialized = true;
        }
Пример #23
0
 internal void Construct(PluginConfig pluginConfig, PresenceController presenceController)
 {
     _pluginConfig       = pluginConfig;
     _presenceController = presenceController;
     Set();
 }
Пример #24
0
 private AppInstaller(PluginConfig config, Logger logger)
 {
     _config = config;
     _logger = logger;
 }
Пример #25
0
 private void ConfigReloaded(PluginConfig _)
 {
     _menuActivity = RebuildActivity();
 }
Пример #26
0
 /// <summary>
 /// Clean up the plugin
 /// </summary>
 public void Dispose()
 {
     this.system = null;
     this.config = null;
 }
Пример #27
0
 public OnAppInstaller(Logger logger, PluginConfig config)
 {
     _config = config;
     _logger = logger;
 }
 internal SettingsController(PluginConfig configuration)
 {
     _configuration = configuration;
 }
Пример #29
0
        private void LoadPluginFeatures(XDocument document)
        {
            var features = from feats in document.Descendants()
                           where feats.Name.LocalName == "feature"
                           select feats;

            foreach (var feature in features)
            {
                string name = (string)feature.Attribute("name");
                var value = (from results in feature.Descendants()
                             where results.Name.LocalName == "param" && ((string)results.Attribute("name") == "wp-package")
                             select results).FirstOrDefault();

                var autoloadNode = (from results in feature.Descendants()
                                    where results.Name.LocalName == "param" && ((string)results.Attribute("name") == "onload")
                                    select results).FirstOrDefault();
                bool isAutoLoad = false;
                if (autoloadNode != null)
                {
                    isAutoLoad = ((string)autoloadNode.Attribute("value") == "true");
                }

                if (value != null)
                {
                    string key = (string)value.Attribute("value");
                    Debug.WriteLine("Adding feature.value=" + key);
                    PluginConfig pConfig = new PluginConfig(key, isAutoLoad);
                    AllowedPlugins[name] = pConfig;

                }

            }
        }
 protected override void LoadDefaultConfig()
 {
     PrintWarning("Сreate a new configuration file");
     _config = new PluginConfig()
     {
         ListItem = new Dictionary <string, string[]>()
         {
             ["cupboard.tool.deployed"] = new[]
             {
                 "cloth",
                 "scrap",
                 "sulfur",
                 "sulfur.ore",
                 "charcoal",
                 "hq.metal.ore",
                 "fat.animal",
                 "leather",
                 "crude.oil",
                 "gunpowder",
                 "metal.ore",
                 "lowgradefuel"
             },
             ["campfire"] = new[]
             {
                 "metal.ore",
                 "fat.animal",
                 "stones",
                 "cctv.camera",
                 "leather",
                 "targeting.computer",
                 "metal.refined",
                 "scrap",
                 "bone.fragments",
                 "gunpowder",
                 "sulfur",
                 "sulfur.ore"
             },
             ["bbq.deployed"] = new[]
             {
                 "metal.ore",
                 "fat.animal",
                 "stones",
                 "cctv.camera",
                 "leather",
                 "targeting.computer",
                 "metal.refined",
                 "scrap",
                 "bone.fragments",
                 "gunpowder",
                 "sulfur",
                 "sulfur.ore"
             },
             ["dropbox.deployed"] = new[]
             {
                 "metal.ore",
                 "fat.animal",
                 "stones",
                 "leather",
                 "metal.refined",
                 "scrap",
                 "bone.fragments",
                 "gunpowder",
                 "sulfur",
                 "sulfur.ore",
                 "crude.oil",
                 "lowgradefuel",
                 "cloth",
                 "explosive.timed",
                 "explosive.satchel",
                 "grenade.beancan",
                 "grenade.f1",
                 "explosives"
             },
             ["furnace"] = new[]
             {
                 "fat.animal",
                 "stones",
                 "cctv.camera",
                 "leather",
                 "targeting.computer",
                 "bone.fragments",
                 "crude.oil",
                 "gunpowder",
                 "lowgradefuel",
                 "jackhammer",
                 "cloth",
                 "chainsaw",
                 "explosive.timed"
             },
             ["furnace.large"] = new[]
             {
                 "fat.animal",
                 "stones",
                 "cctv.camera",
                 "leather",
                 "targeting.computer",
                 "bone.fragments",
                 "crude.oil",
                 "gunpowder",
                 "lowgradefuel",
                 "jackhammer",
                 "cloth",
                 "chainsaw",
                 "explosive.timed"
             }
         }
     };
 }
Пример #31
0
 protected PageHelper(IHSApplication HS, PluginConfig pluginConfig, string pageName, Logger logger) : base(pageName)
 {
     this.HS           = HS;
     this.pluginConfig = pluginConfig;
     this.logger       = logger;
 }
 protected override void LoadDefaultConfig()
 {
     PrintWarning("New configuration file created!!");
     config = PluginConfig.DefaultConfig();
 }
Пример #33
0
        private void LoadPluginFeatures(XDocument document)
        {
            var features = from feats in document.Descendants()
                           where feats.Name.LocalName == "feature"
                           select feats;

            foreach (var feature in features)
            {
                var name = feature.Attribute("name");
                var values = from results in feature.Descendants()
                             where results.Name.LocalName == "param" && ((string)results.Attribute("name") == "wp-package")
                             select results;

                var value = values.FirstOrDefault();
                if (value != null)
                {
                    string key = (string)value.Attribute("value");
                    Debug.WriteLine("Adding feature.value=" + key);
                    var onload = value.Attribute("onload");
                    PluginConfig pConfig = new PluginConfig(key, onload != null && onload.Value == "true");
                    AllowedPlugins[key] = pConfig;
                }
            }
        }
Пример #34
0
 public void OnApplicationQuit()
 {
     SceneManager.activeSceneChanged -= SceneManagerOnActiveSceneChanged;
     SceneManager.sceneLoaded        -= SceneManager_sceneLoaded;
     PluginConfig.SaveConfig();
 }
Пример #35
0
 internal ShaderCore(PluginConfig pluginConfig)
 {
     _pluginConfig = pluginConfig;
 }
Пример #36
0
 private void Init()
 {
     myConfig = Config.ReadObject <PluginConfig>();
 }
Пример #37
0
        private IEnumerator VoteForSong(bool upvote)
        {
            Logger.Log($"Voting...");

            _upvoteButton.interactable   = false;
            _downvoteButton.interactable = false;

            UnityWebRequest voteWWW = UnityWebRequest.Get($"{PluginConfig.beatsaverURL}/api/songs/vote/{_lastBeatSaverSong.id}/{(upvote ? 1 : 0)}/{PluginConfig.apiAccessToken}");

            voteWWW.timeout = 30;
            yield return(voteWWW.SendWebRequest());

            if (voteWWW.isNetworkError || voteWWW.isHttpError)
            {
                Logger.Error(voteWWW.error);
                _ratingText.text = voteWWW.error;
            }
            else
            {
                if (!_firstVote)
                {
                    yield return(new WaitForSecondsRealtime(3f));
                }

                _firstVote = false;

                switch (voteWWW.responseCode)
                {
                case 200:
                {
                    JSONNode node = JSON.Parse(voteWWW.downloadHandler.text);
                    _ratingText.text = (int.Parse(node["upVotes"]) - int.Parse(node["downVotes"])).ToString();

                    if (upvote)
                    {
                        _upvoteButton.interactable   = false;
                        _downvoteButton.interactable = true;
                    }
                    else
                    {
                        _downvoteButton.interactable = false;
                        _upvoteButton.interactable   = true;
                    }

                    if (!PluginConfig.votedSongs.ContainsKey(_lastLevel.levelID.Substring(0, 32)))
                    {
                        PluginConfig.votedSongs.Add(_lastLevel.levelID.Substring(0, 32), new SongVote(_lastBeatSaverSong.id, upvote ? VoteType.Upvote : VoteType.Downvote));
                        PluginConfig.SaveConfig();
                    }
                    else if (PluginConfig.votedSongs[_lastLevel.levelID.Substring(0, 32)].voteType != (upvote ? VoteType.Upvote : VoteType.Downvote))
                    {
                        PluginConfig.votedSongs[_lastLevel.levelID.Substring(0, 32)] = new SongVote(_lastBeatSaverSong.id, upvote ? VoteType.Upvote : VoteType.Downvote);
                        PluginConfig.SaveConfig();
                    }
                }; break;

                case 403:
                {
                    _upvoteButton.interactable   = false;
                    _downvoteButton.interactable = false;
                    _ratingText.text             = "Read-only token";
                }; break;

                case 401:
                {
                    _upvoteButton.interactable   = false;
                    _downvoteButton.interactable = false;
                    _ratingText.text             = "Token not found";
                }; break;

                case 400:
                {
                    _upvoteButton.interactable   = false;
                    _downvoteButton.interactable = false;
                    _ratingText.text             = "Bad token";
                }; break;

                default:
                {
                    _upvoteButton.interactable   = true;
                    _downvoteButton.interactable = true;
                    _ratingText.text             = "Error " + voteWWW.responseCode;
                }; break;
                }
            }
        }
        private void LoadPluginFeatures(XDocument document)
        {
            var plugins = from results in document.Descendants("plugin")
                          select new
                          {
                              name = (string)results.Attribute("name"),
                              autoLoad = results.Attribute("onload")
                          };

            foreach (var plugin in plugins)
            {
                Debug.WriteLine("Warning: Deprecated use of <plugin> by plugin : " + plugin.name);
                PluginConfig pConfig = new PluginConfig(plugin.name, plugin.autoLoad != null && plugin.autoLoad.Value == "true");
                if (pConfig.Name == "*")
                {
                    AllowAllPlugins = true;
                    // break; wait, don't, some still could be autoload
                }
                else
                {
                    AllowedPlugins[pConfig.Name] = pConfig;
                }
            }

            var features = document.Descendants("feature");

            foreach (var feature in features)
            {
                var name = feature.Attribute("name");
                var values = from results in feature.Descendants("param")
                             where ((string)results.Attribute("name") == "wp-package")
                             select results;

                var value = values.FirstOrDefault();
                if (value != null)
                {
                    string key = (string)value.Attribute("value");
                    Debug.WriteLine("Adding feature.value=" + key);
                    var onload = value.Attribute("onload");
                    PluginConfig pConfig = new PluginConfig(key, onload != null && onload.Value == "true");
                    AllowedPlugins[key] = pConfig;
                }
            }
        }
Пример #39
0
 protected override void LoadDefaultConfig()
 {
     Config.Settings.Converters.Add(new Vector2Converter());
     PrintWarning("Creating default config for FurnaceSplitter.");
     config = new PluginConfig();
 }
Пример #40
0
        public void LoadAppPackageConfig()
        {
            StreamResourceInfo streamInfo = Application.GetResourceStream(new Uri("config.xml", UriKind.Relative));

            if (streamInfo != null)
            {
                StreamReader sr = new StreamReader(streamInfo.Stream);
                //This will Read Keys Collection for the xml file
               XDocument document = XDocument.Parse(sr.ReadToEnd());

                var plugins = from results in document.Descendants("plugin")
                              select new
                              {
                                  name = (string)results.Attribute("name"),
                                  autoLoad = results.Attribute("onload")
                              };

                foreach (var plugin in plugins)
                {
                    Debug.WriteLine("plugin " + plugin.name);
                    PluginConfig pConfig = new PluginConfig(plugin.name, plugin.autoLoad != null && plugin.autoLoad.Value == "true");
                    if (pConfig.Name == "*")
                    {
                        AllowAllPlugins = true;
                        // break; wait, don't, some still could be autoload
                    }
                    else
                    {
                        AllowedPlugins.Add(pConfig.Name, pConfig);
                    }
                }

                var preferences = from results in document.Descendants("preference")
                                  select new
                                  {
                                      name = (string)results.Attribute("name"),
                                      value = (string)results.Attribute("value")
                                  };

                foreach (var pref in preferences)
                {
                    Debug.WriteLine("pref" + pref.name + ", " + pref.value);
                }

                var accessList = from results in document.Descendants("access")
                                 select new
                                 {
                                     origin = (string)results.Attribute("origin"),
                                     subdomains = (string)results.Attribute("subdomains") == "true"
                                 };

                foreach (var accessElem in accessList)
                {
                    AddWhiteListEntry(accessElem.origin, accessElem.subdomains);
                }
            }
            else
            {
                // no config.xml, allow all
                AllowAllDomains = true;
                AllowAllPlugins = true;
            }
        }
Пример #41
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (AppContext.ConfigurationFile.PluginConfiguration.Plugins != null)
            {
                foreach (KeyValuePair<string, PluginInfo> kv in plugins)
                {
                    PluginConfig config = AppContext.ConfigurationFile.PluginConfiguration.Plugins[kv.Key];
                    if (config == null)
                    {
                        config = new PluginConfig();
                        config.Title = kv.Key;
                        AppContext.ConfigurationFile.PluginConfiguration.Plugins.Add(config);
                    }

                    try
                    {
                        config.Configuration = kv.Value.Plugin.Configuration;
                    }
                    catch (NotImplementedException) { }
                }
            }

            AppContext.ConfigurationFile.Save(Settings.Default.PluginConfigFile);

            base.OnClosing(e);
        }