本文整理汇总了C#中IMod类的典型用法代码示例。如果您正苦于以下问题:C# IMod类的具体用法?C# IMod怎么用?C# IMod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMod类属于命名空间,在下文中一共展示了IMod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareMod
/// <summary>
/// Prepares the given mod for installation.
/// </summary>
/// <remarks>
/// This task puts the mod into read-only mode.
/// </remarks>
/// <returns><c>true</c> if the mod was successfully prepared;
/// <c>false</c> otherwise.</returns>
/// <param name="p_modMod">The mod to prepare.</param>
public bool PrepareMod(IMod p_modMod)
{
OverallMessage = "Preparing Mod...";
ShowItemProgress = false;
OverallProgressMaximum = 100;
OverallProgressStepSize = 1;
try
{
p_modMod.ReadOnlyInitProgressUpdated += new CancelProgressEventHandler(Mod_ReadOnlyInitProgressUpdated);
p_modMod.BeginReadOnlyTransaction(FileUtility);
}
catch (Exception)
{
Status = TaskStatus.Error;
OnTaskEnded(false);
throw;
}
finally
{
p_modMod.ReadOnlyInitProgressUpdated -= Mod_ReadOnlyInitProgressUpdated;
}
bool booSuccess = Status != TaskStatus.Cancelling;
Status = Status == TaskStatus.Cancelling ? TaskStatus.Cancelled : TaskStatus.Complete;
OnTaskEnded(booSuccess);
return booSuccess;
}
示例2: ModFileUpgradeInstaller
/// <summary>
/// A simple constructor that initializes the object with its dependencies.
/// </summary>
/// <param name="p_gmiGameModeInfo">The environment info of the current game mode.</param>
/// <param name="p_modMod">The mod being installed.</param>
/// <param name="p_ilgInstallLog">The install log to use to log file installations.</param>
/// <param name="p_pmgPluginManager">The plugin manager.</param>
/// <param name="p_dfuDataFileUtility">The utility class to use to work with data files.</param>
/// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
/// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
/// <param name="p_UsesPlugins">Game using plugin or mods (True for plugins).</param>
public ModFileUpgradeInstaller(IGameModeEnvironmentInfo p_gmiGameModeInfo, IMod p_modMod, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager, IDataFileUtil p_dfuDataFileUtility, TxFileManager p_tfmFileManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, bool p_UsesPlugins)
: base(p_gmiGameModeInfo, p_modMod, p_ilgInstallLog, p_pmgPluginManager, p_dfuDataFileUtility, p_tfmFileManager, p_dlgOverwriteConfirmationDelegate, p_UsesPlugins, null)
{
OriginallyInstalledFiles = new Set<string>(StringComparer.OrdinalIgnoreCase);
foreach (string strFile in InstallLog.GetInstalledModFiles(Mod))
OriginallyInstalledFiles.Add(strFile.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar));
}
示例3: GetTagInfoCandidates
/// <summary>
/// Gets a list of possible mod info tags which match the given mod.
/// </summary>
/// <param name="p_modMod">The mod for which to retrieve a list of possible tags.</param>
/// <returns>A list of possible mod info tags which match the given mod.</returns>
public IEnumerable<IModInfo> GetTagInfoCandidates(IMod p_modMod)
{
//get mod info
List<IModInfo> lstMods = new List<IModInfo>();
IModInfo mifInfo = null;
try
{
if (!String.IsNullOrEmpty(p_modMod.Id))
mifInfo = ModRepository.GetModInfo(p_modMod.Id);
if (mifInfo == null)
mifInfo = ModRepository.GetModInfoForFile(p_modMod.Filename);
if (mifInfo == null)
{
//use heuristics to find info
lstMods.AddRange(ModRepository.FindMods(p_modMod.ModName, true));
if (lstMods.Count == 0)
lstMods.AddRange(ModRepository.FindMods(Regex.Replace(p_modMod.ModName, "[^a-zA-Z0-9_. ]+", "", RegexOptions.Compiled), true));
if ((lstMods.Count == 0) && (!String.IsNullOrEmpty(p_modMod.Author)))
lstMods.AddRange(ModRepository.FindMods(p_modMod.ModName, p_modMod.Author));
if (lstMods.Count == 0)
lstMods.AddRange(ModRepository.FindMods(p_modMod.ModName, false));
}
else
lstMods.Add(mifInfo);
//if we don't know the mod Id, then we have no way of getting
// the file-specific info, so only look if we have one mod info
// candidate.
if (lstMods.Count == 1)
{
mifInfo = lstMods[0];
lstMods.Clear();
//get file specific info
IModFileInfo mfiFileInfo = ModRepository.GetFileInfoForFile(p_modMod.Filename);
if (mfiFileInfo == null)
{
foreach (IModFileInfo mfiModFileInfo in ModRepository.GetModFileInfo(mifInfo.Id))
lstMods.Add(CombineInfo(mifInfo, mfiModFileInfo));
}
else
lstMods.Add(CombineInfo(mifInfo, mfiFileInfo));
if (lstMods.Count == 0)
lstMods.Add(mifInfo);
}
}
catch (RepositoryUnavailableException e)
{
TraceUtil.TraceException(e);
//the repository is not available, so add a dummy value indicating such
lstMods.Add(new ModInfo(null, String.Format("{0} is unavailable", ModRepository.Name), null, null, false, null, null, 0, -1, null, null, null, null));
}
catch (NullReferenceException e)
{
TraceUtil.TraceException(e);
//couldn't find any match, so add a dummy value indicating such
lstMods.Add(new ModInfo(null, String.Format("{0}", e.Message), null, null, false, null, null, 0, -1, null, null, null, null));
}
return lstMods;
}
示例4: Compare
/// <summary>
/// Compares the given <see cref="IMod"/>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(IMod x, IMod y)
{
if (x == null)
return (y == null) ? 0 : -1;
if (y == null)
return 1;
return StringComparer.OrdinalIgnoreCase.Compare(x.Filename, y.Filename);
}
示例5: IniInstaller
/// <summary>
/// A simple constructor that initializes the object with its dependencies.
/// </summary>
/// <param name="p_modMod">The mod being installed.</param>
/// <param name="p_ilgInstallLog">The install log to use to log file installations.</param>
/// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
/// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
public IniInstaller(IMod p_modMod, IInstallLog p_ilgInstallLog, TxFileManager p_tfmFileManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate)
{
TouchedFiles = new Set<string>(StringComparer.OrdinalIgnoreCase);
Mod = p_modMod;
InstallLog = p_ilgInstallLog;
TransactionalFileManager = p_tfmFileManager;
m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate ?? ((s, b, m) => OverwriteResult.No);
}
示例6: BasicUninstallTask
/// <summary>
/// A simple constructor that initializes the object with the given values.
/// </summary>
/// <param name="p_modMod">The mod being installed.</param>
/// <param name="p_igpInstallers">The utility class to use to install the mod items.</param>
/// <param name="p_ilgModInstallLog">The install log that tracks mod install info
/// for the current game mode</param>
/// <param name="p_gmdGameMode">The the current game mode.</param>
/// <param name="p_rolActiveMods">The list of active mods.</param>
public BasicUninstallTask(IMod p_modMod, InstallerGroup p_igpInstallers, IInstallLog p_ilgModInstallLog, IGameMode p_gmdGameMode, ReadOnlyObservableList<IMod> p_rolActiveMods)
{
Mod = p_modMod;
Installers = p_igpInstallers;
ModInstallLog = p_ilgModInstallLog;
GameMode = p_gmdGameMode;
ActiveMods = p_rolActiveMods;
}
示例7: XmlScriptExecutor
/// <summary>
/// A simple constructor that initializes the object with the required dependencies.
/// </summary>
/// <param name="p_modMod">The mod for which the script is running.</param>
/// <param name="p_gmdGameMode">The game mode currently being managed.</param>
/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
/// <param name="p_igpInstallers">The utility class to use to install the mod items.</param>
/// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
public XmlScriptExecutor(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, InstallerGroup p_igpInstallers, SynchronizationContext p_scxUIContext)
{
m_scxSyncContext = p_scxUIContext;
Mod = p_modMod;
GameMode = p_gmdGameMode;
EnvironmentInfo = p_eifEnvironmentInfo;
Installers = p_igpInstallers;
}
示例8: BasicInstallTask
/// <summary>
/// A simple constructor that initializes the object with the given values.
/// </summary>
/// <param name="p_modMod">The mod being installed.</param>
/// <param name="p_gmdGameMode">The the current game mode.</param>
/// <param name="p_mfiFileInstaller">The file installer to use.</param>
/// <param name="p_pmgPluginManager">The plugin manager.</param>
/// <param name="p_booSkipReadme">Whether to skip the installation of readme files.</param>
/// <param name="p_rolActiveMods">The list of active mods.</param>
public BasicInstallTask(IMod p_modMod, IGameMode p_gmdGameMode, IModFileInstaller p_mfiFileInstaller, IPluginManager p_pmgPluginManager, bool p_booSkipReadme, ReadOnlyObservableList<IMod> p_rolActiveMods)
{
Mod = p_modMod;
GameMode = p_gmdGameMode;
FileInstaller = p_mfiFileInstaller;
PluginManager = p_pmgPluginManager;
SkipReadme = p_booSkipReadme;
ActiveMods = p_rolActiveMods;
}
示例9: ModTaggerVM
/// <summary>
/// A simple constructor that initializes the object with the given values.
/// </summary>
/// <param name="p_atgTagger">The tagger to use to tag mods with metadata.</param>
/// <param name="p_modMod">The mod to be tagged.</param>
/// <param name="p_setSettings">The application and user settings.</param>
/// <param name="p_thmTheme">The current theme to use for the views.</param>
public ModTaggerVM(AutoTagger p_atgTagger, IMod p_modMod, ISettings p_setSettings, Theme p_thmTheme)
{
ModTagger = p_atgTagger;
Mod = p_modMod;
Settings = p_setSettings;
CurrentTheme = p_thmTheme;
m_mifCurrentTagOption = new ModInfo(Mod);
ModInfoEditorVM = new ModInfoEditorVM(m_mifCurrentTagOption, p_setSettings);
ModInfoEditorVM.EditedModInfoVM.LoadInfoValues(p_modMod);
}
示例10: ModController
public ModController(IMod mod)
: base(mod) {
Contract.Requires<ArgumentNullException>(mod != null);
_contentEngine = CalculatedGameSettings.ContentManager.ContentEngine;
Mod = mod;
_modState = new ModState(mod);
_sixSyncModInstaller = new SixSyncModInstaller(mod, _modState);
Model.State = _modState.State;
}
示例11: ModdingEnvironmentWriter
internal ModdingEnvironmentWriter(IMod[] mods_to_use, IMod[] dependencies_to_use, bool useHiDefProfile)
{
config = ModdingEnvironmentConfiguration.Create();
ModEnvironment.RequestSetupDataReset();
all_mods_to_process = mods_to_use;
all_possible_dependencies = dependencies_to_use;
var source_exe = ModManager.GameDirectory.ContainingFile(ModManager.OriginalExecutable);
//new System.IO.FileInfo(System.IO.Path.Combine(base_directoy.FullName, source_exe_name));
var modded_exe = ModManager.GameDirectory.ContainingFile(ModManager.ModdedExecutable);
//new System.IO.FileInfo(System.IO.Path.Combine(base_directoy.FullName, modded_exe_name));
var source_lib = ModManager.GameDirectory.ContainingFile(ModManager.OriginalLibrary);
var modded_lib = ModManager.GameDirectory.ContainingFile(ModManager.ModdedLibrary);
game_injector = new GnomoriaExeInjector(source_exe);
lib_injector = new Injector(source_lib);
config.Hashes.SourceExecutable = source_exe.GenerateMD5Hash();
config.Hashes.SourceLibrary = source_lib.GenerateMD5Hash();
// may switch those 2 later to have it outside...
game_injector.Inject_SetContentRootDirectoryToCurrentDir_InsertAtStartOfMain();
game_injector.Inject_CallTo_ModRuntimeController_Initialize_AtStartOfMain(ModManager.GameDirectory.ContainingFile(ModManager.ModController));
//game_injector.Inject_TryCatchWrapperAroundEverthingInMain_WriteCrashLog();
//game_injector.Inject_CurrentAppDomain_AddResolveEventAtStartOfMain();
game_injector.Inject_SaveLoadCalls();
//game_injector.Inject_TryCatchWrapperAroundGnomanEmpire_LoadGame();
game_injector.Debug_ManipulateStuff();
if (useHiDefProfile)
{
game_injector.Inject_AddHighDefXnaProfile();
}
foreach (var mod in mods_to_use)
{
ProcessMod(mod);
}
var allLoadedStuff = processedMods.Select(mod => Tuple.Create(mod, mod.Dependencies.Union(mod.InitAfter.Where(befor => processedMods.Contains(befor.GetInstance()))).Select(type => type.GetInstance())));
var processedMods_sortedByDependencyAndInitAfter = DependencySort.Sort(allLoadedStuff);
config.SetModReferences(processedMods_sortedByDependencyAndInitAfter.Select(mod => new ModReference(mod)).ToArray());
//Mono.Cecil.WriterParameters
game_injector.Write(modded_exe);
lib_injector.Write(modded_lib);
config.Hashes.ModdedExecutable = modded_exe.GenerateMD5Hash();
config.Hashes.ModdedLibrary = modded_lib.GenerateMD5Hash();
}
示例12: RegisterMod
/// <summary>
/// Register mod, if not already registered
/// </summary>
/// <param name="mod">Mod to be registered</param>
public static void RegisterMod(IMod mod)
{
if (loadedModTypes.Contains(mod.GetType()))
{
return;
}
RegisterItems(mod.RegisterItems());
RegisterRecipes(mod.RegisterRecipes());
loadedModTypes.Add(mod.GetType());
}
示例13: ModFileInstaller
/// <summary>
/// A simple constructor that initializes the object with its dependencies.
/// </summary>
/// <param name="p_gmiGameModeInfo">The environment info of the current game mode.</param>
/// <param name="p_modMod">The mod being installed.</param>
/// <param name="p_ilgInstallLog">The install log to use to log file installations.</param>
/// <param name="p_pmgPluginManager">The plugin manager.</param>
/// <param name="p_dfuDataFileUtility">The utility class to use to work with data files.</param>
/// <param name="p_tfmFileManager">The transactional file manager to use to interact with the file system.</param>
/// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
/// <param name="p_UsesPlugins">Whether the file is a mod or a plugin.</param>
public ModFileInstaller(IGameModeEnvironmentInfo p_gmiGameModeInfo, IMod p_modMod, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager, IDataFileUtil p_dfuDataFileUtility, TxFileManager p_tfmFileManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, bool p_UsesPlugins)
{
GameModeInfo = p_gmiGameModeInfo;
Mod = p_modMod;
InstallLog = p_ilgInstallLog;
PluginManager = p_pmgPluginManager;
DataFileUtility = p_dfuDataFileUtility;
TransactionalFileManager = p_tfmFileManager;
m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate ?? ((s, b, m) => OverwriteResult.No);
IsPlugin = p_UsesPlugins;
}
示例14: RegisterMod
/// <summary>
/// Registers the given mod as being active, and associates it with the given key.
/// </summary>
/// <param name="p_modNewMod">The mod to register.</param>
/// <param name="p_strModKey">The key with which to associate the mod.</param>
/// <param name="p_booHiddenMod">Whether or not the mod should be included in the
/// list of active mods.</param>
public void RegisterMod(IMod p_modNewMod, string p_strModKey, bool p_booHiddenMod)
{
if (m_dicModKeys.ContainsValue(p_strModKey))
{
IMod modOld = m_dicModKeys.First(x => x.Value.Equals(p_strModKey)).Key;
DeregisterMod(modOld);
}
m_dicModKeys.Add(p_modNewMod, p_strModKey);
if (!p_booHiddenMod)
m_oclRegisteredMods.Add(p_modNewMod);
}
示例15: FindAlternateVersion
/// <summary>
/// This finds any mod in the candidate list that appears to be another version of the given mod.
/// </summary>
/// <param name="p_modMod">The mod for which to find another version.</param>
/// <param name="p_booExistingOnly">Whether the matcher should only match candidate mods that exist.</param>
/// <returns>The active mod that appears to be another version of the given mod,
/// or <c>null</c> if no such mod was found.</returns>
public IMod FindAlternateVersion(IMod p_modMod, bool p_booExistingOnly)
{
IEnumerable<IMod> lstMatches = from m in Candidates
where !String.IsNullOrEmpty(m.Id)
&& m.Id.Equals(p_modMod.Id)
&& !m.Filename.Equals(p_modMod.Filename, StringComparison.OrdinalIgnoreCase)
&& (AssumeAllExist || !p_booExistingOnly || File.Exists(m.Filename))
select m;
string strNewModName = p_modMod.ModName;
if (String.IsNullOrEmpty(p_modMod.Id))
{
if (lstMatches.Count() == 0)
{
lstMatches = from m in Candidates
where m.ModName.Equals(strNewModName, StringComparison.InvariantCultureIgnoreCase)
&& !m.Filename.Equals(p_modMod.Filename, StringComparison.OrdinalIgnoreCase)
&& (AssumeAllExist || !p_booExistingOnly || File.Exists(m.Filename))
select m;
}
if (lstMatches.Count() == 0)
{
string strNewModNamePrefix = strNewModName.Split('-')[0].Trim();
lstMatches = from m in Candidates
where m.ModName.Split('-')[0].Trim().Equals(strNewModNamePrefix, StringComparison.InvariantCultureIgnoreCase)
&& !m.Filename.Equals(p_modMod.Filename, StringComparison.OrdinalIgnoreCase)
&& (AssumeAllExist || !p_booExistingOnly || File.Exists(m.Filename))
select m;
}
}
IMod modMatch = null;
Int64 intFilesize = 0;
foreach (IMod modCandidate in lstMatches)
{
if (File.Exists(modCandidate.Filename))
{
FileInfo fifInfo = new FileInfo(modCandidate.Filename);
if (fifInfo.Length > intFilesize)
{
intFilesize = fifInfo.Length;
modMatch = modCandidate;
}
}
}
if (modMatch == null)
modMatch = lstMatches.FirstOrDefault();
return modMatch;
}