public void Init(DocumentDialogue inDocument, TreeNode inTreeNode, DialogueNode inDialogueNode)
        {
            document     = inDocument;
            treeNode     = inTreeNode;
            dialogueNode = inDialogueNode;

            treeAttributes.ImageList = EditorCore.DefaultImageList;

            //Roots
            treeNodeRootConditions = treeAttributes.Nodes.Add("Root", "Conditions");
            treeNodeRootConditions.ContextMenuStrip = menuAttributes;
            EditorHelper.SetNodeIcon(treeNodeRootConditions, ENodeIcon.ListRootConditions);

            treeNodeRootActions = treeAttributes.Nodes.Add("Root", "Actions");
            treeNodeRootActions.ContextMenuStrip = menuAttributes;
            EditorHelper.SetNodeIcon(treeNodeRootActions, ENodeIcon.ListRootActions);

            treeNodeRootFlags = treeAttributes.Nodes.Add("Root", "Flags");
            treeNodeRootFlags.ContextMenuStrip = menuAttributes;
            EditorHelper.SetNodeIcon(treeNodeRootFlags, ENodeIcon.ListRootFlags);

            //Sync Conditions
            foreach (NodeCondition condition in dialogueNode.Conditions)
            {
                AddTreeNodeCondition(condition, treeNodeRootConditions);
            }

            //Sync Actions
            foreach (NodeAction action in dialogueNode.Actions)
            {
                AddTreeNodeAction(action);
            }

            //Sync Flags
            foreach (NodeFlag flag in dialogueNode.Flags)
            {
                AddTreeNodeFlag(flag);
            }

            //Fill Menu Conditions
            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = "AND";
                menuItem.Click += delegate
                {
                    AddNodeCondition(Activator.CreateInstance(typeof(NodeConditionAnd)) as NodeCondition);
                };
                menuItemAddCondition.DropDownItems.Add(menuItem);
            }

            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = "OR";
                menuItem.Click += delegate
                {
                    AddNodeCondition(Activator.CreateInstance(typeof(NodeConditionOr)) as NodeCondition);
                };
                menuItemAddCondition.DropDownItems.Add(menuItem);
            }

            menuItemAddCondition.DropDownItems.Add(new ToolStripSeparator());

            foreach (ConditionSlot slot in EditorCore.ConditionSlots)
            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = slot.Text;
                menuItem.Click += delegate
                {
                    AddNodeCondition(Activator.CreateInstance(slot.ConditionType) as NodeCondition);
                };
                menuItemAddCondition.DropDownItems.Add(menuItem);
            }

            //Fill Menu Actions
            foreach (ActionSlot slot in EditorCore.ActionSlots)
            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = slot.Text;
                menuItem.Click += delegate
                {
                    AddNodeAction(Activator.CreateInstance(slot.ActionType) as NodeAction);
                };
                menuItemAddAction.DropDownItems.Add(menuItem);
            }

            //Fill Menu Flags
            foreach (FlagSlot slot in EditorCore.FlagSlots)
            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = slot.Text;
                menuItem.Click += delegate
                {
                    AddNodeFlag(Activator.CreateInstance(slot.FlagType) as NodeFlag);
                };
                menuItemAddFlag.DropDownItems.Add(menuItem);
            }

            ready = true;
        }
 static public void Check(Dialogue dialogue)
 {
     EditorHelper.CheckDialogueErrors(dialogue);
 }
Exemple #3
0
        //--------------------------------------------------------------------------------------------------------------
        // Exports

        static public bool ExportToCsv()
        {
            var project = ResourcesHandler.Project;

            string projectDirectory = EditorHelper.GetProjectDirectory();
            string exportDirectory  = Path.Combine(projectDirectory, EditorCore.Settings.DirectoryExportDialogues);

            var dialog = new DialogExport("Export Dialogues",
                                          exportDirectory,
                                          true, false,
                                          true, false,
                                          true, DateTime.MinValue);
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return(false);
            }

            EditorCore.Settings.DirectoryExportDialogues = Utility.GetRelativePath(dialog.ExportPath, projectDirectory);

            exportDirectory = dialog.ExportPath;
            if (dialog.UseDateDirectory)
            {
                exportDirectory = Path.Combine(exportDirectory, Utility.GetCurrentDateAsString());
            }

            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }

            var packageGroups = new List <List <Package> >();

            if (dialog.UsePackagesDirectory)
            {
                foreach (var package in dialog.ListPackages)
                {
                    packageGroups.Add(new List <Package>()
                    {
                        package
                    });
                }
            }
            else
            {
                packageGroups.Add(dialog.ListPackages);
            }

            ExporterStats.ProjectStats projectStats = new ExporterStats.ProjectStats();

            //Ensure no export of a Workstring language
            var listLanguages = new List <Language>();   // { EditorCore.LanguageWorkstring };

            if (!dialog.WorkstringOnly)
            {
                listLanguages = dialog.ListLanguages;
            }

            foreach (var packageGroup in packageGroups)     //Either a list of individual packages, or 1 entry with all the packages
            {
                var packageDirectory = exportDirectory;
                if (dialog.UsePackagesDirectory)
                {
                    packageDirectory = Path.Combine(packageDirectory, packageGroup[0].Name);
                }

                if (!Directory.Exists(packageDirectory))
                {
                    Directory.CreateDirectory(packageDirectory);
                }

                var dialogues = dialog.SelectedDialogues;
                if (!dialog.UseCustomSelection)
                {
                    dialogues = ResourcesHandler.GetAllDialoguesFromPackages(packageGroup);
                }

                ExportDialoguesToCsv(packageDirectory, project, dialogues, listLanguages, dialog.DateFrom, projectStats);

                ExporterStats.Export("TodoTranslationsCount", projectStats, packageDirectory, packageGroup, listLanguages, dialog.WorkstringOnly, dialog.WorkstringFallback);
            }

            if (dialog.Constants)
            {
                ExportConstantsToCsv(exportDirectory, project, listLanguages);
            }

            System.Diagnostics.Process.Start(exportDirectory);

            return(true);
        }
Exemple #4
0
        static public void ExportDialoguesToCsv(string directory, Project project, List <Dialogue> dialogues, List <Language> languages, DateTime dateFrom, ExporterStats.ProjectStats projectStats)
        {
            //Ensure no export of a Workstring language
            //languages.Remove(EditorCore.LanguageWorkstring);

            string path = Path.Combine(directory, "Loca_" + project.GetName() + ".csv");

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, false, Encoding.UTF8))
            {
                //Dialogue, Node ID, Timestamp, Voicing ID, Index, Package, SceneType, Context, Voicing, Voice Intensity, Speaker, Workstring Text, Words, ...Languages..., comments
                {
                    ExporterCsv.CsvLineWriter header = new ExporterCsv.CsvLineWriter();
                    header.AddField("Dialogue");
                    header.AddField("Node ID");
                    header.AddField("Timestamp");
                    header.AddField("Voicing ID");
                    header.AddField("Index");
                    header.AddField("Package");
                    header.AddField("Scene Type");
                    header.AddField("Context");
                    header.AddField("Voicing");
                    header.AddField("Voice Intensity");
                    header.AddField("Speaker");
                    header.AddField("Workstring Text");
                    //TODO: old workstring for updated texts ?
                    header.AddField("Words");
                    //TODO: characters count ?
                    foreach (var language in languages)
                    {
                        header.AddField(language.Name + " State");
                        header.AddField(language.Name + " Text");
                        header.AddField(language.Name + " Words");
                        //TODO: characters count ?
                    }
                    header.AddField("Comments");
                    header.WriteLine(file);
                }

                //file.Write("\n");

                foreach (Dialogue dialogue in dialogues)
                {
                    int index = 0;

                    var orderedListNodes = new List <DialogueNode>();
                    dialogue.GetOrderedNodes(ref orderedListNodes);

                    //Process global Dialogue information
                    {
                        string package   = dialogue.Package.Name;
                        string sceneType = dialogue.SceneType;
                        string context   = dialogue.Context;

                        ExporterCsv.CsvLineWriter line = new ExporterCsv.CsvLineWriter();
                        //Dialogue, Node ID, Timestamp, Voicing ID, Index, Package, SceneType, Context, Voicing, Voicing Intensity, Speaker, Workstring Text, Words, ...Languages..., comments
                        line.AddField(dialogue.GetName());
                        line.AddField(TranslationTable.DialogueNodePrefix + dialogue.RootNodeID);
                        line.AddEmptyField();
                        line.AddEmptyField();
                        line.AddField(index);
                        line.AddField(package);
                        line.AddField(sceneType);
                        line.AddField(context);
                        line.AddEmptyField();
                        line.AddEmptyField();
                        line.AddEmptyField();
                        line.AddEmptyField();
                        line.AddEmptyField();

                        //Locas
                        line.AddEmptyField();
                        line.AddEmptyField();
                        line.AddEmptyField();
                        line.AddEmptyField();

                        line.WriteLine(file);
                    }

                    foreach (DialogueNode dialogueNode in orderedListNodes)
                    {
                        if (dialogueNode is DialogueNodeSentence || dialogueNode is DialogueNodeReply)
                        {
                            ++index;

                            string   context    = "";
                            string   speaker    = "";
                            string   workstring = "";
                            DateTime workstringTimestamp;
                            bool     todo = false;
                            string   voicingID;
                            string   voicing;
                            string   voiceIntensity;

                            if (dialogueNode is DialogueNodeSentence)
                            {
                                var dialogueNodeSentence = dialogueNode as DialogueNodeSentence;

                                context             = dialogueNodeSentence.Context;
                                workstring          = dialogueNodeSentence.Sentence;
                                workstringTimestamp = dialogueNodeSentence.LastEditDate;

                                speaker = project.GetActorName(dialogueNodeSentence.SpeakerID);
                                if (speaker == "")
                                {
                                    speaker = "<Undefined>";
                                }

                                voicingID      = EditorHelper.GetPrettyNodeVoicingID(dialogue, dialogueNodeSentence);
                                voicing        = dialogueNodeSentence.Comment;
                                voiceIntensity = dialogueNodeSentence.VoiceIntensity;
                            }
                            else
                            {
                                var dialogueNodeReply = dialogueNode as DialogueNodeReply;

                                context             = "<User Interface>";
                                speaker             = "<UI>";
                                workstring          = dialogueNodeReply.Reply;
                                workstringTimestamp = dialogueNodeReply.LastEditDate;
                                voicingID           = "";
                                voicing             = "";
                                voiceIntensity      = "";
                            }

                            string[] split = workstring.Split(ExporterStats.DelimiterChars, StringSplitOptions.RemoveEmptyEntries);
                            int      words = split.Length;

                            //Dialogue, Node ID, Timestamp, Voicing ID, Index, Package, SceneType, Context, Voicing, Voicing Intensity, Speaker, Workstring Text, Words, ...Languages..., comments
                            ExporterCsv.CsvLineWriter line = new ExporterCsv.CsvLineWriter();
                            line.AddField(dialogue.GetName());
                            line.AddField(TranslationTable.DialogueNodePrefix + dialogueNode.ID);
                            line.AddField(workstringTimestamp);
                            line.AddField(voicingID);
                            line.AddField(index);
                            line.AddEmptyField();
                            line.AddEmptyField();
                            line.AddField(context);
                            line.AddField(voicing);
                            line.AddField(voiceIntensity);
                            line.AddField(speaker);
                            line.AddField(workstring);
                            line.AddField(words);

                            foreach (var language in languages)
                            {
                                var entry = dialogue.Translations.GetNodeEntry(dialogueNode, language);
                                if (entry != null)
                                {
                                    if (entry.SourceDate < workstringTimestamp)
                                    {
                                        todo = true;
                                        line.AddField("UPDATE");
                                    }
                                    else
                                    {
                                        line.AddField("OK");
                                    }
                                    line.AddField(entry.Text);
                                    line.AddEmptyField();
                                }
                                else
                                {
                                    todo = true;
                                    line.AddField("NEW");
                                    line.AddEmptyField();
                                    line.AddEmptyField();
                                }
                            }

                            line.AddEmptyField();
                            line.WriteLine(file);

                            if (todo)
                            {
                                if (dialogueNode is DialogueNodeSentence)
                                {
                                    var dialogueNodeSentence = dialogueNode as DialogueNodeSentence;
                                    projectStats.AddSentence(dialogue, dialogueNodeSentence.SpeakerID, workstring);
                                }
                                else
                                {
                                    var dialogueNodeReply = dialogueNode as DialogueNodeReply;
                                    projectStats.AddReply(dialogue, workstring);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        static public bool ExportToAriaCode()
        {
            var project = ResourcesHandler.Project;

            string projectDirectory = EditorHelper.GetProjectDirectory();
            string exportDirectory  = Properties.Settings.Default.ModPath;

            var dialog = new CodeExport("Export Dialogues",
                                        exportDirectory);
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return(false);
            }

            EditorCore.Settings.DirectoryExportDialogues = Utility.GetRelativePath(dialog.ExportPath, projectDirectory);

            exportDirectory = dialog.ExportPath;

            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }

            ExporterStats.ProjectStats projectStats = new ExporterStats.ProjectStats();

            string outputDirectory = Path.Combine(exportDirectory, "scripts", "globals", "static_data", "generated_dialog");

            if (!Directory.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }

            foreach (var package in dialog.ListPackages)     //Either a list of individual packages, or 1 entry with all the packages
            {
                var packageDirectory = Path.Combine(outputDirectory, package.Name);

                if (!Directory.Exists(packageDirectory))
                {
                    Directory.CreateDirectory(packageDirectory);
                }

                var dialogues = dialog.SelectedDialogues;
                if (!dialog.UseCustomSelection)
                {
                    dialogues = ResourcesHandler.GetAllDialoguesFromPackages(new List <Package>()
                    {
                        package
                    });
                }

                foreach (var singleDialog in dialogues)
                {
                    string luaContents = BuildLuaFile(singleDialog);
                    File.WriteAllText(Path.Combine(packageDirectory, singleDialog.GetName() + ".lua"), luaContents);
                }

                //Make generated_dialog/<package>/main.lua
                StringBuilder packageMainBuilder = new StringBuilder();
                AddAutogenerateHeader(packageMainBuilder);
                packageMainBuilder.AppendFormat("GeneratedDialog.{0} = {{}}{1}", package.Name, Environment.NewLine);

                foreach (var requireDialog in ResourcesHandler.GetAllDialoguesFromPackages(new List <Package>()
                {
                    package
                }))
                {
                    string dialogFile = Path.Combine(packageDirectory, requireDialog.GetName() + ".lua");
                    if (File.Exists(dialogFile))
                    {
                        packageMainBuilder.AppendFormat("require 'globals.static_data.generated_dialog.{0}.{1}'{2}", package.Name, requireDialog.GetName(), Environment.NewLine);
                    }
                }

                File.WriteAllText(Path.Combine(packageDirectory, "main.lua"), packageMainBuilder.ToString());
            }

            //Make generated_dialog/main.lua
            StringBuilder builder = new StringBuilder();

            AddAutogenerateHeader(builder);
            builder.AppendLine("GeneratedDialog = {}");
            foreach (var package in project.ListPackages)
            {
                if (File.Exists(Path.Combine(outputDirectory, package.Name, "main.lua")))
                {
                    builder.AppendFormat("require 'globals.static_data.generated_dialog.{0}.main'{1}", package.Name, Environment.NewLine);
                }
            }

            File.WriteAllText(Path.Combine(outputDirectory, "main.lua"), builder.ToString());

            System.Diagnostics.Process.Start(exportDirectory);

            Properties.Settings.Default.ModPath = exportDirectory;
            Properties.Settings.Default.Save();

            return(true);
        }
        protected void PlayNode(DialogueNode nextNode, bool forward = true)
        {
            if (forward && currentNode != null && !(currentNode is DialogueNodeReply) && !(currentNode is DialogueNodeGoto))
            {
                previousNodes.Add(currentNode);
            }

            if (nextNode == null)
            {
                Finish();
                return;
            }

            currentNode = nextNode;

            currentDocument.SelectNode(currentNode);

            ResetGroups();

            if (currentNode.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AlwaysFalse)
            {
                PlayNode(currentNode.Next);
                return;
            }

            if (currentNode is DialogueNodeSentence)
            {
                var sentence = currentNode as DialogueNodeSentence;

                ResetSentence();

                Actor speaker = ResourcesHandler.Project.GetActorFromID(sentence.SpeakerID);
                if (speaker != null)
                {
                    labelSpeaker.Text = speaker.Name;

                    string strPathPortraitSpeaker = Path.Combine(EditorHelper.GetProjectDirectory(), speaker.Portrait);
                    if (File.Exists(strPathPortraitSpeaker))
                    {
                        pictureBoxSpeaker.Image = Image.FromFile(strPathPortraitSpeaker);
                    }
                }

                Actor listener = ResourcesHandler.Project.GetActorFromID(sentence.ListenerID);
                if (listener != null)
                {
                    labelListener.Text = listener.Name;

                    string strPathPortraitListener = Path.Combine(EditorHelper.GetProjectDirectory(), listener.Portrait);
                    if (File.Exists(strPathPortraitListener))
                    {
                        pictureBoxListener.Image = Image.FromFile(strPathPortraitListener);
                    }
                }

                if (checkBoxOptionConstants.Checked)
                {
                    labelSentence.Text = EditorHelper.FormatTextEntry(sentence.Sentence, EditorCore.LanguageWorkstring);
                }
                else
                {
                    labelSentence.Text = sentence.Sentence;
                }
            }
            else if (currentNode is DialogueNodeChoice)
            {
                var choice = currentNode as DialogueNodeChoice;

                groupBoxChoice.Visible    = true;
                labelChoice.Text          = String.Format("Choice : {0}", choice.Choice);
                listBoxReplies.DataSource = new BindingSource(choice.Replies, null);

                checkBoxShowReplyConditions.Checked    = false;
                radioButtonReplyConditionsTrue.Checked = true;

                foreach (DialogueNodeReply reply in choice.Replies)
                {
                    if (reply.Conditions.Count > 0)
                    {
                        labelRepliesConditions.Enabled          = true;
                        checkBoxShowReplyConditions.Enabled     = true;
                        radioButtonReplyConditionsTrue.Enabled  = true;
                        radioButtonReplyConditionsFalse.Enabled = true;
                        break;
                    }
                }

                if (choice.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AskEveryTime)
                {
                    ShowConditions(choice);
                }
            }
            else if (currentNode is DialogueNodeGoto)
            {
                var nodeGoto = currentNode as DialogueNodeGoto;

                if (nodeGoto.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AskEveryTime)
                {
                    groupBoxGoto.Visible = true;
                    labelGoto.Text       = String.Format("Goto > \"{0}\"", GetGotoText(nodeGoto.Goto));

                    ShowConditions(nodeGoto);
                }
                else
                {
                    PlayNode(nodeGoto.Goto);
                }
            }
            else if (currentNode is DialogueNodeBranch)
            {
                var nodeBranch = currentNode as DialogueNodeBranch;

                if (nodeBranch.Conditions.Count > 0 && GetCurrentOptionConditions() == EOptionConditions.AskEveryTime)
                {
                    groupBoxGoto.Visible = true;
                    labelGoto.Text       = String.Format("Branch > \"{0}\"", GetGotoText(nodeBranch.Branch));

                    ShowConditions(nodeBranch);
                }
                else
                {
                    PlayNode(nodeBranch.Branch);
                }
            }
        }
        static public void ExportToPO(string directory, Project project, List <Dialogue> dialogues, Language language, bool workstringOnly, bool workstringFallback)
        {
            string path = Path.Combine(directory, "Dialogues.po");

            var  locas     = new Dictionary <string, POEntry>();
            bool isDefault = workstringOnly || (project.GetDefaultLanguage() == language);

            //Fill existing locas

            /*if (File.Exists(path))
             * {
             *  using (System.IO.StreamReader file = new System.IO.StreamReader(path, Encoding.UTF8))
             *  {
             *      while (!file.EndOfStream)
             *      {
             *          string lineId = file.ReadLine();
             *          if (lineId.StartsWith("msgid"))
             *          {
             *              lineId = lineId.Replace("msgid", "");
             *              lineId = lineId.Trim();
             *              lineId = lineId.Substring(1);
             *              lineId = lineId.Substring(0, lineId.Length - 1);
             *
             *              string lineStr = file.ReadLine();
             *              if (lineStr.StartsWith("msgstr"))
             *              {
             *                  lineStr = lineStr.Replace("msgstr", "");
             *                  lineStr = lineStr.Trim();
             *                  lineStr = lineStr.Substring(1);
             *                  lineStr = lineStr.Substring(0, lineStr.Length - 1);
             *
             *                  if (!locas.ContainsKey(lineId))
             *                      locas.Add(lineId, new POEntry() { text = lineStr });
             *              }
             *          }
             *      }
             *  }
             * }*/

            //Parse texts to localize and fill nodes references
            foreach (Dialogue dialogue in dialogues)
            {
                var orderedListNodes = new List <DialogueNode>();
                dialogue.GetOrderedNodes(ref orderedListNodes);
                foreach (DialogueNode dialogueNode in orderedListNodes)
                {
                    if (dialogueNode is DialogueNodeSentence || dialogueNode is DialogueNodeReply)
                    {
                        string workstring;
                        if (dialogueNode is DialogueNodeSentence)
                        {
                            workstring = (dialogueNode as DialogueNodeSentence).Sentence;
                        }
                        else
                        {
                            workstring = (dialogueNode as DialogueNodeReply).Reply;
                        }

                        POEntry entry;
                        if (!locas.TryGetValue(workstring, out entry))
                        {
                            string localizedText = workstring;
                            if (!workstringOnly)
                            {
                                TranslationEntry translation = dialogue.Translations.GetNodeEntry(dialogueNode, language);
                                if (translation == null)
                                {
                                    if (!workstringFallback)
                                    {
                                        localizedText = "";
                                    }
                                }
                                else
                                {
                                    localizedText = translation.Text;
                                }
                            }

                            localizedText = EditorHelper.FormatTextEntry(localizedText, language);  //language = workstring if workstringOnly

                            entry = new POEntry()
                            {
                                text = localizedText
                            };
                            locas.Add(workstring, entry);
                        }

                        entry.nodes.Add(EditorHelper.GetPrettyNodeID(dialogue, dialogueNode));
                    }
                }
            }

            //Re-write file
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, false, Encoding.UTF8))
            {
                string date = Utility.GetDateAsString(Utility.GetCurrentTime());

                //Header
                file.WriteLine("# Dialogues " + language.Name + " translation.");
                file.WriteLine("# ");
                file.WriteLine("msgid \"\"");
                file.WriteLine("msgstr \"\"");
                file.WriteLine("\"Project-Id-Version: Dialogues\\n\"");
                file.WriteLine("\"POT-Creation-Date: " + date + "\\n\"");
                file.WriteLine("\"PO-Revision-Date: " + date + "\\n\"");
                file.WriteLine("\"Language-Team: \\n\"");
                file.WriteLine("\"Language: " + language.LocalizationCode + "\\n\"");
                file.WriteLine("\"MIME-Version: 1.0\\n\"");
                file.WriteLine("\"Content-Type: text/plain; charset=UTF-8\\n\"");
                file.WriteLine("\"Content-Transfer-Encoding: 8bit\\n\"");
                file.WriteLine("\"Plural-Forms: nplurals=2; plural=(n != 1);\\n\"");
            }

            //Write entries
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, true, Encoding.UTF8))
            {
                foreach (var kvp in locas)
                {
                    if (kvp.Value.nodes.Count > 0)
                    {
                        file.WriteLine("");
                        foreach (string node in kvp.Value.nodes)
                        {
                            file.WriteLine(String.Format("#: {0}", node));
                        }
                        file.WriteLine(String.Format("msgid \"{0}\"", kvp.Key));
                        file.WriteLine(String.Format("msgstr \"{0}\"", kvp.Value.text));
                    }
                }
            }
        }
        public void ResyncAllFiles()
        {
            Clear();

            Project project = ResourcesHandler.Project;

            if (project == null)
            {
                return;
            }

            if (EditorCore.CustomLists["SceneTypes"].Count > 0)
            {
                var sceneTypes = new Dictionary <string, string>();
                sceneTypes.Add("", "");
                foreach (var kvp in EditorCore.CustomLists["SceneTypes"])
                {
                    sceneTypes.Add(kvp.Key, kvp.Value);
                }

                comboBoxSearchSceneType.DataSource    = new BindingSource(sceneTypes, null);
                comboBoxSearchSceneType.ValueMember   = "Key";
                comboBoxSearchSceneType.DisplayMember = "Value";

                comboBoxSearchSceneType.Enabled = true;
            }

            if (project.ListActors.Count > 0)
            {
                var actors = new Dictionary <string, string>();
                actors.Add("", "");
                foreach (var actor in project.ListActors)
                {
                    actors.Add(actor.ID, actor.Name);
                }

                comboBoxSearchActor.DataSource    = new BindingSource(actors, null);
                comboBoxSearchActor.ValueMember   = "Key";
                comboBoxSearchActor.DisplayMember = "Value";

                comboBoxSearchActor.Enabled = true;
            }

            tree.BeginUpdate();

            TreeNode nodeProject = tree.Nodes.Add("Project", String.Format("Project {0}", project.GetName()));

            nodeProject.Tag = project;
            EditorHelper.SetNodeIcon(nodeProject, ENodeIcon.Project);

            foreach (Package package in project.ListPackages)
            {
                TreeNode nodePackage = tree.Nodes.Add(GetPackageKey(package.Name), package.Name);
                nodePackage.Tag = package;
                nodePackage.ContextMenuStrip = menuPackage;
                EditorHelper.SetNodeIcon(nodePackage, ENodeIcon.Package);
            }

            foreach (Dialogue dialogue in ResourcesHandler.GetAllDialogues())
            {
                ResyncFile(dialogue, false);
            }

            tree.EndUpdate();

            //tree.CollapseAll();
            foreach (TreeNode node in tree.Nodes)
            {
                node.Expand();
            }
        }
Exemple #9
0
 static public void FillDefaultImageList()
 {
     DefaultImageList = EditorHelper.CreateDefaultImageList();
 }