/// <summary> /// Compares the given <see cref="Plugin"/>s. /// </summary> /// <param name="x">An object to compare to another object.</param> /// <param name="y">An object to compare to another object.</param> /// <returns>A value less than 0 if <paramref name="x"/> is less than <paramref name="y"/>. /// 0 if this node is equal to the other. /// A value greater than 0 if <paramref name="x"/> is greater than <paramref name="y"/>.</returns> public override int Compare(Plugin x, Plugin y) { if (x == null) return (y == null) ? 0 : -1; if (y == null) return 1; return StringComparer.OrdinalIgnoreCase.Compare(x.Filename, y.Filename); }
/// <summary> /// Activates the given plugin. /// </summary> /// <param name="p_plgPlugin">The plugin to activate.</param> public void ActivatePlugin(Plugin p_plgPlugin) { if (!IsPluginActive(p_plgPlugin)) GetEnlistment().ActivatePlugin(p_plgPlugin); }
/// <summary> /// Removes the given plugin from the order list. /// </summary> /// <param name="p_plgPlugin">The plugin to remove from the order list.</param> public void RemovePlugin(Plugin p_plgPlugin) { GetEnlistment().RemovePlugin(p_plgPlugin); }
/// <summary> /// Sets the load order of the specifid plugin. /// </summary> /// <param name="p_plgPlugin">The plugin whose load order is to be set.</param> /// <param name="p_intNewIndex">The new load order index of the plugin.</param> public void SetPluginOrderIndex(Plugin p_plgPlugin, int p_intNewIndex) { PluginOrderLog.SetPluginOrderIndex(p_plgPlugin, p_intNewIndex); }
/// <summary> /// Determines if the active state of the given plugin can be changed. /// </summary> /// <param name="p_plgPlugin">The plugin for which it is to be determined if the active state can be changed.</param> /// <returns><c>true</c> if the given plugin's active state can be changed; /// <c>false</c> otherwise.</returns> public bool CanChangeActiveState(Plugin p_plgPlugin) { return !GameMode.IsCriticalPlugin(p_plgPlugin); }
/// <summary> /// Removes the given plugin from the list of managed plugins. /// </summary> /// <param name="p_plgPlugin">The plugin to remove.</param> public void RemovePlugin(Plugin p_plgPlugin) { ActivePluginLog.DeactivatePlugin(p_plgPlugin); PluginOrderLog.RemovePlugin(p_plgPlugin); ManagedPluginRegistry.UnregisterPlugin(p_plgPlugin); }
/// <summary> /// Removes the specified plugin from the registry. /// </summary> /// <param name="p_plgPlugin">The plugin to unregister.</param> public void UnregisterPlugin(Plugin p_plgPlugin) { m_setManagedPlugins.Remove(p_plgPlugin); m_setRemovedPlugins.Add(p_plgPlugin); if (CurrentTransaction == null) Commit(); else Enlist(); }
/// <summary> /// Gets the hashcode to use for the given <see cref="Plugin"/>. /// </summary> /// <param name="obj">The <see cref="Plugin"/> whose hashcode is to be determined.</param> /// <returns>The hascode to use for the given <see cref="Plugin"/>.</returns> public override int GetHashCode(Plugin obj) { if ((obj == null) || (obj.Filename == null)) return 53; return obj.Filename.GetHashCode(); }
public void ActivatePlugin(Plugin p_plgPlugin) { // nop }
public void SetPluginOrderIndex(Plugin p_plgPlugin, int p_intNewIndex) { // nop }
public void RemovePlugin(Plugin p_plgPlugin) { // nop }
public Int32 GetPluginOrderIndex(Plugin p_plgPlugin) { return -1; }
public bool CanChangeActiveState(Plugin p_plgPlugin) { return false; }
/// <summary> /// Determines if the given plugin is active. /// </summary> /// <param name="p_plgPlugin">The plugin whose active state is to be determined.</param> /// <returns><c>true</c> if the given plugin is active; /// <c>false</c> otherwise.</returns> public bool IsPluginActive(Plugin p_plgPlugin) { return GetEnlistment().IsPluginActive(p_plgPlugin); }
/// <summary> /// Deactivates the given plugin. /// </summary> /// <param name="p_plgPlugin">The plugin to deactivate.</param> public void DeactivatePlugin(Plugin p_plgPlugin) { GetEnlistment().DeactivatePlugin(p_plgPlugin); }
/// <summary> /// Deactivates the given plugin. /// </summary> /// <param name="p_plgPlugin">The plugin to deactivate.</param> public void DeactivatePlugin(Plugin p_plgPlugin) { m_ostActivePlugins.Remove(p_plgPlugin); if (CurrentTransaction == null) Commit(); else Enlist(); }
/// <summary> /// Determines if the given plugin is active. /// </summary> /// <param name="p_plgPlugin">The plugin whose active state is to be determined.</param> /// <returns><c>true</c> if the given plugin is active; /// <c>false</c> otherwise.</returns> public bool IsPluginActive(Plugin p_plgPlugin) { return m_ostActivePlugins.Contains(p_plgPlugin); }
/// <summary> /// Adds the given plugin to the view's list. If the plugin already exists in the list, /// it is replaced with the new version. /// </summary> /// <param name="p_plgAdded">The plugin to add to the view's list.</param> protected void AddPluginToList(Plugin p_plgAdded) { InsertPluginToList(rlvPlugins.Items.Count, p_plgAdded); }
/// <summary> /// Inserts the given plugin to the view's list. If the plugin already exists in the list, /// it is replaced with the new version an moved to the given index. /// </summary> /// <param name="p_intIndex">The index at which to insert the plugin.</param> /// <param name="p_plgAdded">The plugin to add to the view's list.</param> protected void InsertPluginToList(Int32 p_intIndex, Plugin p_plgAdded) { Int32 intLineTracker = 0; try { ListViewItem lviPlugin = null; intLineTracker = 1; if (rlvPlugins.Items.ContainsKey(p_plgAdded.Filename.ToLowerInvariant())) { intLineTracker = 2; lviPlugin = rlvPlugins.Items[p_plgAdded.Filename.ToLowerInvariant()]; intLineTracker = 3; if (lviPlugin.Index != p_intIndex) { intLineTracker = 4; rlvPlugins.Items.Remove(lviPlugin); intLineTracker = 5; rlvPlugins.Items.Insert(p_intIndex, lviPlugin); intLineTracker = 6; } intLineTracker = 7; } else { intLineTracker = 8; lviPlugin = new ListViewItem(); intLineTracker = 9; for (Int32 i = 1; i < rlvPlugins.Columns.Count; i++) { intLineTracker = 10; lviPlugin.SubItems.Add(new ListViewItem.ListViewSubItem()); intLineTracker = 11; lviPlugin.SubItems[i].Name = rlvPlugins.Columns[i].Name; intLineTracker = 12; } intLineTracker = 13; lviPlugin.Name = p_plgAdded.Filename.ToLowerInvariant(); intLineTracker = 14; if (p_intIndex > rlvPlugins.Items.Count - 1) { intLineTracker = 15; rlvPlugins.Items.Add(lviPlugin); } else { intLineTracker = 16; rlvPlugins.Items.Insert(p_intIndex, lviPlugin); } intLineTracker = 17; } intLineTracker = 18; lviPlugin.Tag = p_plgAdded; intLineTracker = 19; lviPlugin.Text = Path.GetFileName(p_plgAdded.Filename); intLineTracker = 20; SetPluginActivationCheck(lviPlugin, ViewModel.ActivePlugins.Contains(p_plgAdded)); if (!ViewModel.CanChangeActiveState(p_plgAdded)) lviPlugin.ForeColor = SystemColors.GrayText; intLineTracker = 21; RefreshPluginIndices(); intLineTracker = 22; } catch (NullReferenceException) { Trace.TraceError(String.Format("InsertPluginToList: NullReferenceException: LineTracker: {0}, Plugin: {1}", intLineTracker, p_plgAdded)); throw; } }
/// <summary> /// Show the given plugin as being either active or inactive in the view. /// </summary> /// <param name="p_plgActivated">The plugin whose active status has changed.</param> /// <param name="p_booIsActive">Whether the given plugin is active.</param> protected void SetPluginActive(Plugin p_plgActivated, bool p_booIsActive) { if (!rlvPlugins.Items.ContainsKey(p_plgActivated.Filename.ToLowerInvariant())) return; ListViewItem lviPlugin = rlvPlugins.Items[p_plgActivated.Filename.ToLowerInvariant()]; SetPluginActivationCheck(lviPlugin, p_booIsActive); }
/// <summary> /// Removes the given plugin from the registry. /// </summary> /// <param name="p_plgPlugin">The plugin to unregister.</param> public void UnregisterPlugin(Plugin p_plgPlugin) { GetEnlistment().UnregisterPlugin(p_plgPlugin); }
/// <summary> /// Activates the given plugin. /// </summary> /// <param name="p_plgPlugin">The plugin to activate.</param> public void ActivatePlugin(Plugin p_plgPlugin) { PluginManager.ActivatePlugin(p_plgPlugin); }
/// <summary> /// Deactivates the given plugin. /// </summary> /// <param name="p_plgPlugin">The plugin to deactivate.</param> public void DeactivatePlugin(Plugin p_plgPlugin) { ActivePluginLog.DeactivatePlugin(p_plgPlugin); }
/// <summary> /// deactivates the given plugin. /// </summary> /// <param name="p_plgPlugin">The plugin to deactivate.</param> public void DeactivatePlugin(Plugin p_plgPlugin) { PluginManager.DeactivatePlugin(p_plgPlugin); }
/// <summary> /// Gets the load order of the specifid plugin. /// </summary> /// <param name="p_plgPlugin">The plugin whose load order is to be returned.</param> /// <returns>The index of the given plugin, or -1 if the plugin is not being managed.</returns> public Int32 GetPluginOrderIndex(Plugin p_plgPlugin) { return PluginOrderLog.OrderedPlugins.IndexOf(p_plgPlugin); }
/// <summary> /// Determines if the active state of the given plugin can be changed. /// </summary> /// <param name="p_plgPlugin">The plugin for which it is to be determined if the active state can be changed.</param> /// <returns><c>true</c> if the given plugin's active state can be changed; /// <c>false</c> otherwise.</returns> public bool CanChangeActiveState(Plugin p_plgPlugin) { return PluginManager.CanChangeActiveState(p_plgPlugin); }
/// <summary> /// Sets the load order of the specified plugin. /// </summary> /// <param name="p_plgPlugin">The full path to the plugin file whose load order is to be set.</param> /// <param name="p_intNewIndex">The new load order index of the plugin.</param> public void SetPluginOrderIndex(Plugin p_plgPlugin, int p_intNewIndex) { List<Plugin> lstPlugins = new List<Plugin>(OrderedPlugins); lstPlugins.Remove(p_plgPlugin, PluginComparer.Filename); if (p_intNewIndex > lstPlugins.Count) p_intNewIndex = lstPlugins.Count; lstPlugins.Insert(p_intNewIndex, p_plgPlugin); SetPluginOrder(lstPlugins); }
/// <summary> /// Determines if the given plugin can be moved up in the load order. /// </summary> /// <param name="p_plgPlugin">The plugin for which it is to be determined if the load order can be decreased.</param> /// <returns><c>true</c> if the given plugin's load order can be decreased; /// <c>false</c> otherwise.</returns> public bool CanMovePluginUp(Plugin p_plgPlugin) { Int32 intOldIndex = PluginManager.ManagedPlugins.IndexOf(p_plgPlugin); if (intOldIndex < 1) return false; List<Plugin> lstPlugins = new List<Plugin>(PluginManager.ManagedPlugins); lstPlugins.Swap(intOldIndex, intOldIndex - 1); return PluginManager.ValidateOrder(lstPlugins); }
/// <summary> /// Determines if the given plugin is critical to the current game. /// </summary> /// <remarks> /// Critical plugins cannot be reordered, cannot be deleted, cannot be deactivated, and cannot have plugins ordered above them. /// </remarks> /// <param name="p_plgPlugin">The plugin for which it is to be determined whether or not it is critical.</param> /// <returns><c>true</c> if the specified pluing is critical; /// <c>false</c> otherwise.</returns> public bool IsCriticalPlugin(Plugin p_plgPlugin) { return OrderedCriticalPluginNames.Contains(p_plgPlugin.Filename.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar), StringComparer.OrdinalIgnoreCase); }
/// <summary> /// Removes the given plugin from the order list. /// </summary> /// <param name="p_plgPlugin">The plugin to remove from the order list.</param> public void RemovePlugin(Plugin p_plgPlugin) { m_oclOrderedPlugins.Remove(p_plgPlugin, PluginComparer.Filename); if (CurrentTransaction == null) Commit(); else Enlist(); }