internal void Init(ErrorCheckersConfig checkersConfig, PluginsConfig pluginsConfig)
 {
     m_config        = checkersConfig;
     m_pluginsConfig = pluginsConfig;
     PopulateListBox();
     drawWindow1.Invalidate(true);
 }
Exemple #2
0
 protected NodeCustomizer(IDataSource datasource, TypeMapConfig <Id <NodeTypeTemp>, TChoice> config, PluginsConfig pluginsConfig)
     : this()
 {
     m_datasource    = datasource;
     m_config        = config;
     m_pluginsConfig = pluginsConfig;
 }
        public void RefreshConfig(PluginsConfig pluginsConfig)
        {
            foreach (var pluginAssembly in pluginsConfig.UnfilteredAssemblies(MainAssembly.Include))
            {
                ErrorCheckerAssembly configECA = GetAssembly(pluginAssembly);

                if (configECA == null)
                {
                    configECA = new ErrorCheckerAssembly(pluginAssembly);
                    AddAssembly(configECA);
                }
            }
            Save();
        }
        public ProjectMenuController(SharedContext context, ConfigParameterList <string> config, INodeFactory conversationNodeFactory, INodeFactory domainNodeFactory, Action <Action> executeInGuiThread, PluginsConfig pluginsConfig, Func <IAudioProviderCustomization> audioCustomization, UpToDateFile.BackEnd backend)
        {
            m_context                 = context;
            m_executeInGuiThread      = executeInGuiThread;
            m_conversationNodeFactory = conversationNodeFactory;
            m_domainNodeFactory       = domainNodeFactory;
            m_config                = config;
            m_pluginsConfig         = pluginsConfig;
            m_audioCustomization    = audioCustomization;
            m_backend               = backend;
            m_context.ProjectMoved += WeakCallback <Changed <FileInfo> > .Handler(this, (me, a) => me.ProjectMoved(a.From, a.To));

            m_context.CurrentProject.Changed.Register(this, (a, b) => UpdateRecentlyOpenedConfig());

            var file = m_config.Value.FirstOrDefault(a => true, a => a, "");

            if (File.Exists(file))
            {
                OpenProject(file);
            }
        }
Exemple #5
0
 public NodeEditorCustomizer(IDataSource datasource, TypeMapConfig <Id <NodeTypeTemp>, NodeEditorChoice> config, PluginsConfig pluginsConfig)
     : base(datasource, config, pluginsConfig)
 {
 }
Exemple #6
0
 public void Initalize(IColorScheme scheme, PluginsConfig config)
 {
     m_config = config;
     Scheme   = scheme;
     PopulatePluginList();
 }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="data"></param>
        /// <param name="conversationNodeFactory"></param>
        /// <param name="domainNodeFactory"></param>
        /// <param name="initialContent">Represents the current contents of the file. Reference is not held. A copy is made.</param>
        /// <param name="projectFile"></param>
        /// <param name="serializer"></param>
        /// <param name="conversationSerializer"></param>
        /// <param name="conversationSerializerDeserializerFactory"></param>
        /// <param name="domainSerializer"></param>
        /// <param name="pluginsConfig"></param>
        /// <param name="audioCustomization"></param>
        public Project(ILocalizationContext context, TData data, INodeFactory conversationNodeFactory, INodeFactory domainNodeFactory, MemoryStream initialData, FileInfo projectFile, ISerializer <TData> serializer, ISerializer <TConversationData> conversationSerializer, ConversationSerializerDeserializerFactory conversationSerializerDeserializerFactory, ISerializer <TDomainData> domainSerializer, PluginsConfig pluginsConfig, Func <IAudioProviderCustomization> audioCustomization, UpToDateFile.BackEnd backend)
        {
            AssertUniqueFileIds(data);
            AssertUniqueLocalizationSetNames(data);
            AssertUniqueFilePaths(data);

            m_upToDateFileBackend = backend;
            Action <Stream> saveTo = stream =>
            {
                Write(GetFilePath, Conversations.Select(x => (x.Id)), LocalizationFiles.Select(x => (x.Id)),
                      DomainFiles.Select(x => (x.Id)), AudioFiles.Select(x => (x.Id)), Localizer.LocalizationSets, stream, m_serializer);
            };

            m_file = new SaveableFileNotUndoable(initialData, projectFile, saveTo, backend);
            ConversationNodeFactory         = conversationNodeFactory;
            DomainNodeFactory               = domainNodeFactory;
            m_serializer                    = serializer;
            ConversationSerializer          = conversationSerializer;
            m_conversationSerializerFactory = conversationSerializerDeserializerFactory;
            m_domainSerializer              = domainSerializer;

            m_filePaths = data.Conversations.Concat(data.Localizations).Concat(data.Domains).Concat(data.Audios).ToDictionary(f => f.Id, f => f.Path);

            IEnumerable <Id <FileInProject> > conversationIds = data.Conversations.Select(f => f.Id);
            IEnumerable <Id <FileInProject> > localizerIds    = data.Localizations.Select(f => f.Id);
            IEnumerable <Id <FileInProject> > domainIds       = data.Domains.Select(f => f.Id);
            IEnumerable <Id <FileInProject> > audioIds        = data.Audios.Select(f => f.Id);

            m_audioProvider = new AudioProvider(new FileInfo(projectFile.FullName), GetFilePath, s => CheckFolder(s, Origin), this, audioCustomization());
            using (m_audioProvider.SuppressUpdates())
            {
                {
                    m_audioProvider.AudioFiles.Load(audioIds);
                }

                {
                    //Dictionary<IDynamicEnumParameter, DynamicEnumParameter.Source> domainEnumSource = new Dictionary<IDynamicEnumParameter, DynamicEnumParameter.Source>();
                    Func <IDynamicEnumParameter, object, DynamicEnumParameter.Source> getDomainEnumSource = (k, o) =>
                    {
                        return(null); //Nothing should need a source (but the system will ask anyway)
                                      //if (!domainEnumSource.ContainsKey(k))
                                      //domainEnumSource[k] = new DynamicEnumParameter.Source();
                                      //return domainEnumSource[k];
                    };

                    m_domainDataSource = new DomainDomain(pluginsConfig);
                    Func <IEnumerable <Tuple <Id <FileInProject>, DocumentPath> >, IEnumerable <IDomainFile> > loader = paths =>
                    {
                        var result = DomainFile.Load(paths, m_domainDataSource, DomainSerializerDeserializer.Make, DomainNodeFactory, () => DomainUsage, getDomainEnumSource, backend).Evaluate();
                        result.ForAll(a => a.ConversationDomainModified += ConversationDatasourceModified);
                        return(result);
                    };
                    Func <DirectoryInfo, DomainFile> makeEmpty = path => DomainFile.CreateEmpty(path, m_domainDataSource, m_domainSerializer, pathOk, DomainNodeFactory, () => DomainUsage, getDomainEnumSource, backend, Origin);
                    m_domainFiles = new ProjectElementList <IDomainFile>(GetFilePath, s => CheckFolder(s, Origin), loader, makeEmpty);
                    m_domainFiles.Load(domainIds);
                }
                m_conversationDataSource = new ConversationDataSource(m_domainFiles.Select(df => df.Data));

                if (m_conversationDataSource.DomainErrors.Any())
                {
                    MessageBox.Show(string.Join("\n", m_conversationDataSource.DomainErrors.Select(error => error.Message)));
                }

                {
                    m_localizer = new LocalizationEngine(GetFilePath, data.LocalizationSets, context, UsedLocalizations, ShouldContract, pathOk, s => CheckFolder(s, Origin), backend, Origin);
                    m_localizer.Localizers.Load(localizerIds);
                    context.CurrentLocalization.Value    = m_localizer.LocalizationSets.FirstOrDefault() ?? Project.TData.LocalizerSetData.Empty;
                    m_localizer.LocalizationSetsChanged += () => { m_file.Change(); };
                }

                {
                    GenerateAudio audio = (c) =>
                    {
                        return(m_audioProvider.Generate(new AudioGenerationParameters(c.File.File, this.File.File)));
                    };

                    //This can be called from multiple threads simultaneously and in arbitrary orders by design of
                    //ConversationDataSource and the underlying ConstantTypeSet and DynamicEnumParameter.Source
                    Func <IDynamicEnumParameter, object, DynamicEnumParameter.Source> getSource = (localEnum, newSourceID) =>
                    {
                        return(m_conversationDataSource.GetSource(localEnum.TypeId, newSourceID));
                    };

                    Func <IEnumerable <Tuple <Id <FileInProject>, DocumentPath> >, IEnumerable <IConversationFile> > loadConversations = files =>
                    {
                        ISerializerDeserializer <XmlGraphData <NodeUIData, ConversationEditorData> > conversationSerializerDeserializer = m_conversationSerializerFactory(m_conversationDataSource);
                        //                                                 _/          _/                           _/                         X        _/             X            _/
                        //return files.Select(file => ConversationFile.Load(file, ConversationNodeFactory, conversationSerializerDeserializer, audio, getSource, m_audioProvider, backend));
                        //TODO: AUDIO: This is ok as long as we're not using audio parameters at all
                        return(ParallelEnumerable.Select(files.AsParallel(), file => ConversationFile.Load(file.Item1, file.Item2, ConversationNodeFactory, conversationSerializerDeserializer, audio, getSource, m_audioProvider, backend)));
                    };
                    Func <DirectoryInfo, ConversationFile> makeEmpty = path => ConversationFile.CreateEmpty(path, this, ConversationNodeFactory, audio, getSource, m_audioProvider, backend, Origin);
                    m_conversations = new ProjectElementList <IConversationFile>(GetFilePath, s => CheckFolder(s, Origin), loadConversations, makeEmpty);
                    m_conversations.Load(conversationIds);
                }

                RefreshCallbacks(m_conversations, m_actionsOnRefreshCallbacksConversations);
                RefreshCallbacks(m_audioProvider.AudioFiles, m_actionsOnRefreshCallbacksAudios);
                RefreshCallbacks(m_localizer.Localizers, m_actionsOnRefreshCallbacksLocalizations);
                RefreshCallbacks(m_domainFiles, m_actionsOnRefreshCallbacksDomains);

                m_conversations.GotChanged            += GotChanged;
                m_audioProvider.AudioFiles.GotChanged += GotChanged;
                m_localizer.Localizers.GotChanged     += GotChanged;
                m_domainFiles.GotChanged += GotChanged;

                m_conversations.GotChanged            += () => RefreshCallbacks(m_conversations, m_actionsOnRefreshCallbacksConversations);
                m_audioProvider.AudioFiles.GotChanged += () => RefreshCallbacks(m_audioProvider.AudioFiles, m_actionsOnRefreshCallbacksAudios);
                m_localizer.Localizers.GotChanged     += () => RefreshCallbacks(m_localizer.Localizers, m_actionsOnRefreshCallbacksLocalizations);
                m_domainFiles.GotChanged += () => RefreshCallbacks(m_domainFiles, m_actionsOnRefreshCallbacksDomains);


                m_domainFiles.GotChanged += ConversationDatasourceModified;
                Action <IDomainFile> MaybeConversationDatasourceModified = file => { if (!file.File.Changed())
                                                                                     {
                                                                                         ConversationDatasourceModified();
                                                                                     }
                };
                m_domainFiles.Added    += argument => { argument.File.SaveStateChanged += () => MaybeConversationDatasourceModified(argument); };
                m_domainFiles.Reloaded += (_, argument) => { argument.File.SaveStateChanged += () => MaybeConversationDatasourceModified(argument); };
                m_domainFiles.ForAll(d => d.File.SaveStateChanged += () => MaybeConversationDatasourceModified(d));
                //m_domainFiles.Added += argument => { argument.File.SaveStateChanged += () => { if (!argument.File.Changed) ReloadDatasource(); }; };
                //m_domainFiles.Reloaded += (from, to) => { to.File.SaveStateChanged += () => { if (!to.File.Changed) ReloadDatasource(); }; };
                //m_domainFiles.ForAll(d => d.File.SaveStateChanged += () => { if (!d.File.Changed) ReloadDatasource(); });

                m_domainFiles.Added                += file => m_filePaths[file.Id] = DocumentPath.FromAbsolutePath(file.File.File.FullName, Origin);
                m_conversations.Added              += file => m_filePaths[file.Id] = DocumentPath.FromAbsolutePath(file.File.File.FullName, Origin);
                m_audioProvider.AudioFiles.Added   += file => m_filePaths[file.Id] = DocumentPath.FromAbsolutePath(file.File.File.FullName, Origin);
                m_localizer.Localizers.Added       += file => m_filePaths[file.Id] = DocumentPath.FromAbsolutePath(file.File.File.FullName, Origin);
                m_domainFiles.Removed              += file => m_filePaths.Remove(file.Id);
                m_conversations.Removed            += file => m_filePaths.Remove(file.Id);
                m_audioProvider.AudioFiles.Removed += file => m_filePaths.Remove(file.Id);
                m_localizer.Localizers.Removed     += file => m_filePaths.Remove(file.Id);
                //Files being moved is setup in RefreshCallbacks()

                DomainUsage = new DomainUsage(this);

                m_audioProvider.UpdateUsage();
            }
        }
Exemple #8
0
        public static Project CreateEmpty(ILocalizationContext context, FileInfo path, INodeFactory conversationNodeFactory, INodeFactory domainNodeFactory, ISerializer <TData> serializer, ISerializer <TConversationData> conversationSerializer, ConversationSerializerDeserializerFactory conversationSerializerDeserializer, ISerializer <TDomainData> domainSerializer, PluginsConfig pluginsConfig, Func <IAudioProviderCustomization> audioCustomization, UpToDateFile.BackEnd backEnd)
        {
            using (MemoryStream m = new MemoryStream())
            {
                //Create the new conversation file stream, fill with essential content and close
                FileInfo conversationFile = ConversationFile.GetAvailableConversationPath(path.Directory, Enumerable.Empty <ISaveableFileProvider>());
                using (FileStream conversationStream = Util.LoadFileStream(conversationFile, FileMode.CreateNew, FileAccess.Write))
                {
                    conversationSerializer.Write(SerializationUtils.MakeConversationData(Enumerable.Empty <ConversationNode>(), new ConversationEditorData()), conversationStream);
                }

                //Create the new project
                GetFilePath getFilePath = null; //Should never need this as all the FileId lists are empty
                Write(getFilePath, Enumerable.Empty <Id <FileInProject> >(), Enumerable.Empty <Id <FileInProject> >(), Enumerable.Empty <Id <FileInProject> >(), Enumerable.Empty <Id <FileInProject> >(), Enumerable.Empty <TData.LocalizerSetData>(), m, serializer);
                using (FileStream projectfile = Util.LoadFileStream(path, FileMode.Create, FileAccess.Write))
                {
                    m.Position = 0;
                    m.CopyTo(projectfile);
                    m.Position = 0;
                }

                TData data = new TData(Enumerable.Empty <TData.FileIdAndPath>(), Enumerable.Empty <TData.FileIdAndPath>(), Enumerable.Empty <TData.FileIdAndPath>(), Enumerable.Empty <TData.FileIdAndPath>(), Enumerable.Empty <TData.LocalizerSetData>());

                Project result = new Project(context, data, conversationNodeFactory, domainNodeFactory, m, path, serializer, conversationSerializer, conversationSerializerDeserializer, domainSerializer, pluginsConfig, audioCustomization, backEnd);
                return(result);
            }
        }
Exemple #9
0
 public ErrorCheckerController(ErrorCheckersConfig config, PluginsConfig pluginsConfig)
 {
     m_config        = config;
     m_pluginsConfig = pluginsConfig;
 }