/// <summary> /// Sorts the plugins. /// </summary> /// <param name="p_strPlugins">The plugins list.</param> /// <returns>The list of plugins sorted.</returns> public string[] SortPlugins(string[] p_strPlugins) { UInt32 uintStatus = 0; string[] strSortedPlugins = p_strPlugins; IntPtr ptrPlugins = IntPtr.Zero; UInt32 numPlugins; if (!String.IsNullOrEmpty(MasterlistPath)) { if (!File.Exists(MasterlistPath)) { UpdateMasterlist(); } } uintStatus = m_dlgSortPlugins(m_ptrSorterDb, out ptrPlugins, out numPlugins); if (uintStatus == 0) { UInt32 uintListLength = numPlugins; using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8")) uintStatus = m_dlgApplyLoadOrder(m_ptrSorterDb, ammMarshaler.MarshalManagedToNative(MarshalPluginArray(ptrPlugins, uintListLength, true)), uintListLength); if (uintStatus == 0) { return(RemoveNonExistentPlugins(MarshalPluginArray(ptrPlugins, uintListLength, false))); } } return(null); }
/// <summary> /// Sets the load order of the plugins. /// </summary> /// <remarks> /// The returned list of sorted plugins will include plugins that were not /// included in the specified order list, if plugins exist that weren't included. /// The extra plugins will be apeended to the end of the given order. /// </remarks> /// <param name="p_strPlugins">The list of plugins in the desired order.</param> public void SetLoadOrder(string[] p_strPlugins) { string[] strSortedPlugins = p_strPlugins; UInt32 uintStatus = 0; using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8")) uintStatus = m_dlgApplyLoadOrder(m_ptrSorterDb, ammMarshaler.MarshalManagedToNative(StripPluginDirectory(strSortedPlugins)), Convert.ToUInt32(strSortedPlugins.Length)); HandleStatusCode(uintStatus); }
/// <summary> /// Marshal the given pointer to an array of plugins. /// </summary> /// <remarks> /// This adjusts the plugin paths to be in the format expected by the mod manager. /// </remarks> /// <param name="p_ptrPluginArray">The pointer to the array of plugin names to marshal.</param> /// <param name="p_uintLength">the length of the array to marshal.</param> /// <returns>The array of plugins names pointed to by the given pointer.</returns> protected string[] MarshalPluginArray(IntPtr p_ptrPluginArray, UInt32 p_uintLength, bool p_booKeepRelativePath) { if (p_ptrPluginArray == IntPtr.Zero) { return(null); } string[] strPlugins = null; using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8")) strPlugins = ammMarshaler.MarshalNativeToManaged(p_ptrPluginArray, Convert.ToInt32(p_uintLength)); if (!p_booKeepRelativePath) { for (Int32 i = strPlugins.Length - 1; i >= 0; i--) { strPlugins[i] = Path.Combine(GameMode.PluginDirectory, strPlugins[i]); } } return(strPlugins); }
/// <summary> /// Sorts the plugins. /// </summary> /// <param name="p_strPlugins">The plugins list.</param> /// <returns>The list of plugins sorted.</returns> public string[] SortPlugins(string[] p_strPlugins) { UInt32 uintStatus = 0; string[] strSortedPlugins = p_strPlugins; IntPtr ptrPlugins = IntPtr.Zero; UInt32 numPlugins; if (!String.IsNullOrEmpty(MasterlistPath)) if (!File.Exists(MasterlistPath)) UpdateMasterlist(); uintStatus = m_dlgSortPlugins(m_ptrSorterDb, out ptrPlugins, out numPlugins); if (uintStatus == 0) { UInt32 uintListLength = numPlugins; using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8")) uintStatus = m_dlgApplyLoadOrder(m_ptrSorterDb, ammMarshaler.MarshalManagedToNative(MarshalPluginArray(ptrPlugins, uintListLength, true)), uintListLength); if (uintStatus == 0) return RemoveNonExistentPlugins(MarshalPluginArray(ptrPlugins, uintListLength, false)); } return null; }
/// <summary> /// Marshal the given pointer to an array of plugins. /// </summary> /// <remarks> /// This adjusts the plugin paths to be in the format expected by the mod manager. /// </remarks> /// <param name="p_ptrPluginArray">The pointer to the array of plugin names to marshal.</param> /// <param name="p_uintLength">the length of the array to marshal.</param> /// <returns>The array of plugins names pointed to by the given pointer.</returns> protected string[] MarshalPluginArray(IntPtr p_ptrPluginArray, UInt32 p_uintLength, bool p_booKeepRelativePath) { if (p_ptrPluginArray == IntPtr.Zero) return null; string[] strPlugins = null; using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8")) strPlugins = ammMarshaler.MarshalNativeToManaged(p_ptrPluginArray, Convert.ToInt32(p_uintLength)); if (!p_booKeepRelativePath) for (Int32 i = strPlugins.Length - 1; i >= 0; i--) strPlugins[i] = Path.Combine(GameMode.PluginDirectory, strPlugins[i]); return strPlugins; }