Fixes for latest NMM versions

This commit is contained in:
Silarn
2018-09-09 00:43:09 -05:00
parent 3980559fe7
commit 6e66c2c7e5
4 changed files with 510 additions and 517 deletions
+3
View File
@@ -1,2 +1,5 @@
/nmm
/NexusClientCLI/obj
/.vs
/.idea
/*.log
+75 -76
View File
@@ -1,76 +1,75 @@
/* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Nexus.Client.CLI
{
class DummyDataFileUtilFactory
{
private string m_installationPath;
private string m_gamePath;
private int m_copiedFiles = 0;
private List<string> m_searchPaths = new List<string>();
/// <summary>
/// Creates an instance of DummyDataFileUtilFactory.
/// </summary>
/// <param name="installationPath">The path where the current mod is being installed</param>
/// <param name="modlistFile">The path to the modlist.txt file</param>
/// <param name="modsPath">The path to the mods directory where previously installed mods are located</param>
public DummyDataFileUtilFactory(string installationPath, string modlistFile, string modsPath, string gamePath, List<string> additionalSearchPaths)
{
m_installationPath = installationPath;
m_gamePath = gamePath;
m_searchPaths = additionalSearchPaths;
m_searchPaths.Add(Path.Combine(m_installationPath, "data"));
StreamReader reader = new StreamReader(modlistFile);
string line;
while ((line = reader.ReadLine()) != null)
{
// A mod name per line
// Handle only activated mods (ignore inactive and unmanaged)
if (line[0] == '+')
{
string modName = line.Substring(1);
string modPath = Path.Combine(modsPath, modName);
// Ignore mod when it is being reinstalled
// That folder has no relevant data files anyway
// This happens when an activated mod is being reinstalled
if (modPath.Equals(m_installationPath, StringComparison.InvariantCultureIgnoreCase))
{
Logger.Debug("Ignoring mod {0} that appears to be the one that is being installed", modName);
}
else
{
m_searchPaths.Add(modPath);
}
}
}
}
/// <summary>
/// Create a new instance DummyDataFileUtil that will use the dummy data folder created by this factory.
/// </summary>
/// <returns>New instance of DummyDataFileUtil</returns>
public DummyDataFileUtil CreateDummyDataFileUtil()
{
return new DummyDataFileUtil(m_installationPath, m_gamePath, m_searchPaths);
}
}
}
/* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Nexus.Client.CLI
{
class DummyDataFileUtilFactory
{
private string m_installationPath;
private string m_gamePath;
private List<string> m_searchPaths = new List<string>();
/// <summary>
/// Creates an instance of DummyDataFileUtilFactory.
/// </summary>
/// <param name="installationPath">The path where the current mod is being installed</param>
/// <param name="modlistFile">The path to the modlist.txt file</param>
/// <param name="modsPath">The path to the mods directory where previously installed mods are located</param>
public DummyDataFileUtilFactory(string installationPath, string modlistFile, string modsPath, string gamePath, List<string> additionalSearchPaths)
{
m_installationPath = installationPath;
m_gamePath = gamePath;
m_searchPaths = additionalSearchPaths;
m_searchPaths.Add(Path.Combine(m_installationPath, "data"));
StreamReader reader = new StreamReader(modlistFile);
string line;
while ((line = reader.ReadLine()) != null)
{
// A mod name per line
// Handle only activated mods (ignore inactive and unmanaged)
if (line[0] == '+')
{
string modName = line.Substring(1);
string modPath = Path.Combine(modsPath, modName);
// Ignore mod when it is being reinstalled
// That folder has no relevant data files anyway
// This happens when an activated mod is being reinstalled
if (modPath.Equals(m_installationPath, StringComparison.InvariantCultureIgnoreCase))
{
Logger.Debug("Ignoring mod {0} that appears to be the one that is being installed", modName);
}
else
{
m_searchPaths.Add(modPath);
}
}
}
}
/// <summary>
/// Create a new instance DummyDataFileUtil that will use the dummy data folder created by this factory.
/// </summary>
/// <returns>New instance of DummyDataFileUtil</returns>
public DummyDataFileUtil CreateDummyDataFileUtil()
{
return new DummyDataFileUtil(m_installationPath, m_gamePath, m_searchPaths);
}
}
}
+134 -143
View File
@@ -1,143 +1,134 @@
/* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
using System;
using System.IO;
using Microsoft.Win32;
using Nexus.Client.Settings;
namespace Nexus.Client
{
/// <summary>
/// Provides information about the current programme environment.
/// </summary>
public class EnvironmentInfo : IEnvironmentInfo
{
private string m_strApplicationPersonalDataFolderPath = null;
private string m_strPersonalDataFolderPath = null;
#region Properties
/// <summary>
/// Gets the path to the user's personal data folder.
/// </summary>
/// <value>The path to the user's personal data folder.</value>
public string PersonalDataFolderPath
{
get
{
return m_strPersonalDataFolderPath;
}
}
/// <summary>
/// Gets the path to the mod manager's folder in the user's personal data folder.
/// </summary>
/// <value>The path to the mod manager's folder in the user's personal data folder.</value>
public string ApplicationPersonalDataFolderPath
{
get
{
return m_strApplicationPersonalDataFolderPath;
}
}
/// <summary>
/// Gets whether the programme is running under the Mono framework.
/// </summary>
/// <value>Whether the programme is running under the Mono framework.</value>
public bool IsMonoMode
{
get
{
return Type.GetType("Mono.Runtime") != null;
}
}
/// <summary>
/// Gets the temporary path used by the application.
/// </summary>
/// <value>The temporary path used by the application.</value>
public string TemporaryPath
{
get
{
string strPath = Path.Combine(Path.GetTempPath(),System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
if (!Directory.Exists(strPath))
Directory.CreateDirectory(strPath);
return strPath;
}
}
/// <summary>
/// Gets the path to the directory where programme data is stored.
/// </summary>
/// <value>The path to the directory where programme data is stored.</value>
public string ProgrammeInfoDirectory
{
get
{
return Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "data");
}
}
/// <summary>
/// Gets whether the current process is 64bit.
/// </summary>
/// <value>Whether the current process is 64bit.</value>
public bool Is64BitProcess
{
get
{
return (IntPtr.Size == 8);
}
}
/// <summary>
/// Gets the application and user settings.
/// </summary>
/// <value>The application and user settings.</value>
public ISettings Settings { get; private set; }
/// <summary>
/// Gets the version of the running application.
/// </summary>
/// <value>The version of the running application.</value>
public Version ApplicationVersion
{
get
{
return new Version(ProgrammeMetadata.VersionString);
}
}
#endregion
#region Constructors
/// <summary>
/// A simple constructor that initializes the object with the given dependencies.
/// </summary>
/// <param name="p_setSettings">The application and user settings.</param>
public EnvironmentInfo(ISettings p_setSettings)
{
Settings = p_setSettings;
m_strPersonalDataFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
if (String.IsNullOrEmpty(m_strPersonalDataFolderPath))
m_strPersonalDataFolderPath = Registry.GetValue(@"HKEY_CURRENT_USER\software\microsoft\windows\currentversion\explorer\user shell folders", "Personal", null).ToString();
m_strApplicationPersonalDataFolderPath = Path.Combine(m_strPersonalDataFolderPath, p_setSettings.ModManagerName);
}
#endregion
}
}
/* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;
using Nexus.Client.Settings;
using Nexus.Client.Util;
namespace Nexus.Client
{
/// <summary>
/// Provides information about the current programme environment.
/// </summary>
public class EnvironmentInfo : IEnvironmentInfo
{
private string m_strApplicationPersonalDataFolderPath = null;
private string m_strPersonalDataFolderPath = null;
private string m_strTempPath = null;
#region Properties
/// <summary>
/// Gets the path to the user's personal data folder.
/// </summary>
/// <value>The path to the user's personal data folder.</value>
public string PersonalDataFolderPath { get; } = null;
/// <summary>
/// Gets the path to the mod manager's folder in the user's personal data folder.
/// </summary>
/// <value>The path to the mod manager's folder in the user's personal data folder.</value>
public string ApplicationPersonalDataFolderPath { get; } = null;
/// <summary>
/// Gets whether the programme is running under the Mono framework.
/// </summary>
/// <value>Whether the programme is running under the Mono framework.</value>
public bool IsMonoMode
{
get
{
return Type.GetType("Mono.Runtime") != null;
}
}
/// <summary>
/// Gets the temporary path used by the application.
/// </summary>
/// <value>The temporary path used by the application.</value>
public string TemporaryPath { get; } = null;
/// <summary>
/// Gets the path to the directory where programme data is stored.
/// </summary>
/// <value>The path to the directory where programme data is stored.</value>
public string ProgrammeInfoDirectory
{
get
{
return Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "data");
}
}
/// <summary>
/// Gets whether the current process is 64bit.
/// </summary>
/// <value>Whether the current process is 64bit.</value>
public bool Is64BitProcess
{
get
{
return (IntPtr.Size == 8);
}
}
/// <summary>
/// Gets the application and user settings.
/// </summary>
/// <value>The application and user settings.</value>
public ISettings Settings { get; private set; }
/// <summary>
/// Gets the version of the running application.
/// </summary>
/// <value>The version of the running application.</value>
public Version ApplicationVersion
{
get
{
return new Version(CommonData.VersionString);
}
}
#endregion
#region Constructors
/// <summary>
/// A simple constructor that initializes the object with the given dependencies.
/// </summary>
/// <param name="p_setSettings">The application and user settings.</param>
public EnvironmentInfo(ISettings p_setSettings)
{
Settings = p_setSettings;
m_strPersonalDataFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
if (String.IsNullOrEmpty(m_strPersonalDataFolderPath))
m_strPersonalDataFolderPath = Registry.GetValue(@"HKEY_CURRENT_USER\software\microsoft\windows\currentversion\explorer\user shell folders", "Personal", null).ToString();
if (String.IsNullOrEmpty(Settings.TempPathFolder))
{
TemporaryPath = Path.Combine(Path.GetTempPath(), Application.ProductName);
if (!Directory.Exists(TemporaryPath))
Directory.CreateDirectory(TemporaryPath);
}
else
TemporaryPath = Settings.TempPathFolder;
ApplicationPersonalDataFolderPath = Path.Combine(PersonalDataFolderPath, p_setSettings.ModManagerName);
}
#endregion
}
}
File diff suppressed because it is too large Load Diff