mirror of
https://github.com/ModOrganizer2/modorganizer-NCC.git
synced 2026-07-27 14:00:52 -07:00
Compare commits
51
Commits
release_v1.0.10
...
2_3_0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
707527d264 | ||
|
|
1b96519fb2 | ||
|
|
d0a4194d55 | ||
|
|
e954eb9489 | ||
|
|
82ff6ae118 | ||
|
|
b7268d048f | ||
|
|
b8cc6b1070 | ||
|
|
ea91433896 | ||
|
|
ed497dd869 | ||
|
|
989af48f5c | ||
|
|
6e66c2c7e5 | ||
|
|
e6bc8867b2 | ||
|
|
3980559fe7 | ||
|
|
9ffc4d1089 | ||
|
|
5dc5c81e36 | ||
|
|
1616dd5f03 | ||
|
|
8b3b82bc6e | ||
|
|
b4fd1b6944 | ||
|
|
0d2af775fe | ||
|
|
e53cf69253 | ||
|
|
c85cfe9a8a | ||
|
|
107e7455bb | ||
|
|
906cf86a41 | ||
|
|
3700460597 | ||
|
|
88852c1440 | ||
|
|
807eb842dd | ||
|
|
3857e3b0f1 | ||
|
|
8b2837ecea | ||
|
|
abb1d33042 | ||
|
|
d5773c1850 | ||
|
|
5004b71e96 | ||
|
|
9ce6d1ab25 | ||
|
|
c8d6ad61a3 | ||
|
|
097cd233aa | ||
|
|
3f4717922e | ||
|
|
4557bc64c7 | ||
|
|
daf39f0347 | ||
|
|
2c2a77edf4 | ||
|
|
5fa02a3045 | ||
|
|
53a94be2fd | ||
|
|
e61f4aff90 | ||
|
|
7fbc9f0770 | ||
|
|
3ba23e0a80 | ||
|
|
66a91265c8 | ||
|
|
89500bc02e | ||
|
|
e58be3d748 | ||
|
|
8bf91045b5 | ||
|
|
f342dae9ba | ||
|
|
afeffdc1e9 | ||
|
|
65a14e2b78 | ||
|
|
96ac387aae |
@@ -0,0 +1,5 @@
|
||||
/nmm
|
||||
/NexusClientCLI/obj
|
||||
/.vs
|
||||
/.idea
|
||||
/*.log
|
||||
+845
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
||||
Copyright 2004-2014 Castle Project - http://www.castleproject.org/
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/* 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 Nexus.Client.ModManagement.Scripting;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Nexus.Client.CLI
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to some files in previously installed mods' installation path.
|
||||
/// </summary>
|
||||
class DummyDataFileUtil : IDataFileUtil
|
||||
{
|
||||
private string m_gamePath;
|
||||
private DataFileUtil m_dataFileUtil;
|
||||
|
||||
protected List<string> SearchPaths { get; set; }
|
||||
|
||||
// To be used internally by DummyDataFileUtilFactory
|
||||
// Use DummyDataFileUtilFactory.CreateDummyDataFileUtil() to instantiate
|
||||
internal DummyDataFileUtil(string installationPath, string gamePath, List<string> installationPaths)
|
||||
{
|
||||
m_gamePath = gamePath;
|
||||
m_dataFileUtil = new DataFileUtil(installationPath);
|
||||
SearchPaths = installationPaths;
|
||||
}
|
||||
|
||||
public void AssertFilePathIsSafe(string p_strPath)
|
||||
{
|
||||
m_dataFileUtil.AssertFilePathIsSafe(p_strPath);
|
||||
}
|
||||
|
||||
public bool DataFileExists(string p_strPath)
|
||||
{
|
||||
string unfixedPath = p_strPath;
|
||||
if (unfixedPath.StartsWith("data", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
unfixedPath = unfixedPath.Substring(5);
|
||||
}
|
||||
foreach (string path in SearchPaths) {
|
||||
if (File.Exists(Path.Combine(path, unfixedPath)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public string[] GetExistingDataFileList(string p_strPath, string p_strPattern, bool p_booAllFolders)
|
||||
{
|
||||
// Not implemented
|
||||
// Will implement if needed
|
||||
return new string[] {};
|
||||
}
|
||||
|
||||
public byte[] GetExistingDataFile(string p_strPath)
|
||||
{
|
||||
AssertFilePathIsSafe(p_strPath);
|
||||
if (p_strPath.StartsWith("data", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
foreach (string path in SearchPaths)
|
||||
{
|
||||
string dataPath = Path.Combine(path, p_strPath.Substring(5));
|
||||
Console.WriteLine("test: " + dataPath + " - " + File.Exists(dataPath));
|
||||
if (File.Exists(dataPath))
|
||||
{
|
||||
return File.ReadAllBytes(dataPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string dataPath = Path.Combine(m_gamePath, p_strPath);
|
||||
if (File.Exists(dataPath))
|
||||
{
|
||||
return File.ReadAllBytes(dataPath);
|
||||
}
|
||||
}
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,15 +21,15 @@ using Nexus.Client.ModManagement.InstallationLog;
|
||||
|
||||
namespace Nexus.Client.ModManagement.InstallationLog
|
||||
{
|
||||
class DummyInstallLog : IInstallLog
|
||||
{
|
||||
|
||||
private Dictionary<string, Pair<IMod, string> > m_InstalledFiles = null;
|
||||
public partial class DummyInstallLog : IInstallLog
|
||||
{
|
||||
|
||||
private Dictionary<string, Pair<IMod, string>> m_InstalledFiles = null;
|
||||
private Set<string> m_UsedKeys = null;
|
||||
|
||||
public DummyInstallLog()
|
||||
{
|
||||
|
||||
|
||||
m_InstalledFiles = new Dictionary<string, Pair<IMod, string>>();
|
||||
m_UsedKeys = new Set<string>();
|
||||
}
|
||||
@@ -100,44 +100,44 @@ namespace Nexus.Client.ModManagement.InstallationLog
|
||||
}
|
||||
|
||||
public void AddIniEdit(IMod p_modInstallingMod, string p_strSettingsFileName, string p_strSection, string p_strKey, string p_strValue)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
public void ReplaceIniEdit(IMod p_modInstallingMod, string p_strSettingsFileName, string p_strSection, string p_strKey, string p_strValue)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
public void ReplaceIniEdit(IMod p_modInstallingMod, string p_strSettingsFileName, string p_strSection, string p_strKey, string p_strValue)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
public void RemoveIniEdit(IMod p_modInstallingMod, string p_strSettingsFileName, string p_strSection, string p_strKey)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
public void RemoveIniEdit(IMod p_modInstallingMod, string p_strSettingsFileName, string p_strSection, string p_strKey)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
public IMod GetCurrentIniEditOwner(string p_strSettingsFileName, string p_strSection, string p_strKey)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public IMod GetCurrentIniEditOwner(string p_strSettingsFileName, string p_strSection, string p_strKey)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetCurrentIniEditOwnerKey(string p_strSettingsFileName, string p_strSection, string p_strKey)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public string GetCurrentIniEditOwnerKey(string p_strSettingsFileName, string p_strSection, string p_strKey)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetPreviousIniValue(string p_strSettingsFileName, string p_strSection, string p_strKey)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public string GetPreviousIniValue(string p_strSettingsFileName, string p_strSection, string p_strKey)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void LogOriginalIniValue(string p_strSettingsFileName, string p_strSection, string p_strKey, string p_strValue)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
public void LogOriginalIniValue(string p_strSettingsFileName, string p_strSection, string p_strKey, string p_strValue)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
public IList<IniEdit> GetInstalledIniEdits(IMod p_modInstaller)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public IList<IniEdit> GetInstalledIniEdits(IMod p_modInstaller)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public IList<IMod> GetIniEditInstallers(string p_strSettingsFileName, string p_strSection, string p_strKey)
|
||||
{
|
||||
@@ -156,18 +156,18 @@ namespace Nexus.Client.ModManagement.InstallationLog
|
||||
}
|
||||
|
||||
public void AddDataFile(IMod p_modInstallingMod, string p_strDataFilePath)
|
||||
{
|
||||
{
|
||||
string key = GenerateKey();
|
||||
m_InstalledFiles[p_strDataFilePath.ToLower()] = new Pair<IMod, string>(p_modInstallingMod, key);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveDataFile(IMod p_modInstallingMod, string p_strDataFilePath)
|
||||
{
|
||||
public void RemoveDataFile(IMod p_modInstallingMod, string p_strDataFilePath)
|
||||
{
|
||||
m_InstalledFiles.Remove(p_strDataFilePath.ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
public IMod GetCurrentFileOwner(string p_strPath)
|
||||
{
|
||||
public IMod GetCurrentFileOwner(string p_strPath)
|
||||
{
|
||||
string strPathLower = p_strPath.ToLower();
|
||||
if (m_InstalledFiles.ContainsKey(strPathLower))
|
||||
{
|
||||
@@ -177,15 +177,15 @@ namespace Nexus.Client.ModManagement.InstallationLog
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IMod GetPreviousFileOwner(string p_strPath)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public IMod GetPreviousFileOwner(string p_strPath)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetCurrentFileOwnerKey(string p_strPath)
|
||||
{
|
||||
public string GetCurrentFileOwnerKey(string p_strPath)
|
||||
{
|
||||
string strPathLower = p_strPath.ToLower();
|
||||
if (m_InstalledFiles.ContainsKey(strPathLower))
|
||||
{
|
||||
@@ -197,18 +197,18 @@ namespace Nexus.Client.ModManagement.InstallationLog
|
||||
}
|
||||
}
|
||||
|
||||
public string GetPreviousFileOwnerKey(string p_strPath)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public string GetPreviousFileOwnerKey(string p_strPath)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void LogOriginalDataFile(string p_strDataFilePath)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
public void LogOriginalDataFile(string p_strDataFilePath)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
public IList<string> GetInstalledModFiles(IMod p_modInstaller)
|
||||
{
|
||||
public IList<string> GetInstalledModFiles(IMod p_modInstaller)
|
||||
{
|
||||
Set<string> result = new Set<string>();
|
||||
foreach (KeyValuePair<string, Pair<IMod, string>> file in m_InstalledFiles)
|
||||
{
|
||||
@@ -217,8 +217,8 @@ namespace Nexus.Client.ModManagement.InstallationLog
|
||||
result.Add(file.Key);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public IList<IMod> GetFileInstallers(string p_strPath)
|
||||
{
|
||||
@@ -232,24 +232,26 @@ namespace Nexus.Client.ModManagement.InstallationLog
|
||||
}
|
||||
|
||||
public void AddActiveMod(IMod p_modMod)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
public void ReplaceActiveMod(IMod p_modOldMod, IMod p_modNewMod)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
public void ReplaceActiveMod(IMod p_modOldMod, IMod p_modNewMod)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
public string GetModKey(IMod p_modMod)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public string GetModKey(IMod p_modMod)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* protected IMod GetMod(string p_strKey)
|
||||
{
|
||||
return null;
|
||||
}*/
|
||||
/*
|
||||
protected IMod GetMod(string p_strKey)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
public IEnumerable<KeyValuePair<IMod, IMod>> GetMismatchedVersionMods()
|
||||
{
|
||||
@@ -265,5 +267,20 @@ namespace Nexus.Client.ModManagement.InstallationLog
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
public byte[] GetXmlModList()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] GetXmlIniList()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public IInstallLog ReInitialize(string p_strLogPath)
|
||||
{
|
||||
return this; // ???
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Nexus.Client.ModManagement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Nexus.Client.CLI
|
||||
{
|
||||
class DummyModLinkInstaller : IModLinkInstaller
|
||||
{
|
||||
public string AddFileLink(Mods.IMod p_modMod, string p_strBaseFilePath, string p_strSourceFile, bool p_booIsSwitching)
|
||||
{
|
||||
return AddFileLink(p_modMod, p_strBaseFilePath, p_strSourceFile, p_booIsSwitching, false);
|
||||
}
|
||||
|
||||
public string AddFileLink(Mods.IMod p_modMod, string p_strBaseFilePath, string p_strSourceFile, bool p_booIsSwitching, bool p_booHandlePlugin)
|
||||
{
|
||||
// nop, linking is done by MO
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ using Nexus.Client.Plugins;
|
||||
using Nexus.Client.Util.Collections;
|
||||
using Nexus.Client.Games;
|
||||
using Nexus.Client.Mods;
|
||||
using Nexus.Client.UI;
|
||||
using Nexus.Client.BackgroundTasks;
|
||||
|
||||
|
||||
namespace Nexus.Client.PluginManagement
|
||||
@@ -31,8 +33,8 @@ namespace Nexus.Client.PluginManagement
|
||||
public DummyPluginManager(string pluginsFile, IGameMode gameMode, IMod mod)
|
||||
{
|
||||
StreamReader reader = new StreamReader(pluginsFile);
|
||||
|
||||
string installationPath = gameMode.GetModFormatAdjustedPath(mod.Format, null);
|
||||
|
||||
string installationPath = Path.Combine(gameMode.GameModeEnvironmentInfo.InstallationPath, gameMode.GetModFormatAdjustedPath(mod.Format, null, false));
|
||||
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
@@ -57,12 +59,12 @@ namespace Nexus.Client.PluginManagement
|
||||
#region Properties
|
||||
|
||||
public ReadOnlyObservableList<Plugin> ManagedPlugins
|
||||
{
|
||||
get
|
||||
{
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ROOLPlugins;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlyObservableList<Plugin> ActivePlugins
|
||||
{
|
||||
@@ -90,6 +92,16 @@ namespace Nexus.Client.PluginManagement
|
||||
// nop
|
||||
}
|
||||
|
||||
public IBackgroundTask AutoPluginSorting(ConfirmActionMethod p_camConfirm)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public IBackgroundTask ManageMultiplePluginsTask(List<Plugin> p_lstPlugins, bool p_booEnable, ConfirmActionMethod p_camConfirm)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsPluginRegistered(string p_strPath)
|
||||
{
|
||||
return false;
|
||||
@@ -173,16 +185,33 @@ namespace Nexus.Client.PluginManagement
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public bool CanActivatePlugins()
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int MaxAllowedActivePluginsCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Plugin> GetOrphanedPlugins(string p_strMasterName)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetPluginDescription(string p_strPlugin)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public IBackgroundTask ApplyLoadOrder(Dictionary<Plugin, string> p_kvpRegisteredPlugins, bool p_booSortingOnly)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public int MaxAllowedActivePluginsCount {
|
||||
get {
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
using Nexus.Client.ModManagement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Nexus.Client.BackgroundTasks;
|
||||
using Nexus.Client.UI;
|
||||
|
||||
namespace Nexus.Client.CLI
|
||||
{
|
||||
class DummyVirtualModActivator : IVirtualModActivator
|
||||
{
|
||||
public event EventHandler ModActivationChanged;
|
||||
|
||||
protected IEnvironmentInfo EnvironmentInfo { get; private set; }
|
||||
|
||||
public bool MultiHDMode
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool Initialized
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public bool DisableLinkCreation
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool DisableIniLogging
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public string VirtualPath
|
||||
{
|
||||
get
|
||||
{
|
||||
//string[] components = EnvironmentInfo.Settings.InstallationPaths[GameMode.ModeId].Split(Path.DirectorySeparatorChar);
|
||||
//return components[components.Length - 1];
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public string HDLinkFolder
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public Util.Collections.ThreadSafeObservableList<IVirtualModLink> VirtualLinks
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public Util.Collections.ThreadSafeObservableList<IVirtualModInfo> VirtualMods
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public IEnumerable<string> ActiveModList
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public int ModCount
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public Games.IGameMode GameMode { get; private set; }
|
||||
|
||||
public DummyVirtualModActivator(Games.IGameMode gameMode, IEnvironmentInfo environment)
|
||||
{
|
||||
GameMode = gameMode;
|
||||
EnvironmentInfo = environment;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveList()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetCurrentList(IList<IVirtualModLink> p_ilvVirtualLinks)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<IVirtualModLink> LoadList(string p_strXMLFilePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<IVirtualModLink> LoadImportedList(string p_strXML)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool LoadListOnDemand(string p_strProfilePath, out List<IVirtualModLink> p_lstVirtualLinks, out List<IVirtualModInfo> p_lstVirtualMods)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveModList(string p_strPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string CheckVirtualLink(string p_strFilePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int CheckFileLink(string p_strFilePath, out Mods.IMod p_modMod, out List<IVirtualModLink> lstFileLinks)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool PurgeLinks()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void AddInactiveLink(Mods.IMod p_modMod, string p_strBaseFilePath, int p_intPriority)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string AddFileLink(Mods.IMod p_modMod, string p_strBaseFilePath, bool p_booIsSwitching, bool p_booIsRestoring, int p_intPriority)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string AddFileLink(Mods.IMod p_modMod, string p_strBaseFilePath, string p_strSourceFile, bool p_booIsSwitching, bool p_booIsRestoring, bool p_booHandlePlugin, int p_intPriority)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void RemoveFileLink(string p_strFilePath, Mods.IMod p_modMod)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void RemoveFileLink(IVirtualModLink p_ivlVirtualLink, Mods.IMod p_modMod)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateLinkPriority(IVirtualModLink p_ivlFileLink)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateLinkListPriority(List<IVirtualModLink> lstFileLinks)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DisableMod(Mods.IMod p_modMod)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DisableModFiles(Mods.IMod p_modMod)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void FinalizeModDeactivation(Mods.IMod p_modMod)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void EnableMod(Mods.IMod p_modMod)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void FinalizeModActivation(Mods.IMod p_modMod)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void LogIniEdits(Mods.IMod p_modMod, string p_strSettingsFileName, string p_strSection, string p_strKey, string p_strValue)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void RestoreIniEdits()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void PurgeIniEdits()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ImportIniEdits(string p_strIniXML)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetNewFolders(string p_strVirtual, string p_strLink, bool? p_booMultiHD)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CheckLinkListIntegrity(IList<IVirtualModLink> p_ivlVirtualLinks, out Dictionary<string, string> p_dicUninstalled, out Dictionary<string, string> p_dicMissing, IList<string> p_lstForced)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IModLinkInstaller GetModLinkInstaller()
|
||||
{
|
||||
return new DummyModLinkInstaller();
|
||||
}
|
||||
|
||||
public void PurgeMods(List<Mods.IMod> p_lstMods, string p_strPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool CheckHasActiveLinks(Mods.IMod p_modMod)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetCurrentFileOwner(string p_strPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public BackgroundTasks.IBackgroundTask ActivatingMod(Mods.IMod p_modMod, bool p_booDisabling, UI.ConfirmActionMethod p_camConfirm)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveModList(string p_strPath, List<IVirtualModInfo> p_lstVirtualModInfo, List<IVirtualModLink> p_lstVirtualModList)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string RequiresFixing()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string RequiresFixing(string p_strFilePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
bool IVirtualModActivator.SaveList()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool SaveList(bool p_booModActivationChange)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<IVirtualModLink> LoadImportedList(string p_strXML, string p_strSavePath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateDownloadId(string p_strCurrentProfilePath, Dictionary<string, string> p_dctNewDownloadID)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CheckLinkListIntegrity(IList<IVirtualModLink> p_ivlVirtualLinks, out List<IVirtualModInfo> p_lstMissingModInfo, IList<string> p_lstForced)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IBackgroundTask FixConfigFiles(List<string> p_lstFiles, IModProfile p_mprProfile, ConfirmActionMethod p_camConfirm)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/* 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/>. */
|
||||
|
||||
namespace Nexus.Client
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
using Nexus.Client.Settings;
|
||||
using Nexus.Client.Util;
|
||||
|
||||
/// <summary>
|
||||
/// Provides information about the current programme environment.
|
||||
/// </summary>
|
||||
public class EnvironmentInfo : IEnvironmentInfo
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private string m_strApplicationPersonalDataFolderPath = null;
|
||||
private string m_strPersonalDataFolderPath = null;
|
||||
private string m_strTempPath = null;
|
||||
|
||||
/// <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;
|
||||
PersonalDataFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||
if (String.IsNullOrEmpty(PersonalDataFolderPath))
|
||||
PersonalDataFolderPath = 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, CommonData.ModManagerName);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using Castle.DynamicProxy;
|
||||
using Nexus.Client.Games;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace Nexus.Client.CLI
|
||||
{
|
||||
public class GameModeInterceptorSelector : IInterceptorSelector
|
||||
{
|
||||
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
|
||||
{
|
||||
if (IsGetter(method))
|
||||
{
|
||||
return interceptors;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsGetter(MethodInfo method)
|
||||
{
|
||||
return method.IsSpecialName && method.Name.StartsWith("get_", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private bool IsSetter(MethodInfo method)
|
||||
{
|
||||
return method.IsSpecialName && method.Name.StartsWith("set_", StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
class GameModeInterceptor : IInterceptor
|
||||
{
|
||||
private List<string> m_AdditionalWritablePaths;
|
||||
private Version m_ExtenderVersion;
|
||||
|
||||
public GameModeInterceptor(List<string> additionalWritablePaths, Version extenderVersion)
|
||||
{
|
||||
m_AdditionalWritablePaths = additionalWritablePaths;
|
||||
m_ExtenderVersion = extenderVersion;
|
||||
}
|
||||
|
||||
public void Intercept(IInvocation invocation)
|
||||
{
|
||||
invocation.Proceed();
|
||||
|
||||
if (invocation.Method.Name == "get_WritablePaths")
|
||||
{
|
||||
IEnumerable<string> temp = (IEnumerable<string>)invocation.ReturnValue;
|
||||
invocation.ReturnValue = temp.Concat(m_AdditionalWritablePaths);
|
||||
}
|
||||
else if (invocation.Method.Name == "get_ScriptExtenderVersion")
|
||||
{
|
||||
if (invocation.ReturnValue == null)
|
||||
invocation.ReturnValue = m_ExtenderVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/* 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.Reflection;
|
||||
|
||||
namespace Nexus.Client.CLI
|
||||
{
|
||||
class Logger
|
||||
{
|
||||
public enum Level
|
||||
{
|
||||
None = 0,
|
||||
Error = 1,
|
||||
Warning = 2,
|
||||
Info = 3,
|
||||
Debug = 4,
|
||||
Fine = 5,
|
||||
// Place finer levels here if needed
|
||||
All = 9
|
||||
}
|
||||
|
||||
|
||||
private const string s_logfileName = "NexusClientCLI.log";
|
||||
private static string s_logfilePath = null;
|
||||
private static Level s_maxVerbosity = Level.None;
|
||||
|
||||
public static void SetVerbosity(Level verbostity)
|
||||
{
|
||||
s_maxVerbosity = verbostity;
|
||||
}
|
||||
|
||||
public static void SetLogDestination(string path)
|
||||
{
|
||||
s_logfilePath = Path.Combine(path, s_logfileName);
|
||||
}
|
||||
|
||||
public static void Error(String msg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Error))
|
||||
WriteMessage(Level.Error, msg);
|
||||
}
|
||||
|
||||
public static void Error(String fmt, Object arg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Error))
|
||||
WriteMessage(Level.Error, String.Format(fmt, arg));
|
||||
}
|
||||
|
||||
public static void Warning(String msg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Warning))
|
||||
WriteMessage(Level.Warning, msg);
|
||||
}
|
||||
|
||||
public static void Warning(String fmt, Object arg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Warning))
|
||||
WriteMessage(Level.Warning, String.Format(fmt, arg));
|
||||
}
|
||||
|
||||
public static void Info(String msg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Info))
|
||||
WriteMessage(Level.Info, msg);
|
||||
}
|
||||
|
||||
public static void Info(String fmt, Object arg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Info))
|
||||
WriteMessage(Level.Info, String.Format(fmt, arg));
|
||||
}
|
||||
|
||||
public static void Debug(String msg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Debug))
|
||||
WriteMessage(Level.Debug, msg);
|
||||
}
|
||||
|
||||
public static void Debug(String fmt, Object arg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Debug))
|
||||
WriteMessage(Level.Debug, String.Format(fmt, arg));
|
||||
}
|
||||
|
||||
public static void Fine(String msg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Fine))
|
||||
WriteMessage(Level.Fine, msg);
|
||||
}
|
||||
|
||||
public static void Fine(String fmt, Object arg)
|
||||
{
|
||||
if (IsLevelLoggable(Level.Fine))
|
||||
WriteMessage(Level.Fine, String.Format(fmt, arg));
|
||||
}
|
||||
|
||||
public static bool IsLevelLoggable(Level level)
|
||||
{
|
||||
return level <= s_maxVerbosity;
|
||||
}
|
||||
|
||||
private static void WriteMessage(Level level, string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
string output = string.Format("[{0}] {1}{2}", level, msg, Environment.NewLine);
|
||||
if (s_logfilePath != null) {
|
||||
File.AppendAllText(s_logfilePath, output);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(output);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore exception
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*using Nexus.Client.Mods;
|
||||
//using Nexus.Client.Mods.Formats.FOMod;
|
||||
//using Nexus.Client.Mods.Formats.OMod;
|
||||
using Nexus.Client.Util;
|
||||
using SevenZip;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Extensions
|
||||
{
|
||||
public static class Extension
|
||||
{
|
||||
public static T GetPrivateField<T>(this object obj, string name)
|
||||
{
|
||||
BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
Type type = obj.GetType();
|
||||
FieldInfo field = type.GetField(name, flags);
|
||||
return (T)field.GetValue(obj);
|
||||
}
|
||||
|
||||
|
||||
public static T GetPrivateProperty<T>(this object obj, string name)
|
||||
{
|
||||
BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
Type type = obj.GetType();
|
||||
PropertyInfo field = type.GetProperty(name, flags);
|
||||
return (T)field.GetValue(obj, null);
|
||||
}
|
||||
|
||||
public static T CallPrivateMethod<T>(this object obj, string name, params object[] param)
|
||||
{
|
||||
BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
Type type = obj.GetType();
|
||||
MethodInfo method = type.GetMethod(name, flags);
|
||||
return (T)method.Invoke(obj, param);
|
||||
}
|
||||
|
||||
|
||||
public static void ExtractFileContents(this Archive archive, string p_strPath, Stream p_outStream)
|
||||
{
|
||||
string strPath = p_strPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||
var fileInfo = archive.GetPrivateField<Dictionary<string, ArchiveFileInfo>>("m_dicFileInfo");
|
||||
if (!fileInfo.ContainsKey(strPath))
|
||||
throw new FileNotFoundException("The requested file does not exist in the archive.", p_strPath);
|
||||
|
||||
ArchiveFileInfo afiFile = fileInfo[strPath];
|
||||
|
||||
//check to see if we are on the same thread as the extractor
|
||||
// if not, then marshall the call to the extractor's thread.
|
||||
// this needs to be done as the 7zip dll cannot handle calls from other
|
||||
// threads.
|
||||
if (archive.GetPrivateProperty<bool>("IsReadonly"))
|
||||
{
|
||||
var roExtractor = archive.GetPrivateField<ThreadSafeSevenZipExtractor>("m_szeReadOnlyExtractor");
|
||||
if (roExtractor == null) {
|
||||
string tempDir = archive.GetPrivateField<string>("m_strReadOnlyTempDirectory");
|
||||
using (FileStream inStream = new FileStream(Path.Combine(tempDir, strPath), FileMode.Open, FileAccess.Read)) {
|
||||
int size = 1024 * 1024;
|
||||
byte[] buffer = new byte[size];
|
||||
int read = 0;
|
||||
while ((read = inStream.Read(buffer, 0, size)) > 0) {
|
||||
p_outStream.Write(buffer, 0, read);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
roExtractor.ExtractFile(afiFile.Index, p_outStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (SevenZipExtractor szeExtractor = archive.CallPrivateMethod<SevenZipExtractor>("GetExtractor", archive.GetPrivateField<string>("m_strPath")))
|
||||
szeExtractor.ExtractFile(afiFile.Index, p_outStream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// write the specified file to a stream
|
||||
/// </summary>
|
||||
/// <param name="p_strFile">The file to retrieve.</param>
|
||||
/// <param name="p_outStream">The stream to write to.</param>
|
||||
/// <exception cref="System.IO.FileNotFoundException">Thrown if the specified file
|
||||
/// is not in the mod.</exception>
|
||||
public static void ExtractFileTo<T>(this T mod, string p_strFile, Stream p_outStream)
|
||||
{
|
||||
string realPath = (string) mod.CallPrivateMethod<string>("GetRealPath", new object[] { p_strFile });
|
||||
if (!(bool) mod.GetType().GetMethod("ContainsFile").Invoke(mod, new object[] { realPath }))
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(p_strFile).ToLower() == "screenshot")
|
||||
{
|
||||
byte[] data = (byte[])(new ImageConverter().ConvertTo(new Bitmap(1, 1), typeof(byte[])));
|
||||
p_outStream.Write(data, 0, data.Length);
|
||||
return;
|
||||
}
|
||||
else
|
||||
throw new FileNotFoundException("File doesn't exist in FOMod", p_strFile);
|
||||
}
|
||||
|
||||
mod.GetPrivateField<Archive>("m_arcFile").ExtractFileContents(realPath, p_outStream);
|
||||
}
|
||||
}
|
||||
class ModExtension
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,241 @@
|
||||
using Nexus.Client.Util;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using SevenZip;
|
||||
|
||||
namespace Nexus.Client.Mods
|
||||
{
|
||||
/// <summary>
|
||||
/// The mod cache manager.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A mod cache manager provides information od methods to use the mod cache.
|
||||
/// </remarks>
|
||||
public class NexusModCacheManager : IModCacheManager
|
||||
{
|
||||
#region IModCacheManager Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path of the directory where the current Game Mode's mods' cache files are stored.
|
||||
/// </summary>
|
||||
/// <value>The path of the directory where the current Game Mode's mods' cache files are stored.</value>
|
||||
public string ModCacheDirectory { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path of the directory where the current Game Mode's mod files are stored.
|
||||
/// </summary>
|
||||
/// <value>The path of the directory where the current Game Mode's mod files are stored.</value>
|
||||
protected string ModDirectory { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the file utility class.
|
||||
/// </summary>
|
||||
/// <value>The file utility class.</value>
|
||||
public FileUtil FileUtility { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application's envrionment info.
|
||||
/// </summary>
|
||||
/// <value>The application's envrionment info.</value>
|
||||
public IEnvironmentInfo EnvironmentInfo { get; private set; }
|
||||
|
||||
protected bool m_booCacheOverhaulSetup = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// A simple constructor that initializes the object with the given dependencies.
|
||||
/// </summary>
|
||||
/// <param name="p_strModCacheDirectory">The path of the directory where the current Game Mode's mods' cache files are stored.</param>
|
||||
/// <param name="p_strModDirectory">The path of the directory where the current Game Mode's mod files are stored.</param>
|
||||
/// <param name="p_futFileUtility">The file utility class.</param>
|
||||
public NexusModCacheManager(string p_strModCacheDirectory, string p_strModDirectory, FileUtil p_futFileUtility, IEnvironmentInfo p_eifEnvironmentInfo)
|
||||
{
|
||||
ModCacheDirectory = p_strModCacheDirectory;
|
||||
ModDirectory = p_strModDirectory;
|
||||
FileUtility = p_futFileUtility;
|
||||
EnvironmentInfo = p_eifEnvironmentInfo;
|
||||
CheckModCache();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// This removes any old cache files.
|
||||
/// </summary>
|
||||
private void CheckModCache()
|
||||
{
|
||||
string[] strCaches = Directory.GetFiles(ModCacheDirectory);
|
||||
foreach (string strCache in strCaches)
|
||||
{
|
||||
string strModPath = Path.Combine(ModDirectory, Path.GetFileNameWithoutExtension(strCache));
|
||||
if (!File.Exists(strModPath) || (File.GetLastWriteTimeUtc(strCache) < File.GetLastWriteTimeUtc(strModPath)))
|
||||
FileUtil.ForceDelete(strCache);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the specified mod's cache file.
|
||||
/// </summary>
|
||||
/// <param name="p_modMod">The mod for which to get the cache filename.</param>
|
||||
/// <returns>The path to the specified mod's cache file.</returns>
|
||||
private string GetCacheFilePath(IMod p_modMod)
|
||||
{
|
||||
return Path.Combine(ModCacheDirectory, Path.GetFileName(p_modMod.ModArchivePath) + ".zip");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the specified mod's cache file.
|
||||
/// </summary>
|
||||
/// <param name="p_strPath">The path for which to get the cache file.</param>
|
||||
/// <returns>The path to the specified mod's cache file.</returns>
|
||||
public string GetCacheFilePath(string p_strPath)
|
||||
{
|
||||
return Path.Combine(ModCacheDirectory, Path.GetFileNameWithoutExtension(p_strPath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cache file for the specified path.
|
||||
/// </summary>
|
||||
/// <param name="p_strPath">The path for which to get the cache file.</param>
|
||||
/// <returns>The cache file for the specified path, or <c>null</c>
|
||||
/// if there is no cache file.</returns>
|
||||
public Archive GetCacheFile(string p_strPath)
|
||||
{
|
||||
string strCachePath = Path.Combine(ModCacheDirectory, Path.GetFileName(p_strPath) + ".zip");
|
||||
if (File.Exists(strCachePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Archive(strCachePath);
|
||||
}
|
||||
catch (SevenZipArchiveException)
|
||||
{
|
||||
//the cachef ile is corrupt - so delete it
|
||||
FileUtil.ForceDelete(strCachePath);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
//we can't access the file - who know why
|
||||
//destroy it so we can try again
|
||||
FileUtil.ForceDelete(strCachePath);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cache file for the specified mod.
|
||||
/// </summary>
|
||||
/// <param name="p_modMod">The mod for which to get the cache file.</param>
|
||||
/// <returns>The cache file for the specified mod, or <c>null</c>
|
||||
/// if there is no cache file.</returns>
|
||||
public Archive GetCacheFile(IMod p_modMod)
|
||||
{
|
||||
|
||||
string strCachePath = GetCacheFilePath(p_modMod);
|
||||
if (File.Exists(strCachePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Archive(strCachePath);
|
||||
}
|
||||
catch (SevenZipArchiveException)
|
||||
{
|
||||
//the cachef ile is corrupt - so delete it
|
||||
FileUtil.ForceDelete(strCachePath);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
//we can't access the file - who know why
|
||||
//destroy it so we can try again
|
||||
FileUtil.ForceDelete(strCachePath);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a cache file for the given mod, containing the specified files.
|
||||
/// </summary>
|
||||
/// <param name="p_modMod">The mod for which to create the cache file.</param>
|
||||
/// <param name="p_strFilesToCacheFolder">The folder containing the files to put into the cache.</param>
|
||||
/// <returns>The cache file for the specified mod, or <c>null</c>
|
||||
/// if there were no files to cache.</returns>
|
||||
public void CreateCacheFile(IMod p_modMod, string p_strFilesToCacheFolder)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(p_strFilesToCacheFolder))
|
||||
{
|
||||
var strFilesToCompress = Directory.EnumerateFiles(p_strFilesToCacheFolder, "*.*", SearchOption.AllDirectories);
|
||||
if (strFilesToCompress.Count() > 0)
|
||||
{
|
||||
string strCachePath = Path.Combine(ModCacheDirectory, Path.GetFileNameWithoutExtension(p_modMod.Filename));
|
||||
string strArcCacheFile = Path.Combine(ModCacheDirectory, Path.GetFileName(p_modMod.Filename) + ".zip");
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(strCachePath))
|
||||
{
|
||||
if (File.Exists(strArcCacheFile))
|
||||
{
|
||||
ExportCacheArchive(strArcCacheFile, strCachePath, EnvironmentInfo.Settings.CacheOverhaulSetup);
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.CreateDirectory(strCachePath);
|
||||
copyDirectory(p_strFilesToCacheFolder, strCachePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Migrates the cache zip file for the given mod to the cache folder.
|
||||
/// </summary>
|
||||
/// <param name="p_modMod">The mod for which to create the cache file.</param>
|
||||
public void MigrateCacheFile(IMod p_modMod)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
private void ExportCacheArchive(string p_strCacheSource, string p_strDestinationFolder, bool p_booCacheOverhaulSetup)
|
||||
{
|
||||
try
|
||||
{
|
||||
ZipFile.ExtractToDirectory(p_strCacheSource, p_strDestinationFolder);
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (p_booCacheOverhaulSetup)
|
||||
FileUtil.ForceDelete(p_strCacheSource);
|
||||
}
|
||||
|
||||
public static void copyDirectory(string strSource, string strDestination)
|
||||
{
|
||||
String[] Files;
|
||||
|
||||
if (strDestination[strDestination.Length - 1] != Path.DirectorySeparatorChar)
|
||||
strDestination += Path.DirectorySeparatorChar;
|
||||
if (!Directory.Exists(strDestination)) Directory.CreateDirectory(strDestination);
|
||||
Files = Directory.GetFileSystemEntries(strSource);
|
||||
foreach (string Element in Files)
|
||||
{
|
||||
// Sub directories
|
||||
if (Directory.Exists(Element))
|
||||
copyDirectory(Element, strDestination + Path.GetFileName(Element));
|
||||
// Files in directory
|
||||
else
|
||||
File.Copy(Element, strDestination + Path.GetFileName(Element), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user