/// <summary>
        /// Gets the editor to use to edit the <see cref="XmlScript"/>'s conditionally installed file set order.
        /// </summary>
        /// <param name="p_lstConditionallyInstalledFileSets">The conditionally installed file sets whose order is to be edited.</param>
        /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
        /// being edited belongs.</param>
        /// <returns>The editor to use to the the <see cref="XmlScript"/>'s conditionally installed file set order. <c>null</c> is returned if the
        /// current <see cref="XmlScript"/> does not support editing the conditionally installed file set order.</returns>
        public virtual NodeEditor GetConditionallyInstalledFileSetOrderEditor(IList <ConditionallyInstalledFileSet> p_lstConditionallyInstalledFileSets, IList <VirtualFileSystemItem> p_lstModFiles)
        {
            CPLConverter cvtConverter = new CPLConverter(ScriptType.GetCplParserFactory());
            ConditionallyInstalledFileSetOrderEditorVM vmlOrderEditor = new ConditionallyInstalledFileSetOrderEditorVM(p_lstConditionallyInstalledFileSets, cvtConverter);

            return(new ConditionallyInstalledFileSetOrderEditor(vmlOrderEditor));
        }
 /// <summary>
 /// Saves the changes that have been made to the <see cref="ICondition"/>.
 /// </summary>
 public void SaveCondition()
 {
     if (Validate())
     {
         Condition = CPLConverter.CplToCondition(EditorViewModel.TextEditorVM.Code);
         OnConditionSaved();
     }
 }
        /// <summary>
        /// Gets the editor to use to edit the <see cref="XmlScript"/> prerequisites.
        /// </summary>
        /// <param name="p_xscScript">The <see cref="XmlScript"/> whose prerequisites are to be edited.</param>
        /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
        /// being edited belongs.</param>
        /// <returns>The editor to use to edit <see cref="XmlScript"/> prerequisites. <c>null</c> is returned if the
        /// current <see cref="XmlScript"/> does not support editing the prerequisites.</returns>
        public virtual NodeEditor GetPrerequisitesEditor(ModManagement.Scripting.XmlScript.XmlScript p_xscScript, IList <VirtualFileSystemItem> p_lstModFiles)
        {
            CPLConverter          cvtConverter           = new CPLConverter(ScriptType.GetCplParserFactory());
            CPLEditorVM           vmlCplEditor           = CreateCPLEditorVM(p_lstModFiles);
            PrerequisitesEditorVM vmlPrerequisitesEditor = new PrerequisitesEditorVM(vmlCplEditor, cvtConverter, p_xscScript);

            return(new ConditionEditor(vmlPrerequisitesEditor));
        }
        /// <summary>
        /// Gets the editor to use to edit an <see cref="InstallStep"/>.
        /// </summary>
        /// <param name="p_ispStep">The <see cref="InstallStep"/> to edit.</param>
        /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
        /// being edited belongs.</param>
        /// <returns>The editor to use to edit an <see cref="InstallStep"/>. <c>null</c> is returned if the
        /// current <see cref="XmlScript"/> does not support editing <see cref="InstallStep"/>s.</returns>
        public virtual NodeEditor GetInstallStepEditor(InstallStep p_ispStep, IList <VirtualFileSystemItem> p_lstModFiles)
        {
            CPLConverter      cvtConverter       = new CPLConverter(ScriptType.GetCplParserFactory());
            ConditionEditorVM vmlConditionEditor = CreateConditionEditorVM(p_lstModFiles, cvtConverter);

            InstallStepEditorVM vmlStepEditor = new InstallStepEditorVM(vmlConditionEditor, p_ispStep, InstallStepProperties.Name | InstallStepProperties.GroupSortOrder | InstallStepProperties.Visibility);

            return(new InstallStepEditor(vmlStepEditor));
        }
Beispiel #5
0
        /// <summary>
        /// A simple constructor that initializes the view model with its dependencies.
        /// </summary>
        /// <param name="p_tpeConditionalTypePatternEditorVM">The <see cref="NodeEditors.ConditionalTypePatternEditorVM"/> that encapsulates the data
        /// and operations for diaplying the <see cref="ConditionalTypePattern"/> editor.</param>
        /// <param name="p_ctrCPLConverter">The <see cref="CPLConverter"/> to use to convert <see cref="ICondition"/>s
        /// conditions to a string.</param>
        /// <param name="p_ctrTypeResolver">The <see cref="ConditionalOptionTypeResolver"/> being edited.</param>
        public ConditionalTypeEditorVM(ConditionalTypePatternEditorVM p_tpeConditionalTypePatternEditorVM, CPLConverter p_ctrCPLConverter, ConditionalOptionTypeResolver p_ctrTypeResolver)
        {
            ConditionalTypePatternEditorVM = p_tpeConditionalTypePatternEditorVM;
            Converter    = p_ctrCPLConverter;
            TypeResolver = p_ctrTypeResolver;
            OptionTypes  = Enum.GetValues(typeof(OptionType));

            EditCommand   = new Command <ConditionalTypePattern>("Edit", "Edit the selected conditional type.", EditConditionalTypePattern, false);
            AddCommand    = new Command <ConditionalTypePattern>("Add", "Add a conditional type.", AddConditionalTypePattern);
            DeleteCommand = new Command <ConditionalTypePattern>("Delete", "Delete the selected conditional type.", DeleteConditionalTypePattern, false);
        }
        /// <summary>
        /// The editor to use to edit a <see cref="ConditionallyInstalledFileSet"/>.
        /// </summary>
        /// <param name="p_cisFileSet">The <see cref="ConditionallyInstalledFileSet"/> to edit.</param>
        /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
        /// being edited belongs.</param>
        /// <returns>The editor to use to edit an <see cref="ConditionallyInstalledFileSet"/>. <c>null</c> is returned if the
        /// current <see cref="XmlScript"/> does not support editing <see cref="ConditionallyInstalledFileSet"/>s.</returns>
        public virtual NodeEditor GetConditionallyInstalledFileSetEditor(ConditionallyInstalledFileSet p_cipPattern, IList <VirtualFileSystemItem> p_lstModFiles)
        {
            CPLConverter      cvtConverter       = new CPLConverter(ScriptType.GetCplParserFactory());
            ConditionEditorVM vmlConditionEditor = CreateConditionEditorVM(p_lstModFiles, cvtConverter);

            InstallableFileEditorVM vmlInstallableFile = new InstallableFileEditorVM(null, p_lstModFiles);
            FileListEditorVM        vmlFileList        = new FileListEditorVM(vmlInstallableFile, p_cipPattern.Files);

            ConditionallyInstalledFileSetEditorVM vmlFileInstall = new ConditionallyInstalledFileSetEditorVM(vmlConditionEditor, vmlFileList, p_cipPattern);

            return(new ConditionallyInstalledFileSetEditor(vmlFileInstall));
        }
        /// <summary>
        /// The editor to use to edit an <see cref="Option"/>.
        /// </summary>
        /// <param name="p_optOption">The <see cref="Option"/> to edit.</param>
        /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
        /// being edited belongs.</param>
        /// <returns>The editor to use to edit an <see cref="Option"/>. <c>null</c> is returned if the
        /// current <see cref="XmlScript"/> does not support editing <see cref="Option"/>s.</returns>
        public virtual NodeEditor GetOptionEditor(Option p_optOption, IList <VirtualFileSystemItem> p_lstModFiles)
        {
            OptionInfoEditorVM vmlOptionInfo = new OptionInfoEditorVM(p_optOption, p_lstModFiles);

            InstallableFileEditorVM vmlInstallableFile = new InstallableFileEditorVM(null, p_lstModFiles);
            FileListEditorVM        vmlFileList        = new FileListEditorVM(vmlInstallableFile, p_optOption.Files);

            CPLConverter      cvtConverter       = new CPLConverter(ScriptType.GetCplParserFactory());
            ConditionEditorVM vmlConditionEditor = CreateConditionEditorVM(p_lstModFiles, cvtConverter);

            ConditionalTypePatternEditorVM vmlPatternEditor      = new ConditionalTypePatternEditorVM(vmlConditionEditor, null);
            ConditionalTypeEditorVM        vmlTypeEditor         = new ConditionalTypeEditorVM(vmlPatternEditor, cvtConverter, null);
            OptionTypeResolverEditorVM     vmlTypeResolverEditor = new OptionTypeResolverEditorVM(vmlTypeEditor, p_optOption);

            OptionEditorVM vmlOptionEditor = new OptionEditorVM(vmlOptionInfo, vmlFileList, vmlTypeResolverEditor);

            return(new OptionEditor(vmlOptionEditor));
        }
        /// <summary>
        /// Creates a <see cref="ConditionEditorVM"/>.
        /// </summary>
        /// <param name="p_lstModFiles">The list of files in the script's mod.</param>
        /// <param name="p_cvtConverter">A converter to use to convert CPL.</param>
        /// <returns>A <see cref="ConditionEditorVM"/>.</returns>
        protected virtual ConditionEditorVM CreateConditionEditorVM(IList <VirtualFileSystemItem> p_lstModFiles, CPLConverter p_cvtConverter)
        {
            CPLEditorVM       vmlCplEditor       = CreateCPLEditorVM(p_lstModFiles);
            ConditionEditorVM vmlConditionEditor = new ConditionEditorVM(vmlCplEditor, p_cvtConverter, null);

            return(vmlConditionEditor);
        }
 /// <summary>
 /// A simple constructor that initializes the view model with its dependencies.
 /// </summary>
 /// <param name="p_edtEditorViewModel">The <see cref="CPLEditorVM"/> that encapsulates the data
 /// and operations for diaplying the CPL editor.</param>
 /// <param name="p_ctrCPLConverter">The CPL converter.</param>
 /// <param name="p_cndCondition">The <see cref="ICondition"/> being edited.</param>
 public ConditionEditorVM(CPLEditorVM p_edtEditorViewModel, CPLConverter p_ctrCPLConverter, ICondition p_cndCondition)
 {
     EditorViewModel = p_edtEditorViewModel;
     CPLConverter    = p_ctrCPLConverter;
     Condition       = p_cndCondition;
 }
 /// <summary>
 /// A simple constructor that initializes the view model with its dependencies.
 /// </summary>
 /// <param name="p_lstConditionallyInstalledFileSets">The list of <see cref="ConditionallyInstalledFileSet"/>s whose order
 /// is being edited.</param>
 /// <param name="p_cvtConverter">The <see cref="CPLConverter"/> to use to convert the <see cref="ConditionallyInstalledFileSet"/>'s
 /// conditions to a string.</param>
 public ConditionallyInstalledFileSetOrderEditorVM(IList <ConditionallyInstalledFileSet> p_lstConditionallyInstalledFileSets, CPLConverter p_cvtConverter)
 {
     ConditionallyInstalledFileSets = p_lstConditionallyInstalledFileSets;
     Converter = p_cvtConverter;
 }
 public PrerequisitesEditorVM(CPLEditorVM p_edtEditorViewModel, CPLConverter p_ctrCPLConverter, XmlScript p_xscScript)
     : base(p_edtEditorViewModel, p_ctrCPLConverter, null)
 {
     Script = p_xscScript;
 }
        /// <summary>
        /// Creates a <see cref="ConditionEditorVM"/>.
        /// </summary>
        /// <param name="p_lstModFiles">The list of files in the script's mod.</param>
        /// <param name="p_cvtConverter">A converter to use to convert CPL.</param>
        /// <returns>A <see cref="ConditionEditorVM"/>.</returns>
        protected virtual ConditionEditorVM CreateConditionEditorVM(IList <VirtualFileSystemItem> p_lstModFiles, CPLConverter p_cvtConverter)
        {
            CPLTextEditorVM vmlCplTextEditor = new CPLTextEditorVM(new FO3CplHighlightingStrategy(ScriptType.GetCplParserFactory()), ScriptType.GetCplParserFactory());

            List <CplConditionEditor> lstConditionEditors = new List <CplConditionEditor>();

            lstConditionEditors.Add(new CplPluginConditionEditor(p_lstModFiles));
            lstConditionEditors.Add(new CplFlagConditionEditor());
            CPLEditorVM vmlCplEditor = new CPLEditorVM(vmlCplTextEditor, lstConditionEditors, ConditionOperator.And | ConditionOperator.Or);


            ConditionEditorVM vmlConditionEditor = new ConditionEditorVM(vmlCplEditor, p_cvtConverter, null);

            return(vmlConditionEditor);
        }